diff --git a/packages/parser/src/loader/sql/__snapshots__/index.test.ts.snap b/packages/parser/src/loader/sql/__snapshots__/index.test.ts.snap index 2dd9a919..e93bea19 100644 --- a/packages/parser/src/loader/sql/__snapshots__/index.test.ts.snap +++ b/packages/parser/src/loader/sql/__snapshots__/index.test.ts.snap @@ -105,6 +105,34 @@ Object { } `; +exports[`Dollar quoted strings are supported 1`] = ` +Object { + "events": Array [], + "queries": Array [ + Object { + "name": "CreateUpdatedAtFunction", + "params": Array [], + "statement": Object { + "body": "CREATE FUNCTION UpdatedAt() + RETURNS TRIGGER AS $$ + BEGIN + NEW.updatedAt = NOW(); + RETURN NEW; + END; + $$ LANGUAGE plpgsql", + "loc": Object { + "a": 41, + "b": 191, + "col": 2, + "line": 3, + }, + }, + "usedParamSet": Object {}, + }, + ], +} +`; + exports[`Double and single quotes are supported 1`] = ` Object { "events": Array [], diff --git a/packages/parser/src/loader/sql/grammar/SQLLexer.g4 b/packages/parser/src/loader/sql/grammar/SQLLexer.g4 index dcb37618..117c4408 100644 --- a/packages/parser/src/loader/sql/grammar/SQLLexer.g4 +++ b/packages/parser/src/loader/sql/grammar/SQLLexer.g4 @@ -19,11 +19,13 @@ OPEN_COMMENT: '/*' -> mode(COMMENT); SID: ID -> type(ID); S_REQUIRED_MARK: '!'; WORD: [a-zA-Z_0-9]+; -SPECIAL: [\-+*/<>=~@#%^&|`?$(){},.[\]"]+ -> type(WORD); +SPECIAL: [\-+*/<>=~@#%^&|`?(){},.[\]"]+ -> type(WORD); +DOLLAR: '$' -> type(WORD); EOF_STATEMENT: ';'; WSL : [ \t\r\n]+ -> skip; // parse strings and recognize escaped quotes STRING: QUOT (QUOT | .*? ~([\\]) QUOT); +DOLLAR_STRING: DOLLAR WORD? DOLLAR .* DOLLAR WORD? DOLLAR; PARAM_MARK: ':'; CAST: '::' -> type(WORD); diff --git a/packages/parser/src/loader/sql/grammar/SQLParser.g4 b/packages/parser/src/loader/sql/grammar/SQLParser.g4 index 5d474ae4..ce94f6aa 100644 --- a/packages/parser/src/loader/sql/grammar/SQLParser.g4 +++ b/packages/parser/src/loader/sql/grammar/SQLParser.g4 @@ -21,7 +21,7 @@ statement statementBody : (LINE_COMMENT | ignoredComment | param | word)*; -word: WORD | ID | STRING | S_REQUIRED_MARK; +word: WORD | ID | STRING | S_REQUIRED_MARK | DOLLAR_STRING; param: PARAM_MARK paramId; diff --git a/packages/parser/src/loader/sql/index.test.ts b/packages/parser/src/loader/sql/index.test.ts index 20fcf4bc..a0b9e6c7 100644 --- a/packages/parser/src/loader/sql/index.test.ts +++ b/packages/parser/src/loader/sql/index.test.ts @@ -140,3 +140,17 @@ test('Comment starts in strings are ignored', () => { const parseTree = parse(text); expect(parseTree).toMatchSnapshot(); }); + +test('Dollar quoted strings are supported', () => { + const text = ` + /* @name CreateUpdatedAtFunction */ + CREATE FUNCTION UpdatedAt() + RETURNS TRIGGER AS $$ + BEGIN + NEW.updatedAt = NOW(); + RETURN NEW; + END; + $$ LANGUAGE plpgsql;`; + const parseTree = parse(text); + expect(parseTree).toMatchSnapshot(); +}); diff --git a/packages/parser/src/loader/sql/parser/SQLLexer.ts b/packages/parser/src/loader/sql/parser/SQLLexer.ts index 91564dd6..576101c7 100644 --- a/packages/parser/src/loader/sql/parser/SQLLexer.ts +++ b/packages/parser/src/loader/sql/parser/SQLLexer.ts @@ -24,19 +24,21 @@ export class SQLLexer extends Lexer { public static readonly EOF_STATEMENT = 6; public static readonly WSL = 7; public static readonly STRING = 8; - public static readonly PARAM_MARK = 9; - public static readonly WS = 10; - public static readonly TRANSFORM_ARROW = 11; - public static readonly SPREAD = 12; - public static readonly NAME_TAG = 13; - public static readonly TYPE_TAG = 14; - public static readonly OB = 15; - public static readonly CB = 16; - public static readonly COMMA = 17; - public static readonly C_REQUIRED_MARK = 18; - public static readonly ANY = 19; - public static readonly CLOSE_COMMENT = 20; - public static readonly CAST = 21; + public static readonly DOLLAR_STRING = 9; + public static readonly PARAM_MARK = 10; + public static readonly WS = 11; + public static readonly TRANSFORM_ARROW = 12; + public static readonly SPREAD = 13; + public static readonly NAME_TAG = 14; + public static readonly TYPE_TAG = 15; + public static readonly OB = 16; + public static readonly CB = 17; + public static readonly COMMA = 18; + public static readonly C_REQUIRED_MARK = 19; + public static readonly ANY = 20; + public static readonly CLOSE_COMMENT = 21; + public static readonly DOLLAR = 22; + public static readonly CAST = 23; public static readonly COMMENT = 1; // tslint:disable:no-trailing-whitespace @@ -50,22 +52,23 @@ export class SQLLexer extends Lexer { ]; public static readonly ruleNames: string[] = [ - "QUOT", "ID", "LINE_COMMENT", "OPEN_COMMENT", "SID", "S_REQUIRED_MARK", - "WORD", "SPECIAL", "EOF_STATEMENT", "WSL", "STRING", "PARAM_MARK", "CAST", - "CID", "WS", "TRANSFORM_ARROW", "SPREAD", "NAME_TAG", "TYPE_TAG", "OB", - "CB", "COMMA", "C_REQUIRED_MARK", "ANY", "CLOSE_COMMENT", + "QUOT", "ID", "LINE_COMMENT", "OPEN_COMMENT", "SID", "S_REQUIRED_MARK", + "WORD", "SPECIAL", "DOLLAR", "EOF_STATEMENT", "WSL", "STRING", "DOLLAR_STRING", + "PARAM_MARK", "CAST", "CID", "WS", "TRANSFORM_ARROW", "SPREAD", "NAME_TAG", + "TYPE_TAG", "OB", "CB", "COMMA", "C_REQUIRED_MARK", "ANY", "CLOSE_COMMENT", ]; private static readonly _LITERAL_NAMES: Array = [ - undefined, undefined, undefined, "'/*'", undefined, undefined, "';'", - undefined, undefined, "':'", undefined, "'->'", "'...'", "'@name'", "'@param'", - "'('", "')'", "','", undefined, undefined, "'*/'", "'::'", + undefined, undefined, undefined, "'/*'", undefined, undefined, "';'", + undefined, undefined, undefined, "':'", undefined, "'->'", "'...'", "'@name'", + "'@param'", "'('", "')'", "','", undefined, undefined, "'*/'", "'$'", + "'::'", ]; private static readonly _SYMBOLIC_NAMES: Array = [ - undefined, "ID", "LINE_COMMENT", "OPEN_COMMENT", "S_REQUIRED_MARK", "WORD", - "EOF_STATEMENT", "WSL", "STRING", "PARAM_MARK", "WS", "TRANSFORM_ARROW", - "SPREAD", "NAME_TAG", "TYPE_TAG", "OB", "CB", "COMMA", "C_REQUIRED_MARK", - "ANY", "CLOSE_COMMENT", "CAST", + undefined, "ID", "LINE_COMMENT", "OPEN_COMMENT", "S_REQUIRED_MARK", "WORD", + "EOF_STATEMENT", "WSL", "STRING", "DOLLAR_STRING", "PARAM_MARK", "WS", + "TRANSFORM_ARROW", "SPREAD", "NAME_TAG", "TYPE_TAG", "OB", "CB", "COMMA", + "C_REQUIRED_MARK", "ANY", "CLOSE_COMMENT", "DOLLAR", "CAST", ]; public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(SQLLexer._LITERAL_NAMES, SQLLexer._SYMBOLIC_NAMES, []); @@ -98,83 +101,95 @@ export class SQLLexer extends Lexer { public get modeNames(): string[] { return SQLLexer.modeNames; } public static readonly _serializedATN: string = - "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x02\x17\xB1\b\x01" + + "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x02\x19\xCA\b\x01" + "\b\x01\x04\x02\t\x02\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06" + "\t\x06\x04\x07\t\x07\x04\b\t\b\x04\t\t\t\x04\n\t\n\x04\v\t\v\x04\f\t\f" + "\x04\r\t\r\x04\x0E\t\x0E\x04\x0F\t\x0F\x04\x10\t\x10\x04\x11\t\x11\x04" + "\x12\t\x12\x04\x13\t\x13\x04\x14\t\x14\x04\x15\t\x15\x04\x16\t\x16\x04" + - "\x17\t\x17\x04\x18\t\x18\x04\x19\t\x19\x04\x1A\t\x1A\x03\x02\x03\x02\x03" + - "\x03\x03\x03\x07\x03;\n\x03\f\x03\x0E\x03>\v\x03\x03\x04\x03\x04\x03\x04" + - "\x03\x04\x07\x04D\n\x04\f\x04\x0E\x04G\v\x04\x03\x04\x05\x04J\n\x04\x03" + - "\x04\x03\x04\x03\x05\x03\x05\x03\x05\x03\x05\x03\x05\x03\x06\x03\x06\x03" + - "\x06\x03\x06\x03\x07\x03\x07\x03\b\x06\bZ\n\b\r\b\x0E\b[\x03\t\x06\t_" + - "\n\t\r\t\x0E\t`\x03\t\x03\t\x03\n\x03\n\x03\v\x06\vh\n\v\r\v\x0E\vi\x03" + - "\v\x03\v\x03\f\x03\f\x03\f\x07\fq\n\f\f\f\x0E\ft\v\f\x03\f\x03\f\x05\f" + - "x\n\f\x03\r\x03\r\x03\x0E\x03\x0E\x03\x0E\x03\x0E\x03\x0E\x03\x0F\x03" + - "\x0F\x03\x0F\x03\x0F\x03\x10\x06\x10\x86\n\x10\r\x10\x0E\x10\x87\x03\x10" + - "\x03\x10\x03\x11\x03\x11\x03\x11\x03\x12\x03\x12\x03\x12\x03\x12\x03\x13" + - "\x03\x13\x03\x13\x03\x13\x03\x13\x03\x13\x03\x14\x03\x14\x03\x14\x03\x14" + - "\x03\x14\x03\x14\x03\x14\x03\x15\x03\x15\x03\x16\x03\x16\x03\x17\x03\x17" + - "\x03\x18\x03\x18\x03\x19\x06\x19\xA9\n\x19\r\x19\x0E\x19\xAA\x03\x1A\x03" + - "\x1A\x03\x1A\x03\x1A\x03\x1A\x04r\xAA\x02\x02\x1B\x04\x02\x02\x06\x02" + - "\x03\b\x02\x04\n\x02\x05\f\x02\x02\x0E\x02\x06\x10\x02\x07\x12\x02\x02" + - "\x14\x02\b\x16\x02\t\x18\x02\n\x1A\x02\v\x1C\x02\x17\x1E\x02\x02 \x02" + - "\f\"\x02\r$\x02\x0E&\x02\x0F(\x02\x10*\x02\x11,\x02\x12.\x02\x130\x02" + - "\x142\x02\x154\x02\x16\x04\x02\x03\b\x05\x02C\\aac|\x06\x022;C\\aac|\x04" + - "\x02\f\f\x0F\x0F\t\x02$(*1>B]]_`bb}\x80\x05\x02\v\f\x0F\x0F\"\"\x03\x02" + - "^^\x02\xB7\x02\b\x03\x02\x02\x02\x02\n\x03\x02\x02\x02\x02\f\x03\x02\x02" + - "\x02\x02\x0E\x03\x02\x02\x02\x02\x10\x03\x02\x02\x02\x02\x12\x03\x02\x02" + - "\x02\x02\x14\x03\x02\x02\x02\x02\x16\x03\x02\x02\x02\x02\x18\x03\x02\x02" + - "\x02\x02\x1A\x03\x02\x02\x02\x02\x1C\x03\x02\x02\x02\x03\x1E\x03\x02\x02" + - "\x02\x03 \x03\x02\x02\x02\x03\"\x03\x02\x02\x02\x03$\x03\x02\x02\x02\x03" + - "&\x03\x02\x02\x02\x03(\x03\x02\x02\x02\x03*\x03\x02\x02\x02\x03,\x03\x02" + - "\x02\x02\x03.\x03\x02\x02\x02\x030\x03\x02\x02\x02\x032\x03\x02\x02\x02" + - "\x034\x03\x02\x02\x02\x046\x03\x02\x02\x02\x068\x03\x02\x02\x02\b?\x03" + - "\x02\x02\x02\nM\x03\x02\x02\x02\fR\x03\x02\x02\x02\x0EV\x03\x02\x02\x02" + - "\x10Y\x03\x02\x02\x02\x12^\x03\x02\x02\x02\x14d\x03\x02\x02\x02\x16g\x03" + - "\x02\x02\x02\x18m\x03\x02\x02\x02\x1Ay\x03\x02\x02\x02\x1C{\x03\x02\x02" + - "\x02\x1E\x80\x03\x02\x02\x02 \x85\x03\x02\x02\x02\"\x8B\x03\x02\x02\x02" + - "$\x8E\x03\x02\x02\x02&\x92\x03\x02\x02\x02(\x98\x03\x02\x02\x02*\x9F\x03" + - "\x02\x02\x02,\xA1\x03\x02\x02\x02.\xA3\x03\x02\x02\x020\xA5\x03\x02\x02" + - "\x022\xA8\x03\x02\x02\x024\xAC\x03\x02\x02\x0267\x07)\x02\x027\x05\x03" + - "\x02\x02\x028<\t\x02\x02\x029;\t\x03\x02\x02:9\x03\x02\x02\x02;>\x03\x02" + - "\x02\x02<:\x03\x02\x02\x02<=\x03\x02\x02\x02=\x07\x03\x02\x02\x02><\x03" + - "\x02\x02\x02?@\x07/\x02\x02@A\x07/\x02\x02AE\x03\x02\x02\x02BD\n\x04\x02" + - "\x02CB\x03\x02\x02\x02DG\x03\x02\x02\x02EC\x03\x02\x02\x02EF\x03\x02\x02" + - "\x02FI\x03\x02\x02\x02GE\x03\x02\x02\x02HJ\x07\x0F\x02\x02IH\x03\x02\x02" + - "\x02IJ\x03\x02\x02\x02JK\x03\x02\x02\x02KL\x07\f\x02\x02L\t\x03\x02\x02" + - "\x02MN\x071\x02\x02NO\x07,\x02\x02OP\x03\x02\x02\x02PQ\b\x05\x02\x02Q" + - "\v\x03\x02\x02\x02RS\x05\x06\x03\x02ST\x03\x02\x02\x02TU\b\x06\x03\x02" + - "U\r\x03\x02\x02\x02VW\x07#\x02\x02W\x0F\x03\x02\x02\x02XZ\t\x03\x02\x02" + - "YX\x03\x02\x02\x02Z[\x03\x02\x02\x02[Y\x03\x02\x02\x02[\\\x03\x02\x02" + - "\x02\\\x11\x03\x02\x02\x02]_\t\x05\x02\x02^]\x03\x02\x02\x02_`\x03\x02" + - "\x02\x02`^\x03\x02\x02\x02`a\x03\x02\x02\x02ab\x03\x02\x02\x02bc\b\t\x04" + - "\x02c\x13\x03\x02\x02\x02de\x07=\x02\x02e\x15\x03\x02\x02\x02fh\t\x06" + - "\x02\x02gf\x03\x02\x02\x02hi\x03\x02\x02\x02ig\x03\x02\x02\x02ij\x03\x02" + - "\x02\x02jk\x03\x02\x02\x02kl\b\v\x05\x02l\x17\x03\x02\x02\x02mw\x05\x04" + - "\x02\x02nx\x05\x04\x02\x02oq\v\x02\x02\x02po\x03\x02\x02\x02qt\x03\x02" + - "\x02\x02rs\x03\x02\x02\x02rp\x03\x02\x02\x02su\x03\x02\x02\x02tr\x03\x02" + - "\x02\x02uv\n\x07\x02\x02vx\x05\x04\x02\x02wn\x03\x02\x02\x02wr\x03\x02" + - "\x02\x02x\x19\x03\x02\x02\x02yz\x07<\x02\x02z\x1B\x03\x02\x02\x02{|\x07" + - "<\x02\x02|}\x07<\x02\x02}~\x03\x02\x02\x02~\x7F\b\x0E\x04\x02\x7F\x1D" + - "\x03\x02\x02\x02\x80\x81\x05\x06\x03\x02\x81\x82\x03\x02\x02\x02\x82\x83" + - "\b\x0F\x03\x02\x83\x1F\x03\x02\x02\x02\x84\x86\t\x06\x02\x02\x85\x84\x03" + - "\x02\x02\x02\x86\x87\x03\x02\x02\x02\x87\x85\x03\x02\x02\x02\x87\x88\x03" + - "\x02\x02\x02\x88\x89\x03\x02\x02\x02\x89\x8A\b\x10\x05\x02\x8A!\x03\x02" + - "\x02\x02\x8B\x8C\x07/\x02\x02\x8C\x8D\x07@\x02\x02\x8D#\x03\x02\x02\x02" + - "\x8E\x8F\x070\x02\x02\x8F\x90\x070\x02\x02\x90\x91\x070\x02\x02\x91%\x03" + - "\x02\x02\x02\x92\x93\x07B\x02\x02\x93\x94\x07p\x02\x02\x94\x95\x07c\x02" + - "\x02\x95\x96\x07o\x02\x02\x96\x97\x07g\x02\x02\x97\'\x03\x02\x02\x02\x98" + - "\x99\x07B\x02\x02\x99\x9A\x07r\x02\x02\x9A\x9B\x07c\x02\x02\x9B\x9C\x07" + - "t\x02\x02\x9C\x9D\x07c\x02\x02\x9D\x9E\x07o\x02\x02\x9E)\x03\x02\x02\x02" + - "\x9F\xA0\x07*\x02\x02\xA0+\x03\x02\x02\x02\xA1\xA2\x07+\x02\x02\xA2-\x03" + - "\x02\x02\x02\xA3\xA4\x07.\x02\x02\xA4/\x03\x02\x02\x02\xA5\xA6\x07#\x02" + - "\x02\xA61\x03\x02\x02\x02\xA7\xA9\v\x02\x02\x02\xA8\xA7\x03\x02\x02\x02" + - "\xA9\xAA\x03\x02\x02\x02\xAA\xAB\x03\x02\x02\x02\xAA\xA8\x03\x02\x02\x02" + - "\xAB3\x03\x02\x02\x02\xAC\xAD\x07,\x02\x02\xAD\xAE\x071\x02\x02\xAE\xAF" + - "\x03\x02\x02\x02\xAF\xB0\b\x1A\x06\x02\xB05\x03\x02\x02\x02\x0E\x02\x03" + - "B]]_`bb}\x80\x05\x02\v\f\x0F\x0F" + + "\"\"\x03\x02^^\x02\xD3\x02\b\x03\x02\x02\x02\x02\n\x03\x02\x02\x02\x02" + + "\f\x03\x02\x02\x02\x02\x0E\x03\x02\x02\x02\x02\x10\x03\x02\x02\x02\x02" + + "\x12\x03\x02\x02\x02\x02\x14\x03\x02\x02\x02\x02\x16\x03\x02\x02\x02\x02" + + "\x18\x03\x02\x02\x02\x02\x1A\x03\x02\x02\x02\x02\x1C\x03\x02\x02\x02\x02" + + "\x1E\x03\x02\x02\x02\x02 \x03\x02\x02\x02\x03\"\x03\x02\x02\x02\x03$\x03" + + "\x02\x02\x02\x03&\x03\x02\x02\x02\x03(\x03\x02\x02\x02\x03*\x03\x02\x02" + + "\x02\x03,\x03\x02\x02\x02\x03.\x03\x02\x02\x02\x030\x03\x02\x02\x02\x03" + + "2\x03\x02\x02\x02\x034\x03\x02\x02\x02\x036\x03\x02\x02\x02\x038\x03\x02" + + "\x02\x02\x04:\x03\x02\x02\x02\x06<\x03\x02\x02\x02\bC\x03\x02\x02\x02" + + "\nQ\x03\x02\x02\x02\fV\x03\x02\x02\x02\x0EZ\x03\x02\x02\x02\x10]\x03\x02" + + "\x02\x02\x12b\x03\x02\x02\x02\x14h\x03\x02\x02\x02\x16l\x03\x02\x02\x02" + + "\x18o\x03\x02\x02\x02\x1Au\x03\x02\x02\x02\x1C\x81\x03\x02\x02\x02\x1E" + + "\x92\x03\x02\x02\x02 \x94\x03\x02\x02\x02\"\x99\x03\x02\x02\x02$\x9E\x03" + + "\x02\x02\x02&\xA4\x03\x02\x02\x02(\xA7\x03\x02\x02\x02*\xAB\x03\x02\x02" + + "\x02,\xB1\x03\x02\x02\x02.\xB8\x03\x02\x02\x020\xBA\x03\x02\x02\x022\xBC" + + "\x03\x02\x02\x024\xBE\x03\x02\x02\x026\xC1\x03\x02\x02\x028\xC5\x03\x02" + + "\x02\x02:;\x07)\x02\x02;\x05\x03\x02\x02\x02<@\t\x02\x02\x02=?\t\x03\x02" + + "\x02>=\x03\x02\x02\x02?B\x03\x02\x02\x02@>\x03\x02\x02\x02@A\x03\x02\x02" + + "\x02A\x07\x03\x02\x02\x02B@\x03\x02\x02\x02CD\x07/\x02\x02DE\x07/\x02" + + "\x02EI\x03\x02\x02\x02FH\n\x04\x02\x02GF\x03\x02\x02\x02HK\x03\x02\x02" + + "\x02IG\x03\x02\x02\x02IJ\x03\x02\x02\x02JM\x03\x02\x02\x02KI\x03\x02\x02" + + "\x02LN\x07\x0F\x02\x02ML\x03\x02\x02\x02MN\x03\x02\x02\x02NO\x03\x02\x02" + + "\x02OP\x07\f\x02\x02P\t\x03\x02\x02\x02QR\x071\x02\x02RS\x07,\x02\x02" + + "ST\x03\x02\x02\x02TU\b\x05\x02\x02U\v\x03\x02\x02\x02VW\x05\x06\x03\x02" + + "WX\x03\x02\x02\x02XY\b\x06\x03\x02Y\r\x03\x02\x02\x02Z[\x07#\x02\x02[" + + "\x0F\x03\x02\x02\x02\\^\t\x03\x02\x02]\\\x03\x02\x02\x02^_\x03\x02\x02" + + "\x02_]\x03\x02\x02\x02_`\x03\x02\x02\x02`\x11\x03\x02\x02\x02ac\t\x05" + + "\x02\x02ba\x03\x02\x02\x02cd\x03\x02\x02\x02db\x03\x02\x02\x02de\x03\x02" + + "\x02\x02ef\x03\x02\x02\x02fg\b\t\x04\x02g\x13\x03\x02\x02\x02hi\x07&\x02" + + "\x02ij\x03\x02\x02\x02jk\b\n\x04\x02k\x15\x03\x02\x02\x02lm\x07=\x02\x02" + + "m\x17\x03\x02\x02\x02np\t\x06\x02\x02on\x03\x02\x02\x02pq\x03\x02\x02" + + "\x02qo\x03\x02\x02\x02qr\x03\x02\x02\x02rs\x03\x02\x02\x02st\b\f\x05\x02" + + "t\x19\x03\x02\x02\x02u\x7F\x05\x04\x02\x02v\x80\x05\x04\x02\x02wy\v\x02" + + "\x02\x02xw\x03\x02\x02\x02y|\x03\x02\x02\x02z{\x03\x02\x02\x02zx\x03\x02" + + "\x02\x02{}\x03\x02\x02\x02|z\x03\x02\x02\x02}~\n\x07\x02\x02~\x80\x05" + + "\x04\x02\x02\x7Fv\x03\x02\x02\x02\x7Fz\x03\x02\x02\x02\x80\x1B\x03\x02" + + "\x02\x02\x81\x83\x05\x14\n\x02\x82\x84\x05\x10\b\x02\x83\x82\x03\x02\x02" + + "\x02\x83\x84\x03\x02\x02\x02\x84\x85\x03\x02\x02\x02\x85\x89\x05\x14\n" + + "\x02\x86\x88\v\x02\x02\x02\x87\x86\x03\x02\x02\x02\x88\x8B\x03\x02\x02" + + "\x02\x89\x87\x03\x02\x02\x02\x89\x8A\x03\x02\x02\x02\x8A\x8C\x03\x02\x02" + + "\x02\x8B\x89\x03\x02\x02\x02\x8C\x8E\x05\x14\n\x02\x8D\x8F\x05\x10\b\x02" + + "\x8E\x8D\x03\x02\x02\x02\x8E\x8F\x03\x02\x02\x02\x8F\x90\x03\x02\x02\x02" + + "\x90\x91\x05\x14\n\x02\x91\x1D\x03\x02\x02\x02\x92\x93\x07<\x02\x02\x93" + + "\x1F\x03\x02\x02\x02\x94\x95\x07<\x02\x02\x95\x96\x07<\x02\x02\x96\x97" + + "\x03\x02\x02\x02\x97\x98\b\x10\x04\x02\x98!\x03\x02\x02\x02\x99\x9A\x05" + + "\x06\x03\x02\x9A\x9B\x03\x02\x02\x02\x9B\x9C\b\x11\x03\x02\x9C#\x03\x02" + + "\x02\x02\x9D\x9F\t\x06\x02\x02\x9E\x9D\x03\x02\x02\x02\x9F\xA0\x03\x02" + + "\x02\x02\xA0\x9E\x03\x02\x02\x02\xA0\xA1\x03\x02\x02\x02\xA1\xA2\x03\x02" + + "\x02\x02\xA2\xA3\b\x12\x05\x02\xA3%\x03\x02\x02\x02\xA4\xA5\x07/\x02\x02" + + "\xA5\xA6\x07@\x02\x02\xA6\'\x03\x02\x02\x02\xA7\xA8\x070\x02\x02\xA8\xA9" + + "\x070\x02\x02\xA9\xAA\x070\x02\x02\xAA)\x03\x02\x02\x02\xAB\xAC\x07B\x02" + + "\x02\xAC\xAD\x07p\x02\x02\xAD\xAE\x07c\x02\x02\xAE\xAF\x07o\x02\x02\xAF" + + "\xB0\x07g\x02\x02\xB0+\x03\x02\x02\x02\xB1\xB2\x07B\x02\x02\xB2\xB3\x07" + + "r\x02\x02\xB3\xB4\x07c\x02\x02\xB4\xB5\x07t\x02\x02\xB5\xB6\x07c\x02\x02" + + "\xB6\xB7\x07o\x02\x02\xB7-\x03\x02\x02\x02\xB8\xB9\x07*\x02\x02\xB9/\x03" + + "\x02\x02\x02\xBA\xBB\x07+\x02\x02\xBB1\x03\x02\x02\x02\xBC\xBD\x07.\x02" + + "\x02\xBD3\x03\x02\x02\x02\xBE\xBF\x07#\x02\x02\xBF5\x03\x02\x02\x02\xC0" + + "\xC2\v\x02\x02\x02\xC1\xC0\x03\x02\x02\x02\xC2\xC3\x03\x02\x02\x02\xC3" + + "\xC4\x03\x02\x02\x02\xC3\xC1\x03\x02\x02\x02\xC47\x03\x02\x02\x02\xC5" + + "\xC6\x07,\x02\x02\xC6\xC7\x071\x02\x02\xC7\xC8\x03\x02\x02\x02\xC8\xC9" + + "\b\x1C\x06\x02\xC99\x03\x02\x02\x02\x11\x02\x03@IM_dqz\x7F\x83\x89\x8E" + + "\xA0\xC3\x07\x04\x03\x02\t\x03\x02\t\x07\x02\b\x02\x02\x04\x02\x02"; public static __ATN: ATN; public static get _ATN(): ATN { if (!SQLLexer.__ATN) { diff --git a/packages/parser/src/loader/sql/parser/SQLParser.ts b/packages/parser/src/loader/sql/parser/SQLParser.ts index a4745398..61352fae 100644 --- a/packages/parser/src/loader/sql/parser/SQLParser.ts +++ b/packages/parser/src/loader/sql/parser/SQLParser.ts @@ -36,19 +36,21 @@ export class SQLParser extends Parser { public static readonly EOF_STATEMENT = 6; public static readonly WSL = 7; public static readonly STRING = 8; - public static readonly PARAM_MARK = 9; - public static readonly WS = 10; - public static readonly TRANSFORM_ARROW = 11; - public static readonly SPREAD = 12; - public static readonly NAME_TAG = 13; - public static readonly TYPE_TAG = 14; - public static readonly OB = 15; - public static readonly CB = 16; - public static readonly COMMA = 17; - public static readonly C_REQUIRED_MARK = 18; - public static readonly ANY = 19; - public static readonly CLOSE_COMMENT = 20; - public static readonly CAST = 21; + public static readonly DOLLAR_STRING = 9; + public static readonly PARAM_MARK = 10; + public static readonly WS = 11; + public static readonly TRANSFORM_ARROW = 12; + public static readonly SPREAD = 13; + public static readonly NAME_TAG = 14; + public static readonly TYPE_TAG = 15; + public static readonly OB = 16; + public static readonly CB = 17; + public static readonly COMMA = 18; + public static readonly C_REQUIRED_MARK = 19; + public static readonly ANY = 20; + public static readonly CLOSE_COMMENT = 21; + public static readonly DOLLAR = 22; + public static readonly CAST = 23; public static readonly RULE_input = 0; public static readonly RULE_query = 1; public static readonly RULE_queryDef = 2; @@ -70,22 +72,23 @@ export class SQLParser extends Parser { public static readonly RULE_paramName = 18; // tslint:disable:no-trailing-whitespace public static readonly ruleNames: string[] = [ - "input", "query", "queryDef", "ignoredComment", "statement", "statementBody", - "word", "param", "paramId", "nameTag", "paramTag", "paramTransform", "transformRule", - "spreadTransform", "pickTransform", "spreadPickTransform", "key", "queryName", + "input", "query", "queryDef", "ignoredComment", "statement", "statementBody", + "word", "param", "paramId", "nameTag", "paramTag", "paramTransform", "transformRule", + "spreadTransform", "pickTransform", "spreadPickTransform", "key", "queryName", "paramName", ]; private static readonly _LITERAL_NAMES: Array = [ - undefined, undefined, undefined, "'/*'", undefined, undefined, "';'", - undefined, undefined, "':'", undefined, "'->'", "'...'", "'@name'", "'@param'", - "'('", "')'", "','", undefined, undefined, "'*/'", "'::'", + undefined, undefined, undefined, "'/*'", undefined, undefined, "';'", + undefined, undefined, undefined, "':'", undefined, "'->'", "'...'", "'@name'", + "'@param'", "'('", "')'", "','", undefined, undefined, "'*/'", "'$'", + "'::'", ]; private static readonly _SYMBOLIC_NAMES: Array = [ - undefined, "ID", "LINE_COMMENT", "OPEN_COMMENT", "S_REQUIRED_MARK", "WORD", - "EOF_STATEMENT", "WSL", "STRING", "PARAM_MARK", "WS", "TRANSFORM_ARROW", - "SPREAD", "NAME_TAG", "TYPE_TAG", "OB", "CB", "COMMA", "C_REQUIRED_MARK", - "ANY", "CLOSE_COMMENT", "CAST", + undefined, "ID", "LINE_COMMENT", "OPEN_COMMENT", "S_REQUIRED_MARK", "WORD", + "EOF_STATEMENT", "WSL", "STRING", "DOLLAR_STRING", "PARAM_MARK", "WS", + "TRANSFORM_ARROW", "SPREAD", "NAME_TAG", "TYPE_TAG", "OB", "CB", "COMMA", + "C_REQUIRED_MARK", "ANY", "CLOSE_COMMENT", "DOLLAR", "CAST", ]; public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(SQLParser._LITERAL_NAMES, SQLParser._SYMBOLIC_NAMES, []); @@ -254,7 +257,7 @@ export class SQLParser extends Parser { this.state = 68; this._errHandler.sync(this); _la = this._input.LA(1); - while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << SQLParser.ID) | (1 << SQLParser.LINE_COMMENT) | (1 << SQLParser.OPEN_COMMENT) | (1 << SQLParser.S_REQUIRED_MARK) | (1 << SQLParser.WORD) | (1 << SQLParser.EOF_STATEMENT) | (1 << SQLParser.WSL) | (1 << SQLParser.STRING) | (1 << SQLParser.PARAM_MARK) | (1 << SQLParser.WS) | (1 << SQLParser.TRANSFORM_ARROW) | (1 << SQLParser.SPREAD) | (1 << SQLParser.NAME_TAG) | (1 << SQLParser.TYPE_TAG) | (1 << SQLParser.OB) | (1 << SQLParser.CB) | (1 << SQLParser.COMMA) | (1 << SQLParser.C_REQUIRED_MARK) | (1 << SQLParser.ANY) | (1 << SQLParser.CAST))) !== 0)) { + while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << SQLParser.ID) | (1 << SQLParser.LINE_COMMENT) | (1 << SQLParser.OPEN_COMMENT) | (1 << SQLParser.S_REQUIRED_MARK) | (1 << SQLParser.WORD) | (1 << SQLParser.EOF_STATEMENT) | (1 << SQLParser.WSL) | (1 << SQLParser.STRING) | (1 << SQLParser.DOLLAR_STRING) | (1 << SQLParser.PARAM_MARK) | (1 << SQLParser.WS) | (1 << SQLParser.TRANSFORM_ARROW) | (1 << SQLParser.SPREAD) | (1 << SQLParser.NAME_TAG) | (1 << SQLParser.TYPE_TAG) | (1 << SQLParser.OB) | (1 << SQLParser.CB) | (1 << SQLParser.COMMA) | (1 << SQLParser.C_REQUIRED_MARK) | (1 << SQLParser.ANY) | (1 << SQLParser.DOLLAR) | (1 << SQLParser.CAST))) !== 0)) { { { this.state = 65; @@ -331,7 +334,7 @@ export class SQLParser extends Parser { this.state = 82; this._errHandler.sync(this); _la = this._input.LA(1); - while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << SQLParser.ID) | (1 << SQLParser.LINE_COMMENT) | (1 << SQLParser.OPEN_COMMENT) | (1 << SQLParser.S_REQUIRED_MARK) | (1 << SQLParser.WORD) | (1 << SQLParser.STRING) | (1 << SQLParser.PARAM_MARK))) !== 0)) { + while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << SQLParser.ID) | (1 << SQLParser.LINE_COMMENT) | (1 << SQLParser.OPEN_COMMENT) | (1 << SQLParser.S_REQUIRED_MARK) | (1 << SQLParser.WORD) | (1 << SQLParser.STRING) | (1 << SQLParser.DOLLAR_STRING) | (1 << SQLParser.PARAM_MARK))) !== 0)) { { this.state = 80; this._errHandler.sync(this); @@ -358,6 +361,7 @@ export class SQLParser extends Parser { case SQLParser.S_REQUIRED_MARK: case SQLParser.WORD: case SQLParser.STRING: + case SQLParser.DOLLAR_STRING: { this.state = 79; this.word(); @@ -397,7 +401,7 @@ export class SQLParser extends Parser { { this.state = 85; _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << SQLParser.ID) | (1 << SQLParser.S_REQUIRED_MARK) | (1 << SQLParser.WORD) | (1 << SQLParser.STRING))) !== 0))) { + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << SQLParser.ID) | (1 << SQLParser.S_REQUIRED_MARK) | (1 << SQLParser.WORD) | (1 << SQLParser.STRING) | (1 << SQLParser.DOLLAR_STRING))) !== 0))) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token.EOF) { @@ -822,7 +826,7 @@ export class SQLParser extends Parser { } public static readonly _serializedATN: string = - "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x03\x17\x8F\x04\x02" + + "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x03\x19\x8F\x04\x02" + "\t\x02\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06\t\x06\x04\x07" + "\t\x07\x04\b\t\b\x04\t\t\t\x04\n\t\n\x04\v\t\v\x04\f\t\f\x04\r\t\r\x04" + "\x0E\t\x0E\x04\x0F\t\x0F\x04\x10\t\x10\x04\x11\t\x11\x04\x12\t\x12\x04" + @@ -839,8 +843,8 @@ export class SQLParser extends Parser { "\x03\x11\x03\x12\x03\x12\x05\x12\x89\n\x12\x03\x13\x03\x13\x03\x14\x03" + "\x14\x03\x14\x02\x02\x02\x15\x02\x02\x04\x02\x06\x02\b\x02\n\x02\f\x02" + "\x0E\x02\x10\x02\x12\x02\x14\x02\x16\x02\x18\x02\x1A\x02\x1C\x02\x1E\x02" + - " \x02\"\x02$\x02&\x02\x02\x04\x03\x02\x16\x16\x05\x02\x03\x03\x06\x07" + - "\n\n\x02\x89\x02/\x03\x02\x02\x02\x045\x03\x02\x02\x02\x068\x03\x02\x02" + + " \x02\"\x02$\x02&\x02\x02\x04\x03\x02\x17\x17\x05\x02\x03\x03\x06\x07" + + "\n\v\x02\x89\x02/\x03\x02\x02\x02\x045\x03\x02\x02\x02\x068\x03\x02\x02" + "\x02\bB\x03\x02\x02\x02\nK\x03\x02\x02\x02\fT\x03\x02\x02\x02\x0EW\x03" + "\x02\x02\x02\x10Y\x03\x02\x02\x02\x12\\\x03\x02\x02\x02\x14`\x03\x02\x02" + "\x02\x16c\x03\x02\x02\x02\x18g\x03\x02\x02\x02\x1Am\x03\x02\x02\x02\x1C" + @@ -852,29 +856,29 @@ export class SQLParser extends Parser { "34\x07\x02\x02\x034\x03\x03\x02\x02\x0256\x05\x06\x04\x0267\x05\n\x06" + "\x027\x05\x03\x02\x02\x0289\x07\x05\x02\x029=\x05\x14\v\x02:<\x05\x16" + "\f\x02;:\x03\x02\x02\x02\x03\x02" + - "\x02\x02>@\x03\x02\x02\x02?=\x03\x02\x02\x02@A\x07\x16\x02\x02A\x07\x03" + + "\x02\x02>@\x03\x02\x02\x02?=\x03\x02\x02\x02@A\x07\x17\x02\x02A\x07\x03" + "\x02\x02\x02BF\x07\x05\x02\x02CE\n\x02\x02\x02DC\x03\x02\x02\x02EH\x03" + "\x02\x02\x02FD\x03\x02\x02\x02FG\x03\x02\x02\x02GI\x03\x02\x02\x02HF\x03" + - "\x02\x02\x02IJ\x07\x16\x02\x02J\t\x03\x02\x02\x02KL\x05\f\x07\x02LM\x07" + + "\x02\x02\x02IJ\x07\x17\x02\x02J\t\x03\x02\x02\x02KL\x05\f\x07\x02LM\x07" + "\b\x02\x02M\v\x03\x02\x02\x02NS\x07\x04\x02\x02OS\x05\b\x05\x02PS\x05" + "\x10\t\x02QS\x05\x0E\b\x02RN\x03\x02\x02\x02RO\x03\x02\x02\x02RP\x03\x02" + "\x02\x02RQ\x03\x02\x02\x02SV\x03\x02\x02\x02TR\x03\x02\x02\x02TU\x03\x02" + "\x02\x02U\r\x03\x02\x02\x02VT\x03\x02\x02\x02WX\t\x03\x02\x02X\x0F\x03" + - "\x02\x02\x02YZ\x07\v\x02\x02Z[\x05\x12\n\x02[\x11\x03\x02\x02\x02\\^\x07" + + "\x02\x02\x02YZ\x07\f\x02\x02Z[\x05\x12\n\x02[\x11\x03\x02\x02\x02\\^\x07" + "\x03\x02\x02]_\x07\x06\x02\x02^]\x03\x02\x02\x02^_\x03\x02\x02\x02_\x13" + - "\x03\x02\x02\x02`a\x07\x0F\x02\x02ab\x05$\x13\x02b\x15\x03\x02\x02\x02" + - "cd\x07\x10\x02\x02de\x05&\x14\x02ef\x05\x18\r\x02f\x17\x03\x02\x02\x02" + - "gh\x07\r\x02\x02hi\x05\x1A\x0E\x02i\x19\x03\x02\x02\x02jn\x05\x1C\x0F" + + "\x03\x02\x02\x02`a\x07\x10\x02\x02ab\x05$\x13\x02b\x15\x03\x02\x02\x02" + + "cd\x07\x11\x02\x02de\x05&\x14\x02ef\x05\x18\r\x02f\x17\x03\x02\x02\x02" + + "gh\x07\x0E\x02\x02hi\x05\x1A\x0E\x02i\x19\x03\x02\x02\x02jn\x05\x1C\x0F" + "\x02kn\x05\x1E\x10\x02ln\x05 \x11\x02mj\x03\x02\x02\x02mk\x03\x02\x02" + - "\x02ml\x03\x02\x02\x02n\x1B\x03\x02\x02\x02op\x07\x11\x02\x02pq\x07\x0E" + - "\x02\x02qr\x07\x12\x02\x02r\x1D\x03\x02\x02\x02st\x07\x11\x02\x02ty\x05" + - "\"\x12\x02uv\x07\x13\x02\x02vx\x05\"\x12\x02wu\x03\x02\x02\x02x{\x03\x02" + + "\x02ml\x03\x02\x02\x02n\x1B\x03\x02\x02\x02op\x07\x12\x02\x02pq\x07\x0F" + + "\x02\x02qr\x07\x13\x02\x02r\x1D\x03\x02\x02\x02st\x07\x12\x02\x02ty\x05" + + "\"\x12\x02uv\x07\x14\x02\x02vx\x05\"\x12\x02wu\x03\x02\x02\x02x{\x03\x02" + "\x02\x02yw\x03\x02\x02\x02yz\x03\x02\x02\x02z}\x03\x02\x02\x02{y\x03\x02" + - "\x02\x02|~\x07\x13\x02\x02}|\x03\x02\x02\x02}~\x03\x02\x02\x02~\x7F\x03" + - "\x02\x02\x02\x7F\x80\x07\x12\x02\x02\x80\x1F\x03\x02\x02\x02\x81\x82\x07" + - "\x11\x02\x02\x82\x83\x05\x1E\x10\x02\x83\x84\x07\x0E\x02\x02\x84\x85\x07" + - "\x12\x02\x02\x85!\x03\x02\x02\x02\x86\x88\x07\x03\x02\x02\x87\x89\x07" + - "\x14\x02\x02\x88\x87\x03\x02\x02\x02\x88\x89\x03\x02\x02\x02\x89#\x03" + + "\x02\x02|~\x07\x14\x02\x02}|\x03\x02\x02\x02}~\x03\x02\x02\x02~\x7F\x03" + + "\x02\x02\x02\x7F\x80\x07\x13\x02\x02\x80\x1F\x03\x02\x02\x02\x81\x82\x07" + + "\x12\x02\x02\x82\x83\x05\x1E\x10\x02\x83\x84\x07\x0F\x02\x02\x84\x85\x07" + + "\x13\x02\x02\x85!\x03\x02\x02\x02\x86\x88\x07\x03\x02\x02\x87\x89\x07" + + "\x15\x02\x02\x88\x87\x03\x02\x02\x02\x88\x89\x03\x02\x02\x02\x89#\x03" + "\x02\x02\x02\x8A\x8B\x07\x03\x02\x02\x8B%\x03\x02\x02\x02\x8C\x8D\x07" + "\x03\x02\x02\x8D\'\x03\x02\x02\x02\r+1=FRT^my}\x88"; public static __ATN: ATN; @@ -1156,6 +1160,7 @@ export class WordContext extends ParserRuleContext { public ID(): TerminalNode | undefined { return this.tryGetToken(SQLParser.ID, 0); } public STRING(): TerminalNode | undefined { return this.tryGetToken(SQLParser.STRING, 0); } public S_REQUIRED_MARK(): TerminalNode | undefined { return this.tryGetToken(SQLParser.S_REQUIRED_MARK, 0); } + public DOLLAR_STRING(): TerminalNode | undefined { return this.tryGetToken(SQLParser.DOLLAR_STRING, 0); } constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); }