@hamelin.sh/compiler 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.d.ts CHANGED
@@ -2927,6 +2927,8 @@ declare class HamelinListener implements ParseTreeListener {
2927
2927
  exitEveryRule(node: ParserRuleContext): void;
2928
2928
  }
2929
2929
 
2930
+ declare const hamelinGrammar = "grammar Hamelin;\n\nqueryEOF\n : query EOF\n ;\n\ncommandEOF\n : command EOF\n ;\n\nexpressionEOF\n : expression EOF\n ;\n\nidentifierEOF\n : identifier EOF\n ;\n\nsimpleIdentifierEOF\n : simpleIdentifier EOF\n ;\n\nquery\n : (WITH simpleIdentifier ASSIGN pipeline)+ pipeline #withQuery\n | pipeline #standaloneQuery\n | expression #expressionQuery\n ;\n\npipeline\n : command ( PIPE command )* #pipelineAlt\n ;\n\ncommand\n : LET_COMMAND assignment (COMMA assignment)* COMMA? #letCommand\n | WHERE_COMMAND expression #whereCommand\n | SELECT_COMMAND assignmentClause (COMMA assignmentClause)* COMMA? #selectCommand\n | DROP_COMMAND selection (COMMA selection)* COMMA? #dropCommand\n | FROM_COMMAND fromClause (COMMA fromClause)* COMMA? #fromCommand\n | UNION_COMMAND fromClause (COMMA fromClause)* COMMA? #unionCommand\n | LIMIT_COMMAND expression #limitCommand\n | PARSE_COMMAND src=expression? string\n AS? identifier (COMMA identifier)* COMMA? NODROP? #parseCommand\n | WITHIN_COMMAND expression #withinCommand\n | AGG_COMMAND (assignmentClause (COMMA assignmentClause)*)? COMMA?\n (BY groupClause (COMMA groupClause)*)? COMMA?\n (SORT BY? sortExpression (COMMA sortExpression)*)? COMMA? #aggCommand\n | SORT BY? sortExpression (COMMA sortExpression)* COMMA? #sortCommand\n | WINDOW_COMMAND assignmentClause (COMMA assignmentClause)* COMMA?\n (BY groupClause (COMMA groupClause)*)? COMMA?\n (SORT BY? sortExpression (COMMA sortExpression)*)? COMMA?\n (WITHIN_COMMAND within=expression)? #windowCommand\n | APPEND_COMMAND tableReference (DISTINCT_BY selection (COMMA selection)*)? COMMA? #appendCommand\n | (JOIN_COMMAND | LOOKUP_COMMAND) fromClause (ON on=expression)? #joinCommand\n | EXPLODE_COMMAND assignmentClause #explodeCommand\n | (UNNEST_COMMAND | ROWS_COMMAND) expression #unnestCommand\n | NEST_COMMAND identifier #nestCommand\n | MATCH_COMMAND pattern+\n (WHEN matchDefine (COMMA matchDefine)*)? COMMA?\n (BY groupClause (COMMA groupClause)*)? COMMA?\n (SORT BY? sortExpression (COMMA sortExpression)*)? COMMA? #matchCommand\n ;\n\nassignmentClause: assignment | expression;\ngroupClause: assignmentClause;\nassignment: identifier ASSIGN expression;\nmatchDefine: simpleIdentifier ASSIGN expression;\nselection: identifier;\nsortExpression: expression (ASC | DESC)?;\ntableAlias: simpleIdentifier ASSIGN tableReference;\nfromClause: tableAlias | tableReference;\n\nexpression\n // Keep this list in precedence order (important!)\n : operator=(MINUS | PLUS) expression #unaryPrefixOperator\n | expression (SECOND_TRUNC | MINUTE_TRUNC | HOUR_TRUNC | DAY_TRUNC | WEEK_TRUNC |\n MONTH_TRUNC | QUARTER_TRUNC | YEAR_TRUNC) #tsTrunc\n | left=expression operator=DOT right=simpleIdentifier #deref\n | value=expression LBRACKET index=expression RBRACKET #indexAccess\n | left=expression operator=(ASTERISK | SLASH | PERCENT) right=expression #binaryOperator\n | left=expression operator=(PLUS | MINUS) right=expression #binaryOperator\n | operator=RANGE expression #unaryPrefixOperator\n | expression operator=RANGE #unaryPostfixOperator\n | left=expression operator=RANGE right=expression #binaryOperator\n | left=expression operator=AS right=hamelintype #cast\n | left=expression\n operator=(EQ | NEQ | LT | LTE | GT | GTE | IS | ISNOT | IN) right=expression #binaryOperator\n | operator=NOT expression #unaryPrefixOperator\n | left=expression operator=AND right=expression #binaryOperator\n | left=expression operator=OR right=expression #binaryOperator\n\n // Complex Literals\n | left=expression operator=COLON right=expression #pairLiteral\n | LCURLY simpleIdentifier COLON expression\n (COMMA simpleIdentifier COLON expression)* COMMA? RCURLY #structLiteral\n | LPARENS ((expression COMMA) |\n (expression COMMA expression (COMMA expression)* COMMA?)) RPARENS #tupleLiteral\n | LBRACKET (expression (COMMA expression)* COMMA?)? RBRACKET #arrayLiteral\n\n // Function Calls\n | functionName=simpleIdentifier\n LPARENS (namedArgument (COMMA namedArgument)* COMMA?)? RPARENS #functionCall\n | functionName=simpleIdentifier LPARENS\n positionalArgument (COMMA positionalArgument)*\n (COMMA namedArgument)* COMMA? RPARENS #functionCall\n\n // Primitive Literals\n | NULL #nullLiteral\n | number #numericLiteral\n | TRUE #booleanLiteral\n | FALSE #booleanLiteral\n | string #stringLiteral\n | BINARY_LITERAL #binaryLiteral\n | RANGE #unboundRangeLiteral\n | (NANOSECOND_INTERVAL | MICROSECOND_INTERVAL | MILLISECOND_INTERVAL |\n SECOND_INTERVAL | MINUTE_INTERVAL | HOUR_INTERVAL | DAY_INTERVAL |\n WEEK_INTERVAL | MONTH_INTERVAL | QUARTER_INTERVAL | YEAR_INTERVAL) #intervalLiteral\n | ROWS_LITERAL #rowsLiteral\n | (SECOND_TRUNC | MINUTE_TRUNC | HOUR_TRUNC | DAY_TRUNC | WEEK_TRUNC |\n MONTH_TRUNC | QUARTER_TRUNC | YEAR_TRUNC) #tsTruncTimestampLiteral\n\n // Environment references\n | columnReference #columnReferenceAlt\n\n // Keep this at the bottom to use it the mechanism that query authors have to specify precedence.\n | LPARENS expression RPARENS #parenthesizedExpression\n ;\n\nhamelintype\n : simpleIdentifier LPARENS hamelintype (COMMA hamelintype)* COMMA? RPARENS #parameterizedType\n | simpleIdentifier LPARENS INTEGER_VALUE (COMMA INTEGER_VALUE)* COMMA? RPARENS #typeWithArguments\n | LCURLY simpleIdentifier COLON hamelintype\n (COMMA simpleIdentifier COLON hamelintype)* COMMA? RCURLY #structType\n | LPARENS hamelintype (COMMA hamelintype )* COMMA? RPARENS #tupleType\n | simpleIdentifier #simpleType\n ;\n\npattern\n : fromClause quantifier? #quantified\n | LPARENS pattern+ RPARENS quantifier #nested\n ;\n\nquantifier\n : ASTERISK #AnyNumber\n | PLUS #AtLeastOne\n | QUESTIONMARK #ZeroOrOne\n | LCURLY INTEGER_VALUE RCURLY #Exactly\n ;\n\ncolumnReference\n : simpleIdentifier\n ;\n\ntableReference\n : identifier\n ;\n\nidentifier\n : simpleIdentifier\n | simpleIdentifier (DOT simpleIdentifier)+\n ;\n\nsimpleIdentifier\n : IDENTIFIER #unquotedIdentifier\n | BACKQUOTED_IDENTIFIER #backQuotedIdentifier\n ;\n\nstring\n : SINGLE_QUOTED_STRING #basicSingleQuotedStringLiteral\n | DOUBLE_QUOTED_STRING #basicDoubleQuotedStringLiteral\n | value=SINGLE_QUOTED_UNICODE_STRING (UESCAPE uesc=SINGLE_QUOTED_STRING)? #unicodeSingleQuotedStringLiteral\n | value=DOUBLE_QUOTED_UNICODE_STRING (UESCAPE uesc=DOUBLE_QUOTED_STRING)? #unicodeDoubleQuotedStringLiteral\n ;\n\nnumber\n : value=DECIMAL_VALUE #decimalLiteral\n | value=DOUBLE_VALUE #scientificLiteral\n | value=INTEGER_VALUE #integerLiteral\n ;\n\npositionalArgument\n : expression\n ;\n\nnamedArgument\n : simpleIdentifier ASSIGN expression\n ;\n\n//\n// COMMANDS\n//\n\nLET_COMMAND: 'LET' | 'let';\nWHERE_COMMAND: 'WHERE' | 'where';\nSELECT_COMMAND: 'SELECT' | 'select';\nDROP_COMMAND: 'DROP' | 'drop';\nFROM_COMMAND: 'FROM' | 'from';\nUNION_COMMAND: 'UNION' | 'union';\nLIMIT_COMMAND: 'LIMIT' | 'limit';\nPARSE_COMMAND: 'PARSE' | 'parse';\nWITHIN_COMMAND: 'WITHIN' | 'within';\nAGG_COMMAND: 'AGG' | 'agg';\nWINDOW_COMMAND: 'WINDOW' | 'window';\nAPPEND_COMMAND: 'APPEND' | 'append';\nJOIN_COMMAND: 'JOIN' | 'join';\nLOOKUP_COMMAND: 'LOOKUP' | 'lookup';\nEXPLODE_COMMAND: 'EXPLODE' | 'explode';\nUNNEST_COMMAND: 'UNNEST' | 'unnest';\nNEST_COMMAND: 'NEST' | 'nest';\nROWS_COMMAND: 'ROWS' | 'rows';\nMATCH_COMMAND: 'MATCH' | 'match';\n\nAS: 'AS' | 'as';\nNODROP: 'NODROP' | 'nodrop';\n\n//\n// Operators\n//\n\nPLUS: '+';\nMINUS: '-';\nASTERISK: '*';\nSLASH: '/';\nPERCENT: '%';\nLCURLY: '{';\nRCURLY: '}';\nCOLON: ':';\nQUESTIONMARK: '?';\n\nEQ: '==';\nNEQ: '!=';\nLT: '<';\nLTE: '<=';\nGT: '>';\nGTE: '>=';\nRANGE: '..';\n\nASSIGN: '=';\n\n//\n// Keywords\n//\n\nAND: 'AND' | 'and';\nFALSE: 'FALSE' | 'false';\nIS: 'IS' | 'is';\nNOT: 'NOT' | 'not';\nISNOT: 'IS NOT' | 'is not';\nIN: 'IN' | 'in';\nNULL: 'NULL' | 'null';\nOR: 'OR' | 'or';\nTRUE: 'TRUE' | 'true';\nUESCAPE: 'UESCAPE' | 'uescape';\nWITH: 'WITH' | 'with';\nBY: 'BY' | 'by';\nSORT: 'SORT' | 'sort';\nASC: 'ASC' | 'asc';\nDESC: 'DESC' | 'desc';\nDISTINCT_BY: 'DISTINCT BY' | 'distinct by';\nON: 'ON' | 'on';\nWHEN: 'WHEN' | 'when';\n\n//\n// Symbols\n//\n\nCOMMA: ',';\nPIPE: '|';\nLPARENS: '(';\nRPARENS: ')';\nDOT: '.';\nLBRACKET: '[';\nRBRACKET: ']';\n\n//\n// Literals\n//\n\nSINGLE_QUOTED_STRING\n : '\\'' ( ~'\\'' | '\\'\\'')* '\\''\n ;\nDOUBLE_QUOTED_STRING\n : '\"' ( ~'\"' | '\"\"')* '\"'\n ;\n\nSINGLE_QUOTED_UNICODE_STRING\n : 'U&\\'' ( ~'\\'' | '\\'\\'')* '\\'' // Unicode string with default escape character: U&'Hello winter \\2603 !'\n ;\n\nDOUBLE_QUOTED_UNICODE_STRING\n : 'U&\"' ( ~'\"' | '\"\"')* '\"' // Unicode string with custom escape character: U&'Hello winter #2603 !' UESCAPE '#'\n ;\n\n// Note: we allow any character inside the binary literal and validate\n// its a correct literal when the AST is being constructed. This\n// allows us to provide more meaningful error messages to the user\nBINARY_LITERAL\n : 'x\\'' (~'\\'')* '\\''\n ;\n\nNANOSECOND_INTERVAL\n : DECIMAL_INTEGER 'ns'\n ;\n\nMICROSECOND_INTERVAL\n : DECIMAL_INTEGER 'us'\n ;\n\nMILLISECOND_INTERVAL\n : DECIMAL_INTEGER 'ms'\n ;\n\nSECOND_INTERVAL\n : DECIMAL_INTEGER ('s' | 'sec' | 'secs' | 'second' | 'seconds')\n ;\n\nMINUTE_INTERVAL\n : DECIMAL_INTEGER ('m' | 'min' | 'mins' | 'minute' | 'minutes')\n ;\n\nHOUR_INTERVAL\n : DECIMAL_INTEGER ('h' | 'hr' | 'hrs' | 'hour' | 'hours')\n ;\n\nDAY_INTERVAL\n : DECIMAL_INTEGER ('d' | 'day' | 'days')\n ;\n\nWEEK_INTERVAL\n : DECIMAL_INTEGER ('w' | 'week' | 'weeks')\n ;\n\nMONTH_INTERVAL\n : DECIMAL_INTEGER ('mon' | 'month' | 'months')\n ;\n\nQUARTER_INTERVAL\n : DECIMAL_INTEGER ('q' | 'qtr' | 'qtrs' | 'quarter' | 'quarters')\n ;\n\nYEAR_INTERVAL\n : DECIMAL_INTEGER ('y' | 'yr' | 'yrs' | 'year' | 'years')\n ;\n\nROWS_LITERAL\n : DECIMAL_INTEGER ('r' | 'row' | 'rows')\n ;\n\nSECOND_TRUNC\n : '@' ('s' | 'sec' | 'secs' | 'second' | 'seconds')\n ;\n\nMINUTE_TRUNC\n : '@' ('m' | 'min' | 'mins' | 'minute' | 'minutes')\n ;\n\nHOUR_TRUNC\n : '@' ('h' | 'hr' | 'hrs' | 'hour' | 'hours')\n ;\n\nDAY_TRUNC\n : '@' ('d' | 'day' | 'days')\n ;\n\nWEEK_TRUNC\n : '@' ('w' | 'week' | 'weeks')\n ;\n\nMONTH_TRUNC\n : '@' ('mon' | 'month' | 'months')\n ;\n\nQUARTER_TRUNC\n : '@' ('q' | 'qtr' | 'qtrs' | 'quarter' | 'quarters')\n ;\n\nYEAR_TRUNC\n : '@' ('y' | 'yr' | 'yrs' | 'year' | 'years')\n ;\n\nINTEGER_VALUE\n : DECIMAL_INTEGER\n | HEXADECIMAL_INTEGER\n | OCTAL_INTEGER\n | BINARY_INTEGER\n ;\n\nDECIMAL_VALUE\n : DECIMAL_INTEGER '.' DECIMAL_INTEGER\n | '.' DECIMAL_INTEGER\n ;\n\nDOUBLE_VALUE\n : DIGIT+ ('.' DIGIT*)? EXPONENT\n | '.' DIGIT+ EXPONENT\n ;\n\nIDENTIFIER\n : [a-zA-Z_][a-zA-Z_0-9]*\n ;\n\nBACKQUOTED_IDENTIFIER\n : '`' ( ~'`' | '``' )* '`'\n ;\n\nfragment DECIMAL_INTEGER\n : DIGIT ('_'? DIGIT)*\n ;\n\nfragment HEXADECIMAL_INTEGER\n : '0x' ('_'? (DIGIT | [A-F]))+\n ;\n\nfragment OCTAL_INTEGER\n : '0o' ('_'? [0-7])+\n ;\n\nfragment BINARY_INTEGER\n : '0b' ('_'? [01])+\n ;\n\nfragment EXPONENT\n : 'e' [+-]? DIGIT+\n ;\n\nfragment DIGIT\n : [0-9]\n ;\n\n//\n// Comments and whitespace\n//\n\nSIMPLE_COMMENT\n : '//' ~[\\r\\n]* '\\r'? '\\n'? -> channel(HIDDEN)\n ;\n\nBRACKETED_COMMENT\n : '/*' .*? '*/' -> channel(HIDDEN)\n ;\n\nWS\n : [ \\r\\n\\t]+ -> skip\n ;\n";
2931
+
2930
2932
  declare const getDatasetsFromQuery: (catalog: Catalog, hamelinInput: string) => Promise<QueryDatasetsResult>;
2931
2933
 
2932
2934
  declare const getFunctionDescriptions: () => Promise<FunctionDescription[]>;
@@ -2947,4 +2949,4 @@ declare const getSorts: (hamelinQuery: string) => QuerySort[];
2947
2949
 
2948
2950
  declare const sampleCatalog: Catalog;
2949
2951
 
2950
- export { AggCommandContext, AnyNumberContext, AppendCommandContext, ArrayLiteralContext, AssignmentClauseContext, AssignmentContext, AtLeastOneContext, BackQuotedIdentifierContext, BasicDoubleQuotedStringLiteralContext, BasicSingleQuotedStringLiteralContext, BinaryLiteralContext, BinaryOperatorContext, BooleanLiteralContext, CastContext, type Catalog, CatalogProvider, type Column, ColumnReferenceAltContext, ColumnReferenceContext, CommandContext, CommandEOFContext, type CompileQueryResult, Compiler, type Completion, type CompletionItem, type CompletionItemKind, type Context, type ContextualCompletion, type ContextualResult, type ContextualTranslationError, type ContextualTranslationErrors, type DMLTranslation, DecimalLiteralContext, DerefContext, DropCommandContext, ExactlyContext, ExplodeCommandContext, ExpressionContext, ExpressionEOFContext, ExpressionQueryContext, FromClauseContext, FromCommandContext, FunctionCallContext, type FunctionDescription, GroupClauseContext, HamelinLexer, HamelinListener, HamelinParser, type HamelinType, HamelinVisitor, HamelintypeContext, IdentifierContext, IdentifierEOFContext, IndexAccessContext, type InitInput, type InitOutput, IntegerLiteralContext, IntervalLiteralContext, JoinCommandContext, type LanguageArea, LetCommandContext, type Level, LimitCommandContext, MatchCommandContext, MatchDefineContext, NamedArgumentContext, NestCommandContext, NestedContext, NullLiteralContext, NumberContext, NumericLiteralContext, PairLiteralContext, ParameterizedTypeContext, ParenthesizedExpressionContext, ParseCommandContext, PatternContext, PipelineAltContext, PipelineContext, PositionalArgumentContext, QuantifiedContext, QuantifierContext, QueryContext, type QueryDatasetsResult, QueryEOFContext, type QuerySort, type QueryTranslation, RowsLiteralContext, ScientificLiteralContext, SelectCommandContext, SelectionContext, SimpleIdentifierContext, SimpleIdentifierEOFContext, SimpleTypeContext, SortCommandContext, SortExpressionContext, type Stage, StandaloneQueryContext, type StatementTranslation, StringContext, StringLiteralContext, StructLiteralContext, StructTypeContext, type SyncInitInput, TableAliasContext, TableReferenceContext, type Translation, type TranslationError, type TranslationErrors, TsTruncContext, TsTruncTimestampLiteralContext, TupleLiteralContext, TupleTypeContext, TypeWithArgumentsContext, UnaryPostfixOperatorContext, UnaryPrefixOperatorContext, UnboundRangeLiteralContext, UnicodeDoubleQuotedStringLiteralContext, UnicodeSingleQuotedStringLiteralContext, UnionCommandContext, UnnestCommandContext, UnquotedIdentifierContext, WhereCommandContext, WindowCommandContext, WithQueryContext, WithinCommandContext, ZeroOrOneContext, compileHamelin, createCompiler, getDatasetsFromQuery, getFunctionDescriptions, getLimits, getSorts, initSync, sampleCatalog };
2952
+ export { AggCommandContext, AnyNumberContext, AppendCommandContext, ArrayLiteralContext, AssignmentClauseContext, AssignmentContext, AtLeastOneContext, BackQuotedIdentifierContext, BasicDoubleQuotedStringLiteralContext, BasicSingleQuotedStringLiteralContext, BinaryLiteralContext, BinaryOperatorContext, BooleanLiteralContext, CastContext, type Catalog, CatalogProvider, type Column, ColumnReferenceAltContext, ColumnReferenceContext, CommandContext, CommandEOFContext, type CompileQueryResult, Compiler, type Completion, type CompletionItem, type CompletionItemKind, type Context, type ContextualCompletion, type ContextualResult, type ContextualTranslationError, type ContextualTranslationErrors, type DMLTranslation, DecimalLiteralContext, DerefContext, DropCommandContext, ExactlyContext, ExplodeCommandContext, ExpressionContext, ExpressionEOFContext, ExpressionQueryContext, FromClauseContext, FromCommandContext, FunctionCallContext, type FunctionDescription, GroupClauseContext, HamelinLexer, HamelinListener, HamelinParser, type HamelinType, HamelinVisitor, HamelintypeContext, IdentifierContext, IdentifierEOFContext, IndexAccessContext, type InitInput, type InitOutput, IntegerLiteralContext, IntervalLiteralContext, JoinCommandContext, type LanguageArea, LetCommandContext, type Level, LimitCommandContext, MatchCommandContext, MatchDefineContext, NamedArgumentContext, NestCommandContext, NestedContext, NullLiteralContext, NumberContext, NumericLiteralContext, PairLiteralContext, ParameterizedTypeContext, ParenthesizedExpressionContext, ParseCommandContext, PatternContext, PipelineAltContext, PipelineContext, PositionalArgumentContext, QuantifiedContext, QuantifierContext, QueryContext, type QueryDatasetsResult, QueryEOFContext, type QuerySort, type QueryTranslation, RowsLiteralContext, ScientificLiteralContext, SelectCommandContext, SelectionContext, SimpleIdentifierContext, SimpleIdentifierEOFContext, SimpleTypeContext, SortCommandContext, SortExpressionContext, type Stage, StandaloneQueryContext, type StatementTranslation, StringContext, StringLiteralContext, StructLiteralContext, StructTypeContext, type SyncInitInput, TableAliasContext, TableReferenceContext, type Translation, type TranslationError, type TranslationErrors, TsTruncContext, TsTruncTimestampLiteralContext, TupleLiteralContext, TupleTypeContext, TypeWithArgumentsContext, UnaryPostfixOperatorContext, UnaryPrefixOperatorContext, UnboundRangeLiteralContext, UnicodeDoubleQuotedStringLiteralContext, UnicodeSingleQuotedStringLiteralContext, UnionCommandContext, UnnestCommandContext, UnquotedIdentifierContext, WhereCommandContext, WindowCommandContext, WithQueryContext, WithinCommandContext, ZeroOrOneContext, compileHamelin, createCompiler, getDatasetsFromQuery, getFunctionDescriptions, getLimits, getSorts, hamelinGrammar, initSync, sampleCatalog };