build: optimize cli and add eslint
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,887 +0,0 @@
|
||||
// Generated from ./grammar/sql.g4 by ANTLR 4.7.1
|
||||
// jshint ignore: start
|
||||
var antlr4 = require('antlr4/index');
|
||||
// This class defines a complete generic visitor for a parse tree produced by sqlParser.
|
||||
function sqlVisitor() {
|
||||
antlr4.tree.ParseTreeVisitor.call(this);
|
||||
return this;
|
||||
}
|
||||
sqlVisitor.prototype = Object.create(antlr4.tree.ParseTreeVisitor.prototype);
|
||||
sqlVisitor.prototype.constructor = sqlVisitor;
|
||||
// Visit a parse tree produced by sqlParser#singleStatement.
|
||||
sqlVisitor.prototype.visitSingleStatement = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleExpression.
|
||||
sqlVisitor.prototype.visitSingleExpression = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleTableIdentifier.
|
||||
sqlVisitor.prototype.visitSingleTableIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleFunctionIdentifier.
|
||||
sqlVisitor.prototype.visitSingleFunctionIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleDataType.
|
||||
sqlVisitor.prototype.visitSingleDataType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleTableSchema.
|
||||
sqlVisitor.prototype.visitSingleTableSchema = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#statementDefault.
|
||||
sqlVisitor.prototype.visitStatementDefault = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#use.
|
||||
sqlVisitor.prototype.visitUse = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createDatabase.
|
||||
sqlVisitor.prototype.visitCreateDatabase = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setDatabaseProperties.
|
||||
sqlVisitor.prototype.visitSetDatabaseProperties = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dropDatabase.
|
||||
sqlVisitor.prototype.visitDropDatabase = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createTable.
|
||||
sqlVisitor.prototype.visitCreateTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createHiveTable.
|
||||
sqlVisitor.prototype.visitCreateHiveTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createFlinkTable.
|
||||
sqlVisitor.prototype.visitCreateFlinkTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createTableLike.
|
||||
sqlVisitor.prototype.visitCreateTableLike = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#analyze.
|
||||
sqlVisitor.prototype.visitAnalyze = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#addTableColumns.
|
||||
sqlVisitor.prototype.visitAddTableColumns = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#renameTable.
|
||||
sqlVisitor.prototype.visitRenameTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setTableProperties.
|
||||
sqlVisitor.prototype.visitSetTableProperties = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#unsetTableProperties.
|
||||
sqlVisitor.prototype.visitUnsetTableProperties = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#changeColumn.
|
||||
sqlVisitor.prototype.visitChangeColumn = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setTableSerDe.
|
||||
sqlVisitor.prototype.visitSetTableSerDe = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#addTablePartition.
|
||||
sqlVisitor.prototype.visitAddTablePartition = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#renameTablePartition.
|
||||
sqlVisitor.prototype.visitRenameTablePartition = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dropTablePartitions.
|
||||
sqlVisitor.prototype.visitDropTablePartitions = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setTableLocation.
|
||||
sqlVisitor.prototype.visitSetTableLocation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#recoverPartitions.
|
||||
sqlVisitor.prototype.visitRecoverPartitions = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dropTable.
|
||||
sqlVisitor.prototype.visitDropTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createView.
|
||||
sqlVisitor.prototype.visitCreateView = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createTempViewUsing.
|
||||
sqlVisitor.prototype.visitCreateTempViewUsing = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#alterViewQuery.
|
||||
sqlVisitor.prototype.visitAlterViewQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createFunction.
|
||||
sqlVisitor.prototype.visitCreateFunction = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dropFunction.
|
||||
sqlVisitor.prototype.visitDropFunction = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#explain.
|
||||
sqlVisitor.prototype.visitExplain = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showTables.
|
||||
sqlVisitor.prototype.visitShowTables = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showTable.
|
||||
sqlVisitor.prototype.visitShowTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showDatabases.
|
||||
sqlVisitor.prototype.visitShowDatabases = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showTblProperties.
|
||||
sqlVisitor.prototype.visitShowTblProperties = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showColumns.
|
||||
sqlVisitor.prototype.visitShowColumns = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showPartitions.
|
||||
sqlVisitor.prototype.visitShowPartitions = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showFunctions.
|
||||
sqlVisitor.prototype.visitShowFunctions = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showCreateTable.
|
||||
sqlVisitor.prototype.visitShowCreateTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#describeFunction.
|
||||
sqlVisitor.prototype.visitDescribeFunction = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#describeDatabase.
|
||||
sqlVisitor.prototype.visitDescribeDatabase = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#describeTable.
|
||||
sqlVisitor.prototype.visitDescribeTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#refreshTable.
|
||||
sqlVisitor.prototype.visitRefreshTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#refreshResource.
|
||||
sqlVisitor.prototype.visitRefreshResource = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#cacheTable.
|
||||
sqlVisitor.prototype.visitCacheTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#uncacheTable.
|
||||
sqlVisitor.prototype.visitUncacheTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#clearCache.
|
||||
sqlVisitor.prototype.visitClearCache = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#loadData.
|
||||
sqlVisitor.prototype.visitLoadData = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#truncateTable.
|
||||
sqlVisitor.prototype.visitTruncateTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#repairTable.
|
||||
sqlVisitor.prototype.visitRepairTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#manageResource.
|
||||
sqlVisitor.prototype.visitManageResource = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#failNativeCommand.
|
||||
sqlVisitor.prototype.visitFailNativeCommand = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setConfiguration.
|
||||
sqlVisitor.prototype.visitSetConfiguration = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#resetConfiguration.
|
||||
sqlVisitor.prototype.visitResetConfiguration = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#unsupportedHiveNativeCommands.
|
||||
sqlVisitor.prototype.visitUnsupportedHiveNativeCommands = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createTableHeader.
|
||||
sqlVisitor.prototype.visitCreateTableHeader = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#bucketSpec.
|
||||
sqlVisitor.prototype.visitBucketSpec = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#skewSpec.
|
||||
sqlVisitor.prototype.visitSkewSpec = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#locationSpec.
|
||||
sqlVisitor.prototype.visitLocationSpec = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#query.
|
||||
sqlVisitor.prototype.visitQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#insertOverwriteTable.
|
||||
sqlVisitor.prototype.visitInsertOverwriteTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#insertIntoTable.
|
||||
sqlVisitor.prototype.visitInsertIntoTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#insertOverwriteHiveDir.
|
||||
sqlVisitor.prototype.visitInsertOverwriteHiveDir = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#insertOverwriteDir.
|
||||
sqlVisitor.prototype.visitInsertOverwriteDir = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#partitionSpecLocation.
|
||||
sqlVisitor.prototype.visitPartitionSpecLocation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#partitionSpec.
|
||||
sqlVisitor.prototype.visitPartitionSpec = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#partitionVal.
|
||||
sqlVisitor.prototype.visitPartitionVal = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#describeFuncName.
|
||||
sqlVisitor.prototype.visitDescribeFuncName = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#describeColName.
|
||||
sqlVisitor.prototype.visitDescribeColName = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#ctes.
|
||||
sqlVisitor.prototype.visitCtes = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#namedQuery.
|
||||
sqlVisitor.prototype.visitNamedQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableProvider.
|
||||
sqlVisitor.prototype.visitTableProvider = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tablePropertyList.
|
||||
sqlVisitor.prototype.visitTablePropertyList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableProperty.
|
||||
sqlVisitor.prototype.visitTableProperty = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tablePropertyKey.
|
||||
sqlVisitor.prototype.visitTablePropertyKey = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tablePropertyValue.
|
||||
sqlVisitor.prototype.visitTablePropertyValue = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#constantList.
|
||||
sqlVisitor.prototype.visitConstantList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#nestedConstantList.
|
||||
sqlVisitor.prototype.visitNestedConstantList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createFileFormat.
|
||||
sqlVisitor.prototype.visitCreateFileFormat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableFileFormat.
|
||||
sqlVisitor.prototype.visitTableFileFormat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#genericFileFormat.
|
||||
sqlVisitor.prototype.visitGenericFileFormat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#storageHandler.
|
||||
sqlVisitor.prototype.visitStorageHandler = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#resource.
|
||||
sqlVisitor.prototype.visitResource = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleInsertQuery.
|
||||
sqlVisitor.prototype.visitSingleInsertQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#multiInsertQuery.
|
||||
sqlVisitor.prototype.visitMultiInsertQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#queryOrganization.
|
||||
sqlVisitor.prototype.visitQueryOrganization = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#multiInsertQueryBody.
|
||||
sqlVisitor.prototype.visitMultiInsertQueryBody = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#queryTermDefault.
|
||||
sqlVisitor.prototype.visitQueryTermDefault = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setOperation.
|
||||
sqlVisitor.prototype.visitSetOperation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#queryPrimaryDefault.
|
||||
sqlVisitor.prototype.visitQueryPrimaryDefault = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#table.
|
||||
sqlVisitor.prototype.visitTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#inlineTableDefault1.
|
||||
sqlVisitor.prototype.visitInlineTableDefault1 = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#subquery.
|
||||
sqlVisitor.prototype.visitSubquery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sortItem.
|
||||
sqlVisitor.prototype.visitSortItem = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#querySpecification.
|
||||
sqlVisitor.prototype.visitQuerySpecification = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#hint.
|
||||
sqlVisitor.prototype.visitHint = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#hintStatement.
|
||||
sqlVisitor.prototype.visitHintStatement = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#fromClause.
|
||||
sqlVisitor.prototype.visitFromClause = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#aggregation.
|
||||
sqlVisitor.prototype.visitAggregation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#groupingSet.
|
||||
sqlVisitor.prototype.visitGroupingSet = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#pivotClause.
|
||||
sqlVisitor.prototype.visitPivotClause = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#pivotColumn.
|
||||
sqlVisitor.prototype.visitPivotColumn = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#pivotValue.
|
||||
sqlVisitor.prototype.visitPivotValue = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#lateralView.
|
||||
sqlVisitor.prototype.visitLateralView = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setQuantifier.
|
||||
sqlVisitor.prototype.visitSetQuantifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#relation.
|
||||
sqlVisitor.prototype.visitRelation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#joinRelation.
|
||||
sqlVisitor.prototype.visitJoinRelation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#joinType.
|
||||
sqlVisitor.prototype.visitJoinType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#joinCriteria.
|
||||
sqlVisitor.prototype.visitJoinCriteria = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sample.
|
||||
sqlVisitor.prototype.visitSample = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sampleByPercentile.
|
||||
sqlVisitor.prototype.visitSampleByPercentile = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sampleByRows.
|
||||
sqlVisitor.prototype.visitSampleByRows = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sampleByBucket.
|
||||
sqlVisitor.prototype.visitSampleByBucket = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sampleByBytes.
|
||||
sqlVisitor.prototype.visitSampleByBytes = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#identifierList.
|
||||
sqlVisitor.prototype.visitIdentifierList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#identifierSeq.
|
||||
sqlVisitor.prototype.visitIdentifierSeq = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#orderedIdentifierList.
|
||||
sqlVisitor.prototype.visitOrderedIdentifierList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#orderedIdentifier.
|
||||
sqlVisitor.prototype.visitOrderedIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#identifierCommentList.
|
||||
sqlVisitor.prototype.visitIdentifierCommentList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#identifierComment.
|
||||
sqlVisitor.prototype.visitIdentifierComment = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableName.
|
||||
sqlVisitor.prototype.visitTableName = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#aliasedQuery.
|
||||
sqlVisitor.prototype.visitAliasedQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#aliasedRelation.
|
||||
sqlVisitor.prototype.visitAliasedRelation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#inlineTableDefault2.
|
||||
sqlVisitor.prototype.visitInlineTableDefault2 = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableValuedFunction.
|
||||
sqlVisitor.prototype.visitTableValuedFunction = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#matchRecognize.
|
||||
sqlVisitor.prototype.visitMatchRecognize = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#measureColumn.
|
||||
sqlVisitor.prototype.visitMeasureColumn = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#condition1.
|
||||
sqlVisitor.prototype.visitCondition1 = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#variable.
|
||||
sqlVisitor.prototype.visitVariable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#pattern1.
|
||||
sqlVisitor.prototype.visitPattern1 = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#patternTerm.
|
||||
sqlVisitor.prototype.visitPatternTerm = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#patternFactor.
|
||||
sqlVisitor.prototype.visitPatternFactor = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#patternQuantifier.
|
||||
sqlVisitor.prototype.visitPatternQuantifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#minRepeat.
|
||||
sqlVisitor.prototype.visitMinRepeat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#maxRepeat.
|
||||
sqlVisitor.prototype.visitMaxRepeat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#repeat.
|
||||
sqlVisitor.prototype.visitRepeat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#inlineTable.
|
||||
sqlVisitor.prototype.visitInlineTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#functionTable.
|
||||
sqlVisitor.prototype.visitFunctionTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableAlias.
|
||||
sqlVisitor.prototype.visitTableAlias = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#rowFormatSerde.
|
||||
sqlVisitor.prototype.visitRowFormatSerde = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#rowFormatDelimited.
|
||||
sqlVisitor.prototype.visitRowFormatDelimited = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableIdentifier.
|
||||
sqlVisitor.prototype.visitTableIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#functionIdentifier.
|
||||
sqlVisitor.prototype.visitFunctionIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#namedExpression.
|
||||
sqlVisitor.prototype.visitNamedExpression = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#namedExpressionSeq.
|
||||
sqlVisitor.prototype.visitNamedExpressionSeq = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#expression.
|
||||
sqlVisitor.prototype.visitExpression = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#logicalNot.
|
||||
sqlVisitor.prototype.visitLogicalNot = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#predicated.
|
||||
sqlVisitor.prototype.visitPredicated = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#exists.
|
||||
sqlVisitor.prototype.visitExists = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#logicalBinary.
|
||||
sqlVisitor.prototype.visitLogicalBinary = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#predicate.
|
||||
sqlVisitor.prototype.visitPredicate = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#valueExpressionDefault.
|
||||
sqlVisitor.prototype.visitValueExpressionDefault = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#comparison.
|
||||
sqlVisitor.prototype.visitComparison = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#arithmeticBinary.
|
||||
sqlVisitor.prototype.visitArithmeticBinary = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#arithmeticUnary.
|
||||
sqlVisitor.prototype.visitArithmeticUnary = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#struct.
|
||||
sqlVisitor.prototype.visitStruct = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dereference.
|
||||
sqlVisitor.prototype.visitDereference = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#simpleCase.
|
||||
sqlVisitor.prototype.visitSimpleCase = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#columnReference.
|
||||
sqlVisitor.prototype.visitColumnReference = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#rowConstructor.
|
||||
sqlVisitor.prototype.visitRowConstructor = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#last.
|
||||
sqlVisitor.prototype.visitLast = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#star.
|
||||
sqlVisitor.prototype.visitStar = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#subscript.
|
||||
sqlVisitor.prototype.visitSubscript = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#subqueryExpression.
|
||||
sqlVisitor.prototype.visitSubqueryExpression = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#cast.
|
||||
sqlVisitor.prototype.visitCast = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#constantDefault.
|
||||
sqlVisitor.prototype.visitConstantDefault = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#lambda.
|
||||
sqlVisitor.prototype.visitLambda = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#parenthesizedExpression.
|
||||
sqlVisitor.prototype.visitParenthesizedExpression = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#extract.
|
||||
sqlVisitor.prototype.visitExtract = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#functionCall.
|
||||
sqlVisitor.prototype.visitFunctionCall = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#searchedCase.
|
||||
sqlVisitor.prototype.visitSearchedCase = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#position.
|
||||
sqlVisitor.prototype.visitPosition = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#first.
|
||||
sqlVisitor.prototype.visitFirst = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#nullLiteral.
|
||||
sqlVisitor.prototype.visitNullLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#intervalLiteral.
|
||||
sqlVisitor.prototype.visitIntervalLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#typeConstructor.
|
||||
sqlVisitor.prototype.visitTypeConstructor = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#numericLiteral.
|
||||
sqlVisitor.prototype.visitNumericLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#booleanLiteral.
|
||||
sqlVisitor.prototype.visitBooleanLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#stringLiteral.
|
||||
sqlVisitor.prototype.visitStringLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#comparisonOperator.
|
||||
sqlVisitor.prototype.visitComparisonOperator = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#arithmeticOperator.
|
||||
sqlVisitor.prototype.visitArithmeticOperator = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#predicateOperator.
|
||||
sqlVisitor.prototype.visitPredicateOperator = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#booleanValue.
|
||||
sqlVisitor.prototype.visitBooleanValue = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#interval.
|
||||
sqlVisitor.prototype.visitInterval = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#intervalField.
|
||||
sqlVisitor.prototype.visitIntervalField = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#intervalValue.
|
||||
sqlVisitor.prototype.visitIntervalValue = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#colPosition.
|
||||
sqlVisitor.prototype.visitColPosition = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#complexDataType.
|
||||
sqlVisitor.prototype.visitComplexDataType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#primitiveDataType.
|
||||
sqlVisitor.prototype.visitPrimitiveDataType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#colTypeList.
|
||||
sqlVisitor.prototype.visitColTypeList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#colType.
|
||||
sqlVisitor.prototype.visitColType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dtColTypeList.
|
||||
sqlVisitor.prototype.visitDtColTypeList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dtColType.
|
||||
sqlVisitor.prototype.visitDtColType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dtColIdentifier.
|
||||
sqlVisitor.prototype.visitDtColIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#complexColTypeList.
|
||||
sqlVisitor.prototype.visitComplexColTypeList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#complexColType.
|
||||
sqlVisitor.prototype.visitComplexColType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#whenClause.
|
||||
sqlVisitor.prototype.visitWhenClause = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#windows.
|
||||
sqlVisitor.prototype.visitWindows = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#namedWindow.
|
||||
sqlVisitor.prototype.visitNamedWindow = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#windowRef.
|
||||
sqlVisitor.prototype.visitWindowRef = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#windowDef.
|
||||
sqlVisitor.prototype.visitWindowDef = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#windowFrame.
|
||||
sqlVisitor.prototype.visitWindowFrame = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#frameBound.
|
||||
sqlVisitor.prototype.visitFrameBound = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#qualifiedName.
|
||||
sqlVisitor.prototype.visitQualifiedName = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#identifier.
|
||||
sqlVisitor.prototype.visitIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#unquotedIdentifier.
|
||||
sqlVisitor.prototype.visitUnquotedIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#quotedIdentifierAlternative.
|
||||
sqlVisitor.prototype.visitQuotedIdentifierAlternative = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#quotedIdentifier.
|
||||
sqlVisitor.prototype.visitQuotedIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#decimalLiteral.
|
||||
sqlVisitor.prototype.visitDecimalLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#integerLiteral.
|
||||
sqlVisitor.prototype.visitIntegerLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#bigIntLiteral.
|
||||
sqlVisitor.prototype.visitBigIntLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#smallIntLiteral.
|
||||
sqlVisitor.prototype.visitSmallIntLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tinyIntLiteral.
|
||||
sqlVisitor.prototype.visitTinyIntLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#doubleLiteral.
|
||||
sqlVisitor.prototype.visitDoubleLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#bigDecimalLiteral.
|
||||
sqlVisitor.prototype.visitBigDecimalLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#nonReserved.
|
||||
sqlVisitor.prototype.visitNonReserved = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
exports.sqlVisitor = sqlVisitor;
|
@ -1,521 +0,0 @@
|
||||
/*
|
||||
* Generated by PEG.js 0.10.0.
|
||||
*
|
||||
* http://pegjs.org/
|
||||
*/
|
||||
(function (root, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define([], factory);
|
||||
}
|
||||
else if (typeof module === "object" && module.exports) {
|
||||
module.exports = factory();
|
||||
}
|
||||
})(this, function () {
|
||||
"use strict";
|
||||
function peg$subclass(child, parent) {
|
||||
function ctor() { this.constructor = child; }
|
||||
ctor.prototype = parent.prototype;
|
||||
child.prototype = new ctor();
|
||||
}
|
||||
function peg$SyntaxError(message, expected, found, location) {
|
||||
this.message = message;
|
||||
this.expected = expected;
|
||||
this.found = found;
|
||||
this.location = location;
|
||||
this.name = "SyntaxError";
|
||||
if (typeof Error.captureStackTrace === "function") {
|
||||
Error.captureStackTrace(this, peg$SyntaxError);
|
||||
}
|
||||
}
|
||||
peg$subclass(peg$SyntaxError, Error);
|
||||
peg$SyntaxError.buildMessage = function (expected, found) {
|
||||
var DESCRIBE_EXPECTATION_FNS = {
|
||||
literal: function (expectation) {
|
||||
return "\"" + literalEscape(expectation.text) + "\"";
|
||||
},
|
||||
"class": function (expectation) {
|
||||
var escapedParts = "", i;
|
||||
for (i = 0; i < expectation.parts.length; i++) {
|
||||
escapedParts += expectation.parts[i] instanceof Array
|
||||
? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
|
||||
: classEscape(expectation.parts[i]);
|
||||
}
|
||||
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
|
||||
},
|
||||
any: function (expectation) {
|
||||
return "any character";
|
||||
},
|
||||
end: function (expectation) {
|
||||
return "end of input";
|
||||
},
|
||||
other: function (expectation) {
|
||||
return expectation.description;
|
||||
}
|
||||
};
|
||||
function hex(ch) {
|
||||
return ch.charCodeAt(0).toString(16).toUpperCase();
|
||||
}
|
||||
function literalEscape(s) {
|
||||
return s
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/"/g, '\\"')
|
||||
.replace(/\0/g, '\\0')
|
||||
.replace(/\t/g, '\\t')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/[\x00-\x0F]/g, function (ch) { return '\\x0' + hex(ch); })
|
||||
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return '\\x' + hex(ch); });
|
||||
}
|
||||
function classEscape(s) {
|
||||
return s
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/\]/g, '\\]')
|
||||
.replace(/\^/g, '\\^')
|
||||
.replace(/-/g, '\\-')
|
||||
.replace(/\0/g, '\\0')
|
||||
.replace(/\t/g, '\\t')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/[\x00-\x0F]/g, function (ch) { return '\\x0' + hex(ch); })
|
||||
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return '\\x' + hex(ch); });
|
||||
}
|
||||
function describeExpectation(expectation) {
|
||||
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
||||
}
|
||||
function describeExpected(expected) {
|
||||
var descriptions = new Array(expected.length), i, j;
|
||||
for (i = 0; i < expected.length; i++) {
|
||||
descriptions[i] = describeExpectation(expected[i]);
|
||||
}
|
||||
descriptions.sort();
|
||||
if (descriptions.length > 0) {
|
||||
for (i = 1, j = 1; i < descriptions.length; i++) {
|
||||
if (descriptions[i - 1] !== descriptions[i]) {
|
||||
descriptions[j] = descriptions[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
descriptions.length = j;
|
||||
}
|
||||
switch (descriptions.length) {
|
||||
case 1:
|
||||
return descriptions[0];
|
||||
case 2:
|
||||
return descriptions[0] + " or " + descriptions[1];
|
||||
default:
|
||||
return descriptions.slice(0, -1).join(", ")
|
||||
+ ", or "
|
||||
+ descriptions[descriptions.length - 1];
|
||||
}
|
||||
}
|
||||
function describeFound(found) {
|
||||
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
|
||||
}
|
||||
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
||||
};
|
||||
function peg$parse(input, options) {
|
||||
options = options !== void 0 ? options : {};
|
||||
var peg$FAILED = {}, peg$startRuleIndices = { start: 0 }, peg$startRuleIndex = 0, peg$consts = [
|
||||
function (union_stmt) {
|
||||
return { lines, text: union_stmt };
|
||||
},
|
||||
peg$anyExpectation(),
|
||||
function (word) { return word; },
|
||||
function (words, comment) { return ''; },
|
||||
function (words, quote) { return quote; },
|
||||
";",
|
||||
peg$literalExpectation(";", false),
|
||||
function (words) { isSplit = true; return ";"; },
|
||||
function (words, stmt) {
|
||||
const text = words.join("") + stmt;
|
||||
let index = Math.max(lines.length - 1, 0);
|
||||
lines[index] = (lines[index] || '') + text;
|
||||
if (isSplit) {
|
||||
isSplit = false;
|
||||
lines.push('');
|
||||
}
|
||||
return text;
|
||||
},
|
||||
function (stmt, other) {
|
||||
const text = stmt.join("") + other.join("");
|
||||
let index = Math.max(lines.length - 1, 0);
|
||||
lines[index] = lines[index] + other.join("");
|
||||
return text;
|
||||
},
|
||||
function (comment) {
|
||||
return comment;
|
||||
},
|
||||
/^[^\r\n]/,
|
||||
peg$classExpectation(["\r", "\n"], true, false),
|
||||
function (start, words) {
|
||||
return start + words.join("");
|
||||
},
|
||||
"*/",
|
||||
peg$literalExpectation("*/", false),
|
||||
function (start, word) { return word; },
|
||||
function (start, words, end) { return start + words.join("") + end; },
|
||||
"\"",
|
||||
peg$literalExpectation("\"", false),
|
||||
/^[^"]/,
|
||||
peg$classExpectation(["\""], true, false),
|
||||
function (start, words, end) { return start + words.join("") + end; },
|
||||
"'",
|
||||
peg$literalExpectation("'", false),
|
||||
/^[^']/,
|
||||
peg$classExpectation(["'"], true, false),
|
||||
"--",
|
||||
peg$literalExpectation("--", false),
|
||||
/^[\r\n]/,
|
||||
peg$classExpectation(["\r", "\n"], false, false),
|
||||
"/*",
|
||||
peg$literalExpectation("/*", false),
|
||||
/^[ \t\r\n]/,
|
||||
peg$classExpectation([" ", "\t", "\r", "\n"], false, false)
|
||||
], peg$bytecode = [
|
||||
peg$decode("%;!/' 8!: !! )"),
|
||||
peg$decode("%$%$%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#0L*%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#&/j#%;\"/( 8!:#!\"\" ).H &%;%/( 8!:$!\"\" ).5 &%2%\"\"6%7&/' 8!:'!!\")/)$8\":(\"\"! )(\"'#&'#0\xCD*%$%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#0L*%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#&/j#%;\"/( 8!:#!\"\" ).H &%;%/( 8!:$!\"\" ).5 &%2%\"\"6%7&/' 8!:'!!\")/)$8\":(\"\"! )(\"'#&'#&/C#$1\"\"5!7!0(*1\"\"5!7!&/)$8\":)\"\"! )(\"'#&'#"),
|
||||
peg$decode("%;$.# &;#/' 8!:*!! )"),
|
||||
peg$decode("%;'/E#$4+\"\"5!7,0)*4+\"\"5!7,&/)$8\":-\"\"! )(\"'#&'#"),
|
||||
peg$decode("%;)/\xA3#$%%<2.\"\"6.7/=.##&&!&'#/7#1\"\"5!7!/)$8\":0\"\"$ )(\"'#&'#0S*%%<2.\"\"6.7/=.##&&!&'#/7#1\"\"5!7!/)$8\":0\"\"$ )(\"'#&'#&/3$;*/*$8#:1##\"! )(#'#(\"'#&'#"),
|
||||
peg$decode("%22\"\"6273/U#$44\"\"5!750)*44\"\"5!75&/9$22\"\"6273/*$8#:6##\"! )(#'#(\"'#&'#.e &%27\"\"6778/U#$49\"\"5!7:0)*49\"\"5!7:&/9$27\"\"6778/*$8#:6##\"! )(#'#(\"'#&'#"),
|
||||
peg$decode(";'.G &;).A &22\"\"6273.5 &27\"\"6778.) &2%\"\"6%7&"),
|
||||
peg$decode("2;\"\"6;7<"),
|
||||
peg$decode("4=\"\"5!7>"),
|
||||
peg$decode("2?\"\"6?7@"),
|
||||
peg$decode("2.\"\"6.7/"),
|
||||
peg$decode("$;,0#*;,&"),
|
||||
peg$decode("4A\"\"5!7B")
|
||||
], peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$result;
|
||||
if ("startRule" in options) {
|
||||
if (!(options.startRule in peg$startRuleIndices)) {
|
||||
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
|
||||
}
|
||||
peg$startRuleIndex = peg$startRuleIndices[options.startRule];
|
||||
}
|
||||
function text() {
|
||||
return input.substring(peg$savedPos, peg$currPos);
|
||||
}
|
||||
function location() {
|
||||
return peg$computeLocation(peg$savedPos, peg$currPos);
|
||||
}
|
||||
function expected(description, location) {
|
||||
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
|
||||
throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location);
|
||||
}
|
||||
function error(message, location) {
|
||||
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
|
||||
throw peg$buildSimpleError(message, location);
|
||||
}
|
||||
function peg$literalExpectation(text, ignoreCase) {
|
||||
return { type: "literal", text: text, ignoreCase: ignoreCase };
|
||||
}
|
||||
function peg$classExpectation(parts, inverted, ignoreCase) {
|
||||
return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
|
||||
}
|
||||
function peg$anyExpectation() {
|
||||
return { type: "any" };
|
||||
}
|
||||
function peg$endExpectation() {
|
||||
return { type: "end" };
|
||||
}
|
||||
function peg$otherExpectation(description) {
|
||||
return { type: "other", description: description };
|
||||
}
|
||||
function peg$computePosDetails(pos) {
|
||||
var details = peg$posDetailsCache[pos], p;
|
||||
if (details) {
|
||||
return details;
|
||||
}
|
||||
else {
|
||||
p = pos - 1;
|
||||
while (!peg$posDetailsCache[p]) {
|
||||
p--;
|
||||
}
|
||||
details = peg$posDetailsCache[p];
|
||||
details = {
|
||||
line: details.line,
|
||||
column: details.column
|
||||
};
|
||||
while (p < pos) {
|
||||
if (input.charCodeAt(p) === 10) {
|
||||
details.line++;
|
||||
details.column = 1;
|
||||
}
|
||||
else {
|
||||
details.column++;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
peg$posDetailsCache[pos] = details;
|
||||
return details;
|
||||
}
|
||||
}
|
||||
function peg$computeLocation(startPos, endPos) {
|
||||
var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos);
|
||||
return {
|
||||
start: {
|
||||
offset: startPos,
|
||||
line: startPosDetails.line,
|
||||
column: startPosDetails.column
|
||||
},
|
||||
end: {
|
||||
offset: endPos,
|
||||
line: endPosDetails.line,
|
||||
column: endPosDetails.column
|
||||
}
|
||||
};
|
||||
}
|
||||
function peg$fail(expected) {
|
||||
if (peg$currPos < peg$maxFailPos) {
|
||||
return;
|
||||
}
|
||||
if (peg$currPos > peg$maxFailPos) {
|
||||
peg$maxFailPos = peg$currPos;
|
||||
peg$maxFailExpected = [];
|
||||
}
|
||||
peg$maxFailExpected.push(expected);
|
||||
}
|
||||
function peg$buildSimpleError(message, location) {
|
||||
return new peg$SyntaxError(message, null, null, location);
|
||||
}
|
||||
function peg$buildStructuredError(expected, found, location) {
|
||||
return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
|
||||
}
|
||||
function peg$decode(s) {
|
||||
var bc = new Array(s.length), i;
|
||||
for (i = 0; i < s.length; i++) {
|
||||
bc[i] = s.charCodeAt(i) - 32;
|
||||
}
|
||||
return bc;
|
||||
}
|
||||
function peg$parseRule(index) {
|
||||
var bc = peg$bytecode[index], ip = 0, ips = [], end = bc.length, ends = [], stack = [], params, i;
|
||||
while (true) {
|
||||
while (ip < end) {
|
||||
switch (bc[ip]) {
|
||||
case 0:
|
||||
stack.push(peg$consts[bc[ip + 1]]);
|
||||
ip += 2;
|
||||
break;
|
||||
case 1:
|
||||
stack.push(void 0);
|
||||
ip++;
|
||||
break;
|
||||
case 2:
|
||||
stack.push(null);
|
||||
ip++;
|
||||
break;
|
||||
case 3:
|
||||
stack.push(peg$FAILED);
|
||||
ip++;
|
||||
break;
|
||||
case 4:
|
||||
stack.push([]);
|
||||
ip++;
|
||||
break;
|
||||
case 5:
|
||||
stack.push(peg$currPos);
|
||||
ip++;
|
||||
break;
|
||||
case 6:
|
||||
stack.pop();
|
||||
ip++;
|
||||
break;
|
||||
case 7:
|
||||
peg$currPos = stack.pop();
|
||||
ip++;
|
||||
break;
|
||||
case 8:
|
||||
stack.length -= bc[ip + 1];
|
||||
ip += 2;
|
||||
break;
|
||||
case 9:
|
||||
stack.splice(-2, 1);
|
||||
ip++;
|
||||
break;
|
||||
case 10:
|
||||
stack[stack.length - 2].push(stack.pop());
|
||||
ip++;
|
||||
break;
|
||||
case 11:
|
||||
stack.push(stack.splice(stack.length - bc[ip + 1], bc[ip + 1]));
|
||||
ip += 2;
|
||||
break;
|
||||
case 12:
|
||||
stack.push(input.substring(stack.pop(), peg$currPos));
|
||||
ip++;
|
||||
break;
|
||||
case 13:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
if (stack[stack.length - 1]) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
}
|
||||
else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
if (stack[stack.length - 1] === peg$FAILED) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
}
|
||||
else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
if (stack[stack.length - 1] !== peg$FAILED) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
}
|
||||
else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
if (stack[stack.length - 1] !== peg$FAILED) {
|
||||
ends.push(end);
|
||||
ips.push(ip);
|
||||
end = ip + 2 + bc[ip + 1];
|
||||
ip += 2;
|
||||
}
|
||||
else {
|
||||
ip += 2 + bc[ip + 1];
|
||||
}
|
||||
break;
|
||||
case 17:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
if (input.length > peg$currPos) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
}
|
||||
else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
ends.push(end);
|
||||
ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]);
|
||||
if (input.substr(peg$currPos, peg$consts[bc[ip + 1]].length) === peg$consts[bc[ip + 1]]) {
|
||||
end = ip + 4 + bc[ip + 2];
|
||||
ip += 4;
|
||||
}
|
||||
else {
|
||||
end = ip + 4 + bc[ip + 2] + bc[ip + 3];
|
||||
ip += 4 + bc[ip + 2];
|
||||
}
|
||||
break;
|
||||
case 19:
|
||||
ends.push(end);
|
||||
ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]);
|
||||
if (input.substr(peg$currPos, peg$consts[bc[ip + 1]].length).toLowerCase() === peg$consts[bc[ip + 1]]) {
|
||||
end = ip + 4 + bc[ip + 2];
|
||||
ip += 4;
|
||||
}
|
||||
else {
|
||||
end = ip + 4 + bc[ip + 2] + bc[ip + 3];
|
||||
ip += 4 + bc[ip + 2];
|
||||
}
|
||||
break;
|
||||
case 20:
|
||||
ends.push(end);
|
||||
ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]);
|
||||
if (peg$consts[bc[ip + 1]].test(input.charAt(peg$currPos))) {
|
||||
end = ip + 4 + bc[ip + 2];
|
||||
ip += 4;
|
||||
}
|
||||
else {
|
||||
end = ip + 4 + bc[ip + 2] + bc[ip + 3];
|
||||
ip += 4 + bc[ip + 2];
|
||||
}
|
||||
break;
|
||||
case 21:
|
||||
stack.push(input.substr(peg$currPos, bc[ip + 1]));
|
||||
peg$currPos += bc[ip + 1];
|
||||
ip += 2;
|
||||
break;
|
||||
case 22:
|
||||
stack.push(peg$consts[bc[ip + 1]]);
|
||||
peg$currPos += peg$consts[bc[ip + 1]].length;
|
||||
ip += 2;
|
||||
break;
|
||||
case 23:
|
||||
stack.push(peg$FAILED);
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$consts[bc[ip + 1]]);
|
||||
}
|
||||
ip += 2;
|
||||
break;
|
||||
case 24:
|
||||
peg$savedPos = stack[stack.length - 1 - bc[ip + 1]];
|
||||
ip += 2;
|
||||
break;
|
||||
case 25:
|
||||
peg$savedPos = peg$currPos;
|
||||
ip++;
|
||||
break;
|
||||
case 26:
|
||||
params = bc.slice(ip + 4, ip + 4 + bc[ip + 3]);
|
||||
for (i = 0; i < bc[ip + 3]; i++) {
|
||||
params[i] = stack[stack.length - 1 - params[i]];
|
||||
}
|
||||
stack.splice(stack.length - bc[ip + 2], bc[ip + 2], peg$consts[bc[ip + 1]].apply(null, params));
|
||||
ip += 4 + bc[ip + 3];
|
||||
break;
|
||||
case 27:
|
||||
stack.push(peg$parseRule(bc[ip + 1]));
|
||||
ip += 2;
|
||||
break;
|
||||
case 28:
|
||||
peg$silentFails++;
|
||||
ip++;
|
||||
break;
|
||||
case 29:
|
||||
peg$silentFails--;
|
||||
ip++;
|
||||
break;
|
||||
default:
|
||||
throw new Error("Invalid opcode: " + bc[ip] + ".");
|
||||
}
|
||||
}
|
||||
if (ends.length > 0) {
|
||||
end = ends.pop();
|
||||
ip = ips.pop();
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return stack[0];
|
||||
}
|
||||
let lines = [];
|
||||
let isSplit = false;
|
||||
peg$result = peg$parseRule(peg$startRuleIndex);
|
||||
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
||||
return peg$result;
|
||||
}
|
||||
else {
|
||||
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
||||
peg$fail(peg$endExpectation());
|
||||
}
|
||||
throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length
|
||||
? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
|
||||
: peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
|
||||
}
|
||||
}
|
||||
return {
|
||||
SyntaxError: peg$SyntaxError,
|
||||
parse: peg$parse
|
||||
};
|
||||
});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,84 +0,0 @@
|
||||
"use strict";
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* AUTOCOMPLETE_MODULES and SYNTAX_MODULES are generated, do not edit manually, see tools/jison/generateParsers.js
|
||||
*/
|
||||
const AUTOCOMPLETE_MODULES = {
|
||||
calcite: require("calcite/calciteAutocompleteParser"),
|
||||
druid: require("druid/druidAutocompleteParser"),
|
||||
elasticsearch: require("elasticsearch/elasticsearchAutocompleteParser"),
|
||||
flink: require("flink/flinkAutocompleteParser"),
|
||||
generic: require("generic/genericAutocompleteParser"),
|
||||
hive: require("hive/hiveAutocompleteParser"),
|
||||
impala: require("impala/impalaAutocompleteParser"),
|
||||
ksql: require("ksql/ksqlAutocompleteParser"),
|
||||
phoenix: require("phoenix/phoenixAutocompleteParser"),
|
||||
presto: require("presto/prestoAutocompleteParser")
|
||||
};
|
||||
const SYNTAX_MODULES = {
|
||||
calcite: require("calcite/calciteSyntaxParser"),
|
||||
druid: require("druid/druidSyntaxParser"),
|
||||
elasticsearch: require("elasticsearch/elasticsearchSyntaxParser"),
|
||||
flink: require("flink/flinkSyntaxParser"),
|
||||
generic: require("generic/genericSyntaxParser"),
|
||||
hive: require("hive/hiveSyntaxParser"),
|
||||
impala: require("impala/impalaSyntaxParser"),
|
||||
ksql: require("ksql/ksqlSyntaxParser"),
|
||||
phoenix: require("phoenix/phoenixSyntaxParser"),
|
||||
presto: require("presto/prestoSyntaxParser")
|
||||
};
|
||||
/* eslint-enable */
|
||||
class SqlParserRepository {
|
||||
constructor() {
|
||||
this.modulePromises = {};
|
||||
}
|
||||
getParser(sourceType, parserType) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!this.modulePromises[sourceType + parserType]) {
|
||||
const modules = parserType === 'Autocomplete' ? AUTOCOMPLETE_MODULES : SYNTAX_MODULES;
|
||||
this.modulePromises[sourceType + parserType] = new Promise((resolve, reject) => {
|
||||
const targetModule = modules[sourceType] || modules.generic;
|
||||
resolve(targetModule);
|
||||
});
|
||||
}
|
||||
return this.modulePromises[sourceType + parserType];
|
||||
});
|
||||
}
|
||||
getAutocompleter(sourceType) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.getParser(sourceType, 'Autocomplete');
|
||||
});
|
||||
}
|
||||
getSyntaxParser(sourceType) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.getParser(sourceType, 'Syntax');
|
||||
});
|
||||
}
|
||||
}
|
||||
const sqlParserRepository = new SqlParserRepository();
|
||||
exports.default = sqlParserRepository;
|
@ -1,75 +0,0 @@
|
||||
"use strict";
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* Calculates the Optimal String Alignment distance between two strings. Returns 0 when the strings are equal and the
|
||||
* distance when not, distances is less than or equal to the length of the longest string.
|
||||
*
|
||||
* @param strA
|
||||
* @param strB
|
||||
* @param [ignoreCase]
|
||||
* @returns {number} The similarity
|
||||
*/
|
||||
const stringDistance = function (strA, strB, ignoreCase) {
|
||||
if (ignoreCase) {
|
||||
strA = strA.toLowerCase();
|
||||
strB = strB.toLowerCase();
|
||||
}
|
||||
// TODO: Consider other algorithms for performance
|
||||
const strALength = strA.length;
|
||||
const strBLength = strB.length;
|
||||
if (strALength === 0) {
|
||||
return strBLength;
|
||||
}
|
||||
if (strBLength === 0) {
|
||||
return strALength;
|
||||
}
|
||||
const distances = new Array(strALength);
|
||||
let cost, deletion, insertion, substitution, transposition;
|
||||
for (let i = 0; i <= strALength; i++) {
|
||||
distances[i] = new Array(strBLength);
|
||||
distances[i][0] = i;
|
||||
for (let j = 1; j <= strBLength; j++) {
|
||||
if (!i) {
|
||||
distances[0][j] = j;
|
||||
}
|
||||
else {
|
||||
cost = strA[i - 1] === strB[j - 1] ? 0 : 1;
|
||||
deletion = distances[i - 1][j] + 1;
|
||||
insertion = distances[i][j - 1] + 1;
|
||||
substitution = distances[i - 1][j - 1] + cost;
|
||||
if (deletion <= insertion && deletion <= substitution) {
|
||||
distances[i][j] = deletion;
|
||||
}
|
||||
else if (insertion <= deletion && insertion <= substitution) {
|
||||
distances[i][j] = insertion;
|
||||
}
|
||||
else {
|
||||
distances[i][j] = substitution;
|
||||
}
|
||||
if (i > 1 && j > 1 && strA[i] === strB[j - 1] && strA[i - 1] === strB[j]) {
|
||||
transposition = distances[i - 2][j - 2] + cost;
|
||||
if (transposition < distances[i][j]) {
|
||||
distances[i][j] = transposition;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return distances[strALength][strBLength];
|
||||
};
|
||||
exports.default = stringDistance;
|
18
lib/index.js
18
lib/index.js
@ -1,8 +1,14 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const parser = require("./lib/parser");
|
||||
exports.parser = parser;
|
||||
const filter = require("./lib/filter");
|
||||
exports.filter = filter;
|
||||
const flinkParser_1 = require("./lib/flinkParser");
|
||||
exports.flinksqlParser = flinkParser_1.default;
|
||||
__exportStar(require("./core"), exports);
|
||||
__exportStar(require("./utils"), exports);
|
||||
|
@ -1,27 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const commentFilter = require("../core/comment");
|
||||
/**
|
||||
* 过滤--注释
|
||||
* @param {String} sql
|
||||
*/
|
||||
function filterComments(sql) {
|
||||
return commentFilter.parse(sql).text;
|
||||
}
|
||||
exports.filterComments = filterComments;
|
||||
/**
|
||||
* 清除注释和前后空格
|
||||
* @param {String} sql
|
||||
*/
|
||||
function cleanSql(sql) {
|
||||
return filterComments(sql);
|
||||
}
|
||||
exports.cleanSql = cleanSql;
|
||||
/**
|
||||
* 分割sql
|
||||
* @param {String} sql
|
||||
*/
|
||||
function splitSql(sql) {
|
||||
return commentFilter.parse(sql).lines;
|
||||
}
|
||||
exports.splitSql = splitSql;
|
@ -1,53 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const antlr4 = require("antlr4");
|
||||
const error_1 = require("antlr4/error");
|
||||
const sqlLexer_1 = require("../antlr4/flinksql/sqlLexer");
|
||||
const sqlParser_1 = require("../antlr4/flinksql/sqlParser");
|
||||
const utils_1 = require("../utils");
|
||||
class SqlErrorListener extends error_1.ErrorListener {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.error = null;
|
||||
}
|
||||
syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
|
||||
this.error = {
|
||||
line,
|
||||
column: charPositionInLine,
|
||||
token: offendingSymbol,
|
||||
errorMsg: msg
|
||||
};
|
||||
}
|
||||
}
|
||||
function parserSingle(sql) {
|
||||
if (!sql || !sql.trim()) {
|
||||
return null;
|
||||
}
|
||||
const inputStream = new antlr4.InputStream(sql.toUpperCase());
|
||||
const lexer = new sqlLexer_1.sqlLexer(inputStream);
|
||||
const tokenStream = new antlr4.CommonTokenStream(lexer);
|
||||
const parser = new sqlParser_1.sqlParser(tokenStream);
|
||||
parser.buildParseTrees = true;
|
||||
let listener = new SqlErrorListener();
|
||||
parser.addErrorListener(listener);
|
||||
parser.singleStatement();
|
||||
return listener.error;
|
||||
}
|
||||
function parserSyntax(sql) {
|
||||
let runSql = typeof sql == 'string' ? sql : sql.join('');
|
||||
const sqls = utils_1.splitSql(runSql);
|
||||
for (let i = 0, index = 0; i < sqls.length; i++) {
|
||||
let end = runSql[sqls[i]] == ';' ? sqls[i] : sqls[i] + 1;
|
||||
/**
|
||||
* 这边不取分号
|
||||
*/
|
||||
let sql = new Array(index).fill(' ').join('') + runSql.substring(index, end);
|
||||
let err = parserSingle(sql);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
index = sqls[i] + 1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
exports.default = parserSyntax;
|
@ -1,76 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// import * as sqlSyntaxParser from '../core/sqlSyntaxParser';
|
||||
const hiveSyntaxParser_1 = require("../core/parse/hive/hiveSyntaxParser");
|
||||
const hiveAutocompleteParser_1 = require("../core/parse/hive/hiveAutocompleteParser");
|
||||
const impalaSyntaxParser_1 = require("../core/parse/impala/impalaSyntaxParser");
|
||||
const impalaAutocompleteParser_1 = require("../core/parse/impala/impalaAutocompleteParser");
|
||||
const genericSyntaxParser_1 = require("../core/parse/generic/genericSyntaxParser");
|
||||
const genericAutocompleteParser_1 = require("../core/parse/generic/genericAutocompleteParser");
|
||||
function getSyntaxParser(type) {
|
||||
switch (type) {
|
||||
case sqlType.Hive: {
|
||||
return hiveSyntaxParser_1.default;
|
||||
}
|
||||
case sqlType.Impala: {
|
||||
return impalaSyntaxParser_1.default;
|
||||
}
|
||||
case sqlType.None: {
|
||||
return genericSyntaxParser_1.default;
|
||||
}
|
||||
default: {
|
||||
return hiveSyntaxParser_1.default;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getAutoCompleteParser(type) {
|
||||
switch (type) {
|
||||
case sqlType.Hive: {
|
||||
return hiveAutocompleteParser_1.default;
|
||||
}
|
||||
case sqlType.Impala: {
|
||||
return impalaAutocompleteParser_1.default;
|
||||
}
|
||||
case sqlType.None: {
|
||||
return genericAutocompleteParser_1.default;
|
||||
}
|
||||
default: {
|
||||
return hiveAutocompleteParser_1.default;
|
||||
}
|
||||
}
|
||||
}
|
||||
var sqlType;
|
||||
(function (sqlType) {
|
||||
sqlType["Hive"] = "hive";
|
||||
sqlType["None"] = "sql";
|
||||
sqlType["Impala"] = "impala";
|
||||
})(sqlType || (sqlType = {}));
|
||||
exports.sqlType = sqlType;
|
||||
function sqlToParserArgs(sql) {
|
||||
let preSql = '', sufSql = '';
|
||||
if (Object.prototype.toString.call(sql) == '[object Array]') {
|
||||
preSql = sql[0];
|
||||
sufSql = sql[1];
|
||||
}
|
||||
else {
|
||||
preSql = sql;
|
||||
}
|
||||
return [preSql, sufSql];
|
||||
}
|
||||
/**
|
||||
* 校验语法
|
||||
*/
|
||||
function parseSyntax(sql, type = sqlType.Hive) {
|
||||
const parserArgs = sqlToParserArgs(sql);
|
||||
console.log(getSyntaxParser(type));
|
||||
return getSyntaxParser(type).parseSyntax(parserArgs[0], parserArgs[1], type, false);
|
||||
}
|
||||
exports.parseSyntax = parseSyntax;
|
||||
/**
|
||||
* 自动补全提示
|
||||
*/
|
||||
function parserSql(sql, type = sqlType.Hive) {
|
||||
const parserArgs = sqlToParserArgs(sql);
|
||||
return getAutoCompleteParser(type).parseSql(parserArgs[0], parserArgs[1], type, false);
|
||||
}
|
||||
exports.parserSql = parserSql;
|
@ -1,467 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const exec = require('child_process').exec;
|
||||
const LICENSE = '// Licensed to Cloudera, Inc. under one\n' +
|
||||
'// or more contributor license agreements. See the NOTICE file\n' +
|
||||
'// distributed with this work for additional information\n' +
|
||||
'// regarding copyright ownership. Cloudera, Inc. licenses this file\n' +
|
||||
'// to you under the Apache License, Version 2.0 (the\n' +
|
||||
'// "License"); you may not use this file except in compliance\n' +
|
||||
'// with the License. You may obtain a copy of the License at\n' +
|
||||
'//\n' +
|
||||
'// http://www.apache.org/licenses/LICENSE-2.0\n' +
|
||||
'//\n' +
|
||||
'// Unless required by applicable law or agreed to in writing, software\n' +
|
||||
'// distributed under the License is distributed on an "AS IS" BASIS,\n' +
|
||||
'// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n' +
|
||||
'// See the License for the specific language governing permissions and\n' +
|
||||
'// limitations under the License.\n';
|
||||
const SQL_STATEMENTS_PARSER_JSDOC = '/**\n' +
|
||||
' * @param {string} input\n' +
|
||||
' *\n' +
|
||||
' * @return {SqlStatementsParserResult}\n' +
|
||||
' */\n';
|
||||
const PARSER_FOLDER = path.join(process.cwd(), 'src/core/parse/');
|
||||
const JISON_FOLDER = path.join(process.cwd(), 'src/jison/');
|
||||
const SQL_PARSER_REPOSITORY_PATH = path.join(PARSER_FOLDER, 'sqlParserRepository.js');
|
||||
const SYNTAX_PARSER_IMPORT_TEMPLATE = ' KEY: require("KEY/KEYSyntaxParser")';
|
||||
const AUTOCOMPLETE_PARSER_IMPORT_TEMPLATE = ' KEY: require("KEY/KEYAutocompleteParser")';
|
||||
const parserDefinitions = {
|
||||
globalSearchParser: {
|
||||
sources: [path.join(JISON_FOLDER, 'globalSearchParser.jison')],
|
||||
target: path.join(JISON_FOLDER, 'globalSearchParser.jison'),
|
||||
outputFolder: PARSER_FOLDER,
|
||||
afterParse: contents => new Promise(resolve => {
|
||||
resolve(LICENSE +
|
||||
contents.replace('var globalSearchParser = ', "import SqlParseSupport from './sqlParseSupport';\n\nvar globalSearchParser = ") +
|
||||
'\nexport default globalSearchParser;\n');
|
||||
})
|
||||
},
|
||||
solrFormulaParser: {
|
||||
sources: [path.join(JISON_FOLDER, 'solrFormulaParser.jison')],
|
||||
target: path.join(JISON_FOLDER, 'solrFormulaParser.jison'),
|
||||
outputFolder: PARSER_FOLDER,
|
||||
afterParse: contents => new Promise(resolve => {
|
||||
resolve(LICENSE + contents + 'export default solrFormulaParser;\n');
|
||||
})
|
||||
},
|
||||
solrQueryParser: {
|
||||
sources: [path.join(JISON_FOLDER, 'solrQueryParser.jison')],
|
||||
target: path.join(JISON_FOLDER, 'solrQueryParser.jison'),
|
||||
outputFolder: PARSER_FOLDER,
|
||||
afterParse: contents => new Promise(resolve => {
|
||||
resolve(LICENSE + contents + 'export default solrQueryParser;\n');
|
||||
})
|
||||
},
|
||||
sqlStatementsParser: {
|
||||
sources: [path.join(JISON_FOLDER, 'sqlStatementsParser.jison')],
|
||||
target: path.join(JISON_FOLDER, 'sqlStatementsParser.jison'),
|
||||
outputFolder: PARSER_FOLDER,
|
||||
afterParse: contents => new Promise(resolve => {
|
||||
resolve(LICENSE +
|
||||
contents.replace('parse: function parse', SQL_STATEMENTS_PARSER_JSDOC + 'parse: function parse') +
|
||||
'export default sqlStatementsParser;\n');
|
||||
})
|
||||
}
|
||||
};
|
||||
const mkdir = path => new Promise((resolve, reject) => {
|
||||
if (fs.existsSync(path)) {
|
||||
resolve();
|
||||
}
|
||||
else {
|
||||
fs.mkdir(path, err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
const readFile = path => new Promise((resolve, reject) => {
|
||||
fs.readFile(path, (err, buf) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
resolve(buf ? buf.toString() : '');
|
||||
});
|
||||
});
|
||||
const writeFile = (path, contents) => new Promise((resolve, reject) => {
|
||||
fs.writeFile(path, contents, err => {
|
||||
if (err) {
|
||||
reject();
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
const copyFile = (source, destination, contentsCallback) => new Promise((resolve, reject) => {
|
||||
readFile(source)
|
||||
.then(contents => {
|
||||
writeFile(destination, contentsCallback ? contentsCallback(contents) : contents)
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
const deleteFile = path => {
|
||||
fs.unlinkSync(path);
|
||||
};
|
||||
const execCmd = cmd => new Promise((resolve, reject) => {
|
||||
exec(cmd, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject('stderr:\n' + stderr + '\n\nstdout:\n' + stdout);
|
||||
}
|
||||
resolve(stdout);
|
||||
});
|
||||
});
|
||||
const generateParser = parserName => new Promise((resolve, reject) => {
|
||||
const parserConfig = parserDefinitions[parserName];
|
||||
/**
|
||||
* 合并jison文件,生成待编译文件
|
||||
*/
|
||||
const concatPromise = new Promise((resolve, reject) => {
|
||||
if (parserConfig.sources.length > 1 && parserConfig.target) {
|
||||
console.log('Concatenating files...');
|
||||
const promises = parserConfig.sources.map(fileName => readFile(fileName));
|
||||
Promise.all(promises)
|
||||
.then(contents => {
|
||||
writeFile(parserConfig.target, contents.join('')).then(() => {
|
||||
resolve(parserConfig.target);
|
||||
});
|
||||
})
|
||||
.catch(reject);
|
||||
}
|
||||
else if (parserConfig.sources.length === 1) {
|
||||
resolve(parserConfig.sources[0]);
|
||||
}
|
||||
else {
|
||||
reject('No jison source specified');
|
||||
}
|
||||
});
|
||||
concatPromise
|
||||
.then(targetPath => {
|
||||
console.log(`Generate precomplier jison success(${targetPath})...`);
|
||||
let jisonCommand = 'jison ' + targetPath;
|
||||
if (parserConfig.lexer) {
|
||||
jisonCommand += ' ' + parserConfig.lexer;
|
||||
}
|
||||
jisonCommand += ' -m js';
|
||||
console.log('Generating parser...');
|
||||
execCmd(jisonCommand)
|
||||
.then(stdout => {
|
||||
if (/\S/.test(stdout)) {
|
||||
console.log('got output for: ' + jisonCommand);
|
||||
console.log(stdout);
|
||||
}
|
||||
if (parserConfig.sources.length > 1) {
|
||||
deleteFile(targetPath); // Remove concatenated file
|
||||
}
|
||||
console.log('Adjusting JS...');
|
||||
/**
|
||||
* 删除生成文件,复制到配置的文件夹中
|
||||
*/
|
||||
const generatedJsFileName = parserConfig.target
|
||||
.replace('.jison', '.js')
|
||||
.replace(/^.*\/([^/]+)$/, '$1');
|
||||
readFile(generatedJsFileName)
|
||||
.then(contents => {
|
||||
parserConfig
|
||||
.afterParse(contents)
|
||||
.then(finalContents => {
|
||||
writeFile(path.join(parserConfig.outputFolder, generatedJsFileName), finalContents)
|
||||
.then(() => {
|
||||
deleteFile(generatedJsFileName);
|
||||
resolve();
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
let parsersToGenerate = [];
|
||||
const invalid = [];
|
||||
let all = false;
|
||||
const listDir = folder => new Promise(resolve => {
|
||||
fs.readdir(folder, (err, files) => {
|
||||
resolve(files);
|
||||
});
|
||||
});
|
||||
/**
|
||||
* 构造,添加子语言模块编译配置
|
||||
* @param {*} fileIndex 文件的存在表
|
||||
* @param {*} folder 对应的子语言文件夹
|
||||
* @param {*} sharedFiles 子语言核心jison文件
|
||||
* @param {*} autocomplete 是否为补全文件
|
||||
*/
|
||||
const findParser = (fileIndex, folder, sharedFiles, autocomplete) => {
|
||||
const prefix = autocomplete ? 'autocomplete' : 'syntax';
|
||||
if (fileIndex[prefix + '_header.jison'] && fileIndex[prefix + '_footer.jison']) {
|
||||
const parserName = folder + (autocomplete ? 'AutocompleteParser' : 'SyntaxParser');
|
||||
const parserDefinition = {
|
||||
sources: [path.join(JISON_FOLDER, 'sql', folder, prefix + '_header.jison')].concat(sharedFiles),
|
||||
lexer: path.join(JISON_FOLDER, 'sql', folder, '/sql.jisonlex'),
|
||||
target: path.join(JISON_FOLDER, 'sql', folder, parserName + '.jison'),
|
||||
sqlParser: autocomplete ? 'AUTOCOMPLETE' : 'SYNTAX',
|
||||
outputFolder: path.join(PARSER_FOLDER, folder),
|
||||
afterParse: contents => new Promise(resolve => {
|
||||
resolve(LICENSE +
|
||||
contents
|
||||
.replace('var ' + parserName + ' = ', "import SqlParseSupport from " +
|
||||
"'./sqlParseSupport';\n\nvar " +
|
||||
parserName +
|
||||
' = ')
|
||||
.replace('loc: yyloc,', "loc: lexer.yylloc, ruleId: stack.slice(stack.length - 2, stack.length).join(''),") +
|
||||
'\nexport default ' +
|
||||
parserName +
|
||||
';\n');
|
||||
})
|
||||
};
|
||||
parserDefinition.sources.push(path.join(JISON_FOLDER, 'sql', folder, prefix + '_footer.jison'));
|
||||
parserDefinitions[parserName] = parserDefinition;
|
||||
}
|
||||
else {
|
||||
console.log("Warn: Could not find '" +
|
||||
prefix +
|
||||
"_header.jison' or '" +
|
||||
prefix +
|
||||
"_footer.jison' in " +
|
||||
JISON_FOLDER +
|
||||
'sql/' +
|
||||
folder +
|
||||
'/');
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 添加所有子语言编译配置
|
||||
*/
|
||||
const identifySqlParsers = () => new Promise(resolve => {
|
||||
listDir(JISON_FOLDER + 'sql').then(files => {
|
||||
const promises = [];
|
||||
files.forEach(folder => {
|
||||
const subLanguageJisonFolder = path.join(JISON_FOLDER, 'sql', folder);
|
||||
promises.push(
|
||||
/**
|
||||
* 遍历具体的语言目录
|
||||
*/
|
||||
listDir(subLanguageJisonFolder).then(jisonFiles => {
|
||||
/**
|
||||
* 文件目录记录表
|
||||
*/
|
||||
const fileIndex = {};
|
||||
jisonFiles.forEach(jisonFile => {
|
||||
fileIndex[jisonFile] = true;
|
||||
});
|
||||
/**
|
||||
* 挑选核心的jison文件(剥除autocomplate,syntax的功能文件)
|
||||
*/
|
||||
const sharedFiles = jisonFiles
|
||||
.filter(jisonFile => jisonFile.indexOf('sql_') !== -1)
|
||||
.map(jisonFile => path.join(subLanguageJisonFolder, jisonFile));
|
||||
if (fileIndex['sql.jisonlex']) {
|
||||
/**
|
||||
* 添加子语言自动补全编译配置
|
||||
* 加入了error.jison,为了在校验失败的情况下也能够提示?
|
||||
*/
|
||||
findParser(fileIndex, folder, sharedFiles, true);
|
||||
/**
|
||||
* 添加子语言语法检查配置
|
||||
*/
|
||||
findParser(fileIndex, folder, sharedFiles.filter(path => path.indexOf('_error.jison') === -1), false);
|
||||
}
|
||||
else {
|
||||
console.log("Warn: Could not find 'sql.jisonlex' in " + JISON_FOLDER + 'sql/' + folder + '/');
|
||||
}
|
||||
}));
|
||||
});
|
||||
Promise.all(promises).then(resolve);
|
||||
});
|
||||
});
|
||||
const copyTests = (source, target) => new Promise((resolve, reject) => {
|
||||
const replaceRegexp = new RegExp(source + '(Autocomplete|Syntax)Parser', 'g');
|
||||
mkdir(PARSER_FOLDER + target)
|
||||
.then(() => {
|
||||
mkdir(PARSER_FOLDER + target + '/test')
|
||||
.then(() => {
|
||||
listDir(PARSER_FOLDER + source + '/test')
|
||||
.then(testFiles => {
|
||||
const copyPromises = [];
|
||||
testFiles.forEach(testFile => {
|
||||
copyPromises.push(copyFile(PARSER_FOLDER + source + '/test/' + testFile, PARSER_FOLDER + target + '/test/' + testFile.replace(source, target), contents => contents.replace(replaceRegexp, target + '$1Parser')));
|
||||
});
|
||||
Promise.all(copyPromises)
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
/**
|
||||
* 校验,配置自定义语言
|
||||
*/
|
||||
const prepareForNewParser = () => new Promise((resolve, reject) => {
|
||||
/**
|
||||
* 根据一个子语言文件夹来生成一个特殊sql名字的语法文件
|
||||
* -new generic postgresql
|
||||
* 根据generic文件夹生成postgresql语法文件
|
||||
*/
|
||||
if (process.argv.length === 3 && process.argv[0] === '-new') {
|
||||
process.argv.shift();
|
||||
const source = process.argv.shift();
|
||||
const target = process.argv.shift();
|
||||
console.log("Generating new parser '" + target + "' based on '" + source + "'...");
|
||||
process.argv.push(target);
|
||||
if (!Object.keys(parserDefinitions).some(key => {
|
||||
if (key.indexOf(source) === 0) {
|
||||
copyTests(source, target)
|
||||
.then(() => {
|
||||
mkdir(JISON_FOLDER + 'sql/' + target)
|
||||
.then(() => {
|
||||
listDir(JISON_FOLDER + 'sql/' + source).then(files => {
|
||||
const copyPromises = [];
|
||||
files.forEach(file => {
|
||||
copyPromises.push(copyFile(JISON_FOLDER + 'sql/' + source + '/' + file, JISON_FOLDER + 'sql/' + target + '/' + file));
|
||||
});
|
||||
Promise.all(copyPromises).then(() => {
|
||||
const autocompleteSources = [
|
||||
'sql/' + target + '/autocomplete_header.jison'
|
||||
];
|
||||
const syntaxSources = ['sql/' + target + '/syntax_header.jison'];
|
||||
files.forEach(file => {
|
||||
if (file.indexOf('sql_') === 0) {
|
||||
autocompleteSources.push('sql/' + target + '/' + file);
|
||||
syntaxSources.push('sql/' + target + '/' + file);
|
||||
}
|
||||
});
|
||||
autocompleteSources.push('sql/' + target + '/autocomplete_footer.jison');
|
||||
syntaxSources.push('sql/' + target + '/syntax_footer.jison');
|
||||
mkdir('desktop/core/src/desktop/js/parse/sql/' + target).then(() => {
|
||||
copyFile('desktop/core/src/desktop/js/parse/sql/' +
|
||||
source +
|
||||
'/sqlParseSupport.js', 'desktop/core/src/desktop/js/parse/sql/' +
|
||||
target +
|
||||
'/sqlParseSupport.js', contents => contents.replace(/parser\.yy\.activeDialect = '[^']+';'/g, "parser.yy.activeDialect = '" + target + "';")).then(() => {
|
||||
identifySqlParsers()
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
})
|
||||
.catch(reject);
|
||||
return true;
|
||||
}
|
||||
})) {
|
||||
reject("No existing parser found for '" + source + "'");
|
||||
}
|
||||
}
|
||||
else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
identifySqlParsers().then(() => {
|
||||
process.argv.shift();
|
||||
process.argv.shift();
|
||||
console.log('Generate sub language success...');
|
||||
prepareForNewParser().then(() => {
|
||||
console.log('Generate custom language success...');
|
||||
process.argv.forEach(arg => {
|
||||
if (arg === 'all') {
|
||||
/**
|
||||
* 编译全部
|
||||
*/
|
||||
all = true;
|
||||
}
|
||||
else if (parserDefinitions[arg]) {
|
||||
/**
|
||||
* 特点编译目标
|
||||
*/
|
||||
parsersToGenerate.push(arg);
|
||||
}
|
||||
else {
|
||||
/**
|
||||
* 根据关键字匹配编译目标
|
||||
*/
|
||||
let prefixFound = false;
|
||||
Object.keys(parserDefinitions).forEach(key => {
|
||||
if (key.indexOf(arg) === 0) {
|
||||
prefixFound = true;
|
||||
parsersToGenerate.push(key);
|
||||
}
|
||||
});
|
||||
if (!prefixFound) {
|
||||
invalid.push(arg);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (all) {
|
||||
parsersToGenerate = Object.keys(parserDefinitions);
|
||||
}
|
||||
if (invalid.length) {
|
||||
console.log("No parser config found for: '" + invalid.join("', '") + "'");
|
||||
console.log('\nPossible options are:\n ' +
|
||||
['all'].concat(Object.keys(parserDefinitions)).join('\n ') +
|
||||
'\n');
|
||||
return;
|
||||
}
|
||||
const parserCount = parsersToGenerate.length;
|
||||
let idx = 0;
|
||||
/**
|
||||
* 执行编译
|
||||
*/
|
||||
const generateRecursive = () => {
|
||||
idx++;
|
||||
if (parsersToGenerate.length) {
|
||||
const parserName = parsersToGenerate.pop();
|
||||
if (parserCount > 1) {
|
||||
console.log("Generating '" + parserName + "' (" + idx + '/' + parserCount + ')...');
|
||||
}
|
||||
else {
|
||||
console.log("Generating '" + parserName + "'...");
|
||||
}
|
||||
generateParser(parserName)
|
||||
.then(generateRecursive)
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
console.log('FAIL!');
|
||||
});
|
||||
}
|
||||
else {
|
||||
const autocompParsers = [];
|
||||
const syntaxParsers = [];
|
||||
console.log('Updating sqlParserRepository.js...');
|
||||
Object.keys(parserDefinitions).forEach(key => {
|
||||
if (parserDefinitions[key].sqlParser === 'AUTOCOMPLETE') {
|
||||
autocompParsers.push(AUTOCOMPLETE_PARSER_IMPORT_TEMPLATE.replace(/KEY/g, key.replace('AutocompleteParser', '')));
|
||||
}
|
||||
else if (parserDefinitions[key].sqlParser === 'SYNTAX') {
|
||||
syntaxParsers.push(SYNTAX_PARSER_IMPORT_TEMPLATE.replace(/KEY/g, key.replace('SyntaxParser', '')));
|
||||
}
|
||||
});
|
||||
readFile(SQL_PARSER_REPOSITORY_PATH).then(contents => {
|
||||
contents = contents.replace(/const SYNTAX_MODULES = [^}]+}/, 'const SYNTAX_MODULES = {\n' + syntaxParsers.sort().join(',\n') + '\n}');
|
||||
contents = contents.replace(/const AUTOCOMPLETE_MODULES = [^}]+}/, 'const AUTOCOMPLETE_MODULES = {\n' + autocompParsers.sort().join(',\n') + '\n}');
|
||||
writeFile(SQL_PARSER_REPOSITORY_PATH, contents).then(() => {
|
||||
console.log('Done!\n');
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 集中精力办大事
|
||||
*/
|
||||
generateRecursive();
|
||||
});
|
||||
});
|
||||
/* eslint-enable no-restricted-syntax */
|
@ -1,15 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.splitSql = exports.replaceStrFormIndexArr = void 0;
|
||||
function replaceStrFormIndexArr(str, replaceStr, indexArr) {
|
||||
let arr = [];
|
||||
let result = "";
|
||||
let result = '';
|
||||
let index = 0;
|
||||
if (!indexArr || indexArr.length < 1) {
|
||||
return str;
|
||||
}
|
||||
for (let i = 0; i < indexArr.length; i++) {
|
||||
let indexItem = indexArr[i];
|
||||
let begin = indexItem.begin;
|
||||
const indexItem = indexArr[i];
|
||||
const begin = indexItem.begin;
|
||||
result = result + str.substring(index, begin) + replaceStr;
|
||||
index = indexItem.end + 1;
|
||||
if (i == indexArr.length - 1) {
|
||||
@ -37,10 +37,10 @@ function splitSql(sql) {
|
||||
}
|
||||
// 处理引号
|
||||
function quoteToken(parser, sql) {
|
||||
let queue = parser.queue;
|
||||
let endsWith = queue[queue.length - 1];
|
||||
const queue = parser.queue;
|
||||
const endsWith = queue[queue.length - 1];
|
||||
if (endsWith == '\'' || endsWith == '"') {
|
||||
let nextToken = sql.indexOf(endsWith, parser.index + 1);
|
||||
const nextToken = sql.indexOf(endsWith, parser.index + 1);
|
||||
if (nextToken != -1) {
|
||||
parser.index = nextToken;
|
||||
parser.queue = '';
|
||||
@ -57,7 +57,7 @@ function splitSql(sql) {
|
||||
function singleLineCommentToken(parser, sql) {
|
||||
let queue = parser.queue;
|
||||
if (queue.endsWith('--')) {
|
||||
let nextToken = sql.indexOf('\n', parser.index + 1);
|
||||
const nextToken = sql.indexOf('\n', parser.index + 1);
|
||||
if (nextToken != -1) {
|
||||
parser.index = nextToken;
|
||||
queue = '';
|
||||
@ -72,9 +72,9 @@ function splitSql(sql) {
|
||||
}
|
||||
// 处理多行注释
|
||||
function multipleLineCommentToken(parser, sql) {
|
||||
let queue = parser.queue;
|
||||
const queue = parser.queue;
|
||||
if (queue.endsWith('/*')) {
|
||||
let nextToken = sql.indexOf('*/', parser.index + 1);
|
||||
const nextToken = sql.indexOf('*/', parser.index + 1);
|
||||
if (nextToken != -1) {
|
||||
parser.index = nextToken + 1;
|
||||
parser.queue = '';
|
||||
@ -89,7 +89,7 @@ function splitSql(sql) {
|
||||
}
|
||||
}
|
||||
function splitToken(parser, sql) {
|
||||
let queue = parser.queue;
|
||||
const queue = parser.queue;
|
||||
if (queue.endsWith(';')) {
|
||||
pushSql(parser, sql);
|
||||
}
|
||||
@ -97,15 +97,20 @@ function splitSql(sql) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
let parser = {
|
||||
const parser = {
|
||||
index: 0,
|
||||
queue: '',
|
||||
sqls: []
|
||||
sqls: [],
|
||||
};
|
||||
for (parser.index = 0; parser.index < sql.length; parser.index++) {
|
||||
let char = sql[parser.index];
|
||||
const char = sql[parser.index];
|
||||
parser.queue += char;
|
||||
let tokenFuncs = [quoteToken, singleLineCommentToken, multipleLineCommentToken, splitToken];
|
||||
const tokenFuncs = [
|
||||
quoteToken,
|
||||
singleLineCommentToken,
|
||||
multipleLineCommentToken,
|
||||
splitToken,
|
||||
];
|
||||
for (let i = 0; i < tokenFuncs.length; i++) {
|
||||
tokenFuncs[i](parser, sql);
|
||||
}
|
||||
|
Reference in New Issue
Block a user