This is an automated email from the ASF dual-hosted git repository.
eya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-age.git
The following commit(s) were added to refs/heads/master by this push:
new e87edb9 fix: (driver/nodejs) replaced to ANTLR4 Parser. (#63)
e87edb9 is described below
commit e87edb925eed60b9f83bf6f77b8e3ceab6e1438e
Author: Alex Kwak <[email protected]>
AuthorDate: Tue May 18 08:55:21 2021 +0900
fix: (driver/nodejs) replaced to ANTLR4 Parser. (#63)
* fix: (driver/nodejs) replaced to ANTLR4 Parser.
* fix: (driver/nodejs) enable eslint.
* fix: (driver/nodejs) insert copyright.
---
drivers/nodejs/.eslintrc.js | 20 +
drivers/nodejs/jest.config.js | 4 +-
drivers/nodejs/package.json | 13 +-
drivers/nodejs/src/antlr4/Agtype.g4 | 116 +++
drivers/nodejs/src/antlr4/Agtype.interp | 57 ++
drivers/nodejs/src/antlr4/Agtype.tokens | 32 +
drivers/nodejs/src/antlr4/AgtypeLexer.interp | 81 ++
drivers/nodejs/src/antlr4/AgtypeLexer.tokens | 32 +
drivers/nodejs/src/antlr4/AgtypeLexer.ts | 214 +++++
drivers/nodejs/src/antlr4/AgtypeListener.ts | 240 ++++++
drivers/nodejs/src/antlr4/AgtypeParser.ts | 993 ++++++++++++++++++++++
drivers/nodejs/src/antlr4/CustomAgTypeListener.ts | 131 +++
drivers/nodejs/src/index.ts | 46 +-
drivers/nodejs/test/Agtype.test.ts | 70 ++
drivers/nodejs/test/index.test.ts | 111 ++-
drivers/nodejs/tsconfig.json | 2 +-
16 files changed, 2089 insertions(+), 73 deletions(-)
diff --git a/drivers/nodejs/.eslintrc.js b/drivers/nodejs/.eslintrc.js
new file mode 100644
index 0000000..2988cae
--- /dev/null
+++ b/drivers/nodejs/.eslintrc.js
@@ -0,0 +1,20 @@
+module.exports = {
+ env: {
+ es2021: true,
+ node: true
+ },
+ extends: [
+ 'standard',
+ 'plugin:jest/recommended'
+ ],
+ parser: '@typescript-eslint/parser',
+ parserOptions: {
+ ecmaVersion: 12,
+ sourceType: 'module'
+ },
+ plugins: [
+ '@typescript-eslint',
+ 'jest'
+ ],
+ rules: {}
+}
diff --git a/drivers/nodejs/jest.config.js b/drivers/nodejs/jest.config.js
index 91a2d2c..758fa13 100644
--- a/drivers/nodejs/jest.config.js
+++ b/drivers/nodejs/jest.config.js
@@ -1,4 +1,4 @@
module.exports = {
preset: 'ts-jest',
- testEnvironment: 'node',
-};
\ No newline at end of file
+ testEnvironment: 'node'
+}
diff --git a/drivers/nodejs/package.json b/drivers/nodejs/package.json
index 818db30..429e519 100644
--- a/drivers/nodejs/package.json
+++ b/drivers/nodejs/package.json
@@ -3,18 +3,29 @@
"version": "1.0.0-alpha",
"main": "dist/index.js",
"scripts": {
+ "antlr4ts": "antlr4ts src/antlr4/Agtype.g4",
"test": "jest --verbose ./test",
- "build": "tsc",
+ "build": "rm -rf dist && tsc",
"prepare": "npm run build"
},
"keywords": [],
"author": "Alex Kwak <[email protected]>",
"dependencies": {
+ "antlr4ts": "^0.5.0-alpha.4",
"pg": ">=6.0.0"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"@types/pg": "^7.14.10",
+ "@typescript-eslint/eslint-plugin": "^4.22.1",
+ "@typescript-eslint/parser": "^4.22.1",
+ "antlr4ts-cli": "^0.5.0-alpha.4",
+ "eslint": "^7.25.0",
+ "eslint-config-standard": "^16.0.2",
+ "eslint-plugin-import": "^2.22.1",
+ "eslint-plugin-jest": "^24.3.6",
+ "eslint-plugin-node": "^11.1.0",
+ "eslint-plugin-promise": "^4.3.1",
"jest": "^26.6.3",
"ts-jest": "^26.5.1",
"typescript": "^4.1.5"
diff --git a/drivers/nodejs/src/antlr4/Agtype.g4
b/drivers/nodejs/src/antlr4/Agtype.g4
new file mode 100644
index 0000000..1d75c1c
--- /dev/null
+++ b/drivers/nodejs/src/antlr4/Agtype.g4
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.
+ */
+
+grammar Agtype;
+
+agType
+ : agValue EOF
+ ;
+
+agValue
+ : value typeAnnotation?
+ ;
+
+value
+ : STRING #StringValue
+ | INTEGER #IntegerValue
+ | floatLiteral #FloatValue
+ | 'true' #TrueBoolean
+ | 'false' #FalseBoolean
+ | 'null' #NullValue
+ | obj #ObjectValue
+ | array #ArrayValue
+ ;
+
+obj
+ : '{' pair (',' pair)* '}'
+ | '{' '}'
+ ;
+
+pair
+ : STRING ':' agValue
+ ;
+
+array
+ : '[' agValue (',' agValue)* ']'
+ | '[' ']'
+ ;
+
+typeAnnotation
+ : '::' IDENT
+ ;
+
+IDENT
+ : [A-Z_a-z][$0-9A-Z_a-z]*
+ ;
+
+STRING
+ : '"' (ESC | SAFECODEPOINT)* '"'
+ ;
+
+fragment ESC
+ : '\\' (["\\/bfnrt] | UNICODE)
+ ;
+
+fragment UNICODE
+ : 'u' HEX HEX HEX HEX
+ ;
+
+fragment HEX
+ : [0-9a-fA-F]
+ ;
+
+fragment SAFECODEPOINT
+ : ~ ["\\\u0000-\u001F]
+ ;
+
+INTEGER
+ : '-'? INT
+ ;
+
+fragment INT
+ : '0' | [1-9] [0-9]*
+ ;
+
+floatLiteral
+ : RegularFloat
+ | ExponentFloat
+ | '-'? 'Infinity'
+ | 'NaN'
+ ;
+
+RegularFloat
+ : '-'? INT DECIMAL
+ ;
+
+ExponentFloat
+ : '-'? INT DECIMAL? SCIENTIFIC
+ ;
+
+fragment DECIMAL
+ : '.' [0-9]+
+ ;
+
+fragment SCIENTIFIC
+ : [Ee][+-]? [0-9]+
+ ;
+
+WS
+ : [ \t\n\r] + -> skip
+ ;
diff --git a/drivers/nodejs/src/antlr4/Agtype.interp
b/drivers/nodejs/src/antlr4/Agtype.interp
new file mode 100644
index 0000000..c364b57
--- /dev/null
+++ b/drivers/nodejs/src/antlr4/Agtype.interp
@@ -0,0 +1,57 @@
+token literal names:
+null
+'true'
+'false'
+'null'
+'{'
+','
+'}'
+':'
+'['
+']'
+'::'
+'-'
+'Infinity'
+'NaN'
+null
+null
+null
+null
+null
+null
+
+token symbolic names:
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+IDENT
+STRING
+INTEGER
+RegularFloat
+ExponentFloat
+WS
+
+rule names:
+agType
+agValue
+value
+obj
+pair
+array
+typeAnnotation
+floatLiteral
+
+
+atn:
+[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 3, 21, 82, 4, 2, 9,
2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4,
9, 9, 9, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 5, 3, 24, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4,
3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 34, 10, 4, 3, 5, 3, 5, 3, 5, 3, 5, 7, 5, 40, 10,
5, 12, 5, 14, 5, 43, 11, 5, 3, 5, 3, 5, 3, 5, 3, 5, 5, 5, 49, 10, 5, 3, 6, 3,
6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 7, 7, 59, 10, 7, 12, 7, 14, 7, 62, 11,
7, 3, 7, 3, 7, 3, 7, [...]
\ No newline at end of file
diff --git a/drivers/nodejs/src/antlr4/Agtype.tokens
b/drivers/nodejs/src/antlr4/Agtype.tokens
new file mode 100644
index 0000000..193f8c9
--- /dev/null
+++ b/drivers/nodejs/src/antlr4/Agtype.tokens
@@ -0,0 +1,32 @@
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+T__5=6
+T__6=7
+T__7=8
+T__8=9
+T__9=10
+T__10=11
+T__11=12
+T__12=13
+IDENT=14
+STRING=15
+INTEGER=16
+RegularFloat=17
+ExponentFloat=18
+WS=19
+'true'=1
+'false'=2
+'null'=3
+'{'=4
+','=5
+'}'=6
+':'=7
+'['=8
+']'=9
+'::'=10
+'-'=11
+'Infinity'=12
+'NaN'=13
diff --git a/drivers/nodejs/src/antlr4/AgtypeLexer.interp
b/drivers/nodejs/src/antlr4/AgtypeLexer.interp
new file mode 100644
index 0000000..ae4b0b4
--- /dev/null
+++ b/drivers/nodejs/src/antlr4/AgtypeLexer.interp
@@ -0,0 +1,81 @@
+token literal names:
+null
+'true'
+'false'
+'null'
+'{'
+','
+'}'
+':'
+'['
+']'
+'::'
+'-'
+'Infinity'
+'NaN'
+null
+null
+null
+null
+null
+null
+
+token symbolic names:
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+IDENT
+STRING
+INTEGER
+RegularFloat
+ExponentFloat
+WS
+
+rule names:
+T__0
+T__1
+T__2
+T__3
+T__4
+T__5
+T__6
+T__7
+T__8
+T__9
+T__10
+T__11
+T__12
+IDENT
+STRING
+ESC
+UNICODE
+HEX
+SAFECODEPOINT
+INTEGER
+INT
+RegularFloat
+ExponentFloat
+DECIMAL
+SCIENTIFIC
+WS
+
+channel names:
+DEFAULT_TOKEN_CHANNEL
+HIDDEN
+
+mode names:
+DEFAULT_MODE
+
+atn:
+[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 2, 21, 185, 8, 1, 4,
2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9,
8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14,
9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4,
20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9,
25, 4, 26, 9, 26, 4, 27, 9, 27, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, [...]
\ No newline at end of file
diff --git a/drivers/nodejs/src/antlr4/AgtypeLexer.tokens
b/drivers/nodejs/src/antlr4/AgtypeLexer.tokens
new file mode 100644
index 0000000..193f8c9
--- /dev/null
+++ b/drivers/nodejs/src/antlr4/AgtypeLexer.tokens
@@ -0,0 +1,32 @@
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+T__5=6
+T__6=7
+T__7=8
+T__8=9
+T__9=10
+T__10=11
+T__11=12
+T__12=13
+IDENT=14
+STRING=15
+INTEGER=16
+RegularFloat=17
+ExponentFloat=18
+WS=19
+'true'=1
+'false'=2
+'null'=3
+'{'=4
+','=5
+'}'=6
+':'=7
+'['=8
+']'=9
+'::'=10
+'-'=11
+'Infinity'=12
+'NaN'=13
diff --git a/drivers/nodejs/src/antlr4/AgtypeLexer.ts
b/drivers/nodejs/src/antlr4/AgtypeLexer.ts
new file mode 100644
index 0000000..b63c353
--- /dev/null
+++ b/drivers/nodejs/src/antlr4/AgtypeLexer.ts
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.
+ */
+
+/* eslint-disable */
+// Generated from src/antlr4/Agtype.g4 by ANTLR 4.9.0-SNAPSHOT
+
+import { ATN } from 'antlr4ts/atn/ATN'
+import { ATNDeserializer } from 'antlr4ts/atn/ATNDeserializer'
+import { CharStream } from 'antlr4ts/CharStream'
+import { Lexer } from 'antlr4ts/Lexer'
+import { LexerATNSimulator } from 'antlr4ts/atn/LexerATNSimulator'
+import { Vocabulary } from 'antlr4ts/Vocabulary'
+import { VocabularyImpl } from 'antlr4ts/VocabularyImpl'
+
+import * as Utils from 'antlr4ts/misc/Utils'
+
+export class AgtypeLexer extends Lexer {
+ public static readonly T__0 = 1;
+ public static readonly T__1 = 2;
+ public static readonly T__2 = 3;
+ public static readonly T__3 = 4;
+ public static readonly T__4 = 5;
+ public static readonly T__5 = 6;
+ public static readonly T__6 = 7;
+ public static readonly T__7 = 8;
+ public static readonly T__8 = 9;
+ public static readonly T__9 = 10;
+ public static readonly T__10 = 11;
+ public static readonly T__11 = 12;
+ public static readonly T__12 = 13;
+ public static readonly IDENT = 14;
+ public static readonly STRING = 15;
+ public static readonly INTEGER = 16;
+ public static readonly RegularFloat = 17;
+ public static readonly ExponentFloat = 18;
+ public static readonly WS = 19;
+
+ // tslint:disable:no-trailing-whitespace
+ public static readonly channelNames: string[] = [
+ 'DEFAULT_TOKEN_CHANNEL', 'HIDDEN'
+ ];
+
+ // tslint:disable:no-trailing-whitespace
+ public static readonly modeNames: string[] = [
+ 'DEFAULT_MODE'
+ ];
+
+ public static readonly ruleNames: string[] = [
+ 'T__0', 'T__1', 'T__2', 'T__3', 'T__4', 'T__5', 'T__6', 'T__7', 'T__8',
+ 'T__9', 'T__10', 'T__11', 'T__12', 'IDENT', 'STRING', 'ESC', 'UNICODE',
+ 'HEX', 'SAFECODEPOINT', 'INTEGER', 'INT', 'RegularFloat',
'ExponentFloat',
+ 'DECIMAL', 'SCIENTIFIC', 'WS'
+ ];
+
+ private static readonly _LITERAL_NAMES: Array<string | undefined> = [
+ undefined, "'true'", "'false'", "'null'", "'{'", "','", "'}'", "':'",
+ "'['", "']'", "'::'", "'-'", "'Infinity'", "'NaN'"
+ ];
+
+ private static readonly _SYMBOLIC_NAMES: Array<string | undefined> = [
+ undefined, undefined, undefined, undefined, undefined, undefined,
undefined,
+ undefined, undefined, undefined, undefined, undefined, undefined,
undefined,
+ 'IDENT', 'STRING', 'INTEGER', 'RegularFloat', 'ExponentFloat', 'WS'
+ ];
+
+ public static readonly VOCABULARY: Vocabulary = new
VocabularyImpl(AgtypeLexer._LITERAL_NAMES, AgtypeLexer._SYMBOLIC_NAMES, []);
+
+ // @Override
+ // @NotNull
+ public get vocabulary (): Vocabulary {
+ return AgtypeLexer.VOCABULARY
+ }
+
+ // tslint:enable:no-trailing-whitespace
+
+ constructor (input: CharStream) {
+ super(input)
+ this._interp = new LexerATNSimulator(AgtypeLexer._ATN, this)
+ }
+
+ // @Override
+ public get grammarFileName (): string {
+ return 'Agtype.g4'
+ }
+
+ // @Override
+ public get ruleNames (): string[] {
+ return AgtypeLexer.ruleNames
+ }
+
+ // @Override
+ public get serializedATN (): string {
+ return AgtypeLexer._serializedATN
+ }
+
+ // @Override
+ public get channelNames (): string[] {
+ return AgtypeLexer.channelNames
+ }
+
+ // @Override
+ public get modeNames (): string[] {
+ return AgtypeLexer.modeNames
+ }
+
+ public static readonly _serializedATN: string =
+
'\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x02\x15\xB9\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\x04\x1B\t\x1B\x03\x02\x03' +
+
'\x02\x03\x02\x03\x02\x03\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03' +
+
'\x03\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x05\x03\x05\x03\x06\x03' +
+
'\x06\x03\x07\x03\x07\x03\b\x03\b\x03\t\x03\t\x03\n\x03\n\x03\v\x03\v\x03' +
+
'\v\x03\f\x03\f\x03\r\x03\r\x03\r\x03\r\x03\r\x03\r\x03\r\x03\r\x03\r\x03' +
+
'\x0E\x03\x0E\x03\x0E\x03\x0E\x03\x0F\x03\x0F\x07\x0Fh\n\x0F\f\x0F\x0E' +
+
'\x0Fk\v\x0F\x03\x10\x03\x10\x03\x10\x07\x10p\n\x10\f\x10\x0E\x10s\v\x10' +
+
'\x03\x10\x03\x10\x03\x11\x03\x11\x03\x11\x05\x11z\n\x11\x03\x12\x03\x12' +
+
'\x03\x12\x03\x12\x03\x12\x03\x12\x03\x13\x03\x13\x03\x14\x03\x14\x03\x15' +
+
'\x05\x15\x87\n\x15\x03\x15\x03\x15\x03\x16\x03\x16\x03\x16\x07\x16\x8E' +
+
'\n\x16\f\x16\x0E\x16\x91\v\x16\x05\x16\x93\n\x16\x03\x17\x05\x17\x96\n' +
+
'\x17\x03\x17\x03\x17\x03\x17\x03\x18\x05\x18\x9C\n\x18\x03\x18\x03\x18' +
+
'\x05\x18\xA0\n\x18\x03\x18\x03\x18\x03\x19\x03\x19\x06\x19\xA6\n\x19\r' +
+
'\x19\x0E\x19\xA7\x03\x1A\x03\x1A\x05\x1A\xAC\n\x1A\x03\x1A\x06\x1A\xAF' +
+
'\n\x1A\r\x1A\x0E\x1A\xB0\x03\x1B\x06\x1B\xB4\n\x1B\r\x1B\x0E\x1B\xB5\x03' +
+
'\x1B\x03\x1B\x02\x02\x02\x1C\x03\x02\x03\x05\x02\x04\x07\x02\x05\t\x02' +
+
'\x06\v\x02\x07\r\x02\b\x0F\x02\t\x11\x02\n\x13\x02\v\x15\x02\f\x17\x02' +
+
'\r\x19\x02\x0E\x1B\x02\x0F\x1D\x02\x10\x1F\x02\x11!\x02\x02#\x02\x02%' +
+
"\x02\x02\'\x02\x02)\x02\x12+\x02\x02-\x02\x13/\x02\x141\x02\x023\x02\x02" +
+
'5\x02\x15\x03\x02\f\x05\x02C\\aac|\x07\x02&&2;C\\aac|\n\x02$$11^^ddhh' +
+
'ppttvv\x05\x022;CHch\x05\x02\x02!$$^^\x03\x023;\x03\x022;\x04\x02GGgg' +
+
'\x04\x02--//\x05\x02\v\f\x0F\x0F""\x02\xBF\x02\x03\x03\x02\x02\x02\x02' +
+
'\x05\x03\x02\x02\x02\x02\x07\x03\x02\x02\x02\x02\t\x03\x02\x02\x02\x02' +
+
'\v\x03\x02\x02\x02\x02\r\x03\x02\x02\x02\x02\x0F\x03\x02\x02\x02\x02\x11' +
+
'\x03\x02\x02\x02\x02\x13\x03\x02\x02\x02\x02\x15\x03\x02\x02\x02\x02\x17' +
+
'\x03\x02\x02\x02\x02\x19\x03\x02\x02\x02\x02\x1B\x03\x02\x02\x02\x02\x1D' +
+
'\x03\x02\x02\x02\x02\x1F\x03\x02\x02\x02\x02)\x03\x02\x02\x02\x02-\x03' +
+
'\x02\x02\x02\x02/\x03\x02\x02\x02\x025\x03\x02\x02\x02\x037\x03\x02\x02' +
+
'\x02\x05<\x03\x02\x02\x02\x07B\x03\x02\x02\x02\tG\x03\x02\x02\x02\vI\x03' +
+
'\x02\x02\x02\rK\x03\x02\x02\x02\x0FM\x03\x02\x02\x02\x11O\x03\x02\x02' +
+
'\x02\x13Q\x03\x02\x02\x02\x15S\x03\x02\x02\x02\x17V\x03\x02\x02\x02\x19' +
+
'X\x03\x02\x02\x02\x1Ba\x03\x02\x02\x02\x1De\x03\x02\x02\x02\x1Fl\x03\x02' +
+
"\x02\x02!v\x03\x02\x02\x02#{\x03\x02\x02\x02%\x81\x03\x02\x02\x02\'\x83" +
+
'\x03\x02\x02\x02)\x86\x03\x02\x02\x02+\x92\x03\x02\x02\x02-\x95\x03\x02' +
+
'\x02\x02/\x9B\x03\x02\x02\x021\xA3\x03\x02\x02\x023\xA9\x03\x02\x02\x02' +
+
'5\xB3\x03\x02\x02\x0278\x07v\x02\x0289\x07t\x02\x029:\x07w\x02\x02:;\x07' +
+
'g\x02\x02;\x04\x03\x02\x02\x02<=\x07h\x02\x02=>\x07c\x02\x02>?\x07n\x02' +
+
'\x02?@\x07u\x02\x02@A\x07g\x02\x02A\x06\x03\x02\x02\x02BC\x07p\x02\x02' +
+
'CD\x07w\x02\x02DE\x07n\x02\x02EF\x07n\x02\x02F\b\x03\x02\x02\x02GH\x07' +
+
'}\x02\x02H\n\x03\x02\x02\x02IJ\x07.\x02\x02J\f\x03\x02\x02\x02KL\x07\x7F' +
+
'\x02\x02L\x0E\x03\x02\x02\x02MN\x07<\x02\x02N\x10\x03\x02\x02\x02OP\x07' +
+
']\x02\x02P\x12\x03\x02\x02\x02QR\x07_\x02\x02R\x14\x03\x02\x02\x02ST\x07' +
+
'<\x02\x02TU\x07<\x02\x02U\x16\x03\x02\x02\x02VW\x07/\x02\x02W\x18\x03' +
+
'\x02\x02\x02XY\x07K\x02\x02YZ\x07p\x02\x02Z[\x07h\x02\x02[\\\x07k\x02' +
+
'\x02\\]\x07p\x02\x02]^\x07k\x02\x02^_\x07v\x02\x02_`\x07{\x02\x02`\x1A' +
+
'\x03\x02\x02\x02ab\x07P\x02\x02bc\x07c\x02\x02cd\x07P\x02\x02d\x1C\x03' +
+
'\x02\x02\x02ei\t\x02\x02\x02fh\t\x03\x02\x02gf\x03\x02\x02\x02hk\x03\x02' +
+
'\x02\x02ig\x03\x02\x02\x02ij\x03\x02\x02\x02j\x1E\x03\x02\x02\x02ki\x03' +
+
"\x02\x02\x02lq\x07$\x02\x02mp\x05!\x11\x02np\x05\'\x14\x02om\x03\x02\x02" +
+
'\x02on\x03\x02\x02\x02ps\x03\x02\x02\x02qo\x03\x02\x02\x02qr\x03\x02\x02' +
+ '\x02rt\x03\x02\x02\x02sq\x03\x02\x02\x02tu\x07$\x02\x02u
\x03\x02\x02' +
+
'\x02vy\x07^\x02\x02wz\t\x04\x02\x02xz\x05#\x12\x02yw\x03\x02\x02\x02y' +
+
'x\x03\x02\x02\x02z"\x03\x02\x02\x02{|\x07w\x02\x02|}\x05%\x13\x02}~\x05' +
+
'%\x13\x02~\x7F\x05%\x13\x02\x7F\x80\x05%\x13\x02\x80$\x03\x02\x02\x02' +
+
'\x81\x82\t\x05\x02\x02\x82&\x03\x02\x02\x02\x83\x84\n\x06\x02\x02\x84' +
+
'(\x03\x02\x02\x02\x85\x87\x07/\x02\x02\x86\x85\x03\x02\x02\x02\x86\x87' +
+
'\x03\x02\x02\x02\x87\x88\x03\x02\x02\x02\x88\x89\x05+\x16\x02\x89*\x03' +
+
'\x02\x02\x02\x8A\x93\x072\x02\x02\x8B\x8F\t\x07\x02\x02\x8C\x8E\t\b\x02' +
+
'\x02\x8D\x8C\x03\x02\x02\x02\x8E\x91\x03\x02\x02\x02\x8F\x8D\x03\x02\x02' +
+
'\x02\x8F\x90\x03\x02\x02\x02\x90\x93\x03\x02\x02\x02\x91\x8F\x03\x02\x02' +
+
'\x02\x92\x8A\x03\x02\x02\x02\x92\x8B\x03\x02\x02\x02\x93,\x03\x02\x02' +
+
'\x02\x94\x96\x07/\x02\x02\x95\x94\x03\x02\x02\x02\x95\x96\x03\x02\x02' +
+
'\x02\x96\x97\x03\x02\x02\x02\x97\x98\x05+\x16\x02\x98\x99\x051\x19\x02' +
+
'\x99.\x03\x02\x02\x02\x9A\x9C\x07/\x02\x02\x9B\x9A\x03\x02\x02\x02\x9B' +
+
'\x9C\x03\x02\x02\x02\x9C\x9D\x03\x02\x02\x02\x9D\x9F\x05+\x16\x02\x9E' +
+
'\xA0\x051\x19\x02\x9F\x9E\x03\x02\x02\x02\x9F\xA0\x03\x02\x02\x02\xA0' +
+
'\xA1\x03\x02\x02\x02\xA1\xA2\x053\x1A\x02\xA20\x03\x02\x02\x02\xA3\xA5' +
+
'\x070\x02\x02\xA4\xA6\t\b\x02\x02\xA5\xA4\x03\x02\x02\x02\xA6\xA7\x03' +
+
'\x02\x02\x02\xA7\xA5\x03\x02\x02\x02\xA7\xA8\x03\x02\x02\x02\xA82\x03' +
+
'\x02\x02\x02\xA9\xAB\t\t\x02\x02\xAA\xAC\t\n\x02\x02\xAB\xAA\x03\x02\x02' +
+
'\x02\xAB\xAC\x03\x02\x02\x02\xAC\xAE\x03\x02\x02\x02\xAD\xAF\t\b\x02\x02' +
+
'\xAE\xAD\x03\x02\x02\x02\xAF\xB0\x03\x02\x02\x02\xB0\xAE\x03\x02\x02\x02' +
+
'\xB0\xB1\x03\x02\x02\x02\xB14\x03\x02\x02\x02\xB2\xB4\t\v\x02\x02\xB3' +
+
'\xB2\x03\x02\x02\x02\xB4\xB5\x03\x02\x02\x02\xB5\xB3\x03\x02\x02\x02\xB5' +
+
'\xB6\x03\x02\x02\x02\xB6\xB7\x03\x02\x02\x02\xB7\xB8\b\x1B\x02\x02\xB8' +
+
'6\x03\x02\x02\x02\x11\x02ioqy\x86\x8F\x92\x95\x9B\x9F\xA7\xAB\xB0\xB5' +
+ '\x03\b\x02\x02';
+
+ public static __ATN: ATN;
+ public static get _ATN (): ATN {
+ if (!AgtypeLexer.__ATN) {
+ AgtypeLexer.__ATN = new
ATNDeserializer().deserialize(Utils.toCharArray(AgtypeLexer._serializedATN))
+ }
+
+ return AgtypeLexer.__ATN
+ }
+}
diff --git a/drivers/nodejs/src/antlr4/AgtypeListener.ts
b/drivers/nodejs/src/antlr4/AgtypeListener.ts
new file mode 100644
index 0000000..58de455
--- /dev/null
+++ b/drivers/nodejs/src/antlr4/AgtypeListener.ts
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.
+ */
+
+// Generated from src/antlr4/Agtype.g4 by ANTLR 4.9.0-SNAPSHOT
+
+import { ParseTreeListener } from 'antlr4ts/tree/ParseTreeListener'
+
+import {
+ AgTypeContext,
+ AgValueContext,
+ ArrayContext,
+ ArrayValueContext,
+ FalseBooleanContext,
+ FloatLiteralContext,
+ FloatValueContext,
+ IntegerValueContext,
+ NullValueContext,
+ ObjContext,
+ ObjectValueContext,
+ PairContext,
+ StringValueContext,
+ TrueBooleanContext,
+ TypeAnnotationContext,
+ ValueContext
+} from './AgtypeParser'
+
+// Generated from src/antlr4/Agtype.g4 by ANTLR 4.9.0-SNAPSHOT
+/**
+ * This interface defines a complete listener for a parse tree produced by
+ * `AgtypeParser`.
+ */
+export interface AgtypeListener extends ParseTreeListener {
+ /**
+ * Enter a parse tree produced by the `StringValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ enterStringValue?: (ctx: StringValueContext) => void;
+ /**
+ * Exit a parse tree produced by the `StringValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ exitStringValue?: (ctx: StringValueContext) => void;
+
+ /**
+ * Enter a parse tree produced by the `IntegerValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ enterIntegerValue?: (ctx: IntegerValueContext) => void;
+ /**
+ * Exit a parse tree produced by the `IntegerValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ exitIntegerValue?: (ctx: IntegerValueContext) => void;
+
+ /**
+ * Enter a parse tree produced by the `FloatValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ enterFloatValue?: (ctx: FloatValueContext) => void;
+ /**
+ * Exit a parse tree produced by the `FloatValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ exitFloatValue?: (ctx: FloatValueContext) => void;
+
+ /**
+ * Enter a parse tree produced by the `TrueBoolean`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ enterTrueBoolean?: (ctx: TrueBooleanContext) => void;
+ /**
+ * Exit a parse tree produced by the `TrueBoolean`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ exitTrueBoolean?: (ctx: TrueBooleanContext) => void;
+
+ /**
+ * Enter a parse tree produced by the `FalseBoolean`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ enterFalseBoolean?: (ctx: FalseBooleanContext) => void;
+ /**
+ * Exit a parse tree produced by the `FalseBoolean`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ exitFalseBoolean?: (ctx: FalseBooleanContext) => void;
+
+ /**
+ * Enter a parse tree produced by the `NullValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ enterNullValue?: (ctx: NullValueContext) => void;
+ /**
+ * Exit a parse tree produced by the `NullValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ exitNullValue?: (ctx: NullValueContext) => void;
+
+ /**
+ * Enter a parse tree produced by the `ObjectValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ enterObjectValue?: (ctx: ObjectValueContext) => void;
+ /**
+ * Exit a parse tree produced by the `ObjectValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ exitObjectValue?: (ctx: ObjectValueContext) => void;
+
+ /**
+ * Enter a parse tree produced by the `ArrayValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ enterArrayValue?: (ctx: ArrayValueContext) => void;
+ /**
+ * Exit a parse tree produced by the `ArrayValue`
+ * labeled alternative in `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ exitArrayValue?: (ctx: ArrayValueContext) => void;
+
+ /**
+ * Enter a parse tree produced by `AgtypeParser.agType`.
+ * @param ctx the parse tree
+ */
+ enterAgType?: (ctx: AgTypeContext) => void;
+ /**
+ * Exit a parse tree produced by `AgtypeParser.agType`.
+ * @param ctx the parse tree
+ */
+ exitAgType?: (ctx: AgTypeContext) => void;
+
+ /**
+ * Enter a parse tree produced by `AgtypeParser.agValue`.
+ * @param ctx the parse tree
+ */
+ enterAgValue?: (ctx: AgValueContext) => void;
+ /**
+ * Exit a parse tree produced by `AgtypeParser.agValue`.
+ * @param ctx the parse tree
+ */
+ exitAgValue?: (ctx: AgValueContext) => void;
+
+ /**
+ * Enter a parse tree produced by `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ enterValue?: (ctx: ValueContext) => void;
+ /**
+ * Exit a parse tree produced by `AgtypeParser.value`.
+ * @param ctx the parse tree
+ */
+ exitValue?: (ctx: ValueContext) => void;
+
+ /**
+ * Enter a parse tree produced by `AgtypeParser.obj`.
+ * @param ctx the parse tree
+ */
+ enterObj?: (ctx: ObjContext) => void;
+ /**
+ * Exit a parse tree produced by `AgtypeParser.obj`.
+ * @param ctx the parse tree
+ */
+ exitObj?: (ctx: ObjContext) => void;
+
+ /**
+ * Enter a parse tree produced by `AgtypeParser.pair`.
+ * @param ctx the parse tree
+ */
+ enterPair?: (ctx: PairContext) => void;
+ /**
+ * Exit a parse tree produced by `AgtypeParser.pair`.
+ * @param ctx the parse tree
+ */
+ exitPair?: (ctx: PairContext) => void;
+
+ /**
+ * Enter a parse tree produced by `AgtypeParser.array`.
+ * @param ctx the parse tree
+ */
+ enterArray?: (ctx: ArrayContext) => void;
+ /**
+ * Exit a parse tree produced by `AgtypeParser.array`.
+ * @param ctx the parse tree
+ */
+ exitArray?: (ctx: ArrayContext) => void;
+
+ /**
+ * Enter a parse tree produced by `AgtypeParser.typeAnnotation`.
+ * @param ctx the parse tree
+ */
+ enterTypeAnnotation?: (ctx: TypeAnnotationContext) => void;
+ /**
+ * Exit a parse tree produced by `AgtypeParser.typeAnnotation`.
+ * @param ctx the parse tree
+ */
+ exitTypeAnnotation?: (ctx: TypeAnnotationContext) => void;
+
+ /**
+ * Enter a parse tree produced by `AgtypeParser.floatLiteral`.
+ * @param ctx the parse tree
+ */
+ enterFloatLiteral?: (ctx: FloatLiteralContext) => void;
+ /**
+ * Exit a parse tree produced by `AgtypeParser.floatLiteral`.
+ * @param ctx the parse tree
+ */
+ exitFloatLiteral?: (ctx: FloatLiteralContext) => void;
+}
diff --git a/drivers/nodejs/src/antlr4/AgtypeParser.ts
b/drivers/nodejs/src/antlr4/AgtypeParser.ts
new file mode 100644
index 0000000..8cf0bbd
--- /dev/null
+++ b/drivers/nodejs/src/antlr4/AgtypeParser.ts
@@ -0,0 +1,993 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.
+ */
+
+/* eslint-disable */
+// Generated from src/antlr4/Agtype.g4 by ANTLR 4.9.0-SNAPSHOT
+
+import { ATN } from 'antlr4ts/atn/ATN'
+import { ATNDeserializer } from 'antlr4ts/atn/ATNDeserializer'
+import { FailedPredicateException } from 'antlr4ts/FailedPredicateException'
+import { NoViableAltException } from 'antlr4ts/NoViableAltException'
+import { Parser } from 'antlr4ts/Parser'
+import { ParserRuleContext } from 'antlr4ts/ParserRuleContext'
+import { ParserATNSimulator } from 'antlr4ts/atn/ParserATNSimulator'
+import { RecognitionException } from 'antlr4ts/RecognitionException'
+// import { RuleVersion } from "antlr4ts/RuleVersion";
+import { TerminalNode } from 'antlr4ts/tree/TerminalNode'
+import { TokenStream } from 'antlr4ts/TokenStream'
+import { Vocabulary } from 'antlr4ts/Vocabulary'
+import { VocabularyImpl } from 'antlr4ts/VocabularyImpl'
+
+import * as Utils from 'antlr4ts/misc/Utils'
+
+import { AgtypeListener } from './AgtypeListener'
+
+export class AgtypeParser extends Parser {
+ public static readonly T__0 = 1;
+ public static readonly T__1 = 2;
+ public static readonly T__2 = 3;
+ public static readonly T__3 = 4;
+ public static readonly T__4 = 5;
+ public static readonly T__5 = 6;
+ public static readonly T__6 = 7;
+ public static readonly T__7 = 8;
+ public static readonly T__8 = 9;
+ public static readonly T__9 = 10;
+ public static readonly T__10 = 11;
+ public static readonly T__11 = 12;
+ public static readonly T__12 = 13;
+ public static readonly IDENT = 14;
+ public static readonly STRING = 15;
+ public static readonly INTEGER = 16;
+ public static readonly RegularFloat = 17;
+ public static readonly ExponentFloat = 18;
+ public static readonly WS = 19;
+ public static readonly RULE_agType = 0;
+ public static readonly RULE_agValue = 1;
+ public static readonly RULE_value = 2;
+ public static readonly RULE_obj = 3;
+ public static readonly RULE_pair = 4;
+ public static readonly RULE_array = 5;
+ public static readonly RULE_typeAnnotation = 6;
+ public static readonly RULE_floatLiteral = 7;
+ // tslint:disable:no-trailing-whitespace
+ public static readonly ruleNames: string[] = [
+ 'agType', 'agValue', 'value', 'obj', 'pair', 'array', 'typeAnnotation',
+ 'floatLiteral'
+ ];
+
+ private static readonly _LITERAL_NAMES: Array<string | undefined> = [
+ undefined, "'true'", "'false'", "'null'", "'{'", "','", "'}'", "':'",
+ "'['", "']'", "'::'", "'-'", "'Infinity'", "'NaN'"
+ ];
+
+ private static readonly _SYMBOLIC_NAMES: Array<string | undefined> = [
+ undefined, undefined, undefined, undefined, undefined, undefined,
undefined,
+ undefined, undefined, undefined, undefined, undefined, undefined,
undefined,
+ 'IDENT', 'STRING', 'INTEGER', 'RegularFloat', 'ExponentFloat', 'WS'
+ ];
+
+ public static readonly VOCABULARY: Vocabulary = new
VocabularyImpl(AgtypeParser._LITERAL_NAMES, AgtypeParser._SYMBOLIC_NAMES, []);
+
+ // @Override
+ // @NotNull
+ public get vocabulary (): Vocabulary {
+ return AgtypeParser.VOCABULARY
+ }
+
+ // tslint:enable:no-trailing-whitespace
+
+ // @Override
+ public get grammarFileName (): string {
+ return 'Agtype.g4'
+ }
+
+ // @Override
+ public get ruleNames (): string[] {
+ return AgtypeParser.ruleNames
+ }
+
+ // @Override
+ public get serializedATN (): string {
+ return AgtypeParser._serializedATN
+ }
+
+ protected createFailedPredicateException (predicate?: string, message?:
string): FailedPredicateException {
+ return new FailedPredicateException(this, predicate, message)
+ }
+
+ constructor (input: TokenStream) {
+ super(input)
+ this._interp = new ParserATNSimulator(AgtypeParser._ATN, this)
+ }
+
+ // @RuleVersion(0)
+ public agType (): AgTypeContext {
+ const _localctx: AgTypeContext = new AgTypeContext(this._ctx, this.state)
+ this.enterRule(_localctx, 0, AgtypeParser.RULE_agType)
+ try {
+ this.enterOuterAlt(_localctx, 1)
+ {
+ this.state = 16
+ this.agValue()
+ this.state = 17
+ this.match(AgtypeParser.EOF)
+ }
+ } catch (re) {
+ if (re instanceof RecognitionException) {
+ _localctx.exception = re
+ this._errHandler.reportError(this, re)
+ this._errHandler.recover(this, re)
+ } else {
+ throw re
+ }
+ } finally {
+ this.exitRule()
+ }
+ return _localctx
+ }
+
+ // @RuleVersion(0)
+ public agValue (): AgValueContext {
+ const _localctx: AgValueContext = new AgValueContext(this._ctx,
this.state)
+ this.enterRule(_localctx, 2, AgtypeParser.RULE_agValue)
+ let _la: number
+ try {
+ this.enterOuterAlt(_localctx, 1)
+ {
+ this.state = 19
+ this.value()
+ this.state = 21
+ this._errHandler.sync(this)
+ _la = this._input.LA(1)
+ if (_la === AgtypeParser.T__9) {
+ {
+ this.state = 20
+ this.typeAnnotation()
+ }
+ }
+ }
+ } catch (re) {
+ if (re instanceof RecognitionException) {
+ _localctx.exception = re
+ this._errHandler.reportError(this, re)
+ this._errHandler.recover(this, re)
+ } else {
+ throw re
+ }
+ } finally {
+ this.exitRule()
+ }
+ return _localctx
+ }
+
+ // @RuleVersion(0)
+ public value (): ValueContext {
+ let _localctx: ValueContext = new ValueContext(this._ctx, this.state)
+ this.enterRule(_localctx, 4, AgtypeParser.RULE_value)
+ try {
+ this.state = 31
+ this._errHandler.sync(this)
+ switch (this._input.LA(1)) {
+ case AgtypeParser.STRING:
+ _localctx = new StringValueContext(_localctx)
+ this.enterOuterAlt(_localctx, 1)
+ {
+ this.state = 23
+ this.match(AgtypeParser.STRING)
+ }
+ break
+ case AgtypeParser.INTEGER:
+ _localctx = new IntegerValueContext(_localctx)
+ this.enterOuterAlt(_localctx, 2)
+ {
+ this.state = 24
+ this.match(AgtypeParser.INTEGER)
+ }
+ break
+ case AgtypeParser.T__10:
+ case AgtypeParser.T__11:
+ case AgtypeParser.T__12:
+ case AgtypeParser.RegularFloat:
+ case AgtypeParser.ExponentFloat:
+ _localctx = new FloatValueContext(_localctx)
+ this.enterOuterAlt(_localctx, 3)
+ {
+ this.state = 25
+ this.floatLiteral()
+ }
+ break
+ case AgtypeParser.T__0:
+ _localctx = new TrueBooleanContext(_localctx)
+ this.enterOuterAlt(_localctx, 4)
+ {
+ this.state = 26
+ this.match(AgtypeParser.T__0)
+ }
+ break
+ case AgtypeParser.T__1:
+ _localctx = new FalseBooleanContext(_localctx)
+ this.enterOuterAlt(_localctx, 5)
+ {
+ this.state = 27
+ this.match(AgtypeParser.T__1)
+ }
+ break
+ case AgtypeParser.T__2:
+ _localctx = new NullValueContext(_localctx)
+ this.enterOuterAlt(_localctx, 6)
+ {
+ this.state = 28
+ this.match(AgtypeParser.T__2)
+ }
+ break
+ case AgtypeParser.T__3:
+ _localctx = new ObjectValueContext(_localctx)
+ this.enterOuterAlt(_localctx, 7)
+ {
+ this.state = 29
+ this.obj()
+ }
+ break
+ case AgtypeParser.T__7:
+ _localctx = new ArrayValueContext(_localctx)
+ this.enterOuterAlt(_localctx, 8)
+ {
+ this.state = 30
+ this.array()
+ }
+ break
+ default:
+ throw new NoViableAltException(this)
+ }
+ } catch (re) {
+ if (re instanceof RecognitionException) {
+ _localctx.exception = re
+ this._errHandler.reportError(this, re)
+ this._errHandler.recover(this, re)
+ } else {
+ throw re
+ }
+ } finally {
+ this.exitRule()
+ }
+ return _localctx
+ }
+
+ // @RuleVersion(0)
+ public obj (): ObjContext {
+ const _localctx: ObjContext = new ObjContext(this._ctx, this.state)
+ this.enterRule(_localctx, 6, AgtypeParser.RULE_obj)
+ let _la: number
+ try {
+ this.state = 46
+ this._errHandler.sync(this)
+ switch (this.interpreter.adaptivePredict(this._input, 3, this._ctx)) {
+ case 1:
+ this.enterOuterAlt(_localctx, 1)
+ {
+ this.state = 33
+ this.match(AgtypeParser.T__3)
+ this.state = 34
+ this.pair()
+ this.state = 39
+ this._errHandler.sync(this)
+ _la = this._input.LA(1)
+ while (_la === AgtypeParser.T__4) {
+ {
+ {
+ this.state = 35
+ this.match(AgtypeParser.T__4)
+ this.state = 36
+ this.pair()
+ }
+ }
+ this.state = 41
+ this._errHandler.sync(this)
+ _la = this._input.LA(1)
+ }
+ this.state = 42
+ this.match(AgtypeParser.T__5)
+ }
+ break
+
+ case 2:
+ this.enterOuterAlt(_localctx, 2)
+ {
+ this.state = 44
+ this.match(AgtypeParser.T__3)
+ this.state = 45
+ this.match(AgtypeParser.T__5)
+ }
+ break
+ }
+ } catch (re) {
+ if (re instanceof RecognitionException) {
+ _localctx.exception = re
+ this._errHandler.reportError(this, re)
+ this._errHandler.recover(this, re)
+ } else {
+ throw re
+ }
+ } finally {
+ this.exitRule()
+ }
+ return _localctx
+ }
+
+ // @RuleVersion(0)
+ public pair (): PairContext {
+ const _localctx: PairContext = new PairContext(this._ctx, this.state)
+ this.enterRule(_localctx, 8, AgtypeParser.RULE_pair)
+ try {
+ this.enterOuterAlt(_localctx, 1)
+ {
+ this.state = 48
+ this.match(AgtypeParser.STRING)
+ this.state = 49
+ this.match(AgtypeParser.T__6)
+ this.state = 50
+ this.agValue()
+ }
+ } catch (re) {
+ if (re instanceof RecognitionException) {
+ _localctx.exception = re
+ this._errHandler.reportError(this, re)
+ this._errHandler.recover(this, re)
+ } else {
+ throw re
+ }
+ } finally {
+ this.exitRule()
+ }
+ return _localctx
+ }
+
+ // @RuleVersion(0)
+ public array (): ArrayContext {
+ const _localctx: ArrayContext = new ArrayContext(this._ctx, this.state)
+ this.enterRule(_localctx, 10, AgtypeParser.RULE_array)
+ let _la: number
+ try {
+ this.state = 65
+ this._errHandler.sync(this)
+ switch (this.interpreter.adaptivePredict(this._input, 5, this._ctx)) {
+ case 1:
+ this.enterOuterAlt(_localctx, 1)
+ {
+ this.state = 52
+ this.match(AgtypeParser.T__7)
+ this.state = 53
+ this.agValue()
+ this.state = 58
+ this._errHandler.sync(this)
+ _la = this._input.LA(1)
+ while (_la === AgtypeParser.T__4) {
+ {
+ {
+ this.state = 54
+ this.match(AgtypeParser.T__4)
+ this.state = 55
+ this.agValue()
+ }
+ }
+ this.state = 60
+ this._errHandler.sync(this)
+ _la = this._input.LA(1)
+ }
+ this.state = 61
+ this.match(AgtypeParser.T__8)
+ }
+ break
+
+ case 2:
+ this.enterOuterAlt(_localctx, 2)
+ {
+ this.state = 63
+ this.match(AgtypeParser.T__7)
+ this.state = 64
+ this.match(AgtypeParser.T__8)
+ }
+ break
+ }
+ } catch (re) {
+ if (re instanceof RecognitionException) {
+ _localctx.exception = re
+ this._errHandler.reportError(this, re)
+ this._errHandler.recover(this, re)
+ } else {
+ throw re
+ }
+ } finally {
+ this.exitRule()
+ }
+ return _localctx
+ }
+
+ // @RuleVersion(0)
+ public typeAnnotation (): TypeAnnotationContext {
+ const _localctx: TypeAnnotationContext = new
TypeAnnotationContext(this._ctx, this.state)
+ this.enterRule(_localctx, 12, AgtypeParser.RULE_typeAnnotation)
+ try {
+ this.enterOuterAlt(_localctx, 1)
+ {
+ this.state = 67
+ this.match(AgtypeParser.T__9)
+ this.state = 68
+ this.match(AgtypeParser.IDENT)
+ }
+ } catch (re) {
+ if (re instanceof RecognitionException) {
+ _localctx.exception = re
+ this._errHandler.reportError(this, re)
+ this._errHandler.recover(this, re)
+ } else {
+ throw re
+ }
+ } finally {
+ this.exitRule()
+ }
+ return _localctx
+ }
+
+ // @RuleVersion(0)
+ public floatLiteral (): FloatLiteralContext {
+ const _localctx: FloatLiteralContext = new
FloatLiteralContext(this._ctx, this.state)
+ this.enterRule(_localctx, 14, AgtypeParser.RULE_floatLiteral)
+ let _la: number
+ try {
+ this.state = 77
+ this._errHandler.sync(this)
+ switch (this._input.LA(1)) {
+ case AgtypeParser.RegularFloat:
+ this.enterOuterAlt(_localctx, 1)
+ {
+ this.state = 70
+ this.match(AgtypeParser.RegularFloat)
+ }
+ break
+ case AgtypeParser.ExponentFloat:
+ this.enterOuterAlt(_localctx, 2)
+ {
+ this.state = 71
+ this.match(AgtypeParser.ExponentFloat)
+ }
+ break
+ case AgtypeParser.T__10:
+ case AgtypeParser.T__11:
+ this.enterOuterAlt(_localctx, 3)
+ {
+ this.state = 73
+ this._errHandler.sync(this)
+ _la = this._input.LA(1)
+ if (_la === AgtypeParser.T__10) {
+ {
+ this.state = 72
+ this.match(AgtypeParser.T__10)
+ }
+ }
+
+ this.state = 75
+ this.match(AgtypeParser.T__11)
+ }
+ break
+ case AgtypeParser.T__12:
+ this.enterOuterAlt(_localctx, 4)
+ {
+ this.state = 76
+ this.match(AgtypeParser.T__12)
+ }
+ break
+ default:
+ throw new NoViableAltException(this)
+ }
+ } catch (re) {
+ if (re instanceof RecognitionException) {
+ _localctx.exception = re
+ this._errHandler.reportError(this, re)
+ this._errHandler.recover(this, re)
+ } else {
+ throw re
+ }
+ } finally {
+ this.exitRule()
+ }
+ return _localctx
+ }
+
+ public static readonly _serializedATN: string =
+
'\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x03\x15R\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\x03\x02\x03\x02\x03\x02\x03\x03\x03\x03\x05' +
+
'\x03\x18\n\x03\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04' +
+
'\x03\x04\x05\x04"\n\x04\x03\x05\x03\x05\x03\x05\x03\x05\x07\x05(\n\x05' +
+
'\f\x05\x0E\x05+\v\x05\x03\x05\x03\x05\x03\x05\x03\x05\x05\x051\n\x05\x03' +
+
'\x06\x03\x06\x03\x06\x03\x06\x03\x07\x03\x07\x03\x07\x03\x07\x07\x07;' +
+
'\n\x07\f\x07\x0E\x07>\v\x07\x03\x07\x03\x07\x03\x07\x03\x07\x05\x07D\n' +
+
'\x07\x03\b\x03\b\x03\b\x03\t\x03\t\x03\t\x05\tL\n\t\x03\t\x03\t\x05\t' +
+
'P\n\t\x03\t\x02\x02\x02\n\x02\x02\x04\x02\x06\x02\b\x02\n\x02\f\x02\x0E' +
+
'\x02\x10\x02\x02\x02\x02Y\x02\x12\x03\x02\x02\x02\x04\x15\x03\x02\x02' +
+
'\x02\x06!\x03\x02\x02\x02\b0\x03\x02\x02\x02\n2\x03\x02\x02\x02\fC\x03' +
+
'\x02\x02\x02\x0EE\x03\x02\x02\x02\x10O\x03\x02\x02\x02\x12\x13\x05\x04' +
+
'\x03\x02\x13\x14\x07\x02\x02\x03\x14\x03\x03\x02\x02\x02\x15\x17\x05\x06' +
+
'\x04\x02\x16\x18\x05\x0E\b\x02\x17\x16\x03\x02\x02\x02\x17\x18\x03\x02' +
+
'\x02\x02\x18\x05\x03\x02\x02\x02\x19"\x07\x11\x02\x02\x1A"\x07\x12\x02' +
+
'\x02\x1B"\x05\x10\t\x02\x1C"\x07\x03\x02\x02\x1D"\x07\x04\x02\x02\x1E' +
+ '"\x07\x05\x02\x02\x1F"\x05\b\x05\x02
"\x05\f\x07\x02!\x19\x03\x02\x02' +
+
'\x02!\x1A\x03\x02\x02\x02!\x1B\x03\x02\x02\x02!\x1C\x03\x02\x02\x02!\x1D' +
+ '\x03\x02\x02\x02!\x1E\x03\x02\x02\x02!\x1F\x03\x02\x02\x02!
\x03\x02\x02' +
+
'\x02"\x07\x03\x02\x02\x02#$\x07\x06\x02\x02$)\x05\n\x06\x02%&\x07\x07' +
+
"\x02\x02&(\x05\n\x06\x02\'%\x03\x02\x02\x02(+\x03\x02\x02\x02)\'\x03\x02" +
+
'\x02\x02)*\x03\x02\x02\x02*,\x03\x02\x02\x02+)\x03\x02\x02\x02,-\x07\b' +
+
'\x02\x02-1\x03\x02\x02\x02./\x07\x06\x02\x02/1\x07\b\x02\x020#\x03\x02' +
+
'\x02\x020.\x03\x02\x02\x021\t\x03\x02\x02\x0223\x07\x11\x02\x0234\x07' +
+
'\t\x02\x0245\x05\x04\x03\x025\v\x03\x02\x02\x0267\x07\n\x02\x027<\x05' +
+
'\x04\x03\x0289\x07\x07\x02\x029;\x05\x04\x03\x02:8\x03\x02\x02\x02;>\x03' +
+
'\x02\x02\x02<:\x03\x02\x02\x02<=\x03\x02\x02\x02=?\x03\x02\x02\x02><\x03' +
+
'\x02\x02\x02?@\x07\v\x02\x02@D\x03\x02\x02\x02AB\x07\n\x02\x02BD\x07\v' +
+
'\x02\x02C6\x03\x02\x02\x02CA\x03\x02\x02\x02D\r\x03\x02\x02\x02EF\x07' +
+
'\f\x02\x02FG\x07\x10\x02\x02G\x0F\x03\x02\x02\x02HP\x07\x13\x02\x02IP' +
+
'\x07\x14\x02\x02JL\x07\r\x02\x02KJ\x03\x02\x02\x02KL\x03\x02\x02\x02L' +
+
'M\x03\x02\x02\x02MP\x07\x0E\x02\x02NP\x07\x0F\x02\x02OH\x03\x02\x02\x02' +
+
'OI\x03\x02\x02\x02OK\x03\x02\x02\x02ON\x03\x02\x02\x02P\x11\x03\x02\x02' +
+ '\x02\n\x17!)0<CKO';
+
+ public static __ATN: ATN;
+ public static get _ATN (): ATN {
+ if (!AgtypeParser.__ATN) {
+ AgtypeParser.__ATN = new
ATNDeserializer().deserialize(Utils.toCharArray(AgtypeParser._serializedATN))
+ }
+
+ return AgtypeParser.__ATN
+ }
+}
+
+export class AgTypeContext extends ParserRuleContext {
+ public agValue (): AgValueContext {
+ return this.getRuleContext(0, AgValueContext)
+ }
+
+ public EOF (): TerminalNode {
+ return this.getToken(AgtypeParser.EOF, 0)
+ }
+
+ constructor (parent: ParserRuleContext | undefined, invokingState: number) {
+ super(parent, invokingState)
+ }
+
+ // @Override
+ public get ruleIndex (): number {
+ return AgtypeParser.RULE_agType
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterAgType) {
+ listener.enterAgType(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitAgType) {
+ listener.exitAgType(this)
+ }
+ }
+}
+
+export class AgValueContext extends ParserRuleContext {
+ public value (): ValueContext {
+ return this.getRuleContext(0, ValueContext)
+ }
+
+ public typeAnnotation (): TypeAnnotationContext | undefined {
+ return this.tryGetRuleContext(0, TypeAnnotationContext)
+ }
+
+ constructor (parent: ParserRuleContext | undefined, invokingState: number) {
+ super(parent, invokingState)
+ }
+
+ // @Override
+ public get ruleIndex (): number {
+ return AgtypeParser.RULE_agValue
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterAgValue) {
+ listener.enterAgValue(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitAgValue) {
+ listener.exitAgValue(this)
+ }
+ }
+}
+
+export class ValueContext extends ParserRuleContext {
+ constructor (parent: ParserRuleContext | undefined, invokingState: number) {
+ super(parent, invokingState)
+ }
+
+ // @Override
+ public get ruleIndex (): number {
+ return AgtypeParser.RULE_value
+ }
+
+ public copyFrom (ctx: ValueContext): void {
+ super.copyFrom(ctx)
+ }
+}
+
+export class StringValueContext extends ValueContext {
+ public STRING (): TerminalNode {
+ return this.getToken(AgtypeParser.STRING, 0)
+ }
+
+ constructor (ctx: ValueContext) {
+ super(ctx.parent, ctx.invokingState)
+ this.copyFrom(ctx)
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterStringValue) {
+ listener.enterStringValue(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitStringValue) {
+ listener.exitStringValue(this)
+ }
+ }
+}
+
+export class IntegerValueContext extends ValueContext {
+ public INTEGER (): TerminalNode {
+ return this.getToken(AgtypeParser.INTEGER, 0)
+ }
+
+ constructor (ctx: ValueContext) {
+ super(ctx.parent, ctx.invokingState)
+ this.copyFrom(ctx)
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterIntegerValue) {
+ listener.enterIntegerValue(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitIntegerValue) {
+ listener.exitIntegerValue(this)
+ }
+ }
+}
+
+export class FloatValueContext extends ValueContext {
+ public floatLiteral (): FloatLiteralContext {
+ return this.getRuleContext(0, FloatLiteralContext)
+ }
+
+ constructor (ctx: ValueContext) {
+ super(ctx.parent, ctx.invokingState)
+ this.copyFrom(ctx)
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterFloatValue) {
+ listener.enterFloatValue(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitFloatValue) {
+ listener.exitFloatValue(this)
+ }
+ }
+}
+
+export class TrueBooleanContext extends ValueContext {
+ constructor (ctx: ValueContext) {
+ super(ctx.parent, ctx.invokingState)
+ this.copyFrom(ctx)
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterTrueBoolean) {
+ listener.enterTrueBoolean(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitTrueBoolean) {
+ listener.exitTrueBoolean(this)
+ }
+ }
+}
+
+export class FalseBooleanContext extends ValueContext {
+ constructor (ctx: ValueContext) {
+ super(ctx.parent, ctx.invokingState)
+ this.copyFrom(ctx)
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterFalseBoolean) {
+ listener.enterFalseBoolean(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitFalseBoolean) {
+ listener.exitFalseBoolean(this)
+ }
+ }
+}
+
+export class NullValueContext extends ValueContext {
+ constructor (ctx: ValueContext) {
+ super(ctx.parent, ctx.invokingState)
+ this.copyFrom(ctx)
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterNullValue) {
+ listener.enterNullValue(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitNullValue) {
+ listener.exitNullValue(this)
+ }
+ }
+}
+
+export class ObjectValueContext extends ValueContext {
+ public obj (): ObjContext {
+ return this.getRuleContext(0, ObjContext)
+ }
+
+ constructor (ctx: ValueContext) {
+ super(ctx.parent, ctx.invokingState)
+ this.copyFrom(ctx)
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterObjectValue) {
+ listener.enterObjectValue(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitObjectValue) {
+ listener.exitObjectValue(this)
+ }
+ }
+}
+
+export class ArrayValueContext extends ValueContext {
+ public array (): ArrayContext {
+ return this.getRuleContext(0, ArrayContext)
+ }
+
+ constructor (ctx: ValueContext) {
+ super(ctx.parent, ctx.invokingState)
+ this.copyFrom(ctx)
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterArrayValue) {
+ listener.enterArrayValue(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitArrayValue) {
+ listener.exitArrayValue(this)
+ }
+ }
+}
+
+export class ObjContext extends ParserRuleContext {
+ public pair(): PairContext[];
+ public pair(i: number): PairContext;
+ public pair (i?: number): PairContext | PairContext[] {
+ if (i === undefined) {
+ return this.getRuleContexts(PairContext)
+ } else {
+ return this.getRuleContext(i, PairContext)
+ }
+ }
+
+ constructor (parent: ParserRuleContext | undefined, invokingState: number) {
+ super(parent, invokingState)
+ }
+
+ // @Override
+ public get ruleIndex (): number {
+ return AgtypeParser.RULE_obj
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterObj) {
+ listener.enterObj(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitObj) {
+ listener.exitObj(this)
+ }
+ }
+}
+
+export class PairContext extends ParserRuleContext {
+ public STRING (): TerminalNode {
+ return this.getToken(AgtypeParser.STRING, 0)
+ }
+
+ public agValue (): AgValueContext {
+ return this.getRuleContext(0, AgValueContext)
+ }
+
+ constructor (parent: ParserRuleContext | undefined, invokingState: number) {
+ super(parent, invokingState)
+ }
+
+ // @Override
+ public get ruleIndex (): number {
+ return AgtypeParser.RULE_pair
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterPair) {
+ listener.enterPair(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitPair) {
+ listener.exitPair(this)
+ }
+ }
+}
+
+export class ArrayContext extends ParserRuleContext {
+ public agValue(): AgValueContext[];
+ public agValue(i: number): AgValueContext;
+ public agValue (i?: number): AgValueContext | AgValueContext[] {
+ if (i === undefined) {
+ return this.getRuleContexts(AgValueContext)
+ } else {
+ return this.getRuleContext(i, AgValueContext)
+ }
+ }
+
+ constructor (parent: ParserRuleContext | undefined, invokingState: number) {
+ super(parent, invokingState)
+ }
+
+ // @Override
+ public get ruleIndex (): number {
+ return AgtypeParser.RULE_array
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterArray) {
+ listener.enterArray(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitArray) {
+ listener.exitArray(this)
+ }
+ }
+}
+
+export class TypeAnnotationContext extends ParserRuleContext {
+ public IDENT (): TerminalNode {
+ return this.getToken(AgtypeParser.IDENT, 0)
+ }
+
+ constructor (parent: ParserRuleContext | undefined, invokingState: number) {
+ super(parent, invokingState)
+ }
+
+ // @Override
+ public get ruleIndex (): number {
+ return AgtypeParser.RULE_typeAnnotation
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterTypeAnnotation) {
+ listener.enterTypeAnnotation(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitTypeAnnotation) {
+ listener.exitTypeAnnotation(this)
+ }
+ }
+}
+
+export class FloatLiteralContext extends ParserRuleContext {
+ public RegularFloat (): TerminalNode | undefined {
+ return this.tryGetToken(AgtypeParser.RegularFloat, 0)
+ }
+
+ public ExponentFloat (): TerminalNode | undefined {
+ return this.tryGetToken(AgtypeParser.ExponentFloat, 0)
+ }
+
+ constructor (parent: ParserRuleContext | undefined, invokingState: number) {
+ super(parent, invokingState)
+ }
+
+ // @Override
+ public get ruleIndex (): number {
+ return AgtypeParser.RULE_floatLiteral
+ }
+
+ // @Override
+ public enterRule (listener: AgtypeListener): void {
+ if (listener.enterFloatLiteral) {
+ listener.enterFloatLiteral(this)
+ }
+ }
+
+ // @Override
+ public exitRule (listener: AgtypeListener): void {
+ if (listener.exitFloatLiteral) {
+ listener.exitFloatLiteral(this)
+ }
+ }
+}
diff --git a/drivers/nodejs/src/antlr4/CustomAgTypeListener.ts
b/drivers/nodejs/src/antlr4/CustomAgTypeListener.ts
new file mode 100644
index 0000000..0319f5c
--- /dev/null
+++ b/drivers/nodejs/src/antlr4/CustomAgTypeListener.ts
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.
+ */
+
+import { AgtypeListener } from './AgtypeListener'
+import {
+ FloatLiteralContext,
+ FloatValueContext,
+ IntegerValueContext,
+ PairContext,
+ StringValueContext
+} from './AgtypeParser'
+import { ParseTreeListener } from 'antlr4ts/tree/ParseTreeListener'
+
+type MapOrArray = Map<string, any> | any[];
+
+class CustomAgTypeListener implements AgtypeListener, ParseTreeListener {
+ rootObject?: MapOrArray;
+ objectInsider: MapOrArray[] = [];
+ lastValue: any = null;
+
+ exitStringValue (ctx: StringValueContext): void {
+ this.lastValue = this.stripQuotes(ctx.text)
+ }
+
+ exitIntegerValue (ctx: IntegerValueContext): void {
+ this.lastValue = parseInt(ctx.text)
+ }
+
+ exitFloatValue (ctx: FloatValueContext): void {
+ this.lastValue = parseFloat(ctx.text)
+ }
+
+ exitTrueBoolean (): void {
+ this.lastValue = true
+ }
+
+ exitFalseBoolean (): void {
+ this.lastValue = false
+ }
+
+ exitNullValue (): void {
+ this.lastValue = null
+ }
+
+ enterObjectValue (): void {
+ this.objectInsider.unshift(new Map())
+ this.lastValue = this.objectInsider[0]
+ }
+
+ exitObjectValue (): void {
+ if (this.objectInsider.length >= 2 && this.objectInsider[1] instanceof
Array) {
+ const currentObject = this.objectInsider.shift()!;
+ (this.objectInsider[0]! as any[]).push(currentObject)
+ }
+ }
+
+ enterArrayValue (): void {
+ this.objectInsider.unshift([])
+ this.lastValue = this.objectInsider[0]
+ }
+
+ exitArrayValue (): void {
+ if (this.objectInsider.length >= 2 && this.objectInsider[1] instanceof
Array) {
+ // if objectInsider == Object then is pair or root
+ const currentObject = this.objectInsider.shift();
+ (this.objectInsider[0]! as any[]).push(currentObject)
+ }
+ }
+
+ exitPair (ctx: PairContext): void {
+ const name = this.stripQuotes(ctx.STRING().text)
+
+ if (this.lastValue !== undefined) {
+ (this.objectInsider[0] as Map<string, any>).set(name, this.lastValue)
+ this.lastValue = undefined
+ } else {
+ const lastValue = this.objectInsider.shift()
+ if (this.objectInsider[0] instanceof Array) {
+ this.objectInsider[0].push(lastValue)
+ } else {
+ (this.objectInsider[0] as Map<string, any>).set(name, lastValue)
+ }
+ }
+ }
+
+ exitFloatLiteral (ctx: FloatLiteralContext): void {
+ this.lastValue = ctx.text
+ }
+
+ exitAgType (): void {
+ this.rootObject = this.objectInsider.shift()
+ }
+
+ stripQuotes (quotesString: string) {
+ return JSON.parse(quotesString)
+ }
+
+ getResult () {
+ return this.rootObject
+ }
+
+ enterEveryRule (): void {
+ }
+
+ exitEveryRule (): void {
+ }
+
+ visitErrorNode (): void {
+ }
+
+ visitTerminal (): void {
+ }
+}
+
+export default CustomAgTypeListener
diff --git a/drivers/nodejs/src/index.ts b/drivers/nodejs/src/index.ts
index 86dd87b..416cc3d 100644
--- a/drivers/nodejs/src/index.ts
+++ b/drivers/nodejs/src/index.ts
@@ -17,40 +17,40 @@
* under the License.
*/
-import {Client} from 'pg';
+import { Client } from 'pg'
import pgTypes from 'pg-types'
-
-function AGTypeParse(input: string) {
- // todo: need to work with antlr4
-
- const inputLength = input.length;
- let splitJson;
- if (input.endsWith("::edge")) {
- splitJson = input.substring(0, inputLength - 6)
- } else {
- // ::vertex
- splitJson = input.substring(0, inputLength - 8);
- }
- return JSON.parse(splitJson);
+import { CharStreams, CommonTokenStream } from 'antlr4ts'
+import { AgtypeLexer } from './antlr4/AgtypeLexer'
+import { AgtypeParser } from './antlr4/AgtypeParser'
+import CustomAgTypeListener from './antlr4/CustomAgTypeListener'
+import { ParseTreeWalker } from 'antlr4ts/tree'
+
+function AGTypeParse (input: string) {
+ const chars = CharStreams.fromString(input)
+ const lexer = new AgtypeLexer(chars)
+ const tokens = new CommonTokenStream(lexer)
+ const parser = new AgtypeParser(tokens)
+ const tree = parser.agType()
+ const printer = new CustomAgTypeListener()
+ ParseTreeWalker.DEFAULT.walk(printer, tree)
+ return printer.getResult()
}
-async function setAGETypes(client: Client, types: typeof pgTypes) {
- await client.query(`
+async function setAGETypes (client: Client, types: typeof pgTypes) {
+ await client.query(`
CREATE EXTENSION IF NOT EXISTS age;
LOAD 'age';
SET search_path = ag_catalog, "$user", public;
`)
- const oidResults = await client.query(`
+ const oidResults = await client.query(`
select typelem
from pg_type
- where typname = '_agtype';`);
+ where typname = '_agtype';`)
- if (oidResults.rows.length < 1)
- throw new Error();
+ if (oidResults.rows.length < 1) { throw new Error() }
- types.setTypeParser(oidResults.rows[0].typelem, AGTypeParse)
+ types.setTypeParser(oidResults.rows[0].typelem, AGTypeParse)
}
-
-export {setAGETypes, AGTypeParse}
+export { setAGETypes, AGTypeParse }
diff --git a/drivers/nodejs/test/Agtype.test.ts
b/drivers/nodejs/test/Agtype.test.ts
new file mode 100644
index 0000000..e19a21d
--- /dev/null
+++ b/drivers/nodejs/test/Agtype.test.ts
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.
+ */
+
+import { AGTypeParse } from '../dist'
+
+describe('Parsing', () => {
+ it('Vertex', async () => {
+ expect(
+ AGTypeParse('{"id": 844424930131969, "label": "Part", "properties":
{"part_num": "123", "number": 3141592653589793, "float":
3.141592653589793}}::vertex')
+ ).toStrictEqual(new Map<string, any>(Object.entries({
+ id: 844424930131969,
+ label: 'Part',
+ properties: new Map(Object.entries({
+ part_num: '123',
+ number: 3141592653589793,
+ float: 3.141592653589793
+ }))
+ })))
+ })
+ it('Edge', async () => {
+ expect(
+ AGTypeParse('{"id": 1125899906842625, "label": "used_by", "end_id":
844424930131970, "start_id": 844424930131969, "properties": {"quantity":
1}}::edge')
+ ).toStrictEqual(new Map(Object.entries({
+ id: 1125899906842625,
+ label: 'used_by',
+ end_id: 844424930131970,
+ start_id: 844424930131969,
+ properties: new Map(Object.entries({ quantity: 1 }))
+ })))
+ })
+ it('Path', async () => {
+ expect(
+ AGTypeParse('[{"id": 844424930131969, "label": "Part", "properties":
{"part_num": "123"}}::vertex, {"id": 1125899906842625, "label": "used_by",
"end_id": 844424930131970, "start_id": 844424930131969, "properties":
{"quantity": 1}}::edge, {"id": 844424930131970, "label": "Part", "properties":
{"part_num": "345"}}::vertex]::path')
+ ).toStrictEqual([
+ new Map(Object.entries({
+ id: 844424930131969,
+ label: 'Part',
+ properties: new Map(Object.entries({ part_num: '123' }))
+ })),
+ new Map(Object.entries({
+ id: 1125899906842625,
+ label: 'used_by',
+ end_id: 844424930131970,
+ start_id: 844424930131969,
+ properties: new Map(Object.entries({ quantity: 1 }))
+ })),
+ new Map(Object.entries({
+ id: 844424930131970,
+ label: 'Part',
+ properties: new Map(Object.entries({ part_num: '345' }))
+ }))
+ ])
+ })
+})
diff --git a/drivers/nodejs/test/index.test.ts
b/drivers/nodejs/test/index.test.ts
index 9362004..60f9e2f 100644
--- a/drivers/nodejs/test/index.test.ts
+++ b/drivers/nodejs/test/index.test.ts
@@ -1,31 +1,50 @@
-import {types, Client, QueryResultRow} from "pg";
-import {setAGETypes} from "../src";
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.
+ */
+
+import { types, Client, QueryResultRow } from 'pg'
+import { setAGETypes } from '../src'
const config = {
- user: 'postgres',
- host: '127.0.0.1',
- database: 'postgres',
- password: 'postgres',
- port: 25432,
+ user: 'postgres',
+ host: '127.0.0.1',
+ database: 'postgres',
+ password: 'postgres',
+ port: 25432
}
-const testGraphName = 'age-test';
+const testGraphName = 'age-test'
-describe("Pre-connected Connection", () => {
- let client: Client | null;
+describe('Pre-connected Connection', () => {
+ let client: Client | null
- beforeAll(async () => {
- client = new Client(config);
- await client.connect();
- await setAGETypes(client, types);
- await client.query(`SELECT create_graph('${testGraphName}');`);
- });
- afterAll(async () => {
- await client?.query(`SELECT drop_graph('${testGraphName}', true);`);
- await client?.end();
- })
- it("simple CREATE & MATCH", async () => {
- await client?.query(`
+ beforeAll(async () => {
+ client = new Client(config)
+ await client.connect()
+ await setAGETypes(client, types)
+ await client.query(`SELECT create_graph('${testGraphName}');`)
+ })
+ afterAll(async () => {
+ await client?.query(`SELECT drop_graph('${testGraphName}', true);`)
+ await client?.end()
+ })
+ it('simple CREATE & MATCH', async () => {
+ await client?.query(`
SELECT *
from cypher('${testGraphName}', $$ CREATE (a:Part {part_num:
'123'}),
(b:Part {part_num: '345'}),
@@ -33,32 +52,32 @@ describe("Pre-connected Connection", () => {
(d:Part {part_num: '789'})
$$) as (a agtype);
`)
- const results: QueryResultRow = await client?.query<QueryResultRow>(`
+ const results: QueryResultRow = await client?.query<QueryResultRow>(`
SELECT *
from cypher('${testGraphName}', $$
MATCH (a) RETURN a
$$) as (a agtype);
`)!
- expect(results.rows).toStrictEqual(
- [{
- "a": {
- "id": 844424930131969,
- "label": "Part",
- "properties": {"part_num": "123"}
- }
- }, {
- "a": {
- "id": 844424930131970,
- "label": "Part",
- "properties": {"part_num": "345"}
- }
- }, {
- "a": {
- "id": 844424930131971,
- "label": "Part",
- "properties": {"part_num": "456"}
- }
- }, {"a": {"id": 844424930131972, "label": "Part", "properties":
{"part_num": "789"}}}]
- )
- });
-});
+ expect(results.rows).toStrictEqual(
+ [{
+ a: {
+ id: 844424930131969,
+ label: 'Part',
+ properties: { part_num: '123' }
+ }
+ }, {
+ a: {
+ id: 844424930131970,
+ label: 'Part',
+ properties: { part_num: '345' }
+ }
+ }, {
+ a: {
+ id: 844424930131971,
+ label: 'Part',
+ properties: { part_num: '456' }
+ }
+ }, { a: { id: 844424930131972, label: 'Part', properties: { part_num:
'789' } } }]
+ )
+ })
+})
diff --git a/drivers/nodejs/tsconfig.json b/drivers/nodejs/tsconfig.json
index 748fc33..2949721 100644
--- a/drivers/nodejs/tsconfig.json
+++ b/drivers/nodejs/tsconfig.json
@@ -1,6 +1,6 @@
{
"compilerOptions": {
- "target": "es5",
+ "target": "es6",
"module": "commonjs",
"declaration": true,
"outDir": "dist/",