From 16d689f21a8cb3f38fe1b29d5e031c87f3b709d3 Mon Sep 17 00:00:00 2001 From: Smith <125195487+sigmaith@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:05:13 +0900 Subject: [PATCH 1/9] Add test code --- antlr/Schema.g4 | 93 +++++++++++++----------- test/schema.test.ts | 169 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 220 insertions(+), 42 deletions(-) diff --git a/antlr/Schema.g4 b/antlr/Schema.g4 index 2fde3a8..8335c4d 100644 --- a/antlr/Schema.g4 +++ b/antlr/Schema.g4 @@ -1,46 +1,55 @@ grammar Schema; +// Lexer rules +IDENTIFIER: [a-zA-Z_] [a-zA-Z0-9_]*; +WHITESPACE: [ \t\n\r]+ -> skip; +COMMENT: ('//' | '#') ~[\r\n]* -> skip; +DIGIT: [0-9]; + +// Keywords +YORKIE_JSON_ARRAY: 'yorkie.JSONArray'; +YORKIE_JSON_OBJECT: 'yorkie.JSONObject'; +YORKIE_COUNTER: 'yorkie.Counter'; +YORKIE_TEXT: 'yorkie.Text'; +YORKIE_TREE: 'yorkie.Tree'; + +// Operations and Symbols +MINUS: '-'; + // Entry point of the grammar start: typeDefinitions EOF; -typeDefinitions - : typeDefinition (WHITESPACE* typeDefinitions)? - ; -typeDefinition - : 'type' IDENTIFIER '{' fieldList '}' - ; -fieldList - : field (WHITESPACE* fieldList)? - ; -field - : IDENTIFIER WHITESPACE* ':' WHITESPACE* fieldType - ; -fieldType - : typeExpression arraySuffix* - ; -typeExpression - : unionType - | simpleType - ; -simpleType - : primitiveType - | IDENTIFIER - ; -arraySuffix - : '[]' - ; -unionType - : '(' WHITESPACE* unionTypeInner WHITESPACE* ')' - | unionTypeInner - ; -unionTypeInner - : simpleType (WHITESPACE* '|' WHITESPACE* simpleType)* - ; -primitiveType - : ('string' | 'number' | 'boolean') - ; -IDENTIFIER - : [a-zA-Z_] [a-zA-Z0-9_]* - ; -WHITESPACE - : [ \t\n\r]+ -> skip - ; \ No newline at end of file +typeDefinitions: typeDefinition (WHITESPACE* typeDefinitions)?; +typeDefinition: 'type' IDENTIFIER '{' fieldList '}'; +fieldList: field (WHITESPACE* fieldList)?; +field: IDENTIFIER WHITESPACE* ':' WHITESPACE* fieldType; +fieldType: typeExpression arraySuffix*; +typeExpression: unionType | simpleType; +simpleType: primitiveType | literalType | IDENTIFIER; +arraySuffix: '[]'; +unionType: + '(' WHITESPACE* unionTypeInner WHITESPACE* ')' + | unionTypeInner; +unionTypeInner: + simpleType (WHITESPACE* '|' WHITESPACE* simpleType)*; +primitiveType: + 'string' + | 'number' + | 'boolean' + | 'null' + | YORKIE_JSON_ARRAY + | YORKIE_JSON_OBJECT + | YORKIE_COUNTER + | YORKIE_TEXT + | YORKIE_TREE; +literalType: + booleanLiteralType + | numberLiteralType + | stringLiteralType; +booleanLiteralType: 'true' | 'false'; +numberLiteralType: MINUS? DIGIT+ ('.' DIGIT+)?; +stringLiteralType: DOUBLE_QUOTED_STRING | SINGLE_QUOTED_STRING; + +DOUBLE_QUOTED_STRING: '"' (ESC | ~["\n])* '"'; + +SINGLE_QUOTED_STRING: '\'' (ESC | ~['\n])* '\''; +fragment ESC: '\\' [btnr\\'"]; \ No newline at end of file diff --git a/test/schema.test.ts b/test/schema.test.ts index b7d0fdb..ea261f3 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -26,3 +26,172 @@ describe("Schema", () => { ); }); }); + +describe("Schema", () => { + it("should parse a valid schema with basic types", () => { + const schema = ` + type Storage { + todos: Todo[] + } + type Todo { + title: string + completed: boolean + } + `; + assert.isTrue(validate(schema)); + }); + + it("should parse a schema using Yorkie's basic types with comma", () => { + const schema = ` + type Storage { + data: yorkie.JSONObject + } + `; + assert.isTrue(validate(schema)); + }); + + it("should parse a schema using Yorkie's basic types", () => { + const schema = ` + type Storage { + data: yorkieJSONObject + } + `; + assert.isTrue(validate(schema)); + }); + + it("should parse a schema using Yorkie's complex types with comma", () => { + const schema = ` + type Storage { + todos: yorkie.JSONArray + counter: yorkie.Counter + text: yorkie.Text + tree: yorkie.Tree + } + `; + assert.isTrue(validate(schema)); + }); // fail + + it("should parse a schema using Yorkie's complex types", () => { + const schema = ` + type Storage { + todos: yorkieJSONArray + counter: yorkieCounter + text: yorkieText + tree: yorkieTree + } + `; + assert.isTrue(validate(schema)); + }); + + it("should not parse a schema with undefined types", () => { + const schema = ` + type Storage { + unknownType: Hello + } + `; + assert.isFalse(validate(schema)); + }); // fail + + it("should parse a schema with Yorkie's primitive types", () => { + const schema = ` + type Storage { + nullValue: null + booleanValue: boolean + numberValue: number + longValue: long + stringValue: string + bytesValue: bytes + dateValue: Date + } + `; + assert.isTrue(validate(schema)); + }); + + it("should not parse a schema with invalid syntax", () => { + const schema = ` + type Storage { + invalidField: + } + `; + assert.isFalse(validate(schema)); + }); // fail + + it("should not parse a schema with invalid syntax2", () => { + const schema = ` + type Storage { + invalidField , boolean + } + `; + assert.isFalse(validate(schema)); + }); + + it("should not parse a schema with invalid syntax3", () => { + const schema = ` + type Storage { + todos: Todo[] + } + type Todo { + title: string, + completed: boolean + } + `; + assert.isFalse(validate(schema)); + }); // fail + + it("multiple type definitions", () => { + const schema = ` + type MyTypeName { + apple: string + banana: number + cookie: boolean + dog: number[] + string_or_number: string | number + array_of_string_or_number: (string | number)[] + complex: string | number | boolean[] + array_of_complex: (string | number | boolean)[] + } + + type AnotherMyType { + mytypes: MyTypeName[] + } + + type UserDetail { + address: string + age: number + foo: string | number | boolean + bar: string[] + } + + type Root { + name: string + detail: UserDetail + } + `; + assert.isTrue(validate(schema)); + }); // fail + + it("anonymous type definition", () => { + const schema = ` + type Storage { + scientist: { name: string, age: number } + } + `; + assert.isTrue(validate(schema)); + }); + + + it("value restriction", () => { + const schema = ` + type Document { + theme: "light" | "dark" + history: Event[] + } + + type Event { + statusCode: 200 | 400 + info: string + } + `; + assert.isTrue(validate(schema)); + }); +}); \ No newline at end of file From bccdd44eb1d115d7fa2911a9d17e783580f91b8d Mon Sep 17 00:00:00 2001 From: Smith <125195487+sigmaith@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:10:20 +0900 Subject: [PATCH 2/9] Handle syntax errors and print error messages --- src/validator.ts | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/validator.ts b/src/validator.ts index 140fc46..714f17c 100644 --- a/src/validator.ts +++ b/src/validator.ts @@ -53,18 +53,23 @@ class Visitor implements SchemaVisitor { return new Node(node.text); } visitErrorNode(node: ErrorNode): Node { - throw new Error("Method not implemented."); + throw new Error(`Syntax error at: ${node.text}`); } } export function validate(data: string): boolean { - const stream = CharStreams.fromString(data); - const lexer = new SchemaLexer(stream); - const tokens = new CommonTokenStream(lexer); - const parser = new SchemaParser(tokens); - const ast = parser.start(); - const visitor = new Visitor(); - visitor.visit(ast); - - return true; + try { + const stream = CharStreams.fromString(data); + const lexer = new SchemaLexer(stream); + const tokens = new CommonTokenStream(lexer); + const parser = new SchemaParser(tokens); + const ast = parser.start(); + const visitor = new Visitor(); + visitor.visit(ast); + return true; + } catch (error) { + const err = error as Error; + console.error(err.message); + return false; + } } From 8ad6ec6b8ebcc6194d9e4d78fdd3824b6d8a971f Mon Sep 17 00:00:00 2001 From: Smith <125195487+sigmaith@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:15:49 +0900 Subject: [PATCH 3/9] Add yorkie specific data types to grammar --- antlr/Schema.g4 | 103 ++++++++++++++----- src/validator.ts | 70 ++++++++----- test/schema.test.ts | 237 +++++++++++++++++++------------------------- 3 files changed, 228 insertions(+), 182 deletions(-) diff --git a/antlr/Schema.g4 b/antlr/Schema.g4 index 8335c4d..680b09b 100644 --- a/antlr/Schema.g4 +++ b/antlr/Schema.g4 @@ -2,54 +2,105 @@ grammar Schema; // Lexer rules IDENTIFIER: [a-zA-Z_] [a-zA-Z0-9_]*; -WHITESPACE: [ \t\n\r]+ -> skip; +NEWLINE: '\r'? '\n' -> skip; COMMENT: ('//' | '#') ~[\r\n]* -> skip; DIGIT: [0-9]; +WHITESPACE: [ \t\n\r]+ -> skip; // Keywords -YORKIE_JSON_ARRAY: 'yorkie.JSONArray'; -YORKIE_JSON_OBJECT: 'yorkie.JSONObject'; +YORKIE_OBJECT: 'yorkie.Object'; +YORKIE_ARRAY: 'yorkie.Array'; YORKIE_COUNTER: 'yorkie.Counter'; YORKIE_TEXT: 'yorkie.Text'; YORKIE_TREE: 'yorkie.Tree'; // Operations and Symbols MINUS: '-'; +SEMICOLON: ';'; +LPAREN: '('; +RPAREN: ')'; +LCURLY: '{'; +RCURLY: '}'; +GT: '>'; +LT: '<'; +PIPE: '|'; +QUESTION: '?'; +EQ: '='; +COMMA: ','; +LSQUARE: '['; +RSQUARE: ']'; + +// Utils +DOUBLE_QUOTED_STRING: '"' (ESC | ~["\n])* '"'; +SINGLE_QUOTED_STRING: '\'' (ESC | ~['\n])* '\''; +fragment ESC: '\\' [btnr\\'"]; + +// Top-level rule +document: definitionList EOF; + +definitionList: definition (WHITESPACE* definition)*; + +definition: objectTypeDefinition; + +typeName: IDENTIFIER; + +objectTypeDefinition + : 'type' WHITESPACE* typeName WHITESPACE* LCURLY WHITESPACE* + fieldDefList? WHITESPACE* RCURLY SEMICOLON? + ; + +fieldDefList + : fieldDef ( (COMMA | SEMICOLON | NEWLINE) fieldDef)* + ; + +identifier: IDENTIFIER; + +fieldDef: identifier QUESTION? ':' type; + +type: nonUnionType (PIPE type)*; + +nonUnionType: nonUnionTypeL2 (LSQUARE RSQUARE)*; + +nonUnionTypeL2: + LPAREN type RPAREN + | objectLiteralType + | primitiveType + | literalType + | yorkieType + | typeReference; + +typeReference: typeName; +objectLiteralType: LCURLY fieldDefList? RCURLY; -// Entry point of the grammar -start: typeDefinitions EOF; -typeDefinitions: typeDefinition (WHITESPACE* typeDefinitions)?; -typeDefinition: 'type' IDENTIFIER '{' fieldList '}'; -fieldList: field (WHITESPACE* fieldList)?; -field: IDENTIFIER WHITESPACE* ':' WHITESPACE* fieldType; -fieldType: typeExpression arraySuffix*; -typeExpression: unionType | simpleType; -simpleType: primitiveType | literalType | IDENTIFIER; -arraySuffix: '[]'; -unionType: - '(' WHITESPACE* unionTypeInner WHITESPACE* ')' - | unionTypeInner; -unionTypeInner: - simpleType (WHITESPACE* '|' WHITESPACE* simpleType)*; primitiveType: 'string' | 'number' | 'boolean' | 'null' - | YORKIE_JSON_ARRAY - | YORKIE_JSON_OBJECT - | YORKIE_COUNTER - | YORKIE_TEXT - | YORKIE_TREE; + | 'bigint' + | 'Uint8Array' + | 'Date'; + literalType: booleanLiteralType | numberLiteralType | stringLiteralType; + booleanLiteralType: 'true' | 'false'; + numberLiteralType: MINUS? DIGIT+ ('.' DIGIT+)?; + stringLiteralType: DOUBLE_QUOTED_STRING | SINGLE_QUOTED_STRING; -DOUBLE_QUOTED_STRING: '"' (ESC | ~["\n])* '"'; +yorkieType: + yorkieObjectType + | yorkieArrayType + | yorkieCounterType + | yorkieTextType + | yorkieTreeType; -SINGLE_QUOTED_STRING: '\'' (ESC | ~['\n])* '\''; -fragment ESC: '\\' [btnr\\'"]; \ No newline at end of file +yorkieObjectType: YORKIE_OBJECT LT GT; +yorkieArrayType: YORKIE_ARRAY LT GT; +yorkieCounterType: YORKIE_COUNTER LT GT; +yorkieTextType: YORKIE_TEXT LT GT; +yorkieTreeType: YORKIE_TREE LT GT; \ No newline at end of file diff --git a/src/validator.ts b/src/validator.ts index 714f17c..156287e 100644 --- a/src/validator.ts +++ b/src/validator.ts @@ -3,19 +3,31 @@ import { ParseTree } from "antlr4ts/tree/ParseTree"; import { SchemaLexer } from "../antlr/SchemaLexer"; import { SchemaVisitor } from "../antlr/SchemaVisitor"; import { - ArraySuffixContext, - FieldContext, - FieldListContext, - FieldTypeContext, + DocumentContext, + DefinitionListContext, + DefinitionContext, + ObjectTypeDefinitionContext, + TypeNameContext, + FieldDefListContext, + IdentifierContext, + FieldDefContext, + TypeContext, + NonUnionTypeContext, + NonUnionTypeL2Context, + TypeReferenceContext, + ObjectLiteralTypeContext, PrimitiveTypeContext, + LiteralTypeContext, + NumberLiteralTypeContext, + BooleanLiteralTypeContext, + StringLiteralTypeContext, + YorkieTypeContext, + YorkieObjectTypeContext, + YorkieArrayTypeContext, + YorkieCounterTypeContext, + YorkieTextTypeContext, + YorkieTreeTypeContext, SchemaParser, - SimpleTypeContext, - StartContext, - TypeDefinitionContext, - TypeDefinitionsContext, - TypeExpressionContext, - UnionTypeContext, - UnionTypeInnerContext, } from "../antlr/SchemaParser"; import { ErrorNode } from "antlr4ts/tree/ErrorNode"; import { RuleNode } from "antlr4ts/tree/RuleNode"; @@ -26,18 +38,30 @@ class Node { } class Visitor implements SchemaVisitor { - visitStart?: ((ctx: StartContext) => Node) | undefined; - visitTypeDefinitions?: ((ctx: TypeDefinitionsContext) => Node) | undefined; - visitTypeDefinition?: ((ctx: TypeDefinitionContext) => Node) | undefined; - visitFieldList?: ((ctx: FieldListContext) => Node) | undefined; - visitField?: ((ctx: FieldContext) => Node) | undefined; - visitFieldType?: ((ctx: FieldTypeContext) => Node) | undefined; - visitTypeExpression?: ((ctx: TypeExpressionContext) => Node) | undefined; - visitSimpleType?: ((ctx: SimpleTypeContext) => Node) | undefined; - visitArraySuffix?: ((ctx: ArraySuffixContext) => Node) | undefined; - visitUnionType?: ((ctx: UnionTypeContext) => Node) | undefined; - visitUnionTypeInner?: ((ctx: UnionTypeInnerContext) => Node) | undefined; + visitDocument?: ((ctx: DocumentContext) => Node) | undefined; + visitDefinitionList?: ((ctx: DefinitionListContext) => Node) | undefined; + visitDefinition?: ((ctx: DefinitionContext) => Node) | undefined; + visitTypeName?: ((ctx: TypeNameContext) => Node) | undefined; + visitObjectTypeDefinition?: ((ctx: ObjectTypeDefinitionContext) => Node) | undefined; + visitFieldDefList?: ((ctx: FieldDefListContext) => Node) | undefined; + visitTypeIdentifier?: ((ctx: IdentifierContext) => Node) | undefined; + visitFieldDef?: ((ctx: FieldDefContext) => Node) | undefined; + visitType?: ((ctx: TypeContext) => Node) | undefined; + visitNonUnionType?: ((ctx: NonUnionTypeContext) => Node) | undefined; + visitNonUnionTypeL2?: ((ctx: NonUnionTypeL2Context) => Node) | undefined; + visitTypeReference?: ((ctx: TypeReferenceContext) => Node) | undefined; + visitObjectLiteralType?: ((ctx: ObjectLiteralTypeContext) => Node) | undefined; visitPrimitiveType?: ((ctx: PrimitiveTypeContext) => Node) | undefined; + visitLiteralType?: ((ctx: LiteralTypeContext) => Node) | undefined; + visitNumberLiteralType?: ((ctx: NumberLiteralTypeContext) => Node) | undefined; + visitBooleanLiteralType?: ((ctx: BooleanLiteralTypeContext) => Node) | undefined; + visitStringLiteralType?: ((ctx: StringLiteralTypeContext) => Node) | undefined; + visitYorkieType?: ((ctx: YorkieTypeContext) => Node) | undefined; + visitYorkieObjectType?: ((ctx: YorkieObjectTypeContext) => Node) | undefined; + visitYorkieArrayType?: ((ctx: YorkieArrayTypeContext) => Node) | undefined; + visitYorkieCounterType?: ((ctx: YorkieCounterTypeContext) => Node) | undefined; + visitYorkieTextType?: ((ctx: YorkieTextTypeContext) => Node) | undefined; + visitYorkieTreeType?: ((ctx: YorkieTreeTypeContext) => Node) | undefined; visit(tree: ParseTree): Node { return tree.accept(this); } @@ -63,7 +87,7 @@ export function validate(data: string): boolean { const lexer = new SchemaLexer(stream); const tokens = new CommonTokenStream(lexer); const parser = new SchemaParser(tokens); - const ast = parser.start(); + const ast = parser.document(); const visitor = new Visitor(); visitor.visit(ast); return true; diff --git a/test/schema.test.ts b/test/schema.test.ts index ea261f3..7e412dd 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -1,197 +1,168 @@ import { describe, it, assert } from "vitest"; import { validate } from "../src/validator"; -describe("Schema", () => { - it("should be able to parse the valid schema", () => { - // 우리가 생각하는 Schema의 스팩은? - // - TypeScript와 유사한 타입 정의 문법을 사용한다. - // - Yorkie가 갖고 있는 기본 타입을 사용할 수 있다. - // - yorkie.JSONArray, yorkie.JSONObject - // - yorkie.Counter, yorkie.Text, yorkie.Tree - // - 이외에 사용자가 정의한 타입을 사용할 수 있다. - // - 하지만 정의하지 않은 타입을 사용할 수 없다. - // - Yorkie가 갖고 있는 Primitive 타입을 사용할 수 있다. - // - null, boolean, number(integer, double), long(bigint), string, bytes(Uint8Array), Date - - assert.isTrue( - validate(` - type Storage { - todos: Todo[] - } - type Todo { - title: string - completed: boolean - } - `) - ); - }); -}); - -describe("Schema", () => { - it("should parse a valid schema with basic types", () => { +describe("Use Grammar Similar to TypeScript", () => { + it("value restriction with literal types", () => { const schema = ` - type Storage { - todos: Todo[] + type Document { + theme: "light" | "dark"; + history: Event[]; } - type Todo { - title: string - completed: boolean + + type Event { + statusCode: 200 | 400; + info: string; } `; assert.isTrue(validate(schema)); }); - it("should parse a schema using Yorkie's basic types with comma", () => { + it("array with anonymous type definition", () => { const schema = ` - type Storage { - data: yorkie.JSONObject + type Document { + objectArray: { name: string; age: number; }[]; } `; assert.isTrue(validate(schema)); }); - it("should parse a schema using Yorkie's basic types", () => { + it("union types", () => { const schema = ` - type Storage { - data: yorkieJSONObject + type Document { + title: string; + author: string | null; } `; assert.isTrue(validate(schema)); }); - it("should parse a schema using Yorkie's complex types with comma", () => { + it("invalid syntax: empty type definition", () => { const schema = ` - type Storage { - todos: yorkie.JSONArray - counter: yorkie.Counter - text: yorkie.Text - tree: yorkie.Tree + type Document { + invalidField: } `; - assert.isTrue(validate(schema)); - }); // fail + assert.isFalse(validate(schema)); + }); - it("should parse a schema using Yorkie's complex types", () => { + it("invalid syntax: no semicolon", () => { const schema = ` - type Storage { - todos: yorkieJSONArray - counter: yorkieCounter - text: yorkieText - tree: yorkieTree + type Document { + invalidField: number; } `; assert.isTrue(validate(schema)); }); - it("should not parse a schema with undefined types", () => { + it("anonymous type definition", () => { const schema = ` - type Storage { - unknownType: Hello - } + type Document { + scientist: { + name: string; + age: number; + }; + }; `; - assert.isFalse(validate(schema)); - }); // fail + assert.isTrue(validate(schema)); + }); - it("should parse a schema with Yorkie's primitive types", () => { + it("optional properties", () => { const schema = ` - type Storage { - nullValue: null - booleanValue: boolean - numberValue: number - longValue: long - stringValue: string - bytesValue: bytes - dateValue: Date - } + type Document { + title: string; + version?: number; + author?: string; + }; `; assert.isTrue(validate(schema)); }); +}); - it("should not parse a schema with invalid syntax", () => { +describe("Yorkie Primitive Types", () => { + it("should parse a schema with Yorkie's primitive types", () => { const schema = ` - type Storage { - invalidField: + type Document { + field1: null; + field2: boolean; + field3: number; + field4: bigint; + field5: Uint8Array; + field6: Date; + field7: string; } `; - assert.isFalse(validate(schema)); - }); // fail + assert.isTrue(validate(schema)); + }); +}); - it("should not parse a schema with invalid syntax2", () => { +describe("Yorkie Element Level Basic Types", () => { + it("should parse a schema using Yorkie's complex types", () => { const schema = ` - type Storage { - invalidField , boolean - } + type Document { + object: yorkie.Object; + array: yorkie.Array; + counter: yorkie.Counter; + text: yorkie.Text; + tree: yorkie.Tree; + }; `; - assert.isFalse(validate(schema)); + assert.isTrue(validate(schema)); }); +}); - it("should not parse a schema with invalid syntax3", () => { +describe("User Defined Types", () => { + it("", () => { const schema = ` - type Storage { - todos: Todo[] + type Document { + todos: Todo[]; } + type Todo { - title: string, - completed: boolean + title: string; + completed: boolean; } `; - assert.isFalse(validate(schema)); - }); // fail - - it("multiple type definitions", () => { - const schema = ` - type MyTypeName { - apple: string - banana: number - cookie: boolean - dog: number[] - string_or_number: string | number - array_of_string_or_number: (string | number)[] - complex: string | number | boolean[] - array_of_complex: (string | number | boolean)[] - } - - type AnotherMyType { - mytypes: MyTypeName[] - } - - type UserDetail { - address: string - age: number - foo: string | number | boolean - bar: string[] - } - - type Root { - name: string - detail: UserDetail - } - `; assert.isTrue(validate(schema)); - }); // fail + }); - it("anonymous type definition", () => { + it("multiple user defined types", () => { const schema = ` - type Storage { - scientist: { name: string, age: number } - } + type Document { + name: string; + detail: UserDetail; + mytypes: MyTypeName[]; + }; + + type MyTypeName { + apple: string; + banana: number; + cookie: boolean; + dog: number[]; + string_or_number: string | number; + array_of_string_or_number: (string | number)[]; + complex: string | number | boolean[]; + array_of_complex: (string | number | boolean)[]; + }; + + type UserDetail { + address: string; + age: number; + foo: string | number | boolean; + bar: string[]; + }; `; assert.isTrue(validate(schema)); }); +}); - - it("value restriction", () => { +describe("Exclude UnDefined Types", () => { + it("should not parse a schema with undefined types", () => { const schema = ` - type Document { - theme: "light" | "dark" - history: Event[] - } - - type Event { - statusCode: 200 | 400 - info: string - } + type Document { + unknownType: Hello; + }; `; - assert.isTrue(validate(schema)); + assert.isFalse(validate(schema)); }); + }); \ No newline at end of file From f652a32b4059bcc552f9951df292939fc2083e16 Mon Sep 17 00:00:00 2001 From: Smith <125195487+sigmaith@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:04:58 +0900 Subject: [PATCH 4/9] Add annotations --- test/schema.test.ts | 129 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 121 insertions(+), 8 deletions(-) diff --git a/test/schema.test.ts b/test/schema.test.ts index 7e412dd..217a003 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -36,12 +36,13 @@ describe("Use Grammar Similar to TypeScript", () => { assert.isTrue(validate(schema)); }); - it("invalid syntax: empty type definition", () => { + it.skip("invalid syntax: empty type definition", () => { const schema = ` type Document { invalidField: } `; + // TODO(sigmaith): If the type is not defined, an error should occur. assert.isFalse(validate(schema)); }); @@ -76,6 +77,29 @@ describe("Use Grammar Similar to TypeScript", () => { `; assert.isTrue(validate(schema)); }); + + it.skip("Type not supported in TypeScript", () => { + const schema = ` + type Document { + title: float; + version?: longlong; + author?: long; + }; + `; + // TODO(sigmaith): Type not supported by TS is not available. + assert.isFalse(validate(schema)); + }); + + it("annotation", () => { + const schema = ` + type Document { + field: string; + } + // comment1 + # comment2 + `; + assert.isTrue(validate(schema)); + }); }); describe("Yorkie Primitive Types", () => { @@ -96,16 +120,53 @@ describe("Yorkie Primitive Types", () => { }); describe("Yorkie Element Level Basic Types", () => { - it("should parse a schema using Yorkie's complex types", () => { + it("Yorkie types correct example: Counter, Tree, Text", () => { const schema = ` type Document { - object: yorkie.Object; - array: yorkie.Array; counter: yorkie.Counter; - text: yorkie.Text; tree: yorkie.Tree; + text: yorkie.Text; + }; + `; + assert.isTrue(validate(schema)); + }); + + it.skip("Yorkie types correct example: User Defined Text Type With Attributes", () => { + const schema = ` + type Document { + text: yorkie.Text<{}>; + text: yorkie.Text<{bold: boolean}>; + }; + `; + // TODO(sigmaith): Users must be able to define the properties of the Yorkie.Text data structure themselves. + assert.isTrue(validate(schema)); + }); + + it.skip("should parse a schema using Yorkie types", () => { + const schema = ` + type Document { + object: yorkie.Object; + array: yorkie.Array; + }; + `; + // TODO(sigmaith): Limit the user to define the Yorkie.Object, Yorkie.Array correctly. + assert.isFalse(validate(schema)); + }); + + it.skip("should parse a schema using Yorkie's complex types", () => { + const schema = ` + type Todo { + title: string; + completed: boolean; + } + type Document { + object: yorkie.Object<{}>; + array: yorkie.Array; + array2: yorkie.Array>; + array3: yorkie.Array; }; `; + // TODO(sigmaith): Limit the user to define the Yorkie.Object, Yorkie.Array correctly. assert.isTrue(validate(schema)); }); }); @@ -125,6 +186,21 @@ describe("User Defined Types", () => { assert.isTrue(validate(schema)); }); + it.skip("", () => { + const schema = ` + type Document { + todos: Array; + } + + type Todo { + title: string; + completed: boolean; + } + `; + assert.isTrue(validate(schema)); + // Todo(sigmaith): Array type should be supported. + }); + it("multiple user defined types", () => { const schema = ` type Document { @@ -156,13 +232,50 @@ describe("User Defined Types", () => { }); describe("Exclude UnDefined Types", () => { - it("should not parse a schema with undefined types", () => { + it.skip("should not parse a schema with undefined types", () => { const schema = ` type Document { unknownType: Hello; }; `; + // TODO(sigmaith): Limit the undefined type to be unavailable. assert.isFalse(validate(schema)); - }); + }) +}); + +describe("Exception Handling", () => { + it("Restricting the use of reserved words", () => { + const schema = ` + type string { + field1: string; + } + `; + assert.isFalse(validate(schema)); + }) -}); \ No newline at end of file + it.skip("Restricting unused type definition", () => { + const schema = ` + type UserType { + field1: string; + } + `; + // TODO(sigmaith): Inform that the defined type has not been used. + assert.isFalse(validate(schema)); + }) + + it.skip("Type Cycle", () => { + const schema = ` + type Hello { + field1: string; + field2: World; + } + + type World { + field1: string; + field2: Hello; + } + `; + // TODO(sigmaith): Restrict Type Cycle. + assert.isFalse(validate(schema)); + }) +}) \ No newline at end of file From 0b4934e735ec3193b589899138cf73f90784f61a Mon Sep 17 00:00:00 2001 From: Smith <125195487+sigmaith@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:32:08 +0900 Subject: [PATCH 5/9] Modify test code's mistakes --- test/schema.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/schema.test.ts b/test/schema.test.ts index 217a003..c7258cd 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -46,13 +46,13 @@ describe("Use Grammar Similar to TypeScript", () => { assert.isFalse(validate(schema)); }); - it("invalid syntax: no semicolon", () => { + it.skip("invalid syntax: no semicolon", () => { const schema = ` type Document { - invalidField: number; + invalidField: number } `; - assert.isTrue(validate(schema)); + assert.isFalse(validate(schema)); }); it("anonymous type definition", () => { @@ -134,8 +134,8 @@ describe("Yorkie Element Level Basic Types", () => { it.skip("Yorkie types correct example: User Defined Text Type With Attributes", () => { const schema = ` type Document { - text: yorkie.Text<{}>; - text: yorkie.Text<{bold: boolean}>; + text1: yorkie.Text<{}>; + text2: yorkie.Text<{bold: boolean}>; }; `; // TODO(sigmaith): Users must be able to define the properties of the Yorkie.Text data structure themselves. @@ -172,7 +172,7 @@ describe("Yorkie Element Level Basic Types", () => { }); describe("User Defined Types", () => { - it("", () => { + it("should support type[] syntax for user-defined types", () => { const schema = ` type Document { todos: Todo[]; @@ -186,7 +186,7 @@ describe("User Defined Types", () => { assert.isTrue(validate(schema)); }); - it.skip("", () => { + it.skip("should support Array syntax for user-defined types", () => { const schema = ` type Document { todos: Array; From a6848945c0b1858c58d28f83fc9c33a8bddb020a Mon Sep 17 00:00:00 2001 From: Smith <125195487+sigmaith@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:37:26 +0900 Subject: [PATCH 6/9] Fix grammar of yorkie element level types --- antlr/Schema.g4 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/antlr/Schema.g4 b/antlr/Schema.g4 index 680b09b..4da6851 100644 --- a/antlr/Schema.g4 +++ b/antlr/Schema.g4 @@ -50,7 +50,7 @@ objectTypeDefinition ; fieldDefList - : fieldDef ( (COMMA | SEMICOLON | NEWLINE) fieldDef)* + : fieldDef ((COMMA | SEMICOLON | NEWLINE) fieldDef)* ; identifier: IDENTIFIER; @@ -79,7 +79,8 @@ primitiveType: | 'null' | 'bigint' | 'Uint8Array' - | 'Date'; + | 'Date' + ; literalType: booleanLiteralType @@ -99,8 +100,11 @@ yorkieType: | yorkieTextType | yorkieTreeType; -yorkieObjectType: YORKIE_OBJECT LT GT; -yorkieArrayType: YORKIE_ARRAY LT GT; -yorkieCounterType: YORKIE_COUNTER LT GT; -yorkieTextType: YORKIE_TEXT LT GT; +yorkieObjectType: + YORKIE_OBJECT LT (typeReference | objectLiteralType) GT; +yorkieArrayType: + YORKIE_ARRAY LT (typeReference | objectLiteralType) GT; +yorkieCounterType: YORKIE_COUNTER; +yorkieTextType: + YORKIE_TEXT LT (typeReference | objectLiteralType) GT; yorkieTreeType: YORKIE_TREE LT GT; \ No newline at end of file From ea9f9c30a886c0e705dc84ae4ae9b87010ba02e8 Mon Sep 17 00:00:00 2001 From: Smith <125195487+sigmaith@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:48:18 +0900 Subject: [PATCH 7/9] Enhance type safety in validate function's error handling --- src/validator.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/validator.ts b/src/validator.ts index 156287e..1890b9a 100644 --- a/src/validator.ts +++ b/src/validator.ts @@ -81,6 +81,8 @@ class Visitor implements SchemaVisitor { } } + + export function validate(data: string): boolean { try { const stream = CharStreams.fromString(data); @@ -92,8 +94,11 @@ export function validate(data: string): boolean { visitor.visit(ast); return true; } catch (error) { - const err = error as Error; - console.error(err.message); + if (error instanceof Error) { + console.error(error.message); + } else { + console.error(String(error)); + } return false; } } From 2e667083fd12e79eed00263020ca85d2d0d78896 Mon Sep 17 00:00:00 2001 From: Smith <125195487+sigmaith@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:06:24 +0900 Subject: [PATCH 8/9] Add newline at end of file --- test/schema.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/schema.test.ts b/test/schema.test.ts index 8be39dd..aeb405a 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -280,4 +280,4 @@ describe("Exception Handling", () => { // TODO(sigmaith): Restrict Type Cycle. assert.isFalse(validate(schema)); }) -}) \ No newline at end of file +}) From a2b9afc64925353a5523e4ba6baba184d98b4cf7 Mon Sep 17 00:00:00 2001 From: Smith <125195487+sigmaith@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:16:40 +0900 Subject: [PATCH 9/9] Add ANTLR grammar build files --- antlr/Schema.interp | 98 +- antlr/Schema.tokens | 69 +- antlr/SchemaLexer.interp | 90 +- antlr/SchemaLexer.tokens | 69 +- antlr/SchemaLexer.ts | 217 +++- antlr/SchemaListener.ts | 254 +++-- antlr/SchemaParser.ts | 2031 +++++++++++++++++++++++++++++--------- antlr/SchemaVisitor.ts | 162 ++- 8 files changed, 2344 insertions(+), 646 deletions(-) diff --git a/antlr/Schema.interp b/antlr/Schema.interp index a4153e1..64cb337 100644 --- a/antlr/Schema.interp +++ b/antlr/Schema.interp @@ -1,16 +1,41 @@ token literal names: null 'type' -'{' -'}' ':' -'[]' -'(' -')' -'|' 'string' 'number' 'boolean' +'null' +'bigint' +'Uint8Array' +'Date' +'true' +'false' +'.' +null +null +null +null +null +'yorkie.Object' +'yorkie.Array' +'yorkie.Counter' +'yorkie.Text' +'yorkie.Tree' +'-' +';' +'(' +')' +'{' +'}' +'>' +'<' +'|' +'?' +'=' +',' +'[' +']' null null @@ -27,23 +52,60 @@ null null null null +null IDENTIFIER +NEWLINE +COMMENT +DIGIT WHITESPACE +YORKIE_OBJECT +YORKIE_ARRAY +YORKIE_COUNTER +YORKIE_TEXT +YORKIE_TREE +MINUS +SEMICOLON +LPAREN +RPAREN +LCURLY +RCURLY +GT +LT +PIPE +QUESTION +EQ +COMMA +LSQUARE +RSQUARE +DOUBLE_QUOTED_STRING +SINGLE_QUOTED_STRING rule names: -start -typeDefinitions -typeDefinition -fieldList -field -fieldType -typeExpression -simpleType -arraySuffix -unionType -unionTypeInner +document +definitionList +definition +typeName +objectTypeDefinition +fieldDefList +identifier +fieldDef +type +nonUnionType +nonUnionTypeL2 +typeReference +objectLiteralType primitiveType +literalType +booleanLiteralType +numberLiteralType +stringLiteralType +yorkieType +yorkieObjectType +yorkieArrayType +yorkieCounterType +yorkieTextType +yorkieTreeType atn: -[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 3, 15, 130, 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, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 7, 3, 32, 10, 3, 12, 3, 14, 3, 35, 11, 3, 3, 3, 5, 3, 38, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 7, 5, 48, 10, 5, 12, 5, 14, 5, 51, 11, 5, 3, 5, 5, 5, 54, 10, 5, 3, 6, 3, 6, 7, 6, 58, 10, 6, 12, 6, 14, 6, 61, 11, 6, 3, 6, 3, 6, 7, 6, 65, 10, 6, 12, 6, 14, 6, 68, 11, 6, 3, 6, 3, 6, 3, 7, 3, 7, 7, 7, 74, 10, 7, 12, 7, 14, 7, 77, 11, 7, 3, 8, 3, 8, 5, 8, 81, 10, 8, 3, 9, 3, 9, 5, 9, 85, 10, 9, 3, 10, 3, 10, 3, 11, 3, 11, 7, 11, 91, 10, 11, 12, 11, 14, 11, 94, 11, 11, 3, 11, 3, 11, 7, 11, 98, 10, 11, 12, 11, 14, 11, 101, 11, 11, 3, 11, 3, 11, 3, 11, 5, 11, 106, 10, 11, 3, 12, 3, 12, 7, 12, 110, 10, 12, 12, 12, 14, 12, 113, 11, 12, 3, 12, 3, 12, 7, 12, 117, 10, 12, 12, 12, 14, 12, 120, 11, 12, 3, 12, 7, 12, 123, 10, 12, 12, 12, 14, 12, 126, 11, 12, 3, 13, 3, 13, 3, 13, 2, 2, 2, 14, 2, 2, 4, 2, 6, 2, 8, 2, 10, 2, 12, 2, 14, 2, 16, 2, 18, 2, 20, 2, 22, 2, 24, 2, 2, 3, 3, 2, 11, 13, 2, 132, 2, 26, 3, 2, 2, 2, 4, 29, 3, 2, 2, 2, 6, 39, 3, 2, 2, 2, 8, 45, 3, 2, 2, 2, 10, 55, 3, 2, 2, 2, 12, 71, 3, 2, 2, 2, 14, 80, 3, 2, 2, 2, 16, 84, 3, 2, 2, 2, 18, 86, 3, 2, 2, 2, 20, 105, 3, 2, 2, 2, 22, 107, 3, 2, 2, 2, 24, 127, 3, 2, 2, 2, 26, 27, 5, 4, 3, 2, 27, 28, 7, 2, 2, 3, 28, 3, 3, 2, 2, 2, 29, 37, 5, 6, 4, 2, 30, 32, 7, 15, 2, 2, 31, 30, 3, 2, 2, 2, 32, 35, 3, 2, 2, 2, 33, 31, 3, 2, 2, 2, 33, 34, 3, 2, 2, 2, 34, 36, 3, 2, 2, 2, 35, 33, 3, 2, 2, 2, 36, 38, 5, 4, 3, 2, 37, 33, 3, 2, 2, 2, 37, 38, 3, 2, 2, 2, 38, 5, 3, 2, 2, 2, 39, 40, 7, 3, 2, 2, 40, 41, 7, 14, 2, 2, 41, 42, 7, 4, 2, 2, 42, 43, 5, 8, 5, 2, 43, 44, 7, 5, 2, 2, 44, 7, 3, 2, 2, 2, 45, 53, 5, 10, 6, 2, 46, 48, 7, 15, 2, 2, 47, 46, 3, 2, 2, 2, 48, 51, 3, 2, 2, 2, 49, 47, 3, 2, 2, 2, 49, 50, 3, 2, 2, 2, 50, 52, 3, 2, 2, 2, 51, 49, 3, 2, 2, 2, 52, 54, 5, 8, 5, 2, 53, 49, 3, 2, 2, 2, 53, 54, 3, 2, 2, 2, 54, 9, 3, 2, 2, 2, 55, 59, 7, 14, 2, 2, 56, 58, 7, 15, 2, 2, 57, 56, 3, 2, 2, 2, 58, 61, 3, 2, 2, 2, 59, 57, 3, 2, 2, 2, 59, 60, 3, 2, 2, 2, 60, 62, 3, 2, 2, 2, 61, 59, 3, 2, 2, 2, 62, 66, 7, 6, 2, 2, 63, 65, 7, 15, 2, 2, 64, 63, 3, 2, 2, 2, 65, 68, 3, 2, 2, 2, 66, 64, 3, 2, 2, 2, 66, 67, 3, 2, 2, 2, 67, 69, 3, 2, 2, 2, 68, 66, 3, 2, 2, 2, 69, 70, 5, 12, 7, 2, 70, 11, 3, 2, 2, 2, 71, 75, 5, 14, 8, 2, 72, 74, 5, 18, 10, 2, 73, 72, 3, 2, 2, 2, 74, 77, 3, 2, 2, 2, 75, 73, 3, 2, 2, 2, 75, 76, 3, 2, 2, 2, 76, 13, 3, 2, 2, 2, 77, 75, 3, 2, 2, 2, 78, 81, 5, 20, 11, 2, 79, 81, 5, 16, 9, 2, 80, 78, 3, 2, 2, 2, 80, 79, 3, 2, 2, 2, 81, 15, 3, 2, 2, 2, 82, 85, 5, 24, 13, 2, 83, 85, 7, 14, 2, 2, 84, 82, 3, 2, 2, 2, 84, 83, 3, 2, 2, 2, 85, 17, 3, 2, 2, 2, 86, 87, 7, 7, 2, 2, 87, 19, 3, 2, 2, 2, 88, 92, 7, 8, 2, 2, 89, 91, 7, 15, 2, 2, 90, 89, 3, 2, 2, 2, 91, 94, 3, 2, 2, 2, 92, 90, 3, 2, 2, 2, 92, 93, 3, 2, 2, 2, 93, 95, 3, 2, 2, 2, 94, 92, 3, 2, 2, 2, 95, 99, 5, 22, 12, 2, 96, 98, 7, 15, 2, 2, 97, 96, 3, 2, 2, 2, 98, 101, 3, 2, 2, 2, 99, 97, 3, 2, 2, 2, 99, 100, 3, 2, 2, 2, 100, 102, 3, 2, 2, 2, 101, 99, 3, 2, 2, 2, 102, 103, 7, 9, 2, 2, 103, 106, 3, 2, 2, 2, 104, 106, 5, 22, 12, 2, 105, 88, 3, 2, 2, 2, 105, 104, 3, 2, 2, 2, 106, 21, 3, 2, 2, 2, 107, 124, 5, 16, 9, 2, 108, 110, 7, 15, 2, 2, 109, 108, 3, 2, 2, 2, 110, 113, 3, 2, 2, 2, 111, 109, 3, 2, 2, 2, 111, 112, 3, 2, 2, 2, 112, 114, 3, 2, 2, 2, 113, 111, 3, 2, 2, 2, 114, 118, 7, 10, 2, 2, 115, 117, 7, 15, 2, 2, 116, 115, 3, 2, 2, 2, 117, 120, 3, 2, 2, 2, 118, 116, 3, 2, 2, 2, 118, 119, 3, 2, 2, 2, 119, 121, 3, 2, 2, 2, 120, 118, 3, 2, 2, 2, 121, 123, 5, 16, 9, 2, 122, 111, 3, 2, 2, 2, 123, 126, 3, 2, 2, 2, 124, 122, 3, 2, 2, 2, 124, 125, 3, 2, 2, 2, 125, 23, 3, 2, 2, 2, 126, 124, 3, 2, 2, 2, 127, 128, 9, 2, 2, 2, 128, 25, 3, 2, 2, 2, 17, 33, 37, 49, 53, 59, 66, 75, 80, 84, 92, 99, 105, 111, 118, 124] \ No newline at end of file +[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 3, 40, 221, 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, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 7, 3, 56, 10, 3, 12, 3, 14, 3, 59, 11, 3, 3, 3, 7, 3, 62, 10, 3, 12, 3, 14, 3, 65, 11, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 7, 6, 73, 10, 6, 12, 6, 14, 6, 76, 11, 6, 3, 6, 3, 6, 7, 6, 80, 10, 6, 12, 6, 14, 6, 83, 11, 6, 3, 6, 3, 6, 7, 6, 87, 10, 6, 12, 6, 14, 6, 90, 11, 6, 3, 6, 5, 6, 93, 10, 6, 3, 6, 7, 6, 96, 10, 6, 12, 6, 14, 6, 99, 11, 6, 3, 6, 3, 6, 5, 6, 103, 10, 6, 3, 7, 3, 7, 3, 7, 7, 7, 108, 10, 7, 12, 7, 14, 7, 111, 11, 7, 3, 8, 3, 8, 3, 9, 3, 9, 5, 9, 117, 10, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 7, 10, 125, 10, 10, 12, 10, 14, 10, 128, 11, 10, 3, 11, 3, 11, 3, 11, 7, 11, 133, 10, 11, 12, 11, 14, 11, 136, 11, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 5, 12, 147, 10, 12, 3, 13, 3, 13, 3, 14, 3, 14, 5, 14, 153, 10, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 5, 16, 162, 10, 16, 3, 17, 3, 17, 3, 18, 5, 18, 167, 10, 18, 3, 18, 6, 18, 170, 10, 18, 13, 18, 14, 18, 171, 3, 18, 3, 18, 6, 18, 176, 10, 18, 13, 18, 14, 18, 177, 5, 18, 180, 10, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 5, 20, 189, 10, 20, 3, 21, 3, 21, 3, 21, 3, 21, 5, 21, 195, 10, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 5, 22, 203, 10, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 5, 24, 213, 10, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 2, 2, 2, 26, 2, 2, 4, 2, 6, 2, 8, 2, 10, 2, 12, 2, 14, 2, 16, 2, 18, 2, 20, 2, 22, 2, 24, 2, 26, 2, 28, 2, 30, 2, 32, 2, 34, 2, 36, 2, 38, 2, 40, 2, 42, 2, 44, 2, 46, 2, 48, 2, 2, 6, 5, 2, 16, 16, 26, 26, 36, 36, 3, 2, 5, 11, 3, 2, 12, 13, 3, 2, 39, 40, 2, 227, 2, 50, 3, 2, 2, 2, 4, 53, 3, 2, 2, 2, 6, 66, 3, 2, 2, 2, 8, 68, 3, 2, 2, 2, 10, 70, 3, 2, 2, 2, 12, 104, 3, 2, 2, 2, 14, 112, 3, 2, 2, 2, 16, 114, 3, 2, 2, 2, 18, 121, 3, 2, 2, 2, 20, 129, 3, 2, 2, 2, 22, 146, 3, 2, 2, 2, 24, 148, 3, 2, 2, 2, 26, 150, 3, 2, 2, 2, 28, 156, 3, 2, 2, 2, 30, 161, 3, 2, 2, 2, 32, 163, 3, 2, 2, 2, 34, 166, 3, 2, 2, 2, 36, 181, 3, 2, 2, 2, 38, 188, 3, 2, 2, 2, 40, 190, 3, 2, 2, 2, 42, 198, 3, 2, 2, 2, 44, 206, 3, 2, 2, 2, 46, 208, 3, 2, 2, 2, 48, 216, 3, 2, 2, 2, 50, 51, 5, 4, 3, 2, 51, 52, 7, 2, 2, 3, 52, 3, 3, 2, 2, 2, 53, 63, 5, 6, 4, 2, 54, 56, 7, 19, 2, 2, 55, 54, 3, 2, 2, 2, 56, 59, 3, 2, 2, 2, 57, 55, 3, 2, 2, 2, 57, 58, 3, 2, 2, 2, 58, 60, 3, 2, 2, 2, 59, 57, 3, 2, 2, 2, 60, 62, 5, 6, 4, 2, 61, 57, 3, 2, 2, 2, 62, 65, 3, 2, 2, 2, 63, 61, 3, 2, 2, 2, 63, 64, 3, 2, 2, 2, 64, 5, 3, 2, 2, 2, 65, 63, 3, 2, 2, 2, 66, 67, 5, 10, 6, 2, 67, 7, 3, 2, 2, 2, 68, 69, 7, 15, 2, 2, 69, 9, 3, 2, 2, 2, 70, 74, 7, 3, 2, 2, 71, 73, 7, 19, 2, 2, 72, 71, 3, 2, 2, 2, 73, 76, 3, 2, 2, 2, 74, 72, 3, 2, 2, 2, 74, 75, 3, 2, 2, 2, 75, 77, 3, 2, 2, 2, 76, 74, 3, 2, 2, 2, 77, 81, 5, 8, 5, 2, 78, 80, 7, 19, 2, 2, 79, 78, 3, 2, 2, 2, 80, 83, 3, 2, 2, 2, 81, 79, 3, 2, 2, 2, 81, 82, 3, 2, 2, 2, 82, 84, 3, 2, 2, 2, 83, 81, 3, 2, 2, 2, 84, 88, 7, 29, 2, 2, 85, 87, 7, 19, 2, 2, 86, 85, 3, 2, 2, 2, 87, 90, 3, 2, 2, 2, 88, 86, 3, 2, 2, 2, 88, 89, 3, 2, 2, 2, 89, 92, 3, 2, 2, 2, 90, 88, 3, 2, 2, 2, 91, 93, 5, 12, 7, 2, 92, 91, 3, 2, 2, 2, 92, 93, 3, 2, 2, 2, 93, 97, 3, 2, 2, 2, 94, 96, 7, 19, 2, 2, 95, 94, 3, 2, 2, 2, 96, 99, 3, 2, 2, 2, 97, 95, 3, 2, 2, 2, 97, 98, 3, 2, 2, 2, 98, 100, 3, 2, 2, 2, 99, 97, 3, 2, 2, 2, 100, 102, 7, 30, 2, 2, 101, 103, 7, 26, 2, 2, 102, 101, 3, 2, 2, 2, 102, 103, 3, 2, 2, 2, 103, 11, 3, 2, 2, 2, 104, 109, 5, 16, 9, 2, 105, 106, 9, 2, 2, 2, 106, 108, 5, 16, 9, 2, 107, 105, 3, 2, 2, 2, 108, 111, 3, 2, 2, 2, 109, 107, 3, 2, 2, 2, 109, 110, 3, 2, 2, 2, 110, 13, 3, 2, 2, 2, 111, 109, 3, 2, 2, 2, 112, 113, 7, 15, 2, 2, 113, 15, 3, 2, 2, 2, 114, 116, 5, 14, 8, 2, 115, 117, 7, 34, 2, 2, 116, 115, 3, 2, 2, 2, 116, 117, 3, 2, 2, 2, 117, 118, 3, 2, 2, 2, 118, 119, 7, 4, 2, 2, 119, 120, 5, 18, 10, 2, 120, 17, 3, 2, 2, 2, 121, 126, 5, 20, 11, 2, 122, 123, 7, 33, 2, 2, 123, 125, 5, 18, 10, 2, 124, 122, 3, 2, 2, 2, 125, 128, 3, 2, 2, 2, 126, 124, 3, 2, 2, 2, 126, 127, 3, 2, 2, 2, 127, 19, 3, 2, 2, 2, 128, 126, 3, 2, 2, 2, 129, 134, 5, 22, 12, 2, 130, 131, 7, 37, 2, 2, 131, 133, 7, 38, 2, 2, 132, 130, 3, 2, 2, 2, 133, 136, 3, 2, 2, 2, 134, 132, 3, 2, 2, 2, 134, 135, 3, 2, 2, 2, 135, 21, 3, 2, 2, 2, 136, 134, 3, 2, 2, 2, 137, 138, 7, 27, 2, 2, 138, 139, 5, 18, 10, 2, 139, 140, 7, 28, 2, 2, 140, 147, 3, 2, 2, 2, 141, 147, 5, 26, 14, 2, 142, 147, 5, 28, 15, 2, 143, 147, 5, 30, 16, 2, 144, 147, 5, 38, 20, 2, 145, 147, 5, 24, 13, 2, 146, 137, 3, 2, 2, 2, 146, 141, 3, 2, 2, 2, 146, 142, 3, 2, 2, 2, 146, 143, 3, 2, 2, 2, 146, 144, 3, 2, 2, 2, 146, 145, 3, 2, 2, 2, 147, 23, 3, 2, 2, 2, 148, 149, 5, 8, 5, 2, 149, 25, 3, 2, 2, 2, 150, 152, 7, 29, 2, 2, 151, 153, 5, 12, 7, 2, 152, 151, 3, 2, 2, 2, 152, 153, 3, 2, 2, 2, 153, 154, 3, 2, 2, 2, 154, 155, 7, 30, 2, 2, 155, 27, 3, 2, 2, 2, 156, 157, 9, 3, 2, 2, 157, 29, 3, 2, 2, 2, 158, 162, 5, 32, 17, 2, 159, 162, 5, 34, 18, 2, 160, 162, 5, 36, 19, 2, 161, 158, 3, 2, 2, 2, 161, 159, 3, 2, 2, 2, 161, 160, 3, 2, 2, 2, 162, 31, 3, 2, 2, 2, 163, 164, 9, 4, 2, 2, 164, 33, 3, 2, 2, 2, 165, 167, 7, 25, 2, 2, 166, 165, 3, 2, 2, 2, 166, 167, 3, 2, 2, 2, 167, 169, 3, 2, 2, 2, 168, 170, 7, 18, 2, 2, 169, 168, 3, 2, 2, 2, 170, 171, 3, 2, 2, 2, 171, 169, 3, 2, 2, 2, 171, 172, 3, 2, 2, 2, 172, 179, 3, 2, 2, 2, 173, 175, 7, 14, 2, 2, 174, 176, 7, 18, 2, 2, 175, 174, 3, 2, 2, 2, 176, 177, 3, 2, 2, 2, 177, 175, 3, 2, 2, 2, 177, 178, 3, 2, 2, 2, 178, 180, 3, 2, 2, 2, 179, 173, 3, 2, 2, 2, 179, 180, 3, 2, 2, 2, 180, 35, 3, 2, 2, 2, 181, 182, 9, 5, 2, 2, 182, 37, 3, 2, 2, 2, 183, 189, 5, 40, 21, 2, 184, 189, 5, 42, 22, 2, 185, 189, 5, 44, 23, 2, 186, 189, 5, 46, 24, 2, 187, 189, 5, 48, 25, 2, 188, 183, 3, 2, 2, 2, 188, 184, 3, 2, 2, 2, 188, 185, 3, 2, 2, 2, 188, 186, 3, 2, 2, 2, 188, 187, 3, 2, 2, 2, 189, 39, 3, 2, 2, 2, 190, 191, 7, 20, 2, 2, 191, 194, 7, 32, 2, 2, 192, 195, 5, 24, 13, 2, 193, 195, 5, 26, 14, 2, 194, 192, 3, 2, 2, 2, 194, 193, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 197, 7, 31, 2, 2, 197, 41, 3, 2, 2, 2, 198, 199, 7, 21, 2, 2, 199, 202, 7, 32, 2, 2, 200, 203, 5, 24, 13, 2, 201, 203, 5, 26, 14, 2, 202, 200, 3, 2, 2, 2, 202, 201, 3, 2, 2, 2, 203, 204, 3, 2, 2, 2, 204, 205, 7, 31, 2, 2, 205, 43, 3, 2, 2, 2, 206, 207, 7, 22, 2, 2, 207, 45, 3, 2, 2, 2, 208, 209, 7, 23, 2, 2, 209, 212, 7, 32, 2, 2, 210, 213, 5, 24, 13, 2, 211, 213, 5, 26, 14, 2, 212, 210, 3, 2, 2, 2, 212, 211, 3, 2, 2, 2, 213, 214, 3, 2, 2, 2, 214, 215, 7, 31, 2, 2, 215, 47, 3, 2, 2, 2, 216, 217, 7, 24, 2, 2, 217, 218, 7, 32, 2, 2, 218, 219, 7, 31, 2, 2, 219, 49, 3, 2, 2, 2, 25, 57, 63, 74, 81, 88, 92, 97, 102, 109, 116, 126, 134, 146, 152, 161, 166, 171, 177, 179, 188, 194, 202, 212] \ No newline at end of file diff --git a/antlr/Schema.tokens b/antlr/Schema.tokens index 2a46a5c..804a890 100644 --- a/antlr/Schema.tokens +++ b/antlr/Schema.tokens @@ -9,16 +9,61 @@ T__7=8 T__8=9 T__9=10 T__10=11 -IDENTIFIER=12 -WHITESPACE=13 +T__11=12 +IDENTIFIER=13 +NEWLINE=14 +COMMENT=15 +DIGIT=16 +WHITESPACE=17 +YORKIE_OBJECT=18 +YORKIE_ARRAY=19 +YORKIE_COUNTER=20 +YORKIE_TEXT=21 +YORKIE_TREE=22 +MINUS=23 +SEMICOLON=24 +LPAREN=25 +RPAREN=26 +LCURLY=27 +RCURLY=28 +GT=29 +LT=30 +PIPE=31 +QUESTION=32 +EQ=33 +COMMA=34 +LSQUARE=35 +RSQUARE=36 +DOUBLE_QUOTED_STRING=37 +SINGLE_QUOTED_STRING=38 'type'=1 -'{'=2 -'}'=3 -':'=4 -'[]'=5 -'('=6 -')'=7 -'|'=8 -'string'=9 -'number'=10 -'boolean'=11 +':'=2 +'string'=3 +'number'=4 +'boolean'=5 +'null'=6 +'bigint'=7 +'Uint8Array'=8 +'Date'=9 +'true'=10 +'false'=11 +'.'=12 +'yorkie.Object'=18 +'yorkie.Array'=19 +'yorkie.Counter'=20 +'yorkie.Text'=21 +'yorkie.Tree'=22 +'-'=23 +';'=24 +'('=25 +')'=26 +'{'=27 +'}'=28 +'>'=29 +'<'=30 +'|'=31 +'?'=32 +'='=33 +','=34 +'['=35 +']'=36 diff --git a/antlr/SchemaLexer.interp b/antlr/SchemaLexer.interp index 3031e76..f7afafc 100644 --- a/antlr/SchemaLexer.interp +++ b/antlr/SchemaLexer.interp @@ -1,16 +1,41 @@ token literal names: null 'type' -'{' -'}' ':' -'[]' -'(' -')' -'|' 'string' 'number' 'boolean' +'null' +'bigint' +'Uint8Array' +'Date' +'true' +'false' +'.' +null +null +null +null +null +'yorkie.Object' +'yorkie.Array' +'yorkie.Counter' +'yorkie.Text' +'yorkie.Tree' +'-' +';' +'(' +')' +'{' +'}' +'>' +'<' +'|' +'?' +'=' +',' +'[' +']' null null @@ -27,8 +52,33 @@ null null null null +null IDENTIFIER +NEWLINE +COMMENT +DIGIT WHITESPACE +YORKIE_OBJECT +YORKIE_ARRAY +YORKIE_COUNTER +YORKIE_TEXT +YORKIE_TREE +MINUS +SEMICOLON +LPAREN +RPAREN +LCURLY +RCURLY +GT +LT +PIPE +QUESTION +EQ +COMMA +LSQUARE +RSQUARE +DOUBLE_QUOTED_STRING +SINGLE_QUOTED_STRING rule names: T__0 @@ -42,8 +92,34 @@ T__7 T__8 T__9 T__10 +T__11 IDENTIFIER +NEWLINE +COMMENT +DIGIT WHITESPACE +YORKIE_OBJECT +YORKIE_ARRAY +YORKIE_COUNTER +YORKIE_TEXT +YORKIE_TREE +MINUS +SEMICOLON +LPAREN +RPAREN +LCURLY +RCURLY +GT +LT +PIPE +QUESTION +EQ +COMMA +LSQUARE +RSQUARE +DOUBLE_QUOTED_STRING +SINGLE_QUOTED_STRING +ESC channel names: DEFAULT_TOKEN_CHANNEL @@ -53,4 +129,4 @@ mode names: DEFAULT_MODE atn: -[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 2, 15, 85, 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, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 7, 13, 74, 10, 13, 12, 13, 14, 13, 77, 11, 13, 3, 14, 6, 14, 80, 10, 14, 13, 14, 14, 14, 81, 3, 14, 3, 14, 2, 2, 2, 15, 3, 2, 3, 5, 2, 4, 7, 2, 5, 9, 2, 6, 11, 2, 7, 13, 2, 8, 15, 2, 9, 17, 2, 10, 19, 2, 11, 21, 2, 12, 23, 2, 13, 25, 2, 14, 27, 2, 15, 3, 2, 5, 5, 2, 67, 92, 97, 97, 99, 124, 6, 2, 50, 59, 67, 92, 97, 97, 99, 124, 5, 2, 11, 12, 15, 15, 34, 34, 2, 86, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 3, 29, 3, 2, 2, 2, 5, 34, 3, 2, 2, 2, 7, 36, 3, 2, 2, 2, 9, 38, 3, 2, 2, 2, 11, 40, 3, 2, 2, 2, 13, 43, 3, 2, 2, 2, 15, 45, 3, 2, 2, 2, 17, 47, 3, 2, 2, 2, 19, 49, 3, 2, 2, 2, 21, 56, 3, 2, 2, 2, 23, 63, 3, 2, 2, 2, 25, 71, 3, 2, 2, 2, 27, 79, 3, 2, 2, 2, 29, 30, 7, 118, 2, 2, 30, 31, 7, 123, 2, 2, 31, 32, 7, 114, 2, 2, 32, 33, 7, 103, 2, 2, 33, 4, 3, 2, 2, 2, 34, 35, 7, 125, 2, 2, 35, 6, 3, 2, 2, 2, 36, 37, 7, 127, 2, 2, 37, 8, 3, 2, 2, 2, 38, 39, 7, 60, 2, 2, 39, 10, 3, 2, 2, 2, 40, 41, 7, 93, 2, 2, 41, 42, 7, 95, 2, 2, 42, 12, 3, 2, 2, 2, 43, 44, 7, 42, 2, 2, 44, 14, 3, 2, 2, 2, 45, 46, 7, 43, 2, 2, 46, 16, 3, 2, 2, 2, 47, 48, 7, 126, 2, 2, 48, 18, 3, 2, 2, 2, 49, 50, 7, 117, 2, 2, 50, 51, 7, 118, 2, 2, 51, 52, 7, 116, 2, 2, 52, 53, 7, 107, 2, 2, 53, 54, 7, 112, 2, 2, 54, 55, 7, 105, 2, 2, 55, 20, 3, 2, 2, 2, 56, 57, 7, 112, 2, 2, 57, 58, 7, 119, 2, 2, 58, 59, 7, 111, 2, 2, 59, 60, 7, 100, 2, 2, 60, 61, 7, 103, 2, 2, 61, 62, 7, 116, 2, 2, 62, 22, 3, 2, 2, 2, 63, 64, 7, 100, 2, 2, 64, 65, 7, 113, 2, 2, 65, 66, 7, 113, 2, 2, 66, 67, 7, 110, 2, 2, 67, 68, 7, 103, 2, 2, 68, 69, 7, 99, 2, 2, 69, 70, 7, 112, 2, 2, 70, 24, 3, 2, 2, 2, 71, 75, 9, 2, 2, 2, 72, 74, 9, 3, 2, 2, 73, 72, 3, 2, 2, 2, 74, 77, 3, 2, 2, 2, 75, 73, 3, 2, 2, 2, 75, 76, 3, 2, 2, 2, 76, 26, 3, 2, 2, 2, 77, 75, 3, 2, 2, 2, 78, 80, 9, 4, 2, 2, 79, 78, 3, 2, 2, 2, 80, 81, 3, 2, 2, 2, 81, 79, 3, 2, 2, 2, 81, 82, 3, 2, 2, 2, 82, 83, 3, 2, 2, 2, 83, 84, 8, 14, 2, 2, 84, 28, 3, 2, 2, 2, 5, 2, 75, 81, 3, 8, 2, 2] \ No newline at end of file +[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 2, 40, 304, 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, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 7, 14, 154, 10, 14, 12, 14, 14, 14, 157, 11, 14, 3, 15, 5, 15, 160, 10, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 5, 16, 169, 10, 16, 3, 16, 7, 16, 172, 10, 16, 12, 16, 14, 16, 175, 11, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 6, 18, 182, 10, 18, 13, 18, 14, 18, 183, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 27, 3, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 30, 3, 30, 3, 31, 3, 31, 3, 32, 3, 32, 3, 33, 3, 33, 3, 34, 3, 34, 3, 35, 3, 35, 3, 36, 3, 36, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 7, 38, 285, 10, 38, 12, 38, 14, 38, 288, 11, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 39, 7, 39, 295, 10, 39, 12, 39, 14, 39, 298, 11, 39, 3, 39, 3, 39, 3, 40, 3, 40, 3, 40, 2, 2, 2, 41, 3, 2, 3, 5, 2, 4, 7, 2, 5, 9, 2, 6, 11, 2, 7, 13, 2, 8, 15, 2, 9, 17, 2, 10, 19, 2, 11, 21, 2, 12, 23, 2, 13, 25, 2, 14, 27, 2, 15, 29, 2, 16, 31, 2, 17, 33, 2, 18, 35, 2, 19, 37, 2, 20, 39, 2, 21, 41, 2, 22, 43, 2, 23, 45, 2, 24, 47, 2, 25, 49, 2, 26, 51, 2, 27, 53, 2, 28, 55, 2, 29, 57, 2, 30, 59, 2, 31, 61, 2, 32, 63, 2, 33, 65, 2, 34, 67, 2, 35, 69, 2, 36, 71, 2, 37, 73, 2, 38, 75, 2, 39, 77, 2, 40, 79, 2, 2, 3, 2, 10, 5, 2, 67, 92, 97, 97, 99, 124, 6, 2, 50, 59, 67, 92, 97, 97, 99, 124, 4, 2, 12, 12, 15, 15, 3, 2, 50, 59, 5, 2, 11, 12, 15, 15, 34, 34, 4, 2, 12, 12, 36, 36, 4, 2, 12, 12, 41, 41, 9, 2, 36, 36, 41, 41, 94, 94, 100, 100, 112, 112, 116, 116, 118, 118, 2, 311, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 3, 81, 3, 2, 2, 2, 5, 86, 3, 2, 2, 2, 7, 88, 3, 2, 2, 2, 9, 95, 3, 2, 2, 2, 11, 102, 3, 2, 2, 2, 13, 110, 3, 2, 2, 2, 15, 115, 3, 2, 2, 2, 17, 122, 3, 2, 2, 2, 19, 133, 3, 2, 2, 2, 21, 138, 3, 2, 2, 2, 23, 143, 3, 2, 2, 2, 25, 149, 3, 2, 2, 2, 27, 151, 3, 2, 2, 2, 29, 159, 3, 2, 2, 2, 31, 168, 3, 2, 2, 2, 33, 178, 3, 2, 2, 2, 35, 181, 3, 2, 2, 2, 37, 187, 3, 2, 2, 2, 39, 201, 3, 2, 2, 2, 41, 214, 3, 2, 2, 2, 43, 229, 3, 2, 2, 2, 45, 241, 3, 2, 2, 2, 47, 253, 3, 2, 2, 2, 49, 255, 3, 2, 2, 2, 51, 257, 3, 2, 2, 2, 53, 259, 3, 2, 2, 2, 55, 261, 3, 2, 2, 2, 57, 263, 3, 2, 2, 2, 59, 265, 3, 2, 2, 2, 61, 267, 3, 2, 2, 2, 63, 269, 3, 2, 2, 2, 65, 271, 3, 2, 2, 2, 67, 273, 3, 2, 2, 2, 69, 275, 3, 2, 2, 2, 71, 277, 3, 2, 2, 2, 73, 279, 3, 2, 2, 2, 75, 281, 3, 2, 2, 2, 77, 291, 3, 2, 2, 2, 79, 301, 3, 2, 2, 2, 81, 82, 7, 118, 2, 2, 82, 83, 7, 123, 2, 2, 83, 84, 7, 114, 2, 2, 84, 85, 7, 103, 2, 2, 85, 4, 3, 2, 2, 2, 86, 87, 7, 60, 2, 2, 87, 6, 3, 2, 2, 2, 88, 89, 7, 117, 2, 2, 89, 90, 7, 118, 2, 2, 90, 91, 7, 116, 2, 2, 91, 92, 7, 107, 2, 2, 92, 93, 7, 112, 2, 2, 93, 94, 7, 105, 2, 2, 94, 8, 3, 2, 2, 2, 95, 96, 7, 112, 2, 2, 96, 97, 7, 119, 2, 2, 97, 98, 7, 111, 2, 2, 98, 99, 7, 100, 2, 2, 99, 100, 7, 103, 2, 2, 100, 101, 7, 116, 2, 2, 101, 10, 3, 2, 2, 2, 102, 103, 7, 100, 2, 2, 103, 104, 7, 113, 2, 2, 104, 105, 7, 113, 2, 2, 105, 106, 7, 110, 2, 2, 106, 107, 7, 103, 2, 2, 107, 108, 7, 99, 2, 2, 108, 109, 7, 112, 2, 2, 109, 12, 3, 2, 2, 2, 110, 111, 7, 112, 2, 2, 111, 112, 7, 119, 2, 2, 112, 113, 7, 110, 2, 2, 113, 114, 7, 110, 2, 2, 114, 14, 3, 2, 2, 2, 115, 116, 7, 100, 2, 2, 116, 117, 7, 107, 2, 2, 117, 118, 7, 105, 2, 2, 118, 119, 7, 107, 2, 2, 119, 120, 7, 112, 2, 2, 120, 121, 7, 118, 2, 2, 121, 16, 3, 2, 2, 2, 122, 123, 7, 87, 2, 2, 123, 124, 7, 107, 2, 2, 124, 125, 7, 112, 2, 2, 125, 126, 7, 118, 2, 2, 126, 127, 7, 58, 2, 2, 127, 128, 7, 67, 2, 2, 128, 129, 7, 116, 2, 2, 129, 130, 7, 116, 2, 2, 130, 131, 7, 99, 2, 2, 131, 132, 7, 123, 2, 2, 132, 18, 3, 2, 2, 2, 133, 134, 7, 70, 2, 2, 134, 135, 7, 99, 2, 2, 135, 136, 7, 118, 2, 2, 136, 137, 7, 103, 2, 2, 137, 20, 3, 2, 2, 2, 138, 139, 7, 118, 2, 2, 139, 140, 7, 116, 2, 2, 140, 141, 7, 119, 2, 2, 141, 142, 7, 103, 2, 2, 142, 22, 3, 2, 2, 2, 143, 144, 7, 104, 2, 2, 144, 145, 7, 99, 2, 2, 145, 146, 7, 110, 2, 2, 146, 147, 7, 117, 2, 2, 147, 148, 7, 103, 2, 2, 148, 24, 3, 2, 2, 2, 149, 150, 7, 48, 2, 2, 150, 26, 3, 2, 2, 2, 151, 155, 9, 2, 2, 2, 152, 154, 9, 3, 2, 2, 153, 152, 3, 2, 2, 2, 154, 157, 3, 2, 2, 2, 155, 153, 3, 2, 2, 2, 155, 156, 3, 2, 2, 2, 156, 28, 3, 2, 2, 2, 157, 155, 3, 2, 2, 2, 158, 160, 7, 15, 2, 2, 159, 158, 3, 2, 2, 2, 159, 160, 3, 2, 2, 2, 160, 161, 3, 2, 2, 2, 161, 162, 7, 12, 2, 2, 162, 163, 3, 2, 2, 2, 163, 164, 8, 15, 2, 2, 164, 30, 3, 2, 2, 2, 165, 166, 7, 49, 2, 2, 166, 169, 7, 49, 2, 2, 167, 169, 7, 37, 2, 2, 168, 165, 3, 2, 2, 2, 168, 167, 3, 2, 2, 2, 169, 173, 3, 2, 2, 2, 170, 172, 10, 4, 2, 2, 171, 170, 3, 2, 2, 2, 172, 175, 3, 2, 2, 2, 173, 171, 3, 2, 2, 2, 173, 174, 3, 2, 2, 2, 174, 176, 3, 2, 2, 2, 175, 173, 3, 2, 2, 2, 176, 177, 8, 16, 2, 2, 177, 32, 3, 2, 2, 2, 178, 179, 9, 5, 2, 2, 179, 34, 3, 2, 2, 2, 180, 182, 9, 6, 2, 2, 181, 180, 3, 2, 2, 2, 182, 183, 3, 2, 2, 2, 183, 181, 3, 2, 2, 2, 183, 184, 3, 2, 2, 2, 184, 185, 3, 2, 2, 2, 185, 186, 8, 18, 2, 2, 186, 36, 3, 2, 2, 2, 187, 188, 7, 123, 2, 2, 188, 189, 7, 113, 2, 2, 189, 190, 7, 116, 2, 2, 190, 191, 7, 109, 2, 2, 191, 192, 7, 107, 2, 2, 192, 193, 7, 103, 2, 2, 193, 194, 7, 48, 2, 2, 194, 195, 7, 81, 2, 2, 195, 196, 7, 100, 2, 2, 196, 197, 7, 108, 2, 2, 197, 198, 7, 103, 2, 2, 198, 199, 7, 101, 2, 2, 199, 200, 7, 118, 2, 2, 200, 38, 3, 2, 2, 2, 201, 202, 7, 123, 2, 2, 202, 203, 7, 113, 2, 2, 203, 204, 7, 116, 2, 2, 204, 205, 7, 109, 2, 2, 205, 206, 7, 107, 2, 2, 206, 207, 7, 103, 2, 2, 207, 208, 7, 48, 2, 2, 208, 209, 7, 67, 2, 2, 209, 210, 7, 116, 2, 2, 210, 211, 7, 116, 2, 2, 211, 212, 7, 99, 2, 2, 212, 213, 7, 123, 2, 2, 213, 40, 3, 2, 2, 2, 214, 215, 7, 123, 2, 2, 215, 216, 7, 113, 2, 2, 216, 217, 7, 116, 2, 2, 217, 218, 7, 109, 2, 2, 218, 219, 7, 107, 2, 2, 219, 220, 7, 103, 2, 2, 220, 221, 7, 48, 2, 2, 221, 222, 7, 69, 2, 2, 222, 223, 7, 113, 2, 2, 223, 224, 7, 119, 2, 2, 224, 225, 7, 112, 2, 2, 225, 226, 7, 118, 2, 2, 226, 227, 7, 103, 2, 2, 227, 228, 7, 116, 2, 2, 228, 42, 3, 2, 2, 2, 229, 230, 7, 123, 2, 2, 230, 231, 7, 113, 2, 2, 231, 232, 7, 116, 2, 2, 232, 233, 7, 109, 2, 2, 233, 234, 7, 107, 2, 2, 234, 235, 7, 103, 2, 2, 235, 236, 7, 48, 2, 2, 236, 237, 7, 86, 2, 2, 237, 238, 7, 103, 2, 2, 238, 239, 7, 122, 2, 2, 239, 240, 7, 118, 2, 2, 240, 44, 3, 2, 2, 2, 241, 242, 7, 123, 2, 2, 242, 243, 7, 113, 2, 2, 243, 244, 7, 116, 2, 2, 244, 245, 7, 109, 2, 2, 245, 246, 7, 107, 2, 2, 246, 247, 7, 103, 2, 2, 247, 248, 7, 48, 2, 2, 248, 249, 7, 86, 2, 2, 249, 250, 7, 116, 2, 2, 250, 251, 7, 103, 2, 2, 251, 252, 7, 103, 2, 2, 252, 46, 3, 2, 2, 2, 253, 254, 7, 47, 2, 2, 254, 48, 3, 2, 2, 2, 255, 256, 7, 61, 2, 2, 256, 50, 3, 2, 2, 2, 257, 258, 7, 42, 2, 2, 258, 52, 3, 2, 2, 2, 259, 260, 7, 43, 2, 2, 260, 54, 3, 2, 2, 2, 261, 262, 7, 125, 2, 2, 262, 56, 3, 2, 2, 2, 263, 264, 7, 127, 2, 2, 264, 58, 3, 2, 2, 2, 265, 266, 7, 64, 2, 2, 266, 60, 3, 2, 2, 2, 267, 268, 7, 62, 2, 2, 268, 62, 3, 2, 2, 2, 269, 270, 7, 126, 2, 2, 270, 64, 3, 2, 2, 2, 271, 272, 7, 65, 2, 2, 272, 66, 3, 2, 2, 2, 273, 274, 7, 63, 2, 2, 274, 68, 3, 2, 2, 2, 275, 276, 7, 46, 2, 2, 276, 70, 3, 2, 2, 2, 277, 278, 7, 93, 2, 2, 278, 72, 3, 2, 2, 2, 279, 280, 7, 95, 2, 2, 280, 74, 3, 2, 2, 2, 281, 286, 7, 36, 2, 2, 282, 285, 5, 79, 40, 2, 283, 285, 10, 7, 2, 2, 284, 282, 3, 2, 2, 2, 284, 283, 3, 2, 2, 2, 285, 288, 3, 2, 2, 2, 286, 284, 3, 2, 2, 2, 286, 287, 3, 2, 2, 2, 287, 289, 3, 2, 2, 2, 288, 286, 3, 2, 2, 2, 289, 290, 7, 36, 2, 2, 290, 76, 3, 2, 2, 2, 291, 296, 7, 41, 2, 2, 292, 295, 5, 79, 40, 2, 293, 295, 10, 8, 2, 2, 294, 292, 3, 2, 2, 2, 294, 293, 3, 2, 2, 2, 295, 298, 3, 2, 2, 2, 296, 294, 3, 2, 2, 2, 296, 297, 3, 2, 2, 2, 297, 299, 3, 2, 2, 2, 298, 296, 3, 2, 2, 2, 299, 300, 7, 41, 2, 2, 300, 78, 3, 2, 2, 2, 301, 302, 7, 94, 2, 2, 302, 303, 9, 9, 2, 2, 303, 80, 3, 2, 2, 2, 12, 2, 155, 159, 168, 173, 183, 284, 286, 294, 296, 3, 8, 2, 2] \ No newline at end of file diff --git a/antlr/SchemaLexer.tokens b/antlr/SchemaLexer.tokens index 2a46a5c..804a890 100644 --- a/antlr/SchemaLexer.tokens +++ b/antlr/SchemaLexer.tokens @@ -9,16 +9,61 @@ T__7=8 T__8=9 T__9=10 T__10=11 -IDENTIFIER=12 -WHITESPACE=13 +T__11=12 +IDENTIFIER=13 +NEWLINE=14 +COMMENT=15 +DIGIT=16 +WHITESPACE=17 +YORKIE_OBJECT=18 +YORKIE_ARRAY=19 +YORKIE_COUNTER=20 +YORKIE_TEXT=21 +YORKIE_TREE=22 +MINUS=23 +SEMICOLON=24 +LPAREN=25 +RPAREN=26 +LCURLY=27 +RCURLY=28 +GT=29 +LT=30 +PIPE=31 +QUESTION=32 +EQ=33 +COMMA=34 +LSQUARE=35 +RSQUARE=36 +DOUBLE_QUOTED_STRING=37 +SINGLE_QUOTED_STRING=38 'type'=1 -'{'=2 -'}'=3 -':'=4 -'[]'=5 -'('=6 -')'=7 -'|'=8 -'string'=9 -'number'=10 -'boolean'=11 +':'=2 +'string'=3 +'number'=4 +'boolean'=5 +'null'=6 +'bigint'=7 +'Uint8Array'=8 +'Date'=9 +'true'=10 +'false'=11 +'.'=12 +'yorkie.Object'=18 +'yorkie.Array'=19 +'yorkie.Counter'=20 +'yorkie.Text'=21 +'yorkie.Tree'=22 +'-'=23 +';'=24 +'('=25 +')'=26 +'{'=27 +'}'=28 +'>'=29 +'<'=30 +'|'=31 +'?'=32 +'='=33 +','=34 +'['=35 +']'=36 diff --git a/antlr/SchemaLexer.ts b/antlr/SchemaLexer.ts index 699dbeb..c4e3056 100644 --- a/antlr/SchemaLexer.ts +++ b/antlr/SchemaLexer.ts @@ -27,8 +27,33 @@ export class SchemaLexer extends Lexer { public static readonly T__8 = 9; public static readonly T__9 = 10; public static readonly T__10 = 11; - public static readonly IDENTIFIER = 12; - public static readonly WHITESPACE = 13; + public static readonly T__11 = 12; + public static readonly IDENTIFIER = 13; + public static readonly NEWLINE = 14; + public static readonly COMMENT = 15; + public static readonly DIGIT = 16; + public static readonly WHITESPACE = 17; + public static readonly YORKIE_OBJECT = 18; + public static readonly YORKIE_ARRAY = 19; + public static readonly YORKIE_COUNTER = 20; + public static readonly YORKIE_TEXT = 21; + public static readonly YORKIE_TREE = 22; + public static readonly MINUS = 23; + public static readonly SEMICOLON = 24; + public static readonly LPAREN = 25; + public static readonly RPAREN = 26; + public static readonly LCURLY = 27; + public static readonly RCURLY = 28; + public static readonly GT = 29; + public static readonly LT = 30; + public static readonly PIPE = 31; + public static readonly QUESTION = 32; + public static readonly EQ = 33; + public static readonly COMMA = 34; + public static readonly LSQUARE = 35; + public static readonly RSQUARE = 36; + public static readonly DOUBLE_QUOTED_STRING = 37; + public static readonly SINGLE_QUOTED_STRING = 38; // tslint:disable:no-trailing-whitespace public static readonly channelNames: string[] = [ @@ -42,16 +67,28 @@ export class SchemaLexer extends Lexer { 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", "IDENTIFIER", "WHITESPACE", + "T__9", "T__10", "T__11", "IDENTIFIER", "NEWLINE", "COMMENT", "DIGIT", + "WHITESPACE", "YORKIE_OBJECT", "YORKIE_ARRAY", "YORKIE_COUNTER", "YORKIE_TEXT", + "YORKIE_TREE", "MINUS", "SEMICOLON", "LPAREN", "RPAREN", "LCURLY", "RCURLY", + "GT", "LT", "PIPE", "QUESTION", "EQ", "COMMA", "LSQUARE", "RSQUARE", "DOUBLE_QUOTED_STRING", + "SINGLE_QUOTED_STRING", "ESC", ]; private static readonly _LITERAL_NAMES: Array = [ - undefined, "'type'", "'{'", "'}'", "':'", "'[]'", "'('", "')'", "'|'", - "'string'", "'number'", "'boolean'", + undefined, "'type'", "':'", "'string'", "'number'", "'boolean'", "'null'", + "'bigint'", "'Uint8Array'", "'Date'", "'true'", "'false'", "'.'", undefined, + undefined, undefined, undefined, undefined, "'yorkie.Object'", "'yorkie.Array'", + "'yorkie.Counter'", "'yorkie.Text'", "'yorkie.Tree'", "'-'", "';'", "'('", + "')'", "'{'", "'}'", "'>'", "'<'", "'|'", "'?'", "'='", "','", "'['", + "']'", ]; private static readonly _SYMBOLIC_NAMES: Array = [ undefined, undefined, undefined, undefined, undefined, undefined, undefined, - undefined, undefined, undefined, undefined, undefined, "IDENTIFIER", "WHITESPACE", + undefined, undefined, undefined, undefined, undefined, undefined, "IDENTIFIER", + "NEWLINE", "COMMENT", "DIGIT", "WHITESPACE", "YORKIE_OBJECT", "YORKIE_ARRAY", + "YORKIE_COUNTER", "YORKIE_TEXT", "YORKIE_TREE", "MINUS", "SEMICOLON", + "LPAREN", "RPAREN", "LCURLY", "RCURLY", "GT", "LT", "PIPE", "QUESTION", + "EQ", "COMMA", "LSQUARE", "RSQUARE", "DOUBLE_QUOTED_STRING", "SINGLE_QUOTED_STRING", ]; public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(SchemaLexer._LITERAL_NAMES, SchemaLexer._SYMBOLIC_NAMES, []); @@ -84,41 +121,139 @@ export class SchemaLexer extends Lexer { public get modeNames(): string[] { return SchemaLexer.modeNames; } public static readonly _serializedATN: string = - "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x02\x0FU\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\x03\x02\x03\x02\x03\x02\x03\x02\x03\x02\x03\x03\x03\x03" + - "\x03\x04\x03\x04\x03\x05\x03\x05\x03\x06\x03\x06\x03\x06\x03\x07\x03\x07" + - "\x03\b\x03\b\x03\t\x03\t\x03\n\x03\n\x03\n\x03\n\x03\n\x03\n\x03\n\x03" + - "\v\x03\v\x03\v\x03\v\x03\v\x03\v\x03\v\x03\f\x03\f\x03\f\x03\f\x03\f\x03" + - "\f\x03\f\x03\f\x03\r\x03\r\x07\rJ\n\r\f\r\x0E\rM\v\r\x03\x0E\x06\x0EP" + - "\n\x0E\r\x0E\x0E\x0EQ\x03\x0E\x03\x0E\x02\x02\x02\x0F\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\x03\x02\x05\x05\x02" + - "C\\aac|\x06\x022;C\\aac|\x05\x02\v\f\x0F\x0F\"\"\x02V\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\x03\x1D\x03\x02\x02\x02\x05\"\x03\x02\x02\x02\x07$\x03\x02\x02\x02" + - "\t&\x03\x02\x02\x02\v(\x03\x02\x02\x02\r+\x03\x02\x02\x02\x0F-\x03\x02" + - "\x02\x02\x11/\x03\x02\x02\x02\x131\x03\x02\x02\x02\x158\x03\x02\x02\x02" + - "\x17?\x03\x02\x02\x02\x19G\x03\x02\x02\x02\x1BO\x03\x02\x02\x02\x1D\x1E" + - "\x07v\x02\x02\x1E\x1F\x07{\x02\x02\x1F \x07r\x02\x02 !\x07g\x02\x02!\x04" + - "\x03\x02\x02\x02\"#\x07}\x02\x02#\x06\x03\x02\x02\x02$%\x07\x7F\x02\x02" + - "%\b\x03\x02\x02\x02&\'\x07<\x02\x02\'\n\x03\x02\x02\x02()\x07]\x02\x02" + - ")*\x07_\x02\x02*\f\x03\x02\x02\x02+,\x07*\x02\x02,\x0E\x03\x02\x02\x02" + - "-.\x07+\x02\x02.\x10\x03\x02\x02\x02/0\x07~\x02\x020\x12\x03\x02\x02\x02" + - "12\x07u\x02\x0223\x07v\x02\x0234\x07t\x02\x0245\x07k\x02\x0256\x07p\x02" + - "\x0267\x07i\x02\x027\x14\x03\x02\x02\x0289\x07p\x02\x029:\x07w\x02\x02" + - ":;\x07o\x02\x02;<\x07d\x02\x02<=\x07g\x02\x02=>\x07t\x02\x02>\x16\x03" + - "\x02\x02\x02?@\x07d\x02\x02@A\x07q\x02\x02AB\x07q\x02\x02BC\x07n\x02\x02" + - "CD\x07g\x02\x02DE\x07c\x02\x02EF\x07p\x02\x02F\x18\x03\x02\x02\x02GK\t" + - "\x02\x02\x02HJ\t\x03\x02\x02IH\x03\x02\x02\x02JM\x03\x02\x02\x02KI\x03" + - "\x02\x02\x02KL\x03\x02\x02\x02L\x1A\x03\x02\x02\x02MK\x03\x02\x02\x02" + - "NP\t\x04\x02\x02ON\x03\x02\x02\x02PQ\x03\x02\x02\x02QO\x03\x02\x02\x02" + - "QR\x03\x02\x02\x02RS\x03\x02\x02\x02ST\b\x0E\x02\x02T\x1C\x03\x02\x02" + - "\x02\x05\x02KQ\x03\b\x02\x02"; + "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x02(\u0130\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\x04\x1C\t" + + "\x1C\x04\x1D\t\x1D\x04\x1E\t\x1E\x04\x1F\t\x1F\x04 \t \x04!\t!\x04\"\t" + + "\"\x04#\t#\x04$\t$\x04%\t%\x04&\t&\x04\'\t\'\x04(\t(\x03\x02\x03\x02\x03" + + "\x02\x03\x02\x03\x02\x03\x03\x03\x03\x03\x04\x03\x04\x03\x04\x03\x04\x03" + + "\x04\x03\x04\x03\x04\x03\x05\x03\x05\x03\x05\x03\x05\x03\x05\x03\x05\x03" + + "\x05\x03\x06\x03\x06\x03\x06\x03\x06\x03\x06\x03\x06\x03\x06\x03\x06\x03" + + "\x07\x03\x07\x03\x07\x03\x07\x03\x07\x03\b\x03\b\x03\b\x03\b\x03\b\x03" + + "\b\x03\b\x03\t\x03\t\x03\t\x03\t\x03\t\x03\t\x03\t\x03\t\x03\t\x03\t\x03" + + "\t\x03\n\x03\n\x03\n\x03\n\x03\n\x03\v\x03\v\x03\v\x03\v\x03\v\x03\f\x03" + + "\f\x03\f\x03\f\x03\f\x03\f\x03\r\x03\r\x03\x0E\x03\x0E\x07\x0E\x9A\n\x0E" + + "\f\x0E\x0E\x0E\x9D\v\x0E\x03\x0F\x05\x0F\xA0\n\x0F\x03\x0F\x03\x0F\x03" + + "\x0F\x03\x0F\x03\x10\x03\x10\x03\x10\x05\x10\xA9\n\x10\x03\x10\x07\x10" + + "\xAC\n\x10\f\x10\x0E\x10\xAF\v\x10\x03\x10\x03\x10\x03\x11\x03\x11\x03" + + "\x12\x06\x12\xB6\n\x12\r\x12\x0E\x12\xB7\x03\x12\x03\x12\x03\x13\x03\x13" + + "\x03\x13\x03\x13\x03\x13\x03\x13\x03\x13\x03\x13\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\x14\x03\x14\x03\x14\x03\x14\x03\x14\x03\x14\x03\x15\x03\x15" + + "\x03\x15\x03\x15\x03\x15\x03\x15\x03\x15\x03\x15\x03\x15\x03\x15\x03\x15" + + "\x03\x15\x03\x15\x03\x15\x03\x15\x03\x16\x03\x16\x03\x16\x03\x16\x03\x16" + + "\x03\x16\x03\x16\x03\x16\x03\x16\x03\x16\x03\x16\x03\x16\x03\x17\x03\x17" + + "\x03\x17\x03\x17\x03\x17\x03\x17\x03\x17\x03\x17\x03\x17\x03\x17\x03\x17" + + "\x03\x17\x03\x18\x03\x18\x03\x19\x03\x19\x03\x1A\x03\x1A\x03\x1B\x03\x1B" + + "\x03\x1C\x03\x1C\x03\x1D\x03\x1D\x03\x1E\x03\x1E\x03\x1F\x03\x1F\x03 " + + "\x03 \x03!\x03!\x03\"\x03\"\x03#\x03#\x03$\x03$\x03%\x03%\x03&\x03&\x03" + + "&\x07&\u011D\n&\f&\x0E&\u0120\v&\x03&\x03&\x03\'\x03\'\x03\'\x07\'\u0127" + + "\n\'\f\'\x0E\'\u012A\v\'\x03\'\x03\'\x03(\x03(\x03(\x02\x02\x02)\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\x12#\x02\x13%\x02\x14\'\x02\x15)\x02\x16+\x02\x17-\x02" + + "\x18/\x02\x191\x02\x1A3\x02\x1B5\x02\x1C7\x02\x1D9\x02\x1E;\x02\x1F=\x02" + + " ?\x02!A\x02\"C\x02#E\x02$G\x02%I\x02&K\x02\'M\x02(O\x02\x02\x03\x02\n" + + "\x05\x02C\\aac|\x06\x022;C\\aac|\x04\x02\f\f\x0F\x0F\x03\x022;\x05\x02" + + "\v\f\x0F\x0F\"\"\x04\x02\f\f$$\x04\x02\f\f))\t\x02$$))^^ddppttvv\x02\u0137" + + "\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\x02\'\x03" + + "\x02\x02\x02\x02)\x03\x02\x02\x02\x02+\x03\x02\x02\x02\x02-\x03\x02\x02" + + "\x02\x02/\x03\x02\x02\x02\x021\x03\x02\x02\x02\x023\x03\x02\x02\x02\x02" + + "5\x03\x02\x02\x02\x027\x03\x02\x02\x02\x029\x03\x02\x02\x02\x02;\x03\x02" + + "\x02\x02\x02=\x03\x02\x02\x02\x02?\x03\x02\x02\x02\x02A\x03\x02\x02\x02" + + "\x02C\x03\x02\x02\x02\x02E\x03\x02\x02\x02\x02G\x03\x02\x02\x02\x02I\x03" + + "\x02\x02\x02\x02K\x03\x02\x02\x02\x02M\x03\x02\x02\x02\x03Q\x03\x02\x02" + + "\x02\x05V\x03\x02\x02\x02\x07X\x03\x02\x02\x02\t_\x03\x02\x02\x02\vf\x03" + + "\x02\x02\x02\rn\x03\x02\x02\x02\x0Fs\x03\x02\x02\x02\x11z\x03\x02\x02" + + "\x02\x13\x85\x03\x02\x02\x02\x15\x8A\x03\x02\x02\x02\x17\x8F\x03\x02\x02" + + "\x02\x19\x95\x03\x02\x02\x02\x1B\x97\x03\x02\x02\x02\x1D\x9F\x03\x02\x02" + + "\x02\x1F\xA8\x03\x02\x02\x02!\xB2\x03\x02\x02\x02#\xB5\x03\x02\x02\x02" + + "%\xBB\x03\x02\x02\x02\'\xC9\x03\x02\x02\x02)\xD6\x03\x02\x02\x02+\xE5" + + "\x03\x02\x02\x02-\xF1\x03\x02\x02\x02/\xFD\x03\x02\x02\x021\xFF\x03\x02" + + "\x02\x023\u0101\x03\x02\x02\x025\u0103\x03\x02\x02\x027\u0105\x03\x02" + + "\x02\x029\u0107\x03\x02\x02\x02;\u0109\x03\x02\x02\x02=\u010B\x03\x02" + + "\x02\x02?\u010D\x03\x02\x02\x02A\u010F\x03\x02\x02\x02C\u0111\x03\x02" + + "\x02\x02E\u0113\x03\x02\x02\x02G\u0115\x03\x02\x02\x02I\u0117\x03\x02" + + "\x02\x02K\u0119\x03\x02\x02\x02M\u0123\x03\x02\x02\x02O\u012D\x03\x02" + + "\x02\x02QR\x07v\x02\x02RS\x07{\x02\x02ST\x07r\x02\x02TU\x07g\x02\x02U" + + "\x04\x03\x02\x02\x02VW\x07<\x02\x02W\x06\x03\x02\x02\x02XY\x07u\x02\x02" + + "YZ\x07v\x02\x02Z[\x07t\x02\x02[\\\x07k\x02\x02\\]\x07p\x02\x02]^\x07i" + + "\x02\x02^\b\x03\x02\x02\x02_`\x07p\x02\x02`a\x07w\x02\x02ab\x07o\x02\x02" + + "bc\x07d\x02\x02cd\x07g\x02\x02de\x07t\x02\x02e\n\x03\x02\x02\x02fg\x07" + + "d\x02\x02gh\x07q\x02\x02hi\x07q\x02\x02ij\x07n\x02\x02jk\x07g\x02\x02" + + "kl\x07c\x02\x02lm\x07p\x02\x02m\f\x03\x02\x02\x02no\x07p\x02\x02op\x07" + + "w\x02\x02pq\x07n\x02\x02qr\x07n\x02\x02r\x0E\x03\x02\x02\x02st\x07d\x02" + + "\x02tu\x07k\x02\x02uv\x07i\x02\x02vw\x07k\x02\x02wx\x07p\x02\x02xy\x07" + + "v\x02\x02y\x10\x03\x02\x02\x02z{\x07W\x02\x02{|\x07k\x02\x02|}\x07p\x02" + + "\x02}~\x07v\x02\x02~\x7F\x07:\x02\x02\x7F\x80\x07C\x02\x02\x80\x81\x07" + + "t\x02\x02\x81\x82\x07t\x02\x02\x82\x83\x07c\x02\x02\x83\x84\x07{\x02\x02" + + "\x84\x12\x03\x02\x02\x02\x85\x86\x07F\x02\x02\x86\x87\x07c\x02\x02\x87" + + "\x88\x07v\x02\x02\x88\x89\x07g\x02\x02\x89\x14\x03\x02\x02\x02\x8A\x8B" + + "\x07v\x02\x02\x8B\x8C\x07t\x02\x02\x8C\x8D\x07w\x02\x02\x8D\x8E\x07g\x02" + + "\x02\x8E\x16\x03\x02\x02\x02\x8F\x90\x07h\x02\x02\x90\x91\x07c\x02\x02" + + "\x91\x92\x07n\x02\x02\x92\x93\x07u\x02\x02\x93\x94\x07g\x02\x02\x94\x18" + + "\x03\x02\x02\x02\x95\x96\x070\x02\x02\x96\x1A\x03\x02\x02\x02\x97\x9B" + + "\t\x02\x02\x02\x98\x9A\t\x03\x02\x02\x99\x98\x03\x02\x02\x02\x9A\x9D\x03" + + "\x02\x02\x02\x9B\x99\x03\x02\x02\x02\x9B\x9C\x03\x02\x02\x02\x9C\x1C\x03" + + "\x02\x02\x02\x9D\x9B\x03\x02\x02\x02\x9E\xA0\x07\x0F\x02\x02\x9F\x9E\x03" + + "\x02\x02\x02\x9F\xA0\x03\x02\x02\x02\xA0\xA1\x03\x02\x02\x02\xA1\xA2\x07" + + "\f\x02\x02\xA2\xA3\x03\x02\x02\x02\xA3\xA4\b\x0F\x02\x02\xA4\x1E\x03\x02" + + "\x02\x02\xA5\xA6\x071\x02\x02\xA6\xA9\x071\x02\x02\xA7\xA9\x07%\x02\x02" + + "\xA8\xA5\x03\x02\x02\x02\xA8\xA7\x03\x02\x02\x02\xA9\xAD\x03\x02\x02\x02" + + "\xAA\xAC\n\x04\x02\x02\xAB\xAA\x03\x02\x02\x02\xAC\xAF\x03\x02\x02\x02" + + "\xAD\xAB\x03\x02\x02\x02\xAD\xAE\x03\x02\x02\x02\xAE\xB0\x03\x02\x02\x02" + + "\xAF\xAD\x03\x02\x02\x02\xB0\xB1\b\x10\x02\x02\xB1 \x03\x02\x02\x02\xB2" + + "\xB3\t\x05\x02\x02\xB3\"\x03\x02\x02\x02\xB4\xB6\t\x06\x02\x02\xB5\xB4" + + "\x03\x02\x02\x02\xB6\xB7\x03\x02\x02\x02\xB7\xB5\x03\x02\x02\x02\xB7\xB8" + + "\x03\x02\x02\x02\xB8\xB9\x03\x02\x02\x02\xB9\xBA\b\x12\x02\x02\xBA$\x03" + + "\x02\x02\x02\xBB\xBC\x07{\x02\x02\xBC\xBD\x07q\x02\x02\xBD\xBE\x07t\x02" + + "\x02\xBE\xBF\x07m\x02\x02\xBF\xC0\x07k\x02\x02\xC0\xC1\x07g\x02\x02\xC1" + + "\xC2\x070\x02\x02\xC2\xC3\x07Q\x02\x02\xC3\xC4\x07d\x02\x02\xC4\xC5\x07" + + "l\x02\x02\xC5\xC6\x07g\x02\x02\xC6\xC7\x07e\x02\x02\xC7\xC8\x07v\x02\x02" + + "\xC8&\x03\x02\x02\x02\xC9\xCA\x07{\x02\x02\xCA\xCB\x07q\x02\x02\xCB\xCC" + + "\x07t\x02\x02\xCC\xCD\x07m\x02\x02\xCD\xCE\x07k\x02\x02\xCE\xCF\x07g\x02" + + "\x02\xCF\xD0\x070\x02\x02\xD0\xD1\x07C\x02\x02\xD1\xD2\x07t\x02\x02\xD2" + + "\xD3\x07t\x02\x02\xD3\xD4\x07c\x02\x02\xD4\xD5\x07{\x02\x02\xD5(\x03\x02" + + "\x02\x02\xD6\xD7\x07{\x02\x02\xD7\xD8\x07q\x02\x02\xD8\xD9\x07t\x02\x02" + + "\xD9\xDA\x07m\x02\x02\xDA\xDB\x07k\x02\x02\xDB\xDC\x07g\x02\x02\xDC\xDD" + + "\x070\x02\x02\xDD\xDE\x07E\x02\x02\xDE\xDF\x07q\x02\x02\xDF\xE0\x07w\x02" + + "\x02\xE0\xE1\x07p\x02\x02\xE1\xE2\x07v\x02\x02\xE2\xE3\x07g\x02\x02\xE3" + + "\xE4\x07t\x02\x02\xE4*\x03\x02\x02\x02\xE5\xE6\x07{\x02\x02\xE6\xE7\x07" + + "q\x02\x02\xE7\xE8\x07t\x02\x02\xE8\xE9\x07m\x02\x02\xE9\xEA\x07k\x02\x02" + + "\xEA\xEB\x07g\x02\x02\xEB\xEC\x070\x02\x02\xEC\xED\x07V\x02\x02\xED\xEE" + + "\x07g\x02\x02\xEE\xEF\x07z\x02\x02\xEF\xF0\x07v\x02\x02\xF0,\x03\x02\x02" + + "\x02\xF1\xF2\x07{\x02\x02\xF2\xF3\x07q\x02\x02\xF3\xF4\x07t\x02\x02\xF4" + + "\xF5\x07m\x02\x02\xF5\xF6\x07k\x02\x02\xF6\xF7\x07g\x02\x02\xF7\xF8\x07" + + "0\x02\x02\xF8\xF9\x07V\x02\x02\xF9\xFA\x07t\x02\x02\xFA\xFB\x07g\x02\x02" + + "\xFB\xFC\x07g\x02\x02\xFC.\x03\x02\x02\x02\xFD\xFE\x07/\x02\x02\xFE0\x03" + + "\x02\x02\x02\xFF\u0100\x07=\x02\x02\u01002\x03\x02\x02\x02\u0101\u0102" + + "\x07*\x02\x02\u01024\x03\x02\x02\x02\u0103\u0104\x07+\x02\x02\u01046\x03" + + "\x02\x02\x02\u0105\u0106\x07}\x02\x02\u01068\x03\x02\x02\x02\u0107\u0108" + + "\x07\x7F\x02\x02\u0108:\x03\x02\x02\x02\u0109\u010A\x07@\x02\x02\u010A" + + "<\x03\x02\x02\x02\u010B\u010C\x07>\x02\x02\u010C>\x03\x02\x02\x02\u010D" + + "\u010E\x07~\x02\x02\u010E@\x03\x02\x02\x02\u010F\u0110\x07A\x02\x02\u0110" + + "B\x03\x02\x02\x02\u0111\u0112\x07?\x02\x02\u0112D\x03\x02\x02\x02\u0113" + + "\u0114\x07.\x02\x02\u0114F\x03\x02\x02\x02\u0115\u0116\x07]\x02\x02\u0116" + + "H\x03\x02\x02\x02\u0117\u0118\x07_\x02\x02\u0118J\x03\x02\x02\x02\u0119" + + "\u011E\x07$\x02\x02\u011A\u011D\x05O(\x02\u011B\u011D\n\x07\x02\x02\u011C" + + "\u011A\x03\x02\x02\x02\u011C\u011B\x03\x02\x02\x02\u011D\u0120\x03\x02" + + "\x02\x02\u011E\u011C\x03\x02\x02\x02\u011E\u011F\x03\x02\x02\x02\u011F" + + "\u0121\x03\x02\x02\x02\u0120\u011E\x03\x02\x02\x02\u0121\u0122\x07$\x02" + + "\x02\u0122L\x03\x02\x02\x02\u0123\u0128\x07)\x02\x02\u0124\u0127\x05O" + + "(\x02\u0125\u0127\n\b\x02\x02\u0126\u0124\x03\x02\x02\x02\u0126\u0125" + + "\x03\x02\x02\x02\u0127\u012A\x03\x02\x02\x02\u0128\u0126\x03\x02\x02\x02" + + "\u0128\u0129\x03\x02\x02\x02\u0129\u012B\x03\x02\x02\x02\u012A\u0128\x03" + + "\x02\x02\x02\u012B\u012C\x07)\x02\x02\u012CN\x03\x02\x02\x02\u012D\u012E" + + "\x07^\x02\x02\u012E\u012F\t\t\x02\x02\u012FP\x03\x02\x02\x02\f\x02\x9B" + + "\x9F\xA8\xAD\xB7\u011C\u011E\u0126\u0128\x03\b\x02\x02"; public static __ATN: ATN; public static get _ATN(): ATN { if (!SchemaLexer.__ATN) { diff --git a/antlr/SchemaListener.ts b/antlr/SchemaListener.ts index b3c9710..a208419 100644 --- a/antlr/SchemaListener.ts +++ b/antlr/SchemaListener.ts @@ -3,18 +3,30 @@ import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener"; -import { StartContext } from "./SchemaParser"; -import { TypeDefinitionsContext } from "./SchemaParser"; -import { TypeDefinitionContext } from "./SchemaParser"; -import { FieldListContext } from "./SchemaParser"; -import { FieldContext } from "./SchemaParser"; -import { FieldTypeContext } from "./SchemaParser"; -import { TypeExpressionContext } from "./SchemaParser"; -import { SimpleTypeContext } from "./SchemaParser"; -import { ArraySuffixContext } from "./SchemaParser"; -import { UnionTypeContext } from "./SchemaParser"; -import { UnionTypeInnerContext } from "./SchemaParser"; +import { DocumentContext } from "./SchemaParser"; +import { DefinitionListContext } from "./SchemaParser"; +import { DefinitionContext } from "./SchemaParser"; +import { TypeNameContext } from "./SchemaParser"; +import { ObjectTypeDefinitionContext } from "./SchemaParser"; +import { FieldDefListContext } from "./SchemaParser"; +import { IdentifierContext } from "./SchemaParser"; +import { FieldDefContext } from "./SchemaParser"; +import { TypeContext } from "./SchemaParser"; +import { NonUnionTypeContext } from "./SchemaParser"; +import { NonUnionTypeL2Context } from "./SchemaParser"; +import { TypeReferenceContext } from "./SchemaParser"; +import { ObjectLiteralTypeContext } from "./SchemaParser"; import { PrimitiveTypeContext } from "./SchemaParser"; +import { LiteralTypeContext } from "./SchemaParser"; +import { BooleanLiteralTypeContext } from "./SchemaParser"; +import { NumberLiteralTypeContext } from "./SchemaParser"; +import { StringLiteralTypeContext } from "./SchemaParser"; +import { YorkieTypeContext } from "./SchemaParser"; +import { YorkieObjectTypeContext } from "./SchemaParser"; +import { YorkieArrayTypeContext } from "./SchemaParser"; +import { YorkieCounterTypeContext } from "./SchemaParser"; +import { YorkieTextTypeContext } from "./SchemaParser"; +import { YorkieTreeTypeContext } from "./SchemaParser"; /** @@ -23,125 +35,147 @@ import { PrimitiveTypeContext } from "./SchemaParser"; */ export interface SchemaListener extends ParseTreeListener { /** - * Enter a parse tree produced by `SchemaParser.start`. + * Enter a parse tree produced by `SchemaParser.document`. * @param ctx the parse tree */ - enterStart?: (ctx: StartContext) => void; + enterDocument?: (ctx: DocumentContext) => void; /** - * Exit a parse tree produced by `SchemaParser.start`. + * Exit a parse tree produced by `SchemaParser.document`. * @param ctx the parse tree */ - exitStart?: (ctx: StartContext) => void; + exitDocument?: (ctx: DocumentContext) => void; /** - * Enter a parse tree produced by `SchemaParser.typeDefinitions`. + * Enter a parse tree produced by `SchemaParser.definitionList`. * @param ctx the parse tree */ - enterTypeDefinitions?: (ctx: TypeDefinitionsContext) => void; + enterDefinitionList?: (ctx: DefinitionListContext) => void; /** - * Exit a parse tree produced by `SchemaParser.typeDefinitions`. + * Exit a parse tree produced by `SchemaParser.definitionList`. * @param ctx the parse tree */ - exitTypeDefinitions?: (ctx: TypeDefinitionsContext) => void; + exitDefinitionList?: (ctx: DefinitionListContext) => void; /** - * Enter a parse tree produced by `SchemaParser.typeDefinition`. + * Enter a parse tree produced by `SchemaParser.definition`. * @param ctx the parse tree */ - enterTypeDefinition?: (ctx: TypeDefinitionContext) => void; + enterDefinition?: (ctx: DefinitionContext) => void; /** - * Exit a parse tree produced by `SchemaParser.typeDefinition`. + * Exit a parse tree produced by `SchemaParser.definition`. * @param ctx the parse tree */ - exitTypeDefinition?: (ctx: TypeDefinitionContext) => void; + exitDefinition?: (ctx: DefinitionContext) => void; /** - * Enter a parse tree produced by `SchemaParser.fieldList`. + * Enter a parse tree produced by `SchemaParser.typeName`. * @param ctx the parse tree */ - enterFieldList?: (ctx: FieldListContext) => void; + enterTypeName?: (ctx: TypeNameContext) => void; /** - * Exit a parse tree produced by `SchemaParser.fieldList`. + * Exit a parse tree produced by `SchemaParser.typeName`. * @param ctx the parse tree */ - exitFieldList?: (ctx: FieldListContext) => void; + exitTypeName?: (ctx: TypeNameContext) => void; /** - * Enter a parse tree produced by `SchemaParser.field`. + * Enter a parse tree produced by `SchemaParser.objectTypeDefinition`. * @param ctx the parse tree */ - enterField?: (ctx: FieldContext) => void; + enterObjectTypeDefinition?: (ctx: ObjectTypeDefinitionContext) => void; /** - * Exit a parse tree produced by `SchemaParser.field`. + * Exit a parse tree produced by `SchemaParser.objectTypeDefinition`. * @param ctx the parse tree */ - exitField?: (ctx: FieldContext) => void; + exitObjectTypeDefinition?: (ctx: ObjectTypeDefinitionContext) => void; /** - * Enter a parse tree produced by `SchemaParser.fieldType`. + * Enter a parse tree produced by `SchemaParser.fieldDefList`. * @param ctx the parse tree */ - enterFieldType?: (ctx: FieldTypeContext) => void; + enterFieldDefList?: (ctx: FieldDefListContext) => void; /** - * Exit a parse tree produced by `SchemaParser.fieldType`. + * Exit a parse tree produced by `SchemaParser.fieldDefList`. * @param ctx the parse tree */ - exitFieldType?: (ctx: FieldTypeContext) => void; + exitFieldDefList?: (ctx: FieldDefListContext) => void; /** - * Enter a parse tree produced by `SchemaParser.typeExpression`. + * Enter a parse tree produced by `SchemaParser.identifier`. * @param ctx the parse tree */ - enterTypeExpression?: (ctx: TypeExpressionContext) => void; + enterIdentifier?: (ctx: IdentifierContext) => void; /** - * Exit a parse tree produced by `SchemaParser.typeExpression`. + * Exit a parse tree produced by `SchemaParser.identifier`. * @param ctx the parse tree */ - exitTypeExpression?: (ctx: TypeExpressionContext) => void; + exitIdentifier?: (ctx: IdentifierContext) => void; /** - * Enter a parse tree produced by `SchemaParser.simpleType`. + * Enter a parse tree produced by `SchemaParser.fieldDef`. * @param ctx the parse tree */ - enterSimpleType?: (ctx: SimpleTypeContext) => void; + enterFieldDef?: (ctx: FieldDefContext) => void; /** - * Exit a parse tree produced by `SchemaParser.simpleType`. + * Exit a parse tree produced by `SchemaParser.fieldDef`. * @param ctx the parse tree */ - exitSimpleType?: (ctx: SimpleTypeContext) => void; + exitFieldDef?: (ctx: FieldDefContext) => void; /** - * Enter a parse tree produced by `SchemaParser.arraySuffix`. + * Enter a parse tree produced by `SchemaParser.type`. * @param ctx the parse tree */ - enterArraySuffix?: (ctx: ArraySuffixContext) => void; + enterType?: (ctx: TypeContext) => void; /** - * Exit a parse tree produced by `SchemaParser.arraySuffix`. + * Exit a parse tree produced by `SchemaParser.type`. * @param ctx the parse tree */ - exitArraySuffix?: (ctx: ArraySuffixContext) => void; + exitType?: (ctx: TypeContext) => void; /** - * Enter a parse tree produced by `SchemaParser.unionType`. + * Enter a parse tree produced by `SchemaParser.nonUnionType`. * @param ctx the parse tree */ - enterUnionType?: (ctx: UnionTypeContext) => void; + enterNonUnionType?: (ctx: NonUnionTypeContext) => void; /** - * Exit a parse tree produced by `SchemaParser.unionType`. + * Exit a parse tree produced by `SchemaParser.nonUnionType`. * @param ctx the parse tree */ - exitUnionType?: (ctx: UnionTypeContext) => void; + exitNonUnionType?: (ctx: NonUnionTypeContext) => void; /** - * Enter a parse tree produced by `SchemaParser.unionTypeInner`. + * Enter a parse tree produced by `SchemaParser.nonUnionTypeL2`. * @param ctx the parse tree */ - enterUnionTypeInner?: (ctx: UnionTypeInnerContext) => void; + enterNonUnionTypeL2?: (ctx: NonUnionTypeL2Context) => void; /** - * Exit a parse tree produced by `SchemaParser.unionTypeInner`. + * Exit a parse tree produced by `SchemaParser.nonUnionTypeL2`. * @param ctx the parse tree */ - exitUnionTypeInner?: (ctx: UnionTypeInnerContext) => void; + exitNonUnionTypeL2?: (ctx: NonUnionTypeL2Context) => void; + + /** + * Enter a parse tree produced by `SchemaParser.typeReference`. + * @param ctx the parse tree + */ + enterTypeReference?: (ctx: TypeReferenceContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.typeReference`. + * @param ctx the parse tree + */ + exitTypeReference?: (ctx: TypeReferenceContext) => void; + + /** + * Enter a parse tree produced by `SchemaParser.objectLiteralType`. + * @param ctx the parse tree + */ + enterObjectLiteralType?: (ctx: ObjectLiteralTypeContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.objectLiteralType`. + * @param ctx the parse tree + */ + exitObjectLiteralType?: (ctx: ObjectLiteralTypeContext) => void; /** * Enter a parse tree produced by `SchemaParser.primitiveType`. @@ -153,5 +187,115 @@ export interface SchemaListener extends ParseTreeListener { * @param ctx the parse tree */ exitPrimitiveType?: (ctx: PrimitiveTypeContext) => void; + + /** + * Enter a parse tree produced by `SchemaParser.literalType`. + * @param ctx the parse tree + */ + enterLiteralType?: (ctx: LiteralTypeContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.literalType`. + * @param ctx the parse tree + */ + exitLiteralType?: (ctx: LiteralTypeContext) => void; + + /** + * Enter a parse tree produced by `SchemaParser.booleanLiteralType`. + * @param ctx the parse tree + */ + enterBooleanLiteralType?: (ctx: BooleanLiteralTypeContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.booleanLiteralType`. + * @param ctx the parse tree + */ + exitBooleanLiteralType?: (ctx: BooleanLiteralTypeContext) => void; + + /** + * Enter a parse tree produced by `SchemaParser.numberLiteralType`. + * @param ctx the parse tree + */ + enterNumberLiteralType?: (ctx: NumberLiteralTypeContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.numberLiteralType`. + * @param ctx the parse tree + */ + exitNumberLiteralType?: (ctx: NumberLiteralTypeContext) => void; + + /** + * Enter a parse tree produced by `SchemaParser.stringLiteralType`. + * @param ctx the parse tree + */ + enterStringLiteralType?: (ctx: StringLiteralTypeContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.stringLiteralType`. + * @param ctx the parse tree + */ + exitStringLiteralType?: (ctx: StringLiteralTypeContext) => void; + + /** + * Enter a parse tree produced by `SchemaParser.yorkieType`. + * @param ctx the parse tree + */ + enterYorkieType?: (ctx: YorkieTypeContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.yorkieType`. + * @param ctx the parse tree + */ + exitYorkieType?: (ctx: YorkieTypeContext) => void; + + /** + * Enter a parse tree produced by `SchemaParser.yorkieObjectType`. + * @param ctx the parse tree + */ + enterYorkieObjectType?: (ctx: YorkieObjectTypeContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.yorkieObjectType`. + * @param ctx the parse tree + */ + exitYorkieObjectType?: (ctx: YorkieObjectTypeContext) => void; + + /** + * Enter a parse tree produced by `SchemaParser.yorkieArrayType`. + * @param ctx the parse tree + */ + enterYorkieArrayType?: (ctx: YorkieArrayTypeContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.yorkieArrayType`. + * @param ctx the parse tree + */ + exitYorkieArrayType?: (ctx: YorkieArrayTypeContext) => void; + + /** + * Enter a parse tree produced by `SchemaParser.yorkieCounterType`. + * @param ctx the parse tree + */ + enterYorkieCounterType?: (ctx: YorkieCounterTypeContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.yorkieCounterType`. + * @param ctx the parse tree + */ + exitYorkieCounterType?: (ctx: YorkieCounterTypeContext) => void; + + /** + * Enter a parse tree produced by `SchemaParser.yorkieTextType`. + * @param ctx the parse tree + */ + enterYorkieTextType?: (ctx: YorkieTextTypeContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.yorkieTextType`. + * @param ctx the parse tree + */ + exitYorkieTextType?: (ctx: YorkieTextTypeContext) => void; + + /** + * Enter a parse tree produced by `SchemaParser.yorkieTreeType`. + * @param ctx the parse tree + */ + enterYorkieTreeType?: (ctx: YorkieTreeTypeContext) => void; + /** + * Exit a parse tree produced by `SchemaParser.yorkieTreeType`. + * @param ctx the parse tree + */ + exitYorkieTreeType?: (ctx: YorkieTreeTypeContext) => void; } diff --git a/antlr/SchemaParser.ts b/antlr/SchemaParser.ts index 742c3f3..eee530a 100644 --- a/antlr/SchemaParser.ts +++ b/antlr/SchemaParser.ts @@ -39,34 +39,82 @@ export class SchemaParser extends Parser { public static readonly T__8 = 9; public static readonly T__9 = 10; public static readonly T__10 = 11; - public static readonly IDENTIFIER = 12; - public static readonly WHITESPACE = 13; - public static readonly RULE_start = 0; - public static readonly RULE_typeDefinitions = 1; - public static readonly RULE_typeDefinition = 2; - public static readonly RULE_fieldList = 3; - public static readonly RULE_field = 4; - public static readonly RULE_fieldType = 5; - public static readonly RULE_typeExpression = 6; - public static readonly RULE_simpleType = 7; - public static readonly RULE_arraySuffix = 8; - public static readonly RULE_unionType = 9; - public static readonly RULE_unionTypeInner = 10; - public static readonly RULE_primitiveType = 11; + public static readonly T__11 = 12; + public static readonly IDENTIFIER = 13; + public static readonly NEWLINE = 14; + public static readonly COMMENT = 15; + public static readonly DIGIT = 16; + public static readonly WHITESPACE = 17; + public static readonly YORKIE_OBJECT = 18; + public static readonly YORKIE_ARRAY = 19; + public static readonly YORKIE_COUNTER = 20; + public static readonly YORKIE_TEXT = 21; + public static readonly YORKIE_TREE = 22; + public static readonly MINUS = 23; + public static readonly SEMICOLON = 24; + public static readonly LPAREN = 25; + public static readonly RPAREN = 26; + public static readonly LCURLY = 27; + public static readonly RCURLY = 28; + public static readonly GT = 29; + public static readonly LT = 30; + public static readonly PIPE = 31; + public static readonly QUESTION = 32; + public static readonly EQ = 33; + public static readonly COMMA = 34; + public static readonly LSQUARE = 35; + public static readonly RSQUARE = 36; + public static readonly DOUBLE_QUOTED_STRING = 37; + public static readonly SINGLE_QUOTED_STRING = 38; + public static readonly RULE_document = 0; + public static readonly RULE_definitionList = 1; + public static readonly RULE_definition = 2; + public static readonly RULE_typeName = 3; + public static readonly RULE_objectTypeDefinition = 4; + public static readonly RULE_fieldDefList = 5; + public static readonly RULE_identifier = 6; + public static readonly RULE_fieldDef = 7; + public static readonly RULE_type = 8; + public static readonly RULE_nonUnionType = 9; + public static readonly RULE_nonUnionTypeL2 = 10; + public static readonly RULE_typeReference = 11; + public static readonly RULE_objectLiteralType = 12; + public static readonly RULE_primitiveType = 13; + public static readonly RULE_literalType = 14; + public static readonly RULE_booleanLiteralType = 15; + public static readonly RULE_numberLiteralType = 16; + public static readonly RULE_stringLiteralType = 17; + public static readonly RULE_yorkieType = 18; + public static readonly RULE_yorkieObjectType = 19; + public static readonly RULE_yorkieArrayType = 20; + public static readonly RULE_yorkieCounterType = 21; + public static readonly RULE_yorkieTextType = 22; + public static readonly RULE_yorkieTreeType = 23; // tslint:disable:no-trailing-whitespace public static readonly ruleNames: string[] = [ - "start", "typeDefinitions", "typeDefinition", "fieldList", "field", "fieldType", - "typeExpression", "simpleType", "arraySuffix", "unionType", "unionTypeInner", - "primitiveType", + "document", "definitionList", "definition", "typeName", "objectTypeDefinition", + "fieldDefList", "identifier", "fieldDef", "type", "nonUnionType", "nonUnionTypeL2", + "typeReference", "objectLiteralType", "primitiveType", "literalType", + "booleanLiteralType", "numberLiteralType", "stringLiteralType", "yorkieType", + "yorkieObjectType", "yorkieArrayType", "yorkieCounterType", "yorkieTextType", + "yorkieTreeType", ]; private static readonly _LITERAL_NAMES: Array = [ - undefined, "'type'", "'{'", "'}'", "':'", "'[]'", "'('", "')'", "'|'", - "'string'", "'number'", "'boolean'", + undefined, "'type'", "':'", "'string'", "'number'", "'boolean'", "'null'", + "'bigint'", "'Uint8Array'", "'Date'", "'true'", "'false'", "'.'", undefined, + undefined, undefined, undefined, undefined, "'yorkie.Object'", "'yorkie.Array'", + "'yorkie.Counter'", "'yorkie.Text'", "'yorkie.Tree'", "'-'", "';'", "'('", + "')'", "'{'", "'}'", "'>'", "'<'", "'|'", "'?'", "'='", "','", "'['", + "']'", ]; private static readonly _SYMBOLIC_NAMES: Array = [ undefined, undefined, undefined, undefined, undefined, undefined, undefined, - undefined, undefined, undefined, undefined, undefined, "IDENTIFIER", "WHITESPACE", + undefined, undefined, undefined, undefined, undefined, undefined, "IDENTIFIER", + "NEWLINE", "COMMENT", "DIGIT", "WHITESPACE", "YORKIE_OBJECT", "YORKIE_ARRAY", + "YORKIE_COUNTER", "YORKIE_TEXT", "YORKIE_TREE", "MINUS", "SEMICOLON", + "LPAREN", "RPAREN", "LCURLY", "RCURLY", "GT", "LT", "PIPE", "QUESTION", + "EQ", "COMMA", "LSQUARE", "RSQUARE", "DOUBLE_QUOTED_STRING", "SINGLE_QUOTED_STRING", ]; public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(SchemaParser._LITERAL_NAMES, SchemaParser._SYMBOLIC_NAMES, []); @@ -95,15 +143,15 @@ export class SchemaParser extends Parser { this._interp = new ParserATNSimulator(SchemaParser._ATN, this); } // @RuleVersion(0) - public start(): StartContext { - let _localctx: StartContext = new StartContext(this._ctx, this.state); - this.enterRule(_localctx, 0, SchemaParser.RULE_start); + public document(): DocumentContext { + let _localctx: DocumentContext = new DocumentContext(this._ctx, this.state); + this.enterRule(_localctx, 0, SchemaParser.RULE_document); try { this.enterOuterAlt(_localctx, 1); { - this.state = 24; - this.typeDefinitions(); - this.state = 25; + this.state = 48; + this.definitionList(); + this.state = 49; this.match(SchemaParser.EOF); } } @@ -122,39 +170,43 @@ export class SchemaParser extends Parser { return _localctx; } // @RuleVersion(0) - public typeDefinitions(): TypeDefinitionsContext { - let _localctx: TypeDefinitionsContext = new TypeDefinitionsContext(this._ctx, this.state); - this.enterRule(_localctx, 2, SchemaParser.RULE_typeDefinitions); + public definitionList(): DefinitionListContext { + let _localctx: DefinitionListContext = new DefinitionListContext(this._ctx, this.state); + this.enterRule(_localctx, 2, SchemaParser.RULE_definitionList); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 27; - this.typeDefinition(); - this.state = 35; + this.state = 51; + this.definition(); + this.state = 61; this._errHandler.sync(this); _la = this._input.LA(1); - if (_la === SchemaParser.T__0 || _la === SchemaParser.WHITESPACE) { + while (_la === SchemaParser.T__0 || _la === SchemaParser.WHITESPACE) { + { { - this.state = 31; + this.state = 55; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === SchemaParser.WHITESPACE) { { { - this.state = 28; + this.state = 52; this.match(SchemaParser.WHITESPACE); } } - this.state = 33; + this.state = 57; this._errHandler.sync(this); _la = this._input.LA(1); } - this.state = 34; - this.typeDefinitions(); + this.state = 58; + this.definition(); } + } + this.state = 63; + this._errHandler.sync(this); + _la = this._input.LA(1); } - } } catch (re) { @@ -172,22 +224,14 @@ export class SchemaParser extends Parser { return _localctx; } // @RuleVersion(0) - public typeDefinition(): TypeDefinitionContext { - let _localctx: TypeDefinitionContext = new TypeDefinitionContext(this._ctx, this.state); - this.enterRule(_localctx, 4, SchemaParser.RULE_typeDefinition); + public definition(): DefinitionContext { + let _localctx: DefinitionContext = new DefinitionContext(this._ctx, this.state); + this.enterRule(_localctx, 4, SchemaParser.RULE_definition); try { this.enterOuterAlt(_localctx, 1); { - this.state = 37; - this.match(SchemaParser.T__0); - this.state = 38; - this.match(SchemaParser.IDENTIFIER); - this.state = 39; - this.match(SchemaParser.T__1); - this.state = 40; - this.fieldList(); - this.state = 41; - this.match(SchemaParser.T__2); + this.state = 64; + this.objectTypeDefinition(); } } catch (re) { @@ -205,39 +249,14 @@ export class SchemaParser extends Parser { return _localctx; } // @RuleVersion(0) - public fieldList(): FieldListContext { - let _localctx: FieldListContext = new FieldListContext(this._ctx, this.state); - this.enterRule(_localctx, 6, SchemaParser.RULE_fieldList); - let _la: number; + public typeName(): TypeNameContext { + let _localctx: TypeNameContext = new TypeNameContext(this._ctx, this.state); + this.enterRule(_localctx, 6, SchemaParser.RULE_typeName); try { this.enterOuterAlt(_localctx, 1); { - this.state = 43; - this.field(); - this.state = 51; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === SchemaParser.IDENTIFIER || _la === SchemaParser.WHITESPACE) { - { - this.state = 47; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === SchemaParser.WHITESPACE) { - { - { - this.state = 44; - this.match(SchemaParser.WHITESPACE); - } - } - this.state = 49; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 50; - this.fieldList(); - } - } - + this.state = 66; + this.match(SchemaParser.IDENTIFIER); } } catch (re) { @@ -255,47 +274,100 @@ export class SchemaParser extends Parser { return _localctx; } // @RuleVersion(0) - public field(): FieldContext { - let _localctx: FieldContext = new FieldContext(this._ctx, this.state); - this.enterRule(_localctx, 8, SchemaParser.RULE_field); + public objectTypeDefinition(): ObjectTypeDefinitionContext { + let _localctx: ObjectTypeDefinitionContext = new ObjectTypeDefinitionContext(this._ctx, this.state); + this.enterRule(_localctx, 8, SchemaParser.RULE_objectTypeDefinition); let _la: number; try { + let _alt: number; this.enterOuterAlt(_localctx, 1); { - this.state = 53; - this.match(SchemaParser.IDENTIFIER); - this.state = 57; + this.state = 68; + this.match(SchemaParser.T__0); + this.state = 72; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === SchemaParser.WHITESPACE) { { { - this.state = 54; + this.state = 69; this.match(SchemaParser.WHITESPACE); } } - this.state = 59; + this.state = 74; this._errHandler.sync(this); _la = this._input.LA(1); } - this.state = 60; - this.match(SchemaParser.T__3); - this.state = 64; + this.state = 75; + this.typeName(); + this.state = 79; + this._errHandler.sync(this); + _la = this._input.LA(1); + while (_la === SchemaParser.WHITESPACE) { + { + { + this.state = 76; + this.match(SchemaParser.WHITESPACE); + } + } + this.state = 81; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + this.state = 82; + this.match(SchemaParser.LCURLY); + this.state = 86; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 4, this._ctx); + while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { + if (_alt === 1) { + { + { + this.state = 83; + this.match(SchemaParser.WHITESPACE); + } + } + } + this.state = 88; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 4, this._ctx); + } + this.state = 90; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === SchemaParser.IDENTIFIER) { + { + this.state = 89; + this.fieldDefList(); + } + } + + this.state = 95; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === SchemaParser.WHITESPACE) { { { - this.state = 61; + this.state = 92; this.match(SchemaParser.WHITESPACE); } } - this.state = 66; + this.state = 97; this._errHandler.sync(this); _la = this._input.LA(1); } - this.state = 67; - this.fieldType(); + this.state = 98; + this.match(SchemaParser.RCURLY); + this.state = 100; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === SchemaParser.SEMICOLON) { + { + this.state = 99; + this.match(SchemaParser.SEMICOLON); + } + } + } } catch (re) { @@ -313,26 +385,38 @@ export class SchemaParser extends Parser { return _localctx; } // @RuleVersion(0) - public fieldType(): FieldTypeContext { - let _localctx: FieldTypeContext = new FieldTypeContext(this._ctx, this.state); - this.enterRule(_localctx, 10, SchemaParser.RULE_fieldType); + public fieldDefList(): FieldDefListContext { + let _localctx: FieldDefListContext = new FieldDefListContext(this._ctx, this.state); + this.enterRule(_localctx, 10, SchemaParser.RULE_fieldDefList); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 69; - this.typeExpression(); - this.state = 73; + this.state = 102; + this.fieldDef(); + this.state = 107; this._errHandler.sync(this); _la = this._input.LA(1); - while (_la === SchemaParser.T__4) { + while (((((_la - 14)) & ~0x1F) === 0 && ((1 << (_la - 14)) & ((1 << (SchemaParser.NEWLINE - 14)) | (1 << (SchemaParser.SEMICOLON - 14)) | (1 << (SchemaParser.COMMA - 14)))) !== 0)) { { { - this.state = 70; - this.arraySuffix(); + this.state = 103; + _la = this._input.LA(1); + if (!(((((_la - 14)) & ~0x1F) === 0 && ((1 << (_la - 14)) & ((1 << (SchemaParser.NEWLINE - 14)) | (1 << (SchemaParser.SEMICOLON - 14)) | (1 << (SchemaParser.COMMA - 14)))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 104; + this.fieldDef(); } } - this.state = 75; + this.state = 109; this._errHandler.sync(this); _la = this._input.LA(1); } @@ -353,28 +437,54 @@ export class SchemaParser extends Parser { return _localctx; } // @RuleVersion(0) - public typeExpression(): TypeExpressionContext { - let _localctx: TypeExpressionContext = new TypeExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 12, SchemaParser.RULE_typeExpression); + public identifier(): IdentifierContext { + let _localctx: IdentifierContext = new IdentifierContext(this._ctx, this.state); + this.enterRule(_localctx, 12, SchemaParser.RULE_identifier); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 110; + this.match(SchemaParser.IDENTIFIER); + } + } + 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 fieldDef(): FieldDefContext { + let _localctx: FieldDefContext = new FieldDefContext(this._ctx, this.state); + this.enterRule(_localctx, 14, SchemaParser.RULE_fieldDef); + let _la: number; try { - this.state = 78; + this.enterOuterAlt(_localctx, 1); + { + this.state = 112; + this.identifier(); + this.state = 114; this._errHandler.sync(this); - switch ( this.interpreter.adaptivePredict(this._input, 7, this._ctx) ) { - case 1: - this.enterOuterAlt(_localctx, 1); + _la = this._input.LA(1); + if (_la === SchemaParser.QUESTION) { { - this.state = 76; - this.unionType(); + this.state = 113; + this.match(SchemaParser.QUESTION); } - break; + } - case 2: - this.enterOuterAlt(_localctx, 2); - { - this.state = 77; - this.simpleType(); - } - break; + this.state = 116; + this.match(SchemaParser.T__1); + this.state = 117; + this.type(); } } catch (re) { @@ -392,31 +502,33 @@ export class SchemaParser extends Parser { return _localctx; } // @RuleVersion(0) - public simpleType(): SimpleTypeContext { - let _localctx: SimpleTypeContext = new SimpleTypeContext(this._ctx, this.state); - this.enterRule(_localctx, 14, SchemaParser.RULE_simpleType); + public type(): TypeContext { + let _localctx: TypeContext = new TypeContext(this._ctx, this.state); + this.enterRule(_localctx, 16, SchemaParser.RULE_type); try { - this.state = 82; + let _alt: number; + this.enterOuterAlt(_localctx, 1); + { + this.state = 119; + this.nonUnionType(); + this.state = 124; this._errHandler.sync(this); - switch (this._input.LA(1)) { - case SchemaParser.T__8: - case SchemaParser.T__9: - case SchemaParser.T__10: - this.enterOuterAlt(_localctx, 1); - { - this.state = 80; - this.primitiveType(); - } - break; - case SchemaParser.IDENTIFIER: - this.enterOuterAlt(_localctx, 2); - { - this.state = 81; - this.match(SchemaParser.IDENTIFIER); + _alt = this.interpreter.adaptivePredict(this._input, 10, this._ctx); + while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { + if (_alt === 1) { + { + { + this.state = 120; + this.match(SchemaParser.PIPE); + this.state = 121; + this.type(); + } + } } - break; - default: - throw new NoViableAltException(this); + this.state = 126; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 10, this._ctx); + } } } catch (re) { @@ -434,14 +546,31 @@ export class SchemaParser extends Parser { return _localctx; } // @RuleVersion(0) - public arraySuffix(): ArraySuffixContext { - let _localctx: ArraySuffixContext = new ArraySuffixContext(this._ctx, this.state); - this.enterRule(_localctx, 16, SchemaParser.RULE_arraySuffix); + public nonUnionType(): NonUnionTypeContext { + let _localctx: NonUnionTypeContext = new NonUnionTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 18, SchemaParser.RULE_nonUnionType); + let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 84; - this.match(SchemaParser.T__4); + this.state = 127; + this.nonUnionTypeL2(); + this.state = 132; + this._errHandler.sync(this); + _la = this._input.LA(1); + while (_la === SchemaParser.LSQUARE) { + { + { + this.state = 128; + this.match(SchemaParser.LSQUARE); + this.state = 129; + this.match(SchemaParser.RSQUARE); + } + } + this.state = 134; + this._errHandler.sync(this); + _la = this._input.LA(1); + } } } catch (re) { @@ -459,61 +588,72 @@ export class SchemaParser extends Parser { return _localctx; } // @RuleVersion(0) - public unionType(): UnionTypeContext { - let _localctx: UnionTypeContext = new UnionTypeContext(this._ctx, this.state); - this.enterRule(_localctx, 18, SchemaParser.RULE_unionType); - let _la: number; + public nonUnionTypeL2(): NonUnionTypeL2Context { + let _localctx: NonUnionTypeL2Context = new NonUnionTypeL2Context(this._ctx, this.state); + this.enterRule(_localctx, 20, SchemaParser.RULE_nonUnionTypeL2); try { - this.state = 103; + this.state = 144; this._errHandler.sync(this); switch (this._input.LA(1)) { - case SchemaParser.T__5: + case SchemaParser.LPAREN: this.enterOuterAlt(_localctx, 1); { - this.state = 86; - this.match(SchemaParser.T__5); - this.state = 90; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === SchemaParser.WHITESPACE) { - { - { - this.state = 87; - this.match(SchemaParser.WHITESPACE); - } - } - this.state = 92; - this._errHandler.sync(this); - _la = this._input.LA(1); + this.state = 135; + this.match(SchemaParser.LPAREN); + this.state = 136; + this.type(); + this.state = 137; + this.match(SchemaParser.RPAREN); } - this.state = 93; - this.unionTypeInner(); - this.state = 97; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === SchemaParser.WHITESPACE) { - { - { - this.state = 94; - this.match(SchemaParser.WHITESPACE); - } - } - this.state = 99; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 100; - this.match(SchemaParser.T__6); + break; + case SchemaParser.LCURLY: + this.enterOuterAlt(_localctx, 2); + { + this.state = 139; + this.objectLiteralType(); } break; + case SchemaParser.T__2: + case SchemaParser.T__3: + case SchemaParser.T__4: + case SchemaParser.T__5: + case SchemaParser.T__6: + case SchemaParser.T__7: case SchemaParser.T__8: + this.enterOuterAlt(_localctx, 3); + { + this.state = 140; + this.primitiveType(); + } + break; case SchemaParser.T__9: case SchemaParser.T__10: + case SchemaParser.DIGIT: + case SchemaParser.MINUS: + case SchemaParser.DOUBLE_QUOTED_STRING: + case SchemaParser.SINGLE_QUOTED_STRING: + this.enterOuterAlt(_localctx, 4); + { + this.state = 141; + this.literalType(); + } + break; + case SchemaParser.YORKIE_OBJECT: + case SchemaParser.YORKIE_ARRAY: + case SchemaParser.YORKIE_COUNTER: + case SchemaParser.YORKIE_TEXT: + case SchemaParser.YORKIE_TREE: + this.enterOuterAlt(_localctx, 5); + { + this.state = 142; + this.yorkieType(); + } + break; case SchemaParser.IDENTIFIER: - this.enterOuterAlt(_localctx, 2); + this.enterOuterAlt(_localctx, 6); { - this.state = 102; - this.unionTypeInner(); + this.state = 143; + this.typeReference(); } break; default: @@ -535,62 +675,52 @@ export class SchemaParser extends Parser { return _localctx; } // @RuleVersion(0) - public unionTypeInner(): UnionTypeInnerContext { - let _localctx: UnionTypeInnerContext = new UnionTypeInnerContext(this._ctx, this.state); - this.enterRule(_localctx, 20, SchemaParser.RULE_unionTypeInner); + public typeReference(): TypeReferenceContext { + let _localctx: TypeReferenceContext = new TypeReferenceContext(this._ctx, this.state); + this.enterRule(_localctx, 22, SchemaParser.RULE_typeReference); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 146; + this.typeName(); + } + } + 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 objectLiteralType(): ObjectLiteralTypeContext { + let _localctx: ObjectLiteralTypeContext = new ObjectLiteralTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 24, SchemaParser.RULE_objectLiteralType); let _la: number; try { - let _alt: number; this.enterOuterAlt(_localctx, 1); { - this.state = 105; - this.simpleType(); - this.state = 122; + this.state = 148; + this.match(SchemaParser.LCURLY); + this.state = 150; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 14, this._ctx); - while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { - if (_alt === 1) { - { - { - this.state = 109; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === SchemaParser.WHITESPACE) { - { - { - this.state = 106; - this.match(SchemaParser.WHITESPACE); - } - } - this.state = 111; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 112; - this.match(SchemaParser.T__7); - this.state = 116; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === SchemaParser.WHITESPACE) { - { - { - this.state = 113; - this.match(SchemaParser.WHITESPACE); - } - } - this.state = 118; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 119; - this.simpleType(); - } - } + _la = this._input.LA(1); + if (_la === SchemaParser.IDENTIFIER) { + { + this.state = 149; + this.fieldDefList(); } - this.state = 124; - this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 14, this._ctx); } + + this.state = 152; + this.match(SchemaParser.RCURLY); } } catch (re) { @@ -610,14 +740,14 @@ export class SchemaParser extends Parser { // @RuleVersion(0) public primitiveType(): PrimitiveTypeContext { let _localctx: PrimitiveTypeContext = new PrimitiveTypeContext(this._ctx, this.state); - this.enterRule(_localctx, 22, SchemaParser.RULE_primitiveType); + this.enterRule(_localctx, 26, SchemaParser.RULE_primitiveType); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 125; + this.state = 154; _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << SchemaParser.T__8) | (1 << SchemaParser.T__9) | (1 << SchemaParser.T__10))) !== 0))) { + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << SchemaParser.T__2) | (1 << SchemaParser.T__3) | (1 << SchemaParser.T__4) | (1 << SchemaParser.T__5) | (1 << SchemaParser.T__6) | (1 << SchemaParser.T__7) | (1 << SchemaParser.T__8))) !== 0))) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token.EOF) { @@ -643,95 +773,746 @@ export class SchemaParser extends Parser { } return _localctx; } - - public static readonly _serializedATN: string = - "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x03\x0F\x82\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\x03" + - "\x02\x03\x02\x03\x02\x03\x03\x03\x03\x07\x03 \n\x03\f\x03\x0E\x03#\v\x03" + - "\x03\x03\x05\x03&\n\x03\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04" + - "\x03\x05\x03\x05\x07\x050\n\x05\f\x05\x0E\x053\v\x05\x03\x05\x05\x056" + - "\n\x05\x03\x06\x03\x06\x07\x06:\n\x06\f\x06\x0E\x06=\v\x06\x03\x06\x03" + - "\x06\x07\x06A\n\x06\f\x06\x0E\x06D\v\x06\x03\x06\x03\x06\x03\x07\x03\x07" + - "\x07\x07J\n\x07\f\x07\x0E\x07M\v\x07\x03\b\x03\b\x05\bQ\n\b\x03\t\x03" + - "\t\x05\tU\n\t\x03\n\x03\n\x03\v\x03\v\x07\v[\n\v\f\v\x0E\v^\v\v\x03\v" + - "\x03\v\x07\vb\n\v\f\v\x0E\ve\v\v\x03\v\x03\v\x03\v\x05\vj\n\v\x03\f\x03" + - "\f\x07\fn\n\f\f\f\x0E\fq\v\f\x03\f\x03\f\x07\fu\n\f\f\f\x0E\fx\v\f\x03" + - "\f\x07\f{\n\f\f\f\x0E\f~\v\f\x03\r\x03\r\x03\r\x02\x02\x02\x0E\x02\x02" + - "\x04\x02\x06\x02\b\x02\n\x02\f\x02\x0E\x02\x10\x02\x12\x02\x14\x02\x16" + - "\x02\x18\x02\x02\x03\x03\x02\v\r\x02\x84\x02\x1A\x03\x02\x02\x02\x04\x1D" + - "\x03\x02\x02\x02\x06\'\x03\x02\x02\x02\b-\x03\x02\x02\x02\n7\x03\x02\x02" + - "\x02\fG\x03\x02\x02\x02\x0EP\x03\x02\x02\x02\x10T\x03\x02\x02\x02\x12" + - "V\x03\x02\x02\x02\x14i\x03\x02\x02\x02\x16k\x03\x02\x02\x02\x18\x7F\x03" + - "\x02\x02\x02\x1A\x1B\x05\x04\x03\x02\x1B\x1C\x07\x02\x02\x03\x1C\x03\x03" + - "\x02\x02\x02\x1D%\x05\x06\x04\x02\x1E \x07\x0F\x02\x02\x1F\x1E\x03\x02" + - "\x02\x02 #\x03\x02\x02\x02!\x1F\x03\x02\x02\x02!\"\x03\x02\x02\x02\"$" + - "\x03\x02\x02\x02#!\x03\x02\x02\x02$&\x05\x04\x03\x02%!\x03\x02\x02\x02" + - "%&\x03\x02\x02\x02&\x05\x03\x02\x02\x02\'(\x07\x03\x02\x02()\x07\x0E\x02" + - "\x02)*\x07\x04\x02\x02*+\x05\b\x05\x02+,\x07\x05\x02\x02,\x07\x03\x02" + - "\x02\x02-5\x05\n\x06\x02.0\x07\x0F\x02\x02/.\x03\x02\x02\x0203\x03\x02" + - "\x02\x021/\x03\x02\x02\x0212\x03\x02\x02\x0224\x03\x02\x02\x0231\x03\x02" + - "\x02\x0246\x05\b\x05\x0251\x03\x02\x02\x0256\x03\x02\x02\x026\t\x03\x02" + - "\x02\x027;\x07\x0E\x02\x028:\x07\x0F\x02\x0298\x03\x02\x02\x02:=\x03\x02" + - "\x02\x02;9\x03\x02\x02\x02;<\x03\x02\x02\x02<>\x03\x02\x02\x02=;\x03\x02" + - "\x02\x02>B\x07\x06\x02\x02?A\x07\x0F\x02\x02@?\x03\x02\x02\x02AD\x03\x02" + - "\x02\x02B@\x03\x02\x02\x02BC\x03\x02\x02\x02CE\x03\x02\x02\x02DB\x03\x02" + - "\x02\x02EF\x05\f\x07\x02F\v\x03\x02\x02\x02GK\x05\x0E\b\x02HJ\x05\x12" + - "\n\x02IH\x03\x02\x02\x02JM\x03\x02\x02\x02KI\x03\x02\x02\x02KL\x03\x02" + - "\x02\x02L\r\x03\x02\x02\x02MK\x03\x02\x02\x02NQ\x05\x14\v\x02OQ\x05\x10" + - "\t\x02PN\x03\x02\x02\x02PO\x03\x02\x02\x02Q\x0F\x03\x02\x02\x02RU\x05" + - "\x18\r\x02SU\x07\x0E\x02\x02TR\x03\x02\x02\x02TS\x03\x02\x02\x02U\x11" + - "\x03\x02\x02\x02VW\x07\x07\x02\x02W\x13\x03\x02\x02\x02X\\\x07\b\x02\x02" + - "Y[\x07\x0F\x02\x02ZY\x03\x02\x02\x02[^\x03\x02\x02\x02\\Z\x03\x02\x02" + - "\x02\\]\x03\x02\x02\x02]_\x03\x02\x02\x02^\\\x03\x02\x02\x02_c\x05\x16" + - "\f\x02`b\x07\x0F\x02\x02a`\x03\x02\x02\x02be\x03\x02\x02\x02ca\x03\x02" + - "\x02\x02cd\x03\x02\x02\x02df\x03\x02\x02\x02ec\x03\x02\x02\x02fg\x07\t" + - "\x02\x02gj\x03\x02\x02\x02hj\x05\x16\f\x02iX\x03\x02\x02\x02ih\x03\x02" + - "\x02\x02j\x15\x03\x02\x02\x02k|\x05\x10\t\x02ln\x07\x0F\x02\x02ml\x03" + - "\x02\x02\x02nq\x03\x02\x02\x02om\x03\x02\x02\x02op\x03\x02\x02\x02pr\x03" + - "\x02\x02\x02qo\x03\x02\x02\x02rv\x07\n\x02\x02su\x07\x0F\x02\x02ts\x03" + - "\x02\x02\x02ux\x03\x02\x02\x02vt\x03\x02\x02\x02vw\x03\x02\x02\x02wy\x03" + - "\x02\x02\x02xv\x03\x02\x02\x02y{\x05\x10\t\x02zo\x03\x02\x02\x02{~\x03" + - "\x02\x02\x02|z\x03\x02\x02\x02|}\x03\x02\x02\x02}\x17\x03\x02\x02\x02" + - "~|\x03\x02\x02\x02\x7F\x80\t\x02\x02\x02\x80\x19\x03\x02\x02\x02\x11!" + - "%15;BKPT\\ciov|"; - public static __ATN: ATN; - public static get _ATN(): ATN { - if (!SchemaParser.__ATN) { - SchemaParser.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(SchemaParser._serializedATN)); + // @RuleVersion(0) + public literalType(): LiteralTypeContext { + let _localctx: LiteralTypeContext = new LiteralTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 28, SchemaParser.RULE_literalType); + try { + this.state = 159; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case SchemaParser.T__9: + case SchemaParser.T__10: + this.enterOuterAlt(_localctx, 1); + { + this.state = 156; + this.booleanLiteralType(); + } + break; + case SchemaParser.DIGIT: + case SchemaParser.MINUS: + this.enterOuterAlt(_localctx, 2); + { + this.state = 157; + this.numberLiteralType(); + } + break; + case SchemaParser.DOUBLE_QUOTED_STRING: + case SchemaParser.SINGLE_QUOTED_STRING: + this.enterOuterAlt(_localctx, 3); + { + this.state = 158; + this.stringLiteralType(); + } + 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 booleanLiteralType(): BooleanLiteralTypeContext { + let _localctx: BooleanLiteralTypeContext = new BooleanLiteralTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 30, SchemaParser.RULE_booleanLiteralType); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 161; + _la = this._input.LA(1); + if (!(_la === SchemaParser.T__9 || _la === SchemaParser.T__10)) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + } + } + 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 numberLiteralType(): NumberLiteralTypeContext { + let _localctx: NumberLiteralTypeContext = new NumberLiteralTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 32, SchemaParser.RULE_numberLiteralType); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 164; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === SchemaParser.MINUS) { + { + this.state = 163; + this.match(SchemaParser.MINUS); + } + } + + this.state = 167; + this._errHandler.sync(this); + _la = this._input.LA(1); + do { + { + { + this.state = 166; + this.match(SchemaParser.DIGIT); + } + } + this.state = 169; + this._errHandler.sync(this); + _la = this._input.LA(1); + } while (_la === SchemaParser.DIGIT); + this.state = 177; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === SchemaParser.T__11) { + { + this.state = 171; + this.match(SchemaParser.T__11); + this.state = 173; + this._errHandler.sync(this); + _la = this._input.LA(1); + do { + { + { + this.state = 172; + this.match(SchemaParser.DIGIT); + } + } + this.state = 175; + this._errHandler.sync(this); + _la = this._input.LA(1); + } while (_la === SchemaParser.DIGIT); + } + } + + } + } + 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 stringLiteralType(): StringLiteralTypeContext { + let _localctx: StringLiteralTypeContext = new StringLiteralTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 34, SchemaParser.RULE_stringLiteralType); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 179; + _la = this._input.LA(1); + if (!(_la === SchemaParser.DOUBLE_QUOTED_STRING || _la === SchemaParser.SINGLE_QUOTED_STRING)) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + } + } + 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 yorkieType(): YorkieTypeContext { + let _localctx: YorkieTypeContext = new YorkieTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 36, SchemaParser.RULE_yorkieType); + try { + this.state = 186; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case SchemaParser.YORKIE_OBJECT: + this.enterOuterAlt(_localctx, 1); + { + this.state = 181; + this.yorkieObjectType(); + } + break; + case SchemaParser.YORKIE_ARRAY: + this.enterOuterAlt(_localctx, 2); + { + this.state = 182; + this.yorkieArrayType(); + } + break; + case SchemaParser.YORKIE_COUNTER: + this.enterOuterAlt(_localctx, 3); + { + this.state = 183; + this.yorkieCounterType(); + } + break; + case SchemaParser.YORKIE_TEXT: + this.enterOuterAlt(_localctx, 4); + { + this.state = 184; + this.yorkieTextType(); + } + break; + case SchemaParser.YORKIE_TREE: + this.enterOuterAlt(_localctx, 5); + { + this.state = 185; + this.yorkieTreeType(); + } + 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 yorkieObjectType(): YorkieObjectTypeContext { + let _localctx: YorkieObjectTypeContext = new YorkieObjectTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 38, SchemaParser.RULE_yorkieObjectType); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 188; + this.match(SchemaParser.YORKIE_OBJECT); + this.state = 189; + this.match(SchemaParser.LT); + this.state = 192; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case SchemaParser.IDENTIFIER: + { + this.state = 190; + this.typeReference(); + } + break; + case SchemaParser.LCURLY: + { + this.state = 191; + this.objectLiteralType(); + } + break; + default: + throw new NoViableAltException(this); + } + this.state = 194; + this.match(SchemaParser.GT); + } + } + 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 yorkieArrayType(): YorkieArrayTypeContext { + let _localctx: YorkieArrayTypeContext = new YorkieArrayTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 40, SchemaParser.RULE_yorkieArrayType); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 196; + this.match(SchemaParser.YORKIE_ARRAY); + this.state = 197; + this.match(SchemaParser.LT); + this.state = 200; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case SchemaParser.IDENTIFIER: + { + this.state = 198; + this.typeReference(); + } + break; + case SchemaParser.LCURLY: + { + this.state = 199; + this.objectLiteralType(); + } + break; + default: + throw new NoViableAltException(this); + } + this.state = 202; + this.match(SchemaParser.GT); + } + } + 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 yorkieCounterType(): YorkieCounterTypeContext { + let _localctx: YorkieCounterTypeContext = new YorkieCounterTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 42, SchemaParser.RULE_yorkieCounterType); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 204; + this.match(SchemaParser.YORKIE_COUNTER); + } + } + 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 yorkieTextType(): YorkieTextTypeContext { + let _localctx: YorkieTextTypeContext = new YorkieTextTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 44, SchemaParser.RULE_yorkieTextType); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 206; + this.match(SchemaParser.YORKIE_TEXT); + this.state = 207; + this.match(SchemaParser.LT); + this.state = 210; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case SchemaParser.IDENTIFIER: + { + this.state = 208; + this.typeReference(); + } + break; + case SchemaParser.LCURLY: + { + this.state = 209; + this.objectLiteralType(); + } + break; + default: + throw new NoViableAltException(this); + } + this.state = 212; + this.match(SchemaParser.GT); + } + } + 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 yorkieTreeType(): YorkieTreeTypeContext { + let _localctx: YorkieTreeTypeContext = new YorkieTreeTypeContext(this._ctx, this.state); + this.enterRule(_localctx, 46, SchemaParser.RULE_yorkieTreeType); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 214; + this.match(SchemaParser.YORKIE_TREE); + this.state = 215; + this.match(SchemaParser.LT); + this.state = 216; + this.match(SchemaParser.GT); + } + } + 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(\xDD\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\x03\x02\x03\x02\x03\x02\x03\x03\x03\x03\x07\x03" + + "8\n\x03\f\x03\x0E\x03;\v\x03\x03\x03\x07\x03>\n\x03\f\x03\x0E\x03A\v\x03" + + "\x03\x04\x03\x04\x03\x05\x03\x05\x03\x06\x03\x06\x07\x06I\n\x06\f\x06" + + "\x0E\x06L\v\x06\x03\x06\x03\x06\x07\x06P\n\x06\f\x06\x0E\x06S\v\x06\x03" + + "\x06\x03\x06\x07\x06W\n\x06\f\x06\x0E\x06Z\v\x06\x03\x06\x05\x06]\n\x06" + + "\x03\x06\x07\x06`\n\x06\f\x06\x0E\x06c\v\x06\x03\x06\x03\x06\x05\x06g" + + "\n\x06\x03\x07\x03\x07\x03\x07\x07\x07l\n\x07\f\x07\x0E\x07o\v\x07\x03" + + "\b\x03\b\x03\t\x03\t\x05\tu\n\t\x03\t\x03\t\x03\t\x03\n\x03\n\x03\n\x07" + + "\n}\n\n\f\n\x0E\n\x80\v\n\x03\v\x03\v\x03\v\x07\v\x85\n\v\f\v\x0E\v\x88" + + "\v\v\x03\f\x03\f\x03\f\x03\f\x03\f\x03\f\x03\f\x03\f\x03\f\x05\f\x93\n" + + "\f\x03\r\x03\r\x03\x0E\x03\x0E\x05\x0E\x99\n\x0E\x03\x0E\x03\x0E\x03\x0F" + + "\x03\x0F\x03\x10\x03\x10\x03\x10\x05\x10\xA2\n\x10\x03\x11\x03\x11\x03" + + "\x12\x05\x12\xA7\n\x12\x03\x12\x06\x12\xAA\n\x12\r\x12\x0E\x12\xAB\x03" + + "\x12\x03\x12\x06\x12\xB0\n\x12\r\x12\x0E\x12\xB1\x05\x12\xB4\n\x12\x03" + + "\x13\x03\x13\x03\x14\x03\x14\x03\x14\x03\x14\x03\x14\x05\x14\xBD\n\x14" + + "\x03\x15\x03\x15\x03\x15\x03\x15\x05\x15\xC3\n\x15\x03\x15\x03\x15\x03" + + "\x16\x03\x16\x03\x16\x03\x16\x05\x16\xCB\n\x16\x03\x16\x03\x16\x03\x17" + + "\x03\x17\x03\x18\x03\x18\x03\x18\x03\x18\x05\x18\xD5\n\x18\x03\x18\x03" + + "\x18\x03\x19\x03\x19\x03\x19\x03\x19\x03\x19\x02\x02\x02\x1A\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*\x02,\x02." + + "\x020\x02\x02\x06\x05\x02\x10\x10\x1A\x1A$$\x03\x02\x05\v\x03\x02\f\r" + + "\x03\x02\'(\x02\xE3\x022\x03\x02\x02\x02\x045\x03\x02\x02\x02\x06B\x03" + + "\x02\x02\x02\bD\x03\x02\x02\x02\nF\x03\x02\x02\x02\fh\x03\x02\x02\x02" + + "\x0Ep\x03\x02\x02\x02\x10r\x03\x02\x02\x02\x12y\x03\x02\x02\x02\x14\x81" + + "\x03\x02\x02\x02\x16\x92\x03\x02\x02\x02\x18\x94\x03\x02\x02\x02\x1A\x96" + + "\x03\x02\x02\x02\x1C\x9C\x03\x02\x02\x02\x1E\xA1\x03\x02\x02\x02 \xA3" + + "\x03\x02\x02\x02\"\xA6\x03\x02\x02\x02$\xB5\x03\x02\x02\x02&\xBC\x03\x02" + + "\x02\x02(\xBE\x03\x02\x02\x02*\xC6\x03\x02\x02\x02,\xCE\x03\x02\x02\x02" + + ".\xD0\x03\x02\x02\x020\xD8\x03\x02\x02\x0223\x05\x04\x03\x0234\x07\x02" + + "\x02\x034\x03\x03\x02\x02\x025?\x05\x06\x04\x0268\x07\x13\x02\x0276\x03" + + "\x02\x02\x028;\x03\x02\x02\x0297\x03\x02\x02\x029:\x03\x02\x02\x02:<\x03" + + "\x02\x02\x02;9\x03\x02\x02\x02<>\x05\x06\x04\x02=9\x03\x02\x02\x02>A\x03" + + "\x02\x02\x02?=\x03\x02\x02\x02?@\x03\x02\x02\x02@\x05\x03\x02\x02\x02" + + "A?\x03\x02\x02\x02BC\x05\n\x06\x02C\x07\x03\x02\x02\x02DE\x07\x0F\x02" + + "\x02E\t\x03\x02\x02\x02FJ\x07\x03\x02\x02GI\x07\x13\x02\x02HG\x03\x02" + + "\x02\x02IL\x03\x02\x02\x02JH\x03\x02\x02\x02JK\x03\x02\x02\x02KM\x03\x02" + + "\x02\x02LJ\x03\x02\x02\x02MQ\x05\b\x05\x02NP\x07\x13\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\x02TX\x07\x1D\x02\x02UW\x07\x13\x02\x02VU\x03\x02" + + "\x02\x02WZ\x03\x02\x02\x02XV\x03\x02\x02\x02XY\x03\x02\x02\x02Y\\\x03" + + "\x02\x02\x02ZX\x03\x02\x02\x02[]\x05\f\x07\x02\\[\x03\x02\x02\x02\\]\x03" + + "\x02\x02\x02]a\x03\x02\x02\x02^`\x07\x13\x02\x02_^\x03\x02\x02\x02`c\x03" + + "\x02\x02\x02a_\x03\x02\x02\x02ab\x03\x02\x02\x02bd\x03\x02\x02\x02ca\x03" + + "\x02\x02\x02df\x07\x1E\x02\x02eg\x07\x1A\x02\x02fe\x03\x02\x02\x02fg\x03" + + "\x02\x02\x02g\v\x03\x02\x02\x02hm\x05\x10\t\x02ij\t\x02\x02\x02jl\x05" + + "\x10\t\x02ki\x03\x02\x02\x02lo\x03\x02\x02\x02mk\x03\x02\x02\x02mn\x03" + + "\x02\x02\x02n\r\x03\x02\x02\x02om\x03\x02\x02\x02pq\x07\x0F\x02\x02q\x0F" + + "\x03\x02\x02\x02rt\x05\x0E\b\x02su\x07\"\x02\x02ts\x03\x02\x02\x02tu\x03" + + "\x02\x02\x02uv\x03\x02\x02\x02vw\x07\x04\x02\x02wx\x05\x12\n\x02x\x11" + + "\x03\x02\x02\x02y~\x05\x14\v\x02z{\x07!\x02\x02{}\x05\x12\n\x02|z\x03" + + "\x02\x02\x02}\x80\x03\x02\x02\x02~|\x03\x02\x02\x02~\x7F\x03\x02\x02\x02" + + "\x7F\x13\x03\x02\x02\x02\x80~\x03\x02\x02\x02\x81\x86\x05\x16\f\x02\x82" + + "\x83\x07%\x02\x02\x83\x85\x07&\x02\x02\x84\x82\x03\x02\x02\x02\x85\x88" + + "\x03\x02\x02\x02\x86\x84\x03\x02\x02\x02\x86\x87\x03\x02\x02\x02\x87\x15" + + "\x03\x02\x02\x02\x88\x86\x03\x02\x02\x02\x89\x8A\x07\x1B\x02\x02\x8A\x8B" + + "\x05\x12\n\x02\x8B\x8C\x07\x1C\x02\x02\x8C\x93\x03\x02\x02\x02\x8D\x93" + + "\x05\x1A\x0E\x02\x8E\x93\x05\x1C\x0F\x02\x8F\x93\x05\x1E\x10\x02\x90\x93" + + "\x05&\x14\x02\x91\x93\x05\x18\r\x02\x92\x89\x03\x02\x02\x02\x92\x8D\x03" + + "\x02\x02\x02\x92\x8E\x03\x02\x02\x02\x92\x8F\x03\x02\x02\x02\x92\x90\x03" + + "\x02\x02\x02\x92\x91\x03\x02\x02\x02\x93\x17\x03\x02\x02\x02\x94\x95\x05" + + "\b\x05\x02\x95\x19\x03\x02\x02\x02\x96\x98\x07\x1D\x02\x02\x97\x99\x05" + + "\f\x07\x02\x98\x97\x03\x02\x02\x02\x98\x99\x03\x02\x02\x02\x99\x9A\x03" + + "\x02\x02\x02\x9A\x9B\x07\x1E\x02\x02\x9B\x1B\x03\x02\x02\x02\x9C\x9D\t" + + "\x03\x02\x02\x9D\x1D\x03\x02\x02\x02\x9E\xA2\x05 \x11\x02\x9F\xA2\x05" + + "\"\x12\x02\xA0\xA2\x05$\x13\x02\xA1\x9E\x03\x02\x02\x02\xA1\x9F\x03\x02" + + "\x02\x02\xA1\xA0\x03\x02\x02\x02\xA2\x1F\x03\x02\x02\x02\xA3\xA4\t\x04" + + "\x02\x02\xA4!\x03\x02\x02\x02\xA5\xA7\x07\x19\x02\x02\xA6\xA5\x03\x02" + + "\x02\x02\xA6\xA7\x03\x02\x02\x02\xA7\xA9\x03\x02\x02\x02\xA8\xAA\x07\x12" + + "\x02\x02\xA9\xA8\x03\x02\x02\x02\xAA\xAB\x03\x02\x02\x02\xAB\xA9\x03\x02" + + "\x02\x02\xAB\xAC\x03\x02\x02\x02\xAC\xB3\x03\x02\x02\x02\xAD\xAF\x07\x0E" + + "\x02\x02\xAE\xB0\x07\x12\x02\x02\xAF\xAE\x03\x02\x02\x02\xB0\xB1\x03\x02" + + "\x02\x02\xB1\xAF\x03\x02\x02\x02\xB1\xB2\x03\x02\x02\x02\xB2\xB4\x03\x02" + + "\x02\x02\xB3\xAD\x03\x02\x02\x02\xB3\xB4\x03\x02\x02\x02\xB4#\x03\x02" + + "\x02\x02\xB5\xB6\t\x05\x02\x02\xB6%\x03\x02\x02\x02\xB7\xBD\x05(\x15\x02" + + "\xB8\xBD\x05*\x16\x02\xB9\xBD\x05,\x17\x02\xBA\xBD\x05.\x18\x02\xBB\xBD" + + "\x050\x19\x02\xBC\xB7\x03\x02\x02\x02\xBC\xB8\x03\x02\x02\x02\xBC\xB9" + + "\x03\x02\x02\x02\xBC\xBA\x03\x02\x02\x02\xBC\xBB\x03\x02\x02\x02\xBD\'" + + "\x03\x02\x02\x02\xBE\xBF\x07\x14\x02\x02\xBF\xC2\x07 \x02\x02\xC0\xC3" + + "\x05\x18\r\x02\xC1\xC3\x05\x1A\x0E\x02\xC2\xC0\x03\x02\x02\x02\xC2\xC1" + + "\x03\x02\x02\x02\xC3\xC4\x03\x02\x02\x02\xC4\xC5\x07\x1F\x02\x02\xC5)" + + "\x03\x02\x02\x02\xC6\xC7\x07\x15\x02\x02\xC7\xCA\x07 \x02\x02\xC8\xCB" + + "\x05\x18\r\x02\xC9\xCB\x05\x1A\x0E\x02\xCA\xC8\x03\x02\x02\x02\xCA\xC9" + + "\x03\x02\x02\x02\xCB\xCC\x03\x02\x02\x02\xCC\xCD\x07\x1F\x02\x02\xCD+" + + "\x03\x02\x02\x02\xCE\xCF\x07\x16\x02\x02\xCF-\x03\x02\x02\x02\xD0\xD1" + + "\x07\x17\x02\x02\xD1\xD4\x07 \x02\x02\xD2\xD5\x05\x18\r\x02\xD3\xD5\x05" + + "\x1A\x0E\x02\xD4\xD2\x03\x02\x02\x02\xD4\xD3\x03\x02\x02\x02\xD5\xD6\x03" + + "\x02\x02\x02\xD6\xD7\x07\x1F\x02\x02\xD7/\x03\x02\x02\x02\xD8\xD9\x07" + + "\x18\x02\x02\xD9\xDA\x07 \x02\x02\xDA\xDB\x07\x1F\x02\x02\xDB1\x03\x02" + + "\x02\x02\x199?JQX\\afmt~\x86\x92\x98\xA1\xA6\xAB\xB1\xB3\xBC\xC2\xCA\xD4"; + public static __ATN: ATN; + public static get _ATN(): ATN { + if (!SchemaParser.__ATN) { + SchemaParser.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(SchemaParser._serializedATN)); + } + + return SchemaParser.__ATN; + } + +} + +export class DocumentContext extends ParserRuleContext { + public definitionList(): DefinitionListContext { + return this.getRuleContext(0, DefinitionListContext); + } + public EOF(): TerminalNode { return this.getToken(SchemaParser.EOF, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_document; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterDocument) { + listener.enterDocument(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitDocument) { + listener.exitDocument(this); + } + } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitDocument) { + return visitor.visitDocument(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class DefinitionListContext extends ParserRuleContext { + public definition(): DefinitionContext[]; + public definition(i: number): DefinitionContext; + public definition(i?: number): DefinitionContext | DefinitionContext[] { + if (i === undefined) { + return this.getRuleContexts(DefinitionContext); + } else { + return this.getRuleContext(i, DefinitionContext); + } + } + public WHITESPACE(): TerminalNode[]; + public WHITESPACE(i: number): TerminalNode; + public WHITESPACE(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(SchemaParser.WHITESPACE); + } else { + return this.getToken(SchemaParser.WHITESPACE, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_definitionList; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterDefinitionList) { + listener.enterDefinitionList(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitDefinitionList) { + listener.exitDefinitionList(this); + } + } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitDefinitionList) { + return visitor.visitDefinitionList(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class DefinitionContext extends ParserRuleContext { + public objectTypeDefinition(): ObjectTypeDefinitionContext { + return this.getRuleContext(0, ObjectTypeDefinitionContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_definition; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterDefinition) { + listener.enterDefinition(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitDefinition) { + listener.exitDefinition(this); + } + } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitDefinition) { + return visitor.visitDefinition(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class TypeNameContext extends ParserRuleContext { + public IDENTIFIER(): TerminalNode { return this.getToken(SchemaParser.IDENTIFIER, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_typeName; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterTypeName) { + listener.enterTypeName(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitTypeName) { + listener.exitTypeName(this); + } + } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitTypeName) { + return visitor.visitTypeName(this); + } else { + return visitor.visitChildren(this); + } + } +} + - return SchemaParser.__ATN; - } - -} - -export class StartContext extends ParserRuleContext { - public typeDefinitions(): TypeDefinitionsContext { - return this.getRuleContext(0, TypeDefinitionsContext); +export class ObjectTypeDefinitionContext extends ParserRuleContext { + public typeName(): TypeNameContext { + return this.getRuleContext(0, TypeNameContext); } - public EOF(): TerminalNode { return this.getToken(SchemaParser.EOF, 0); } + public LCURLY(): TerminalNode { return this.getToken(SchemaParser.LCURLY, 0); } + public RCURLY(): TerminalNode { return this.getToken(SchemaParser.RCURLY, 0); } + public WHITESPACE(): TerminalNode[]; + public WHITESPACE(i: number): TerminalNode; + public WHITESPACE(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(SchemaParser.WHITESPACE); + } else { + return this.getToken(SchemaParser.WHITESPACE, i); + } + } + public fieldDefList(): FieldDefListContext | undefined { + return this.tryGetRuleContext(0, FieldDefListContext); + } + public SEMICOLON(): TerminalNode | undefined { return this.tryGetToken(SchemaParser.SEMICOLON, 0); } constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_start; } + public get ruleIndex(): number { return SchemaParser.RULE_objectTypeDefinition; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterStart) { - listener.enterStart(this); + if (listener.enterObjectTypeDefinition) { + listener.enterObjectTypeDefinition(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitStart) { - listener.exitStart(this); + if (listener.exitObjectTypeDefinition) { + listener.exitObjectTypeDefinition(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitStart) { - return visitor.visitStart(this); + if (visitor.visitObjectTypeDefinition) { + return visitor.visitObjectTypeDefinition(this); } else { return visitor.visitChildren(this); } @@ -739,43 +1520,64 @@ export class StartContext extends ParserRuleContext { } -export class TypeDefinitionsContext extends ParserRuleContext { - public typeDefinition(): TypeDefinitionContext { - return this.getRuleContext(0, TypeDefinitionContext); +export class FieldDefListContext extends ParserRuleContext { + public fieldDef(): FieldDefContext[]; + public fieldDef(i: number): FieldDefContext; + public fieldDef(i?: number): FieldDefContext | FieldDefContext[] { + if (i === undefined) { + return this.getRuleContexts(FieldDefContext); + } else { + return this.getRuleContext(i, FieldDefContext); + } + } + public COMMA(): TerminalNode[]; + public COMMA(i: number): TerminalNode; + public COMMA(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(SchemaParser.COMMA); + } else { + return this.getToken(SchemaParser.COMMA, i); + } } - public typeDefinitions(): TypeDefinitionsContext | undefined { - return this.tryGetRuleContext(0, TypeDefinitionsContext); + public SEMICOLON(): TerminalNode[]; + public SEMICOLON(i: number): TerminalNode; + public SEMICOLON(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(SchemaParser.SEMICOLON); + } else { + return this.getToken(SchemaParser.SEMICOLON, i); + } } - public WHITESPACE(): TerminalNode[]; - public WHITESPACE(i: number): TerminalNode; - public WHITESPACE(i?: number): TerminalNode | TerminalNode[] { + public NEWLINE(): TerminalNode[]; + public NEWLINE(i: number): TerminalNode; + public NEWLINE(i?: number): TerminalNode | TerminalNode[] { if (i === undefined) { - return this.getTokens(SchemaParser.WHITESPACE); + return this.getTokens(SchemaParser.NEWLINE); } else { - return this.getToken(SchemaParser.WHITESPACE, i); + return this.getToken(SchemaParser.NEWLINE, i); } } constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_typeDefinitions; } + public get ruleIndex(): number { return SchemaParser.RULE_fieldDefList; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterTypeDefinitions) { - listener.enterTypeDefinitions(this); + if (listener.enterFieldDefList) { + listener.enterFieldDefList(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitTypeDefinitions) { - listener.exitTypeDefinitions(this); + if (listener.exitFieldDefList) { + listener.exitFieldDefList(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitTypeDefinitions) { - return visitor.visitTypeDefinitions(this); + if (visitor.visitFieldDefList) { + return visitor.visitFieldDefList(this); } else { return visitor.visitChildren(this); } @@ -783,32 +1585,65 @@ export class TypeDefinitionsContext extends ParserRuleContext { } -export class TypeDefinitionContext extends ParserRuleContext { +export class IdentifierContext extends ParserRuleContext { public IDENTIFIER(): TerminalNode { return this.getToken(SchemaParser.IDENTIFIER, 0); } - public fieldList(): FieldListContext { - return this.getRuleContext(0, FieldListContext); + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_identifier; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterIdentifier) { + listener.enterIdentifier(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitIdentifier) { + listener.exitIdentifier(this); + } + } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitIdentifier) { + return visitor.visitIdentifier(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class FieldDefContext extends ParserRuleContext { + public identifier(): IdentifierContext { + return this.getRuleContext(0, IdentifierContext); + } + public type(): TypeContext { + return this.getRuleContext(0, TypeContext); } + public QUESTION(): TerminalNode | undefined { return this.tryGetToken(SchemaParser.QUESTION, 0); } constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_typeDefinition; } + public get ruleIndex(): number { return SchemaParser.RULE_fieldDef; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterTypeDefinition) { - listener.enterTypeDefinition(this); + if (listener.enterFieldDef) { + listener.enterFieldDef(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitTypeDefinition) { - listener.exitTypeDefinition(this); + if (listener.exitFieldDef) { + listener.exitFieldDef(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitTypeDefinition) { - return visitor.visitTypeDefinition(this); + if (visitor.visitFieldDef) { + return visitor.visitFieldDef(this); } else { return visitor.visitChildren(this); } @@ -816,43 +1651,49 @@ export class TypeDefinitionContext extends ParserRuleContext { } -export class FieldListContext extends ParserRuleContext { - public field(): FieldContext { - return this.getRuleContext(0, FieldContext); +export class TypeContext extends ParserRuleContext { + public nonUnionType(): NonUnionTypeContext { + return this.getRuleContext(0, NonUnionTypeContext); } - public fieldList(): FieldListContext | undefined { - return this.tryGetRuleContext(0, FieldListContext); + public PIPE(): TerminalNode[]; + public PIPE(i: number): TerminalNode; + public PIPE(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(SchemaParser.PIPE); + } else { + return this.getToken(SchemaParser.PIPE, i); + } } - public WHITESPACE(): TerminalNode[]; - public WHITESPACE(i: number): TerminalNode; - public WHITESPACE(i?: number): TerminalNode | TerminalNode[] { + public type(): TypeContext[]; + public type(i: number): TypeContext; + public type(i?: number): TypeContext | TypeContext[] { if (i === undefined) { - return this.getTokens(SchemaParser.WHITESPACE); + return this.getRuleContexts(TypeContext); } else { - return this.getToken(SchemaParser.WHITESPACE, i); + return this.getRuleContext(i, TypeContext); } } constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_fieldList; } + public get ruleIndex(): number { return SchemaParser.RULE_type; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterFieldList) { - listener.enterFieldList(this); + if (listener.enterType) { + listener.enterType(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitFieldList) { - listener.exitFieldList(this); + if (listener.exitType) { + listener.exitType(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitFieldList) { - return visitor.visitFieldList(this); + if (visitor.visitType) { + return visitor.visitType(this); } else { return visitor.visitChildren(this); } @@ -860,41 +1701,49 @@ export class FieldListContext extends ParserRuleContext { } -export class FieldContext extends ParserRuleContext { - public IDENTIFIER(): TerminalNode { return this.getToken(SchemaParser.IDENTIFIER, 0); } - public fieldType(): FieldTypeContext { - return this.getRuleContext(0, FieldTypeContext); +export class NonUnionTypeContext extends ParserRuleContext { + public nonUnionTypeL2(): NonUnionTypeL2Context { + return this.getRuleContext(0, NonUnionTypeL2Context); } - public WHITESPACE(): TerminalNode[]; - public WHITESPACE(i: number): TerminalNode; - public WHITESPACE(i?: number): TerminalNode | TerminalNode[] { + public LSQUARE(): TerminalNode[]; + public LSQUARE(i: number): TerminalNode; + public LSQUARE(i?: number): TerminalNode | TerminalNode[] { if (i === undefined) { - return this.getTokens(SchemaParser.WHITESPACE); + return this.getTokens(SchemaParser.LSQUARE); } else { - return this.getToken(SchemaParser.WHITESPACE, i); + return this.getToken(SchemaParser.LSQUARE, i); + } + } + public RSQUARE(): TerminalNode[]; + public RSQUARE(i: number): TerminalNode; + public RSQUARE(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(SchemaParser.RSQUARE); + } else { + return this.getToken(SchemaParser.RSQUARE, i); } } constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_field; } + public get ruleIndex(): number { return SchemaParser.RULE_nonUnionType; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterField) { - listener.enterField(this); + if (listener.enterNonUnionType) { + listener.enterNonUnionType(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitField) { - listener.exitField(this); + if (listener.exitNonUnionType) { + listener.exitNonUnionType(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitField) { - return visitor.visitField(this); + if (visitor.visitNonUnionType) { + return visitor.visitNonUnionType(this); } else { return visitor.visitChildren(this); } @@ -902,40 +1751,80 @@ export class FieldContext extends ParserRuleContext { } -export class FieldTypeContext extends ParserRuleContext { - public typeExpression(): TypeExpressionContext { - return this.getRuleContext(0, TypeExpressionContext); +export class NonUnionTypeL2Context extends ParserRuleContext { + public LPAREN(): TerminalNode | undefined { return this.tryGetToken(SchemaParser.LPAREN, 0); } + public type(): TypeContext | undefined { + return this.tryGetRuleContext(0, TypeContext); } - public arraySuffix(): ArraySuffixContext[]; - public arraySuffix(i: number): ArraySuffixContext; - public arraySuffix(i?: number): ArraySuffixContext | ArraySuffixContext[] { - if (i === undefined) { - return this.getRuleContexts(ArraySuffixContext); + public RPAREN(): TerminalNode | undefined { return this.tryGetToken(SchemaParser.RPAREN, 0); } + public objectLiteralType(): ObjectLiteralTypeContext | undefined { + return this.tryGetRuleContext(0, ObjectLiteralTypeContext); + } + public primitiveType(): PrimitiveTypeContext | undefined { + return this.tryGetRuleContext(0, PrimitiveTypeContext); + } + public literalType(): LiteralTypeContext | undefined { + return this.tryGetRuleContext(0, LiteralTypeContext); + } + public yorkieType(): YorkieTypeContext | undefined { + return this.tryGetRuleContext(0, YorkieTypeContext); + } + public typeReference(): TypeReferenceContext | undefined { + return this.tryGetRuleContext(0, TypeReferenceContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_nonUnionTypeL2; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterNonUnionTypeL2) { + listener.enterNonUnionTypeL2(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitNonUnionTypeL2) { + listener.exitNonUnionTypeL2(this); + } + } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitNonUnionTypeL2) { + return visitor.visitNonUnionTypeL2(this); } else { - return this.getRuleContext(i, ArraySuffixContext); + return visitor.visitChildren(this); } } +} + + +export class TypeReferenceContext extends ParserRuleContext { + public typeName(): TypeNameContext { + return this.getRuleContext(0, TypeNameContext); + } constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_fieldType; } + public get ruleIndex(): number { return SchemaParser.RULE_typeReference; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterFieldType) { - listener.enterFieldType(this); + if (listener.enterTypeReference) { + listener.enterTypeReference(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitFieldType) { - listener.exitFieldType(this); + if (listener.exitTypeReference) { + listener.exitTypeReference(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitFieldType) { - return visitor.visitFieldType(this); + if (visitor.visitTypeReference) { + return visitor.visitTypeReference(this); } else { return visitor.visitChildren(this); } @@ -943,34 +1832,62 @@ export class FieldTypeContext extends ParserRuleContext { } -export class TypeExpressionContext extends ParserRuleContext { - public unionType(): UnionTypeContext | undefined { - return this.tryGetRuleContext(0, UnionTypeContext); +export class ObjectLiteralTypeContext extends ParserRuleContext { + public LCURLY(): TerminalNode { return this.getToken(SchemaParser.LCURLY, 0); } + public RCURLY(): TerminalNode { return this.getToken(SchemaParser.RCURLY, 0); } + public fieldDefList(): FieldDefListContext | undefined { + return this.tryGetRuleContext(0, FieldDefListContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); } - public simpleType(): SimpleTypeContext | undefined { - return this.tryGetRuleContext(0, SimpleTypeContext); + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_objectLiteralType; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterObjectLiteralType) { + listener.enterObjectLiteralType(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitObjectLiteralType) { + listener.exitObjectLiteralType(this); + } } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitObjectLiteralType) { + return visitor.visitObjectLiteralType(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class PrimitiveTypeContext extends ParserRuleContext { constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_typeExpression; } + public get ruleIndex(): number { return SchemaParser.RULE_primitiveType; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterTypeExpression) { - listener.enterTypeExpression(this); + if (listener.enterPrimitiveType) { + listener.enterPrimitiveType(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitTypeExpression) { - listener.exitTypeExpression(this); + if (listener.exitPrimitiveType) { + listener.exitPrimitiveType(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitTypeExpression) { - return visitor.visitTypeExpression(this); + if (visitor.visitPrimitiveType) { + return visitor.visitPrimitiveType(this); } else { return visitor.visitChildren(this); } @@ -978,32 +1895,37 @@ export class TypeExpressionContext extends ParserRuleContext { } -export class SimpleTypeContext extends ParserRuleContext { - public primitiveType(): PrimitiveTypeContext | undefined { - return this.tryGetRuleContext(0, PrimitiveTypeContext); +export class LiteralTypeContext extends ParserRuleContext { + public booleanLiteralType(): BooleanLiteralTypeContext | undefined { + return this.tryGetRuleContext(0, BooleanLiteralTypeContext); + } + public numberLiteralType(): NumberLiteralTypeContext | undefined { + return this.tryGetRuleContext(0, NumberLiteralTypeContext); + } + public stringLiteralType(): StringLiteralTypeContext | undefined { + return this.tryGetRuleContext(0, StringLiteralTypeContext); } - public IDENTIFIER(): TerminalNode | undefined { return this.tryGetToken(SchemaParser.IDENTIFIER, 0); } constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_simpleType; } + public get ruleIndex(): number { return SchemaParser.RULE_literalType; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterSimpleType) { - listener.enterSimpleType(this); + if (listener.enterLiteralType) { + listener.enterLiteralType(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitSimpleType) { - listener.exitSimpleType(this); + if (listener.exitLiteralType) { + listener.exitLiteralType(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitSimpleType) { - return visitor.visitSimpleType(this); + if (visitor.visitLiteralType) { + return visitor.visitLiteralType(this); } else { return visitor.visitChildren(this); } @@ -1011,28 +1933,28 @@ export class SimpleTypeContext extends ParserRuleContext { } -export class ArraySuffixContext extends ParserRuleContext { +export class BooleanLiteralTypeContext extends ParserRuleContext { constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_arraySuffix; } + public get ruleIndex(): number { return SchemaParser.RULE_booleanLiteralType; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterArraySuffix) { - listener.enterArraySuffix(this); + if (listener.enterBooleanLiteralType) { + listener.enterBooleanLiteralType(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitArraySuffix) { - listener.exitArraySuffix(this); + if (listener.exitBooleanLiteralType) { + listener.exitBooleanLiteralType(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitArraySuffix) { - return visitor.visitArraySuffix(this); + if (visitor.visitBooleanLiteralType) { + return visitor.visitBooleanLiteralType(this); } else { return visitor.visitChildren(this); } @@ -1040,40 +1962,38 @@ export class ArraySuffixContext extends ParserRuleContext { } -export class UnionTypeContext extends ParserRuleContext { - public unionTypeInner(): UnionTypeInnerContext { - return this.getRuleContext(0, UnionTypeInnerContext); - } - public WHITESPACE(): TerminalNode[]; - public WHITESPACE(i: number): TerminalNode; - public WHITESPACE(i?: number): TerminalNode | TerminalNode[] { +export class NumberLiteralTypeContext extends ParserRuleContext { + public MINUS(): TerminalNode | undefined { return this.tryGetToken(SchemaParser.MINUS, 0); } + public DIGIT(): TerminalNode[]; + public DIGIT(i: number): TerminalNode; + public DIGIT(i?: number): TerminalNode | TerminalNode[] { if (i === undefined) { - return this.getTokens(SchemaParser.WHITESPACE); + return this.getTokens(SchemaParser.DIGIT); } else { - return this.getToken(SchemaParser.WHITESPACE, i); + return this.getToken(SchemaParser.DIGIT, i); } } constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_unionType; } + public get ruleIndex(): number { return SchemaParser.RULE_numberLiteralType; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterUnionType) { - listener.enterUnionType(this); + if (listener.enterNumberLiteralType) { + listener.enterNumberLiteralType(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitUnionType) { - listener.exitUnionType(this); + if (listener.exitNumberLiteralType) { + listener.exitNumberLiteralType(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitUnionType) { - return visitor.visitUnionType(this); + if (visitor.visitNumberLiteralType) { + return visitor.visitNumberLiteralType(this); } else { return visitor.visitChildren(this); } @@ -1081,46 +2001,112 @@ export class UnionTypeContext extends ParserRuleContext { } -export class UnionTypeInnerContext extends ParserRuleContext { - public simpleType(): SimpleTypeContext[]; - public simpleType(i: number): SimpleTypeContext; - public simpleType(i?: number): SimpleTypeContext | SimpleTypeContext[] { - if (i === undefined) { - return this.getRuleContexts(SimpleTypeContext); +export class StringLiteralTypeContext extends ParserRuleContext { + public DOUBLE_QUOTED_STRING(): TerminalNode | undefined { return this.tryGetToken(SchemaParser.DOUBLE_QUOTED_STRING, 0); } + public SINGLE_QUOTED_STRING(): TerminalNode | undefined { return this.tryGetToken(SchemaParser.SINGLE_QUOTED_STRING, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_stringLiteralType; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterStringLiteralType) { + listener.enterStringLiteralType(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitStringLiteralType) { + listener.exitStringLiteralType(this); + } + } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitStringLiteralType) { + return visitor.visitStringLiteralType(this); } else { - return this.getRuleContext(i, SimpleTypeContext); + return visitor.visitChildren(this); } } - public WHITESPACE(): TerminalNode[]; - public WHITESPACE(i: number): TerminalNode; - public WHITESPACE(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(SchemaParser.WHITESPACE); +} + + +export class YorkieTypeContext extends ParserRuleContext { + public yorkieObjectType(): YorkieObjectTypeContext | undefined { + return this.tryGetRuleContext(0, YorkieObjectTypeContext); + } + public yorkieArrayType(): YorkieArrayTypeContext | undefined { + return this.tryGetRuleContext(0, YorkieArrayTypeContext); + } + public yorkieCounterType(): YorkieCounterTypeContext | undefined { + return this.tryGetRuleContext(0, YorkieCounterTypeContext); + } + public yorkieTextType(): YorkieTextTypeContext | undefined { + return this.tryGetRuleContext(0, YorkieTextTypeContext); + } + public yorkieTreeType(): YorkieTreeTypeContext | undefined { + return this.tryGetRuleContext(0, YorkieTreeTypeContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_yorkieType; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterYorkieType) { + listener.enterYorkieType(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitYorkieType) { + listener.exitYorkieType(this); + } + } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitYorkieType) { + return visitor.visitYorkieType(this); } else { - return this.getToken(SchemaParser.WHITESPACE, i); + return visitor.visitChildren(this); } } +} + + +export class YorkieObjectTypeContext extends ParserRuleContext { + public YORKIE_OBJECT(): TerminalNode { return this.getToken(SchemaParser.YORKIE_OBJECT, 0); } + public LT(): TerminalNode { return this.getToken(SchemaParser.LT, 0); } + public GT(): TerminalNode { return this.getToken(SchemaParser.GT, 0); } + public typeReference(): TypeReferenceContext | undefined { + return this.tryGetRuleContext(0, TypeReferenceContext); + } + public objectLiteralType(): ObjectLiteralTypeContext | undefined { + return this.tryGetRuleContext(0, ObjectLiteralTypeContext); + } constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_unionTypeInner; } + public get ruleIndex(): number { return SchemaParser.RULE_yorkieObjectType; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterUnionTypeInner) { - listener.enterUnionTypeInner(this); + if (listener.enterYorkieObjectType) { + listener.enterYorkieObjectType(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitUnionTypeInner) { - listener.exitUnionTypeInner(this); + if (listener.exitYorkieObjectType) { + listener.exitYorkieObjectType(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitUnionTypeInner) { - return visitor.visitUnionTypeInner(this); + if (visitor.visitYorkieObjectType) { + return visitor.visitYorkieObjectType(this); } else { return visitor.visitChildren(this); } @@ -1128,28 +2114,137 @@ export class UnionTypeInnerContext extends ParserRuleContext { } -export class PrimitiveTypeContext extends ParserRuleContext { +export class YorkieArrayTypeContext extends ParserRuleContext { + public YORKIE_ARRAY(): TerminalNode { return this.getToken(SchemaParser.YORKIE_ARRAY, 0); } + public LT(): TerminalNode { return this.getToken(SchemaParser.LT, 0); } + public GT(): TerminalNode { return this.getToken(SchemaParser.GT, 0); } + public typeReference(): TypeReferenceContext | undefined { + return this.tryGetRuleContext(0, TypeReferenceContext); + } + public objectLiteralType(): ObjectLiteralTypeContext | undefined { + return this.tryGetRuleContext(0, ObjectLiteralTypeContext); + } constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override - public get ruleIndex(): number { return SchemaParser.RULE_primitiveType; } + public get ruleIndex(): number { return SchemaParser.RULE_yorkieArrayType; } // @Override public enterRule(listener: SchemaListener): void { - if (listener.enterPrimitiveType) { - listener.enterPrimitiveType(this); + if (listener.enterYorkieArrayType) { + listener.enterYorkieArrayType(this); } } // @Override public exitRule(listener: SchemaListener): void { - if (listener.exitPrimitiveType) { - listener.exitPrimitiveType(this); + if (listener.exitYorkieArrayType) { + listener.exitYorkieArrayType(this); } } // @Override public accept(visitor: SchemaVisitor): Result { - if (visitor.visitPrimitiveType) { - return visitor.visitPrimitiveType(this); + if (visitor.visitYorkieArrayType) { + return visitor.visitYorkieArrayType(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class YorkieCounterTypeContext extends ParserRuleContext { + public YORKIE_COUNTER(): TerminalNode { return this.getToken(SchemaParser.YORKIE_COUNTER, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_yorkieCounterType; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterYorkieCounterType) { + listener.enterYorkieCounterType(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitYorkieCounterType) { + listener.exitYorkieCounterType(this); + } + } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitYorkieCounterType) { + return visitor.visitYorkieCounterType(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class YorkieTextTypeContext extends ParserRuleContext { + public YORKIE_TEXT(): TerminalNode { return this.getToken(SchemaParser.YORKIE_TEXT, 0); } + public LT(): TerminalNode { return this.getToken(SchemaParser.LT, 0); } + public GT(): TerminalNode { return this.getToken(SchemaParser.GT, 0); } + public typeReference(): TypeReferenceContext | undefined { + return this.tryGetRuleContext(0, TypeReferenceContext); + } + public objectLiteralType(): ObjectLiteralTypeContext | undefined { + return this.tryGetRuleContext(0, ObjectLiteralTypeContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_yorkieTextType; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterYorkieTextType) { + listener.enterYorkieTextType(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitYorkieTextType) { + listener.exitYorkieTextType(this); + } + } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitYorkieTextType) { + return visitor.visitYorkieTextType(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class YorkieTreeTypeContext extends ParserRuleContext { + public YORKIE_TREE(): TerminalNode { return this.getToken(SchemaParser.YORKIE_TREE, 0); } + public LT(): TerminalNode { return this.getToken(SchemaParser.LT, 0); } + public GT(): TerminalNode { return this.getToken(SchemaParser.GT, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return SchemaParser.RULE_yorkieTreeType; } + // @Override + public enterRule(listener: SchemaListener): void { + if (listener.enterYorkieTreeType) { + listener.enterYorkieTreeType(this); + } + } + // @Override + public exitRule(listener: SchemaListener): void { + if (listener.exitYorkieTreeType) { + listener.exitYorkieTreeType(this); + } + } + // @Override + public accept(visitor: SchemaVisitor): Result { + if (visitor.visitYorkieTreeType) { + return visitor.visitYorkieTreeType(this); } else { return visitor.visitChildren(this); } diff --git a/antlr/SchemaVisitor.ts b/antlr/SchemaVisitor.ts index b8765e2..e669c6d 100644 --- a/antlr/SchemaVisitor.ts +++ b/antlr/SchemaVisitor.ts @@ -3,18 +3,30 @@ import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor"; -import { StartContext } from "./SchemaParser"; -import { TypeDefinitionsContext } from "./SchemaParser"; -import { TypeDefinitionContext } from "./SchemaParser"; -import { FieldListContext } from "./SchemaParser"; -import { FieldContext } from "./SchemaParser"; -import { FieldTypeContext } from "./SchemaParser"; -import { TypeExpressionContext } from "./SchemaParser"; -import { SimpleTypeContext } from "./SchemaParser"; -import { ArraySuffixContext } from "./SchemaParser"; -import { UnionTypeContext } from "./SchemaParser"; -import { UnionTypeInnerContext } from "./SchemaParser"; +import { DocumentContext } from "./SchemaParser"; +import { DefinitionListContext } from "./SchemaParser"; +import { DefinitionContext } from "./SchemaParser"; +import { TypeNameContext } from "./SchemaParser"; +import { ObjectTypeDefinitionContext } from "./SchemaParser"; +import { FieldDefListContext } from "./SchemaParser"; +import { IdentifierContext } from "./SchemaParser"; +import { FieldDefContext } from "./SchemaParser"; +import { TypeContext } from "./SchemaParser"; +import { NonUnionTypeContext } from "./SchemaParser"; +import { NonUnionTypeL2Context } from "./SchemaParser"; +import { TypeReferenceContext } from "./SchemaParser"; +import { ObjectLiteralTypeContext } from "./SchemaParser"; import { PrimitiveTypeContext } from "./SchemaParser"; +import { LiteralTypeContext } from "./SchemaParser"; +import { BooleanLiteralTypeContext } from "./SchemaParser"; +import { NumberLiteralTypeContext } from "./SchemaParser"; +import { StringLiteralTypeContext } from "./SchemaParser"; +import { YorkieTypeContext } from "./SchemaParser"; +import { YorkieObjectTypeContext } from "./SchemaParser"; +import { YorkieArrayTypeContext } from "./SchemaParser"; +import { YorkieCounterTypeContext } from "./SchemaParser"; +import { YorkieTextTypeContext } from "./SchemaParser"; +import { YorkieTreeTypeContext } from "./SchemaParser"; /** @@ -26,81 +38,95 @@ import { PrimitiveTypeContext } from "./SchemaParser"; */ export interface SchemaVisitor extends ParseTreeVisitor { /** - * Visit a parse tree produced by `SchemaParser.start`. + * Visit a parse tree produced by `SchemaParser.document`. * @param ctx the parse tree * @return the visitor result */ - visitStart?: (ctx: StartContext) => Result; + visitDocument?: (ctx: DocumentContext) => Result; /** - * Visit a parse tree produced by `SchemaParser.typeDefinitions`. + * Visit a parse tree produced by `SchemaParser.definitionList`. * @param ctx the parse tree * @return the visitor result */ - visitTypeDefinitions?: (ctx: TypeDefinitionsContext) => Result; + visitDefinitionList?: (ctx: DefinitionListContext) => Result; /** - * Visit a parse tree produced by `SchemaParser.typeDefinition`. + * Visit a parse tree produced by `SchemaParser.definition`. * @param ctx the parse tree * @return the visitor result */ - visitTypeDefinition?: (ctx: TypeDefinitionContext) => Result; + visitDefinition?: (ctx: DefinitionContext) => Result; /** - * Visit a parse tree produced by `SchemaParser.fieldList`. + * Visit a parse tree produced by `SchemaParser.typeName`. * @param ctx the parse tree * @return the visitor result */ - visitFieldList?: (ctx: FieldListContext) => Result; + visitTypeName?: (ctx: TypeNameContext) => Result; /** - * Visit a parse tree produced by `SchemaParser.field`. + * Visit a parse tree produced by `SchemaParser.objectTypeDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitField?: (ctx: FieldContext) => Result; + visitObjectTypeDefinition?: (ctx: ObjectTypeDefinitionContext) => Result; /** - * Visit a parse tree produced by `SchemaParser.fieldType`. + * Visit a parse tree produced by `SchemaParser.fieldDefList`. * @param ctx the parse tree * @return the visitor result */ - visitFieldType?: (ctx: FieldTypeContext) => Result; + visitFieldDefList?: (ctx: FieldDefListContext) => Result; /** - * Visit a parse tree produced by `SchemaParser.typeExpression`. + * Visit a parse tree produced by `SchemaParser.identifier`. * @param ctx the parse tree * @return the visitor result */ - visitTypeExpression?: (ctx: TypeExpressionContext) => Result; + visitIdentifier?: (ctx: IdentifierContext) => Result; /** - * Visit a parse tree produced by `SchemaParser.simpleType`. + * Visit a parse tree produced by `SchemaParser.fieldDef`. * @param ctx the parse tree * @return the visitor result */ - visitSimpleType?: (ctx: SimpleTypeContext) => Result; + visitFieldDef?: (ctx: FieldDefContext) => Result; /** - * Visit a parse tree produced by `SchemaParser.arraySuffix`. + * Visit a parse tree produced by `SchemaParser.type`. * @param ctx the parse tree * @return the visitor result */ - visitArraySuffix?: (ctx: ArraySuffixContext) => Result; + visitType?: (ctx: TypeContext) => Result; /** - * Visit a parse tree produced by `SchemaParser.unionType`. + * Visit a parse tree produced by `SchemaParser.nonUnionType`. * @param ctx the parse tree * @return the visitor result */ - visitUnionType?: (ctx: UnionTypeContext) => Result; + visitNonUnionType?: (ctx: NonUnionTypeContext) => Result; /** - * Visit a parse tree produced by `SchemaParser.unionTypeInner`. + * Visit a parse tree produced by `SchemaParser.nonUnionTypeL2`. * @param ctx the parse tree * @return the visitor result */ - visitUnionTypeInner?: (ctx: UnionTypeInnerContext) => Result; + visitNonUnionTypeL2?: (ctx: NonUnionTypeL2Context) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.typeReference`. + * @param ctx the parse tree + * @return the visitor result + */ + visitTypeReference?: (ctx: TypeReferenceContext) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.objectLiteralType`. + * @param ctx the parse tree + * @return the visitor result + */ + visitObjectLiteralType?: (ctx: ObjectLiteralTypeContext) => Result; /** * Visit a parse tree produced by `SchemaParser.primitiveType`. @@ -108,5 +134,75 @@ export interface SchemaVisitor extends ParseTreeVisitor { * @return the visitor result */ visitPrimitiveType?: (ctx: PrimitiveTypeContext) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.literalType`. + * @param ctx the parse tree + * @return the visitor result + */ + visitLiteralType?: (ctx: LiteralTypeContext) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.booleanLiteralType`. + * @param ctx the parse tree + * @return the visitor result + */ + visitBooleanLiteralType?: (ctx: BooleanLiteralTypeContext) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.numberLiteralType`. + * @param ctx the parse tree + * @return the visitor result + */ + visitNumberLiteralType?: (ctx: NumberLiteralTypeContext) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.stringLiteralType`. + * @param ctx the parse tree + * @return the visitor result + */ + visitStringLiteralType?: (ctx: StringLiteralTypeContext) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.yorkieType`. + * @param ctx the parse tree + * @return the visitor result + */ + visitYorkieType?: (ctx: YorkieTypeContext) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.yorkieObjectType`. + * @param ctx the parse tree + * @return the visitor result + */ + visitYorkieObjectType?: (ctx: YorkieObjectTypeContext) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.yorkieArrayType`. + * @param ctx the parse tree + * @return the visitor result + */ + visitYorkieArrayType?: (ctx: YorkieArrayTypeContext) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.yorkieCounterType`. + * @param ctx the parse tree + * @return the visitor result + */ + visitYorkieCounterType?: (ctx: YorkieCounterTypeContext) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.yorkieTextType`. + * @param ctx the parse tree + * @return the visitor result + */ + visitYorkieTextType?: (ctx: YorkieTextTypeContext) => Result; + + /** + * Visit a parse tree produced by `SchemaParser.yorkieTreeType`. + * @param ctx the parse tree + * @return the visitor result + */ + visitYorkieTreeType?: (ctx: YorkieTreeTypeContext) => Result; }