diff --git a/.run/kipper run.run.xml b/.run/kipper run.run.xml index 612c7c3f3..1c8bd0784 100644 --- a/.run/kipper run.run.xml +++ b/.run/kipper run.run.xml @@ -1,7 +1,5 @@ - - - + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 7adc0075c..dbdad7884 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,8 +18,49 @@ To use development versions of Kipper download the ### Added +- Implemented internal representation for custom types such as objects, interfaces and classes. This change means that + the entire core type system has been reworked and adjusted to also support custom types as well as complex types + (objects, arrays etc.). This does not inheritely add functionality but serves as the stepping stone for the + implementation of all custom types in the future. ([#524](https://github.com/Kipper-Lang/Kipper/issues/524)) +- New module: + - `semantics/runtime-built-ins`, which contains runtime built-in functions, variables and types. + - `semantics/runtime-internals`, which contains the runtime internal functions. + - `semantics/types`, which contains the runtime types. +- New classes: + - `InterfaceDeclaration`, which represents an AST interface declaration. + - `ClassDeclaration`, which represents an AST class declaration. + - `BuiltInType`, which represents a built-in type. + - `CustomType`, which represents a user defined type. + - `ScopeTypeDeclaration`, which represents a scope type declaration. + - `UniverseTypeDeclaration`, which represents the universe, where all built-in types, functions and variables are + declared. This serves as the parent of the global scope. + - `CustomType`, which is a class extending from `ProcessedType` and implementing the functionality for a custom type such as a interface or class. +- New errors: + - `TypeCanNotBeUsedForTypeCheckingError`, which is thrown when a type is used for type checking, but is not a valid + type. This is an error indicating an invalid logic that should be fixed. +- New interfaces: + - `InterfaceDeclarationSemantics`, which represents the semantics of an interface declaration. + - `InterfaceDeclarationTypeSemantics`, which represents the type semantics of an interface declaration. + - `ClassDeclarationSemantics`, which represents the semantics of a class declaration. + - `ClassDeclarationTypeSemantics`, which represents the type semantics of a class declaration. + - `TypeDeclaration`, which represents a type declaration. This is an abstract base class for all type declarations. + - `TypeDeclarationSemantics`, which represents the semantics of a type declaration. + - `TypeDeclarationTypeSemantics`, which represents the type semantics of a type declaration. + - `CompilableType`, which represents a type that can be compiled. + ### Changed +- Changed type from interface to class: + - `InternalFunction`, which represents an internal function. + - `BuiltInFunction`, which represents a built-in function. + - `InternalFunctionArgument`, which represents an internal function argument. + - `BuiltInVariable`, which represents a built-in variable. +- Renamed: + - Module `analysis` to `semantics`. + - Class `UncheckedType` to `RawType`. + - Class `CheckedType` to `ProcessedType`. + - Class `UndefinedCustomType` to `UndefinedType`. + ### Fixed ### Deprecated @@ -32,7 +73,7 @@ To use development versions of Kipper download the ### Added -- Implemented Processing for File Scoped Pragmas ([#480](https://github.com/Kipper-Lang/Kipper/issues/480)) +- Implemented Processing for File Scoped pragmas ([#480](https://github.com/Kipper-Lang/Kipper/issues/480)) - Added Lambda Expressions, which are anonymous functions that can be used as expressions. ([#572](https://github.com/Kipper-Lang/Kipper/issues/572)) - Implemented Bitwise Operations (`&`, `|`, `^`, `~`, `<<`, `>>`, `>>>`). diff --git a/kipper/cli/src/commands/compile.ts b/kipper/cli/src/commands/compile.ts index 40385faa3..cfbb8723e 100644 --- a/kipper/cli/src/commands/compile.ts +++ b/kipper/cli/src/commands/compile.ts @@ -150,10 +150,6 @@ export default class Compile extends Command { defaultOptimisationOptions.optimiseBuiltIns, }, recover: flags["recover"] ?? preExistingCompileConfig?.recover ?? EvaluatedCompileConfig.defaults.recover, - abortOnFirstError: - flags["abort-on-first-error"] ?? - preExistingCompileConfig?.abortOnFirstError ?? - EvaluatedCompileConfig.defaults.abortOnFirstError, } as CompileConfig, }, }; diff --git a/kipper/config/src/evaluated-kipper-config-file.ts b/kipper/config/src/evaluated-kipper-config-file.ts index 532ecf6c1..f09c6093c 100644 --- a/kipper/config/src/evaluated-kipper-config-file.ts +++ b/kipper/config/src/evaluated-kipper-config-file.ts @@ -1,4 +1,4 @@ -import type { EvaluatedConfigValue } from "./abstract"; +import { EvaluatedConfigValue } from "./abstract"; import type { EvaluatedConfigFile } from "./abstract"; import type * as semver from "semver"; import type { CompileConfig, KipperCompileTarget } from "@kipper/core"; diff --git a/kipper/core/KipperLexer.g4 b/kipper/core/KipperLexer.g4 index c10e18453..089b562ce 100644 --- a/kipper/core/KipperLexer.g4 +++ b/kipper/core/KipperLexer.g4 @@ -68,7 +68,7 @@ Else : 'else'; // for - loop For : 'for'; -// Enum Variable +// enums Enum : 'enum'; // function-related @@ -77,6 +77,10 @@ Return : 'return'; CallFunc : 'call'; RetIndicator : '->'; +// class and interface-related +Class : 'class'; +Interface : 'interface'; + // boolean constants True : 'true'; False : 'false'; diff --git a/kipper/core/KipperLexer.tokens b/kipper/core/KipperLexer.tokens index 7c4c655e8..a380f4448 100644 --- a/kipper/core/KipperLexer.tokens +++ b/kipper/core/KipperLexer.tokens @@ -21,67 +21,69 @@ DefFunc=20 Return=21 CallFunc=22 RetIndicator=23 -True=24 -False=25 -Typeof=26 -Void=27 -Null=28 -Undefined=29 -Comma=30 -SemiColon=31 -QuestionMark=32 -Colon=33 -LeftParen=34 -RightParen=35 -LeftBracket=36 -RightBracket=37 -FStringExpEnd=38 -LeftBrace=39 -RightBrace=40 -Plus=41 -PlusPlus=42 -Minus=43 -MinusMinus=44 -Star=45 -Div=46 -Mod=47 -PowerTo=48 -AndAnd=49 -OrOr=50 -Not=51 -Assign=52 -PlusAssign=53 -MinusAssign=54 -StarAssign=55 -DivAssign=56 -ModAssign=57 -Equal=58 -NotEqual=59 -Less=60 -LessEqual=61 -Greater=62 -GreaterEqual=63 -BitwiseAnd=64 -BitwiseOr=65 -BitwiseXor=66 -BitwiseNot=67 -BitwiseZeroFillLeftShift=68 -BitwiseSignedRightShift=69 -BitwiseZeroFillRightShift=70 -Dot=71 -Identifier=72 -IntegerConstant=73 -SingleQuoteStringLiteral=74 -DoubleQuoteStringLiteral=75 -FloatingConstant=76 -Whitespace=77 -Newline=78 -FStringSingleQuoteStart=79 -FStringDoubleQuoteStart=80 -FStringSingleQuoteEnd=81 -FStringSingleQuoteAtom=82 -FStringDoubleQuoteEnd=83 -FStringDoubleQuoteAtom=84 +Class=24 +Interface=25 +True=26 +False=27 +Typeof=28 +Void=29 +Null=30 +Undefined=31 +Comma=32 +SemiColon=33 +QuestionMark=34 +Colon=35 +LeftParen=36 +RightParen=37 +LeftBracket=38 +RightBracket=39 +FStringExpEnd=40 +LeftBrace=41 +RightBrace=42 +Plus=43 +PlusPlus=44 +Minus=45 +MinusMinus=46 +Star=47 +Div=48 +Mod=49 +PowerTo=50 +AndAnd=51 +OrOr=52 +Not=53 +Assign=54 +PlusAssign=55 +MinusAssign=56 +StarAssign=57 +DivAssign=58 +ModAssign=59 +Equal=60 +NotEqual=61 +Less=62 +LessEqual=63 +Greater=64 +GreaterEqual=65 +BitwiseAnd=66 +BitwiseOr=67 +BitwiseXor=68 +BitwiseNot=69 +BitwiseZeroFillLeftShift=70 +BitwiseSignedRightShift=71 +BitwiseZeroFillRightShift=72 +Dot=73 +Identifier=74 +IntegerConstant=75 +SingleQuoteStringLiteral=76 +DoubleQuoteStringLiteral=77 +FloatingConstant=78 +Whitespace=79 +Newline=80 +FStringSingleQuoteStart=81 +FStringDoubleQuoteStart=82 +FStringSingleQuoteEnd=83 +FStringSingleQuoteAtom=84 +FStringDoubleQuoteEnd=85 +FStringDoubleQuoteAtom=86 'const'=5 'var'=6 'as'=7 @@ -101,50 +103,52 @@ FStringDoubleQuoteAtom=84 'return'=21 'call'=22 '->'=23 -'true'=24 -'false'=25 -'typeof'=26 -'void'=27 -'null'=28 -'undefined'=29 -','=30 -';'=31 -'?'=32 -':'=33 -'('=34 -')'=35 -'['=36 -']'=37 -'{'=39 -'}'=40 -'+'=41 -'++'=42 -'-'=43 -'--'=44 -'*'=45 -'/'=46 -'%'=47 -'**'=48 -'&&'=49 -'||'=50 -'!'=51 -'='=52 -'+='=53 -'-='=54 -'*='=55 -'/='=56 -'%='=57 -'=='=58 -'!='=59 -'<'=60 -'<='=61 -'>'=62 -'>='=63 -'&'=64 -'|'=65 -'^'=66 -'~'=67 -'<<'=68 -'>>'=69 -'>>>'=70 -'.'=71 +'class'=24 +'interface'=25 +'true'=26 +'false'=27 +'typeof'=28 +'void'=29 +'null'=30 +'undefined'=31 +','=32 +';'=33 +'?'=34 +':'=35 +'('=36 +')'=37 +'['=38 +']'=39 +'{'=41 +'}'=42 +'+'=43 +'++'=44 +'-'=45 +'--'=46 +'*'=47 +'/'=48 +'%'=49 +'**'=50 +'&&'=51 +'||'=52 +'!'=53 +'='=54 +'+='=55 +'-='=56 +'*='=57 +'/='=58 +'%='=59 +'=='=60 +'!='=61 +'<'=62 +'<='=63 +'>'=64 +'>='=65 +'&'=66 +'|'=67 +'^'=68 +'~'=69 +'<<'=70 +'>>'=71 +'>>>'=72 +'.'=73 diff --git a/kipper/core/KipperParser.g4 b/kipper/core/KipperParser.g4 index 7f55555fb..2588eb8f7 100644 --- a/kipper/core/KipperParser.g4 +++ b/kipper/core/KipperParser.g4 @@ -42,13 +42,11 @@ blockItem declaration : variableDeclaration SemiColon - | functionDeclaration SemiColon? + | functionDeclaration + | interfaceDeclaration + | classDeclaration ; -functionDeclaration - : 'def' declarator '(' parameterList? ')' '->' typeSpecifierExpression compoundStatement? - ; - variableDeclaration : storageTypeSpecifier initDeclarator ; @@ -58,6 +56,14 @@ storageTypeSpecifier | 'const' ; +initDeclarator + : declarator ':' typeSpecifierExpression ('=' initializer)? + ; + +initializer + : assignmentExpression + ; + declarator : directDeclarator ; @@ -66,22 +72,25 @@ directDeclarator : Identifier ; -initDeclarator - : declarator ':' typeSpecifierExpression ('=' initializer)? - ; +functionDeclaration + : 'def' declarator '(' parameterList? ')' '->' typeSpecifierExpression compoundStatement? + ; parameterList : parameterDeclaration (',' parameterDeclaration)* - // Note: Args and Kwargs, like in Python will be added later ; parameterDeclaration : declarator ':' typeSpecifierExpression ; -initializer - : assignmentExpression - ; +interfaceDeclaration + : 'interface' Identifier '{' '}' + ; + +classDeclaration + : 'class' Identifier '{' '}' + ; // -- Statements diff --git a/kipper/core/KipperParser.tokens b/kipper/core/KipperParser.tokens index 7c4c655e8..a380f4448 100644 --- a/kipper/core/KipperParser.tokens +++ b/kipper/core/KipperParser.tokens @@ -21,67 +21,69 @@ DefFunc=20 Return=21 CallFunc=22 RetIndicator=23 -True=24 -False=25 -Typeof=26 -Void=27 -Null=28 -Undefined=29 -Comma=30 -SemiColon=31 -QuestionMark=32 -Colon=33 -LeftParen=34 -RightParen=35 -LeftBracket=36 -RightBracket=37 -FStringExpEnd=38 -LeftBrace=39 -RightBrace=40 -Plus=41 -PlusPlus=42 -Minus=43 -MinusMinus=44 -Star=45 -Div=46 -Mod=47 -PowerTo=48 -AndAnd=49 -OrOr=50 -Not=51 -Assign=52 -PlusAssign=53 -MinusAssign=54 -StarAssign=55 -DivAssign=56 -ModAssign=57 -Equal=58 -NotEqual=59 -Less=60 -LessEqual=61 -Greater=62 -GreaterEqual=63 -BitwiseAnd=64 -BitwiseOr=65 -BitwiseXor=66 -BitwiseNot=67 -BitwiseZeroFillLeftShift=68 -BitwiseSignedRightShift=69 -BitwiseZeroFillRightShift=70 -Dot=71 -Identifier=72 -IntegerConstant=73 -SingleQuoteStringLiteral=74 -DoubleQuoteStringLiteral=75 -FloatingConstant=76 -Whitespace=77 -Newline=78 -FStringSingleQuoteStart=79 -FStringDoubleQuoteStart=80 -FStringSingleQuoteEnd=81 -FStringSingleQuoteAtom=82 -FStringDoubleQuoteEnd=83 -FStringDoubleQuoteAtom=84 +Class=24 +Interface=25 +True=26 +False=27 +Typeof=28 +Void=29 +Null=30 +Undefined=31 +Comma=32 +SemiColon=33 +QuestionMark=34 +Colon=35 +LeftParen=36 +RightParen=37 +LeftBracket=38 +RightBracket=39 +FStringExpEnd=40 +LeftBrace=41 +RightBrace=42 +Plus=43 +PlusPlus=44 +Minus=45 +MinusMinus=46 +Star=47 +Div=48 +Mod=49 +PowerTo=50 +AndAnd=51 +OrOr=52 +Not=53 +Assign=54 +PlusAssign=55 +MinusAssign=56 +StarAssign=57 +DivAssign=58 +ModAssign=59 +Equal=60 +NotEqual=61 +Less=62 +LessEqual=63 +Greater=64 +GreaterEqual=65 +BitwiseAnd=66 +BitwiseOr=67 +BitwiseXor=68 +BitwiseNot=69 +BitwiseZeroFillLeftShift=70 +BitwiseSignedRightShift=71 +BitwiseZeroFillRightShift=72 +Dot=73 +Identifier=74 +IntegerConstant=75 +SingleQuoteStringLiteral=76 +DoubleQuoteStringLiteral=77 +FloatingConstant=78 +Whitespace=79 +Newline=80 +FStringSingleQuoteStart=81 +FStringDoubleQuoteStart=82 +FStringSingleQuoteEnd=83 +FStringSingleQuoteAtom=84 +FStringDoubleQuoteEnd=85 +FStringDoubleQuoteAtom=86 'const'=5 'var'=6 'as'=7 @@ -101,50 +103,52 @@ FStringDoubleQuoteAtom=84 'return'=21 'call'=22 '->'=23 -'true'=24 -'false'=25 -'typeof'=26 -'void'=27 -'null'=28 -'undefined'=29 -','=30 -';'=31 -'?'=32 -':'=33 -'('=34 -')'=35 -'['=36 -']'=37 -'{'=39 -'}'=40 -'+'=41 -'++'=42 -'-'=43 -'--'=44 -'*'=45 -'/'=46 -'%'=47 -'**'=48 -'&&'=49 -'||'=50 -'!'=51 -'='=52 -'+='=53 -'-='=54 -'*='=55 -'/='=56 -'%='=57 -'=='=58 -'!='=59 -'<'=60 -'<='=61 -'>'=62 -'>='=63 -'&'=64 -'|'=65 -'^'=66 -'~'=67 -'<<'=68 -'>>'=69 -'>>>'=70 -'.'=71 +'class'=24 +'interface'=25 +'true'=26 +'false'=27 +'typeof'=28 +'void'=29 +'null'=30 +'undefined'=31 +','=32 +';'=33 +'?'=34 +':'=35 +'('=36 +')'=37 +'['=38 +']'=39 +'{'=41 +'}'=42 +'+'=43 +'++'=44 +'-'=45 +'--'=46 +'*'=47 +'/'=48 +'%'=49 +'**'=50 +'&&'=51 +'||'=52 +'!'=53 +'='=54 +'+='=55 +'-='=56 +'*='=57 +'/='=58 +'%='=59 +'=='=60 +'!='=61 +'<'=62 +'<='=63 +'>'=64 +'>='=65 +'&'=66 +'|'=67 +'^'=68 +'~'=69 +'<<'=70 +'>>'=71 +'>>>'=72 +'.'=73 diff --git a/kipper/core/src/compiler/analysis/symbol-table/entry/scope-function-declaration.ts b/kipper/core/src/compiler/analysis/symbol-table/entry/scope-function-declaration.ts deleted file mode 100644 index a1e86bed7..000000000 --- a/kipper/core/src/compiler/analysis/symbol-table/entry/scope-function-declaration.ts +++ /dev/null @@ -1,107 +0,0 @@ -/** - * A symbol table entry for a function declaration. - * @since 0.10.0 - */ -import type { - FunctionDeclaration, - FunctionDeclarationSemantics, - FunctionDeclarationTypeSemantics, - ParameterDeclaration, -} from "../../../ast"; -import { ScopeDeclaration } from "./scope-declaration"; -import { CheckedType } from "../../type"; - -/** - * Represents the definition of a function inside a {@link Scope}. - * @since 0.1.2 - */ -export class ScopeFunctionDeclaration extends ScopeDeclaration { - private readonly _node: FunctionDeclaration; - - public constructor(node: FunctionDeclaration) { - super(); - this._node = node; - } - - /** - * The semantic data of this declaration. - * @throws UndefinedSemanticsError If this is accessed, before semantic analysis was performed. - * @private - */ - private get semanticData(): FunctionDeclarationSemantics { - return this._node.getSemanticData(); - } - - /** - * The type data of this declaration. - * @throws UndefinedSemanticsError If this is accessed, before type checking was performed. - * @private - */ - private get typeData(): FunctionDeclarationTypeSemantics { - return this._node.getTypeSemanticData(); - } - - /** - * Returns the {@link FunctionDeclaration AST node} this scope function declaration bases on. - */ - public get node(): FunctionDeclaration { - return this._node; - } - - /** - * The identifier of this function. - */ - public get identifier(): string { - return this.semanticData.identifier; - } - - /** - * The type of this function. This is always "func". - * @since 0.10.0 - */ - public get type(): CheckedType { - return CheckedType.fromCompilableType("func"); - } - - /** - * The return type of this function. This can be every {@link KipperType} except {@link KipperFuncType}. - */ - public get returnType(): CheckedType { - return this.typeData.returnType; - } - - /** - * The parameters that are accepted inside this function. These are represented using the {@link ParameterDeclaration} - * class. - * - * The index in the array represents the position inside the function. Meaning the first item in the array maps to - * the first parameter inside the function. - */ - public get params(): Array { - return this.semanticData.params; - } - - /** - * Returns whether the function declaration is defined and has a function body set during declaration. - * @since 0.3.0 - */ - public get isDefined(): boolean { - return this.semanticData.isDefined; - } - - /** - * Returns whether the function declaration has a value. - * @since 0.10.0 - */ - public get hasValue(): boolean { - return this.isDefined; - } - - /** - * Returns whether the declaration has a callable value (function). - * @since 0.10.0 - */ - public get isCallable(): boolean { - return true; - } -} diff --git a/kipper/core/src/compiler/analysis/symbol-table/entry/scope-variable-declaration.ts b/kipper/core/src/compiler/analysis/symbol-table/entry/scope-variable-declaration.ts deleted file mode 100644 index 45ef11b2f..000000000 --- a/kipper/core/src/compiler/analysis/symbol-table/entry/scope-variable-declaration.ts +++ /dev/null @@ -1,107 +0,0 @@ -/** - * A symbol table entry for a variable declaration. - * @since 0.10.0 - */ -import type { VariableDeclaration, VariableDeclarationSemantics, VariableDeclarationTypeSemantics } from "../../../ast"; -import type { KipperStorageType } from "../../../const"; -import type { Scope } from "../index"; -import type { CheckedType } from "../../type"; -import { ScopeDeclaration } from "./scope-declaration"; - -/** - * Represents a variable scope entry that may be a child of the global scope or local scope. - * @since 0.1.0 - */ -export class ScopeVariableDeclaration extends ScopeDeclaration { - private readonly _node: VariableDeclaration; - - /** - * Returns whether the variable has been updated after its initial declaration. - * @since 0.10.0 - */ - public valueWasUpdated: boolean = false; - - public constructor(node: VariableDeclaration) { - super(); - this._node = node; - } - - /** - * The semantic data of this declaration. - * @throws UndefinedSemanticsError If this is accessed, before semantic analysis was performed. - * @private - */ - private get semanticData(): VariableDeclarationSemantics { - return this._node.getSemanticData(); - } - - /** - * The type data of this declaration. - * @throws UndefinedSemanticsError If this is accessed, before type checking was performed. - * @private - */ - private get typeData(): VariableDeclarationTypeSemantics { - return this._node.getTypeSemanticData(); - } - - /** - * Returns the {@link VariableDeclaration AST node} this scope declaration bases on. - */ - public get node(): VariableDeclaration { - return this._node; - } - - /** - * The identifier of this variable. - */ - public get identifier(): string { - return this.semanticData.identifier; - } - - /** - * The value type of this variable. - */ - public get type(): CheckedType { - return this.typeData.valueType; - } - - /** - * The storage type of this variable. - */ - public get storageType(): KipperStorageType { - return this.semanticData.storageType; - } - - /** - * Returns the scope associated with this {@link ScopeDeclaration}. - */ - public get scope(): Scope { - return this.semanticData.scope; - } - - /** - * Returns whether the variable declaration is defined and has a value set during declaration. - */ - public get isDefined(): boolean { - return this.semanticData.isDefined; - } - - /** - * Returns whether the variable declaration has a value. - * - * This is different from {@link isDefined}, since this also considers variable assignments *after* the initial - * declaration. - * @since 0.10.0 - */ - public get hasValue(): boolean { - return this.isDefined || this.valueWasUpdated; - } - - /** - * Returns whether the declaration has a callable value (function). - * @since 0.10.0 - */ - public get isCallable(): boolean { - return this.type.kipperType === "func"; - } -} diff --git a/kipper/core/src/compiler/analysis/type.ts b/kipper/core/src/compiler/analysis/type.ts deleted file mode 100644 index 32466c5a9..000000000 --- a/kipper/core/src/compiler/analysis/type.ts +++ /dev/null @@ -1,148 +0,0 @@ -/** - * A type that has not been checked yet and may contain an invalid or unknown type. - * @since 0.10.0 - */ -import type { KipperCompilableType, KipperType } from "../const"; -import { TypeNotCompilableError } from "../../errors"; - -/** - * Represents an undefined custom type that was specified by the user, but can not be evaluated. - * - * This is used to represent an invalid type that can not be used for type checking. If a type like this is encountered, - * then the type checking will silently fail, as this type should have already thrown an error. - * @since 0.10.0 - */ -export class UndefinedCustomType { - constructor(public readonly identifier: string) {} -} - -/** - * The abstract base type of a general type that may exist/be valid, but also - * may not. This is a general representation to store a type's information - * in the {@link CompilableASTNode.semanticData semantic data} and - * {@link CompilableASTNode.typeData type data} of an {@link CompilableASTNode}. - * @since 0.10.0 - */ -export abstract class Type { - protected readonly _identifier: string; - - protected constructor(identifier: string) { - this._identifier = identifier; - } - - /** - * The identifier of this type. - * @since 0.10.0 - */ - public get identifier(): string { - return this._identifier; - } -} - -/** - * An unchecked type wrapper that may contain any type, even if it does not exist or is invalid. - * @since 0.10.0 - */ -export class UncheckedType extends Type { - constructor(identifier: string) { - super(identifier); - } - - /** - * The identifier of this type. - * - * This identifier has not been type-checked yet, and may not exist/be valid. - * @since 0.10.0 - */ - public get identifier(): string { - return super.identifier; - } -} - -/** - * A wrapper class for a {@link KipperType} that is used to properly represent a type during type checking. This is - * primarily intended to check to handle invalid/undefined types and continue with type checking despite their - * existence. - * - * This type may be used for a compilation if the field {@link CheckedType.isCompilable isCompilable} is true. - * @since 0.10.0 - */ -export class CheckedType extends Type { - protected readonly _kipperType: KipperType; - protected readonly _isCompilable: boolean; - - private constructor(identifier: string, kipperType: KipperType) { - super(identifier); - this._kipperType = kipperType; - this._isCompilable = !(this._kipperType instanceof UndefinedCustomType); - } - - /** - * Creates a new {@link CheckedType} instance based on the passed {@link KipperType}. - * - * If the type is invalid, the function will still return a {@link CheckedType}, but the field - * {@link CheckedType.isCompilable isCompilable} will be false and the instance WILL NOT be usable for a compilation. - */ - public static fromKipperType(kipperType: KipperType): CheckedType { - return new CheckedType(kipperType instanceof UndefinedCustomType ? kipperType.identifier : kipperType, kipperType); - } - - /** - * Creates a new instance of this class using the given {@link kipperType}. - * - * This instance will ALWAYS be compilable, since the type {@link KipperCompilableType} automatically excludes any - * undefined/invalid types to be stored in this class. - * @param kipperType The type to use for the created of a checked type. - */ - public static fromCompilableType(kipperType: KipperCompilableType): CheckedType { - return new CheckedType(kipperType, kipperType); - } - - /** - * The identifier of this type. - * - * If {@link kipperType} is of type {@link UndefinedCustomType}, then this will return the invalid - * {@link UndefinedCustomType.identifier type identifier} of {@link UndefinedCustomType}. - */ - public get identifier(): string { - return this._identifier; - } - - /** - * The {@link identifier} in a {@link KipperType} format. - * - * This mainly differentiates from {@link identifier} by possibly returning the class {@link UndefinedCustomType}, - * which represents an invalid type that should still be stored though. - */ - public get kipperType(): KipperType { - return this._kipperType; - } - - /** - * Returns whether the type is compilable. - * - * This function exists, since during type checking an undefined/invalid type may be encountered that should still - * be stored using this class though (but NOT compiled!). - * @since 0.10.0 - */ - public get isCompilable(): boolean { - return this._isCompilable; - } - - /** - * Gets the compilable type for this type. - * - * This function throws an error instead of returning undefined, since it's intended to be used in circumstances, - * where only due to a bug the type is not compilable. As such, it makes sense to strictly assert it will be - * compilable, unless an error occurs. - * @throws UndefinedCustomType If the {@link isCompilable} is false, which - * should only occur if the identifier is of type {@link UndefinedCustomType}. - * @since 0.10.0 - */ - public getCompilableType(): KipperCompilableType { - if (!this.isCompilable) { - throw new TypeNotCompilableError(); - } - return this.kipperType; - } -} diff --git a/kipper/core/src/compiler/ast/analysable-ast-node.ts b/kipper/core/src/compiler/ast/analysable-ast-node.ts index b71a175ed..af25342f8 100644 --- a/kipper/core/src/compiler/ast/analysable-ast-node.ts +++ b/kipper/core/src/compiler/ast/analysable-ast-node.ts @@ -14,7 +14,7 @@ import { MissingRequiredSemanticDataError } from "../../errors"; import type { KipperProgramContext } from "../program-ctx"; import type { RootASTNode } from "./nodes/root-ast-node"; import type { EvaluatedCompileConfig } from "../compile-config"; -import { handleSemanticError } from "../analysis"; +import { handleSemanticError } from "../semantics"; /** * An eligible parent for an analysable AST node. @@ -39,11 +39,7 @@ export abstract class AnalysableASTNode< extends ParserASTNode implements TargetAnalysableNode { - protected override _children: Array; - protected override _parent: AnalysableNodeParent; - protected _errors: Array; - protected _skippedSemanticAnalysis: boolean; - protected _skippedSemanticTypeChecking: boolean; + abstract readonly targetSemanticAnalysis: TargetASTNodeSemanticAnalyser | undefined; protected _skippedTargetSemanticAnalysis: boolean; protected constructor(antlrCtx: KipperParserRuleContext, parent: AnalysableNodeParent) { @@ -56,13 +52,7 @@ export abstract class AnalysableASTNode< this._skippedTargetSemanticAnalysis = false; } - /** - * Returns the {@link CompilableASTNode parent} that has this node as a child. - * @since 0.8.0 - */ - public get parent(): AnalysableNodeParent { - return this._parent; - } + protected override _children: Array; /** * The children of this AST node. @@ -72,21 +62,17 @@ export abstract class AnalysableASTNode< return this._children; } + protected override _parent: AnalysableNodeParent; + /** - * The file context instance containing the metadata for the listener and this AST node. + * Returns the {@link CompilableASTNode parent} that has this node as a child. * @since 0.8.0 */ - public get programCtx(): KipperProgramContext { - return this.parent.programCtx; + public get parent(): AnalysableNodeParent { + return this._parent; } - /** - * The compilation config for the program of this AST node. - * @since 0.10.0 - */ - public get compileConfig(): EvaluatedCompileConfig { - return this.programCtx.compileConfig; - } + protected _errors: Array; /** * The errors that were caused by this node. Includes all errors from children. @@ -96,28 +82,7 @@ export abstract class AnalysableASTNode< return [...this._errors, ...this._children.flatMap((child) => child.errors)]; } - /** - * Adds the specified {@link error} to the list of errors caused by this node. - * - * This is not the same as {@link KipperProgramContext.reportError}, since that function automatically logs the error - * as well and this function does not! This is only intended to keep track if a node has failed. - * @param error The error to add. - */ - public addError(error: KipperError) { - this._errors.push(error); - } - - /** - * Returns true if the {@link this.primarySemanticAnalysis semantic analysis} or - * {@link this.primarySemanticTypeChecking type checking} of {@link CompilableASTNode this node} or any - * {@link children children nodes} failed. - * - * This indicates that the node is not valid and can not be translated. - * @since 0.10.0 - */ - public get hasFailed(): boolean { - return this.errors.length > 0; - } + protected _skippedSemanticAnalysis: boolean; /** * Returns true if the {@link this.primarySemanticAnalysis semantic analysis} of {@link CompilableASTNode this node} @@ -128,6 +93,8 @@ export abstract class AnalysableASTNode< return this._skippedSemanticAnalysis; } + protected _skippedSemanticTypeChecking: boolean; + /** * Returns true if the {@link this.primarySemanticTypeChecking type checking} of {@link CompilableASTNode this node} * was skipped, due to required semantic data being missing. This indicates that the node is impossible to type check @@ -139,12 +106,42 @@ export abstract class AnalysableASTNode< } /** - * Handles the specified error that occurred during the semantic analysis of this node in a standardised way. - * @param error The error to handle. + * The file context instance containing the metadata for the listener and this AST node. + * @since 0.8.0 + */ + public get programCtx(): KipperProgramContext { + return this.parent.programCtx; + } + + /** + * The compilation config for the program of this AST node. * @since 0.10.0 */ - protected handleSemanticError(error: Error | KipperError): void { - handleSemanticError(this, error); + public get compileConfig(): EvaluatedCompileConfig { + return this.programCtx.compileConfig; + } + + /** + * Returns true if the {@link this.primarySemanticAnalysis semantic analysis} or + * {@link this.primarySemanticTypeChecking type checking} of {@link CompilableASTNode this node} or any + * {@link children children nodes} failed. + * + * This indicates that the node is not valid and can not be translated. + * @since 0.10.0 + */ + public get hasFailed(): boolean { + return this.errors.length > 0; + } + + /** + * Adds the specified {@link error} to the list of errors caused by this node. + * + * This is not the same as {@link KipperProgramContext.reportError}, since that function automatically logs the error + * as well and this function does not! This is only intended to keep track if a node has failed. + * @param error The error to add. + */ + public addError(error: KipperError) { + this._errors.push(error); } /** @@ -201,21 +198,6 @@ export abstract class AnalysableASTNode< } } - /** - * Runs {@link semanticAnalysis} of all children nodes. - * @since 0.10.0 - * @protected - */ - protected async semanticallyAnalyseChildren(): Promise { - for (const child of this.children) { - try { - await child.semanticAnalysis(); - } catch (e) { - this.handleSemanticError(e); - } - } - } - /** * Semantically analyses the code inside this AST node and all {@link this.children children nodes}. * @@ -246,21 +228,6 @@ export abstract class AnalysableASTNode< } } - /** - * Runs {@link semanticTypeChecking} of all children nodes. - * @since 0.10.0 - * @protected - */ - protected async semanticallyTypeCheckChildren(): Promise { - for (const child of this.children) { - try { - await child.semanticTypeChecking(); - } catch (e) { - this.handleSemanticError(e); - } - } - } - /** * Performs type checking on this AST node and all {@link this.children children nodes}. This uses the * {@link this.semanticData semantic data} that was evaluated during {@link this.semanticAnalysis semantic analysis}. @@ -287,21 +254,6 @@ export abstract class AnalysableASTNode< } } - /** - * Runs {@link semanticTypeChecking} of all children nodes. - * @since 0.10.0 - * @protected - */ - protected async targetSemanticallyAnalyseChildren(): Promise { - for (const child of this.children) { - try { - await child.wrapUpSemanticAnalysis(); - } catch (e) { - this.handleSemanticError(e); - } - } - } - /** * Wrap-up semantic analysis, which analyses this AST node and all {@link this.children children nodes}, and * checks whether they are semantically valid for the {@link this.target target language}. This uses the @@ -346,6 +298,60 @@ export abstract class AnalysableASTNode< } } + /** + * Handles the specified error that occurred during the semantic analysis of this node in a standardised way. + * @param error The error to handle. + * @since 0.10.0 + */ + protected handleSemanticError(error: Error | KipperError): void { + handleSemanticError(this, error); + } + + /** + * Runs {@link semanticAnalysis} of all children nodes. + * @since 0.10.0 + * @protected + */ + protected async semanticallyAnalyseChildren(): Promise { + for (const child of this.children) { + try { + await child.semanticAnalysis(); + } catch (e) { + this.handleSemanticError(e); + } + } + } + + /** + * Runs {@link semanticTypeChecking} of all children nodes. + * @since 0.10.0 + * @protected + */ + protected async semanticallyTypeCheckChildren(): Promise { + for (const child of this.children) { + try { + await child.semanticTypeChecking(); + } catch (e) { + this.handleSemanticError(e); + } + } + } + + /** + * Runs {@link semanticTypeChecking} of all children nodes. + * @since 0.10.0 + * @protected + */ + protected async targetSemanticallyAnalyseChildren(): Promise { + for (const child of this.children) { + try { + await child.wrapUpSemanticAnalysis(); + } catch (e) { + this.handleSemanticError(e); + } + } + } + /** * Semantically analyses the code inside this AST node. * @@ -374,6 +380,4 @@ export abstract class AnalysableASTNode< * @since 0.9.0 */ protected abstract checkForWarnings?(): Promise; - - abstract readonly targetSemanticAnalysis: TargetASTNodeSemanticAnalyser | undefined; } diff --git a/kipper/core/src/compiler/ast/ast-generator.ts b/kipper/core/src/compiler/ast/ast-generator.ts index dd84afd16..7e6894834 100644 --- a/kipper/core/src/compiler/ast/ast-generator.ts +++ b/kipper/core/src/compiler/ast/ast-generator.ts @@ -80,7 +80,7 @@ import type { import type { KipperProgramContext } from "../program-ctx"; import type { CompilableASTNode } from "./compilable-ast-node"; import type { ParserRuleContext } from "antlr4ts/ParserRuleContext"; -import { Declaration, Expression, Statement, RootASTNode } from "./nodes"; +import { Declaration, Expression, RootASTNode, Statement } from "./nodes"; import { DeclarationASTNodeFactory, ExpressionASTNodeFactory, StatementASTNodeFactory } from "./factories"; import { KipperInternalError } from "../../errors"; @@ -90,323 +90,112 @@ import { KipperInternalError } from "../../errors"; * @since 0.10.0 */ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeListener { - private readonly _rootNode: RootASTNode; - private readonly _expressionFactory: ExpressionASTNodeFactory; - private readonly _statementFactory: StatementASTNodeFactory; - private readonly _declarationFactory: DeclarationASTNodeFactory; - - /** - * If this is true, the current context is inside an external item and automatically indicates - * {@link _isFunctionDefinition} is false. - */ - private _isExternalItem: boolean; - - /** - * If this is true, the current context is inside a function definition and automatically indicates - * {@link _isExternalItem} is false. - */ - private _isFunctionDefinition: boolean; - - /** - * The current Kipper AST node that is being walked through right now. This is the instance where current metadata - * should be added to and read from, as this instance will represent and handle the context rules that were walked - * through during this operation. - */ - private _currentPrimaryNode: Declaration | Statement | Expression | undefined; - - constructor(programCtx: KipperProgramContext, rootNode: CompilationUnitContext) { - this._rootNode = new RootASTNode(programCtx, rootNode); - this._isExternalItem = false; - this._isFunctionDefinition = false; - this._currentPrimaryNode = undefined; - this._expressionFactory = new ExpressionASTNodeFactory(); - this._statementFactory = new StatementASTNodeFactory(); - this._declarationFactory = new DeclarationASTNodeFactory(); - } - - /** - * The root node of the generated abstract syntax tree. - * @since 0.8.0 - */ - public get rootNode(): RootASTNode { - return this._rootNode; - } - - /** - * Returns the {@link KipperProgramContext program context} that owns this listener and the root node. - * @since 0.10.0 - */ - public get programCtx(): KipperProgramContext { - return this._rootNode.programCtx; - } - - /** - * Returns the {@link ExpressionASTNodeFactory expression factory} that is used to create new expression nodes - * based on the current Antlr4 context that is being walked through. - * @since 0.10.0 - */ - public get expressionFactory(): ExpressionASTNodeFactory { - return this._expressionFactory; - } - - /** - * Returns the {@link StatementASTNodeFactory statement factory} that is used to create new statement nodes based on - * the current Antlr4 context that is being walked through. - * @since 0.10.0 - */ - public get statementFactory(): StatementASTNodeFactory { - return this._statementFactory; - } - - /** - * Returns the {@link DeclarationASTNodeFactory declaration factory} that is used to create new declaration nodes - * based on the current Antlr4 context that is being walked through. - */ - public get declarationFactory(): DeclarationASTNodeFactory { - return this._declarationFactory; - } - - /** - * Returns which token is being processed at the moment and where meta-data should be assigned to. - * @private - */ - private get currentNode(): CompilableASTNode | RootASTNode { - if (this._currentPrimaryNode) { - return this._currentPrimaryNode; - } else { - return this.rootNode; - } - } - - /** - * Handles an incoming statement context. The handling algorithm is as following: - * - If {@link _currentPrimaryNode} is undefined, then it will be created and set as a child of - * {@link _rootNode} - * - Otherwise, generate a new {@link Statement} instance, which will be added to the {@link _currentPrimaryNode} as - * a child. Afterwards {@link _currentPrimaryNode} will be set to this new instance, as all new context instances - * must be assigned to it. When the context is left, then the old {@link _currentPrimaryNode} will be restored as - * {@link _currentPrimaryNode}, and all further context instances will be assigned to it. - * @private - */ - private handleEnteringTreeNode(ctx: ASTNodeParserContext) { - if (this.isStatementContext(ctx)) { - this._currentPrimaryNode = this.statementFactory.create(ctx, this.currentNode); - } else if (this.isDeclarationContext(ctx)) { - this._currentPrimaryNode = this.declarationFactory.create(ctx, this.currentNode); - } else if (this.isExpressionContext(ctx)) { - /* istanbul ignore if: internal errors should rarely happen if ever, and only in very very bad situations */ - if (this.currentNode instanceof RootASTNode) { - throw new KipperInternalError( - "An expression may not have the root file token as a parent. It must be child to a statement or a" + - " definition.", - ); - } - this._currentPrimaryNode = this.expressionFactory.create(ctx, this.currentNode); - } else { - throw new KipperInternalError(`The context '${ctx.astSyntaxKind}' is not supported by any of the factories.`); - } - - this.programCtx.logger.debug( - `Created AST node of type '${this.currentNode.constructor.name}' for context '${ctx.astSyntaxKind}'` + - `(Loc: ${ctx.start.line}:${ctx.start.charPositionInLine})`, - ); - } - - private isStatementContext(ctx: ASTNodeParserContext): boolean { - return this.statementFactory.ruleIds.includes(ctx.astSyntaxKind); - } - - private isDeclarationContext(ctx: ASTNodeParserContext): boolean { - return this.declarationFactory.ruleIds.includes(ctx.astSyntaxKind); - } - - private isExpressionContext(ctx: ASTNodeParserContext): boolean { - return this.expressionFactory.ruleIds.includes(ctx.astSyntaxKind); - } - - /** - * Handles an exiting node context. This is required to properly generate the AST node hierarchy. - * @private - */ - private handleExitingTreeNode() { - const parent = this._currentPrimaryNode?.parent; - if (parent instanceof Declaration || parent instanceof Statement || parent instanceof Expression) { - this._currentPrimaryNode = parent; - } else { - this._currentPrimaryNode = undefined; - } - } - - /** - * Function that is called every time an item is entered. - * @param ctx The context of the rule. - */ - public enterEveryRule?(/*@NotNull*/ ctx: ParserRuleContext | KipperParserRuleContext): void; - - /** - * Function that is called every time an item is exited. - * @param ctx The context of the rule. - */ - public exitEveryRule?(/*@NotNull*/ ctx: ParserRuleContext | KipperParserRuleContext): void; - - // ------------------------------------------------------------------------------------------------------------------- - // Root Item section - // ------------------------------------------------------------------------------------------------------------------- - - /** - * Enter a parse tree produced by the `externalItem`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public enterExternalItem(ctx: ExternalItemContext): void { - this._isExternalItem = true; - } - - /** - * Exit a parse tree produced by the `externalItem`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public exitExternalItem(ctx: ExternalItemContext): void { - this._isExternalItem = false; - } - - // ------------------------------------------------------------------------------------------------------------------- - // Expression section - // ------------------------------------------------------------------------------------------------------------------- - /** * Enter a parse tree produced by `KipperParser.identifierPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterIdentifierPrimaryExpression: (ctx: IdentifierPrimaryExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.identifierPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitIdentifierPrimaryExpression: (ctx: IdentifierPrimaryExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.stringPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterStringPrimaryExpression: (ctx: StringPrimaryExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.stringPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitStringPrimaryExpression: (ctx: StringPrimaryExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.fStringPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterFStringPrimaryExpression: (ctx: FStringPrimaryExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.fStringPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitFStringPrimaryExpression: (ctx: FStringPrimaryExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.tangledPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterTangledPrimaryExpression: (ctx: TangledPrimaryExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.tangledPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitTangledPrimaryExpression: (ctx: TangledPrimaryExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.numberPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterNumberPrimaryExpression: (ctx: NumberPrimaryExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.numberPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitNumberPrimaryExpression: (ctx: NumberPrimaryExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.arrayPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterArrayPrimaryExpression: (ctx: ArrayPrimaryExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.arrayPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitArrayPrimaryExpression: (ctx: ArrayPrimaryExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.objectPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterObjectPrimaryExpression: (ctx: ObjectPrimaryExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.objectPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitObjectPrimaryExpression: (ctx: ObjectPrimaryExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.objectProperty`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). * @since 0.11.0 */ public enterObjectProperty: (ctx: ObjectPropertyContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.objectProperty`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). * @since 0.11.0 */ public exitObjectProperty: (ctx: ObjectPropertyContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.boolPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterBoolPrimaryExpression: (ctx: BoolPrimaryExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.boolPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitBoolPrimaryExpression: (ctx: BoolPrimaryExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.voidOrNullOrUndefinedPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterVoidOrNullOrUndefinedPrimaryExpression: (ctx: VoidOrNullOrUndefinedPrimaryExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.voidOrNullOrUndefinedPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitVoidOrNullOrUndefinedPrimaryExpression: (ctx: VoidOrNullOrUndefinedPrimaryExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'computedPrimaryExpression' rule, and only going to handle the rules - // 'functionCallExpression' and 'memberAccessExpression' as they are the only ones which implements a more precise - // 'computedPrimaryExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time - // an expression is called. - /** * Enter a parse tree produced by the `dotNotationMemberAccessExpression` * Labeled alternative in `KipperParser.computedPrimaryExpression`. @@ -415,6 +204,9 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi public enterDotNotationMemberAccessExpression: (ctx: DotNotationMemberAccessExpressionContext) => void = this.handleEnteringTreeNode; + // ------------------------------------------------------------------------------------------------------------------- + // Root Item section + // ------------------------------------------------------------------------------------------------------------------- /** * Exit a parse tree produced by the `dotNotationMemberAccessExpression` * Labeled alternative in `KipperParser.computedPrimaryExpression`. @@ -422,7 +214,6 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public exitDotNotationMemberAccessExpression: (ctx: DotNotationMemberAccessExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by the `bracketNotationMemberAccessExpression` * Labeled alternative in `KipperParser.computedPrimaryExpression`. @@ -431,6 +222,9 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi public enterBracketNotationMemberAccessExpression: (ctx: BracketNotationMemberAccessExpressionContext) => void = this.handleEnteringTreeNode; + // ------------------------------------------------------------------------------------------------------------------- + // Expression section + // ------------------------------------------------------------------------------------------------------------------- /** * Exit a parse tree produced by the `bracketNotationMemberAccessExpression` * Labeled alternative in `KipperParser.computedPrimaryExpression`. @@ -438,7 +232,6 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public exitBracketNotationMemberAccessExpression: (ctx: BracketNotationMemberAccessExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by the `sliceNotationMemberAccessExpression` * Labeled alternative in `KipperParser.computedPrimaryExpression`. @@ -446,7 +239,6 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public enterSliceNotationMemberAccessExpression: (ctx: SliceNotationMemberAccessExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the `sliceNotationMemberAccessExpression` * Labeled alternative in `KipperParser.computedPrimaryExpression`. @@ -454,21 +246,18 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public exitSliceNotationMemberAccessExpression: (ctx: SliceNotationMemberAccessExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by the `functionCallExpression` * Labeled alternative in `KipperParser.computedPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}).. */ public enterFunctionCallExpression: (ctx: FunctionCallExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the `functionCallExpression` * Labeled alternative in `KipperParser.computedPrimaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}).. */ public exitFunctionCallExpression: (ctx: FunctionCallExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by the `explicitCallFunctionCallExpression` * Labeled alternative in `KipperParser.computedPrimaryExpression`. @@ -476,7 +265,6 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public enterExplicitCallFunctionCallExpression: (ctx: ExplicitCallFunctionCallExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the `explicitCallFunctionCallExpression` * Labeled alternative in `KipperParser.computedPrimaryExpression`. @@ -484,71 +272,42 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public exitExplicitCallFunctionCallExpression: (ctx: ExplicitCallFunctionCallExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'postfixExpression' rule, and only going to handle the rule - // 'incrementOrDecrementPostfixExpression', which implements a more precise 'postfixExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time - // an expression is called. - /** * Enter a parse tree produced by `KipperParser.incrementOrDecrementPostfixExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterIncrementOrDecrementPostfixExpression: (ctx: IncrementOrDecrementPostfixExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.incrementOrDecrementPostfixExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitIncrementOrDecrementPostfixExpression: (ctx: IncrementOrDecrementPostfixExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'unaryExpression' rule, and only going to handle the rules - // 'incrementOrDecrementUnaryExpression' and 'operatorModifiedUnaryExpression', which implement a more precise - // 'unaryExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time - // an expression is called. - /** * Enter a parse tree produced by `KipperParser.incrementOrDecrementUnaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterIncrementOrDecrementUnaryExpression: (ctx: IncrementOrDecrementUnaryExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.incrementOrDecrementUnaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitIncrementOrDecrementUnaryExpression: (ctx: IncrementOrDecrementUnaryExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.operatorModifiedUnaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterOperatorModifiedUnaryExpression: (ctx: OperatorModifiedUnaryExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.operatorModifiedUnaryExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitOperatorModifiedUnaryExpression: (ctx: OperatorModifiedUnaryExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'castOrConvertExpression' rule, and only going to handle the rule - // 'actualCastOrConvertExpression', which implements a more precise 'castOrConvertExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time - // an expression is called. - /** * Enter a parse tree produced by the `actualCastOrConvertExpression` * labeled alternative in `KipperParser.castOrConvertExpression`. @@ -556,7 +315,6 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public enterActualCastOrConvertExpression: (ctx: ActualCastOrConvertExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the `actualCastOrConvertExpression` * labeled alternative in `KipperParser.castOrConvertExpression`. @@ -564,14 +322,6 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public exitActualCastOrConvertExpression: (ctx: ActualCastOrConvertExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'multiplicativeExpression' rule, and only going to handle the rule - // 'actualMultiplicativeExpression', which implements a more precise 'multiplicativeExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time - // an expression is called. - /** * Enter a parse tree produced by the `actualMultiplicativeExpression` * Labeled alternative in `KipperParser.multiplicativeExpression`. @@ -579,7 +329,6 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public enterActualMultiplicativeExpression: (ctx: ActualMultiplicativeExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the `actualMultiplicativeExpression` * Labeled alternative in `KipperParser.multiplicativeExpression`. @@ -587,35 +336,18 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public exitActualMultiplicativeExpression: (ctx: ActualMultiplicativeExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'additiveExpression' rule, and only going to handle the rule 'actualAdditiveExpression', - // which implements a more precise 'additiveExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time - // an expression is called. - /** * Enter a parse tree produced by the `actualAdditiveExpression` * labeled alternative in `KipperParser.additiveExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterActualAdditiveExpression: (ctx: ActualAdditiveExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the `actualAdditiveExpression` * labeled alternative in `KipperParser.additiveExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitActualAdditiveExpression: (ctx: ActualAdditiveExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'relationalExpression' rule, and only going to handle the rule - // 'actualRelationalExpression', which implements a more precise 'relationalExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time an - // expression is called. - /** * Enter a parse tree produced by the `actualRelationalExpression` * labeled alternative in `KipperParser.relationalExpression`. @@ -624,77 +356,39 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi public enterActualRelationalExpression: (ctx: ActualRelationalExpressionContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring the 'computedPrimaryExpression' rule, and only going to handle the rules + // 'functionCallExpression' and 'memberAccessExpression' as they are the only ones which implements a more precise + // 'computedPrimaryExpression' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time + // an expression is called. /** * Exit a parse tree produced by the `actualRelationalExpression` * labeled alternative in `KipperParser.relationalExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitActualRelationalExpression: (ctx: ActualRelationalExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'equalityExpression' rule, and only going to handle the rule 'actualEqualityExpression', - // which implements a more precise 'equalityExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time an - // expression is called. - /** * Enter a parse tree produced by the `actualEqualityExpression` * labeled alternative in `KipperParser.equalityExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterActualEqualityExpression: (ctx: ActualEqualityExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the `actualEqualityExpression` * labeled alternative in `KipperParser.equalityExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitActualEqualityExpression: (ctx: ActualEqualityExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by the `actualBitwiseShiftExpression` */ public enterLambdaExpression: (ctx: LambdaExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the `actualBitwiseShiftExpression` */ public exitLambdaExpression: (ctx: LambdaExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring logical and expressions, and only going to handle the rules 'passOnLogicalAndExpression', - // and 'actualLogicalAndExpression', which implement a more precise 'logicalAndExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time an - // expression is called. - - /** - * Enter a parse tree produced by `KipperParser.logicalAndExpression`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public enterLogicalAndExpression?(ctx: LogicalAndExpressionContext): void; // Unspecific parent -> skip - - /** - * Exit a parse tree produced by `KipperParser.logicalAndExpression`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public exitLogicalAndExpression?(ctx: LogicalAndExpressionContext): void; // Unspecific parent -> skip - - /** - * Enter a parse tree produced by the `passOnLogicalAndExpression` - * Labeled alternative in `KipperParser.logicalAndExpression`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public enterPassOnLogicalAndExpression?(ctx: PassOnLogicalAndExpressionContext): void; // Pass-on -> skip - - /** - * Exit a parse tree produced by the `passOnLogicalAndExpression` - * Labeled alternative in `KipperParser.logicalAndExpression`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public exitPassOnLogicalAndExpression?(ctx: PassOnLogicalAndExpressionContext): void; // Pass-on -> skip - /** * Enter a parse tree produced by the `actualLogicalAndExpression` * Labeled alternative in `KipperParser.logicalAndExpression`. @@ -702,90 +396,82 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public enterActualLogicalAndExpression: (ctx: ActualLogicalAndExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the `actualLogicalAndExpression` * Labeled alternative in `KipperParser.logicalAndExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitActualLogicalAndExpression: (ctx: ActualLogicalAndExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'logicalOrExpression' rule, and only going to handle the rule 'actualLogicalOrExpression', - // which implements a more precise 'logicalOrExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time an - // expression is called. - /** * Enter a parse tree produced by the `actualLogicalOrExpression` * Labeled alternative in `KipperParser.logicalOrExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterActualLogicalOrExpression: (ctx: ActualLogicalOrExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the `actualLogicalOrExpression` * Labeled alternative in `KipperParser.logicalOrExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitActualLogicalOrExpression: (ctx: ActualLogicalOrExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'bitwiseOrExpression' rule, and only going to handle the rule 'actualBitwiseOrExpression', - // which implements a more precise 'bitwiseOrExpression' rule. - /** * Enter a parse tree produced by the KipperParser.bitwiseOrExpression */ public enterActualBitwiseOrExpression: (ctx: ActualBitwiseOrExpressionContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring the 'postfixExpression' rule, and only going to handle the rule + // 'incrementOrDecrementPostfixExpression', which implements a more precise 'postfixExpression' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time + // an expression is called. /** * Exit a parse tree produced by the KipperParser.bitwiseOrExpression */ public exitActualBitwiseOrExpression: (ctx: ActualBitwiseOrExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by the KipperParser.bitwiseAndExpression */ public enterActualBitwiseAndExpression: (ctx: ActualBitwiseAndExpressionContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring the 'unaryExpression' rule, and only going to handle the rules + // 'incrementOrDecrementUnaryExpression' and 'operatorModifiedUnaryExpression', which implement a more precise + // 'unaryExpression' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time + // an expression is called. /** * Exit a parse tree produced by the KipperParser.bitwiseAndExpression */ public exitActualBitwiseAndExpression: (ctx: ActualBitwiseAndExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by the KipperParser.bitwiseXorExpression */ public enterActualBitwiseXorExpression: (ctx: ActualBitwiseXorExpressionContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the KipperParser.bitwiseXorExpression */ public exitActualBitwiseXorExpression: (ctx: ActualBitwiseXorExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by the KipperParser.bitwiseShiftExpression */ public enterActualBitwiseShiftExpression: (ctx: ActualBitwiseShiftExpressionContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring the 'castOrConvertExpression' rule, and only going to handle the rule + // 'actualCastOrConvertExpression', which implements a more precise 'castOrConvertExpression' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time + // an expression is called. /** * Exit a parse tree produced by the KipperParser.bitwiseShiftExpression */ public exitActualBitwiseShiftExpression: (ctx: ActualBitwiseShiftExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'conditionalExpression' rule, and only going to handle the rule - // 'actualConditionalExpression', which implements a more precise 'conditionalExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time an - // expression is called. - /** * Enter a parse tree produced by the `actualConditionalExpression` * Labeled alternative in `KipperParser.conditionalExpression`. @@ -794,6 +480,12 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi public enterActualConditionalExpression: (ctx: ActualConditionalExpressionContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring the 'multiplicativeExpression' rule, and only going to handle the rule + // 'actualMultiplicativeExpression', which implements a more precise 'multiplicativeExpression' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time + // an expression is called. /** * Exit a parse tree produced by the `actualConditionalExpression` * Labeled alternative in `KipperParser.conditionalExpression`. @@ -801,14 +493,6 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public exitActualConditionalExpression: (ctx: ActualConditionalExpressionContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'assignmentExpression' rule, and only going to handle the rule - // 'actualAssignmentExpression', which implements a more precise 'assignmentExpression' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time an - // expression is called. - /** * Enter a parse tree produced by the `actualAssignmentExpression` * Labeled alternative in `KipperParser.assignmentExpression`. @@ -817,84 +501,64 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi public enterActualAssignmentExpression: (ctx: ActualAssignmentExpressionContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring the 'additiveExpression' rule, and only going to handle the rule 'actualAdditiveExpression', + // which implements a more precise 'additiveExpression' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time + // an expression is called. /** * Exit a parse tree produced by the `actualAssignmentExpression` * Labeled alternative in `KipperParser.assignmentExpression`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitActualAssignmentExpression: (ctx: ActualAssignmentExpressionContext) => void = this.handleExitingTreeNode; - - // -- NOTE: We are ignoring standard expressions, as the children rules will handle everything. -- - - /** - * Enter a parse tree produced by `KipperParser.expression`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public enterExpression?(ctx: ExpressionContext): void; - /** - * Exit a parse tree produced by `KipperParser.expression`. + * Enter a parse tree produced by `KipperParser.expressionStatement`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ - public exitExpression?(ctx: ExpressionContext): void; + public enterExpressionStatement: (ctx: ExpressionStatementContext) => void = this.handleEnteringTreeNode; - // ------------------------------------------------------------------------------------------------------------------- - // Statement section - // ------------------------------------------------------------------------------------------------------------------- - // // NOTE: - // We are ignoring the 'statement' rule, and only going to handle the rules 'expressionStatement', 'labeledStatement' - // 'selectionStatement', 'iterationStatement' (do-while, while and loop), 'jumpStatement' and 'compoundStatement', - // which implement a more precise 'statement' rule. + // We are ignoring the 'relationalExpression' rule, and only going to handle the rule + // 'actualRelationalExpression', which implements a more precise 'relationalExpression' rule. // // This is to simplify the walking process, without having to check if the expression is actually used every time an // expression is called. - - /** - * Enter a parse tree produced by `KipperParser.expressionStatement`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public enterExpressionStatement: (ctx: ExpressionStatementContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.expressionStatement`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitExpressionStatement: (ctx: ExpressionStatementContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.compoundStatement`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterCompoundStatement: (ctx: CompoundStatementContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring the 'equalityExpression' rule, and only going to handle the rule 'actualEqualityExpression', + // which implements a more precise 'equalityExpression' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time an + // expression is called. /** * Exit a parse tree produced by `KipperParser.compoundStatement`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitCompoundStatement: (ctx: CompoundStatementContext) => void = this.handleExitingTreeNode; - - // NOTE: - // We are ignoring the 'selectionStatement' rule, and only going to handle the rules 'ifStatement' and - // 'switchStatement', which implement a more precise 'selectionStatement' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time an - // expression is called. - /** * Enter a parse tree produced by the `ifStatement` * labeled alternative in `KipperParser.selectionStatement`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterIfStatement: (ctx: IfStatementContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by the `ifStatement` * labeled alternative in `KipperParser.selectionStatement`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitIfStatement: (ctx: IfStatementContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by the `switchStatement` * labeled alternative in `KipperParser.selectionStatement`. @@ -902,63 +566,40 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi */ public enterSwitchStatement: (ctx: SwitchStatementContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring logical and expressions, and only going to handle the rules 'passOnLogicalAndExpression', + // and 'actualLogicalAndExpression', which implement a more precise 'logicalAndExpression' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time an + // expression is called. /** * Exit a parse tree produced by the `switchStatement` * labeled alternative in `KipperParser.selectionStatement`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitSwitchStatement: (ctx: SwitchStatementContext) => void = this.handleExitingTreeNode; - - /** - * Enter a parse tree produced by `KipperParser.labeledStatement`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public enterSwitchLabeledStatement(ctx: SwitchLabeledStatementContext): void { - // TODO! Implement switch statements - } - - /** - * Exit a parse tree produced by `KipperParser.labeledStatement`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public exitSwitchLabeledStatement(ctx: SwitchLabeledStatementContext): void { - // TODO! Implement switch statements - } - - // NOTE: - // We are ignoring the 'iterationStatement' rule, and only going to handle the rules 'forLoopIterationStatement', - // 'whileLoopIterationStatement' and 'doWhileLoopIterationStatement', which implement a more precise - // 'iterationStatement' rule. - // - // This is to simplify the walking process, without having to check if the expression is actually used every time an - // expression is called. - /** * Enter a parse tree produced by `KipperParser.forLoopIterationStatement`. * @param ctx the parse tree */ public enterForLoopIterationStatement: (ctx: ForLoopIterationStatementContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.forLoopIterationStatement`. * @param ctx the parse tree */ public exitForLoopIterationStatement: (ctx: ForLoopIterationStatementContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.whileLoopIterationStatement`. * @param ctx the parse tree */ public enterWhileLoopIterationStatement: (ctx: WhileLoopIterationStatementContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.whileLoopIterationStatement`. * @param ctx the parse tree */ public exitWhileLoopIterationStatement: (ctx: WhileLoopIterationStatementContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.doWhileLoopIterationStatement`. * @param ctx the parse tree @@ -966,119 +607,79 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi public enterDoWhileLoopIterationStatement: (ctx: DoWhileLoopIterationStatementContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring the 'logicalOrExpression' rule, and only going to handle the rule 'actualLogicalOrExpression', + // which implements a more precise 'logicalOrExpression' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time an + // expression is called. /** * Exit a parse tree produced by `KipperParser.doWhileLoopIterationStatement`. * @param ctx the parse tree */ public exitDoWhileLoopIterationStatement: (ctx: DoWhileLoopIterationStatementContext) => void = this.handleExitingTreeNode; - - // -- Special statements - /** * Enter a parse tree produced by `KipperParser.returnStatement`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterReturnStatement: (ctx: ReturnStatementContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring the 'bitwiseOrExpression' rule, and only going to handle the rule 'actualBitwiseOrExpression', + // which implements a more precise 'bitwiseOrExpression' rule. /** * Exit a parse tree produced by `KipperParser.returnStatement`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitReturnStatement: (ctx: ReturnStatementContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.jumpStatement`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterJumpStatement: (ctx: JumpStatementContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.jumpStatement`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitJumpStatement: (ctx: JumpStatementContext) => void = this.handleExitingTreeNode; - - // ------------------------------------------------------------------------------------------------------------------- - // Declaration section - // ------------------------------------------------------------------------------------------------------------------- - - /** - * Enter a parse tree produced by `KipperParser.declaration`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public enterDeclaration?(ctx: DeclarationContext): void; - - /** - * Exit a parse tree produced by `KipperParser.declaration`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public exitDeclaration?(ctx: DeclarationContext): void; - /** * Enter a parse tree produced by `KipperParser.variableDeclaration`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterVariableDeclaration: (ctx: VariableDeclarationContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.variableDeclaration`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitVariableDeclaration: (ctx: VariableDeclarationContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.functionDefinition`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterFunctionDeclaration: (ctx: FunctionDeclarationContext) => void = this.handleEnteringTreeNode; - /** * Exit a parse tree produced by `KipperParser.functionDefinition`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitFunctionDeclaration: (ctx: FunctionDeclarationContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.parameterDeclaration`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public enterParameterDeclaration: (ctx: ParameterDeclarationContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring the 'conditionalExpression' rule, and only going to handle the rule + // 'actualConditionalExpression', which implements a more precise 'conditionalExpression' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time an + // expression is called. /** * Exit a parse tree produced by `KipperParser.parameterDeclaration`. * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitParameterDeclaration: (ctx: ParameterDeclarationContext) => void = this.handleExitingTreeNode; - - // ------------------------------------------------------------------------------------------------------------------- - // Other - // ------------------------------------------------------------------------------------------------------------------- - - /** - * Enter a parse tree produced by `KipperParser.storageTypeSpecifier`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public enterStorageTypeSpecifier?(ctx: StorageTypeSpecifierContext): void; - - /** - * Exit a parse tree produced by `KipperParser.storageTypeSpecifier`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public exitStorageTypeSpecifier?(ctx: StorageTypeSpecifierContext): void; - - /** - * Enter a parse tree produced by `KipperParser.initDeclarator`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public enterInitDeclarator?(ctx: InitDeclaratorContext): void; - - /** - * Exit a parse tree produced by `KipperParser.initDeclarator`. - * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). - */ - public exitInitDeclarator?(ctx: InitDeclaratorContext): void; - /** * Enter a parse tree produced by `KipperParser.identifierTypeSpecifier`. * @param ctx the parse tree @@ -1086,13 +687,18 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi public enterIdentifierTypeSpecifierExpression: (ctx: IdentifierTypeSpecifierExpressionContext) => void = this.handleEnteringTreeNode; + // NOTE: + // We are ignoring the 'assignmentExpression' rule, and only going to handle the rule + // 'actualAssignmentExpression', which implements a more precise 'assignmentExpression' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time an + // expression is called. /** * Exit a parse tree produced by `KipperParser.identifierTypeSpecifier`. * @param ctx the parse tree */ public exitIdentifierTypeSpecifierExpression: (ctx: IdentifierTypeSpecifierExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.genericTypeSpecifier`. * @param ctx the parse tree @@ -1100,13 +706,13 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi public enterGenericTypeSpecifierExpression: (ctx: GenericTypeSpecifierExpressionContext) => void = this.handleEnteringTreeNode; + // -- NOTE: We are ignoring standard expressions, as the children rules will handle everything. -- /** * Exit a parse tree produced by `KipperParser.genericTypeSpecifier`. * @param ctx the parse tree */ public exitGenericTypeSpecifierExpression: (ctx: GenericTypeSpecifierExpressionContext) => void = this.handleExitingTreeNode; - /** * Enter a parse tree produced by `KipperParser.typeofTypeSpecifier`. * @param ctx the parse tree @@ -1114,12 +720,250 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi public enterTypeofTypeSpecifierExpression: (ctx: TypeofTypeSpecifierExpressionContext) => void = this.handleEnteringTreeNode; + // ------------------------------------------------------------------------------------------------------------------- + // Statement section + // ------------------------------------------------------------------------------------------------------------------- + // + // NOTE: + // We are ignoring the 'statement' rule, and only going to handle the rules 'expressionStatement', 'labeledStatement' + // 'selectionStatement', 'iterationStatement' (do-while, while and loop), 'jumpStatement' and 'compoundStatement', + // which implement a more precise 'statement' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time an + // expression is called. /** * Exit a parse tree produced by `KipperParser.typeofTypeSpecifier`. * @param ctx the parse tree */ public exitTypeofTypeSpecifierExpression: (ctx: TypeofTypeSpecifierExpressionContext) => void = this.handleExitingTreeNode; + private readonly _rootNode: RootASTNode; + private readonly _expressionFactory: ExpressionASTNodeFactory; + private readonly _statementFactory: StatementASTNodeFactory; + + // NOTE: + // We are ignoring the 'selectionStatement' rule, and only going to handle the rules 'ifStatement' and + // 'switchStatement', which implement a more precise 'selectionStatement' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time an + // expression is called. + private readonly _declarationFactory: DeclarationASTNodeFactory; + /** + * If this is true, the current context is inside an external item and automatically indicates + * {@link _isFunctionDefinition} is false. + */ + private _isExternalItem: boolean; + /** + * If this is true, the current context is inside a function definition and automatically indicates + * {@link _isExternalItem} is false. + */ + private _isFunctionDefinition: boolean; + /** + * The current Kipper AST node that is being walked through right now. This is the instance where current metadata + * should be added to and read from, as this instance will represent and handle the context rules that were walked + * through during this operation. + */ + private _currentPrimaryNode: Declaration | Statement | Expression | undefined; + + constructor(programCtx: KipperProgramContext, rootNode: CompilationUnitContext) { + this._rootNode = new RootASTNode(programCtx, rootNode); + this._isExternalItem = false; + this._isFunctionDefinition = false; + this._currentPrimaryNode = undefined; + this._expressionFactory = new ExpressionASTNodeFactory(); + this._statementFactory = new StatementASTNodeFactory(); + this._declarationFactory = new DeclarationASTNodeFactory(); + } + + /** + * The root node of the generated abstract syntax tree. + * @since 0.8.0 + */ + public get rootNode(): RootASTNode { + return this._rootNode; + } + + // NOTE: + // We are ignoring the 'iterationStatement' rule, and only going to handle the rules 'forLoopIterationStatement', + // 'whileLoopIterationStatement' and 'doWhileLoopIterationStatement', which implement a more precise + // 'iterationStatement' rule. + // + // This is to simplify the walking process, without having to check if the expression is actually used every time an + // expression is called. + + /** + * Returns the {@link KipperProgramContext program context} that owns this listener and the root node. + * @since 0.10.0 + */ + public get programCtx(): KipperProgramContext { + return this._rootNode.programCtx; + } + + /** + * Returns the {@link ExpressionASTNodeFactory expression factory} that is used to create new expression nodes + * based on the current Antlr4 context that is being walked through. + * @since 0.10.0 + */ + public get expressionFactory(): ExpressionASTNodeFactory { + return this._expressionFactory; + } + + /** + * Returns the {@link StatementASTNodeFactory statement factory} that is used to create new statement nodes based on + * the current Antlr4 context that is being walked through. + * @since 0.10.0 + */ + public get statementFactory(): StatementASTNodeFactory { + return this._statementFactory; + } + + /** + * Returns the {@link DeclarationASTNodeFactory declaration factory} that is used to create new declaration nodes + * based on the current Antlr4 context that is being walked through. + */ + public get declarationFactory(): DeclarationASTNodeFactory { + return this._declarationFactory; + } + + /** + * Returns which token is being processed at the moment and where meta-data should be assigned to. + * @private + */ + private get currentNode(): CompilableASTNode | RootASTNode { + if (this._currentPrimaryNode) { + return this._currentPrimaryNode; + } else { + return this.rootNode; + } + } + + /** + * Function that is called every time an item is entered. + * @param ctx The context of the rule. + */ + public enterEveryRule?(/*@NotNull*/ ctx: ParserRuleContext | KipperParserRuleContext): void; + + // -- Special statements + + /** + * Function that is called every time an item is exited. + * @param ctx The context of the rule. + */ + public exitEveryRule?(/*@NotNull*/ ctx: ParserRuleContext | KipperParserRuleContext): void; + + /** + * Enter a parse tree produced by the `externalItem`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public enterExternalItem(ctx: ExternalItemContext): void { + this._isExternalItem = true; + } + + /** + * Exit a parse tree produced by the `externalItem`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public exitExternalItem(ctx: ExternalItemContext): void { + this._isExternalItem = false; + } + + /** + * Enter a parse tree produced by `KipperParser.logicalAndExpression`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public enterLogicalAndExpression?(ctx: LogicalAndExpressionContext): void; // Unspecific parent -> skip + + // ------------------------------------------------------------------------------------------------------------------- + // Declaration section + // ------------------------------------------------------------------------------------------------------------------- + + /** + * Exit a parse tree produced by `KipperParser.logicalAndExpression`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public exitLogicalAndExpression?(ctx: LogicalAndExpressionContext): void; // Unspecific parent -> skip + + /** + * Enter a parse tree produced by the `passOnLogicalAndExpression` + * Labeled alternative in `KipperParser.logicalAndExpression`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public enterPassOnLogicalAndExpression?(ctx: PassOnLogicalAndExpressionContext): void; // Pass-on -> skip + + /** + * Exit a parse tree produced by the `passOnLogicalAndExpression` + * Labeled alternative in `KipperParser.logicalAndExpression`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public exitPassOnLogicalAndExpression?(ctx: PassOnLogicalAndExpressionContext): void; // Pass-on -> skip + + /** + * Enter a parse tree produced by `KipperParser.expression`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public enterExpression?(ctx: ExpressionContext): void; + + /** + * Exit a parse tree produced by `KipperParser.expression`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public exitExpression?(ctx: ExpressionContext): void; + + /** + * Enter a parse tree produced by `KipperParser.labeledStatement`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public enterSwitchLabeledStatement(ctx: SwitchLabeledStatementContext): void { + // TODO! Implement switch statements + } + + /** + * Exit a parse tree produced by `KipperParser.labeledStatement`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public exitSwitchLabeledStatement(ctx: SwitchLabeledStatementContext): void { + // TODO! Implement switch statements + } + + /** + * Enter a parse tree produced by `KipperParser.declaration`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public enterDeclaration?(ctx: DeclarationContext): void; + + // ------------------------------------------------------------------------------------------------------------------- + // Other + // ------------------------------------------------------------------------------------------------------------------- + + /** + * Exit a parse tree produced by `KipperParser.declaration`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public exitDeclaration?(ctx: DeclarationContext): void; + + /** + * Enter a parse tree produced by `KipperParser.storageTypeSpecifier`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public enterStorageTypeSpecifier?(ctx: StorageTypeSpecifierContext): void; + + /** + * Exit a parse tree produced by `KipperParser.storageTypeSpecifier`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public exitStorageTypeSpecifier?(ctx: StorageTypeSpecifierContext): void; + + /** + * Enter a parse tree produced by `KipperParser.initDeclarator`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public enterInitDeclarator?(ctx: InitDeclaratorContext): void; + + /** + * Exit a parse tree produced by `KipperParser.initDeclarator`. + * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). + */ + public exitInitDeclarator?(ctx: InitDeclaratorContext): void; /** * Enter a parse tree produced by `KipperParser.typeSpecifier`. @@ -1180,4 +1024,63 @@ export class KipperFileASTGenerator implements KipperParserListener, ParseTreeLi * @param ctx The parse tree (instance of {@link KipperParserRuleContext}). */ public exitInitializer?(ctx: InitializerContext): void; // Unspecific parent -> skip + + /** + * Handles an incoming statement context. The handling algorithm is as following: + * - If {@link _currentPrimaryNode} is undefined, then it will be created and set as a child of + * {@link _rootNode} + * - Otherwise, generate a new {@link Statement} instance, which will be added to the {@link _currentPrimaryNode} as + * a child. Afterwards {@link _currentPrimaryNode} will be set to this new instance, as all new context instances + * must be assigned to it. When the context is left, then the old {@link _currentPrimaryNode} will be restored as + * {@link _currentPrimaryNode}, and all further context instances will be assigned to it. + * @private + */ + private handleEnteringTreeNode(ctx: ASTNodeParserContext) { + if (this.isStatementContext(ctx)) { + this._currentPrimaryNode = this.statementFactory.create(ctx, this.currentNode); + } else if (this.isDeclarationContext(ctx)) { + this._currentPrimaryNode = this.declarationFactory.create(ctx, this.currentNode); + } else if (this.isExpressionContext(ctx)) { + /* istanbul ignore if: internal errors should rarely happen if ever, and only in very very bad situations */ + if (this.currentNode instanceof RootASTNode) { + throw new KipperInternalError( + "An expression may not have the root file token as a parent. It must be child to a statement or a" + + " definition.", + ); + } + this._currentPrimaryNode = this.expressionFactory.create(ctx, this.currentNode); + } else { + throw new KipperInternalError(`The context '${ctx.astSyntaxKind}' is not supported by any of the factories.`); + } + + this.programCtx.logger.debug( + `Created AST node of type '${this.currentNode.constructor.name}' for context '${ctx.astSyntaxKind}'` + + `(Loc: ${ctx.start.line}:${ctx.start.charPositionInLine})`, + ); + } + + private isStatementContext(ctx: ASTNodeParserContext): boolean { + return this.statementFactory.ruleIds.includes(ctx.astSyntaxKind); + } + + private isDeclarationContext(ctx: ASTNodeParserContext): boolean { + return this.declarationFactory.ruleIds.includes(ctx.astSyntaxKind); + } + + private isExpressionContext(ctx: ASTNodeParserContext): boolean { + return this.expressionFactory.ruleIds.includes(ctx.astSyntaxKind); + } + + /** + * Handles an exiting node context. This is required to properly generate the AST node hierarchy. + * @private + */ + private handleExitingTreeNode() { + const parent = this._currentPrimaryNode?.parent; + if (parent instanceof Declaration || parent instanceof Statement || parent instanceof Expression) { + this._currentPrimaryNode = parent; + } else { + this._currentPrimaryNode = undefined; + } + } } diff --git a/kipper/core/src/compiler/ast/ast-node.ts b/kipper/core/src/compiler/ast/ast-node.ts index ba492f688..358be4438 100644 --- a/kipper/core/src/compiler/ast/ast-node.ts +++ b/kipper/core/src/compiler/ast/ast-node.ts @@ -15,13 +15,13 @@ import type { KipperParserRuleContext } from "../lexer-parser"; * {@link CompilableASTNode}. * @since 0.3.0 */ -export type SemanticData = Record; +export type SemanticData = { [key: string]: any }; /** * Type semantics for an expression class that must be evaluated during Type Checking. * @since 0.10.0 */ -export type TypeData = Record; +export type TypeData = { [key: string]: any }; /** * Empty semantics interface for hinting an AST node has *no* semantics. @@ -45,24 +45,6 @@ export abstract class ParserASTNode>; protected readonly _parent: ParserASTNode | undefined; - protected _semanticData: Semantics | undefined; - protected _typeSemantics: TypeSemantics | undefined; - - /** - * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST - * node wraps. - * - * This may be compared using the {@link KipperParser} rule fields, for example {@link KipperParser.RULE_expression}. - * @since 0.10.0 - */ - public abstract get kind(): number; - - /** - * Returns the identifier of this AST node. This is a unique identifier that can be used to differentiate this AST - * node from other AST nodes. - * @since 0.11.0 - */ - public abstract get ruleName(): string; protected constructor(antlrCtx: KipperParserRuleContext, parent: ParserASTNode | undefined) { this._antlrRuleCtx = antlrCtx; @@ -71,6 +53,8 @@ export abstract class ParserASTNode implements TargetCompilableNode { - protected _scopeCtx: ScopeNode | KipperProgramContext | undefined; - protected override _parent: CompilableNodeParent; - protected override _children: Array; + abstract readonly targetCodeGenerator: TargetASTNodeCodeGenerator< + any, + TranslatedCodeLine | Array + >; protected constructor(antlrCtx: KipperParserRuleContext, parent: CompilableNodeParent) { super(antlrCtx, parent); @@ -52,6 +52,8 @@ export abstract class CompilableASTNode< this._children = []; } + protected override _parent: CompilableNodeParent; + /** * Returns the {@link CompilableASTNode parent} that has this node as a child. * @since 0.8.0 @@ -60,6 +62,8 @@ export abstract class CompilableASTNode< return this._parent; } + protected override _children: Array; + /** * The children of this AST node. * @since 0.8.0 @@ -68,28 +72,6 @@ export abstract class CompilableASTNode< return this._children; } - /** - * Adds new child ctx item to this AST node. The child item should be in the order that they appeared in the - * {@link this.antlrCtx} parse tree. - * - * This will also automatically set the parent of {@link newChild} to this instance. - * @since 0.8.0 - */ - public addNewChild(newChild: CompilableNodeChild): void { - this._children.push(newChild); - } - - /** - * Returns whether this AST node has any side effects. This means that the node will change the state of the - * program in some way and not only return a value. - * - * This specifically can mean it assigns or modifies a variable, calls a function, or throws an error. - * @since 0.11.0 - */ - public hasSideEffects(): boolean { - return false; - } - /** * The parser that generated the parse tree and {@link antlrRuleCtx antlr rule context}. * @since 0.8.0 @@ -128,22 +110,14 @@ export abstract class CompilableASTNode< * @since 0.8.0 */ public get scope(): LocalScope | GlobalScope { - if ("innerScope" in this.scopeCtx) { - return (>this.scopeCtx).innerScope; - } else { - return (this.scopeCtx).globalScope; - } + return this.scopeCtx.innerScope; } /** * The context / AST node of the {@link scope}. * @since 0.8.0 */ - public get scopeCtx(): ScopeNode | KipperProgramContext { - if (this._scopeCtx) { - return this._scopeCtx; - } - + public get scopeCtx(): ScopeNode { let parent: CompilableNodeParent = this.parent; while (parent.parent !== undefined && !("innerScope" in parent)) { parent = parent.parent; @@ -151,9 +125,9 @@ export abstract class CompilableASTNode< // If there is no parent -> root node, return the program context if (parent.parent === undefined) { - return (parent).programCtx; + return parent; } - return >parent; + return >parent; } /** @@ -165,6 +139,28 @@ export abstract class CompilableASTNode< return this.target.semanticAnalyser; } + /** + * Adds new child ctx item to this AST node. The child item should be in the order that they appeared in the + * {@link this.antlrCtx} parse tree. + * + * This will also automatically set the parent of {@link newChild} to this instance. + * @since 0.8.0 + */ + public addNewChild(newChild: CompilableNodeChild): void { + this._children.push(newChild); + } + + /** + * Returns whether this AST node has any side effects. This means that the node will change the state of the + * program in some way and not only return a value. + * + * This specifically can mean it assigns or modifies a variable, calls a function, or throws an error. + * @since 0.11.0 + */ + public hasSideEffects(): boolean { + return false; + } + /** * Generates the typescript code for this item, and all children (if they exist). * @since 0.8.0 @@ -172,9 +168,4 @@ export abstract class CompilableASTNode< public async translateCtxAndChildren(): Promise> { return await this.targetCodeGenerator(this); } - - abstract readonly targetCodeGenerator: TargetASTNodeCodeGenerator< - any, - TranslatedCodeLine | Array - >; } diff --git a/kipper/core/src/compiler/ast/mapping/ast-node-mapper.ts b/kipper/core/src/compiler/ast/mapping/ast-node-mapper.ts index b0c90325f..e67558bd6 100644 --- a/kipper/core/src/compiler/ast/mapping/ast-node-mapper.ts +++ b/kipper/core/src/compiler/ast/mapping/ast-node-mapper.ts @@ -5,7 +5,6 @@ * @since 0.11.0 */ import { - ParseRuleKindMapping, AdditiveExpressionContext, ArrayPrimaryExpressionContext, AssignmentExpressionContext, @@ -16,6 +15,7 @@ import { BoolPrimaryExpressionContext, BracketNotationMemberAccessExpressionContext, CastOrConvertExpressionContext, + ClassDeclarationContext, CompoundStatementContext, ConditionalExpressionContext, DotNotationMemberAccessExpressionContext, @@ -32,14 +32,18 @@ import { IfStatementContext, IncrementOrDecrementPostfixExpressionContext, IncrementOrDecrementUnaryExpressionContext, + InterfaceDeclarationContext, JumpStatementContext, + LambdaExpressionContext, LogicalAndExpressionContext, LogicalOrExpressionContext, MultiplicativeExpressionContext, NumberPrimaryExpressionContext, ObjectPrimaryExpressionContext, + ObjectPropertyContext, OperatorModifiedUnaryExpressionContext, ParameterDeclarationContext, + ParseRuleKindMapping, RelationalExpressionContext, ReturnStatementContext, SliceNotationMemberAccessExpressionContext, @@ -50,8 +54,6 @@ import { VariableDeclarationContext, VoidOrNullOrUndefinedPrimaryExpressionContext, WhileLoopIterationStatementContext, - ObjectPropertyContext, - LambdaExpressionContext, } from "../../lexer-parser"; import type { ASTDeclarationKind, @@ -66,8 +68,13 @@ import { AdditiveExpression, ArrayPrimaryExpression, AssignmentExpression, + BitwiseAndExpression, + BitwiseOrExpression, + BitwiseShiftExpression, + BitwiseXorExpression, BoolPrimaryExpression, CastOrConvertExpression, + ClassDeclaration, CompoundStatement, ConditionalExpression, DoWhileLoopIterationStatement, @@ -83,13 +90,16 @@ import { IfStatement, IncrementOrDecrementPostfixExpression, IncrementOrDecrementUnaryExpression, + InterfaceDeclaration, JumpStatement, + LambdaExpression, LogicalAndExpression, LogicalOrExpression, MemberAccessExpression, MultiplicativeExpression, NumberPrimaryExpression, ObjectPrimaryExpression, + ObjectProperty, OperatorModifiedUnaryExpression, ParameterDeclaration, RelationalExpression, @@ -101,12 +111,6 @@ import { VariableDeclaration, VoidOrNullOrUndefinedPrimaryExpression, WhileLoopIterationStatement, - BitwiseOrExpression, - BitwiseXorExpression, - BitwiseShiftExpression, - BitwiseAndExpression, - ObjectProperty, - LambdaExpression, } from "../nodes"; /** @@ -125,6 +129,8 @@ export class ASTNodeMapper { [ParseRuleKindMapping.RULE_functionDeclaration]: FunctionDeclaration, [ParseRuleKindMapping.RULE_variableDeclaration]: VariableDeclaration, [ParseRuleKindMapping.RULE_parameterDeclaration]: ParameterDeclaration, + [ParseRuleKindMapping.RULE_interfaceDeclaration]: InterfaceDeclaration, + [ParseRuleKindMapping.RULE_classDeclaration]: ClassDeclaration, } satisfies Record>; /** @@ -193,6 +199,8 @@ export class ASTNodeMapper { [ParseRuleKindMapping.RULE_functionDeclaration]: FunctionDeclarationContext, [ParseRuleKindMapping.RULE_variableDeclaration]: VariableDeclarationContext, [ParseRuleKindMapping.RULE_parameterDeclaration]: ParameterDeclarationContext, + [ParseRuleKindMapping.RULE_interfaceDeclaration]: InterfaceDeclarationContext, + [ParseRuleKindMapping.RULE_classDeclaration]: ClassDeclarationContext, } satisfies Record; /** @@ -266,6 +274,8 @@ export class ASTNodeMapper { RULE_functionDeclaration: FunctionDeclaration, RULE_variableDeclaration: VariableDeclaration, RULE_parameterDeclaration: ParameterDeclaration, + RULE_interfaceDeclaration: InterfaceDeclaration, + RULE_classDeclaration: ClassDeclaration, } satisfies Record>; /** diff --git a/kipper/core/src/compiler/ast/nodes/declarations/declaration.ts b/kipper/core/src/compiler/ast/nodes/declarations/declaration.ts index 45afea8bd..079f63e0c 100644 --- a/kipper/core/src/compiler/ast/nodes/declarations/declaration.ts +++ b/kipper/core/src/compiler/ast/nodes/declarations/declaration.ts @@ -14,7 +14,7 @@ import type { DeclarationTypeSemantics } from "./declaration-type-semantics"; import type { TranslatedCodeLine } from "../../../const"; import type { ASTDeclarationKind, ASTDeclarationRuleName, ParserDeclarationContext } from "../../common"; import type { TargetASTNodeCodeGenerator, TargetASTNodeSemanticAnalyser } from "../../../target-presets"; -import type { ScopeDeclaration } from "../../../analysis"; +import type { ScopeDeclaration } from "../../../semantics"; import { CompilableASTNode, type CompilableNodeParent } from "../../compilable-ast-node"; import { MissingRequiredSemanticDataError, UndefinedDeclarationCtxError } from "../../../../errors"; @@ -33,6 +33,8 @@ export abstract class Declaration< Semantics extends DeclarationSemantics = DeclarationSemantics, TypeData extends DeclarationTypeSemantics = DeclarationTypeSemantics, > extends CompilableASTNode { + public abstract targetSemanticAnalysis: TargetASTNodeSemanticAnalyser | undefined; + public abstract targetCodeGenerator: TargetASTNodeCodeGenerator>; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -40,6 +42,14 @@ export abstract class Declaration< */ protected override readonly _antlrRuleCtx: ParserDeclarationContext; + protected constructor(antlrRuleCtx: ParserDeclarationContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + + // Manually add the child to the parent + parent.addNewChild(this); + } + /** * The private field '_scopeDeclaration' that actually stores the variable data, * which is returned inside the {@link this.scopeDeclaration}. @@ -47,6 +57,19 @@ export abstract class Declaration< */ protected _scopeDeclaration: ScopeDeclaration | undefined; + /** + * The {@link ScopeDeclaration} context instance for this declaration, which is used to register the declaration + * in the {@link scope parent scope}. + * @since 0.10.0 + */ + public get scopeDeclaration(): ScopeDeclaration | undefined { + return this._scopeDeclaration; + } + + protected set scopeDeclaration(declaration: ScopeDeclaration | undefined) { + this._scopeDeclaration = declaration; + } + /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST * node wraps. @@ -66,14 +89,6 @@ export abstract class Declaration< */ public abstract get ruleName(): ASTDeclarationRuleName; - protected constructor(antlrRuleCtx: ParserDeclarationContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - - // Manually add the child to the parent - parent.addNewChild(this); - } - /** * The antlr context containing the antlr4 metadata for this expression. */ @@ -81,19 +96,6 @@ export abstract class Declaration< return this._antlrRuleCtx; } - /** - * The {@link ScopeDeclaration} context instance for this declaration, which is used to register the declaration - * in the {@link scope parent scope}. - * @since 0.10.0 - */ - public get scopeDeclaration(): ScopeDeclaration | undefined { - return this._scopeDeclaration; - } - - protected set scopeDeclaration(declaration: ScopeDeclaration | undefined) { - this._scopeDeclaration = declaration; - } - /** * Returns the {@link scopeDeclaration scope declaration ctx} of this declaration and throws an error in case * it is undefined. @@ -136,7 +138,4 @@ export abstract class Declaration< public async translateCtxAndChildren(): Promise> { return await this.targetCodeGenerator(this); } - - public abstract targetSemanticAnalysis: TargetASTNodeSemanticAnalyser | undefined; - public abstract targetCodeGenerator: TargetASTNodeCodeGenerator>; } diff --git a/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration-semantics.ts index 7c5d20d73..9c49bc525 100644 --- a/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration-semantics.ts @@ -2,7 +2,7 @@ * Semantics for AST Node {@link FunctionDeclaration}. * @since 0.3.0 */ -import type { UncheckedType } from "../../../../analysis"; +import type { RawType } from "../../../../semantics"; import type { CompoundStatement, IdentifierTypeSpecifierExpression, ParameterDeclaration } from "../../../nodes"; import type { DeclarationSemantics } from "../declaration-semantics"; @@ -20,7 +20,7 @@ export interface FunctionDeclarationSemantics extends DeclarationSemantics { * The {@link KipperType return type} of the function. * @since 0.5.0 */ - returnType: UncheckedType; + returnType: RawType; /** * The type specifier expression for the return type. * @since 0.10.0 diff --git a/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration-type-semantics.ts index 9392138da..3d7a6df54 100644 --- a/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration-type-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration-type-semantics.ts @@ -2,7 +2,7 @@ * Type semantics for AST Node {@link FunctionDeclaration}. * @since 0.10.0 */ -import type { CheckedType } from "../../../../analysis"; +import type { ProcessedType } from "../../../../semantics"; import type { DeclarationTypeSemantics } from "../declaration-type-semantics"; /** @@ -14,5 +14,5 @@ export interface FunctionDeclarationTypeSemantics extends DeclarationTypeSemanti * The {@link KipperType return type} of the function. * @since 0.10.0 */ - returnType: CheckedType; + returnType: ProcessedType; } diff --git a/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration.ts b/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration.ts index 7860f2c17..f94a81715 100644 --- a/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration.ts +++ b/kipper/core/src/compiler/ast/nodes/declarations/function-declaration/function-declaration.ts @@ -9,8 +9,8 @@ import type { FunctionDeclarationTypeSemantics } from "./function-declaration-ty import type { CompilableNodeParent } from "../../../compilable-ast-node"; import type { CompoundStatement, Statement } from "../../statements"; import type { IdentifierTypeSpecifierExpression } from "../../expressions"; -import type { ScopeFunctionDeclaration, UncheckedType } from "../../../../analysis"; -import { FunctionScope } from "../../../../analysis"; +import type { RawType, ScopeFunctionDeclaration } from "../../../../semantics"; +import { FunctionScope } from "../../../../semantics"; import type { FunctionDeclarationContext } from "../../../../lexer-parser"; import { CompoundStatementContext, @@ -32,18 +32,44 @@ export class FunctionDeclaration implements ScopeNode { /** - * The private field '_innerScope' that actually stores the variable data, - * which is returned inside the {@link this.innerScope}. - * @private + /** + * The static kind for this AST Node. + * @since 0.11.0 */ - private readonly _innerScope: FunctionScope; - + public static readonly kind = ParseRuleKindMapping.RULE_functionDeclaration; + /* /** + * + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.functionDeclaration; + readonly targetCodeGenerator = this.codeGenerator.functionDeclaration; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. * @private */ protected override readonly _antlrRuleCtx: FunctionDeclarationContext; + /** + * The private field '_innerScope' that actually stores the variable data, + * which is returned inside the {@link this.innerScope}. + * @private + */ + private readonly _innerScope: FunctionScope; + + constructor(antlrRuleCtx: FunctionDeclarationContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._innerScope = new FunctionScope(this); + } /** * The private field '_scopeDeclaration' that actually stores the variable data, @@ -53,11 +79,17 @@ export class FunctionDeclaration protected override _scopeDeclaration: ScopeFunctionDeclaration | undefined; /** - /** - * The static kind for this AST Node. - * @since 0.11.0 + * The {@link ScopeDeclaration} context instance for this declaration, which is used to register the declaration + * in the {@link scope parent scope}. + * @since 0.10.0 */ - public static readonly kind = ParseRuleKindMapping.RULE_functionDeclaration; + public get scopeDeclaration(): ScopeFunctionDeclaration | undefined { + return this._scopeDeclaration; + } + + protected set scopeDeclaration(declaration: ScopeFunctionDeclaration | undefined) { + this._scopeDeclaration = declaration; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -71,13 +103,6 @@ export class FunctionDeclaration return FunctionDeclaration.kind; } - /* /** - * - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -90,12 +115,6 @@ export class FunctionDeclaration return FunctionDeclaration.ruleName; } - constructor(antlrRuleCtx: FunctionDeclarationContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._innerScope = new FunctionScope(this); - } - /** * The antlr context containing the antlr4 metadata for this expression. */ @@ -111,19 +130,6 @@ export class FunctionDeclaration return this._innerScope; } - /** - * The {@link ScopeDeclaration} context instance for this declaration, which is used to register the declaration - * in the {@link scope parent scope}. - * @since 0.10.0 - */ - public get scopeDeclaration(): ScopeFunctionDeclaration | undefined { - return this._scopeDeclaration; - } - - protected set scopeDeclaration(declaration: ScopeFunctionDeclaration | undefined) { - this._scopeDeclaration = declaration; - } - public getScopeDeclaration(): ScopeFunctionDeclaration { /* istanbul ignore next: super function already being run/tested */ return super.getScopeDeclaration(); @@ -175,13 +181,13 @@ export class FunctionDeclaration this.programCtx.semanticCheck(this).validFunctionBody(body); const identifier = this.tokenStream.getText(declaratorCtx.sourceInterval); - const type: UncheckedType = retTypeSpecifier.getSemanticData().typeIdentifier; + const returnType: RawType = retTypeSpecifier.getSemanticData().typeIdentifier; this.semanticData = { isDefined: parseTreeChildren.find((val) => val instanceof CompoundStatementContext) !== undefined, identifier: identifier, returnTypeSpecifier: retTypeSpecifier, - returnType: type, + returnType: returnType, params: params, functionBody: body, // Will always syntactically be a compound statement }; @@ -210,15 +216,4 @@ export class FunctionDeclaration // Ensure that all code paths return a value this.programCtx.typeCheck(this).validReturnCodePathsInFunctionBody(this); } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - readonly targetSemanticAnalysis = this.semanticAnalyser.functionDeclaration; - readonly targetCodeGenerator = this.codeGenerator.functionDeclaration; } diff --git a/kipper/core/src/compiler/ast/nodes/declarations/index.ts b/kipper/core/src/compiler/ast/nodes/declarations/index.ts index e782ff02e..732b9860f 100644 --- a/kipper/core/src/compiler/ast/nodes/declarations/index.ts +++ b/kipper/core/src/compiler/ast/nodes/declarations/index.ts @@ -9,3 +9,4 @@ export * from "./declaration-type-semantics"; export * from "./parameter-declaration/"; export * from "./function-declaration/"; export * from "./variable-declaration/"; +export * from "./type-declaration/"; diff --git a/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration-semantics.ts index 73c67c86e..1079771bc 100644 --- a/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration-semantics.ts @@ -2,9 +2,9 @@ * Semantics for AST Node {@link FunctionDeclaration}. * @since 0.3.0 */ -import type { UncheckedType } from "../../../../analysis"; -import type { FunctionDeclaration, IdentifierTypeSpecifierExpression, LambdaExpression } from "../../../nodes"; +import type { RawType } from "../../../../semantics"; import type { DeclarationSemantics } from "../declaration-semantics"; +import type { FunctionDeclaration, IdentifierTypeSpecifierExpression, LambdaExpression } from "../../../nodes"; /** * Semantics for AST Node {@link ParameterDeclaration}. @@ -20,7 +20,7 @@ export interface ParameterDeclarationSemantics extends DeclarationSemantics { * The {@link KipperType type} of the parameter. * @since 0.5.0 */ - valueType: UncheckedType; + valueType: RawType; /** * The type specifier expression for the parameter type. * @since 0.10.0 diff --git a/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration-type-semantics.ts index 49170ea1d..b4fc213d4 100644 --- a/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration-type-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration-type-semantics.ts @@ -2,7 +2,7 @@ * Type semantics for AST Node {@link FunctionDeclaration}. * @since 0.10.0 */ -import type { CheckedType } from "../../../../analysis"; +import type { ProcessedType } from "../../../../semantics"; import type { DeclarationTypeSemantics } from "../declaration-type-semantics"; /** @@ -14,5 +14,5 @@ export interface ParameterDeclarationTypeSemantics extends DeclarationTypeSemant * The {@link KipperType type} of the parameter. * @since 0.10.0 */ - valueType: CheckedType; + valueType: ProcessedType; } diff --git a/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration.ts b/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration.ts index 7b53a1fed..6399ecdf9 100644 --- a/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration.ts +++ b/kipper/core/src/compiler/ast/nodes/declarations/parameter-declaration/parameter-declaration.ts @@ -5,14 +5,13 @@ import type { ParameterDeclarationSemantics } from "./parameter-declaration-semantics"; import type { ParameterDeclarationTypeSemantics } from "./parameter-declaration-type-semantics"; import type { CompilableNodeParent } from "../../../compilable-ast-node"; -import type { FunctionScope, ScopeParameterDeclaration } from "../../../../analysis"; +import type { FunctionScope, LambdaScope, ScopeParameterDeclaration } from "../../../../semantics"; import type { FunctionDeclaration } from "../function-declaration"; import type { IdentifierTypeSpecifierExpression, LambdaExpression } from "../../expressions"; import { Declaration } from "../declaration"; import type { ParameterDeclarationContext } from "../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../lexer-parser"; import { getParseTreeSource } from "../../../../../tools"; -import type { LambdaScope } from "../../../../analysis/symbol-table/lambda-scope"; /** * Function declaration class, which represents the definition of a parameter inside a {@link FunctionDeclaration}. @@ -22,6 +21,25 @@ export class ParameterDeclaration extends Declaration< ParameterDeclarationSemantics, ParameterDeclarationTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_parameterDeclaration; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.parameterDeclaration; + readonly targetCodeGenerator = this.codeGenerator.parameterDeclaration; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -29,6 +47,11 @@ export class ParameterDeclaration extends Declaration< */ protected override readonly _antlrRuleCtx: ParameterDeclarationContext; + constructor(antlrRuleCtx: ParameterDeclarationContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } + /** * The private field '_scopeDeclaration' that actually stores the variable data, * which is returned inside the {@link this.scopeDeclaration}. @@ -37,10 +60,17 @@ export class ParameterDeclaration extends Declaration< protected override _scopeDeclaration: ScopeParameterDeclaration | undefined; /** - * The static kind for this AST Node. - * @since 0.11.0 + * The {@link ScopeDeclaration} context instance for this declaration, which is used to register the declaration + * in the {@link scope parent scope}. + * @since 0.10.0 */ - public static readonly kind = ParseRuleKindMapping.RULE_parameterDeclaration; + public override get scopeDeclaration(): ScopeParameterDeclaration | undefined { + return this._scopeDeclaration; + } + + protected override set scopeDeclaration(declaration: ScopeParameterDeclaration | undefined) { + this._scopeDeclaration = declaration; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -54,12 +84,6 @@ export class ParameterDeclaration extends Declaration< return ParameterDeclaration.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -72,11 +96,6 @@ export class ParameterDeclaration extends Declaration< return ParameterDeclaration.ruleName; } - constructor(antlrRuleCtx: ParameterDeclarationContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - } - /** * The antlr context containing the antlr4 metadata for this expression. */ @@ -84,19 +103,6 @@ export class ParameterDeclaration extends Declaration< return this._antlrRuleCtx; } - /** - * The {@link ScopeDeclaration} context instance for this declaration, which is used to register the declaration - * in the {@link scope parent scope}. - * @since 0.10.0 - */ - public override get scopeDeclaration(): ScopeParameterDeclaration | undefined { - return this._scopeDeclaration; - } - - protected override set scopeDeclaration(declaration: ScopeParameterDeclaration | undefined) { - this._scopeDeclaration = declaration; - } - public override getScopeDeclaration(): ScopeParameterDeclaration { /* istanbul ignore next: super function already being run/tested */ return super.getScopeDeclaration(); @@ -116,14 +122,6 @@ export class ParameterDeclaration extends Declaration< this.scopeDeclaration = scopeToUse.addArgument(this); } - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - /** * Performs the semantic analysis for this Kipper token. This will log all warnings using {@link programCtx.logger} * and throw errors if encountered. @@ -170,7 +168,4 @@ export class ParameterDeclaration extends Declaration< valueType: valueType, }; } - - readonly targetSemanticAnalysis = this.semanticAnalyser.parameterDeclaration; - readonly targetCodeGenerator = this.codeGenerator.parameterDeclaration; } diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/class-declaration-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/class-declaration-semantics.ts new file mode 100644 index 000000000..e146a8edc --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/class-declaration-semantics.ts @@ -0,0 +1,17 @@ +/** + * Semantics for AST Node {@link ClassDeclaration}. + * @since 0.11.0 + */ +import type { TypeDeclarationSemantics } from "../type-declaration-semantics"; + +/** + * Semantics for AST Node {@link ClassDeclaration}. + * @since 0.11.0 + */ +export interface ClassDeclarationSemantics extends TypeDeclarationSemantics { + /** + * The identifier of this class. + * @since 0.11.0 + */ + identifier: string; +} diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/class-declaration-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/class-declaration-type-semantics.ts new file mode 100644 index 000000000..8963de3b3 --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/class-declaration-type-semantics.ts @@ -0,0 +1,11 @@ +/** + * Type semantics for AST Node {@link ClassDeclaration}. + * @since 0.11.0 + */ +import type { TypeDeclarationTypeSemantics } from "../type-declaration-type-semantics"; + +/** + * Type semantics for AST Node {@link ClassDeclaration}. + * @since 0.11.0 + */ +export interface ClassDeclarationTypeSemantics extends TypeDeclarationTypeSemantics {} diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/class-declaration.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/class-declaration.ts new file mode 100644 index 000000000..0a284fc0a --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/class-declaration.ts @@ -0,0 +1,153 @@ +/** + * Represents a class declaration in the Kipper language, which may contain methods and fields. + * @since 0.11.0 + */ +import type { ScopeNode } from "../../../../scope-node"; +import type { ClassDeclarationSemantics } from "./class-declaration-semantics"; +import type { ClassDeclarationTypeSemantics } from "./class-declaration-type-semantics"; +import type { CompilableNodeParent } from "../../../../compilable-ast-node"; +import type { ScopeTypeDeclaration } from "../../../../../semantics"; +import type { ClassDeclarationContext } from "../../../../../lexer-parser"; +import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; +import { KipperNotImplementedError } from "../../../../../../errors"; +import { ClassScope } from "../../../../../semantics/symbol-table/class-scope"; +import { TypeDeclaration } from "../type-declaration"; + +/** + * Represents a class declaration in the Kipper language, which may contain methods and fields. + * @since 0.11.0 + */ +export class ClassDeclaration + extends TypeDeclaration + implements ScopeNode +{ + /** + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_classDeclaration; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.11.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.classDeclaration; + readonly targetCodeGenerator = this.codeGenerator.classDeclaration; + /** + * The private field '_antlrRuleCtx' that actually stores the variable data, + * which is returned inside the {@link this.antlrRuleCtx}. + * @private + */ + protected override readonly _antlrRuleCtx: ClassDeclarationContext; + /** + * The private field '_innerScope' that actually stores the variable data, + * which is returned inside the {@link this.innerScope}. + * @private + */ + private readonly _innerScope: ClassScope; + + constructor(antlrRuleCtx: ClassDeclarationContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._innerScope = new ClassScope(this); + } + + /** + * The private field '_scopeDeclaration' that actually stores the variable data, + * which is returned inside the {@link this.scopeDeclaration}. + * @private + */ + protected override _scopeDeclaration: ScopeTypeDeclaration | undefined; + + /** + * The {@link ScopeDeclaration} context instance for this declaration, which is used to register the declaration + * in the {@link scope parent scope}. + * @since 0.11.0 + */ + public get scopeDeclaration(): ScopeTypeDeclaration | undefined { + return this._scopeDeclaration; + } + + protected set scopeDeclaration(declaration: ScopeTypeDeclaration | undefined) { + this._scopeDeclaration = declaration; + } + + /** + * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST + * node wraps. + * + * This may be compared using the {@link ParseRuleKindMapping rule fields}, for example + * {@link ParseRuleKindMapping.RULE_declaration}. + * @since 0.11.0 + */ + public override get kind() { + return ClassDeclaration.kind; + } + + /** + * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this + * AST node wraps. + * + * This may be compared using the {@link ParseRuleKindMapping rule fields}, for example + * {@link ParseRuleKindMapping.RULE_declaration}. + * @since 0.11.0 + */ + public override get ruleName() { + return ClassDeclaration.ruleName; + } + + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): ClassDeclarationContext { + return this._antlrRuleCtx; + } + + /** + * Gets the inner scope of this class. + * @since 0.11.0 + */ + public get innerScope(): ClassScope { + return this._innerScope; + } + + public getScopeDeclaration(): ScopeTypeDeclaration { + /* istanbul ignore next: super function already being run/tested */ + return super.getScopeDeclaration(); + } + + /** + * Performs the semantic analysis for this Kipper token. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the semantic analysis of + * the children has already failed and as such no parent node should run type checking. + */ + public async primarySemanticAnalysis(): Promise { + this.programCtx + .semanticCheck(this) + .notImplementedError(new KipperNotImplementedError("Class declarations are not yet implemented.")); + } + + /** + * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of + * the children has already failed and as such no parent node should run type checking. + * @since 0.11.0 + */ + public async primarySemanticTypeChecking(): Promise { + this.programCtx + .semanticCheck(this) + .notImplementedError(new KipperNotImplementedError("Class declarations are not yet implemented.")); + } +} diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/index.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/index.ts new file mode 100644 index 000000000..93aafc51e --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/class-declaration/index.ts @@ -0,0 +1,8 @@ +/** + * AST Node {@link ClassDeclaration} and the related {@link ClassDeclarationSemantics semantics} and + * {@link ClassDeclarationTypeSemantics type semantics}. + * @since 0.11.0 + */ +export * from "./class-declaration"; +export * from "./class-declaration-semantics"; +export * from "./class-declaration-type-semantics"; diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/index.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/index.ts new file mode 100644 index 000000000..2b38dca6e --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/index.ts @@ -0,0 +1,9 @@ +/** + * Type declarations such as interface and class declarations in the Kipper language. + * @since 0.11.0 + */ +export * from "./type-declaration"; +export * from "./type-declaration-semantics"; +export * from "./type-declaration-type-semantics"; +export * from "./class-declaration/"; +export * from "./interface-declaration/"; diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/index.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/index.ts new file mode 100644 index 000000000..3bba5b835 --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/index.ts @@ -0,0 +1,8 @@ +/** + * AST Node {@link InterfaceDeclaration} and the related {@link InterfaceDeclarationSemantics semantics} and + * {@link InterfaceDeclarationTypeSemantics type semantics}. + * @since 0.11.0 + */ +export * from "./interface-declaration"; +export * from "./interface-declaration-semantics"; +export * from "./interface-declaration-type-semantics"; diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/interface-declaration-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/interface-declaration-semantics.ts new file mode 100644 index 000000000..8448441ea --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/interface-declaration-semantics.ts @@ -0,0 +1,17 @@ +/** + * Semantics for AST Node {@link ClassDeclaration}. + * @since 0.11.0 + */ +import type { TypeDeclarationSemantics } from "../type-declaration-semantics"; + +/** + * Semantics for AST Node {@link ClassDeclaration}. + * @since 0.11.0 + */ +export interface InterfaceDeclarationSemantics extends TypeDeclarationSemantics { + /** + * The identifier of this interface. + * @since 0.11.0 + */ + identifier: string; +} diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/interface-declaration-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/interface-declaration-type-semantics.ts new file mode 100644 index 000000000..161e6498e --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/interface-declaration-type-semantics.ts @@ -0,0 +1,11 @@ +/** + * Type semantics for AST Node {@link ClassDeclaration}. + * @since 0.11.0 + */ +import type { TypeDeclarationTypeSemantics } from "../type-declaration-type-semantics"; + +/** + * Type semantics for AST Node {@link ClassDeclaration}. + * @since 0.11.0 + */ +export interface InterfaceDeclarationTypeSemantics extends TypeDeclarationTypeSemantics {} diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/interface-declaration.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/interface-declaration.ts new file mode 100644 index 000000000..a458613ea --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/interface-declaration/interface-declaration.ts @@ -0,0 +1,136 @@ +/** + * Represents an interface declaration in the Kipper language, which may contain methods and fields declarations. + * @since 0.11.0 + */ +import type { InterfaceDeclarationSemantics } from "./interface-declaration-semantics"; +import type { InterfaceDeclarationTypeSemantics } from "./interface-declaration-type-semantics"; +import type { CompilableNodeParent } from "../../../../compilable-ast-node"; +import type { ScopeTypeDeclaration } from "../../../../../semantics"; +import type { InterfaceDeclarationContext } from "../../../../../lexer-parser"; +import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; +import { KipperNotImplementedError } from "../../../../../../errors"; +import { TypeDeclaration } from "../type-declaration"; + +/** + * Represents an interface declaration in the Kipper language, which may contain methods and fields declarations. + * @since 0.11.0 + */ +export class InterfaceDeclaration extends TypeDeclaration< + InterfaceDeclarationSemantics, + InterfaceDeclarationTypeSemantics +> { + /** + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_interfaceDeclaration; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.11.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.interfaceDeclaration; + readonly targetCodeGenerator = this.codeGenerator.interfaceDeclaration; + /** + * The private field '_antlrRuleCtx' that actually stores the variable data, + * which is returned inside the {@link this.antlrRuleCtx}. + * @private + */ + protected override readonly _antlrRuleCtx: InterfaceDeclarationContext; + + constructor(antlrRuleCtx: InterfaceDeclarationContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } + + /** + * The private field '_scopeDeclaration' that actually stores the variable data, + * which is returned inside the {@link this.scopeDeclaration}. + * @private + */ + protected override _scopeDeclaration: ScopeTypeDeclaration | undefined; + + /** + * The {@link ScopeDeclaration} context instance for this declaration, which is used to register the declaration + * in the {@link scope parent scope}. + * @since 0.11.0 + */ + public get scopeDeclaration(): ScopeTypeDeclaration | undefined { + return this._scopeDeclaration; + } + + protected set scopeDeclaration(declaration: ScopeTypeDeclaration | undefined) { + this._scopeDeclaration = declaration; + } + + /** + * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST + * node wraps. + * + * This may be compared using the {@link ParseRuleKindMapping rule fields}, for example + * {@link ParseRuleKindMapping.RULE_declaration}. + * @since 0.11.0 + */ + public override get kind() { + return InterfaceDeclaration.kind; + } + + /** + * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this + * AST node wraps. + * + * This may be compared using the {@link ParseRuleKindMapping rule fields}, for example + * {@link ParseRuleKindMapping.RULE_declaration}. + * @since 0.11.0 + */ + public override get ruleName() { + return InterfaceDeclaration.ruleName; + } + + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): InterfaceDeclarationContext { + return this._antlrRuleCtx; + } + + public getScopeDeclaration(): ScopeTypeDeclaration { + /* istanbul ignore next: super function already being run/tested */ + return super.getScopeDeclaration(); + } + + /** + * Performs the semantic analysis for this Kipper token. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the semantic analysis of + * the children has already failed and as such no parent node should run type checking. + */ + public async primarySemanticAnalysis(): Promise { + this.programCtx + .semanticCheck(this) + .notImplementedError(new KipperNotImplementedError("Interface declarations are not yet implemented.")); + } + + /** + * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of + * the children has already failed and as such no parent node should run type checking. + * @since 0.11.0 + */ + public async primarySemanticTypeChecking(): Promise { + this.programCtx + .semanticCheck(this) + .notImplementedError(new KipperNotImplementedError("Interface declarations are not yet implemented.")); + } +} diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/type-declaration-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/type-declaration-semantics.ts new file mode 100644 index 000000000..6f1e836a1 --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/type-declaration-semantics.ts @@ -0,0 +1,13 @@ +import type { SemanticData } from "../../../ast-node"; + +/** + * Semantics for a {@link TypeDeclaration}. + * @since 0.11.0 + */ +export interface TypeDeclarationSemantics extends SemanticData { + /** + * The identifier of the type declaration. + * @since 0.11.0 + */ + identifier: string; +} diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/type-declaration-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/type-declaration-type-semantics.ts new file mode 100644 index 000000000..928e1899d --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/type-declaration-type-semantics.ts @@ -0,0 +1,14 @@ +import type { TypeData } from "../../../ast-node"; +import type { CustomType } from "../../../../semantics"; + +/** + * Type semantics for a {@link TypeDeclaration}. + * @since 0.11.0 + */ +export interface TypeDeclarationTypeSemantics extends TypeData { + /** + * The processed type of the type declaration. + * @since 0.11.0 + */ + type: CustomType; +} diff --git a/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/type-declaration.ts b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/type-declaration.ts new file mode 100644 index 000000000..63531ecd1 --- /dev/null +++ b/kipper/core/src/compiler/ast/nodes/declarations/type-declaration/type-declaration.ts @@ -0,0 +1,44 @@ +import type { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../lexer-parser"; +import type { ASTNodeMapper } from "../../../mapping"; +import type { TypeDeclarationSemantics } from "./type-declaration-semantics"; +import type { TypeDeclarationTypeSemantics } from "./type-declaration-type-semantics"; +import { Declaration } from "../declaration"; + +/** + * Union type of all possible {@link ParserASTNode.kind} values for a constructable {@link TypeDeclaration} AST node. + * @since 0.10.0 + */ +export type ASTTypeDeclarationKind = + | typeof ParseRuleKindMapping.RULE_interfaceDeclaration + | typeof ParseRuleKindMapping.RULE_classDeclaration; + +/** + * Union type of all possible {@link ParserASTNode} context classes for a constructable {@link TypeDeclaration} AST node. + * @since 0.10.0 + */ +export type ParserTypeDeclarationContext = InstanceType< + (typeof ASTNodeMapper.declarationKindToRuleContextMap)[ASTTypeDeclarationKind] +>; + +/** + * Union type of all possible {@link ParserASTNode.ruleName} values for a constructable {@link TypeDeclaration} + * AST node. + * @since 0.11.0 + */ +export type ParserTypeDeclarationRuleName = (typeof KindParseRuleMapping)[ASTTypeDeclarationKind]; + +/** + * Abstract comparative expression class representing a comparative expression, which can be used to compare two + * expressions. This abstract class only exists to provide the commonality between the different comparative expressions. + * @since 0.9.0 + */ +export abstract class TypeDeclaration< + Semantics extends TypeDeclarationSemantics = TypeDeclarationSemantics, + TypeSemantics extends TypeDeclarationTypeSemantics = TypeDeclarationTypeSemantics, +> extends Declaration { + protected abstract readonly _antlrRuleCtx: ParserTypeDeclarationContext; + + public abstract get kind(): ASTTypeDeclarationKind; + + public abstract get ruleName(): ParserTypeDeclarationRuleName; +} diff --git a/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration-semantics.ts index f2f46ef42..ea38cad91 100644 --- a/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration-semantics.ts @@ -3,7 +3,7 @@ * @since 0.3.0 */ import type { KipperStorageType } from "../../../../const"; -import type { Scope, UncheckedType } from "../../../../analysis"; +import type { RawType, Scope } from "../../../../semantics"; import type { Expression, IdentifierTypeSpecifierExpression } from "../../../nodes"; import type { DeclarationSemantics } from "../declaration-semantics"; @@ -28,7 +28,7 @@ export interface VariableDeclarationSemantics extends DeclarationSemantics { * The identifier of the {@link valueTypeSpecifier.semanticData.identifier typeSpecifier}. * @since 0.5.0 */ - valueType: UncheckedType; + valueType: RawType; /** * The type specifier expression for the variable type. * @since 0.10.0 diff --git a/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration-type-semantics.ts index 4bca21c55..dc8f80d12 100644 --- a/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration-type-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration-type-semantics.ts @@ -2,7 +2,7 @@ * Type semantics for AST Node {@link FunctionDeclaration}. * @since 0.10.0 */ -import type { CheckedType } from "../../../../analysis"; +import type { ProcessedType } from "../../../../semantics"; import type { DeclarationTypeSemantics } from "../declaration-type-semantics"; /** @@ -16,5 +16,5 @@ export interface VariableDeclarationTypeSemantics extends DeclarationTypeSemanti * This is the type evaluated using the {@link VariableDeclarationSemantics.valueType valueType identifier}. * @since 0.10.0 */ - valueType: CheckedType; + valueType: ProcessedType; } diff --git a/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration.ts b/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration.ts index ce4550dde..4438c25fe 100644 --- a/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration.ts +++ b/kipper/core/src/compiler/ast/nodes/declarations/variable-declaration/variable-declaration.ts @@ -8,7 +8,7 @@ import type { VariableDeclarationSemantics } from "./variable-declaration-semantics"; import type { VariableDeclarationTypeSemantics } from "./variable-declaration-type-semantics"; import type { CompilableNodeParent } from "../../../compilable-ast-node"; -import type { ScopeVariableDeclaration, UncheckedType } from "../../../../analysis"; +import type { RawType, ScopeVariableDeclaration } from "../../../../semantics"; import type { Expression, IdentifierTypeSpecifierExpression } from "../../expressions"; import type { ParseTree } from "antlr4ts/tree"; import type { KipperStorageType } from "../../../../const"; @@ -31,6 +31,25 @@ import { UnableToDetermineSemanticDataError } from "../../../../../errors"; * (accessible for the entire program). */ export class VariableDeclaration extends Declaration { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_variableDeclaration; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.variableDeclaration; + readonly targetCodeGenerator = this.codeGenerator.variableDeclaration; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -38,6 +57,12 @@ export class VariableDeclaration extends Declaration; + public override get children(): Array { + return this._children; + } + /** * The private field '_scopeDeclaration' that actually stores the variable data, * which is returned inside the {@link this.scopeDeclaration}. @@ -53,10 +82,17 @@ export class VariableDeclaration extends Declaration { - return this._children; - } - - /** - * The {@link ScopeDeclaration} context instance for this declaration, which is used to register the declaration - * in the {@link scope parent scope}. - * @since 0.10.0 - */ - public get scopeDeclaration(): ScopeVariableDeclaration | undefined { - return this._scopeDeclaration; - } - - protected set scopeDeclaration(declaration: ScopeVariableDeclaration | undefined) { - this._scopeDeclaration = declaration; - } - public getScopeDeclaration(): ScopeVariableDeclaration { return super.getScopeDeclaration(); } @@ -160,7 +167,7 @@ export class VariableDeclaration extends Declarationthis.tokenStream.getText(storageTypeCtx.sourceInterval); - const valueType: UncheckedType = typeSpecifier.getSemanticData().typeIdentifier; + const valueType: RawType = typeSpecifier.getSemanticData().typeIdentifier; this.semanticData = { isDefined: isDefined, @@ -204,15 +211,4 @@ export class VariableDeclaration extends Declaration { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_additiveExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.additiveExpression; + readonly targetCodeGenerator = this.codeGenerator.additiveExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -39,11 +58,10 @@ export class AdditiveExpression extends ArithmeticExpression< */ protected override readonly _antlrRuleCtx: AdditiveExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_additiveExpression; + constructor(antlrRuleCtx: AdditiveExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -57,12 +75,6 @@ export class AdditiveExpression extends ArithmeticExpression< return AdditiveExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -75,9 +87,11 @@ export class AdditiveExpression extends ArithmeticExpression< return AdditiveExpression.ruleName; } - constructor(antlrRuleCtx: AdditiveExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): AdditiveExpressionContext { + return this._antlrRuleCtx; } /** @@ -133,22 +147,4 @@ export class AdditiveExpression extends ArithmeticExpression< evaluatedType: semanticData.leftOp.getTypeSemanticData().evaluatedType, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): AdditiveExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.additiveExpression; - readonly targetCodeGenerator = this.codeGenerator.additiveExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/arithmetic/arithmetic-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/arithmetic/arithmetic-expression.ts index 30a935af7..971fdfe0c 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/arithmetic/arithmetic-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/arithmetic/arithmetic-expression.ts @@ -6,10 +6,9 @@ */ import type { ArithmeticExpressionSemantics } from "./arithmetic-expression-semantics"; import type { ArithmeticExpressionTypeSemantics } from "./arithmetic-expression-type-semantics"; -import type { ParseRuleKindMapping } from "../../../../lexer-parser"; -import type { KindParseRuleMapping } from "../../../../lexer-parser"; -import { Expression } from "../expression"; +import type { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../lexer-parser"; import type { ASTNodeMapper } from "../../../mapping"; +import { Expression } from "../expression"; /** * Union type of all possible {@link ParserASTNode.kind} values for a constructable {@link ArithmeticExpression} AST node. @@ -45,6 +44,8 @@ export abstract class ArithmeticExpression< TypeSemantics extends ArithmeticExpressionTypeSemantics = ArithmeticExpressionTypeSemantics, > extends Expression { protected abstract readonly _antlrRuleCtx: ParserArithmeticExpressionContext; + public abstract get kind(): ASTArithmeticExpressionKind; + public abstract get ruleName(): ParserArithmeticExpressionRuleName; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/arithmetic/multiplicative-expression/multiplicative-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/arithmetic/multiplicative-expression/multiplicative-expression.ts index e027b3e64..0d2c09c57 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/arithmetic/multiplicative-expression/multiplicative-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/arithmetic/multiplicative-expression/multiplicative-expression.ts @@ -20,7 +20,7 @@ import { kipperMultiplicativeOperators } from "../../../../../const"; import { TerminalNode } from "antlr4ts/tree/TerminalNode"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; import { ArithmeticExpression } from "../arithmetic-expression"; -import { kipperInternalBuiltInFunctions } from "../../../../../runtime-built-ins"; +import { BuiltInTypes, kipperInternalBuiltInFunctions } from "../../../../../semantics"; /** * Multiplicative expression, which can be used to perform multiplicative operations on two expressions. @@ -37,6 +37,25 @@ export class MultiplicativeExpression extends ArithmeticExpression< MultiplicativeExpressionSemantics, MultiplicativeTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_multiplicativeExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.multiplicativeExpression; + readonly targetCodeGenerator = this.codeGenerator.multiplicativeExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link antlrRuleCtx}. @@ -44,11 +63,10 @@ export class MultiplicativeExpression extends ArithmeticExpression< */ protected override readonly _antlrRuleCtx: MultiplicativeExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_multiplicativeExpression; + constructor(antlrRuleCtx: MultiplicativeExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -62,12 +80,6 @@ export class MultiplicativeExpression extends ArithmeticExpression< return MultiplicativeExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -80,9 +92,11 @@ export class MultiplicativeExpression extends ArithmeticExpression< return MultiplicativeExpression.ruleName; } - constructor(antlrRuleCtx: MultiplicativeExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): MultiplicativeExpressionContext { + return this._antlrRuleCtx; } /** @@ -141,28 +155,10 @@ export class MultiplicativeExpression extends ArithmeticExpression< }; if ( - semanticData.leftOp.getTypeSemanticData().evaluatedType.getCompilableType() === "str" && - semanticData.rightOp.getTypeSemanticData().evaluatedType.getCompilableType() === "num" + semanticData.leftOp.getTypeSemanticData().evaluatedType === BuiltInTypes.str && + semanticData.rightOp.getTypeSemanticData().evaluatedType === BuiltInTypes.num ) { this.programCtx.addInternalReference(this, kipperInternalBuiltInFunctions["repeatString"]); } } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): MultiplicativeExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.multiplicativeExpression; - readonly targetCodeGenerator = this.codeGenerator.multiplicativeExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/assignment-expression/assignment-expression-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/assignment-expression/assignment-expression-semantics.ts index eec8fbd28..ed7099329 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/assignment-expression/assignment-expression-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/assignment-expression/assignment-expression-semantics.ts @@ -2,7 +2,7 @@ * Semantics for AST Node {@link AssignmentExpression}. * @since 0.5.0 */ -import type { Reference } from "../../../../analysis"; +import type { Reference } from "../../../../semantics"; import type { KipperAssignOperator } from "../../../../const"; import type { Expression } from "../expression"; import type { ExpressionSemantics } from "../expression-semantics"; diff --git a/kipper/core/src/compiler/ast/nodes/expressions/assignment-expression/assignment-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/assignment-expression/assignment-expression.ts index f33474ad7..9ee088d1d 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/assignment-expression/assignment-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/assignment-expression/assignment-expression.ts @@ -23,7 +23,7 @@ import { UnableToDetermineSemanticDataError } from "../../../../../errors"; import type { KipperAssignOperator } from "../../../../const"; import { kipperArithmeticAssignOperators } from "../../../../const"; import { getParseRuleSource } from "../../../../../tools"; -import { ScopeVariableDeclaration } from "../../../../analysis"; +import { ScopeVariableDeclaration } from "../../../../semantics"; /** * Assignment expression, which assigns an expression to a variable. This class only represents assigning a value to @@ -44,6 +44,25 @@ export class AssignmentExpression extends Expression< AssignmentExpressionTypeSemantics, Expression > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_assignmentExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.assignmentExpression; + readonly targetCodeGenerator = this.codeGenerator.assignmentExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -51,11 +70,10 @@ export class AssignmentExpression extends Expression< */ protected override readonly _antlrRuleCtx: AssignmentExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_assignmentExpression; + constructor(antlrRuleCtx: AssignmentExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -69,12 +87,6 @@ export class AssignmentExpression extends Expression< return AssignmentExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -87,9 +99,11 @@ export class AssignmentExpression extends Expression< return AssignmentExpression.ruleName; } - constructor(antlrRuleCtx: AssignmentExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): AssignmentExpressionContext { + return this._antlrRuleCtx; } public hasSideEffects(): boolean { @@ -141,7 +155,7 @@ export class AssignmentExpression extends Expression< // If the reference was a variable, indicate that the value was updated, since it's being assigned to if (identifierSemantics.ref.refTarget instanceof ScopeVariableDeclaration) { - identifierSemantics.ref.refTarget.valueWasUpdated = true; + identifierSemantics.ref.refTarget.notifyOfUpdate(); } } @@ -164,22 +178,4 @@ export class AssignmentExpression extends Expression< // Ensure the assignment is valid and the types match up this.programCtx.typeCheck(this).validAssignment(this); } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): AssignmentExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.assignmentExpression; - readonly targetCodeGenerator = this.codeGenerator.assignmentExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-and-expression/bitwise-and-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-and-expression/bitwise-and-expression.ts index e6c0a29a7..4a5e4cee8 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-and-expression/bitwise-and-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-and-expression/bitwise-and-expression.ts @@ -7,7 +7,6 @@ * 0 & 1 // 0 * 0 & 0 // 0 */ - import type { BitwiseAndExpressionSemantics } from "./bitwise-and-expression-semantics"; import type { BitwiseAndExpressionTypeSemantics } from "./bitwise-and-expression-type-semantics"; import { BitwiseExpression } from "../bitwise-expression"; @@ -16,7 +15,7 @@ import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer import type { CompilableASTNode } from "../../../../compilable-ast-node"; import type { Expression } from "../../expression"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; /** * Bitwise and expression AST node. @@ -31,6 +30,23 @@ export class BitwiseAndExpression extends BitwiseExpression< BitwiseAndExpressionSemantics, BitwiseAndExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_bitwiseAndExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * The primary code generation for this AST node. + * @since 0.11.0 + */ + public checkForWarnings = undefined; + readonly targetSemanticAnalysis = this.semanticAnalyser.bitwiseAndExpression; + readonly targetCodeGenerator = this.codeGenerator.bitwiseAndExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -38,11 +54,10 @@ export class BitwiseAndExpression extends BitwiseExpression< */ protected override readonly _antlrRuleCtx: BitwiseAndExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_bitwiseAndExpression; + constructor(antlrRuleCtx: BitwiseAndExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -56,19 +71,16 @@ export class BitwiseAndExpression extends BitwiseExpression< return BitwiseAndExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - public override get ruleName() { return BitwiseAndExpression.ruleName; } - constructor(antlrRuleCtx: BitwiseAndExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The primary code generation for this AST node. + * @since 0.11.0 + */ + public override get antlrRuleCtx(): BitwiseAndExpressionContext { + return this._antlrRuleCtx; } /** @@ -102,25 +114,7 @@ export class BitwiseAndExpression extends BitwiseExpression< .validBitwiseExpression(semanticData.leftOp, semanticData.rightOp, semanticData.operator); this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("num"), + evaluatedType: BuiltInTypes.num, }; } - - /** - * The primary code generation for this AST node. - * @since 0.11.0 - */ - public checkForWarnings = undefined; - - /** - * The primary code generation for this AST node. - * @since 0.11.0 - */ - public override get antlrRuleCtx(): BitwiseAndExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.bitwiseAndExpression; - - readonly targetCodeGenerator = this.codeGenerator.bitwiseAndExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-expression.ts index 9a92455cc..fc571d871 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-expression.ts @@ -44,6 +44,8 @@ export abstract class BitwiseExpression< TypeSemantics extends BitwiseExpressionTypeSemantics = BitwiseExpressionTypeSemantics, > extends Expression { protected abstract readonly _antlrRuleCtx: ParserBitwiseExpressionContext; + public abstract get kind(): ASTBitwiseExpressionKind; + public abstract get ruleName(): ParserBitwiseExpressionRuleName; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-or-expression/bitwise-or-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-or-expression/bitwise-or-expression.ts index ae416fe28..c01d3a7b8 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-or-expression/bitwise-or-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-or-expression/bitwise-or-expression.ts @@ -8,14 +8,13 @@ * 0 | 1 // 1 * 0 | 0 // 0 */ - import { BitwiseExpression } from "../bitwise-expression"; import type { BitwiseOrExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; import type { CompilableASTNode } from "../../../../compilable-ast-node"; import type { Expression } from "../../expression"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; import type { BitwiseOrExpressionSemantics } from "./bitwise-or-expression-semantics"; import type { BitwiseOrExpressionTypeSemantics } from "./bitwise-or-expression-type-semantics"; @@ -33,6 +32,19 @@ export class BitwiseOrExpression extends BitwiseExpression< BitwiseOrExpressionSemantics, BitwiseOrExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_bitwiseOrExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + public checkForWarnings = undefined; + readonly targetSemanticAnalysis = this.semanticAnalyser.bitwiseOrExpression; + readonly targetCodeGenerator = this.codeGenerator.bitwiseOrExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -40,11 +52,10 @@ export class BitwiseOrExpression extends BitwiseExpression< */ protected override readonly _antlrRuleCtx: BitwiseOrExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_bitwiseOrExpression; + constructor(antlrRuleCtx: BitwiseOrExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -58,12 +69,6 @@ export class BitwiseOrExpression extends BitwiseExpression< return BitwiseOrExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the name of the rule for this AST node. This represents the specific type of the {@link antlrRuleCtx} that * this AST node wraps. @@ -73,9 +78,8 @@ export class BitwiseOrExpression extends BitwiseExpression< return BitwiseOrExpression.ruleName; } - constructor(antlrRuleCtx: BitwiseOrExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + public override get antlrRuleCtx(): BitwiseOrExpressionContext { + return this._antlrRuleCtx; } /** @@ -109,17 +113,7 @@ export class BitwiseOrExpression extends BitwiseExpression< .validBitwiseExpression(semanticData.leftOp, semanticData.rightOp, semanticData.operator); this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("num"), + evaluatedType: BuiltInTypes.num, }; } - - public checkForWarnings = undefined; - - public override get antlrRuleCtx(): BitwiseOrExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.bitwiseOrExpression; - - readonly targetCodeGenerator = this.codeGenerator.bitwiseOrExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-shift-expression/bitwise-shift-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-shift-expression/bitwise-shift-expression.ts index f73eae96e..c0303edb9 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-shift-expression/bitwise-shift-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-shift-expression/bitwise-shift-expression.ts @@ -9,14 +9,13 @@ * 2 >> 1 // 1 * 2 >>> 1 // 1 */ - import { BitwiseExpression } from "../bitwise-expression"; import type { BitwiseOrExpressionContext, BitwiseShiftExpressionContext } from "../../../../../lexer-parser"; import { BitwiseShiftOperatorsContext, KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; import type { CompilableASTNode } from "../../../../compilable-ast-node"; import type { Expression } from "../../expression"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; import type { BitwiseShiftExpressionSemantics } from "./bitwise-shift-expression-semantics"; import type { BitwiseShiftExpressionTypeSemantics } from "./bitwise-shift-expression-type-semantics"; import type { KipperBitwiseShiftOperator } from "../../../../../const"; @@ -37,6 +36,19 @@ export class BitwiseShiftExpression extends BitwiseExpression< BitwiseShiftExpressionSemantics, BitwiseShiftExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_bitwiseShiftExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + public checkForWarnings = undefined; + readonly targetSemanticAnalysis = this.semanticAnalyser.bitwiseShiftExpression; + readonly targetCodeGenerator = this.codeGenerator.bitwiseShiftExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -44,11 +56,10 @@ export class BitwiseShiftExpression extends BitwiseExpression< */ protected override readonly _antlrRuleCtx: BitwiseShiftExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_bitwiseShiftExpression; + constructor(antlrRuleCtx: BitwiseShiftExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -62,12 +73,6 @@ export class BitwiseShiftExpression extends BitwiseExpression< return BitwiseShiftExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -80,9 +85,12 @@ export class BitwiseShiftExpression extends BitwiseExpression< return BitwiseShiftExpression.ruleName; } - constructor(antlrRuleCtx: BitwiseShiftExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr rule context for this AST node. + * @since 0.11.0 + */ + public override get antlrRuleCtx(): BitwiseOrExpressionContext { + return this._antlrRuleCtx; } /** @@ -134,20 +142,7 @@ export class BitwiseShiftExpression extends BitwiseExpression< .validBitwiseExpression(semanticData.leftOp, semanticData.rightOp, semanticData.operator); this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("num"), + evaluatedType: BuiltInTypes.num, }; } - - public checkForWarnings = undefined; - - /** - * The antlr rule context for this AST node. - * @since 0.11.0 - */ - public override get antlrRuleCtx(): BitwiseOrExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.bitwiseShiftExpression; - readonly targetCodeGenerator = this.codeGenerator.bitwiseShiftExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-xor-expression/bitwise-xor-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-xor-expression/bitwise-xor-expression.ts index 773937b36..9d5e599a3 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-xor-expression/bitwise-xor-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/bitwise-expression/bitwise-xor-expression/bitwise-xor-expression.ts @@ -13,7 +13,7 @@ import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer import type { CompilableASTNode } from "../../../../compilable-ast-node"; import type { Expression } from "../../expression"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; import type { BitwiseXorExpressionSemantics } from "./bitwise-xor-expression-semantics"; import type { BitwiseXorExpressionTypeSemantics } from "./bitwise-xor-expression-type-semantics"; @@ -30,6 +30,23 @@ export class BitwiseXorExpression extends BitwiseExpression< BitwiseXorExpressionSemantics, BitwiseXorExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_bitwiseXorExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * The code generation for this AST node. + * @since 0.11.0 + */ + public checkForWarnings = undefined; + readonly targetSemanticAnalysis = this.semanticAnalyser.bitwiseXorExpression; + readonly targetCodeGenerator = this.codeGenerator.bitwiseXorExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -37,11 +54,10 @@ export class BitwiseXorExpression extends BitwiseExpression< */ protected override readonly _antlrRuleCtx: BitwiseXorExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_bitwiseXorExpression; + constructor(antlrRuleCtx: BitwiseXorExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -55,12 +71,6 @@ export class BitwiseXorExpression extends BitwiseExpression< return BitwiseXorExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the name of the rule for this AST node. This represents the specific type of the {@link antlrRuleCtx} that ths AST Node wraps. * This may be compared using the {@link ParseRuleKindMapping rule fields}, for example {@link ParseRuleKindMapping.RULE_expression}. @@ -70,9 +80,12 @@ export class BitwiseXorExpression extends BitwiseExpression< return BitwiseXorExpression.ruleName; } - constructor(antlrRuleCtx: BitwiseXorExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The code generation for this AST node. + * @since 0.11.0 + */ + public override get antlrRuleCtx(): BitwiseXorExpressionContext { + return this._antlrRuleCtx; } /** @@ -114,24 +127,7 @@ export class BitwiseXorExpression extends BitwiseExpression< .validBitwiseExpression(semanticData.leftOp, semanticData.rightOp, semanticData.operator); this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("num"), + evaluatedType: BuiltInTypes.num, }; } - - /** - * The code generation for this AST node. - * @since 0.11.0 - */ - public checkForWarnings = undefined; - - /** - * The code generation for this AST node. - * @since 0.11.0 - */ - public override get antlrRuleCtx(): BitwiseXorExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.bitwiseXorExpression; - readonly targetCodeGenerator = this.codeGenerator.bitwiseXorExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression-semantics.ts index b789929d9..a394b47b6 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression-semantics.ts @@ -4,7 +4,7 @@ */ import type { ExpressionSemantics } from "../expression-semantics"; import type { Expression } from "../expression"; -import type { UncheckedType } from "../../../../analysis"; +import type { RawType } from "../../../../semantics"; import type { IdentifierTypeSpecifierExpression } from "../type-specifier-expression"; /** @@ -21,7 +21,7 @@ export interface CastOrConvertExpressionSemantics extends ExpressionSemantics { * The type the {@link exp} should be converted to. * @since 0.10.0 */ - castType: UncheckedType; + castType: RawType; /** * The type specifier that determined {@link castType}. * @since 0.10.0 diff --git a/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression-type-semantics.ts index c8518ff3b..a5a65f8fd 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression-type-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression-type-semantics.ts @@ -2,7 +2,7 @@ * Type semantics for AST Node {@link CastOrConvertExpression}. * @since 0.10.0 */ -import type { CheckedType } from "../../../../analysis"; +import type { ProcessedType } from "../../../../semantics"; import type { ExpressionTypeSemantics } from "../expression-type-semantics"; /** @@ -14,5 +14,5 @@ export interface CastOrConvertExpressionTypeSemantics extends ExpressionTypeSema * The type the {@link CastOrConvertExpressionSemantics.exp} should be converted to. * @since 0.10.0 */ - castType: CheckedType; + castType: ProcessedType; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression.ts index d8094df7d..b9a8d9b0e 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/cast-or-convert-expression/cast-or-convert-expression.ts @@ -14,10 +14,10 @@ import type { IdentifierTypeSpecifierExpression } from "../type-specifier-expres import { Expression } from "../expression"; import type { CastOrConvertExpressionContext } from "../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../lexer-parser"; -import type { UncheckedType } from "../../../../analysis"; +import type { RawType } from "../../../../semantics"; +import { kipperInternalBuiltInFunctions } from "../../../../semantics"; import { UnableToDetermineSemanticDataError } from "../../../../../errors"; import { getConversionFunctionIdentifier } from "../../../../../tools"; -import { kipperInternalBuiltInFunctions } from "../../../../runtime-built-ins"; /** * Convert expressions, which are used to convert a value to a different type. @@ -33,6 +33,25 @@ export class CastOrConvertExpression extends Expression< CastOrConvertExpressionTypeSemantics, Expression > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_castOrConvertExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.castOrConvertExpression; + readonly targetCodeGenerator = this.codeGenerator.castOrConvertExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -40,11 +59,10 @@ export class CastOrConvertExpression extends Expression< */ protected override readonly _antlrRuleCtx: CastOrConvertExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_castOrConvertExpression; + constructor(antlrRuleCtx: CastOrConvertExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -58,12 +76,6 @@ export class CastOrConvertExpression extends Expression< return CastOrConvertExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -76,9 +88,11 @@ export class CastOrConvertExpression extends Expression< return CastOrConvertExpression.ruleName; } - constructor(antlrRuleCtx: CastOrConvertExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): CastOrConvertExpressionContext { + return this._antlrRuleCtx; } /** @@ -94,7 +108,7 @@ export class CastOrConvertExpression extends Expression< // Get the type using the type specifier const typeSpecifier = this.children[1]; - const type: UncheckedType = typeSpecifier.getSemanticData().typeIdentifier; + const type: RawType = typeSpecifier.getSemanticData().typeIdentifier; // Ensure that the children are fully present and not undefined if (!exp || !type) { @@ -142,22 +156,4 @@ export class CastOrConvertExpression extends Expression< ); } } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): CastOrConvertExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.castOrConvertExpression; - readonly targetCodeGenerator = this.codeGenerator.castOrConvertExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/comparative-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/comparative-expression.ts index 2b38b5225..459b1e682 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/comparative-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/comparative-expression.ts @@ -42,6 +42,8 @@ export abstract class ComparativeExpression< TypeSemantics extends ComparativeExpressionTypeSemantics = ComparativeExpressionTypeSemantics, > extends Expression { protected abstract readonly _antlrRuleCtx: ParserComparativeExpressionContext; + public abstract get kind(): ASTComparativeExpressionKind; + public abstract get ruleName(): ParserComparativeExpressionRuleName; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/equality-expression/equality-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/equality-expression/equality-expression.ts index c0ba38d17..a42fd117e 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/equality-expression/equality-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/equality-expression/equality-expression.ts @@ -11,7 +11,7 @@ import type { EqualityExpressionSemantics } from "./equality-expression-semantic import type { EqualityExpressionTypeSemantics } from "./equality-expression-type-semantics"; import type { Expression } from "../../expression"; import { ComparativeExpression } from "../comparative-expression"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; import type { EqualityExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; @@ -33,6 +33,25 @@ export class EqualityExpression extends ComparativeExpression< EqualityExpressionSemantics, EqualityExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_equalityExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.equalityExpression; + readonly targetCodeGenerator = this.codeGenerator.equalityExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -40,11 +59,10 @@ export class EqualityExpression extends ComparativeExpression< */ protected override readonly _antlrRuleCtx: EqualityExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_equalityExpression; + constructor(antlrRuleCtx: EqualityExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -58,12 +76,6 @@ export class EqualityExpression extends ComparativeExpression< return EqualityExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -76,9 +88,11 @@ export class EqualityExpression extends ComparativeExpression< return EqualityExpression.ruleName; } - constructor(antlrRuleCtx: EqualityExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): EqualityExpressionContext { + return this._antlrRuleCtx; } /** @@ -122,25 +136,7 @@ export class EqualityExpression extends ComparativeExpression< public async primarySemanticTypeChecking(): Promise { // Equality expressions always return 'bool' this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("bool"), + evaluatedType: BuiltInTypes.bool, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): EqualityExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.equalityExpression; - readonly targetCodeGenerator = this.codeGenerator.equalityExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/relational-expression/relational-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/relational-expression/relational-expression.ts index 961e4f4b6..b38c17f0c 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/relational-expression/relational-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/comparative-expression/relational-expression/relational-expression.ts @@ -24,7 +24,7 @@ import type { KipperRelationalOperator } from "../../../../../const"; import { kipperRelationalOperators } from "../../../../../const"; import { TerminalNode } from "antlr4ts/tree/TerminalNode"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; /** * Relational expression, which can be used to compare two numeric expressions. @@ -45,6 +45,25 @@ export class RelationalExpression extends ComparativeExpression< RelationalExpressionSemantics, RelationalExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_relationalExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.relationalExpression; + readonly targetCodeGenerator = this.codeGenerator.relationalExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -52,11 +71,10 @@ export class RelationalExpression extends ComparativeExpression< */ protected override readonly _antlrRuleCtx: RelationalExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_relationalExpression; + constructor(antlrRuleCtx: RelationalExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -70,12 +88,6 @@ export class RelationalExpression extends ComparativeExpression< return RelationalExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -88,9 +100,11 @@ export class RelationalExpression extends ComparativeExpression< return RelationalExpression.ruleName; } - constructor(antlrRuleCtx: RelationalExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): RelationalExpressionContext { + return this._antlrRuleCtx; } /** @@ -134,28 +148,10 @@ export class RelationalExpression extends ComparativeExpression< public async primarySemanticTypeChecking(): Promise { // Relational expressions always return 'bool' this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("bool"), + evaluatedType: BuiltInTypes.bool, }; // Type check the relational expression and ensure its operands are of type 'num' this.programCtx.typeCheck(this).validRelationalExpression(this); } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): RelationalExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.relationalExpression; - readonly targetCodeGenerator = this.codeGenerator.relationalExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/conditional-expression/conditional-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/conditional-expression/conditional-expression.ts index 5f1621944..3ea13669a 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/conditional-expression/conditional-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/conditional-expression/conditional-expression.ts @@ -26,6 +26,25 @@ export class ConditionalExpression extends Expression< ConditionalExpressionTypeSemantics, Expression > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_conditionalExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.conditionalExpression; + readonly targetCodeGenerator = this.codeGenerator.conditionalExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -33,11 +52,10 @@ export class ConditionalExpression extends Expression< */ protected override readonly _antlrRuleCtx: ConditionalExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_conditionalExpression; + constructor(antlrRuleCtx: ConditionalExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -51,12 +69,6 @@ export class ConditionalExpression extends Expression< return ConditionalExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -69,9 +81,11 @@ export class ConditionalExpression extends Expression< return ConditionalExpression.ruleName; } - constructor(antlrRuleCtx: ConditionalExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): ConditionalExpressionContext { + return this._antlrRuleCtx; } /** @@ -109,22 +123,4 @@ export class ConditionalExpression extends Expression< evaluatedType: semanticData.trueBranch.getTypeSemanticData().evaluatedType, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): ConditionalExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.conditionalExpression; - readonly targetCodeGenerator = this.codeGenerator.conditionalExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/expression-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/expression-type-semantics.ts index f0320c47c..01a6fc932 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/expression-type-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/expression-type-semantics.ts @@ -2,7 +2,7 @@ * Type semantics for an expression class that must be evaluated during Type Checking. * @since 0.10.0 */ -import type { CheckedType } from "../../../analysis"; +import type { ProcessedType } from "../../../semantics"; import type { TypeData } from "../../ast-node"; /** @@ -17,5 +17,5 @@ export interface ExpressionTypeSemantics extends TypeData { * This will always evaluate to "type", as a type specifier will always be a type. * @since 0.10.0 */ - evaluatedType: CheckedType; + evaluatedType: ProcessedType; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/expression.ts index 758448048..a158f9a61 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/expression.ts @@ -25,6 +25,7 @@ export abstract class Expression< TypeSemantics extends ExpressionTypeSemantics = ExpressionTypeSemantics, Children extends CompilableASTNode = CompilableASTNode, > extends CompilableASTNode { + public abstract targetCodeGenerator: TargetASTNodeCodeGenerator; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -32,8 +33,21 @@ export abstract class Expression< */ protected override readonly _antlrRuleCtx: ParserExpressionContext; + protected constructor(antlrRuleCtx: ParserExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._children = []; + + // Manually add the child to the parent + parent.addNewChild(this); + } + protected override _children: Array; + public get children(): Array { + return this._children; + } + /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST * node wraps. @@ -54,17 +68,11 @@ export abstract class Expression< */ public abstract get ruleName(): ASTExpressionRuleName; - protected constructor(antlrRuleCtx: ParserExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._children = []; - - // Manually add the child to the parent - parent.addNewChild(this); - } - - public get children(): Array { - return this._children; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): ParserExpressionContext { + return this._antlrRuleCtx; } public addNewChild(newChild: Children) { @@ -79,13 +87,6 @@ export abstract class Expression< */ public abstract checkForWarnings?(): Promise; - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): ParserExpressionContext { - return this._antlrRuleCtx; - } - /** * Semantically analyses the code inside this AST node and all {@link this.children children nodes}. * @@ -173,6 +174,4 @@ export abstract class Expression< public override async translateCtxAndChildren(): Promise { return await this.targetCodeGenerator(this); } - - public abstract targetCodeGenerator: TargetASTNodeCodeGenerator; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression-semantics.ts index 274e89c19..f85bb73ce 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression-semantics.ts @@ -2,7 +2,7 @@ * Semantics for AST Node {@link FunctionCallExpression}. * @since 0.5.0 */ -import type { Reference } from "../../../../analysis"; +import type { Reference } from "../../../../semantics"; import type { Expression } from "../expression"; import type { ExpressionSemantics } from "../expression-semantics"; diff --git a/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression-type-semantics.ts index ef16b155b..b70381a5a 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression-type-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression-type-semantics.ts @@ -2,8 +2,8 @@ * Type semantics for AST Node {@link FunctionCallExpression}. * @since 0.5.0 */ -import type { KipperFunction } from "../../../../const"; import type { ExpressionTypeSemantics } from "../expression-type-semantics"; +import type { ScopeFunctionDeclaration } from "../../../../semantics"; /** * Type semantics for AST Node {@link FunctionCallExpression}. @@ -15,5 +15,5 @@ export interface FunctionCallExpressionTypeSemantics extends ExpressionTypeSeman * a {@link ScopeVariableDeclaration function in a variable}. * @since 0.10.0 */ - func: KipperFunction; + func: ScopeFunctionDeclaration; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression.ts index 6699aa26c..f4525e1a6 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/function-call-expression/function-call-expression.ts @@ -9,14 +9,12 @@ import type { FunctionCallExpressionSemantics } from "./function-call-expression-semantics"; import type { FunctionCallExpressionTypeSemantics } from "./function-call-expression-type-semantics"; import type { CompilableASTNode } from "../../../compilable-ast-node"; -import type { KipperReferenceableFunction } from "../../../../const"; -import type { FunctionCallExpressionContext } from "../../../../lexer-parser"; +import type { IdentifierPrimaryExpressionSemantics } from "../primary-expression"; import { Expression } from "../expression"; +import type { FunctionCallExpressionContext } from "../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../lexer-parser"; import { UnableToDetermineSemanticDataError } from "../../../../../errors"; -import type { Reference } from "../../../../analysis"; -import { CheckedType } from "../../../../analysis"; -import type { IdentifierPrimaryExpressionSemantics } from "../primary-expression"; +import type { Reference, ScopeFunctionDeclaration } from "../../../../semantics"; /** * Function call class, which represents a function call expression in the Kipper language. @@ -31,6 +29,25 @@ export class FunctionCallExpression extends Expression< FunctionCallExpressionTypeSemantics, Expression > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_functionCallExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.functionCallExpression; + readonly targetCodeGenerator = this.codeGenerator.functionCallExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -38,11 +55,10 @@ export class FunctionCallExpression extends Expression< */ protected override readonly _antlrRuleCtx: FunctionCallExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_functionCallExpression; + constructor(antlrRuleCtx: FunctionCallExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -56,12 +72,6 @@ export class FunctionCallExpression extends Expression< return FunctionCallExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -74,15 +84,6 @@ export class FunctionCallExpression extends Expression< return FunctionCallExpression.ruleName; } - constructor(antlrRuleCtx: FunctionCallExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - } - - public hasSideEffects(): boolean { - return true; // This expression has side effects as it calls a function - } - /** * The antlr context containing the antlr4 metadata for this expression. */ @@ -90,6 +91,10 @@ export class FunctionCallExpression extends Expression< return this._antlrRuleCtx; } + public hasSideEffects(): boolean { + return true; // This expression has side effects as it calls a function + } + /** * Performs the semantic analysis for this Kipper token. This will log all warnings using {@link programCtx.logger} * and throw errors if encountered. @@ -138,34 +143,15 @@ export class FunctionCallExpression extends Expression< // Ensure that the reference is a callable function this.programCtx.typeCheck(this).refTargetCallable(semanticData.target); - const calledFunc = (semanticData.target).refTarget; + const calledFunc = (>semanticData.target).refTarget; // Ensure valid arguments are passed this.programCtx.typeCheck(this).validFunctionCallArguments(calledFunc, semanticData.args); - // Get the type that the function call will evaluate to - let evaluatedType: CheckedType; - if (calledFunc.returnType instanceof CheckedType) { - evaluatedType = calledFunc.returnType; - } else { - evaluatedType = CheckedType.fromCompilableType(calledFunc.returnType); - } - // The evaluated type is always equal to the return of the function this.typeSemantics = { - evaluatedType: evaluatedType, + evaluatedType: calledFunc.returnType, func: calledFunc, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - readonly targetSemanticAnalysis = this.semanticAnalyser.functionCallExpression; - readonly targetCodeGenerator = this.codeGenerator.functionCallExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression-semantics.ts index 497d7f3aa..b5a885263 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression-semantics.ts @@ -7,7 +7,7 @@ import type { ParameterDeclaration } from "../../declarations"; import type { IdentifierTypeSpecifierExpression } from "../type-specifier-expression"; import type { CompoundStatement } from "../../statements"; import type { Expression } from "../expression"; -import type { UncheckedType } from "../../../../analysis"; +import type { RawType } from "../../../../semantics"; /** * Semantics for AST Node {@link LambdaExpression}. @@ -18,7 +18,7 @@ export interface LambdaExpressionSemantics extends ExpressionSemantics { * The return type of the lambda expression. * @since 0.11.0 */ - returnType: UncheckedType; + returnType: RawType; /** * The type specifier expression for the return type. * @since 0.11.0 diff --git a/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression-type-semantics.ts index 54f007730..311f83328 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression-type-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression-type-semantics.ts @@ -2,13 +2,17 @@ * Type semantics for AST Node {@link LambdaExpression}. * @since 0.11.0 */ -import type { CheckedType } from "../../../../analysis"; import type { ExpressionTypeSemantics } from "../expression-type-semantics"; +import type { ProcessedType } from "../../../../semantics"; /** * Type semantics for AST Node {@link LambdaExpression}. * @since 0.11.0 */ export interface LambdaExpressionTypeSemantics extends ExpressionTypeSemantics { - returnType: CheckedType; + /** + * The return type of the lambda expression. + * @since 0.11.0 + */ + returnType: ProcessedType; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression.ts index 66bb5cf7a..5f4459f90 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/lambda-expression/lambda-expression.ts @@ -11,13 +11,12 @@ import type { LambdaExpressionContext } from "../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../lexer-parser"; import type { CompilableASTNode } from "../../../compilable-ast-node"; import type { ScopeNode } from "../../../scope-node"; -import { LambdaScope } from "../../../../analysis/symbol-table/lambda-scope"; import type { Statement } from "../../statements"; import { CompoundStatement } from "../../statements"; import type { IdentifierTypeSpecifierExpression } from "../type-specifier-expression"; import { ParameterDeclaration } from "../../declarations"; import { UnableToDetermineSemanticDataError } from "../../../../../errors"; -import { CheckedType } from "../../../../analysis"; +import { BuiltInTypes, LambdaScope } from "../../../../semantics"; /** * Lambda expression class, which represents a lambda expression in the AST. @@ -34,30 +33,42 @@ export class LambdaExpression implements ScopeNode { /** - * The inner scope of this lambda expression. + * The static kind for this AST Node. + * @since 0.11.0 */ - private readonly _innerScope: LambdaScope; - + public static readonly kind = ParseRuleKindMapping.RULE_lambdaExpression; /** - * Gets the inner scope of this function, where also the {@link semanticData.params arguments} should be registered. - * @since 0.10.0 + * The static rule name for this AST Node. + * @since 0.11.0 */ - public get innerScope(): LambdaScope { - return this._innerScope; - } - + public static readonly ruleName = KindParseRuleMapping[this.kind]; + public checkForWarnings = undefined; + readonly targetSemanticAnalysis = this.semanticAnalyser.lambdaExpression; + readonly targetCodeGenerator = this.codeGenerator.lambdaExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. * @private */ protected override readonly _antlrRuleCtx: LambdaExpressionContext; + /** + * The inner scope of this lambda expression. + */ + private readonly _innerScope: LambdaScope; + + constructor(antlrRuleCtx: LambdaExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._innerScope = new LambdaScope(this); + } /** - * The static kind for this AST Node. - * @since 0.11.0 + * Gets the inner scope of this function, where also the {@link semanticData.params arguments} should be registered. + * @since 0.10.0 */ - public static readonly kind = ParseRuleKindMapping.RULE_lambdaExpression; + public get innerScope(): LambdaScope { + return this._innerScope; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -71,12 +82,6 @@ export class LambdaExpression return LambdaExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -86,12 +91,6 @@ export class LambdaExpression return LambdaExpression.ruleName; } - constructor(antlrRuleCtx: LambdaExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._innerScope = new LambdaScope(this); - } - /** * The antlr context containing the antlr4 metadata for this expression. */ @@ -141,7 +140,7 @@ export class LambdaExpression // Get the type that will be returned using the return type specifier const returnType = semanticData.returnTypeSpecifier.getTypeSemanticData().storedType; this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("func"), + evaluatedType: BuiltInTypes.func, returnType: returnType, }; @@ -150,9 +149,4 @@ export class LambdaExpression this.programCtx.typeCheck(this).validReturnCodePathsInFunctionBody(this); } } - - public checkForWarnings = undefined; - - readonly targetSemanticAnalysis = this.semanticAnalyser.lambdaExpression; - readonly targetCodeGenerator = this.codeGenerator.lambdaExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-and-expression/logical-and-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-and-expression/logical-and-expression.ts index 67b3b67b0..78e92a4b4 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-and-expression/logical-and-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-and-expression/logical-and-expression.ts @@ -16,7 +16,7 @@ import type { LogicalAndExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; import type { CompilableASTNode } from "../../../../compilable-ast-node"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; /** * Logical-and expression, representing an expression which can be used to combine multiple conditions. It will @@ -32,6 +32,25 @@ export class LogicalAndExpression extends LogicalExpression< LogicalAndExpressionSemantics, LogicalAndExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_logicalAndExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.logicalAndExpression; + readonly targetCodeGenerator = this.codeGenerator.logicalAndExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -39,11 +58,10 @@ export class LogicalAndExpression extends LogicalExpression< */ protected override readonly _antlrRuleCtx: LogicalAndExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_logicalAndExpression; + constructor(antlrRuleCtx: LogicalAndExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -57,12 +75,6 @@ export class LogicalAndExpression extends LogicalExpression< return LogicalAndExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -75,9 +87,11 @@ export class LogicalAndExpression extends LogicalExpression< return LogicalAndExpression.ruleName; } - constructor(antlrRuleCtx: LogicalAndExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): LogicalAndExpressionContext { + return this._antlrRuleCtx; } /** @@ -115,25 +129,7 @@ export class LogicalAndExpression extends LogicalExpression< public async primarySemanticTypeChecking(): Promise { // Logical expressions always return 'bool' this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("bool"), + evaluatedType: BuiltInTypes.bool, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): LogicalAndExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.logicalAndExpression; - readonly targetCodeGenerator = this.codeGenerator.logicalAndExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-expression.ts index 5777cc16e..e8d3d7a54 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-expression.ts @@ -45,6 +45,8 @@ export abstract class LogicalExpression< TypeSemantics extends LogicalExpressionTypeSemantics = LogicalExpressionTypeSemantics, > extends Expression { protected abstract readonly _antlrRuleCtx: ParserLogicalExpressionContext; + public abstract get kind(): ASTLogicalExpressionKind; + public abstract get ruleName(): ParserLogicalExpressionRuleName; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-or-expression/logical-or-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-or-expression/logical-or-expression.ts index 36988ab83..3dffbb39b 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-or-expression/logical-or-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/logical-expression/logical-or-expression/logical-or-expression.ts @@ -17,7 +17,7 @@ import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer import type { CompilableASTNode } from "../../../../compilable-ast-node"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; import { kipperLogicalOrOperator } from "../../../../../const"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; /** * Logical-or expression, representing an expression which can be used to combine multiple conditions. It returns true @@ -33,6 +33,25 @@ export class LogicalOrExpression extends LogicalExpression< LogicalOrExpressionSemantics, LogicalOrExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_logicalOrExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.logicalOrExpression; + readonly targetCodeGenerator = this.codeGenerator.logicalOrExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -40,11 +59,10 @@ export class LogicalOrExpression extends LogicalExpression< */ protected override readonly _antlrRuleCtx: LogicalOrExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_logicalOrExpression; + constructor(antlrRuleCtx: LogicalOrExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -58,12 +76,6 @@ export class LogicalOrExpression extends LogicalExpression< return LogicalOrExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -76,9 +88,11 @@ export class LogicalOrExpression extends LogicalExpression< return LogicalOrExpression.ruleName; } - constructor(antlrRuleCtx: LogicalOrExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): LogicalOrExpressionContext { + return this._antlrRuleCtx; } /** @@ -116,25 +130,7 @@ export class LogicalOrExpression extends LogicalExpression< public async primarySemanticTypeChecking(): Promise { // Logical expressions always return 'bool' this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("bool"), + evaluatedType: BuiltInTypes.bool, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): LogicalOrExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.logicalOrExpression; - readonly targetCodeGenerator = this.codeGenerator.logicalOrExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/member-access-expression/member-access-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/member-access-expression/member-access-expression.ts index 94b4db18a..33738de77 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/member-access-expression/member-access-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/member-access-expression/member-access-expression.ts @@ -15,7 +15,7 @@ import { import type { CompilableASTNode } from "../../../compilable-ast-node"; import { Expression } from "../expression"; import { KipperNotImplementedError, UnableToDetermineSemanticDataError } from "../../../../../errors"; -import { kipperInternalBuiltInFunctions } from "../../../../runtime-built-ins"; +import { kipperInternalBuiltInFunctions } from "../../../../semantics"; /** * A union of all possible {@link KipperParserRuleContext} rule contexts that {@link MemberAccessExpression} implements. @@ -36,6 +36,25 @@ export class MemberAccessExpression extends Expression< MemberAccessExpressionTypeSemantics, Expression > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_memberAccessExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.memberAccessExpression; + readonly targetCodeGenerator = this.codeGenerator.memberAccessExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -43,11 +62,10 @@ export class MemberAccessExpression extends Expression< */ protected override readonly _antlrRuleCtx: MemberAccessExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_memberAccessExpression; + constructor(antlrRuleCtx: MemberAccessExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -61,12 +79,6 @@ export class MemberAccessExpression extends Expression< return MemberAccessExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -79,11 +91,6 @@ export class MemberAccessExpression extends Expression< return MemberAccessExpression.ruleName; } - constructor(antlrRuleCtx: MemberAccessExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - } - /** * The antlr context containing the antlr4 metadata for this expression. */ @@ -169,15 +176,4 @@ export class MemberAccessExpression extends Expression< evaluatedType: type, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - readonly targetSemanticAnalysis = this.semanticAnalyser.memberAccessExpression; - readonly targetCodeGenerator = this.codeGenerator.memberAccessExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/postfix-expression/increment-or-decrement-postfix-expression/increment-or-decrement-postfix-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/postfix-expression/increment-or-decrement-postfix-expression/increment-or-decrement-postfix-expression.ts index 60f10db67..b2a63ed17 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/postfix-expression/increment-or-decrement-postfix-expression/increment-or-decrement-postfix-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/postfix-expression/increment-or-decrement-postfix-expression/increment-or-decrement-postfix-expression.ts @@ -14,7 +14,7 @@ import type { IncrementOrDecrementPostfixExpressionContext } from "../../../../. import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; import type { CompilableASTNode } from "../../../../compilable-ast-node"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; /** * Increment or Decrement expression, which represents a right-side -- or ++ expression modifying a numeric value. @@ -27,6 +27,25 @@ export class IncrementOrDecrementPostfixExpression extends PostfixExpression< IncrementOrDecrementPostfixExpressionSemantics, IncrementOrDecrementPostfixExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_incrementOrDecrementPostfixExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.incrementOrDecrementPostfixExpression; + readonly targetCodeGenerator = this.codeGenerator.incrementOrDecrementPostfixExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -34,11 +53,10 @@ export class IncrementOrDecrementPostfixExpression extends PostfixExpression< */ protected override readonly _antlrRuleCtx: IncrementOrDecrementPostfixExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_incrementOrDecrementPostfixExpression; + constructor(antlrRuleCtx: IncrementOrDecrementPostfixExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -52,12 +70,6 @@ export class IncrementOrDecrementPostfixExpression extends PostfixExpression< return IncrementOrDecrementPostfixExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -70,9 +82,11 @@ export class IncrementOrDecrementPostfixExpression extends PostfixExpression< return IncrementOrDecrementPostfixExpression.ruleName; } - constructor(antlrRuleCtx: IncrementOrDecrementPostfixExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): IncrementOrDecrementPostfixExpressionContext { + return this._antlrRuleCtx; } public hasSideEffects(): boolean { @@ -112,28 +126,10 @@ export class IncrementOrDecrementPostfixExpression extends PostfixExpression< public async primarySemanticTypeChecking(): Promise { this.typeSemantics = { // This will always be a number - evaluatedType: CheckedType.fromKipperType("num"), + evaluatedType: BuiltInTypes.num, }; // Ensure that this expression is valid (e.g. the operand is a number) this.programCtx.typeCheck(this).validUnaryExpression(this); } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): IncrementOrDecrementPostfixExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.incrementOrDecrementPostfixExpression; - readonly targetCodeGenerator = this.codeGenerator.incrementOrDecrementPostfixExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/postfix-expression/postfix-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/postfix-expression/postfix-expression.ts index 9fee43f6c..ba4c192fd 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/postfix-expression/postfix-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/postfix-expression/postfix-expression.ts @@ -43,6 +43,8 @@ export abstract class PostfixExpression< TypeSemantics extends PostfixExpressionTypeSemantics = PostfixExpressionTypeSemantics, > extends Expression { protected abstract readonly _antlrRuleCtx: ParserPostfixExpressionContext; + public abstract get kind(): ASTPostfixExpressionKind; + public abstract get ruleName(): ParserPostfixExpressionRuleName; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/array-primary-expression/array-primary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/array-primary-expression/array-primary-expression.ts index b7c8437e0..1b272246d 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/array-primary-expression/array-primary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/array-primary-expression/array-primary-expression.ts @@ -7,7 +7,7 @@ import type { ArrayPrimaryExpressionTypeSemantics } from "./array-primary-expres import type { CompilableASTNode } from "../../../../compilable-ast-node"; import type { ArrayPrimaryExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; import { PrimaryExpression } from "../primary-expression"; /** @@ -18,6 +18,25 @@ export class ArrayPrimaryExpression extends PrimaryExpression< ArrayPrimaryExpressionSemantics, ArrayPrimaryExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_arrayPrimaryExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.arrayPrimaryExpression; + readonly targetCodeGenerator = this.codeGenerator.arrayPrimaryExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -25,11 +44,10 @@ export class ArrayPrimaryExpression extends PrimaryExpression< */ protected override readonly _antlrRuleCtx: ArrayPrimaryExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_arrayPrimaryExpression; + constructor(antlrRuleCtx: ArrayPrimaryExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -43,12 +61,6 @@ export class ArrayPrimaryExpression extends PrimaryExpression< return ArrayPrimaryExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -61,9 +73,11 @@ export class ArrayPrimaryExpression extends PrimaryExpression< return ArrayPrimaryExpression.ruleName; } - constructor(antlrRuleCtx: ArrayPrimaryExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): ArrayPrimaryExpressionContext { + return this._antlrRuleCtx; } /** @@ -90,25 +104,7 @@ export class ArrayPrimaryExpression extends PrimaryExpression< public async primarySemanticTypeChecking(): Promise { // This will always be of type 'list' this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("list"), + evaluatedType: BuiltInTypes.list, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): ArrayPrimaryExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.arrayPrimaryExpression; - readonly targetCodeGenerator = this.codeGenerator.arrayPrimaryExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/bool-primary-expression/bool-primary-expression-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/bool-primary-expression/bool-primary-expression-semantics.ts index c09a6cb78..0871c7aa5 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/bool-primary-expression/bool-primary-expression-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/bool-primary-expression/bool-primary-expression-semantics.ts @@ -2,7 +2,7 @@ * Semantics for AST Node {@link BoolPrimaryExpression}. * @since 0.8.0 */ -import type { KipperBoolTypeLiterals } from "../../../../../const"; +import type { KipperBoolTypeConstants } from "../../../../../const"; import type { PrimaryExpressionSemantics } from "../primary-expression-semantics"; /** @@ -14,5 +14,5 @@ export interface BoolPrimaryExpressionSemantics extends PrimaryExpressionSemanti * The value of this boolean constant expression. * @since 0.8.0 */ - value: KipperBoolTypeLiterals; + value: KipperBoolTypeConstants; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/bool-primary-expression/bool-primary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/bool-primary-expression/bool-primary-expression.ts index 43d1874c7..57116c4ff 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/bool-primary-expression/bool-primary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/bool-primary-expression/bool-primary-expression.ts @@ -5,10 +5,10 @@ import type { BoolPrimaryExpressionSemantics } from "./bool-primary-expression-semantics"; import type { BoolPrimaryExpressionTypeSemantics } from "./bool-primary-expression-type-semantics"; import type { CompilableASTNode } from "../../../../compilable-ast-node"; -import type { KipperBoolTypeLiterals } from "../../../../../const"; +import type { KipperBoolTypeConstants } from "../../../../../const"; import type { BoolPrimaryExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; import { PrimaryExpression } from "../primary-expression"; /** @@ -19,6 +19,25 @@ export class BoolPrimaryExpression extends PrimaryExpression< BoolPrimaryExpressionSemantics, BoolPrimaryExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_boolPrimaryExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.boolPrimaryExpression; + readonly targetCodeGenerator = this.codeGenerator.boolPrimaryExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -26,11 +45,10 @@ export class BoolPrimaryExpression extends PrimaryExpression< */ protected override readonly _antlrRuleCtx: BoolPrimaryExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_boolPrimaryExpression; + constructor(antlrRuleCtx: BoolPrimaryExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -44,12 +62,6 @@ export class BoolPrimaryExpression extends PrimaryExpression< return BoolPrimaryExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -62,9 +74,11 @@ export class BoolPrimaryExpression extends PrimaryExpression< return BoolPrimaryExpression.ruleName; } - constructor(antlrRuleCtx: BoolPrimaryExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): BoolPrimaryExpressionContext { + return this._antlrRuleCtx; } /** @@ -76,7 +90,7 @@ export class BoolPrimaryExpression extends PrimaryExpression< */ public async primarySemanticAnalysis(): Promise { this.semanticData = { - value: this.sourceCode, + value: this.sourceCode, }; } @@ -91,25 +105,7 @@ export class BoolPrimaryExpression extends PrimaryExpression< public async primarySemanticTypeChecking(): Promise { // This will always be of type 'bool' this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("bool"), + evaluatedType: BuiltInTypes.bool, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): BoolPrimaryExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.boolPrimaryExpression; - readonly targetCodeGenerator = this.codeGenerator.boolPrimaryExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/fstring-primary-expression/fstring-primary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/fstring-primary-expression/fstring-primary-expression.ts index c3c591a0c..d582e697d 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/fstring-primary-expression/fstring-primary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/fstring-primary-expression/fstring-primary-expression.ts @@ -14,7 +14,7 @@ import { ParseRuleKindMapping, } from "../../../../../lexer-parser"; import type { CompilableASTNode } from "../../../../compilable-ast-node"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; import { getParseRuleSource } from "../../../../../../tools"; /** @@ -27,6 +27,25 @@ export class FStringPrimaryExpression extends Expression< FStringPrimaryExpressionTypeSemantics, Expression > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_fStringPrimaryExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.fStringPrimaryExpression; + readonly targetCodeGenerator = this.codeGenerator.fStringPrimaryExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -34,11 +53,10 @@ export class FStringPrimaryExpression extends Expression< */ protected override readonly _antlrRuleCtx: FStringPrimaryExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_fStringPrimaryExpression; + constructor(antlrRuleCtx: FStringPrimaryExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -52,12 +70,6 @@ export class FStringPrimaryExpression extends Expression< return FStringPrimaryExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -70,9 +82,11 @@ export class FStringPrimaryExpression extends Expression< return FStringPrimaryExpression.ruleName; } - constructor(antlrRuleCtx: FStringPrimaryExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): FStringPrimaryExpressionContext { + return this._antlrRuleCtx; } /** @@ -117,25 +131,7 @@ export class FStringPrimaryExpression extends Expression< public async primarySemanticTypeChecking(): Promise { // This will always be of type 'str' this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("str"), + evaluatedType: BuiltInTypes.str, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): FStringPrimaryExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.fStringPrimaryExpression; - readonly targetCodeGenerator = this.codeGenerator.fStringPrimaryExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression-semantics.ts index 3d739a4c5..fda8c6b85 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression-semantics.ts @@ -2,7 +2,7 @@ * Semantics for AST Node {@link IdentifierPrimaryExpression}. * @since 0.5.0 */ -import type { Reference } from "../../../../../analysis"; +import type { Reference } from "../../../../../semantics"; import type { PrimaryExpressionSemantics } from "../primary-expression-semantics"; /** diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression-type-semantics.ts index d75c90fdd..b0291921c 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression-type-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression-type-semantics.ts @@ -2,7 +2,7 @@ * Type semantics for AST Node {@link IdentifierPrimaryExpression}. * @since 0.10.0 */ -import type { CheckedType } from "../../../../../analysis"; +import type { ProcessedType } from "../../../../../semantics"; import type { PrimaryExpressionTypeSemantics } from "../primary-expression-type-semantics"; /** @@ -17,5 +17,5 @@ export interface IdentifierPrimaryExpressionTypeSemantics extends PrimaryExpress * {@link IdentifierPrimaryExpressionSemantics.identifier identifier} points to. * @since 0.10.0 */ - evaluatedType: CheckedType; + evaluatedType: ProcessedType; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression.ts index 1d1e7f4d2..a633daa5f 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/identifier-primary-expression/identifier-primary-expression.ts @@ -9,7 +9,7 @@ import type { IdentifierPrimaryExpressionTypeSemantics } from "./identifier-prim import type { CompilableASTNode } from "../../../../compilable-ast-node"; import type { IdentifierPrimaryExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; -import { CheckedType, ScopeDeclaration } from "../../../../../analysis"; +import { ScopeFunctionDeclaration, ScopeVariableDeclaration } from "../../../../../semantics"; import { AssignmentExpression } from "../../assignment-expression/assignment-expression"; import { PrimaryExpression } from "../primary-expression"; @@ -23,6 +23,25 @@ export class IdentifierPrimaryExpression extends PrimaryExpression< IdentifierPrimaryExpressionSemantics, IdentifierPrimaryExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_identifierPrimaryExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.identifierPrimaryExpression; + readonly targetCodeGenerator = this.codeGenerator.identifierPrimaryExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -30,11 +49,10 @@ export class IdentifierPrimaryExpression extends PrimaryExpression< */ protected override readonly _antlrRuleCtx: IdentifierPrimaryExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_identifierPrimaryExpression; + constructor(antlrRuleCtx: IdentifierPrimaryExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -48,12 +66,6 @@ export class IdentifierPrimaryExpression extends PrimaryExpression< return IdentifierPrimaryExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -66,9 +78,11 @@ export class IdentifierPrimaryExpression extends PrimaryExpression< return IdentifierPrimaryExpression.ruleName; } - constructor(antlrRuleCtx: IdentifierPrimaryExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): IdentifierPrimaryExpressionContext { + return this._antlrRuleCtx; } /** @@ -82,9 +96,7 @@ export class IdentifierPrimaryExpression extends PrimaryExpression< const identifier = this.sourceCode; // Make sure the referenced variable even exists! - const ref = this.programCtx - .semanticCheck(this) - .getExistingReference(identifier, "innerScope" in this.scopeCtx ? this.scopeCtx : undefined); + const ref = this.programCtx.semanticCheck(this).getExistingReference(identifier, this.scope); // Once we have the identifier and ensured a reference exists, we are done with the primary semantic analysis. this.semanticData = { @@ -95,7 +107,7 @@ export class IdentifierPrimaryExpression extends PrimaryExpression< }, }; - if (!(ref instanceof ScopeDeclaration)) { + if (ref.isBuiltIn && (ref instanceof ScopeVariableDeclaration || ref instanceof ScopeFunctionDeclaration)) { this.programCtx.addBuiltInReference(this, ref); } else { // If the reference is not used inside an assignment expression, ensure that the reference is defined @@ -119,34 +131,8 @@ export class IdentifierPrimaryExpression extends PrimaryExpression< const semanticData = this.getSemanticData(); const refTarget = semanticData.ref.refTarget; - let type: CheckedType; - if (refTarget instanceof ScopeDeclaration) { - type = refTarget.type; - } else { - // Built-in function -> type is 'func' - type = CheckedType.fromCompilableType("valueType" in refTarget ? refTarget.valueType : "func"); - } - this.typeSemantics = { - evaluatedType: type, + evaluatedType: refTarget.type, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): IdentifierPrimaryExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.identifierPrimaryExpression; - readonly targetCodeGenerator = this.codeGenerator.identifierPrimaryExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/number-primary-expression/number-primary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/number-primary-expression/number-primary-expression.ts index 14c8697cd..78a7beeb9 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/number-primary-expression/number-primary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/number-primary-expression/number-primary-expression.ts @@ -7,7 +7,7 @@ import type { NumberPrimaryExpressionTypeSemantics } from "./number-primary-expr import type { CompilableASTNode } from "../../../../compilable-ast-node"; import type { NumberPrimaryExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; import { PrimaryExpression } from "../primary-expression"; /** @@ -18,6 +18,25 @@ export class NumberPrimaryExpression extends PrimaryExpression< NumberPrimaryExpressionSemantics, NumberPrimaryExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_numberPrimaryExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.numberPrimaryExpression; + readonly targetCodeGenerator = this.codeGenerator.numberPrimaryExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -25,11 +44,10 @@ export class NumberPrimaryExpression extends PrimaryExpression< */ protected override readonly _antlrRuleCtx: NumberPrimaryExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_numberPrimaryExpression; + constructor(antlrRuleCtx: NumberPrimaryExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -43,12 +61,6 @@ export class NumberPrimaryExpression extends PrimaryExpression< return NumberPrimaryExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -61,9 +73,11 @@ export class NumberPrimaryExpression extends PrimaryExpression< return NumberPrimaryExpression.ruleName; } - constructor(antlrRuleCtx: NumberPrimaryExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): NumberPrimaryExpressionContext { + return this._antlrRuleCtx; } /** @@ -92,25 +106,7 @@ export class NumberPrimaryExpression extends PrimaryExpression< public async primarySemanticTypeChecking(): Promise { // This will always be of type 'number' this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("num"), + evaluatedType: BuiltInTypes.num, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): NumberPrimaryExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.numberPrimaryExpression; - readonly targetCodeGenerator = this.codeGenerator.numberPrimaryExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/object-primary-expression/object-property/object-property.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/object-primary-expression/object-property/object-property.ts index 37e279647..ec3ba2a57 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/object-primary-expression/object-property/object-property.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/object-primary-expression/object-property/object-property.ts @@ -11,6 +11,25 @@ import type { CompilableASTNode } from "../../../../../compilable-ast-node"; * @since 0.11.0 */ export class ObjectProperty extends PrimaryExpression { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_objectProperty; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.11.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.objectProperty; + readonly targetCodeGenerator = this.codeGenerator.objectProperty; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -18,11 +37,10 @@ export class ObjectProperty extends PrimaryExpression { return; // For now, we don't have any type checking for object properties. } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.11.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): ObjectPropertyContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.objectProperty; - readonly targetCodeGenerator = this.codeGenerator.objectProperty; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/primary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/primary-expression.ts index 526bfc7c4..89f4e55e6 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/primary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/primary-expression.ts @@ -53,6 +53,8 @@ export abstract class PrimaryExpression< TypeSemantics extends PrimaryExpressionTypeSemantics = PrimaryExpressionTypeSemantics, > extends Expression { protected abstract readonly _antlrRuleCtx: ParserPrimaryExpressionContext; + public abstract get kind(): ASTPrimaryExpressionKind; + public abstract get ruleName(): ParserPrimaryExpressionRuleName; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/string-primary-expression/string-primary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/string-primary-expression/string-primary-expression.ts index 79ecf9219..7cb9b4060 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/string-primary-expression/string-primary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/string-primary-expression/string-primary-expression.ts @@ -7,7 +7,7 @@ import type { StringPrimaryExpressionTypeSemantics } from "./string-primary-expr import type { CompilableASTNode } from "../../../../compilable-ast-node"; import type { StringPrimaryExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes, ProcessedType } from "../../../../../semantics"; import { PrimaryExpression } from "../primary-expression"; /** @@ -91,7 +91,7 @@ export class StringPrimaryExpression extends PrimaryExpression< public async primarySemanticTypeChecking(): Promise { // This will always be of type 'str' this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType("str"), + evaluatedType: BuiltInTypes.str, }; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/tangled-primary-expression/tangled-primary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/tangled-primary-expression/tangled-primary-expression.ts index bd1b9757d..0070c6cae 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/tangled-primary-expression/tangled-primary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/tangled-primary-expression/tangled-primary-expression.ts @@ -25,6 +25,25 @@ export class TangledPrimaryExpression extends PrimaryExpression< TangledPrimaryExpressionSemantics, TangledPrimaryExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_tangledPrimaryExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.tangledPrimaryExpression; + readonly targetCodeGenerator = this.codeGenerator.tangledPrimaryExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -32,11 +51,10 @@ export class TangledPrimaryExpression extends PrimaryExpression< */ protected override readonly _antlrRuleCtx: TangledPrimaryExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_tangledPrimaryExpression; + constructor(antlrRuleCtx: TangledPrimaryExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -50,12 +68,6 @@ export class TangledPrimaryExpression extends PrimaryExpression< return TangledPrimaryExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -68,9 +80,11 @@ export class TangledPrimaryExpression extends PrimaryExpression< return TangledPrimaryExpression.ruleName; } - constructor(antlrRuleCtx: TangledPrimaryExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): TangledPrimaryExpressionContext { + return this._antlrRuleCtx; } /** @@ -110,22 +124,4 @@ export class TangledPrimaryExpression extends PrimaryExpression< evaluatedType: exp.getTypeSemanticData().evaluatedType, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): TangledPrimaryExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.tangledPrimaryExpression; - readonly targetCodeGenerator = this.codeGenerator.tangledPrimaryExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/void-or-null-or-undefined-primary-expression/void-or-null-or-undefined-primary-expression-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/void-or-null-or-undefined-primary-expression/void-or-null-or-undefined-primary-expression-semantics.ts index 58f239321..87ff0a4b0 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/void-or-null-or-undefined-primary-expression/void-or-null-or-undefined-primary-expression-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/void-or-null-or-undefined-primary-expression/void-or-null-or-undefined-primary-expression-semantics.ts @@ -2,7 +2,7 @@ * Semantics for AST Node {@link VoidOrNullOrUndefinedPrimaryExpression}. * @since 0.10.0 */ -import type { KipperNullType, KipperUndefinedType, KipperVoidType } from "../../../../../const"; +import type { KipperNullTypeLiteral, KipperUndefinedTypeLiteral, KipperVoidTypeLiteral } from "../../../../../const"; import type { PrimaryExpressionSemantics } from "../primary-expression-semantics"; /** @@ -14,5 +14,5 @@ export interface VoidOrNullOrUndefinedPrimaryExpressionSemantics extends Primary * The constant identifier of this expression. * @since 0.10.0 */ - constantIdentifier: KipperVoidType | KipperNullType | KipperUndefinedType; + constantIdentifier: KipperVoidTypeLiteral | KipperNullTypeLiteral | KipperUndefinedTypeLiteral; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/void-or-null-or-undefined-primary-expression/void-or-null-or-undefined-primary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/void-or-null-or-undefined-primary-expression/void-or-null-or-undefined-primary-expression.ts index a23f79a39..2887586ba 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/void-or-null-or-undefined-primary-expression/void-or-null-or-undefined-primary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/primary-expression/void-or-null-or-undefined-primary-expression/void-or-null-or-undefined-primary-expression.ts @@ -2,13 +2,13 @@ * Constant expression, representing the void, null or undefined keyword. * @since 0.10.0 */ -import type { KipperNullType, KipperUndefinedType, KipperVoidType } from "../../../../../const"; +import type { KipperNullTypeLiteral, KipperUndefinedTypeLiteral, KipperVoidTypeLiteral } from "../../../../../const"; import type { CompilableASTNode } from "../../../../compilable-ast-node"; import type { VoidOrNullOrUndefinedPrimaryExpressionSemantics } from "./void-or-null-or-undefined-primary-expression-semantics"; import type { VoidOrNullOrUndefinedPrimaryExpressionTypeSemantics } from "./void-or-null-or-undefined-primary-expression-type-semantics"; import type { VoidOrNullOrUndefinedPrimaryExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; import { PrimaryExpression } from "../primary-expression"; /** @@ -19,6 +19,25 @@ export class VoidOrNullOrUndefinedPrimaryExpression extends PrimaryExpression< VoidOrNullOrUndefinedPrimaryExpressionSemantics, VoidOrNullOrUndefinedPrimaryExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_voidOrNullOrUndefinedPrimaryExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.voidOrNullOrUndefinedPrimaryExpression; + readonly targetCodeGenerator = this.codeGenerator.voidOrNullOrUndefinedPrimaryExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -26,11 +45,10 @@ export class VoidOrNullOrUndefinedPrimaryExpression extends PrimaryExpression< */ protected override readonly _antlrRuleCtx: VoidOrNullOrUndefinedPrimaryExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_voidOrNullOrUndefinedPrimaryExpression; + constructor(antlrRuleCtx: VoidOrNullOrUndefinedPrimaryExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -44,12 +62,6 @@ export class VoidOrNullOrUndefinedPrimaryExpression extends PrimaryExpression< return VoidOrNullOrUndefinedPrimaryExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -62,9 +74,11 @@ export class VoidOrNullOrUndefinedPrimaryExpression extends PrimaryExpression< return VoidOrNullOrUndefinedPrimaryExpression.ruleName; } - constructor(antlrRuleCtx: VoidOrNullOrUndefinedPrimaryExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): VoidOrNullOrUndefinedPrimaryExpressionContext { + return this._antlrRuleCtx; } /** @@ -77,7 +91,7 @@ export class VoidOrNullOrUndefinedPrimaryExpression extends PrimaryExpression< public async primarySemanticAnalysis(): Promise { this.semanticData = { // Syntactically there can only be 'void', 'null' or 'undefined' stored in this expression - constantIdentifier: this.sourceCode, + constantIdentifier: this.sourceCode, value: this.sourceCode, // The value of this expression is equal to the constant identifier in string form }; } @@ -93,25 +107,7 @@ export class VoidOrNullOrUndefinedPrimaryExpression extends PrimaryExpression< // The evaluated type of this expression will always be equal to the constant identifier that this expression // contains e.g. either 'void', 'null' or 'undefined'. this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType(semanticData.constantIdentifier), + evaluatedType: BuiltInTypes[semanticData.constantIdentifier], }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): VoidOrNullOrUndefinedPrimaryExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.voidOrNullOrUndefinedPrimaryExpression; - readonly targetCodeGenerator = this.codeGenerator.voidOrNullOrUndefinedPrimaryExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/generic-type-specifier-expression/generic-type-specifier-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/generic-type-specifier-expression/generic-type-specifier-expression.ts index bdac4cdd1..ede851a5f 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/generic-type-specifier-expression/generic-type-specifier-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/generic-type-specifier-expression/generic-type-specifier-expression.ts @@ -22,6 +22,25 @@ export class GenericTypeSpecifierExpression extends TypeSpecifierExpression< GenericTypeSpecifierExpressionSemantics, GenericTypeSpecifierExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_genericTypeSpecifierExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.genericTypeSpecifierExpression; + readonly targetCodeGenerator = this.codeGenerator.genericTypeSpecifierExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -29,11 +48,10 @@ export class GenericTypeSpecifierExpression extends TypeSpecifierExpression< */ protected override readonly _antlrRuleCtx: GenericTypeSpecifierExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_genericTypeSpecifierExpression; + constructor(antlrRuleCtx: GenericTypeSpecifierExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -47,12 +65,6 @@ export class GenericTypeSpecifierExpression extends TypeSpecifierExpression< return GenericTypeSpecifierExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -65,9 +77,11 @@ export class GenericTypeSpecifierExpression extends TypeSpecifierExpression< return GenericTypeSpecifierExpression.ruleName; } - constructor(antlrRuleCtx: GenericTypeSpecifierExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): GenericTypeSpecifierExpressionContext { + return this._antlrRuleCtx; } /** @@ -93,22 +107,4 @@ export class GenericTypeSpecifierExpression extends TypeSpecifierExpression< .semanticCheck(this) .notImplementedError(new KipperNotImplementedError("Generic Type Expressions have not been implemented yet.")); } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): GenericTypeSpecifierExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.genericTypeSpecifierExpression; - readonly targetCodeGenerator = this.codeGenerator.genericTypeSpecifierExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/identifier-type-specifier-expression/identifier-type-specifier-expression-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/identifier-type-specifier-expression/identifier-type-specifier-expression-semantics.ts index e48b6bf06..68b74b568 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/identifier-type-specifier-expression/identifier-type-specifier-expression-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/identifier-type-specifier-expression/identifier-type-specifier-expression-semantics.ts @@ -2,7 +2,7 @@ * Semantics for AST Node {@link IdentifierTypeSpecifierExpression}. * @since 0.8.0 */ -import type { UncheckedType } from "../../../../../analysis"; +import type { RawType } from "../../../../../semantics"; import type { TypeSpecifierExpressionSemantics } from "../type-specifier-expression-semantics"; /** @@ -15,5 +15,5 @@ export interface IdentifierTypeSpecifierExpressionSemantics extends TypeSpecifie * therefore may be invalid/undefined. * @since 0.8.0 */ - typeIdentifier: UncheckedType; + typeIdentifier: RawType; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/identifier-type-specifier-expression/identifier-type-specifier-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/identifier-type-specifier-expression/identifier-type-specifier-expression.ts index d4194566f..c5dd01fc8 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/identifier-type-specifier-expression/identifier-type-specifier-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/identifier-type-specifier-expression/identifier-type-specifier-expression.ts @@ -13,7 +13,7 @@ import type { CompilableASTNode } from "../../../../compilable-ast-node"; import { TypeSpecifierExpression } from "../type-specifier-expression"; import type { IdentifierTypeSpecifierExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; -import { CheckedType, UncheckedType } from "../../../../../analysis"; +import { BuiltInTypes, RawType } from "../../../../../semantics"; /** * Type specifier expression, which represents a simple identifier type specifier. @@ -28,6 +28,25 @@ export class IdentifierTypeSpecifierExpression extends TypeSpecifierExpression< IdentifierTypeSpecifierExpressionSemantics, IdentifierTypeSpecifierExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_identifierTypeSpecifierExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.identifierTypeSpecifierExpression; + readonly targetCodeGenerator = this.codeGenerator.identifierTypeSpecifierExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -35,11 +54,10 @@ export class IdentifierTypeSpecifierExpression extends TypeSpecifierExpression< */ protected override readonly _antlrRuleCtx: IdentifierTypeSpecifierExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_identifierTypeSpecifierExpression; + constructor(antlrRuleCtx: IdentifierTypeSpecifierExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -53,12 +71,6 @@ export class IdentifierTypeSpecifierExpression extends TypeSpecifierExpression< return IdentifierTypeSpecifierExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -71,9 +83,11 @@ export class IdentifierTypeSpecifierExpression extends TypeSpecifierExpression< return IdentifierTypeSpecifierExpression.ruleName; } - constructor(antlrRuleCtx: IdentifierTypeSpecifierExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): IdentifierTypeSpecifierExpressionContext { + return this._antlrRuleCtx; } /** @@ -85,7 +99,7 @@ export class IdentifierTypeSpecifierExpression extends TypeSpecifierExpression< */ public async primarySemanticAnalysis(): Promise { this.semanticData = { - typeIdentifier: new UncheckedType(this.sourceCode), + typeIdentifier: new RawType(this.sourceCode), }; } @@ -98,29 +112,11 @@ export class IdentifierTypeSpecifierExpression extends TypeSpecifierExpression< const semanticData = this.getSemanticData(); // Create a checked type instance (this function handles error recovery and invalid types) - const valueType = this.programCtx.typeCheck(this).getCheckedType(semanticData.typeIdentifier); + const valueType = this.programCtx.typeCheck(this).getCheckedType(semanticData.typeIdentifier, this.scope); this.typeSemantics = { // A type specifier will always evaluate to be of type 'type' - evaluatedType: CheckedType.fromCompilableType("type"), + evaluatedType: BuiltInTypes.type, storedType: valueType, }; } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): IdentifierTypeSpecifierExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.identifierTypeSpecifierExpression; - readonly targetCodeGenerator = this.codeGenerator.identifierTypeSpecifierExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/type-specifier-expression-type-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/type-specifier-expression-type-semantics.ts index 284abeb1c..92536702f 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/type-specifier-expression-type-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/type-specifier-expression-type-semantics.ts @@ -2,7 +2,7 @@ * Type semantics for AST Node {@link TypeSpecifierExpression}. * @since 0.10.0 */ -import type { CheckedType } from "../../../../analysis"; +import type { ProcessedType } from "../../../../semantics"; import type { ExpressionTypeSemantics } from "../expression-type-semantics"; /** @@ -15,5 +15,5 @@ export interface TypeSpecifierExpressionTypeSemantics extends ExpressionTypeSema * values should be stored in a variable. * @since 0.10.0 */ - storedType: CheckedType; + storedType: ProcessedType; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/type-specifier-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/type-specifier-expression.ts index 3ff65350b..f04058275 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/type-specifier-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/type-specifier-expression.ts @@ -44,6 +44,8 @@ export abstract class TypeSpecifierExpression< TypeSemantics extends TypeSpecifierExpressionTypeSemantics = TypeSpecifierExpressionTypeSemantics, > extends Expression { protected abstract readonly _antlrRuleCtx: ParserTypeSpecifierExpressionContext; + public abstract get kind(): ASTTypeSpecifierExpressionKind; + public abstract get ruleName(): ParserTypeSpecifierExpressionRuleName; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression.ts index ff098fb81..9c0aee2d7 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression.ts @@ -18,6 +18,25 @@ export class TypeofTypeSpecifierExpression extends TypeSpecifierExpression< TypeofTypeSpecifierExpressionSemantics, TypeofTypeSpecifierExpressionTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_typeofTypeSpecifierExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.typeofTypeSpecifierExpression; + readonly targetCodeGenerator = this.codeGenerator.typeofTypeSpecifierExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -25,11 +44,10 @@ export class TypeofTypeSpecifierExpression extends TypeSpecifierExpression< */ protected override readonly _antlrRuleCtx: TypeofTypeSpecifierExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_typeofTypeSpecifierExpression; + constructor(antlrRuleCtx: TypeofTypeSpecifierExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -43,12 +61,6 @@ export class TypeofTypeSpecifierExpression extends TypeSpecifierExpression< return TypeofTypeSpecifierExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -61,9 +73,11 @@ export class TypeofTypeSpecifierExpression extends TypeSpecifierExpression< return TypeofTypeSpecifierExpression.ruleName; } - constructor(antlrRuleCtx: TypeofTypeSpecifierExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): TypeofTypeSpecifierExpressionContext { + return this._antlrRuleCtx; } /** @@ -89,22 +103,4 @@ export class TypeofTypeSpecifierExpression extends TypeSpecifierExpression< .semanticCheck(this) .notImplementedError(new KipperNotImplementedError("Typeof Type Expressions have not been implemented yet.")); } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): TypeofTypeSpecifierExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.typeofTypeSpecifierExpression; - readonly targetCodeGenerator = this.codeGenerator.typeofTypeSpecifierExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/increment-or-decrement-unary-expression/increment-or-decrement-unary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/increment-or-decrement-unary-expression/increment-or-decrement-unary-expression.ts index f368e6ab4..293d12547 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/increment-or-decrement-unary-expression/increment-or-decrement-unary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/increment-or-decrement-unary-expression/increment-or-decrement-unary-expression.ts @@ -14,7 +14,7 @@ import { UnaryExpression } from "../unary-expression"; import type { IncrementOrDecrementUnaryExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; /** * Increment or decrement expression class, which represents a left-side -- or ++ expression modifying a numeric value. @@ -27,6 +27,25 @@ export class IncrementOrDecrementUnaryExpression extends UnaryExpression< IncrementOrDecrementUnaryExpressionSemantics, IncrementOrDecrementUnaryTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_incrementOrDecrementUnaryExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.incrementOrDecrementUnaryExpression; + readonly targetCodeGenerator = this.codeGenerator.incrementOrDecrementUnaryExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -34,11 +53,10 @@ export class IncrementOrDecrementUnaryExpression extends UnaryExpression< */ protected override readonly _antlrRuleCtx: IncrementOrDecrementUnaryExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_incrementOrDecrementUnaryExpression; + constructor(antlrRuleCtx: IncrementOrDecrementUnaryExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -52,12 +70,6 @@ export class IncrementOrDecrementUnaryExpression extends UnaryExpression< return IncrementOrDecrementUnaryExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -70,9 +82,11 @@ export class IncrementOrDecrementUnaryExpression extends UnaryExpression< return IncrementOrDecrementUnaryExpression.ruleName; } - constructor(antlrRuleCtx: IncrementOrDecrementUnaryExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): IncrementOrDecrementUnaryExpressionContext { + return this._antlrRuleCtx; } public hasSideEffects(): boolean { @@ -112,28 +126,10 @@ export class IncrementOrDecrementUnaryExpression extends UnaryExpression< public async primarySemanticTypeChecking(): Promise { this.typeSemantics = { // This will always be a number - evaluatedType: CheckedType.fromKipperType("num"), + evaluatedType: BuiltInTypes.num, }; // Ensure that this expression is valid (e.g. the operand is a number) this.programCtx.typeCheck(this).validUnaryExpression(this); } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): IncrementOrDecrementUnaryExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.incrementOrDecrementUnaryExpression; - readonly targetCodeGenerator = this.codeGenerator.incrementOrDecrementUnaryExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/operator-modified-unary-expression/operator-modified-unary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/operator-modified-unary-expression/operator-modified-unary-expression.ts index 8d87f589b..59cb5076f 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/operator-modified-unary-expression/operator-modified-unary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/operator-modified-unary-expression/operator-modified-unary-expression.ts @@ -16,7 +16,7 @@ import { UnaryExpression } from "../unary-expression"; import type { OperatorModifiedUnaryExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping, UnaryOperatorContext } from "../../../../../lexer-parser"; import { UnableToDetermineSemanticDataError } from "../../../../../../errors"; -import { CheckedType } from "../../../../../analysis"; +import { BuiltInTypes } from "../../../../../semantics"; /** * Operator modified expressions, which are used to modify the value of an expression based on an @@ -30,6 +30,25 @@ export class OperatorModifiedUnaryExpression extends UnaryExpression< OperatorModifiedUnaryExpressionSemantics, OperatorModifiedUnaryTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_operatorModifiedUnaryExpression; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.operatorModifiedUnaryExpression; + readonly targetCodeGenerator = this.codeGenerator.operatorModifiedUnaryExpression; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -37,11 +56,10 @@ export class OperatorModifiedUnaryExpression extends UnaryExpression< */ protected override readonly _antlrRuleCtx: OperatorModifiedUnaryExpressionContext; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_operatorModifiedUnaryExpression; + constructor(antlrRuleCtx: OperatorModifiedUnaryExpressionContext, parent: CompilableASTNode) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -55,12 +73,6 @@ export class OperatorModifiedUnaryExpression extends UnaryExpression< return OperatorModifiedUnaryExpression.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -73,9 +85,11 @@ export class OperatorModifiedUnaryExpression extends UnaryExpression< return OperatorModifiedUnaryExpression.ruleName; } - constructor(antlrRuleCtx: OperatorModifiedUnaryExpressionContext, parent: CompilableASTNode) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; + /** + * The antlr context containing the antlr4 metadata for this expression. + */ + public override get antlrRuleCtx(): OperatorModifiedUnaryExpressionContext { + return this._antlrRuleCtx; } /** @@ -125,28 +139,10 @@ export class OperatorModifiedUnaryExpression extends UnaryExpression< const semanticData = this.getSemanticData(); this.typeSemantics = { - evaluatedType: CheckedType.fromCompilableType(semanticData.operator === "!" ? "bool" : "num"), + evaluatedType: semanticData.operator === "!" ? BuiltInTypes.bool : BuiltInTypes.num, }; // Ensure the operator is compatible with the type of the operand this.programCtx.typeCheck(this).validUnaryExpression(this); } - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - /** - * The antlr context containing the antlr4 metadata for this expression. - */ - public override get antlrRuleCtx(): OperatorModifiedUnaryExpressionContext { - return this._antlrRuleCtx; - } - - readonly targetSemanticAnalysis = this.semanticAnalyser.operatorModifiedUnaryExpression; - readonly targetCodeGenerator = this.codeGenerator.operatorModifiedUnaryExpression; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/unary-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/unary-expression.ts index eb5036f6c..44d3cf12e 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/unary-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/unary-expression/unary-expression.ts @@ -6,8 +6,7 @@ */ import type { UnaryExpressionSemantics } from "./unary-expression-semantics"; import type { UnaryExpressionTypeSemantics } from "./unary-expression-type-semantics"; -import type { ParseRuleKindMapping } from "../../../../lexer-parser"; -import type { KindParseRuleMapping } from "../../../../lexer-parser"; +import type { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../lexer-parser"; import { Expression } from "../expression"; import type { ASTNodeMapper } from "../../../mapping"; @@ -45,6 +44,8 @@ export abstract class UnaryExpression< TypeSemantics extends UnaryExpressionTypeSemantics = UnaryExpressionTypeSemantics, > extends Expression { protected abstract readonly _antlrRuleCtx: ParserUnaryExpressionContext; + public abstract get kind(): ASTUnaryExpressionKind; + public abstract get ruleName(): ParserUnaryExpressionRuleName; } diff --git a/kipper/core/src/compiler/ast/nodes/root-ast-node.ts b/kipper/core/src/compiler/ast/nodes/root-ast-node.ts index 31eac1bce..8e4851f98 100644 --- a/kipper/core/src/compiler/ast/nodes/root-ast-node.ts +++ b/kipper/core/src/compiler/ast/nodes/root-ast-node.ts @@ -19,23 +19,38 @@ import type { TranslatedCodeLine } from "../../const"; import type { KipperError } from "../../../errors"; import type { CompilationUnitContext } from "../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../lexer-parser"; -import { handleSemanticError } from "../../analysis"; +import { GlobalScope, handleSemanticError } from "../../semantics"; +import type { ScopeNode } from "../scope-node"; /** * The root node of an abstract syntax tree, which contains all AST nodes of a file. * @since 0.8.0 */ -export class RootASTNode extends ParserASTNode { - protected readonly _antlrRuleCtx: CompilationUnitContext; - protected readonly _programCtx: KipperProgramContext; - protected readonly _parent: undefined; - protected readonly _children: Array; - +export class RootASTNode extends ParserASTNode implements ScopeNode { /** * The static kind for this AST Node. * @since 0.11.0 */ public static readonly kind = ParseRuleKindMapping.RULE_compilationUnit; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + protected readonly _antlrRuleCtx: CompilationUnitContext; + protected readonly _programCtx: KipperProgramContext; + protected readonly _parent: undefined; + protected readonly _children: Array; + protected readonly _innerScope: GlobalScope; + + constructor(programCtx: KipperProgramContext, antlrCtx: CompilationUnitContext) { + super(antlrCtx, undefined); + this._antlrRuleCtx = antlrCtx; + this._programCtx = programCtx; + this._children = []; + this._parent = undefined; + this._innerScope = new GlobalScope(this, this.programCtx.universeScope); + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -49,12 +64,6 @@ export class RootASTNode extends ParserASTNode { return RootASTNode.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -67,12 +76,12 @@ export class RootASTNode extends ParserASTNode { return RootASTNode.ruleName; } - constructor(programCtx: KipperProgramContext, antlrCtx: CompilationUnitContext) { - super(antlrCtx, undefined); - this._antlrRuleCtx = antlrCtx; - this._programCtx = programCtx; - this._children = []; - this._parent = undefined; + /** + * Gets the inner scope of this function, where also the {@link semanticData.params arguments} should be registered. + * @since 0.10.0 + */ + public get innerScope(): GlobalScope { + return this._innerScope; } /** @@ -165,15 +174,6 @@ export class RootASTNode extends ParserASTNode { this._children.push(newChild); } - /** - * Handles the specified error that occurred during the semantic analysis of this node in a standardised way. - * @param error The error to handle. - * @since 0.10.0 - */ - protected handleSemanticError(error: Error | KipperError): void { - handleSemanticError(this, error); - } - /** * Semantically analyses the children tokens of this * {@link RootASTNode instance} and performs additional @@ -247,4 +247,13 @@ export class RootASTNode extends ParserASTNode { // Finished code for this Kipper file return genCode; } + + /** + * Handles the specified error that occurred during the semantic analysis of this node in a standardised way. + * @param error The error to handle. + * @since 0.10.0 + */ + protected handleSemanticError(error: Error | KipperError): void { + handleSemanticError(this, error); + } } diff --git a/kipper/core/src/compiler/ast/nodes/statements/compound-statement/compound-statement.ts b/kipper/core/src/compiler/ast/nodes/statements/compound-statement/compound-statement.ts index d8536f2b4..9964e223c 100644 --- a/kipper/core/src/compiler/ast/nodes/statements/compound-statement/compound-statement.ts +++ b/kipper/core/src/compiler/ast/nodes/statements/compound-statement/compound-statement.ts @@ -7,7 +7,7 @@ import type { CompilableNodeParent } from "../../../compilable-ast-node"; import type { CompoundStatementSemantics } from "./compound-statement-semantics"; import type { CompoundStatementTypeSemantics } from "./compound-statement-type-semantics"; import { Statement } from "../statement"; -import { LocalScope } from "../../../../analysis"; +import { LocalScope } from "../../../../semantics"; import type { CompoundStatementContext } from "../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../lexer-parser"; @@ -19,18 +19,59 @@ export class CompoundStatement extends Statement implements ScopeNode { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_compoundStatement; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Performs the semantic analysis for this Kipper token. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the semantic analysis of + * the children has already failed and as such no parent node should run type checking. + */ + public primarySemanticAnalysis = undefined; // Compound statements will never have semantic data + /** + * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of + * the children has already failed and as such no parent node should run type checking. + * @since 0.7.0 + */ + public primarySemanticTypeChecking = undefined; // Compound statements will never have type checking + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.compoundStatement; + readonly targetCodeGenerator = this.codeGenerator.compoundStatement; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. * @private */ protected override readonly _antlrRuleCtx: CompoundStatementContext; + protected readonly _children: Array; + private readonly _innerScope: LocalScope; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_compoundStatement; + constructor(antlrRuleCtx: CompoundStatementContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._children = []; + this._semanticData = {}; + this._typeSemantics = {}; + this._innerScope = new LocalScope(this); + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -44,12 +85,6 @@ export class CompoundStatement return CompoundStatement.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -62,19 +97,6 @@ export class CompoundStatement return CompoundStatement.ruleName; } - protected readonly _children: Array; - - private readonly _innerScope: LocalScope; - - constructor(antlrRuleCtx: CompoundStatementContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._children = []; - this._semanticData = {}; - this._typeSemantics = {}; - this._innerScope = new LocalScope(this); - } - /** * The children of this parse token. */ @@ -97,34 +119,4 @@ export class CompoundStatement public get innerScope(): LocalScope { return this._innerScope; } - - /** - * Performs the semantic analysis for this Kipper token. This will log all warnings using {@link programCtx.logger} - * and throw errors if encountered. - * - * This will not run in case that {@link this.hasFailed} is true, as that indicates that the semantic analysis of - * the children has already failed and as such no parent node should run type checking. - */ - public primarySemanticAnalysis = undefined; // Compound statements will never have semantic data - - /** - * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} - * and throw errors if encountered. - * - * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of - * the children has already failed and as such no parent node should run type checking. - * @since 0.7.0 - */ - public primarySemanticTypeChecking = undefined; // Compound statements will never have type checking - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - readonly targetSemanticAnalysis = this.semanticAnalyser.compoundStatement; - readonly targetCodeGenerator = this.codeGenerator.compoundStatement; } diff --git a/kipper/core/src/compiler/ast/nodes/statements/expression-statement/expression-statement.ts b/kipper/core/src/compiler/ast/nodes/statements/expression-statement/expression-statement.ts index 43e630f6a..af8663d1c 100644 --- a/kipper/core/src/compiler/ast/nodes/statements/expression-statement/expression-statement.ts +++ b/kipper/core/src/compiler/ast/nodes/statements/expression-statement/expression-statement.ts @@ -13,18 +13,50 @@ import type { Expression } from "../../expressions"; * Expression statement class, which represents a statement made up of an expression in the Kipper language. */ export class ExpressionStatement extends Statement { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_expressionStatement; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Performs the semantic analysis for this Kipper token. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the semantic analysis of + * the children has already failed and as such no parent node should run type checking. + */ + public primarySemanticAnalysis = undefined; // Expression statements will never have semantic data + /** + * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of + * the children has already failed and as such no parent node should run type checking. + * @since 0.7.0 + */ + public primarySemanticTypeChecking = undefined; // Expression statements will never have type checking + readonly targetSemanticAnalysis = this.semanticAnalyser.expressionStatement; + readonly targetCodeGenerator = this.codeGenerator.expressionStatement; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. * @private */ protected override readonly _antlrRuleCtx: ExpressionStatementContext; + protected readonly _children: Array; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_expressionStatement; + constructor(antlrRuleCtx: ExpressionStatementContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._children = []; + this._semanticData = {}; + this._typeSemantics = {}; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -38,12 +70,6 @@ export class ExpressionStatement extends Statement; - - constructor(antlrRuleCtx: ExpressionStatementContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._children = []; - this._semanticData = {}; - this._typeSemantics = {}; - } - /** * The children of this parse token. */ @@ -80,25 +96,6 @@ export class ExpressionStatement extends Statement { this.programCtx.warningCheck(this).uselessStatement(this); } - - readonly targetSemanticAnalysis = this.semanticAnalyser.expressionStatement; - readonly targetCodeGenerator = this.codeGenerator.expressionStatement; } diff --git a/kipper/core/src/compiler/ast/nodes/statements/if-statement/if-statement.ts b/kipper/core/src/compiler/ast/nodes/statements/if-statement/if-statement.ts index 733a09616..115c2a20e 100644 --- a/kipper/core/src/compiler/ast/nodes/statements/if-statement/if-statement.ts +++ b/kipper/core/src/compiler/ast/nodes/statements/if-statement/if-statement.ts @@ -16,18 +16,48 @@ import { UnableToDetermineSemanticDataError } from "../../../../../errors"; * {@link translateCtxAndChildren}. */ export class IfStatement extends Statement { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_ifStatement; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of + * the children has already failed and as such no parent node should run type checking. + * @since 0.7.0 + */ + public primarySemanticTypeChecking = undefined; // If-statements will never have type checking + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.ifStatement; + readonly targetCodeGenerator = this.codeGenerator.ifStatement; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. * @private */ protected override readonly _antlrRuleCtx: IfStatementContext; + protected readonly _children: Array; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_ifStatement; + constructor(antlrRuleCtx: IfStatementContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._children = []; + this._typeSemantics = {}; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -41,12 +71,6 @@ export class IfStatement extends Statement; - - constructor(antlrRuleCtx: IfStatementContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._children = []; - this._typeSemantics = {}; - } - /** * The children of this AST node. * @@ -110,25 +125,4 @@ export class IfStatement extends Statement { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_doWhileLoopIterationStatement; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of + * the children has already failed and as such no parent node should run type checking. + * @since 0.7.0 + */ + public primarySemanticTypeChecking: undefined = undefined; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.doWhileLoopIterationStatement; + readonly targetCodeGenerator = this.codeGenerator.doWhileLoopIterationStatement; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. * @private */ protected override readonly _antlrRuleCtx: DoWhileLoopIterationStatementContext; + protected readonly _children: Array; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_doWhileLoopIterationStatement; + constructor(antlrRuleCtx: DoWhileLoopIterationStatementContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._children = []; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -44,12 +73,6 @@ export class DoWhileLoopIterationStatement extends IterationStatement< return DoWhileLoopIterationStatement.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -62,14 +85,6 @@ export class DoWhileLoopIterationStatement extends IterationStatement< return DoWhileLoopIterationStatement.ruleName; } - protected readonly _children: Array; - - constructor(antlrRuleCtx: DoWhileLoopIterationStatementContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._children = []; - } - /** * The children of this parse token. */ @@ -100,25 +115,4 @@ export class DoWhileLoopIterationStatement extends IterationStatement< loopBody: loopBody, }; } - - /** - * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} - * and throw errors if encountered. - * - * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of - * the children has already failed and as such no parent node should run type checking. - * @since 0.7.0 - */ - public primarySemanticTypeChecking: undefined = undefined; - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - readonly targetSemanticAnalysis = this.semanticAnalyser.doWhileLoopIterationStatement; - readonly targetCodeGenerator = this.codeGenerator.doWhileLoopIterationStatement; } diff --git a/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/for-loop-iteration-statement/for-loop-iteration-statement.ts b/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/for-loop-iteration-statement/for-loop-iteration-statement.ts index bc096eac1..949730301 100644 --- a/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/for-loop-iteration-statement/for-loop-iteration-statement.ts +++ b/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/for-loop-iteration-statement/for-loop-iteration-statement.ts @@ -12,7 +12,7 @@ import { IterationStatement } from "../iteration-statement"; import type { ForLoopIterationStatementContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; import type { Expression } from "../../../expressions"; -import { LocalScope } from "../../../../../analysis"; +import { LocalScope } from "../../../../../semantics"; /** * For loop statement class, which represents a for loop statement in the Kipper language and is compilable @@ -23,24 +23,53 @@ export class ForLoopIterationStatement implements ScopeNode { /** - * The private field '_innerScope' that actually stores the variable data, - * which is returned inside the {@link this.innerScope}. - * @private + * The static kind for this AST Node. + * @since 0.11.0 */ - private readonly _innerScope: LocalScope; - + public static readonly kind = ParseRuleKindMapping.RULE_forLoopIterationStatement; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of + * the children has already failed and as such no parent node should run type checking. + * @since 0.7.0 + */ + public primarySemanticTypeChecking = undefined; // For-loop statements will never have type checking + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.forLoopIterationStatement; + readonly targetCodeGenerator = this.codeGenerator.forLoopIterationStatement; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. * @private */ protected override readonly _antlrRuleCtx: ForLoopIterationStatementContext; - + protected readonly _children: Array; /** - * The static kind for this AST Node. - * @since 0.11.0 + * The private field '_innerScope' that actually stores the variable data, + * which is returned inside the {@link this.innerScope}. + * @private */ - public static readonly kind = ParseRuleKindMapping.RULE_forLoopIterationStatement; + private readonly _innerScope: LocalScope; + + constructor(antlrRuleCtx: ForLoopIterationStatementContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._children = []; + this._innerScope = new LocalScope(this); + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -54,12 +83,6 @@ export class ForLoopIterationStatement return ForLoopIterationStatement.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -72,15 +95,6 @@ export class ForLoopIterationStatement return ForLoopIterationStatement.ruleName; } - protected readonly _children: Array; - - constructor(antlrRuleCtx: ForLoopIterationStatementContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._children = []; - this._innerScope = new LocalScope(this); - } - /** * The children of this parse token. */ @@ -129,25 +143,4 @@ export class ForLoopIterationStatement loopBody: loopBody, }; } - - /** - * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} - * and throw errors if encountered. - * - * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of - * the children has already failed and as such no parent node should run type checking. - * @since 0.7.0 - */ - public primarySemanticTypeChecking = undefined; // For-loop statements will never have type checking - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - readonly targetSemanticAnalysis = this.semanticAnalyser.forLoopIterationStatement; - readonly targetCodeGenerator = this.codeGenerator.forLoopIterationStatement; } diff --git a/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/iteration-statement.ts b/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/iteration-statement.ts index b9cf08cb0..45d8062f0 100644 --- a/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/iteration-statement.ts +++ b/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/iteration-statement.ts @@ -45,6 +45,8 @@ export abstract class IterationStatement< TypeSemantics extends IterationStatementTypeSemantics = IterationStatementTypeSemantics, > extends Statement { protected abstract readonly _antlrRuleCtx: ParserIterationStatementContext; + public abstract get kind(): ParserIterationStatementKind; + public abstract get ruleName(): ParserIterationStatementRuleName; } diff --git a/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/while-loop-iteration-statement/while-loop-iteration-statement.ts b/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/while-loop-iteration-statement/while-loop-iteration-statement.ts index cb3ac28f5..1096b291c 100644 --- a/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/while-loop-iteration-statement/while-loop-iteration-statement.ts +++ b/kipper/core/src/compiler/ast/nodes/statements/iteration-statement/while-loop-iteration-statement/while-loop-iteration-statement.ts @@ -19,18 +19,48 @@ export class WhileLoopIterationStatement extends IterationStatement< WhileLoopStatementSemantics, WhileLoopStatementTypeSemantics > { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_whileLoopIterationStatement; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of + * the children has already failed and as such no parent node should run type checking. + * @since 0.7.0 + */ + public primarySemanticTypeChecking = undefined; // While-loop statements will never have type checking + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.whileLoopIterationStatement; + readonly targetCodeGenerator = this.codeGenerator.whileLoopIterationStatement; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. * @private */ protected override readonly _antlrRuleCtx: WhileLoopIterationStatementContext; + protected readonly _children: Array; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_whileLoopIterationStatement; + constructor(antlrRuleCtx: WhileLoopIterationStatementContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._children = []; + this._typeSemantics = {}; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -44,12 +74,6 @@ export class WhileLoopIterationStatement extends IterationStatement< return WhileLoopIterationStatement.kind; } - /** - * The static rule name for this AST Node. - * @since 0.11.0 - */ - public static readonly ruleName = KindParseRuleMapping[this.kind]; - /** * Returns the rule name of this AST Node. This represents the specific type of the {@link antlrRuleCtx} that this * AST node wraps. @@ -62,15 +86,6 @@ export class WhileLoopIterationStatement extends IterationStatement< return WhileLoopIterationStatement.ruleName; } - protected readonly _children: Array; - - constructor(antlrRuleCtx: WhileLoopIterationStatementContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._children = []; - this._typeSemantics = {}; - } - /** * The children of this parse token. */ @@ -101,25 +116,4 @@ export class WhileLoopIterationStatement extends IterationStatement< loopBody: loopBody, }; } - - /** - * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} - * and throw errors if encountered. - * - * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of - * the children has already failed and as such no parent node should run type checking. - * @since 0.7.0 - */ - public primarySemanticTypeChecking = undefined; // While-loop statements will never have type checking - - /** - * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. - * - * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. - * @since 0.9.0 - */ - public checkForWarnings = undefined; // TODO! - - readonly targetSemanticAnalysis = this.semanticAnalyser.whileLoopIterationStatement; - readonly targetCodeGenerator = this.codeGenerator.whileLoopIterationStatement; } diff --git a/kipper/core/src/compiler/ast/nodes/statements/jump-statement/jump-statement.ts b/kipper/core/src/compiler/ast/nodes/statements/jump-statement/jump-statement.ts index f99f8fb15..80ef65a2f 100644 --- a/kipper/core/src/compiler/ast/nodes/statements/jump-statement/jump-statement.ts +++ b/kipper/core/src/compiler/ast/nodes/statements/jump-statement/jump-statement.ts @@ -15,18 +15,47 @@ import type { Expression } from "../../expressions"; * {@link translateCtxAndChildren}. */ export class JumpStatement extends Statement { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_jumpStatement; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Performs type checking for this AST Node. This will log all warnings using {@link programCtx.logger} + * and throw errors if encountered. + * + * This will not run in case that {@link this.hasFailed} is true, as that indicates that the type checking of + * the children has already failed and as such no parent node should run type checking. + * @since 0.7.0 + */ + public primarySemanticTypeChecking = undefined; // Jump statements will never have type checking + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.jumpStatement; + readonly targetCodeGenerator = this.codeGenerator.jumpStatement; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. * @private */ protected override readonly _antlrRuleCtx: JumpStatementContext; + protected readonly _children: Array; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_jumpStatement; + constructor(antlrRuleCtx: JumpStatementContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._children = []; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -40,12 +69,6 @@ export class JumpStatement extends Statement; - - constructor(antlrRuleCtx: JumpStatementContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._children = []; - } - /** * The children of this parse token. */ @@ -96,25 +111,4 @@ export class JumpStatement extends Statement { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_returnStatement; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.returnStatement; + readonly targetCodeGenerator = this.codeGenerator.returnStatement; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. * @private */ protected override readonly _antlrRuleCtx: ReturnStatementContext; + protected readonly _children: Array; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_returnStatement; + constructor(antlrRuleCtx: ReturnStatementContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._children = []; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -41,12 +61,6 @@ export class ReturnStatement extends Statement; - - constructor(antlrRuleCtx: ReturnStatementContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._children = []; - } - /** * The children of this parse token. */ @@ -115,19 +121,7 @@ export class ReturnStatement extends Statement extends CompilableASTNode { + public abstract targetCodeGenerator: TargetASTNodeCodeGenerator>; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. @@ -28,6 +29,14 @@ export abstract class Statement< */ protected override readonly _antlrRuleCtx: ParserStatementContext; + protected constructor(antlrRuleCtx: ParserStatementContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + + // Manually add the child to the parent + parent.addNewChild(this); + } + /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST * node wraps. @@ -48,14 +57,6 @@ export abstract class Statement< */ public abstract get ruleName(): ASTStatementRuleName; - protected constructor(antlrRuleCtx: ParserStatementContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - - // Manually add the child to the parent - parent.addNewChild(this); - } - /** * The antlr context containing the antlr4 metadata for this statement. */ @@ -71,6 +72,4 @@ export abstract class Statement< public async translateCtxAndChildren(): Promise> { return await this.targetCodeGenerator(this); } - - public abstract targetCodeGenerator: TargetASTNodeCodeGenerator>; } diff --git a/kipper/core/src/compiler/ast/nodes/statements/switch-statement/switch-statement.ts b/kipper/core/src/compiler/ast/nodes/statements/switch-statement/switch-statement.ts index 81dd7339e..10c8aabd0 100644 --- a/kipper/core/src/compiler/ast/nodes/statements/switch-statement/switch-statement.ts +++ b/kipper/core/src/compiler/ast/nodes/statements/switch-statement/switch-statement.ts @@ -13,18 +13,38 @@ import { KipperNotImplementedError } from "../../../../../errors"; * Switch statement class, which represents a switch selection statement in the Kipper language. */ export class SwitchStatement extends Statement { + /** + * The static kind for this AST Node. + * @since 0.11.0 + */ + public static readonly kind = ParseRuleKindMapping.RULE_switchStatement; + /** + * The static rule name for this AST Node. + * @since 0.11.0 + */ + public static readonly ruleName = KindParseRuleMapping[this.kind]; + /** + * Semantically analyses the code inside this AST node and checks for possible warnings or problematic code. + * + * This will log all warnings using {@link programCtx.logger} and store them in {@link KipperProgramContext.warnings}. + * @since 0.9.0 + */ + public checkForWarnings = undefined; // TODO! + readonly targetSemanticAnalysis = this.semanticAnalyser.switchStatement; + readonly targetCodeGenerator = this.codeGenerator.switchStatement; /** * The private field '_antlrRuleCtx' that actually stores the variable data, * which is returned inside the {@link this.antlrRuleCtx}. * @private */ protected override readonly _antlrRuleCtx: SwitchStatementContext; + protected readonly _children: Array; - /** - * The static kind for this AST Node. - * @since 0.11.0 - */ - public static readonly kind = ParseRuleKindMapping.RULE_switchStatement; + constructor(antlrRuleCtx: SwitchStatementContext, parent: CompilableNodeParent) { + super(antlrRuleCtx, parent); + this._antlrRuleCtx = antlrRuleCtx; + this._children = []; + } /** * Returns the kind of this AST node. This represents the specific type of the {@link antlrRuleCtx} that this AST @@ -38,12 +58,6 @@ export class SwitchStatement extends Statement; - - constructor(antlrRuleCtx: SwitchStatementContext, parent: CompilableNodeParent) { - super(antlrRuleCtx, parent); - this._antlrRuleCtx = antlrRuleCtx; - this._children = []; - } - /** * The children of this AST node. */ @@ -104,15 +110,4 @@ export class SwitchStatement extends Statement extends CompilableASTNode { +export interface ScopeNode extends ParserASTNode { /** * The inner scope that is created for this node. * @@ -24,17 +23,4 @@ export interface ScopeNode extends CompilableASTNode { * @since 0.10.0 */ innerScope: T; - /** - * Semantic analyser function that is specific for the {@link KipperCompileTarget target}. - * - * This only should perform logical analysis and not interpret the code/modify - * the {@link semanticData} field. - * @since 0.10.0 - */ - readonly targetSemanticAnalysis: TargetASTNodeSemanticAnalyser | undefined; - /** - * Code generator function that is specific for the {@link KipperCompileTarget target}. - * @since 0.10.0 - */ - readonly targetCodeGenerator: TargetASTNodeCodeGenerator>; } diff --git a/kipper/core/src/compiler/compile-config.ts b/kipper/core/src/compiler/compile-config.ts index eaef50a60..6cea3dafe 100644 --- a/kipper/core/src/compiler/compile-config.ts +++ b/kipper/core/src/compiler/compile-config.ts @@ -2,8 +2,7 @@ * Configuration for a Kipper program that can be passed to {@link KipperCompiler.compile}. * @since 0.10.0 */ -import type { BuiltInFunction, BuiltInVariable } from "./runtime-built-ins"; -import { kipperRuntimeBuiltInFunctions, kipperRuntimeBuiltInVariables } from "./runtime-built-ins"; +import type { BuiltInFunction, BuiltInVariable } from "./semantics/runtime-built-ins"; import type { KipperCompileTarget } from "./target-presets"; import type { OptimisationOptions } from "./optimiser"; import { defaultOptimisationOptions } from "./optimiser"; @@ -118,8 +117,6 @@ export class EvaluatedCompileConfig implements CompileConfig { * @since 0.2.0 */ public static readonly defaults = { - builtInFunctions: Object.values(kipperRuntimeBuiltInFunctions), // Default built-in global functions - builtInVariables: Object.values(kipperRuntimeBuiltInVariables), // Default built-in global variables extendBuiltInFunctions: >[], // Use no custom built-in functions per default extendBuiltInVariables: >[], // Use no custom built-in variables per default fileName: "anonymous-script", // Default name if no name is specified @@ -135,23 +132,6 @@ export class EvaluatedCompileConfig implements CompileConfig { */ public readonly target: KipperCompileTarget; - /** - * The built-in functions that will be available in a Kipper program. - * - * This will be extended by {@link extendBuiltInFunctions}. All built-in functions defined here must be implemented by the - * {@link target.builtInGenerator}. - */ - public readonly builtInFunctions: Array; - - /** - * The built-in variables that will be available in a Kipper program. This option overwrites the default built-ins, - * if you wish to only add new built-in variables write to {@link extendBuiltInVariables}. - * - * All built-in variables defined here must be implemented by the {@link target.builtInGenerator}. - * @since 0.10.0 - */ - public readonly builtInVariables: Array; - /** * Extensions to the global built-in functions that should not replace the primary {@link builtInFunctions}. * @@ -226,8 +206,6 @@ export class EvaluatedCompileConfig implements CompileConfig { // Evaluate all config options this.target = rawConfig.target; - this.builtInFunctions = this.getConfigOption("builtInFunctions", rawConfig); - this.builtInVariables = this.getConfigOption("builtInVariables", rawConfig); this.extendBuiltInFunctions = this.getConfigOption("extendBuiltInFunctions", rawConfig); this.extendBuiltInVariables = this.getConfigOption("extendBuiltInVariables", rawConfig); this.fileName = this.getConfigOption("fileName", rawConfig); diff --git a/kipper/core/src/compiler/compiler.ts b/kipper/core/src/compiler/compiler.ts index 56dd428c2..547792a0a 100644 --- a/kipper/core/src/compiler/compiler.ts +++ b/kipper/core/src/compiler/compiler.ts @@ -2,8 +2,6 @@ * Main Compiler file for interacting with the entire Kipper Compiler * @since 0.0.1 */ -import type { InternalFunction } from "./runtime-built-ins"; -import { kipperInternalBuiltInFunctions } from "./runtime-built-ins"; import type { CodePointCharStream, Token } from "antlr4ts"; import { CommonTokenStream } from "antlr4ts"; import { KipperAntlrErrorListener } from "../antlr-error-listener"; @@ -18,6 +16,8 @@ import { EvaluatedCompileConfig } from "./compile-config"; import { KipperCompileResult } from "./compile-result"; import * as Channel from "./lexer-parser/lexer-channels"; import { PragmaProcessor } from "./pragma-processor"; +import type { InternalFunction } from "./semantics"; +import { kipperInternalBuiltInFunctions } from "./semantics"; /** * The main Compiler class that contains the functions for parsing and compiling a file. diff --git a/kipper/core/src/compiler/const.ts b/kipper/core/src/compiler/const.ts index c8336370a..e62883f06 100644 --- a/kipper/core/src/compiler/const.ts +++ b/kipper/core/src/compiler/const.ts @@ -2,15 +2,7 @@ * Constant declarations and types for the compiler implementation. * @since 0.3.0 */ -import type { - ScopeDeclaration, - ScopeFunctionDeclaration, - ScopeParameterDeclaration, - ScopeVariableDeclaration, - UndefinedCustomType, -} from "./analysis"; -import type { BuiltInFunction, BuiltInVariable } from "./runtime-built-ins"; -import type { InternalFunction } from "./runtime-built-ins"; +import type { ScopeDeclaration } from "./semantics"; /** * If this variable is true, then this environment is assumed to be inside a browser and special browser support should @@ -26,50 +18,50 @@ export const isBrowser = typeof window !== "undefined" && {}.toString.call(windo * type. * @since 0.8.0 */ -export type KipperMetaType = "type"; +export type KipperMetaTypeLiteral = "type"; /** * Represents the meta type in Kipper, which itself is used represents a type e.g. this is the type of a * type. * @since 0.8.0 */ -export const kipperMetaType: KipperMetaType = "type"; +export const kipperMetaTypeLiteral: KipperMetaTypeLiteral = "type"; /** * Null type in Kipper. * @since 0.10.0 */ -export type KipperNullType = "null"; +export type KipperNullTypeLiteral = "null"; /** * Null type in Kipper. * @since 0.10.0 */ -export const kipperNullType: KipperNullType = "null"; +export const kipperNullTypeLiteral: KipperNullTypeLiteral = "null"; /** * Undefined type in Kipper. * @since 0.10.0 */ -export type KipperUndefinedType = "undefined"; +export type KipperUndefinedTypeLiteral = "undefined"; /** * Undefined type in Kipper. * @since 0.10.0 */ -export const kipperUndefinedType: KipperUndefinedType = "undefined"; +export const kipperUndefinedTypeLiteral: KipperUndefinedTypeLiteral = "undefined"; /** * Function type in Kipper. * @since 0.6.0 */ -export type KipperFuncType = "func"; +export type KipperFuncTypeLiteral = "func"; /** * Function type in Kipper. * @since 0.6.0 */ -export const kipperFuncType: KipperFuncType = "func"; +export const kipperFuncTypeLiteral: KipperFuncTypeLiteral = "func"; /** * Void type in Kipper. @@ -77,7 +69,7 @@ export const kipperFuncType: KipperFuncType = "func"; * @example * void */ -export type KipperVoidType = "void"; +export type KipperVoidTypeLiteral = "void"; /** * Void type in Kipper. @@ -85,7 +77,7 @@ export type KipperVoidType = "void"; * @example * void */ -export const kipperVoidType: KipperVoidType = "void"; +export const kipperVoidTypeLiteral: KipperVoidTypeLiteral = "void"; /** * Numeric type in Kipper. @@ -93,7 +85,7 @@ export const kipperVoidType: KipperVoidType = "void"; * @example * num */ -export type KipperNumType = "num"; +export type KipperNumTypeLiteral = "num"; /** * Numeric type in Kipper. @@ -101,7 +93,7 @@ export type KipperNumType = "num"; * @example * num */ -export const kipperNumType: KipperNumType = "num"; +export const kipperNumTypeLiteral: KipperNumTypeLiteral = "num"; /** * String type in Kipper. @@ -109,7 +101,7 @@ export const kipperNumType: KipperNumType = "num"; * @example * str */ -export type KipperStrType = "str"; +export type KipperStrTypeLiteral = "str"; /** * String type in Kipper. @@ -117,7 +109,7 @@ export type KipperStrType = "str"; * @example * str */ -export const kipperStrType: KipperStrType = "str"; +export const kipperStrTypeLiteral: KipperStrTypeLiteral = "str"; /** * Boolean type in Kipper. @@ -125,15 +117,15 @@ export const kipperStrType: KipperStrType = "str"; * @example * bool */ -export type KipperBoolType = "bool"; +export type KipperBoolTypeLiteral = "bool"; /** - * Literal names for a Kipper boolean. + * Constant names for a Kipper boolean. * @since 0.8.0 * @example * var x: bool = true; */ -export type KipperBoolTypeLiterals = "true" | "false"; +export type KipperBoolTypeConstants = "true" | "false"; /** * Boolean type in Kipper. @@ -141,17 +133,14 @@ export type KipperBoolTypeLiterals = "true" | "false"; * @example * bool */ -export const kipperBoolType: KipperBoolType = "bool"; +export const kipperBoolTypeLiteral: KipperBoolTypeLiteral = "bool"; /** * List type in Kipper. {@link KipperType T} represents the type of the list content and only serves as a * type checking generic type, it will not change the type itself. * @since 0.5.0 - * @example - * list */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export type KipperListType = "list"; +export type KipperListTypeLiteral = "list"; /** * List type in Kipper. {@link KipperType ValueType} represents the type of the list content and only serves as a @@ -160,31 +149,31 @@ export type KipperListType = "list"; * @example * list */ -export const kipperListType: KipperListType = "list"; +export const kipperListTypeLiteral: KipperListTypeLiteral = "list"; /** * All primitive types inside Kipper. * @since 0.6.0 */ -export type KipperPrimitiveType = - | KipperVoidType - | KipperNullType - | KipperUndefinedType - | KipperNumType - | KipperStrType - | KipperBoolType; +export type KipperPrimitiveTypeLiteral = + | KipperVoidTypeLiteral + | KipperNullTypeLiteral + | KipperUndefinedTypeLiteral + | KipperNumTypeLiteral + | KipperStrTypeLiteral + | KipperBoolTypeLiteral; /** * All primitive types inside Kipper. * @since 0.6.0 */ -export const kipperPrimitiveTypes: Array = [ - kipperVoidType, - kipperNullType, - kipperUndefinedType, - kipperNumType, - kipperStrType, - kipperBoolType, +export const kipperPrimitiveTypeLiterals: Array = [ + kipperVoidTypeLiteral, + kipperNullTypeLiteral, + kipperUndefinedTypeLiteral, + kipperNumTypeLiteral, + kipperStrTypeLiteral, + kipperBoolTypeLiteral, ]; /** @@ -194,29 +183,23 @@ export const kipperPrimitiveTypes: Array = [ * only used for error handling/recovery and skips type checking altogether. * @since 0.10.0 */ -export type KipperCompilableType = KipperMetaType | KipperPrimitiveType | KipperFuncType | KipperListType; +export type KipperBuiltInTypeLiteral = + | KipperMetaTypeLiteral + | KipperPrimitiveTypeLiteral + | KipperFuncTypeLiteral + | KipperListTypeLiteral; /** * All compilable and valid base types inside Kipper. * @since 0.10.0 */ -export const kipperCompilableTypes: Array = [ - kipperFuncType, - ...kipperPrimitiveTypes, - kipperListType, +export const kipperBuiltInTypeLiterals: Array = [ + kipperMetaTypeLiteral, + kipperFuncTypeLiteral, + ...kipperPrimitiveTypeLiterals, + kipperListTypeLiteral, ]; -/** - * All error types inside Kipper, which indicate an invalid type that can not be used for type checking. - * @since 0.10.0 - */ -export type KipperErrorType = UndefinedCustomType; - -/** - * All available variable types inside Kipper. - */ -export type KipperType = KipperCompilableType | KipperErrorType; - /** * List of all supported variable type conversions that can be performed in a Kipper program. * @@ -224,7 +207,7 @@ export type KipperType = KipperCompilableType | KipperErrorType; * which generates for each conversion the translator function in the specific target. * @since 0.8.0 */ -export const kipperSupportedConversions: Array<[KipperType, KipperType]> = [ +export const kipperSupportedConversions: Array<[KipperBuiltInTypeLiteral, KipperBuiltInTypeLiteral]> = [ ["num", "str"], ["bool", "str"], ["void", "str"], @@ -237,7 +220,7 @@ export const kipperSupportedConversions: Array<[KipperType, KipperType]> = [ /** * All available storage types inside Kipper, which define how a variable is stored/can be accessed. */ -export type KipperStorageType = "var" | "const"; +export type KipperStorageType = "var" | "const" | "built-in"; /** * All available storage types inside Kipper, which define how a variable is stored/can be accessed. @@ -627,43 +610,11 @@ export type TranslatedExpression = Array; */ export type TranslatedCodeLine = Array; -/** - * Represents all referencable functions that a user can use inside Kipper. This does not include internal functions. - * @since 0.10.0 - */ -export type KipperReferenceableFunction = BuiltInFunction | ScopeFunctionDeclaration; - -/** - * Represents a Kipper function that can be either declared or defined. - * @since 0.6.0 - */ -export type KipperFunction = InternalFunction | KipperReferenceableFunction; - -/** - * Represents a Kipper variable that can be either declared or defined. - * @since 0.6.0 - */ -export type KipperVariable = BuiltInVariable | ScopeVariableDeclaration; - -/** - * Represents a Kipper parameter inside a custom user-defined {@link FunctionDeclaration ScopeFunctionDeclaration}. - * @since 0.10.0 - */ -export type KipperParam = ScopeParameterDeclaration; - -/** - * Represents a Kipper argument inside a custom user-defined {@link FunctionDeclaration ScopeFunctionDeclaration}. - * - * @alias KipperParam - * @since 0.10.0 - */ -export type KipperArg = KipperParam; - /** * Represents a runtime variable or function that can be referenced. * @since 0.6.0 */ -export type KipperReferenceable = KipperReferenceableFunction | KipperVariable | KipperParam | ScopeDeclaration; +export type KipperReferenceable = ScopeDeclaration; /** * Represents all possible jump statements inside Kipper. diff --git a/kipper/core/src/compiler/index.ts b/kipper/core/src/compiler/index.ts index 1ce75dda9..8d5333946 100644 --- a/kipper/core/src/compiler/index.ts +++ b/kipper/core/src/compiler/index.ts @@ -5,11 +5,11 @@ export * from "./const"; export * from "./lexer-parser/"; export * from "./ast/"; -export * from "./analysis/"; +export * from "./semantics/"; export * from "./target-presets/"; export * from "./optimiser/"; export * from "./compile-config"; export * from "./compile-result"; export * from "./compiler"; export * from "./program-ctx"; -export * from "./runtime-built-ins"; +export * from "./semantics/runtime-built-ins"; diff --git a/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.interp b/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.interp index 6fb70de37..0e72778cf 100644 --- a/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.interp +++ b/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.interp @@ -23,6 +23,8 @@ null 'return' 'call' '->' +'class' +'interface' 'true' 'false' 'typeof' @@ -110,6 +112,8 @@ DefFunc Return CallFunc RetIndicator +Class +Interface True False Typeof @@ -195,6 +199,8 @@ DefFunc Return CallFunc RetIndicator +Class +Interface True False Typeof @@ -304,4 +310,4 @@ SINGLE_QUOTE_FSTRING DOUBLE_QUOTE_FSTRING atn: -[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 2, 86, 736, 8, 1, 8, 1, 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, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 4, 68, 9, 68, 4, 69, 9, 69, 4, 70, 9, 70, 4, 71, 9, 71, 4, 72, 9, 72, 4, 73, 9, 73, 4, 74, 9, 74, 4, 75, 9, 75, 4, 76, 9, 76, 4, 77, 9, 77, 4, 78, 9, 78, 4, 79, 9, 79, 4, 80, 9, 80, 4, 81, 9, 81, 4, 82, 9, 82, 4, 83, 9, 83, 4, 84, 9, 84, 4, 85, 9, 85, 4, 86, 9, 86, 4, 87, 9, 87, 4, 88, 9, 88, 4, 89, 9, 89, 4, 90, 9, 90, 4, 91, 9, 91, 4, 92, 9, 92, 4, 93, 9, 93, 4, 94, 9, 94, 4, 95, 9, 95, 4, 96, 9, 96, 4, 97, 9, 97, 4, 98, 9, 98, 4, 99, 9, 99, 4, 100, 9, 100, 4, 101, 9, 101, 4, 102, 9, 102, 4, 103, 9, 103, 4, 104, 9, 104, 4, 105, 9, 105, 4, 106, 9, 106, 4, 107, 9, 107, 4, 108, 9, 108, 4, 109, 9, 109, 4, 110, 9, 110, 4, 111, 9, 111, 4, 112, 9, 112, 4, 113, 9, 113, 4, 114, 9, 114, 4, 115, 9, 115, 4, 116, 9, 116, 4, 117, 9, 117, 3, 2, 3, 2, 3, 2, 3, 2, 7, 2, 242, 10, 2, 12, 2, 14, 2, 245, 11, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 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, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 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, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 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, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 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, 3, 38, 3, 38, 3, 39, 3, 39, 3, 40, 3, 40, 3, 41, 3, 41, 3, 42, 3, 42, 3, 42, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 46, 3, 46, 3, 47, 3, 47, 3, 48, 3, 48, 3, 48, 3, 49, 3, 49, 3, 49, 3, 50, 3, 50, 3, 50, 3, 51, 3, 51, 3, 52, 3, 52, 3, 53, 3, 53, 3, 53, 3, 54, 3, 54, 3, 54, 3, 55, 3, 55, 3, 55, 3, 56, 3, 56, 3, 56, 3, 57, 3, 57, 3, 57, 3, 58, 3, 58, 3, 58, 3, 59, 3, 59, 3, 59, 3, 60, 3, 60, 3, 61, 3, 61, 3, 61, 3, 62, 3, 62, 3, 63, 3, 63, 3, 63, 3, 64, 3, 64, 3, 65, 3, 65, 3, 66, 3, 66, 3, 67, 3, 67, 3, 68, 3, 68, 3, 68, 3, 69, 3, 69, 3, 69, 3, 70, 3, 70, 3, 70, 3, 70, 3, 71, 3, 71, 3, 72, 3, 72, 3, 72, 7, 72, 514, 10, 72, 12, 72, 14, 72, 517, 11, 72, 3, 73, 3, 73, 3, 73, 3, 73, 5, 73, 523, 10, 73, 3, 74, 3, 74, 5, 74, 527, 10, 74, 3, 74, 3, 74, 3, 75, 3, 75, 5, 75, 533, 10, 75, 3, 75, 3, 75, 3, 76, 3, 76, 3, 77, 6, 77, 540, 10, 77, 13, 77, 14, 77, 541, 3, 77, 3, 77, 3, 78, 3, 78, 3, 78, 3, 78, 3, 79, 3, 79, 3, 79, 3, 79, 3, 79, 3, 79, 3, 79, 3, 80, 3, 80, 3, 80, 3, 80, 3, 80, 3, 80, 3, 80, 3, 81, 3, 81, 3, 81, 3, 81, 3, 81, 3, 81, 3, 82, 3, 82, 3, 82, 3, 82, 3, 82, 3, 83, 3, 83, 3, 84, 3, 84, 3, 84, 3, 84, 3, 84, 3, 84, 3, 85, 3, 85, 3, 85, 3, 85, 3, 85, 3, 86, 3, 86, 3, 87, 3, 87, 3, 88, 3, 88, 3, 89, 3, 89, 3, 90, 6, 90, 597, 10, 90, 13, 90, 14, 90, 598, 3, 91, 3, 91, 3, 91, 6, 91, 604, 10, 91, 13, 91, 14, 91, 605, 3, 92, 3, 92, 3, 92, 6, 92, 611, 10, 92, 13, 92, 14, 92, 612, 3, 93, 3, 93, 3, 93, 6, 93, 618, 10, 93, 13, 93, 14, 93, 619, 3, 94, 3, 94, 3, 95, 3, 95, 3, 96, 3, 96, 3, 97, 3, 97, 3, 98, 3, 98, 5, 98, 632, 10, 98, 3, 98, 3, 98, 3, 98, 5, 98, 637, 10, 98, 3, 99, 5, 99, 640, 10, 99, 3, 99, 3, 99, 3, 99, 3, 99, 3, 99, 5, 99, 647, 10, 99, 3, 100, 3, 100, 5, 100, 651, 10, 100, 3, 100, 3, 100, 3, 101, 6, 101, 656, 10, 101, 13, 101, 14, 101, 657, 3, 102, 3, 102, 3, 103, 6, 103, 663, 10, 103, 13, 103, 14, 103, 664, 3, 104, 3, 104, 5, 104, 669, 10, 104, 3, 105, 3, 105, 3, 105, 5, 105, 674, 10, 105, 3, 106, 3, 106, 3, 106, 3, 107, 3, 107, 3, 107, 5, 107, 682, 10, 107, 3, 107, 5, 107, 685, 10, 107, 3, 108, 3, 108, 3, 108, 3, 108, 6, 108, 691, 10, 108, 13, 108, 14, 108, 692, 3, 109, 6, 109, 696, 10, 109, 13, 109, 14, 109, 697, 3, 110, 3, 110, 5, 110, 702, 10, 110, 3, 111, 6, 111, 705, 10, 111, 13, 111, 14, 111, 706, 3, 112, 3, 112, 5, 112, 711, 10, 112, 3, 113, 6, 113, 714, 10, 113, 13, 113, 14, 113, 715, 3, 114, 3, 114, 5, 114, 720, 10, 114, 3, 115, 6, 115, 723, 10, 115, 13, 115, 14, 115, 724, 3, 116, 3, 116, 5, 116, 729, 10, 116, 3, 117, 7, 117, 732, 10, 117, 12, 117, 14, 117, 735, 11, 117, 3, 243, 2, 2, 118, 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, 41, 81, 2, 42, 83, 2, 43, 85, 2, 44, 87, 2, 45, 89, 2, 46, 91, 2, 47, 93, 2, 48, 95, 2, 49, 97, 2, 50, 99, 2, 51, 101, 2, 52, 103, 2, 53, 105, 2, 54, 107, 2, 55, 109, 2, 56, 111, 2, 57, 113, 2, 58, 115, 2, 59, 117, 2, 60, 119, 2, 61, 121, 2, 62, 123, 2, 63, 125, 2, 64, 127, 2, 65, 129, 2, 66, 131, 2, 67, 133, 2, 68, 135, 2, 69, 137, 2, 70, 139, 2, 71, 141, 2, 72, 143, 2, 73, 145, 2, 74, 147, 2, 75, 149, 2, 76, 151, 2, 77, 153, 2, 78, 155, 2, 79, 157, 2, 80, 159, 2, 81, 161, 2, 82, 163, 2, 2, 165, 2, 83, 167, 2, 84, 169, 2, 2, 171, 2, 85, 173, 2, 86, 175, 2, 2, 177, 2, 2, 179, 2, 2, 181, 2, 2, 183, 2, 2, 185, 2, 2, 187, 2, 2, 189, 2, 2, 191, 2, 2, 193, 2, 2, 195, 2, 2, 197, 2, 2, 199, 2, 2, 201, 2, 2, 203, 2, 2, 205, 2, 2, 207, 2, 2, 209, 2, 2, 211, 2, 2, 213, 2, 2, 215, 2, 2, 217, 2, 2, 219, 2, 2, 221, 2, 2, 223, 2, 2, 225, 2, 2, 227, 2, 2, 229, 2, 2, 231, 2, 2, 233, 2, 2, 235, 2, 2, 5, 2, 3, 4, 20, 6, 2, 11, 11, 13, 14, 34, 34, 162, 162, 5, 2, 12, 12, 15, 15, 8234, 8235, 5, 2, 67, 92, 97, 97, 99, 124, 3, 2, 50, 59, 4, 2, 68, 68, 100, 100, 4, 2, 81, 81, 113, 113, 4, 2, 90, 90, 122, 122, 3, 2, 51, 59, 3, 2, 50, 51, 3, 2, 50, 57, 5, 2, 50, 59, 67, 72, 99, 104, 4, 2, 71, 71, 103, 103, 4, 2, 45, 45, 47, 47, 6, 2, 12, 12, 15, 15, 41, 41, 94, 94, 14, 2, 36, 36, 41, 41, 65, 65, 94, 94, 99, 100, 104, 104, 112, 112, 116, 116, 118, 118, 120, 120, 125, 125, 127, 127, 8, 2, 12, 12, 15, 15, 41, 41, 94, 94, 125, 125, 127, 127, 8, 2, 12, 12, 15, 15, 36, 36, 94, 94, 125, 125, 127, 127, 6, 2, 12, 12, 15, 15, 36, 36, 94, 94, 2, 737, 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, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 2, 85, 3, 2, 2, 2, 2, 87, 3, 2, 2, 2, 2, 89, 3, 2, 2, 2, 2, 91, 3, 2, 2, 2, 2, 93, 3, 2, 2, 2, 2, 95, 3, 2, 2, 2, 2, 97, 3, 2, 2, 2, 2, 99, 3, 2, 2, 2, 2, 101, 3, 2, 2, 2, 2, 103, 3, 2, 2, 2, 2, 105, 3, 2, 2, 2, 2, 107, 3, 2, 2, 2, 2, 109, 3, 2, 2, 2, 2, 111, 3, 2, 2, 2, 2, 113, 3, 2, 2, 2, 2, 115, 3, 2, 2, 2, 2, 117, 3, 2, 2, 2, 2, 119, 3, 2, 2, 2, 2, 121, 3, 2, 2, 2, 2, 123, 3, 2, 2, 2, 2, 125, 3, 2, 2, 2, 2, 127, 3, 2, 2, 2, 2, 129, 3, 2, 2, 2, 2, 131, 3, 2, 2, 2, 2, 133, 3, 2, 2, 2, 2, 135, 3, 2, 2, 2, 2, 137, 3, 2, 2, 2, 2, 139, 3, 2, 2, 2, 2, 141, 3, 2, 2, 2, 2, 143, 3, 2, 2, 2, 2, 145, 3, 2, 2, 2, 2, 147, 3, 2, 2, 2, 2, 149, 3, 2, 2, 2, 2, 151, 3, 2, 2, 2, 2, 153, 3, 2, 2, 2, 2, 155, 3, 2, 2, 2, 2, 157, 3, 2, 2, 2, 2, 159, 3, 2, 2, 2, 2, 161, 3, 2, 2, 2, 3, 163, 3, 2, 2, 2, 3, 165, 3, 2, 2, 2, 3, 167, 3, 2, 2, 2, 4, 169, 3, 2, 2, 2, 4, 171, 3, 2, 2, 2, 4, 173, 3, 2, 2, 2, 5, 237, 3, 2, 2, 2, 7, 251, 3, 2, 2, 2, 9, 258, 3, 2, 2, 2, 11, 270, 3, 2, 2, 2, 13, 276, 3, 2, 2, 2, 15, 280, 3, 2, 2, 2, 17, 283, 3, 2, 2, 2, 19, 287, 3, 2, 2, 2, 21, 294, 3, 2, 2, 2, 23, 299, 3, 2, 2, 2, 25, 307, 3, 2, 2, 2, 27, 313, 3, 2, 2, 2, 29, 322, 3, 2, 2, 2, 31, 325, 3, 2, 2, 2, 33, 331, 3, 2, 2, 2, 35, 334, 3, 2, 2, 2, 37, 339, 3, 2, 2, 2, 39, 343, 3, 2, 2, 2, 41, 348, 3, 2, 2, 2, 43, 352, 3, 2, 2, 2, 45, 359, 3, 2, 2, 2, 47, 364, 3, 2, 2, 2, 49, 367, 3, 2, 2, 2, 51, 372, 3, 2, 2, 2, 53, 378, 3, 2, 2, 2, 55, 385, 3, 2, 2, 2, 57, 390, 3, 2, 2, 2, 59, 395, 3, 2, 2, 2, 61, 405, 3, 2, 2, 2, 63, 407, 3, 2, 2, 2, 65, 409, 3, 2, 2, 2, 67, 411, 3, 2, 2, 2, 69, 413, 3, 2, 2, 2, 71, 415, 3, 2, 2, 2, 73, 417, 3, 2, 2, 2, 75, 419, 3, 2, 2, 2, 77, 421, 3, 2, 2, 2, 79, 426, 3, 2, 2, 2, 81, 428, 3, 2, 2, 2, 83, 430, 3, 2, 2, 2, 85, 432, 3, 2, 2, 2, 87, 435, 3, 2, 2, 2, 89, 437, 3, 2, 2, 2, 91, 440, 3, 2, 2, 2, 93, 442, 3, 2, 2, 2, 95, 444, 3, 2, 2, 2, 97, 446, 3, 2, 2, 2, 99, 449, 3, 2, 2, 2, 101, 452, 3, 2, 2, 2, 103, 455, 3, 2, 2, 2, 105, 457, 3, 2, 2, 2, 107, 459, 3, 2, 2, 2, 109, 462, 3, 2, 2, 2, 111, 465, 3, 2, 2, 2, 113, 468, 3, 2, 2, 2, 115, 471, 3, 2, 2, 2, 117, 474, 3, 2, 2, 2, 119, 477, 3, 2, 2, 2, 121, 480, 3, 2, 2, 2, 123, 482, 3, 2, 2, 2, 125, 485, 3, 2, 2, 2, 127, 487, 3, 2, 2, 2, 129, 490, 3, 2, 2, 2, 131, 492, 3, 2, 2, 2, 133, 494, 3, 2, 2, 2, 135, 496, 3, 2, 2, 2, 137, 498, 3, 2, 2, 2, 139, 501, 3, 2, 2, 2, 141, 504, 3, 2, 2, 2, 143, 508, 3, 2, 2, 2, 145, 510, 3, 2, 2, 2, 147, 522, 3, 2, 2, 2, 149, 524, 3, 2, 2, 2, 151, 530, 3, 2, 2, 2, 153, 536, 3, 2, 2, 2, 155, 539, 3, 2, 2, 2, 157, 545, 3, 2, 2, 2, 159, 549, 3, 2, 2, 2, 161, 556, 3, 2, 2, 2, 163, 563, 3, 2, 2, 2, 165, 569, 3, 2, 2, 2, 167, 574, 3, 2, 2, 2, 169, 576, 3, 2, 2, 2, 171, 582, 3, 2, 2, 2, 173, 587, 3, 2, 2, 2, 175, 589, 3, 2, 2, 2, 177, 591, 3, 2, 2, 2, 179, 593, 3, 2, 2, 2, 181, 596, 3, 2, 2, 2, 183, 600, 3, 2, 2, 2, 185, 607, 3, 2, 2, 2, 187, 614, 3, 2, 2, 2, 189, 621, 3, 2, 2, 2, 191, 623, 3, 2, 2, 2, 193, 625, 3, 2, 2, 2, 195, 627, 3, 2, 2, 2, 197, 636, 3, 2, 2, 2, 199, 646, 3, 2, 2, 2, 201, 648, 3, 2, 2, 2, 203, 655, 3, 2, 2, 2, 205, 659, 3, 2, 2, 2, 207, 662, 3, 2, 2, 2, 209, 668, 3, 2, 2, 2, 211, 673, 3, 2, 2, 2, 213, 675, 3, 2, 2, 2, 215, 678, 3, 2, 2, 2, 217, 686, 3, 2, 2, 2, 219, 695, 3, 2, 2, 2, 221, 701, 3, 2, 2, 2, 223, 704, 3, 2, 2, 2, 225, 710, 3, 2, 2, 2, 227, 713, 3, 2, 2, 2, 229, 719, 3, 2, 2, 2, 231, 722, 3, 2, 2, 2, 233, 728, 3, 2, 2, 2, 235, 733, 3, 2, 2, 2, 237, 238, 7, 49, 2, 2, 238, 239, 7, 44, 2, 2, 239, 243, 3, 2, 2, 2, 240, 242, 11, 2, 2, 2, 241, 240, 3, 2, 2, 2, 242, 245, 3, 2, 2, 2, 243, 244, 3, 2, 2, 2, 243, 241, 3, 2, 2, 2, 244, 246, 3, 2, 2, 2, 245, 243, 3, 2, 2, 2, 246, 247, 7, 44, 2, 2, 247, 248, 7, 49, 2, 2, 248, 249, 3, 2, 2, 2, 249, 250, 8, 2, 2, 2, 250, 6, 3, 2, 2, 2, 251, 252, 7, 49, 2, 2, 252, 253, 7, 49, 2, 2, 253, 254, 3, 2, 2, 2, 254, 255, 5, 235, 117, 2, 255, 256, 3, 2, 2, 2, 256, 257, 8, 3, 2, 2, 257, 8, 3, 2, 2, 2, 258, 259, 7, 37, 2, 2, 259, 260, 7, 114, 2, 2, 260, 261, 7, 116, 2, 2, 261, 262, 7, 99, 2, 2, 262, 263, 7, 105, 2, 2, 263, 264, 7, 111, 2, 2, 264, 265, 7, 99, 2, 2, 265, 266, 3, 2, 2, 2, 266, 267, 5, 235, 117, 2, 267, 268, 3, 2, 2, 2, 268, 269, 8, 4, 3, 2, 269, 10, 3, 2, 2, 2, 270, 271, 7, 101, 2, 2, 271, 272, 7, 113, 2, 2, 272, 273, 7, 112, 2, 2, 273, 274, 7, 117, 2, 2, 274, 275, 7, 118, 2, 2, 275, 12, 3, 2, 2, 2, 276, 277, 7, 120, 2, 2, 277, 278, 7, 99, 2, 2, 278, 279, 7, 116, 2, 2, 279, 14, 3, 2, 2, 2, 280, 281, 7, 99, 2, 2, 281, 282, 7, 117, 2, 2, 282, 16, 3, 2, 2, 2, 283, 284, 7, 48, 2, 2, 284, 285, 7, 48, 2, 2, 285, 286, 7, 48, 2, 2, 286, 18, 3, 2, 2, 2, 287, 288, 7, 117, 2, 2, 288, 289, 7, 121, 2, 2, 289, 290, 7, 107, 2, 2, 290, 291, 7, 118, 2, 2, 291, 292, 7, 101, 2, 2, 292, 293, 7, 106, 2, 2, 293, 20, 3, 2, 2, 2, 294, 295, 7, 101, 2, 2, 295, 296, 7, 99, 2, 2, 296, 297, 7, 117, 2, 2, 297, 298, 7, 103, 2, 2, 298, 22, 3, 2, 2, 2, 299, 300, 7, 102, 2, 2, 300, 301, 7, 103, 2, 2, 301, 302, 7, 104, 2, 2, 302, 303, 7, 99, 2, 2, 303, 304, 7, 119, 2, 2, 304, 305, 7, 110, 2, 2, 305, 306, 7, 118, 2, 2, 306, 24, 3, 2, 2, 2, 307, 308, 7, 100, 2, 2, 308, 309, 7, 116, 2, 2, 309, 310, 7, 103, 2, 2, 310, 311, 7, 99, 2, 2, 311, 312, 7, 109, 2, 2, 312, 26, 3, 2, 2, 2, 313, 314, 7, 101, 2, 2, 314, 315, 7, 113, 2, 2, 315, 316, 7, 112, 2, 2, 316, 317, 7, 118, 2, 2, 317, 318, 7, 107, 2, 2, 318, 319, 7, 112, 2, 2, 319, 320, 7, 119, 2, 2, 320, 321, 7, 103, 2, 2, 321, 28, 3, 2, 2, 2, 322, 323, 7, 102, 2, 2, 323, 324, 7, 113, 2, 2, 324, 30, 3, 2, 2, 2, 325, 326, 7, 121, 2, 2, 326, 327, 7, 106, 2, 2, 327, 328, 7, 107, 2, 2, 328, 329, 7, 110, 2, 2, 329, 330, 7, 103, 2, 2, 330, 32, 3, 2, 2, 2, 331, 332, 7, 107, 2, 2, 332, 333, 7, 104, 2, 2, 333, 34, 3, 2, 2, 2, 334, 335, 7, 103, 2, 2, 335, 336, 7, 110, 2, 2, 336, 337, 7, 117, 2, 2, 337, 338, 7, 103, 2, 2, 338, 36, 3, 2, 2, 2, 339, 340, 7, 104, 2, 2, 340, 341, 7, 113, 2, 2, 341, 342, 7, 116, 2, 2, 342, 38, 3, 2, 2, 2, 343, 344, 7, 103, 2, 2, 344, 345, 7, 112, 2, 2, 345, 346, 7, 119, 2, 2, 346, 347, 7, 111, 2, 2, 347, 40, 3, 2, 2, 2, 348, 349, 7, 102, 2, 2, 349, 350, 7, 103, 2, 2, 350, 351, 7, 104, 2, 2, 351, 42, 3, 2, 2, 2, 352, 353, 7, 116, 2, 2, 353, 354, 7, 103, 2, 2, 354, 355, 7, 118, 2, 2, 355, 356, 7, 119, 2, 2, 356, 357, 7, 116, 2, 2, 357, 358, 7, 112, 2, 2, 358, 44, 3, 2, 2, 2, 359, 360, 7, 101, 2, 2, 360, 361, 7, 99, 2, 2, 361, 362, 7, 110, 2, 2, 362, 363, 7, 110, 2, 2, 363, 46, 3, 2, 2, 2, 364, 365, 7, 47, 2, 2, 365, 366, 7, 64, 2, 2, 366, 48, 3, 2, 2, 2, 367, 368, 7, 118, 2, 2, 368, 369, 7, 116, 2, 2, 369, 370, 7, 119, 2, 2, 370, 371, 7, 103, 2, 2, 371, 50, 3, 2, 2, 2, 372, 373, 7, 104, 2, 2, 373, 374, 7, 99, 2, 2, 374, 375, 7, 110, 2, 2, 375, 376, 7, 117, 2, 2, 376, 377, 7, 103, 2, 2, 377, 52, 3, 2, 2, 2, 378, 379, 7, 118, 2, 2, 379, 380, 7, 123, 2, 2, 380, 381, 7, 114, 2, 2, 381, 382, 7, 103, 2, 2, 382, 383, 7, 113, 2, 2, 383, 384, 7, 104, 2, 2, 384, 54, 3, 2, 2, 2, 385, 386, 7, 120, 2, 2, 386, 387, 7, 113, 2, 2, 387, 388, 7, 107, 2, 2, 388, 389, 7, 102, 2, 2, 389, 56, 3, 2, 2, 2, 390, 391, 7, 112, 2, 2, 391, 392, 7, 119, 2, 2, 392, 393, 7, 110, 2, 2, 393, 394, 7, 110, 2, 2, 394, 58, 3, 2, 2, 2, 395, 396, 7, 119, 2, 2, 396, 397, 7, 112, 2, 2, 397, 398, 7, 102, 2, 2, 398, 399, 7, 103, 2, 2, 399, 400, 7, 104, 2, 2, 400, 401, 7, 107, 2, 2, 401, 402, 7, 112, 2, 2, 402, 403, 7, 103, 2, 2, 403, 404, 7, 102, 2, 2, 404, 60, 3, 2, 2, 2, 405, 406, 7, 46, 2, 2, 406, 62, 3, 2, 2, 2, 407, 408, 7, 61, 2, 2, 408, 64, 3, 2, 2, 2, 409, 410, 7, 65, 2, 2, 410, 66, 3, 2, 2, 2, 411, 412, 7, 60, 2, 2, 412, 68, 3, 2, 2, 2, 413, 414, 7, 42, 2, 2, 414, 70, 3, 2, 2, 2, 415, 416, 7, 43, 2, 2, 416, 72, 3, 2, 2, 2, 417, 418, 7, 93, 2, 2, 418, 74, 3, 2, 2, 2, 419, 420, 7, 95, 2, 2, 420, 76, 3, 2, 2, 2, 421, 422, 6, 38, 2, 2, 422, 423, 7, 127, 2, 2, 423, 424, 3, 2, 2, 2, 424, 425, 8, 38, 4, 2, 425, 78, 3, 2, 2, 2, 426, 427, 7, 125, 2, 2, 427, 80, 3, 2, 2, 2, 428, 429, 7, 127, 2, 2, 429, 82, 3, 2, 2, 2, 430, 431, 7, 45, 2, 2, 431, 84, 3, 2, 2, 2, 432, 433, 7, 45, 2, 2, 433, 434, 7, 45, 2, 2, 434, 86, 3, 2, 2, 2, 435, 436, 7, 47, 2, 2, 436, 88, 3, 2, 2, 2, 437, 438, 7, 47, 2, 2, 438, 439, 7, 47, 2, 2, 439, 90, 3, 2, 2, 2, 440, 441, 7, 44, 2, 2, 441, 92, 3, 2, 2, 2, 442, 443, 7, 49, 2, 2, 443, 94, 3, 2, 2, 2, 444, 445, 7, 39, 2, 2, 445, 96, 3, 2, 2, 2, 446, 447, 7, 44, 2, 2, 447, 448, 7, 44, 2, 2, 448, 98, 3, 2, 2, 2, 449, 450, 7, 40, 2, 2, 450, 451, 7, 40, 2, 2, 451, 100, 3, 2, 2, 2, 452, 453, 7, 126, 2, 2, 453, 454, 7, 126, 2, 2, 454, 102, 3, 2, 2, 2, 455, 456, 7, 35, 2, 2, 456, 104, 3, 2, 2, 2, 457, 458, 7, 63, 2, 2, 458, 106, 3, 2, 2, 2, 459, 460, 7, 45, 2, 2, 460, 461, 7, 63, 2, 2, 461, 108, 3, 2, 2, 2, 462, 463, 7, 47, 2, 2, 463, 464, 7, 63, 2, 2, 464, 110, 3, 2, 2, 2, 465, 466, 7, 44, 2, 2, 466, 467, 7, 63, 2, 2, 467, 112, 3, 2, 2, 2, 468, 469, 7, 49, 2, 2, 469, 470, 7, 63, 2, 2, 470, 114, 3, 2, 2, 2, 471, 472, 7, 39, 2, 2, 472, 473, 7, 63, 2, 2, 473, 116, 3, 2, 2, 2, 474, 475, 7, 63, 2, 2, 475, 476, 7, 63, 2, 2, 476, 118, 3, 2, 2, 2, 477, 478, 7, 35, 2, 2, 478, 479, 7, 63, 2, 2, 479, 120, 3, 2, 2, 2, 480, 481, 7, 62, 2, 2, 481, 122, 3, 2, 2, 2, 482, 483, 7, 62, 2, 2, 483, 484, 7, 63, 2, 2, 484, 124, 3, 2, 2, 2, 485, 486, 7, 64, 2, 2, 486, 126, 3, 2, 2, 2, 487, 488, 7, 64, 2, 2, 488, 489, 7, 63, 2, 2, 489, 128, 3, 2, 2, 2, 490, 491, 7, 40, 2, 2, 491, 130, 3, 2, 2, 2, 492, 493, 7, 126, 2, 2, 493, 132, 3, 2, 2, 2, 494, 495, 7, 96, 2, 2, 495, 134, 3, 2, 2, 2, 496, 497, 7, 128, 2, 2, 497, 136, 3, 2, 2, 2, 498, 499, 7, 62, 2, 2, 499, 500, 7, 62, 2, 2, 500, 138, 3, 2, 2, 2, 501, 502, 7, 64, 2, 2, 502, 503, 7, 64, 2, 2, 503, 140, 3, 2, 2, 2, 504, 505, 7, 64, 2, 2, 505, 506, 7, 64, 2, 2, 506, 507, 7, 64, 2, 2, 507, 142, 3, 2, 2, 2, 508, 509, 7, 48, 2, 2, 509, 144, 3, 2, 2, 2, 510, 515, 5, 175, 87, 2, 511, 514, 5, 175, 87, 2, 512, 514, 5, 179, 89, 2, 513, 511, 3, 2, 2, 2, 513, 512, 3, 2, 2, 2, 514, 517, 3, 2, 2, 2, 515, 513, 3, 2, 2, 2, 515, 516, 3, 2, 2, 2, 516, 146, 3, 2, 2, 2, 517, 515, 3, 2, 2, 2, 518, 523, 5, 181, 90, 2, 519, 523, 5, 185, 92, 2, 520, 523, 5, 187, 93, 2, 521, 523, 5, 183, 91, 2, 522, 518, 3, 2, 2, 2, 522, 519, 3, 2, 2, 2, 522, 520, 3, 2, 2, 2, 522, 521, 3, 2, 2, 2, 523, 148, 3, 2, 2, 2, 524, 526, 7, 41, 2, 2, 525, 527, 5, 227, 113, 2, 526, 525, 3, 2, 2, 2, 526, 527, 3, 2, 2, 2, 527, 528, 3, 2, 2, 2, 528, 529, 7, 41, 2, 2, 529, 150, 3, 2, 2, 2, 530, 532, 7, 36, 2, 2, 531, 533, 5, 231, 115, 2, 532, 531, 3, 2, 2, 2, 532, 533, 3, 2, 2, 2, 533, 534, 3, 2, 2, 2, 534, 535, 7, 36, 2, 2, 535, 152, 3, 2, 2, 2, 536, 537, 5, 197, 98, 2, 537, 154, 3, 2, 2, 2, 538, 540, 9, 2, 2, 2, 539, 538, 3, 2, 2, 2, 540, 541, 3, 2, 2, 2, 541, 539, 3, 2, 2, 2, 541, 542, 3, 2, 2, 2, 542, 543, 3, 2, 2, 2, 543, 544, 8, 77, 5, 2, 544, 156, 3, 2, 2, 2, 545, 546, 9, 3, 2, 2, 546, 547, 3, 2, 2, 2, 547, 548, 8, 78, 5, 2, 548, 158, 3, 2, 2, 2, 549, 550, 7, 104, 2, 2, 550, 551, 7, 41, 2, 2, 551, 552, 3, 2, 2, 2, 552, 553, 8, 79, 6, 2, 553, 554, 3, 2, 2, 2, 554, 555, 8, 79, 7, 2, 555, 160, 3, 2, 2, 2, 556, 557, 7, 104, 2, 2, 557, 558, 7, 36, 2, 2, 558, 559, 3, 2, 2, 2, 559, 560, 8, 80, 8, 2, 560, 561, 3, 2, 2, 2, 561, 562, 8, 80, 9, 2, 562, 162, 3, 2, 2, 2, 563, 564, 6, 81, 3, 2, 564, 565, 7, 125, 2, 2, 565, 566, 3, 2, 2, 2, 566, 567, 8, 81, 10, 2, 567, 568, 8, 81, 11, 2, 568, 164, 3, 2, 2, 2, 569, 570, 7, 41, 2, 2, 570, 571, 8, 82, 12, 2, 571, 572, 3, 2, 2, 2, 572, 573, 8, 82, 4, 2, 573, 166, 3, 2, 2, 2, 574, 575, 5, 219, 109, 2, 575, 168, 3, 2, 2, 2, 576, 577, 6, 84, 4, 2, 577, 578, 7, 125, 2, 2, 578, 579, 3, 2, 2, 2, 579, 580, 8, 84, 10, 2, 580, 581, 8, 84, 11, 2, 581, 170, 3, 2, 2, 2, 582, 583, 7, 36, 2, 2, 583, 584, 8, 85, 13, 2, 584, 585, 3, 2, 2, 2, 585, 586, 8, 85, 4, 2, 586, 172, 3, 2, 2, 2, 587, 588, 5, 223, 111, 2, 588, 174, 3, 2, 2, 2, 589, 590, 5, 177, 88, 2, 590, 176, 3, 2, 2, 2, 591, 592, 9, 4, 2, 2, 592, 178, 3, 2, 2, 2, 593, 594, 9, 5, 2, 2, 594, 180, 3, 2, 2, 2, 595, 597, 5, 179, 89, 2, 596, 595, 3, 2, 2, 2, 597, 598, 3, 2, 2, 2, 598, 596, 3, 2, 2, 2, 598, 599, 3, 2, 2, 2, 599, 182, 3, 2, 2, 2, 600, 601, 7, 50, 2, 2, 601, 603, 9, 6, 2, 2, 602, 604, 5, 191, 95, 2, 603, 602, 3, 2, 2, 2, 604, 605, 3, 2, 2, 2, 605, 603, 3, 2, 2, 2, 605, 606, 3, 2, 2, 2, 606, 184, 3, 2, 2, 2, 607, 608, 7, 50, 2, 2, 608, 610, 9, 7, 2, 2, 609, 611, 5, 193, 96, 2, 610, 609, 3, 2, 2, 2, 611, 612, 3, 2, 2, 2, 612, 610, 3, 2, 2, 2, 612, 613, 3, 2, 2, 2, 613, 186, 3, 2, 2, 2, 614, 615, 7, 50, 2, 2, 615, 617, 9, 8, 2, 2, 616, 618, 5, 195, 97, 2, 617, 616, 3, 2, 2, 2, 618, 619, 3, 2, 2, 2, 619, 617, 3, 2, 2, 2, 619, 620, 3, 2, 2, 2, 620, 188, 3, 2, 2, 2, 621, 622, 9, 9, 2, 2, 622, 190, 3, 2, 2, 2, 623, 624, 9, 10, 2, 2, 624, 192, 3, 2, 2, 2, 625, 626, 9, 11, 2, 2, 626, 194, 3, 2, 2, 2, 627, 628, 9, 12, 2, 2, 628, 196, 3, 2, 2, 2, 629, 631, 5, 199, 99, 2, 630, 632, 5, 201, 100, 2, 631, 630, 3, 2, 2, 2, 631, 632, 3, 2, 2, 2, 632, 637, 3, 2, 2, 2, 633, 634, 5, 203, 101, 2, 634, 635, 5, 201, 100, 2, 635, 637, 3, 2, 2, 2, 636, 629, 3, 2, 2, 2, 636, 633, 3, 2, 2, 2, 637, 198, 3, 2, 2, 2, 638, 640, 5, 203, 101, 2, 639, 638, 3, 2, 2, 2, 639, 640, 3, 2, 2, 2, 640, 641, 3, 2, 2, 2, 641, 642, 7, 48, 2, 2, 642, 647, 5, 203, 101, 2, 643, 644, 5, 203, 101, 2, 644, 645, 7, 48, 2, 2, 645, 647, 3, 2, 2, 2, 646, 639, 3, 2, 2, 2, 646, 643, 3, 2, 2, 2, 647, 200, 3, 2, 2, 2, 648, 650, 9, 13, 2, 2, 649, 651, 5, 205, 102, 2, 650, 649, 3, 2, 2, 2, 650, 651, 3, 2, 2, 2, 651, 652, 3, 2, 2, 2, 652, 653, 5, 203, 101, 2, 653, 202, 3, 2, 2, 2, 654, 656, 5, 179, 89, 2, 655, 654, 3, 2, 2, 2, 656, 657, 3, 2, 2, 2, 657, 655, 3, 2, 2, 2, 657, 658, 3, 2, 2, 2, 658, 204, 3, 2, 2, 2, 659, 660, 9, 14, 2, 2, 660, 206, 3, 2, 2, 2, 661, 663, 5, 209, 104, 2, 662, 661, 3, 2, 2, 2, 663, 664, 3, 2, 2, 2, 664, 662, 3, 2, 2, 2, 664, 665, 3, 2, 2, 2, 665, 208, 3, 2, 2, 2, 666, 669, 10, 15, 2, 2, 667, 669, 5, 211, 105, 2, 668, 666, 3, 2, 2, 2, 668, 667, 3, 2, 2, 2, 669, 210, 3, 2, 2, 2, 670, 674, 5, 213, 106, 2, 671, 674, 5, 215, 107, 2, 672, 674, 5, 217, 108, 2, 673, 670, 3, 2, 2, 2, 673, 671, 3, 2, 2, 2, 673, 672, 3, 2, 2, 2, 674, 212, 3, 2, 2, 2, 675, 676, 7, 94, 2, 2, 676, 677, 9, 16, 2, 2, 677, 214, 3, 2, 2, 2, 678, 679, 7, 94, 2, 2, 679, 681, 5, 193, 96, 2, 680, 682, 5, 193, 96, 2, 681, 680, 3, 2, 2, 2, 681, 682, 3, 2, 2, 2, 682, 684, 3, 2, 2, 2, 683, 685, 5, 193, 96, 2, 684, 683, 3, 2, 2, 2, 684, 685, 3, 2, 2, 2, 685, 216, 3, 2, 2, 2, 686, 687, 7, 94, 2, 2, 687, 688, 7, 122, 2, 2, 688, 690, 3, 2, 2, 2, 689, 691, 5, 195, 97, 2, 690, 689, 3, 2, 2, 2, 691, 692, 3, 2, 2, 2, 692, 690, 3, 2, 2, 2, 692, 693, 3, 2, 2, 2, 693, 218, 3, 2, 2, 2, 694, 696, 5, 221, 110, 2, 695, 694, 3, 2, 2, 2, 696, 697, 3, 2, 2, 2, 697, 695, 3, 2, 2, 2, 697, 698, 3, 2, 2, 2, 698, 220, 3, 2, 2, 2, 699, 702, 10, 17, 2, 2, 700, 702, 5, 211, 105, 2, 701, 699, 3, 2, 2, 2, 701, 700, 3, 2, 2, 2, 702, 222, 3, 2, 2, 2, 703, 705, 5, 225, 112, 2, 704, 703, 3, 2, 2, 2, 705, 706, 3, 2, 2, 2, 706, 704, 3, 2, 2, 2, 706, 707, 3, 2, 2, 2, 707, 224, 3, 2, 2, 2, 708, 711, 10, 18, 2, 2, 709, 711, 5, 211, 105, 2, 710, 708, 3, 2, 2, 2, 710, 709, 3, 2, 2, 2, 711, 226, 3, 2, 2, 2, 712, 714, 5, 229, 114, 2, 713, 712, 3, 2, 2, 2, 714, 715, 3, 2, 2, 2, 715, 713, 3, 2, 2, 2, 715, 716, 3, 2, 2, 2, 716, 228, 3, 2, 2, 2, 717, 720, 10, 15, 2, 2, 718, 720, 5, 211, 105, 2, 719, 717, 3, 2, 2, 2, 719, 718, 3, 2, 2, 2, 720, 230, 3, 2, 2, 2, 721, 723, 5, 233, 116, 2, 722, 721, 3, 2, 2, 2, 723, 724, 3, 2, 2, 2, 724, 722, 3, 2, 2, 2, 724, 725, 3, 2, 2, 2, 725, 232, 3, 2, 2, 2, 726, 729, 10, 19, 2, 2, 727, 729, 5, 211, 105, 2, 728, 726, 3, 2, 2, 2, 728, 727, 3, 2, 2, 2, 729, 234, 3, 2, 2, 2, 730, 732, 10, 3, 2, 2, 731, 730, 3, 2, 2, 2, 732, 735, 3, 2, 2, 2, 733, 731, 3, 2, 2, 2, 733, 734, 3, 2, 2, 2, 734, 236, 3, 2, 2, 2, 735, 733, 3, 2, 2, 2, 37, 2, 3, 4, 243, 513, 515, 522, 526, 532, 541, 598, 605, 612, 619, 631, 636, 639, 646, 650, 657, 664, 668, 673, 681, 684, 692, 697, 701, 706, 710, 715, 719, 724, 728, 733, 14, 2, 4, 2, 2, 5, 2, 6, 2, 2, 2, 3, 2, 3, 79, 2, 7, 3, 2, 3, 80, 3, 7, 4, 2, 9, 3, 2, 7, 2, 2, 3, 82, 4, 3, 85, 5] \ No newline at end of file +[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 2, 88, 756, 8, 1, 8, 1, 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, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 4, 68, 9, 68, 4, 69, 9, 69, 4, 70, 9, 70, 4, 71, 9, 71, 4, 72, 9, 72, 4, 73, 9, 73, 4, 74, 9, 74, 4, 75, 9, 75, 4, 76, 9, 76, 4, 77, 9, 77, 4, 78, 9, 78, 4, 79, 9, 79, 4, 80, 9, 80, 4, 81, 9, 81, 4, 82, 9, 82, 4, 83, 9, 83, 4, 84, 9, 84, 4, 85, 9, 85, 4, 86, 9, 86, 4, 87, 9, 87, 4, 88, 9, 88, 4, 89, 9, 89, 4, 90, 9, 90, 4, 91, 9, 91, 4, 92, 9, 92, 4, 93, 9, 93, 4, 94, 9, 94, 4, 95, 9, 95, 4, 96, 9, 96, 4, 97, 9, 97, 4, 98, 9, 98, 4, 99, 9, 99, 4, 100, 9, 100, 4, 101, 9, 101, 4, 102, 9, 102, 4, 103, 9, 103, 4, 104, 9, 104, 4, 105, 9, 105, 4, 106, 9, 106, 4, 107, 9, 107, 4, 108, 9, 108, 4, 109, 9, 109, 4, 110, 9, 110, 4, 111, 9, 111, 4, 112, 9, 112, 4, 113, 9, 113, 4, 114, 9, 114, 4, 115, 9, 115, 4, 116, 9, 116, 4, 117, 9, 117, 4, 118, 9, 118, 4, 119, 9, 119, 3, 2, 3, 2, 3, 2, 3, 2, 7, 2, 246, 10, 2, 12, 2, 14, 2, 249, 11, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 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, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 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, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 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, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 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, 39, 3, 39, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 41, 3, 41, 3, 42, 3, 42, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 46, 3, 46, 3, 46, 3, 47, 3, 47, 3, 48, 3, 48, 3, 49, 3, 49, 3, 50, 3, 50, 3, 50, 3, 51, 3, 51, 3, 51, 3, 52, 3, 52, 3, 52, 3, 53, 3, 53, 3, 54, 3, 54, 3, 55, 3, 55, 3, 55, 3, 56, 3, 56, 3, 56, 3, 57, 3, 57, 3, 57, 3, 58, 3, 58, 3, 58, 3, 59, 3, 59, 3, 59, 3, 60, 3, 60, 3, 60, 3, 61, 3, 61, 3, 61, 3, 62, 3, 62, 3, 63, 3, 63, 3, 63, 3, 64, 3, 64, 3, 65, 3, 65, 3, 65, 3, 66, 3, 66, 3, 67, 3, 67, 3, 68, 3, 68, 3, 69, 3, 69, 3, 70, 3, 70, 3, 70, 3, 71, 3, 71, 3, 71, 3, 72, 3, 72, 3, 72, 3, 72, 3, 73, 3, 73, 3, 74, 3, 74, 3, 74, 7, 74, 534, 10, 74, 12, 74, 14, 74, 537, 11, 74, 3, 75, 3, 75, 3, 75, 3, 75, 5, 75, 543, 10, 75, 3, 76, 3, 76, 5, 76, 547, 10, 76, 3, 76, 3, 76, 3, 77, 3, 77, 5, 77, 553, 10, 77, 3, 77, 3, 77, 3, 78, 3, 78, 3, 79, 6, 79, 560, 10, 79, 13, 79, 14, 79, 561, 3, 79, 3, 79, 3, 80, 3, 80, 3, 80, 3, 80, 3, 81, 3, 81, 3, 81, 3, 81, 3, 81, 3, 81, 3, 81, 3, 82, 3, 82, 3, 82, 3, 82, 3, 82, 3, 82, 3, 82, 3, 83, 3, 83, 3, 83, 3, 83, 3, 83, 3, 83, 3, 84, 3, 84, 3, 84, 3, 84, 3, 84, 3, 85, 3, 85, 3, 86, 3, 86, 3, 86, 3, 86, 3, 86, 3, 86, 3, 87, 3, 87, 3, 87, 3, 87, 3, 87, 3, 88, 3, 88, 3, 89, 3, 89, 3, 90, 3, 90, 3, 91, 3, 91, 3, 92, 6, 92, 617, 10, 92, 13, 92, 14, 92, 618, 3, 93, 3, 93, 3, 93, 6, 93, 624, 10, 93, 13, 93, 14, 93, 625, 3, 94, 3, 94, 3, 94, 6, 94, 631, 10, 94, 13, 94, 14, 94, 632, 3, 95, 3, 95, 3, 95, 6, 95, 638, 10, 95, 13, 95, 14, 95, 639, 3, 96, 3, 96, 3, 97, 3, 97, 3, 98, 3, 98, 3, 99, 3, 99, 3, 100, 3, 100, 5, 100, 652, 10, 100, 3, 100, 3, 100, 3, 100, 5, 100, 657, 10, 100, 3, 101, 5, 101, 660, 10, 101, 3, 101, 3, 101, 3, 101, 3, 101, 3, 101, 5, 101, 667, 10, 101, 3, 102, 3, 102, 5, 102, 671, 10, 102, 3, 102, 3, 102, 3, 103, 6, 103, 676, 10, 103, 13, 103, 14, 103, 677, 3, 104, 3, 104, 3, 105, 6, 105, 683, 10, 105, 13, 105, 14, 105, 684, 3, 106, 3, 106, 5, 106, 689, 10, 106, 3, 107, 3, 107, 3, 107, 5, 107, 694, 10, 107, 3, 108, 3, 108, 3, 108, 3, 109, 3, 109, 3, 109, 5, 109, 702, 10, 109, 3, 109, 5, 109, 705, 10, 109, 3, 110, 3, 110, 3, 110, 3, 110, 6, 110, 711, 10, 110, 13, 110, 14, 110, 712, 3, 111, 6, 111, 716, 10, 111, 13, 111, 14, 111, 717, 3, 112, 3, 112, 5, 112, 722, 10, 112, 3, 113, 6, 113, 725, 10, 113, 13, 113, 14, 113, 726, 3, 114, 3, 114, 5, 114, 731, 10, 114, 3, 115, 6, 115, 734, 10, 115, 13, 115, 14, 115, 735, 3, 116, 3, 116, 5, 116, 740, 10, 116, 3, 117, 6, 117, 743, 10, 117, 13, 117, 14, 117, 744, 3, 118, 3, 118, 5, 118, 749, 10, 118, 3, 119, 7, 119, 752, 10, 119, 12, 119, 14, 119, 755, 11, 119, 3, 247, 2, 2, 120, 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, 41, 81, 2, 42, 83, 2, 43, 85, 2, 44, 87, 2, 45, 89, 2, 46, 91, 2, 47, 93, 2, 48, 95, 2, 49, 97, 2, 50, 99, 2, 51, 101, 2, 52, 103, 2, 53, 105, 2, 54, 107, 2, 55, 109, 2, 56, 111, 2, 57, 113, 2, 58, 115, 2, 59, 117, 2, 60, 119, 2, 61, 121, 2, 62, 123, 2, 63, 125, 2, 64, 127, 2, 65, 129, 2, 66, 131, 2, 67, 133, 2, 68, 135, 2, 69, 137, 2, 70, 139, 2, 71, 141, 2, 72, 143, 2, 73, 145, 2, 74, 147, 2, 75, 149, 2, 76, 151, 2, 77, 153, 2, 78, 155, 2, 79, 157, 2, 80, 159, 2, 81, 161, 2, 82, 163, 2, 83, 165, 2, 84, 167, 2, 2, 169, 2, 85, 171, 2, 86, 173, 2, 2, 175, 2, 87, 177, 2, 88, 179, 2, 2, 181, 2, 2, 183, 2, 2, 185, 2, 2, 187, 2, 2, 189, 2, 2, 191, 2, 2, 193, 2, 2, 195, 2, 2, 197, 2, 2, 199, 2, 2, 201, 2, 2, 203, 2, 2, 205, 2, 2, 207, 2, 2, 209, 2, 2, 211, 2, 2, 213, 2, 2, 215, 2, 2, 217, 2, 2, 219, 2, 2, 221, 2, 2, 223, 2, 2, 225, 2, 2, 227, 2, 2, 229, 2, 2, 231, 2, 2, 233, 2, 2, 235, 2, 2, 237, 2, 2, 239, 2, 2, 5, 2, 3, 4, 20, 6, 2, 11, 11, 13, 14, 34, 34, 162, 162, 5, 2, 12, 12, 15, 15, 8234, 8235, 5, 2, 67, 92, 97, 97, 99, 124, 3, 2, 50, 59, 4, 2, 68, 68, 100, 100, 4, 2, 81, 81, 113, 113, 4, 2, 90, 90, 122, 122, 3, 2, 51, 59, 3, 2, 50, 51, 3, 2, 50, 57, 5, 2, 50, 59, 67, 72, 99, 104, 4, 2, 71, 71, 103, 103, 4, 2, 45, 45, 47, 47, 6, 2, 12, 12, 15, 15, 41, 41, 94, 94, 14, 2, 36, 36, 41, 41, 65, 65, 94, 94, 99, 100, 104, 104, 112, 112, 116, 116, 118, 118, 120, 120, 125, 125, 127, 127, 8, 2, 12, 12, 15, 15, 41, 41, 94, 94, 125, 125, 127, 127, 8, 2, 12, 12, 15, 15, 36, 36, 94, 94, 125, 125, 127, 127, 6, 2, 12, 12, 15, 15, 36, 36, 94, 94, 2, 757, 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, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 2, 85, 3, 2, 2, 2, 2, 87, 3, 2, 2, 2, 2, 89, 3, 2, 2, 2, 2, 91, 3, 2, 2, 2, 2, 93, 3, 2, 2, 2, 2, 95, 3, 2, 2, 2, 2, 97, 3, 2, 2, 2, 2, 99, 3, 2, 2, 2, 2, 101, 3, 2, 2, 2, 2, 103, 3, 2, 2, 2, 2, 105, 3, 2, 2, 2, 2, 107, 3, 2, 2, 2, 2, 109, 3, 2, 2, 2, 2, 111, 3, 2, 2, 2, 2, 113, 3, 2, 2, 2, 2, 115, 3, 2, 2, 2, 2, 117, 3, 2, 2, 2, 2, 119, 3, 2, 2, 2, 2, 121, 3, 2, 2, 2, 2, 123, 3, 2, 2, 2, 2, 125, 3, 2, 2, 2, 2, 127, 3, 2, 2, 2, 2, 129, 3, 2, 2, 2, 2, 131, 3, 2, 2, 2, 2, 133, 3, 2, 2, 2, 2, 135, 3, 2, 2, 2, 2, 137, 3, 2, 2, 2, 2, 139, 3, 2, 2, 2, 2, 141, 3, 2, 2, 2, 2, 143, 3, 2, 2, 2, 2, 145, 3, 2, 2, 2, 2, 147, 3, 2, 2, 2, 2, 149, 3, 2, 2, 2, 2, 151, 3, 2, 2, 2, 2, 153, 3, 2, 2, 2, 2, 155, 3, 2, 2, 2, 2, 157, 3, 2, 2, 2, 2, 159, 3, 2, 2, 2, 2, 161, 3, 2, 2, 2, 2, 163, 3, 2, 2, 2, 2, 165, 3, 2, 2, 2, 3, 167, 3, 2, 2, 2, 3, 169, 3, 2, 2, 2, 3, 171, 3, 2, 2, 2, 4, 173, 3, 2, 2, 2, 4, 175, 3, 2, 2, 2, 4, 177, 3, 2, 2, 2, 5, 241, 3, 2, 2, 2, 7, 255, 3, 2, 2, 2, 9, 262, 3, 2, 2, 2, 11, 274, 3, 2, 2, 2, 13, 280, 3, 2, 2, 2, 15, 284, 3, 2, 2, 2, 17, 287, 3, 2, 2, 2, 19, 291, 3, 2, 2, 2, 21, 298, 3, 2, 2, 2, 23, 303, 3, 2, 2, 2, 25, 311, 3, 2, 2, 2, 27, 317, 3, 2, 2, 2, 29, 326, 3, 2, 2, 2, 31, 329, 3, 2, 2, 2, 33, 335, 3, 2, 2, 2, 35, 338, 3, 2, 2, 2, 37, 343, 3, 2, 2, 2, 39, 347, 3, 2, 2, 2, 41, 352, 3, 2, 2, 2, 43, 356, 3, 2, 2, 2, 45, 363, 3, 2, 2, 2, 47, 368, 3, 2, 2, 2, 49, 371, 3, 2, 2, 2, 51, 377, 3, 2, 2, 2, 53, 387, 3, 2, 2, 2, 55, 392, 3, 2, 2, 2, 57, 398, 3, 2, 2, 2, 59, 405, 3, 2, 2, 2, 61, 410, 3, 2, 2, 2, 63, 415, 3, 2, 2, 2, 65, 425, 3, 2, 2, 2, 67, 427, 3, 2, 2, 2, 69, 429, 3, 2, 2, 2, 71, 431, 3, 2, 2, 2, 73, 433, 3, 2, 2, 2, 75, 435, 3, 2, 2, 2, 77, 437, 3, 2, 2, 2, 79, 439, 3, 2, 2, 2, 81, 441, 3, 2, 2, 2, 83, 446, 3, 2, 2, 2, 85, 448, 3, 2, 2, 2, 87, 450, 3, 2, 2, 2, 89, 452, 3, 2, 2, 2, 91, 455, 3, 2, 2, 2, 93, 457, 3, 2, 2, 2, 95, 460, 3, 2, 2, 2, 97, 462, 3, 2, 2, 2, 99, 464, 3, 2, 2, 2, 101, 466, 3, 2, 2, 2, 103, 469, 3, 2, 2, 2, 105, 472, 3, 2, 2, 2, 107, 475, 3, 2, 2, 2, 109, 477, 3, 2, 2, 2, 111, 479, 3, 2, 2, 2, 113, 482, 3, 2, 2, 2, 115, 485, 3, 2, 2, 2, 117, 488, 3, 2, 2, 2, 119, 491, 3, 2, 2, 2, 121, 494, 3, 2, 2, 2, 123, 497, 3, 2, 2, 2, 125, 500, 3, 2, 2, 2, 127, 502, 3, 2, 2, 2, 129, 505, 3, 2, 2, 2, 131, 507, 3, 2, 2, 2, 133, 510, 3, 2, 2, 2, 135, 512, 3, 2, 2, 2, 137, 514, 3, 2, 2, 2, 139, 516, 3, 2, 2, 2, 141, 518, 3, 2, 2, 2, 143, 521, 3, 2, 2, 2, 145, 524, 3, 2, 2, 2, 147, 528, 3, 2, 2, 2, 149, 530, 3, 2, 2, 2, 151, 542, 3, 2, 2, 2, 153, 544, 3, 2, 2, 2, 155, 550, 3, 2, 2, 2, 157, 556, 3, 2, 2, 2, 159, 559, 3, 2, 2, 2, 161, 565, 3, 2, 2, 2, 163, 569, 3, 2, 2, 2, 165, 576, 3, 2, 2, 2, 167, 583, 3, 2, 2, 2, 169, 589, 3, 2, 2, 2, 171, 594, 3, 2, 2, 2, 173, 596, 3, 2, 2, 2, 175, 602, 3, 2, 2, 2, 177, 607, 3, 2, 2, 2, 179, 609, 3, 2, 2, 2, 181, 611, 3, 2, 2, 2, 183, 613, 3, 2, 2, 2, 185, 616, 3, 2, 2, 2, 187, 620, 3, 2, 2, 2, 189, 627, 3, 2, 2, 2, 191, 634, 3, 2, 2, 2, 193, 641, 3, 2, 2, 2, 195, 643, 3, 2, 2, 2, 197, 645, 3, 2, 2, 2, 199, 647, 3, 2, 2, 2, 201, 656, 3, 2, 2, 2, 203, 666, 3, 2, 2, 2, 205, 668, 3, 2, 2, 2, 207, 675, 3, 2, 2, 2, 209, 679, 3, 2, 2, 2, 211, 682, 3, 2, 2, 2, 213, 688, 3, 2, 2, 2, 215, 693, 3, 2, 2, 2, 217, 695, 3, 2, 2, 2, 219, 698, 3, 2, 2, 2, 221, 706, 3, 2, 2, 2, 223, 715, 3, 2, 2, 2, 225, 721, 3, 2, 2, 2, 227, 724, 3, 2, 2, 2, 229, 730, 3, 2, 2, 2, 231, 733, 3, 2, 2, 2, 233, 739, 3, 2, 2, 2, 235, 742, 3, 2, 2, 2, 237, 748, 3, 2, 2, 2, 239, 753, 3, 2, 2, 2, 241, 242, 7, 49, 2, 2, 242, 243, 7, 44, 2, 2, 243, 247, 3, 2, 2, 2, 244, 246, 11, 2, 2, 2, 245, 244, 3, 2, 2, 2, 246, 249, 3, 2, 2, 2, 247, 248, 3, 2, 2, 2, 247, 245, 3, 2, 2, 2, 248, 250, 3, 2, 2, 2, 249, 247, 3, 2, 2, 2, 250, 251, 7, 44, 2, 2, 251, 252, 7, 49, 2, 2, 252, 253, 3, 2, 2, 2, 253, 254, 8, 2, 2, 2, 254, 6, 3, 2, 2, 2, 255, 256, 7, 49, 2, 2, 256, 257, 7, 49, 2, 2, 257, 258, 3, 2, 2, 2, 258, 259, 5, 239, 119, 2, 259, 260, 3, 2, 2, 2, 260, 261, 8, 3, 2, 2, 261, 8, 3, 2, 2, 2, 262, 263, 7, 37, 2, 2, 263, 264, 7, 114, 2, 2, 264, 265, 7, 116, 2, 2, 265, 266, 7, 99, 2, 2, 266, 267, 7, 105, 2, 2, 267, 268, 7, 111, 2, 2, 268, 269, 7, 99, 2, 2, 269, 270, 3, 2, 2, 2, 270, 271, 5, 239, 119, 2, 271, 272, 3, 2, 2, 2, 272, 273, 8, 4, 3, 2, 273, 10, 3, 2, 2, 2, 274, 275, 7, 101, 2, 2, 275, 276, 7, 113, 2, 2, 276, 277, 7, 112, 2, 2, 277, 278, 7, 117, 2, 2, 278, 279, 7, 118, 2, 2, 279, 12, 3, 2, 2, 2, 280, 281, 7, 120, 2, 2, 281, 282, 7, 99, 2, 2, 282, 283, 7, 116, 2, 2, 283, 14, 3, 2, 2, 2, 284, 285, 7, 99, 2, 2, 285, 286, 7, 117, 2, 2, 286, 16, 3, 2, 2, 2, 287, 288, 7, 48, 2, 2, 288, 289, 7, 48, 2, 2, 289, 290, 7, 48, 2, 2, 290, 18, 3, 2, 2, 2, 291, 292, 7, 117, 2, 2, 292, 293, 7, 121, 2, 2, 293, 294, 7, 107, 2, 2, 294, 295, 7, 118, 2, 2, 295, 296, 7, 101, 2, 2, 296, 297, 7, 106, 2, 2, 297, 20, 3, 2, 2, 2, 298, 299, 7, 101, 2, 2, 299, 300, 7, 99, 2, 2, 300, 301, 7, 117, 2, 2, 301, 302, 7, 103, 2, 2, 302, 22, 3, 2, 2, 2, 303, 304, 7, 102, 2, 2, 304, 305, 7, 103, 2, 2, 305, 306, 7, 104, 2, 2, 306, 307, 7, 99, 2, 2, 307, 308, 7, 119, 2, 2, 308, 309, 7, 110, 2, 2, 309, 310, 7, 118, 2, 2, 310, 24, 3, 2, 2, 2, 311, 312, 7, 100, 2, 2, 312, 313, 7, 116, 2, 2, 313, 314, 7, 103, 2, 2, 314, 315, 7, 99, 2, 2, 315, 316, 7, 109, 2, 2, 316, 26, 3, 2, 2, 2, 317, 318, 7, 101, 2, 2, 318, 319, 7, 113, 2, 2, 319, 320, 7, 112, 2, 2, 320, 321, 7, 118, 2, 2, 321, 322, 7, 107, 2, 2, 322, 323, 7, 112, 2, 2, 323, 324, 7, 119, 2, 2, 324, 325, 7, 103, 2, 2, 325, 28, 3, 2, 2, 2, 326, 327, 7, 102, 2, 2, 327, 328, 7, 113, 2, 2, 328, 30, 3, 2, 2, 2, 329, 330, 7, 121, 2, 2, 330, 331, 7, 106, 2, 2, 331, 332, 7, 107, 2, 2, 332, 333, 7, 110, 2, 2, 333, 334, 7, 103, 2, 2, 334, 32, 3, 2, 2, 2, 335, 336, 7, 107, 2, 2, 336, 337, 7, 104, 2, 2, 337, 34, 3, 2, 2, 2, 338, 339, 7, 103, 2, 2, 339, 340, 7, 110, 2, 2, 340, 341, 7, 117, 2, 2, 341, 342, 7, 103, 2, 2, 342, 36, 3, 2, 2, 2, 343, 344, 7, 104, 2, 2, 344, 345, 7, 113, 2, 2, 345, 346, 7, 116, 2, 2, 346, 38, 3, 2, 2, 2, 347, 348, 7, 103, 2, 2, 348, 349, 7, 112, 2, 2, 349, 350, 7, 119, 2, 2, 350, 351, 7, 111, 2, 2, 351, 40, 3, 2, 2, 2, 352, 353, 7, 102, 2, 2, 353, 354, 7, 103, 2, 2, 354, 355, 7, 104, 2, 2, 355, 42, 3, 2, 2, 2, 356, 357, 7, 116, 2, 2, 357, 358, 7, 103, 2, 2, 358, 359, 7, 118, 2, 2, 359, 360, 7, 119, 2, 2, 360, 361, 7, 116, 2, 2, 361, 362, 7, 112, 2, 2, 362, 44, 3, 2, 2, 2, 363, 364, 7, 101, 2, 2, 364, 365, 7, 99, 2, 2, 365, 366, 7, 110, 2, 2, 366, 367, 7, 110, 2, 2, 367, 46, 3, 2, 2, 2, 368, 369, 7, 47, 2, 2, 369, 370, 7, 64, 2, 2, 370, 48, 3, 2, 2, 2, 371, 372, 7, 101, 2, 2, 372, 373, 7, 110, 2, 2, 373, 374, 7, 99, 2, 2, 374, 375, 7, 117, 2, 2, 375, 376, 7, 117, 2, 2, 376, 50, 3, 2, 2, 2, 377, 378, 7, 107, 2, 2, 378, 379, 7, 112, 2, 2, 379, 380, 7, 118, 2, 2, 380, 381, 7, 103, 2, 2, 381, 382, 7, 116, 2, 2, 382, 383, 7, 104, 2, 2, 383, 384, 7, 99, 2, 2, 384, 385, 7, 101, 2, 2, 385, 386, 7, 103, 2, 2, 386, 52, 3, 2, 2, 2, 387, 388, 7, 118, 2, 2, 388, 389, 7, 116, 2, 2, 389, 390, 7, 119, 2, 2, 390, 391, 7, 103, 2, 2, 391, 54, 3, 2, 2, 2, 392, 393, 7, 104, 2, 2, 393, 394, 7, 99, 2, 2, 394, 395, 7, 110, 2, 2, 395, 396, 7, 117, 2, 2, 396, 397, 7, 103, 2, 2, 397, 56, 3, 2, 2, 2, 398, 399, 7, 118, 2, 2, 399, 400, 7, 123, 2, 2, 400, 401, 7, 114, 2, 2, 401, 402, 7, 103, 2, 2, 402, 403, 7, 113, 2, 2, 403, 404, 7, 104, 2, 2, 404, 58, 3, 2, 2, 2, 405, 406, 7, 120, 2, 2, 406, 407, 7, 113, 2, 2, 407, 408, 7, 107, 2, 2, 408, 409, 7, 102, 2, 2, 409, 60, 3, 2, 2, 2, 410, 411, 7, 112, 2, 2, 411, 412, 7, 119, 2, 2, 412, 413, 7, 110, 2, 2, 413, 414, 7, 110, 2, 2, 414, 62, 3, 2, 2, 2, 415, 416, 7, 119, 2, 2, 416, 417, 7, 112, 2, 2, 417, 418, 7, 102, 2, 2, 418, 419, 7, 103, 2, 2, 419, 420, 7, 104, 2, 2, 420, 421, 7, 107, 2, 2, 421, 422, 7, 112, 2, 2, 422, 423, 7, 103, 2, 2, 423, 424, 7, 102, 2, 2, 424, 64, 3, 2, 2, 2, 425, 426, 7, 46, 2, 2, 426, 66, 3, 2, 2, 2, 427, 428, 7, 61, 2, 2, 428, 68, 3, 2, 2, 2, 429, 430, 7, 65, 2, 2, 430, 70, 3, 2, 2, 2, 431, 432, 7, 60, 2, 2, 432, 72, 3, 2, 2, 2, 433, 434, 7, 42, 2, 2, 434, 74, 3, 2, 2, 2, 435, 436, 7, 43, 2, 2, 436, 76, 3, 2, 2, 2, 437, 438, 7, 93, 2, 2, 438, 78, 3, 2, 2, 2, 439, 440, 7, 95, 2, 2, 440, 80, 3, 2, 2, 2, 441, 442, 6, 40, 2, 2, 442, 443, 7, 127, 2, 2, 443, 444, 3, 2, 2, 2, 444, 445, 8, 40, 4, 2, 445, 82, 3, 2, 2, 2, 446, 447, 7, 125, 2, 2, 447, 84, 3, 2, 2, 2, 448, 449, 7, 127, 2, 2, 449, 86, 3, 2, 2, 2, 450, 451, 7, 45, 2, 2, 451, 88, 3, 2, 2, 2, 452, 453, 7, 45, 2, 2, 453, 454, 7, 45, 2, 2, 454, 90, 3, 2, 2, 2, 455, 456, 7, 47, 2, 2, 456, 92, 3, 2, 2, 2, 457, 458, 7, 47, 2, 2, 458, 459, 7, 47, 2, 2, 459, 94, 3, 2, 2, 2, 460, 461, 7, 44, 2, 2, 461, 96, 3, 2, 2, 2, 462, 463, 7, 49, 2, 2, 463, 98, 3, 2, 2, 2, 464, 465, 7, 39, 2, 2, 465, 100, 3, 2, 2, 2, 466, 467, 7, 44, 2, 2, 467, 468, 7, 44, 2, 2, 468, 102, 3, 2, 2, 2, 469, 470, 7, 40, 2, 2, 470, 471, 7, 40, 2, 2, 471, 104, 3, 2, 2, 2, 472, 473, 7, 126, 2, 2, 473, 474, 7, 126, 2, 2, 474, 106, 3, 2, 2, 2, 475, 476, 7, 35, 2, 2, 476, 108, 3, 2, 2, 2, 477, 478, 7, 63, 2, 2, 478, 110, 3, 2, 2, 2, 479, 480, 7, 45, 2, 2, 480, 481, 7, 63, 2, 2, 481, 112, 3, 2, 2, 2, 482, 483, 7, 47, 2, 2, 483, 484, 7, 63, 2, 2, 484, 114, 3, 2, 2, 2, 485, 486, 7, 44, 2, 2, 486, 487, 7, 63, 2, 2, 487, 116, 3, 2, 2, 2, 488, 489, 7, 49, 2, 2, 489, 490, 7, 63, 2, 2, 490, 118, 3, 2, 2, 2, 491, 492, 7, 39, 2, 2, 492, 493, 7, 63, 2, 2, 493, 120, 3, 2, 2, 2, 494, 495, 7, 63, 2, 2, 495, 496, 7, 63, 2, 2, 496, 122, 3, 2, 2, 2, 497, 498, 7, 35, 2, 2, 498, 499, 7, 63, 2, 2, 499, 124, 3, 2, 2, 2, 500, 501, 7, 62, 2, 2, 501, 126, 3, 2, 2, 2, 502, 503, 7, 62, 2, 2, 503, 504, 7, 63, 2, 2, 504, 128, 3, 2, 2, 2, 505, 506, 7, 64, 2, 2, 506, 130, 3, 2, 2, 2, 507, 508, 7, 64, 2, 2, 508, 509, 7, 63, 2, 2, 509, 132, 3, 2, 2, 2, 510, 511, 7, 40, 2, 2, 511, 134, 3, 2, 2, 2, 512, 513, 7, 126, 2, 2, 513, 136, 3, 2, 2, 2, 514, 515, 7, 96, 2, 2, 515, 138, 3, 2, 2, 2, 516, 517, 7, 128, 2, 2, 517, 140, 3, 2, 2, 2, 518, 519, 7, 62, 2, 2, 519, 520, 7, 62, 2, 2, 520, 142, 3, 2, 2, 2, 521, 522, 7, 64, 2, 2, 522, 523, 7, 64, 2, 2, 523, 144, 3, 2, 2, 2, 524, 525, 7, 64, 2, 2, 525, 526, 7, 64, 2, 2, 526, 527, 7, 64, 2, 2, 527, 146, 3, 2, 2, 2, 528, 529, 7, 48, 2, 2, 529, 148, 3, 2, 2, 2, 530, 535, 5, 179, 89, 2, 531, 534, 5, 179, 89, 2, 532, 534, 5, 183, 91, 2, 533, 531, 3, 2, 2, 2, 533, 532, 3, 2, 2, 2, 534, 537, 3, 2, 2, 2, 535, 533, 3, 2, 2, 2, 535, 536, 3, 2, 2, 2, 536, 150, 3, 2, 2, 2, 537, 535, 3, 2, 2, 2, 538, 543, 5, 185, 92, 2, 539, 543, 5, 189, 94, 2, 540, 543, 5, 191, 95, 2, 541, 543, 5, 187, 93, 2, 542, 538, 3, 2, 2, 2, 542, 539, 3, 2, 2, 2, 542, 540, 3, 2, 2, 2, 542, 541, 3, 2, 2, 2, 543, 152, 3, 2, 2, 2, 544, 546, 7, 41, 2, 2, 545, 547, 5, 231, 115, 2, 546, 545, 3, 2, 2, 2, 546, 547, 3, 2, 2, 2, 547, 548, 3, 2, 2, 2, 548, 549, 7, 41, 2, 2, 549, 154, 3, 2, 2, 2, 550, 552, 7, 36, 2, 2, 551, 553, 5, 235, 117, 2, 552, 551, 3, 2, 2, 2, 552, 553, 3, 2, 2, 2, 553, 554, 3, 2, 2, 2, 554, 555, 7, 36, 2, 2, 555, 156, 3, 2, 2, 2, 556, 557, 5, 201, 100, 2, 557, 158, 3, 2, 2, 2, 558, 560, 9, 2, 2, 2, 559, 558, 3, 2, 2, 2, 560, 561, 3, 2, 2, 2, 561, 559, 3, 2, 2, 2, 561, 562, 3, 2, 2, 2, 562, 563, 3, 2, 2, 2, 563, 564, 8, 79, 5, 2, 564, 160, 3, 2, 2, 2, 565, 566, 9, 3, 2, 2, 566, 567, 3, 2, 2, 2, 567, 568, 8, 80, 5, 2, 568, 162, 3, 2, 2, 2, 569, 570, 7, 104, 2, 2, 570, 571, 7, 41, 2, 2, 571, 572, 3, 2, 2, 2, 572, 573, 8, 81, 6, 2, 573, 574, 3, 2, 2, 2, 574, 575, 8, 81, 7, 2, 575, 164, 3, 2, 2, 2, 576, 577, 7, 104, 2, 2, 577, 578, 7, 36, 2, 2, 578, 579, 3, 2, 2, 2, 579, 580, 8, 82, 8, 2, 580, 581, 3, 2, 2, 2, 581, 582, 8, 82, 9, 2, 582, 166, 3, 2, 2, 2, 583, 584, 6, 83, 3, 2, 584, 585, 7, 125, 2, 2, 585, 586, 3, 2, 2, 2, 586, 587, 8, 83, 10, 2, 587, 588, 8, 83, 11, 2, 588, 168, 3, 2, 2, 2, 589, 590, 7, 41, 2, 2, 590, 591, 8, 84, 12, 2, 591, 592, 3, 2, 2, 2, 592, 593, 8, 84, 4, 2, 593, 170, 3, 2, 2, 2, 594, 595, 5, 223, 111, 2, 595, 172, 3, 2, 2, 2, 596, 597, 6, 86, 4, 2, 597, 598, 7, 125, 2, 2, 598, 599, 3, 2, 2, 2, 599, 600, 8, 86, 10, 2, 600, 601, 8, 86, 11, 2, 601, 174, 3, 2, 2, 2, 602, 603, 7, 36, 2, 2, 603, 604, 8, 87, 13, 2, 604, 605, 3, 2, 2, 2, 605, 606, 8, 87, 4, 2, 606, 176, 3, 2, 2, 2, 607, 608, 5, 227, 113, 2, 608, 178, 3, 2, 2, 2, 609, 610, 5, 181, 90, 2, 610, 180, 3, 2, 2, 2, 611, 612, 9, 4, 2, 2, 612, 182, 3, 2, 2, 2, 613, 614, 9, 5, 2, 2, 614, 184, 3, 2, 2, 2, 615, 617, 5, 183, 91, 2, 616, 615, 3, 2, 2, 2, 617, 618, 3, 2, 2, 2, 618, 616, 3, 2, 2, 2, 618, 619, 3, 2, 2, 2, 619, 186, 3, 2, 2, 2, 620, 621, 7, 50, 2, 2, 621, 623, 9, 6, 2, 2, 622, 624, 5, 195, 97, 2, 623, 622, 3, 2, 2, 2, 624, 625, 3, 2, 2, 2, 625, 623, 3, 2, 2, 2, 625, 626, 3, 2, 2, 2, 626, 188, 3, 2, 2, 2, 627, 628, 7, 50, 2, 2, 628, 630, 9, 7, 2, 2, 629, 631, 5, 197, 98, 2, 630, 629, 3, 2, 2, 2, 631, 632, 3, 2, 2, 2, 632, 630, 3, 2, 2, 2, 632, 633, 3, 2, 2, 2, 633, 190, 3, 2, 2, 2, 634, 635, 7, 50, 2, 2, 635, 637, 9, 8, 2, 2, 636, 638, 5, 199, 99, 2, 637, 636, 3, 2, 2, 2, 638, 639, 3, 2, 2, 2, 639, 637, 3, 2, 2, 2, 639, 640, 3, 2, 2, 2, 640, 192, 3, 2, 2, 2, 641, 642, 9, 9, 2, 2, 642, 194, 3, 2, 2, 2, 643, 644, 9, 10, 2, 2, 644, 196, 3, 2, 2, 2, 645, 646, 9, 11, 2, 2, 646, 198, 3, 2, 2, 2, 647, 648, 9, 12, 2, 2, 648, 200, 3, 2, 2, 2, 649, 651, 5, 203, 101, 2, 650, 652, 5, 205, 102, 2, 651, 650, 3, 2, 2, 2, 651, 652, 3, 2, 2, 2, 652, 657, 3, 2, 2, 2, 653, 654, 5, 207, 103, 2, 654, 655, 5, 205, 102, 2, 655, 657, 3, 2, 2, 2, 656, 649, 3, 2, 2, 2, 656, 653, 3, 2, 2, 2, 657, 202, 3, 2, 2, 2, 658, 660, 5, 207, 103, 2, 659, 658, 3, 2, 2, 2, 659, 660, 3, 2, 2, 2, 660, 661, 3, 2, 2, 2, 661, 662, 7, 48, 2, 2, 662, 667, 5, 207, 103, 2, 663, 664, 5, 207, 103, 2, 664, 665, 7, 48, 2, 2, 665, 667, 3, 2, 2, 2, 666, 659, 3, 2, 2, 2, 666, 663, 3, 2, 2, 2, 667, 204, 3, 2, 2, 2, 668, 670, 9, 13, 2, 2, 669, 671, 5, 209, 104, 2, 670, 669, 3, 2, 2, 2, 670, 671, 3, 2, 2, 2, 671, 672, 3, 2, 2, 2, 672, 673, 5, 207, 103, 2, 673, 206, 3, 2, 2, 2, 674, 676, 5, 183, 91, 2, 675, 674, 3, 2, 2, 2, 676, 677, 3, 2, 2, 2, 677, 675, 3, 2, 2, 2, 677, 678, 3, 2, 2, 2, 678, 208, 3, 2, 2, 2, 679, 680, 9, 14, 2, 2, 680, 210, 3, 2, 2, 2, 681, 683, 5, 213, 106, 2, 682, 681, 3, 2, 2, 2, 683, 684, 3, 2, 2, 2, 684, 682, 3, 2, 2, 2, 684, 685, 3, 2, 2, 2, 685, 212, 3, 2, 2, 2, 686, 689, 10, 15, 2, 2, 687, 689, 5, 215, 107, 2, 688, 686, 3, 2, 2, 2, 688, 687, 3, 2, 2, 2, 689, 214, 3, 2, 2, 2, 690, 694, 5, 217, 108, 2, 691, 694, 5, 219, 109, 2, 692, 694, 5, 221, 110, 2, 693, 690, 3, 2, 2, 2, 693, 691, 3, 2, 2, 2, 693, 692, 3, 2, 2, 2, 694, 216, 3, 2, 2, 2, 695, 696, 7, 94, 2, 2, 696, 697, 9, 16, 2, 2, 697, 218, 3, 2, 2, 2, 698, 699, 7, 94, 2, 2, 699, 701, 5, 197, 98, 2, 700, 702, 5, 197, 98, 2, 701, 700, 3, 2, 2, 2, 701, 702, 3, 2, 2, 2, 702, 704, 3, 2, 2, 2, 703, 705, 5, 197, 98, 2, 704, 703, 3, 2, 2, 2, 704, 705, 3, 2, 2, 2, 705, 220, 3, 2, 2, 2, 706, 707, 7, 94, 2, 2, 707, 708, 7, 122, 2, 2, 708, 710, 3, 2, 2, 2, 709, 711, 5, 199, 99, 2, 710, 709, 3, 2, 2, 2, 711, 712, 3, 2, 2, 2, 712, 710, 3, 2, 2, 2, 712, 713, 3, 2, 2, 2, 713, 222, 3, 2, 2, 2, 714, 716, 5, 225, 112, 2, 715, 714, 3, 2, 2, 2, 716, 717, 3, 2, 2, 2, 717, 715, 3, 2, 2, 2, 717, 718, 3, 2, 2, 2, 718, 224, 3, 2, 2, 2, 719, 722, 10, 17, 2, 2, 720, 722, 5, 215, 107, 2, 721, 719, 3, 2, 2, 2, 721, 720, 3, 2, 2, 2, 722, 226, 3, 2, 2, 2, 723, 725, 5, 229, 114, 2, 724, 723, 3, 2, 2, 2, 725, 726, 3, 2, 2, 2, 726, 724, 3, 2, 2, 2, 726, 727, 3, 2, 2, 2, 727, 228, 3, 2, 2, 2, 728, 731, 10, 18, 2, 2, 729, 731, 5, 215, 107, 2, 730, 728, 3, 2, 2, 2, 730, 729, 3, 2, 2, 2, 731, 230, 3, 2, 2, 2, 732, 734, 5, 233, 116, 2, 733, 732, 3, 2, 2, 2, 734, 735, 3, 2, 2, 2, 735, 733, 3, 2, 2, 2, 735, 736, 3, 2, 2, 2, 736, 232, 3, 2, 2, 2, 737, 740, 10, 15, 2, 2, 738, 740, 5, 215, 107, 2, 739, 737, 3, 2, 2, 2, 739, 738, 3, 2, 2, 2, 740, 234, 3, 2, 2, 2, 741, 743, 5, 237, 118, 2, 742, 741, 3, 2, 2, 2, 743, 744, 3, 2, 2, 2, 744, 742, 3, 2, 2, 2, 744, 745, 3, 2, 2, 2, 745, 236, 3, 2, 2, 2, 746, 749, 10, 19, 2, 2, 747, 749, 5, 215, 107, 2, 748, 746, 3, 2, 2, 2, 748, 747, 3, 2, 2, 2, 749, 238, 3, 2, 2, 2, 750, 752, 10, 3, 2, 2, 751, 750, 3, 2, 2, 2, 752, 755, 3, 2, 2, 2, 753, 751, 3, 2, 2, 2, 753, 754, 3, 2, 2, 2, 754, 240, 3, 2, 2, 2, 755, 753, 3, 2, 2, 2, 37, 2, 3, 4, 247, 533, 535, 542, 546, 552, 561, 618, 625, 632, 639, 651, 656, 659, 666, 670, 677, 684, 688, 693, 701, 704, 712, 717, 721, 726, 730, 735, 739, 744, 748, 753, 14, 2, 4, 2, 2, 5, 2, 6, 2, 2, 2, 3, 2, 3, 81, 2, 7, 3, 2, 3, 82, 3, 7, 4, 2, 9, 3, 2, 7, 2, 2, 3, 84, 4, 3, 87, 5] \ No newline at end of file diff --git a/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.tokens b/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.tokens index 7c4c655e8..a380f4448 100644 --- a/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.tokens +++ b/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.tokens @@ -21,67 +21,69 @@ DefFunc=20 Return=21 CallFunc=22 RetIndicator=23 -True=24 -False=25 -Typeof=26 -Void=27 -Null=28 -Undefined=29 -Comma=30 -SemiColon=31 -QuestionMark=32 -Colon=33 -LeftParen=34 -RightParen=35 -LeftBracket=36 -RightBracket=37 -FStringExpEnd=38 -LeftBrace=39 -RightBrace=40 -Plus=41 -PlusPlus=42 -Minus=43 -MinusMinus=44 -Star=45 -Div=46 -Mod=47 -PowerTo=48 -AndAnd=49 -OrOr=50 -Not=51 -Assign=52 -PlusAssign=53 -MinusAssign=54 -StarAssign=55 -DivAssign=56 -ModAssign=57 -Equal=58 -NotEqual=59 -Less=60 -LessEqual=61 -Greater=62 -GreaterEqual=63 -BitwiseAnd=64 -BitwiseOr=65 -BitwiseXor=66 -BitwiseNot=67 -BitwiseZeroFillLeftShift=68 -BitwiseSignedRightShift=69 -BitwiseZeroFillRightShift=70 -Dot=71 -Identifier=72 -IntegerConstant=73 -SingleQuoteStringLiteral=74 -DoubleQuoteStringLiteral=75 -FloatingConstant=76 -Whitespace=77 -Newline=78 -FStringSingleQuoteStart=79 -FStringDoubleQuoteStart=80 -FStringSingleQuoteEnd=81 -FStringSingleQuoteAtom=82 -FStringDoubleQuoteEnd=83 -FStringDoubleQuoteAtom=84 +Class=24 +Interface=25 +True=26 +False=27 +Typeof=28 +Void=29 +Null=30 +Undefined=31 +Comma=32 +SemiColon=33 +QuestionMark=34 +Colon=35 +LeftParen=36 +RightParen=37 +LeftBracket=38 +RightBracket=39 +FStringExpEnd=40 +LeftBrace=41 +RightBrace=42 +Plus=43 +PlusPlus=44 +Minus=45 +MinusMinus=46 +Star=47 +Div=48 +Mod=49 +PowerTo=50 +AndAnd=51 +OrOr=52 +Not=53 +Assign=54 +PlusAssign=55 +MinusAssign=56 +StarAssign=57 +DivAssign=58 +ModAssign=59 +Equal=60 +NotEqual=61 +Less=62 +LessEqual=63 +Greater=64 +GreaterEqual=65 +BitwiseAnd=66 +BitwiseOr=67 +BitwiseXor=68 +BitwiseNot=69 +BitwiseZeroFillLeftShift=70 +BitwiseSignedRightShift=71 +BitwiseZeroFillRightShift=72 +Dot=73 +Identifier=74 +IntegerConstant=75 +SingleQuoteStringLiteral=76 +DoubleQuoteStringLiteral=77 +FloatingConstant=78 +Whitespace=79 +Newline=80 +FStringSingleQuoteStart=81 +FStringDoubleQuoteStart=82 +FStringSingleQuoteEnd=83 +FStringSingleQuoteAtom=84 +FStringDoubleQuoteEnd=85 +FStringDoubleQuoteAtom=86 'const'=5 'var'=6 'as'=7 @@ -101,50 +103,52 @@ FStringDoubleQuoteAtom=84 'return'=21 'call'=22 '->'=23 -'true'=24 -'false'=25 -'typeof'=26 -'void'=27 -'null'=28 -'undefined'=29 -','=30 -';'=31 -'?'=32 -':'=33 -'('=34 -')'=35 -'['=36 -']'=37 -'{'=39 -'}'=40 -'+'=41 -'++'=42 -'-'=43 -'--'=44 -'*'=45 -'/'=46 -'%'=47 -'**'=48 -'&&'=49 -'||'=50 -'!'=51 -'='=52 -'+='=53 -'-='=54 -'*='=55 -'/='=56 -'%='=57 -'=='=58 -'!='=59 -'<'=60 -'<='=61 -'>'=62 -'>='=63 -'&'=64 -'|'=65 -'^'=66 -'~'=67 -'<<'=68 -'>>'=69 -'>>>'=70 -'.'=71 +'class'=24 +'interface'=25 +'true'=26 +'false'=27 +'typeof'=28 +'void'=29 +'null'=30 +'undefined'=31 +','=32 +';'=33 +'?'=34 +':'=35 +'('=36 +')'=37 +'['=38 +']'=39 +'{'=41 +'}'=42 +'+'=43 +'++'=44 +'-'=45 +'--'=46 +'*'=47 +'/'=48 +'%'=49 +'**'=50 +'&&'=51 +'||'=52 +'!'=53 +'='=54 +'+='=55 +'-='=56 +'*='=57 +'/='=58 +'%='=59 +'=='=60 +'!='=61 +'<'=62 +'<='=63 +'>'=64 +'>='=65 +'&'=66 +'|'=67 +'^'=68 +'~'=69 +'<<'=70 +'>>'=71 +'>>>'=72 +'.'=73 diff --git a/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.ts b/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.ts index efaaec50c..11ae1d1dc 100644 --- a/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.ts +++ b/kipper/core/src/compiler/lexer-parser/antlr/KipperLexer.ts @@ -39,67 +39,69 @@ export class KipperLexer extends KipperLexerBase { public static readonly Return = 21; public static readonly CallFunc = 22; public static readonly RetIndicator = 23; - public static readonly True = 24; - public static readonly False = 25; - public static readonly Typeof = 26; - public static readonly Void = 27; - public static readonly Null = 28; - public static readonly Undefined = 29; - public static readonly Comma = 30; - public static readonly SemiColon = 31; - public static readonly QuestionMark = 32; - public static readonly Colon = 33; - public static readonly LeftParen = 34; - public static readonly RightParen = 35; - public static readonly LeftBracket = 36; - public static readonly RightBracket = 37; - public static readonly FStringExpEnd = 38; - public static readonly LeftBrace = 39; - public static readonly RightBrace = 40; - public static readonly Plus = 41; - public static readonly PlusPlus = 42; - public static readonly Minus = 43; - public static readonly MinusMinus = 44; - public static readonly Star = 45; - public static readonly Div = 46; - public static readonly Mod = 47; - public static readonly PowerTo = 48; - public static readonly AndAnd = 49; - public static readonly OrOr = 50; - public static readonly Not = 51; - public static readonly Assign = 52; - public static readonly PlusAssign = 53; - public static readonly MinusAssign = 54; - public static readonly StarAssign = 55; - public static readonly DivAssign = 56; - public static readonly ModAssign = 57; - public static readonly Equal = 58; - public static readonly NotEqual = 59; - public static readonly Less = 60; - public static readonly LessEqual = 61; - public static readonly Greater = 62; - public static readonly GreaterEqual = 63; - public static readonly BitwiseAnd = 64; - public static readonly BitwiseOr = 65; - public static readonly BitwiseXor = 66; - public static readonly BitwiseNot = 67; - public static readonly BitwiseZeroFillLeftShift = 68; - public static readonly BitwiseSignedRightShift = 69; - public static readonly BitwiseZeroFillRightShift = 70; - public static readonly Dot = 71; - public static readonly Identifier = 72; - public static readonly IntegerConstant = 73; - public static readonly SingleQuoteStringLiteral = 74; - public static readonly DoubleQuoteStringLiteral = 75; - public static readonly FloatingConstant = 76; - public static readonly Whitespace = 77; - public static readonly Newline = 78; - public static readonly FStringSingleQuoteStart = 79; - public static readonly FStringDoubleQuoteStart = 80; - public static readonly FStringSingleQuoteEnd = 81; - public static readonly FStringSingleQuoteAtom = 82; - public static readonly FStringDoubleQuoteEnd = 83; - public static readonly FStringDoubleQuoteAtom = 84; + public static readonly Class = 24; + public static readonly Interface = 25; + public static readonly True = 26; + public static readonly False = 27; + public static readonly Typeof = 28; + public static readonly Void = 29; + public static readonly Null = 30; + public static readonly Undefined = 31; + public static readonly Comma = 32; + public static readonly SemiColon = 33; + public static readonly QuestionMark = 34; + public static readonly Colon = 35; + public static readonly LeftParen = 36; + public static readonly RightParen = 37; + public static readonly LeftBracket = 38; + public static readonly RightBracket = 39; + public static readonly FStringExpEnd = 40; + public static readonly LeftBrace = 41; + public static readonly RightBrace = 42; + public static readonly Plus = 43; + public static readonly PlusPlus = 44; + public static readonly Minus = 45; + public static readonly MinusMinus = 46; + public static readonly Star = 47; + public static readonly Div = 48; + public static readonly Mod = 49; + public static readonly PowerTo = 50; + public static readonly AndAnd = 51; + public static readonly OrOr = 52; + public static readonly Not = 53; + public static readonly Assign = 54; + public static readonly PlusAssign = 55; + public static readonly MinusAssign = 56; + public static readonly StarAssign = 57; + public static readonly DivAssign = 58; + public static readonly ModAssign = 59; + public static readonly Equal = 60; + public static readonly NotEqual = 61; + public static readonly Less = 62; + public static readonly LessEqual = 63; + public static readonly Greater = 64; + public static readonly GreaterEqual = 65; + public static readonly BitwiseAnd = 66; + public static readonly BitwiseOr = 67; + public static readonly BitwiseXor = 68; + public static readonly BitwiseNot = 69; + public static readonly BitwiseZeroFillLeftShift = 70; + public static readonly BitwiseSignedRightShift = 71; + public static readonly BitwiseZeroFillRightShift = 72; + public static readonly Dot = 73; + public static readonly Identifier = 74; + public static readonly IntegerConstant = 75; + public static readonly SingleQuoteStringLiteral = 76; + public static readonly DoubleQuoteStringLiteral = 77; + public static readonly FloatingConstant = 78; + public static readonly Whitespace = 79; + public static readonly Newline = 80; + public static readonly FStringSingleQuoteStart = 81; + public static readonly FStringDoubleQuoteStart = 82; + public static readonly FStringSingleQuoteEnd = 83; + public static readonly FStringSingleQuoteAtom = 84; + public static readonly FStringDoubleQuoteEnd = 85; + public static readonly FStringDoubleQuoteAtom = 86; public static readonly COMMENT = 2; public static readonly PRAGMA = 3; public static readonly SINGLE_QUOTE_FSTRING = 1; @@ -134,6 +136,8 @@ export class KipperLexer extends KipperLexerBase { "Return", "CallFunc", "RetIndicator", + "Class", + "Interface", "True", "False", "Typeof", @@ -255,6 +259,8 @@ export class KipperLexer extends KipperLexerBase { "'return'", "'call'", "'->'", + "'class'", + "'interface'", "'true'", "'false'", "'typeof'", @@ -329,6 +335,8 @@ export class KipperLexer extends KipperLexerBase { "Return", "CallFunc", "RetIndicator", + "Class", + "Interface", "True", "False", "Typeof", @@ -402,6 +410,7 @@ export class KipperLexer extends KipperLexerBase { public get vocabulary(): Vocabulary { return KipperLexer.VOCABULARY; } + // tslint:enable:no-trailing-whitespace constructor(input: CharStream) { @@ -437,23 +446,24 @@ export class KipperLexer extends KipperLexerBase { // @Override public action(_localctx: RuleContext, ruleIndex: number, actionIndex: number): void { switch (ruleIndex) { - case 77: + case 79: this.FStringSingleQuoteStart_action(_localctx, actionIndex); break; - case 78: + case 80: this.FStringDoubleQuoteStart_action(_localctx, actionIndex); break; - case 80: + case 82: this.FStringSingleQuoteEnd_action(_localctx, actionIndex); break; - case 83: + case 85: this.FStringDoubleQuoteEnd_action(_localctx, actionIndex); break; } } + private FStringSingleQuoteStart_action(_localctx: RuleContext, actionIndex: number): void { switch (actionIndex) { case 0: @@ -461,6 +471,7 @@ export class KipperLexer extends KipperLexerBase { break; } } + private FStringDoubleQuoteStart_action(_localctx: RuleContext, actionIndex: number): void { switch (actionIndex) { case 1: @@ -468,6 +479,7 @@ export class KipperLexer extends KipperLexerBase { break; } } + private FStringSingleQuoteEnd_action(_localctx: RuleContext, actionIndex: number): void { switch (actionIndex) { case 2: @@ -475,6 +487,7 @@ export class KipperLexer extends KipperLexerBase { break; } } + private FStringDoubleQuoteEnd_action(_localctx: RuleContext, actionIndex: number): void { switch (actionIndex) { case 3: @@ -482,20 +495,22 @@ export class KipperLexer extends KipperLexerBase { break; } } + // @Override public sempred(_localctx: RuleContext, ruleIndex: number, predIndex: number): boolean { switch (ruleIndex) { - case 36: + case 38: return this.FStringExpEnd_sempred(_localctx, predIndex); - case 79: + case 81: return this.FStringSingleQuoteExpStart_sempred(_localctx, predIndex); - case 82: + case 84: return this.FStringDoubleQuoteExpStart_sempred(_localctx, predIndex); } return true; } + private FStringExpEnd_sempred(_localctx: RuleContext, predIndex: number): boolean { switch (predIndex) { case 0: @@ -503,6 +518,7 @@ export class KipperLexer extends KipperLexerBase { } return true; } + private FStringSingleQuoteExpStart_sempred(_localctx: RuleContext, predIndex: number): boolean { switch (predIndex) { case 1: @@ -510,6 +526,7 @@ export class KipperLexer extends KipperLexerBase { } return true; } + private FStringDoubleQuoteExpStart_sempred(_localctx: RuleContext, predIndex: number): boolean { switch (predIndex) { case 2: @@ -520,7 +537,7 @@ export class KipperLexer extends KipperLexerBase { private static readonly _serializedATNSegments: number = 2; private static readonly _serializedATNSegment0: string = - "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x02V\u02E0\b\x01" + + "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x02X\u02F4\b\x01" + "\b\x01\b\x01\x04\x02\t\x02\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04" + "\x06\t\x06\x04\x07\t\x07\x04\b\t\b\x04\t\t\t\x04\n\t\n\x04\v\t\v\x04\f" + "\t\f\x04\r\t\r\x04\x0E\t\x0E\x04\x0F\t\x0F\x04\x10\t\x10\x04\x11\t\x11" + @@ -536,337 +553,346 @@ export class KipperLexer extends KipperLexerBase { "V\tV\x04W\tW\x04X\tX\x04Y\tY\x04Z\tZ\x04[\t[\x04\\\t\\\x04]\t]\x04^\t" + "^\x04_\t_\x04`\t`\x04a\ta\x04b\tb\x04c\tc\x04d\td\x04e\te\x04f\tf\x04" + "g\tg\x04h\th\x04i\ti\x04j\tj\x04k\tk\x04l\tl\x04m\tm\x04n\tn\x04o\to\x04" + - "p\tp\x04q\tq\x04r\tr\x04s\ts\x04t\tt\x04u\tu\x03\x02\x03\x02\x03\x02\x03" + - "\x02\x07\x02\xF2\n\x02\f\x02\x0E\x02\xF5\v\x02\x03\x02\x03\x02\x03\x02" + - "\x03\x02\x03\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03" + - "\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\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\x06\x03\x06\x03\x06\x03\x06\x03\x07\x03\x07\x03\x07\x03\b\x03\b\x03" + - "\b\x03\b\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\v\x03\v\x03\v\x03\f\x03\f\x03" + - "\f\x03\f\x03\f\x03\f\x03\r\x03\r\x03\r\x03\r\x03\r\x03\r\x03\r\x03\r\x03" + - "\r\x03\x0E\x03\x0E\x03\x0E\x03\x0F\x03\x0F\x03\x0F\x03\x0F\x03\x0F\x03" + - "\x0F\x03\x10\x03\x10\x03\x10\x03\x11\x03\x11\x03\x11\x03\x11\x03\x11\x03" + - "\x12\x03\x12\x03\x12\x03\x12\x03\x13\x03\x13\x03\x13\x03\x13\x03\x13\x03" + - "\x14\x03\x14\x03\x14\x03\x14\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\x17\x03\x17\x03" + - "\x17\x03\x18\x03\x18\x03\x18\x03\x18\x03\x18\x03\x19\x03\x19\x03\x19\x03" + - "\x19\x03\x19\x03\x19\x03\x1A\x03\x1A\x03\x1A\x03\x1A\x03\x1A\x03\x1A\x03" + - "\x1A\x03\x1B\x03\x1B\x03\x1B\x03\x1B\x03\x1B\x03\x1C\x03\x1C\x03\x1C\x03" + - "\x1C\x03\x1C\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03" + - "\x1D\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&\x03&\x03&\x03' + - "'\x03'\x03(\x03(\x03)\x03)\x03*\x03*\x03*\x03+\x03+\x03,\x03,\x03,\x03" + - "-\x03-\x03.\x03.\x03/\x03/\x030\x030\x030\x031\x031\x031\x032\x032\x03" + - "2\x033\x033\x034\x034\x035\x035\x035\x036\x036\x036\x037\x037\x037\x03" + - "8\x038\x038\x039\x039\x039\x03:\x03:\x03:\x03;\x03;\x03;\x03<\x03<\x03" + - "=\x03=\x03=\x03>\x03>\x03?\x03?\x03?\x03@\x03@\x03A\x03A\x03B\x03B\x03" + - "C\x03C\x03D\x03D\x03D\x03E\x03E\x03E\x03F\x03F\x03F\x03F\x03G\x03G\x03" + - "H\x03H\x03H\x07H\u0202\nH\fH\x0EH\u0205\vH\x03I\x03I\x03I\x03I\x05I\u020B" + - "\nI\x03J\x03J\x05J\u020F\nJ\x03J\x03J\x03K\x03K\x05K\u0215\nK\x03K\x03" + - "K\x03L\x03L\x03M\x06M\u021C\nM\rM\x0EM\u021D\x03M\x03M\x03N\x03N\x03N" + - "\x03N\x03O\x03O\x03O\x03O\x03O\x03O\x03O\x03P\x03P\x03P\x03P\x03P\x03" + - "P\x03P\x03Q\x03Q\x03Q\x03Q\x03Q\x03Q\x03R\x03R\x03R\x03R\x03R\x03S\x03" + - "S\x03T\x03T\x03T\x03T\x03T\x03T\x03U\x03U\x03U\x03U\x03U\x03V\x03V\x03" + - "W\x03W\x03X\x03X\x03Y\x03Y\x03Z\x06Z\u0255\nZ\rZ\x0EZ\u0256\x03[\x03[" + - "\x03[\x06[\u025C\n[\r[\x0E[\u025D\x03\\\x03\\\x03\\\x06\\\u0263\n\\\r" + - "\\\x0E\\\u0264\x03]\x03]\x03]\x06]\u026A\n]\r]\x0E]\u026B\x03^\x03^\x03" + - "_\x03_\x03`\x03`\x03a\x03a\x03b\x03b\x05b\u0278\nb\x03b\x03b\x03b\x05" + - "b\u027D\nb\x03c\x05c\u0280\nc\x03c\x03c\x03c\x03c\x03c\x05c\u0287\nc\x03" + - "d\x03d\x05d\u028B\nd\x03d\x03d\x03e\x06e\u0290\ne\re\x0Ee\u0291\x03f\x03" + - "f\x03g\x06g\u0297\ng\rg\x0Eg\u0298\x03h\x03h\x05h\u029D\nh\x03i\x03i\x03" + - "i\x05i\u02A2\ni\x03j\x03j\x03j\x03k\x03k\x03k\x05k\u02AA\nk\x03k\x05k" + - "\u02AD\nk\x03l\x03l\x03l\x03l\x06l\u02B3\nl\rl\x0El\u02B4\x03m\x06m\u02B8" + - "\nm\rm\x0Em\u02B9\x03n\x03n\x05n\u02BE\nn\x03o\x06o\u02C1\no\ro\x0Eo\u02C2" + - "\x03p\x03p\x05p\u02C7\np\x03q\x06q\u02CA\nq\rq\x0Eq\u02CB\x03r\x03r\x05" + - "r\u02D0\nr\x03s\x06s\u02D3\ns\rs\x0Es\u02D4\x03t\x03t\x05t\u02D9\nt\x03" + - "u\x07u\u02DC\nu\fu\x0Eu\u02DF\vu\x03\xF3\x02\x02v\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)Q\x02*S\x02+U\x02,W\x02-Y\x02" + - ".[\x02/]\x020_\x021a\x022c\x023e\x024g\x025i\x026k\x027m\x028o\x029q\x02" + - ":s\x02;u\x02{\x02?}\x02@\x7F\x02A\x81\x02B\x83\x02C\x85\x02" + - "D\x87\x02E\x89\x02F\x8B\x02G\x8D\x02H\x8F\x02I\x91\x02J\x93\x02K\x95\x02" + - "L\x97\x02M\x99\x02N\x9B\x02O\x9D\x02P\x9F\x02Q\xA1\x02R\xA3\x02\x02\xA5" + - "\x02S\xA7\x02T\xA9\x02\x02\xAB\x02U\xAD\x02V\xAF\x02\x02\xB1\x02\x02\xB3" + - "\x02\x02\xB5\x02\x02\xB7\x02\x02\xB9\x02\x02\xBB\x02\x02\xBD\x02\x02\xBF" + - "\x02\x02\xC1\x02\x02\xC3\x02\x02\xC5\x02\x02\xC7\x02\x02\xC9\x02\x02\xCB" + - "\x02\x02\xCD\x02\x02\xCF\x02\x02\xD1\x02\x02\xD3\x02\x02\xD5\x02\x02\xD7" + - "\x02\x02\xD9\x02\x02\xDB\x02\x02\xDD\x02\x02\xDF\x02\x02\xE1\x02\x02\xE3" + - "\x02\x02\xE5\x02\x02\xE7\x02\x02\xE9\x02\x02\xEB\x02\x02\x05\x02\x03\x04" + - '\x14\x06\x02\v\v\r\x0E""\xA2\xA2\x05\x02\f\f\x0F\x0F\u202A\u202B\x05' + - "\x02C\\aac|\x03\x022;\x04\x02DDdd\x04\x02QQqq\x04\x02ZZzz\x03\x023;\x03" + - "\x0223\x03\x0229\x05\x022;CHch\x04\x02GGgg\x04\x02--//\x06\x02\f\f\x0F" + - "\x0F))^^\x0E\x02$$))AA^^cdhhppttvvxx}}\x7F\x7F\b\x02\f\f\x0F\x0F))^^}" + - "}\x7F\x7F\b\x02\f\f\x0F\x0F$$^^}}\x7F\x7F\x06\x02\f\f\x0F\x0F$$^^\x02" + - "\u02E1\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\x025\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\x02" + - "K\x03\x02\x02\x02\x02M\x03\x02\x02\x02\x02O\x03\x02\x02\x02\x02Q\x03\x02" + - "\x02\x02\x02S\x03\x02\x02\x02\x02U\x03\x02\x02\x02\x02W\x03\x02\x02\x02" + - "\x02Y\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\x02" + - "m\x03\x02\x02\x02\x02o\x03\x02\x02\x02\x02q\x03\x02\x02\x02\x02s\x03\x02" + - "\x02\x02\x02u\x03\x02\x02\x02\x02w\x03\x02\x02\x02\x02y\x03\x02\x02\x02" + - "\x02{\x03\x02\x02\x02\x02}\x03\x02\x02\x02\x02\x7F\x03\x02\x02\x02\x02" + - "\x81\x03\x02\x02\x02\x02\x83\x03\x02\x02\x02\x02\x85\x03\x02\x02\x02\x02" + - "\x87\x03\x02\x02\x02\x02\x89\x03\x02\x02\x02\x02\x8B\x03\x02\x02\x02\x02" + - "\x8D\x03\x02\x02\x02\x02\x8F\x03\x02\x02\x02\x02\x91\x03\x02\x02\x02\x02" + - "\x93\x03\x02\x02\x02\x02\x95\x03\x02\x02\x02\x02\x97\x03\x02\x02\x02\x02" + - "\x99\x03\x02\x02\x02\x02\x9B\x03\x02\x02\x02\x02\x9D\x03\x02\x02\x02\x02" + - "\x9F\x03\x02\x02\x02\x02\xA1\x03\x02\x02\x02\x03\xA3\x03\x02\x02\x02\x03" + - "\xA5\x03\x02\x02\x02\x03\xA7\x03\x02\x02\x02\x04\xA9\x03\x02\x02\x02\x04" + - "\xAB\x03\x02\x02\x02\x04\xAD\x03\x02\x02\x02\x05\xED\x03\x02\x02\x02\x07" + - "\xFB\x03\x02\x02\x02\t\u0102\x03\x02\x02\x02\v\u010E\x03\x02\x02\x02\r" + - "\u0114\x03\x02\x02\x02\x0F\u0118\x03\x02\x02\x02\x11\u011B\x03\x02\x02" + - "\x02\x13\u011F\x03\x02\x02\x02\x15\u0126\x03\x02\x02\x02\x17\u012B\x03" + - "\x02\x02\x02\x19\u0133\x03\x02\x02\x02\x1B\u0139\x03\x02\x02\x02\x1D\u0142" + - "\x03\x02\x02\x02\x1F\u0145\x03\x02\x02\x02!\u014B\x03\x02\x02\x02#\u014E" + - "\x03\x02\x02\x02%\u0153\x03\x02\x02\x02'\u0157\x03\x02\x02\x02)\u015C" + - "\x03\x02\x02\x02+\u0160\x03\x02\x02\x02-\u0167\x03\x02\x02\x02/\u016C" + - "\x03\x02\x02\x021\u016F\x03\x02\x02\x023\u0174\x03\x02\x02\x025\u017A" + - "\x03\x02\x02\x027\u0181\x03\x02\x02\x029\u0186\x03\x02\x02\x02;\u018B" + - "\x03\x02\x02\x02=\u0195\x03\x02\x02\x02?\u0197\x03\x02\x02\x02A\u0199" + - "\x03\x02\x02\x02C\u019B\x03\x02\x02\x02E\u019D\x03\x02\x02\x02G\u019F" + - "\x03\x02\x02\x02I\u01A1\x03\x02\x02\x02K\u01A3\x03\x02\x02\x02M\u01A5" + - "\x03\x02\x02\x02O\u01AA\x03\x02\x02\x02Q\u01AC\x03\x02\x02\x02S\u01AE" + - "\x03\x02\x02\x02U\u01B0\x03\x02\x02\x02W\u01B3\x03\x02\x02\x02Y\u01B5" + - "\x03\x02\x02\x02[\u01B8\x03\x02\x02\x02]\u01BA\x03\x02\x02\x02_\u01BC" + - "\x03\x02\x02\x02a\u01BE\x03\x02\x02\x02c\u01C1\x03\x02\x02\x02e\u01C4" + - "\x03\x02\x02\x02g\u01C7\x03\x02\x02\x02i\u01C9\x03\x02\x02\x02k\u01CB" + - "\x03\x02\x02\x02m\u01CE\x03\x02\x02\x02o\u01D1\x03\x02\x02\x02q\u01D4" + - "\x03\x02\x02\x02s\u01D7\x03\x02\x02\x02u\u01DA\x03\x02\x02\x02w\u01DD" + - "\x03\x02\x02\x02y\u01E0\x03\x02\x02\x02{\u01E2\x03\x02\x02\x02}\u01E5" + - "\x03\x02\x02\x02\x7F\u01E7\x03\x02\x02\x02\x81\u01EA\x03\x02\x02\x02\x83" + - "\u01EC\x03\x02\x02\x02\x85\u01EE\x03\x02\x02\x02\x87\u01F0\x03\x02\x02" + - "\x02\x89\u01F2\x03\x02\x02\x02\x8B\u01F5\x03\x02\x02\x02\x8D\u01F8\x03" + - "\x02\x02\x02\x8F\u01FC\x03\x02\x02\x02\x91\u01FE\x03\x02\x02\x02\x93\u020A" + - "\x03\x02\x02\x02\x95\u020C\x03\x02\x02\x02\x97\u0212\x03\x02\x02\x02\x99" + - "\u0218\x03\x02\x02\x02\x9B\u021B\x03\x02\x02\x02\x9D\u0221\x03\x02\x02" + - "\x02\x9F\u0225\x03\x02\x02\x02\xA1\u022C\x03\x02\x02\x02\xA3\u0233\x03" + - "\x02\x02\x02\xA5\u0239\x03\x02\x02\x02\xA7\u023E\x03\x02\x02\x02\xA9\u0240" + - "\x03\x02\x02\x02\xAB\u0246\x03\x02\x02\x02\xAD\u024B\x03\x02\x02\x02\xAF" + - "\u024D\x03\x02\x02\x02\xB1\u024F\x03\x02\x02\x02\xB3\u0251\x03\x02\x02" + - "\x02\xB5\u0254\x03\x02\x02\x02\xB7\u0258\x03\x02\x02\x02\xB9\u025F\x03" + - "\x02\x02\x02\xBB\u0266\x03\x02\x02\x02\xBD\u026D\x03\x02\x02\x02\xBF\u026F" + - "\x03\x02\x02\x02\xC1\u0271\x03\x02\x02\x02\xC3\u0273\x03\x02\x02\x02\xC5" + - "\u027C\x03\x02\x02\x02\xC7\u0286\x03\x02\x02\x02\xC9\u0288\x03\x02\x02" + - "\x02\xCB\u028F\x03\x02\x02\x02\xCD\u0293\x03\x02\x02\x02\xCF\u0296\x03" + - "\x02\x02\x02\xD1\u029C\x03\x02\x02\x02\xD3\u02A1\x03\x02\x02\x02\xD5\u02A3" + - "\x03\x02\x02\x02\xD7\u02A6\x03\x02\x02\x02\xD9\u02AE\x03\x02\x02\x02\xDB" + - "\u02B7\x03\x02\x02\x02\xDD\u02BD\x03\x02\x02\x02\xDF\u02C0\x03\x02\x02" + - "\x02\xE1\u02C6\x03\x02\x02\x02\xE3\u02C9\x03\x02\x02\x02\xE5\u02CF\x03" + - "\x02\x02\x02\xE7\u02D2\x03\x02\x02\x02\xE9\u02D8\x03\x02\x02\x02\xEB\u02DD" + - "\x03\x02\x02\x02\xED\xEE\x071\x02\x02\xEE\xEF\x07,\x02\x02\xEF\xF3\x03" + - "\x02\x02\x02\xF0\xF2\v\x02\x02\x02\xF1\xF0\x03\x02\x02\x02\xF2\xF5\x03" + - "\x02\x02\x02\xF3\xF4\x03\x02\x02\x02\xF3\xF1\x03\x02\x02\x02\xF4\xF6\x03" + - "\x02\x02\x02\xF5\xF3\x03\x02\x02\x02\xF6\xF7\x07,\x02\x02\xF7\xF8\x07" + - "1\x02\x02\xF8\xF9\x03\x02\x02\x02\xF9\xFA\b\x02\x02\x02\xFA\x06\x03\x02" + - "\x02\x02\xFB\xFC\x071\x02\x02\xFC\xFD\x071\x02\x02\xFD\xFE\x03\x02\x02" + - "\x02\xFE\xFF\x05\xEBu\x02\xFF\u0100\x03\x02\x02\x02\u0100\u0101\b\x03" + - "\x02\x02\u0101\b\x03\x02\x02\x02\u0102\u0103\x07%\x02\x02\u0103\u0104" + - "\x07r\x02\x02\u0104\u0105\x07t\x02\x02\u0105\u0106\x07c\x02\x02\u0106" + - "\u0107\x07i\x02\x02\u0107\u0108\x07o\x02\x02\u0108\u0109\x07c\x02\x02" + - "\u0109\u010A\x03\x02\x02\x02\u010A\u010B\x05\xEBu\x02\u010B\u010C\x03" + - "\x02\x02\x02\u010C\u010D\b\x04\x03\x02\u010D\n\x03\x02\x02\x02\u010E\u010F" + - "\x07e\x02\x02\u010F\u0110\x07q\x02\x02\u0110\u0111\x07p\x02\x02\u0111" + - "\u0112\x07u\x02\x02\u0112\u0113\x07v\x02\x02\u0113\f\x03\x02\x02\x02\u0114" + - "\u0115\x07x\x02\x02\u0115\u0116\x07c\x02\x02\u0116\u0117\x07t\x02\x02" + - "\u0117\x0E\x03\x02\x02\x02\u0118\u0119\x07c\x02\x02\u0119\u011A\x07u\x02" + - "\x02\u011A\x10\x03\x02\x02\x02\u011B\u011C\x070\x02\x02\u011C\u011D\x07" + - "0\x02\x02\u011D\u011E\x070\x02\x02\u011E\x12\x03\x02\x02\x02\u011F\u0120" + - "\x07u\x02\x02\u0120\u0121\x07y\x02\x02\u0121\u0122\x07k\x02\x02\u0122" + - "\u0123\x07v\x02\x02\u0123\u0124\x07e\x02\x02\u0124\u0125\x07j\x02\x02" + - "\u0125\x14\x03\x02\x02\x02\u0126\u0127\x07e\x02\x02\u0127\u0128\x07c\x02" + - "\x02\u0128\u0129\x07u\x02\x02\u0129\u012A\x07g\x02\x02\u012A\x16\x03\x02" + - "\x02\x02\u012B\u012C\x07f\x02\x02\u012C\u012D\x07g\x02\x02\u012D\u012E" + - "\x07h\x02\x02\u012E\u012F\x07c\x02\x02\u012F\u0130\x07w\x02\x02\u0130" + - "\u0131\x07n\x02\x02\u0131\u0132\x07v\x02\x02\u0132\x18\x03\x02\x02\x02" + - "\u0133\u0134\x07d\x02\x02\u0134\u0135\x07t\x02\x02\u0135\u0136\x07g\x02" + - "\x02\u0136\u0137\x07c\x02\x02\u0137\u0138\x07m\x02\x02\u0138\x1A\x03\x02" + - "\x02\x02\u0139\u013A\x07e\x02\x02\u013A\u013B\x07q\x02\x02\u013B\u013C" + - "\x07p\x02\x02\u013C\u013D\x07v\x02\x02\u013D\u013E\x07k\x02\x02\u013E" + - "\u013F\x07p\x02\x02\u013F\u0140\x07w\x02\x02\u0140\u0141\x07g\x02\x02" + - "\u0141\x1C\x03\x02\x02\x02\u0142\u0143\x07f\x02\x02\u0143\u0144\x07q\x02" + - "\x02\u0144\x1E\x03\x02\x02\x02\u0145\u0146\x07y\x02\x02\u0146\u0147\x07" + - "j\x02\x02\u0147\u0148\x07k\x02\x02\u0148\u0149\x07n\x02\x02\u0149\u014A" + - "\x07g\x02\x02\u014A \x03\x02\x02\x02\u014B\u014C\x07k\x02\x02\u014C\u014D" + - '\x07h\x02\x02\u014D"\x03\x02\x02\x02\u014E\u014F\x07g\x02\x02\u014F\u0150' + - "\x07n\x02\x02\u0150\u0151\x07u\x02\x02\u0151\u0152\x07g\x02\x02\u0152" + - "$\x03\x02\x02\x02\u0153\u0154\x07h\x02\x02\u0154\u0155\x07q\x02\x02\u0155" + - "\u0156\x07t\x02\x02\u0156&\x03\x02\x02\x02\u0157\u0158\x07g\x02\x02\u0158" + - "\u0159\x07p\x02\x02\u0159\u015A\x07w\x02\x02\u015A\u015B\x07o\x02\x02" + - "\u015B(\x03\x02\x02\x02\u015C\u015D\x07f\x02\x02\u015D\u015E\x07g\x02" + - "\x02\u015E\u015F\x07h\x02\x02\u015F*\x03\x02\x02\x02\u0160\u0161\x07t" + - "\x02\x02\u0161\u0162\x07g\x02\x02\u0162\u0163\x07v\x02\x02\u0163\u0164" + - "\x07w\x02\x02\u0164\u0165\x07t\x02\x02\u0165\u0166\x07p\x02\x02\u0166" + - ",\x03\x02\x02\x02\u0167\u0168\x07e\x02\x02\u0168\u0169\x07c\x02\x02\u0169" + - "\u016A\x07n\x02\x02\u016A\u016B\x07n\x02\x02\u016B.\x03\x02\x02\x02\u016C" + - "\u016D\x07/\x02\x02\u016D\u016E\x07@\x02\x02\u016E0\x03\x02\x02\x02\u016F" + - "\u0170\x07v\x02\x02\u0170\u0171\x07t\x02\x02\u0171\u0172\x07w\x02\x02" + - "\u0172\u0173\x07g\x02\x02\u01732\x03\x02\x02\x02\u0174\u0175\x07h\x02" + - "\x02\u0175\u0176\x07c\x02\x02\u0176\u0177\x07n\x02\x02\u0177\u0178\x07" + - "u\x02\x02\u0178\u0179\x07g\x02\x02\u01794\x03\x02\x02\x02\u017A\u017B" + - "\x07v\x02\x02\u017B\u017C\x07{\x02\x02\u017C\u017D\x07r\x02\x02\u017D" + - "\u017E\x07g\x02\x02\u017E\u017F\x07q\x02\x02\u017F\u0180\x07h\x02\x02" + - "\u01806\x03\x02\x02\x02\u0181\u0182\x07x\x02\x02\u0182\u0183\x07q\x02" + - "\x02\u0183\u0184\x07k\x02\x02\u0184\u0185\x07f\x02\x02\u01858\x03\x02" + - "\x02\x02\u0186\u0187\x07p\x02\x02\u0187\u0188\x07w\x02\x02\u0188\u0189" + - "\x07n\x02\x02\u0189\u018A\x07n\x02\x02\u018A:\x03\x02\x02\x02\u018B\u018C" + - "\x07w\x02\x02\u018C\u018D\x07p\x02\x02\u018D\u018E\x07f\x02\x02\u018E" + - "\u018F\x07g\x02\x02\u018F\u0190\x07h\x02\x02\u0190\u0191\x07k\x02\x02" + - "\u0191\u0192\x07p\x02\x02\u0192\u0193\x07g\x02\x02\u0193\u0194\x07f\x02" + - "\x02\u0194<\x03\x02\x02\x02\u0195\u0196\x07.\x02\x02\u0196>\x03\x02\x02" + - "\x02\u0197\u0198\x07=\x02\x02\u0198@\x03\x02\x02\x02\u0199\u019A\x07A" + - "\x02\x02\u019AB\x03\x02\x02\x02\u019B\u019C\x07<\x02\x02\u019CD\x03\x02" + - "\x02\x02\u019D\u019E\x07*\x02\x02\u019EF\x03\x02\x02\x02\u019F\u01A0\x07" + - "+\x02\x02\u01A0H\x03\x02\x02\x02\u01A1\u01A2\x07]\x02\x02\u01A2J\x03\x02" + - "\x02\x02\u01A3\u01A4\x07_\x02\x02\u01A4L\x03\x02\x02\x02\u01A5\u01A6\x06" + - "&\x02\x02\u01A6\u01A7\x07\x7F\x02\x02\u01A7\u01A8\x03\x02\x02\x02\u01A8" + - "\u01A9\b&\x04\x02\u01A9N\x03\x02\x02\x02\u01AA\u01AB\x07}\x02\x02\u01AB" + - "P\x03\x02\x02\x02\u01AC\u01AD\x07\x7F\x02\x02\u01ADR\x03\x02\x02\x02\u01AE" + - "\u01AF\x07-\x02\x02\u01AFT\x03\x02\x02\x02\u01B0\u01B1\x07-\x02\x02\u01B1" + - "\u01B2\x07-\x02\x02\u01B2V\x03\x02\x02\x02\u01B3\u01B4\x07/\x02\x02\u01B4" + - "X\x03\x02\x02\x02\u01B5\u01B6\x07/\x02\x02\u01B6\u01B7\x07/\x02\x02\u01B7" + - "Z\x03\x02\x02\x02\u01B8\u01B9\x07,\x02\x02\u01B9\\\x03\x02\x02\x02\u01BA" + - "\u01BB\x071\x02\x02\u01BB^\x03\x02\x02\x02\u01BC\u01BD\x07'\x02\x02\u01BD" + - "`\x03\x02\x02\x02\u01BE\u01BF\x07,\x02\x02\u01BF\u01C0\x07,\x02\x02\u01C0" + - "b\x03\x02\x02\x02\u01C1\u01C2\x07(\x02\x02\u01C2\u01C3\x07(\x02\x02\u01C3" + - "d\x03\x02\x02\x02\u01C4\u01C5\x07~\x02\x02\u01C5\u01C6\x07~\x02\x02\u01C6" + - "f\x03\x02\x02\x02\u01C7\u01C8\x07#\x02\x02\u01C8h\x03\x02\x02\x02\u01C9" + - "\u01CA\x07?\x02\x02\u01CAj\x03\x02\x02\x02\u01CB\u01CC\x07-\x02\x02\u01CC" + - "\u01CD\x07?\x02\x02\u01CDl\x03\x02\x02\x02\u01CE\u01CF\x07/\x02\x02\u01CF" + - "\u01D0\x07?\x02\x02\u01D0n\x03\x02\x02\x02\u01D1\u01D2\x07,\x02\x02\u01D2" + - "\u01D3\x07?\x02\x02\u01D3p\x03\x02\x02\x02\u01D4\u01D5\x071\x02\x02\u01D5" + - "\u01D6\x07?\x02\x02\u01D6r\x03\x02\x02\x02\u01D7\u01D8\x07'\x02\x02\u01D8" + - "\u01D9\x07?\x02\x02\u01D9t\x03\x02\x02\x02\u01DA\u01DB\x07?\x02\x02\u01DB" + - "\u01DC\x07?\x02\x02\u01DCv\x03\x02\x02\x02\u01DD\u01DE\x07#\x02\x02\u01DE" + - "\u01DF\x07?\x02\x02\u01DFx\x03\x02\x02\x02\u01E0\u01E1\x07>\x02\x02\u01E1" + - "z\x03\x02\x02\x02\u01E2\u01E3\x07>\x02\x02\u01E3\u01E4\x07?\x02\x02\u01E4" + - "|\x03\x02\x02\x02\u01E5\u01E6\x07@\x02\x02\u01E6~\x03\x02\x02\x02\u01E7" + - "\u01E8\x07@\x02\x02\u01E8\u01E9\x07?\x02\x02\u01E9\x80\x03\x02\x02\x02" + - "\u01EA\u01EB\x07(\x02\x02\u01EB\x82\x03\x02\x02\x02\u01EC\u01ED\x07~\x02" + - "\x02\u01ED\x84\x03\x02\x02\x02\u01EE\u01EF\x07`\x02\x02\u01EF\x86\x03" + - "\x02\x02\x02\u01F0\u01F1\x07\x80\x02\x02\u01F1\x88\x03\x02\x02\x02\u01F2" + - "\u01F3\x07>\x02\x02\u01F3\u01F4\x07>\x02\x02\u01F4\x8A\x03\x02\x02\x02" + - "\u01F5\u01F6\x07@\x02\x02\u01F6\u01F7\x07@\x02\x02\u01F7\x8C\x03\x02\x02" + - "\x02\u01F8\u01F9\x07@\x02\x02\u01F9\u01FA\x07@\x02\x02\u01FA\u01FB\x07" + - "@\x02\x02\u01FB\x8E\x03\x02\x02\x02\u01FC\u01FD\x070\x02\x02\u01FD\x90" + - "\x03\x02\x02\x02\u01FE\u0203\x05\xAFW\x02\u01FF\u0202\x05\xAFW\x02\u0200" + - "\u0202\x05\xB3Y\x02\u0201\u01FF\x03\x02\x02\x02\u0201\u0200\x03\x02\x02" + - "\x02\u0202\u0205\x03\x02\x02\x02\u0203\u0201\x03\x02\x02\x02\u0203\u0204" + - "\x03\x02\x02\x02\u0204\x92\x03\x02\x02\x02\u0205\u0203\x03\x02\x02\x02" + - "\u0206\u020B\x05\xB5Z\x02\u0207\u020B\x05\xB9\\\x02\u0208\u020B\x05\xBB" + - "]\x02\u0209\u020B\x05\xB7[\x02\u020A\u0206\x03\x02\x02\x02\u020A\u0207" + - "\x03\x02\x02\x02\u020A\u0208\x03\x02\x02\x02\u020A\u0209\x03\x02\x02\x02" + - "\u020B\x94"; + "p\tp\x04q\tq\x04r\tr\x04s\ts\x04t\tt\x04u\tu\x04v\tv\x04w\tw\x03\x02\x03" + + "\x02\x03\x02\x03\x02\x07\x02\xF6\n\x02\f\x02\x0E\x02\xF9\v\x02\x03\x02" + + "\x03\x02\x03\x02\x03\x02\x03\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03" + + "\x03\x03\x03\x03\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\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\x06\x03\x06\x03\x06\x03\x06\x03\x07\x03\x07\x03\x07" + + "\x03\b\x03\b\x03\b\x03\b\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\v\x03\v\x03" + + "\v\x03\f\x03\f\x03\f\x03\f\x03\f\x03\f\x03\r\x03\r\x03\r\x03\r\x03\r\x03" + + "\r\x03\r\x03\r\x03\r\x03\x0E\x03\x0E\x03\x0E\x03\x0F\x03\x0F\x03\x0F\x03" + + "\x0F\x03\x0F\x03\x0F\x03\x10\x03\x10\x03\x10\x03\x11\x03\x11\x03\x11\x03" + + "\x11\x03\x11\x03\x12\x03\x12\x03\x12\x03\x12\x03\x13\x03\x13\x03\x13\x03" + + "\x13\x03\x13\x03\x14\x03\x14\x03\x14\x03\x14\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" + + "\x17\x03\x17\x03\x17\x03\x18\x03\x18\x03\x18\x03\x18\x03\x18\x03\x18\x03" + + "\x19\x03\x19\x03\x19\x03\x19\x03\x19\x03\x19\x03\x19\x03\x19\x03\x19\x03" + + "\x19\x03\x1A\x03\x1A\x03\x1A\x03\x1A\x03\x1A\x03\x1B\x03\x1B\x03\x1B\x03" + + "\x1B\x03\x1B\x03\x1B\x03\x1C\x03\x1C\x03\x1C\x03\x1C\x03\x1C\x03\x1C\x03" + + "\x1C\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1E\x03\x1E\x03\x1E\x03" + + "\x1E\x03\x1E\x03\x1F\x03\x1F\x03\x1F\x03\x1F\x03\x1F\x03\x1F\x03\x1F\x03" + + '\x1F\x03\x1F\x03\x1F\x03 \x03 \x03!\x03!\x03"\x03"\x03#\x03#\x03$\x03' + + "$\x03%\x03%\x03&\x03&\x03'\x03'\x03(\x03(\x03(\x03(\x03(\x03)\x03)\x03" + + "*\x03*\x03+\x03+\x03,\x03,\x03,\x03-\x03-\x03.\x03.\x03.\x03/\x03/\x03" + + "0\x030\x031\x031\x032\x032\x032\x033\x033\x033\x034\x034\x034\x035\x03" + + "5\x036\x036\x037\x037\x037\x038\x038\x038\x039\x039\x039\x03:\x03:\x03" + + ":\x03;\x03;\x03;\x03<\x03<\x03<\x03=\x03=\x03=\x03>\x03>\x03?\x03?\x03" + + "?\x03@\x03@\x03A\x03A\x03A\x03B\x03B\x03C\x03C\x03D\x03D\x03E\x03E\x03" + + "F\x03F\x03F\x03G\x03G\x03G\x03H\x03H\x03H\x03H\x03I\x03I\x03J\x03J\x03" + + "J\x07J\u0216\nJ\fJ\x0EJ\u0219\vJ\x03K\x03K\x03K\x03K\x05K\u021F\nK\x03" + + "L\x03L\x05L\u0223\nL\x03L\x03L\x03M\x03M\x05M\u0229\nM\x03M\x03M\x03N" + + "\x03N\x03O\x06O\u0230\nO\rO\x0EO\u0231\x03O\x03O\x03P\x03P\x03P\x03P\x03" + + "Q\x03Q\x03Q\x03Q\x03Q\x03Q\x03Q\x03R\x03R\x03R\x03R\x03R\x03R\x03R\x03" + + "S\x03S\x03S\x03S\x03S\x03S\x03T\x03T\x03T\x03T\x03T\x03U\x03U\x03V\x03" + + "V\x03V\x03V\x03V\x03V\x03W\x03W\x03W\x03W\x03W\x03X\x03X\x03Y\x03Y\x03" + + "Z\x03Z\x03[\x03[\x03\\\x06\\\u0269\n\\\r\\\x0E\\\u026A\x03]\x03]\x03]" + + "\x06]\u0270\n]\r]\x0E]\u0271\x03^\x03^\x03^\x06^\u0277\n^\r^\x0E^\u0278" + + "\x03_\x03_\x03_\x06_\u027E\n_\r_\x0E_\u027F\x03`\x03`\x03a\x03a\x03b\x03" + + "b\x03c\x03c\x03d\x03d\x05d\u028C\nd\x03d\x03d\x03d\x05d\u0291\nd\x03e" + + "\x05e\u0294\ne\x03e\x03e\x03e\x03e\x03e\x05e\u029B\ne\x03f\x03f\x05f\u029F" + + "\nf\x03f\x03f\x03g\x06g\u02A4\ng\rg\x0Eg\u02A5\x03h\x03h\x03i\x06i\u02AB" + + "\ni\ri\x0Ei\u02AC\x03j\x03j\x05j\u02B1\nj\x03k\x03k\x03k\x05k\u02B6\n" + + "k\x03l\x03l\x03l\x03m\x03m\x03m\x05m\u02BE\nm\x03m\x05m\u02C1\nm\x03n" + + "\x03n\x03n\x03n\x06n\u02C7\nn\rn\x0En\u02C8\x03o\x06o\u02CC\no\ro\x0E" + + "o\u02CD\x03p\x03p\x05p\u02D2\np\x03q\x06q\u02D5\nq\rq\x0Eq\u02D6\x03r" + + "\x03r\x05r\u02DB\nr\x03s\x06s\u02DE\ns\rs\x0Es\u02DF\x03t\x03t\x05t\u02E4" + + "\nt\x03u\x06u\u02E7\nu\ru\x0Eu\u02E8\x03v\x03v\x05v\u02ED\nv\x03w\x07" + + "w\u02F0\nw\fw\x0Ew\u02F3\vw\x03\xF7\x02\x02x\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)Q\x02*S\x02+U\x02,W\x02-Y\x02.[\x02/]" + + "\x020_\x021a\x022c\x023e\x024g\x025i\x026k\x027m\x028o\x029q\x02:s\x02" + + ";u\x02{\x02?}\x02@\x7F\x02A\x81\x02B\x83\x02C\x85\x02D\x87" + + "\x02E\x89\x02F\x8B\x02G\x8D\x02H\x8F\x02I\x91\x02J\x93\x02K\x95\x02L\x97" + + "\x02M\x99\x02N\x9B\x02O\x9D\x02P\x9F\x02Q\xA1\x02R\xA3\x02S\xA5\x02T\xA7" + + "\x02\x02\xA9\x02U\xAB\x02V\xAD\x02\x02\xAF\x02W\xB1\x02X\xB3\x02\x02\xB5" + + "\x02\x02\xB7\x02\x02\xB9\x02\x02\xBB\x02\x02\xBD\x02\x02\xBF\x02\x02\xC1" + + "\x02\x02\xC3\x02\x02\xC5\x02\x02\xC7\x02\x02\xC9\x02\x02\xCB\x02\x02\xCD" + + "\x02\x02\xCF\x02\x02\xD1\x02\x02\xD3\x02\x02\xD5\x02\x02\xD7\x02\x02\xD9" + + "\x02\x02\xDB\x02\x02\xDD\x02\x02\xDF\x02\x02\xE1\x02\x02\xE3\x02\x02\xE5" + + "\x02\x02\xE7\x02\x02\xE9\x02\x02\xEB\x02\x02\xED\x02\x02\xEF\x02\x02\x05" + + '\x02\x03\x04\x14\x06\x02\v\v\r\x0E""\xA2\xA2\x05\x02\f\f\x0F\x0F\u202A' + + "\u202B\x05\x02C\\aac|\x03\x022;\x04\x02DDdd\x04\x02QQqq\x04\x02ZZzz\x03" + + "\x023;\x03\x0223\x03\x0229\x05\x022;CHch\x04\x02GGgg\x04\x02--//\x06\x02" + + "\f\f\x0F\x0F))^^\x0E\x02$$))AA^^cdhhppttvvxx}}\x7F\x7F\b\x02\f\f\x0F\x0F" + + "))^^}}\x7F\x7F\b\x02\f\f\x0F\x0F$$^^}}\x7F\x7F\x06\x02\f\f\x0F\x0F$$^" + + "^\x02\u02F5\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\x025\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\x02O\x03\x02\x02\x02\x02Q\x03" + + "\x02\x02\x02\x02S\x03\x02\x02\x02\x02U\x03\x02\x02\x02\x02W\x03\x02\x02" + + "\x02\x02Y\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\x02o\x03\x02\x02\x02\x02q\x03\x02\x02\x02\x02s\x03" + + "\x02\x02\x02\x02u\x03\x02\x02\x02\x02w\x03\x02\x02\x02\x02y\x03\x02\x02" + + "\x02\x02{\x03\x02\x02\x02\x02}\x03\x02\x02\x02\x02\x7F\x03\x02\x02\x02" + + "\x02\x81\x03\x02\x02\x02\x02\x83\x03\x02\x02\x02\x02\x85\x03\x02\x02\x02" + + "\x02\x87\x03\x02\x02\x02\x02\x89\x03\x02\x02\x02\x02\x8B\x03\x02\x02\x02" + + "\x02\x8D\x03\x02\x02\x02\x02\x8F\x03\x02\x02\x02\x02\x91\x03\x02\x02\x02" + + "\x02\x93\x03\x02\x02\x02\x02\x95\x03\x02\x02\x02\x02\x97\x03\x02\x02\x02" + + "\x02\x99\x03\x02\x02\x02\x02\x9B\x03\x02\x02\x02\x02\x9D\x03\x02\x02\x02" + + "\x02\x9F\x03\x02\x02\x02\x02\xA1\x03\x02\x02\x02\x02\xA3\x03\x02\x02\x02" + + "\x02\xA5\x03\x02\x02\x02\x03\xA7\x03\x02\x02\x02\x03\xA9\x03\x02\x02\x02" + + "\x03\xAB\x03\x02\x02\x02\x04\xAD\x03\x02\x02\x02\x04\xAF\x03\x02\x02\x02" + + "\x04\xB1\x03\x02\x02\x02\x05\xF1\x03\x02\x02\x02\x07\xFF\x03\x02\x02\x02" + + "\t\u0106\x03\x02\x02\x02\v\u0112\x03\x02\x02\x02\r\u0118\x03\x02\x02\x02" + + "\x0F\u011C\x03\x02\x02\x02\x11\u011F\x03\x02\x02\x02\x13\u0123\x03\x02" + + "\x02\x02\x15\u012A\x03\x02\x02\x02\x17\u012F\x03\x02\x02\x02\x19\u0137" + + "\x03\x02\x02\x02\x1B\u013D\x03\x02\x02\x02\x1D\u0146\x03\x02\x02\x02\x1F" + + "\u0149\x03\x02\x02\x02!\u014F\x03\x02\x02\x02#\u0152\x03\x02\x02\x02%" + + "\u0157\x03\x02\x02\x02'\u015B\x03\x02\x02\x02)\u0160\x03\x02\x02\x02" + + "+\u0164\x03\x02\x02\x02-\u016B\x03\x02\x02\x02/\u0170\x03\x02\x02\x02" + + "1\u0173\x03\x02\x02\x023\u0179\x03\x02\x02\x025\u0183\x03\x02\x02\x02" + + "7\u0188\x03\x02\x02\x029\u018E\x03\x02\x02\x02;\u0195\x03\x02\x02\x02" + + "=\u019A\x03\x02\x02\x02?\u019F\x03\x02\x02\x02A\u01A9\x03\x02\x02\x02" + + "C\u01AB\x03\x02\x02\x02E\u01AD\x03\x02\x02\x02G\u01AF\x03\x02\x02\x02" + + "I\u01B1\x03\x02\x02\x02K\u01B3\x03\x02\x02\x02M\u01B5\x03\x02\x02\x02" + + "O\u01B7\x03\x02\x02\x02Q\u01B9\x03\x02\x02\x02S\u01BE\x03\x02\x02\x02" + + "U\u01C0\x03\x02\x02\x02W\u01C2\x03\x02\x02\x02Y\u01C4\x03\x02\x02\x02" + + "[\u01C7\x03\x02\x02\x02]\u01C9\x03\x02\x02\x02_\u01CC\x03\x02\x02\x02" + + "a\u01CE\x03\x02\x02\x02c\u01D0\x03\x02\x02\x02e\u01D2\x03\x02\x02\x02" + + "g\u01D5\x03\x02\x02\x02i\u01D8\x03\x02\x02\x02k\u01DB\x03\x02\x02\x02" + + "m\u01DD\x03\x02\x02\x02o\u01DF\x03\x02\x02\x02q\u01E2\x03\x02\x02\x02" + + "s\u01E5\x03\x02\x02\x02u\u01E8\x03\x02\x02\x02w\u01EB\x03\x02\x02\x02" + + "y\u01EE\x03\x02\x02\x02{\u01F1\x03\x02\x02\x02}\u01F4\x03\x02\x02\x02" + + "\x7F\u01F6\x03\x02\x02\x02\x81\u01F9\x03\x02\x02\x02\x83\u01FB\x03\x02" + + "\x02\x02\x85\u01FE\x03\x02\x02\x02\x87\u0200\x03\x02\x02\x02\x89\u0202" + + "\x03\x02\x02\x02\x8B\u0204\x03\x02\x02\x02\x8D\u0206\x03\x02\x02\x02\x8F" + + "\u0209\x03\x02\x02\x02\x91\u020C\x03\x02\x02\x02\x93\u0210\x03\x02\x02" + + "\x02\x95\u0212\x03\x02\x02\x02\x97\u021E\x03\x02\x02\x02\x99\u0220\x03" + + "\x02\x02\x02\x9B\u0226\x03\x02\x02\x02\x9D\u022C\x03\x02\x02\x02\x9F\u022F" + + "\x03\x02\x02\x02\xA1\u0235\x03\x02\x02\x02\xA3\u0239\x03\x02\x02\x02\xA5" + + "\u0240\x03\x02\x02\x02\xA7\u0247\x03\x02\x02\x02\xA9\u024D\x03\x02\x02" + + "\x02\xAB\u0252\x03\x02\x02\x02\xAD\u0254\x03\x02\x02\x02\xAF\u025A\x03" + + "\x02\x02\x02\xB1\u025F\x03\x02\x02\x02\xB3\u0261\x03\x02\x02\x02\xB5\u0263" + + "\x03\x02\x02\x02\xB7\u0265\x03\x02\x02\x02\xB9\u0268\x03\x02\x02\x02\xBB" + + "\u026C\x03\x02\x02\x02\xBD\u0273\x03\x02\x02\x02\xBF\u027A\x03\x02\x02" + + "\x02\xC1\u0281\x03\x02\x02\x02\xC3\u0283\x03\x02\x02\x02\xC5\u0285\x03" + + "\x02\x02\x02\xC7\u0287\x03\x02\x02\x02\xC9\u0290\x03\x02\x02\x02\xCB\u029A" + + "\x03\x02\x02\x02\xCD\u029C\x03\x02\x02\x02\xCF\u02A3\x03\x02\x02\x02\xD1" + + "\u02A7\x03\x02\x02\x02\xD3\u02AA\x03\x02\x02\x02\xD5\u02B0\x03\x02\x02" + + "\x02\xD7\u02B5\x03\x02\x02\x02\xD9\u02B7\x03\x02\x02\x02\xDB\u02BA\x03" + + "\x02\x02\x02\xDD\u02C2\x03\x02\x02\x02\xDF\u02CB\x03\x02\x02\x02\xE1\u02D1" + + "\x03\x02\x02\x02\xE3\u02D4\x03\x02\x02\x02\xE5\u02DA\x03\x02\x02\x02\xE7" + + "\u02DD\x03\x02\x02\x02\xE9\u02E3\x03\x02\x02\x02\xEB\u02E6\x03\x02\x02" + + "\x02\xED\u02EC\x03\x02\x02\x02\xEF\u02F1\x03\x02\x02\x02\xF1\xF2\x071" + + "\x02\x02\xF2\xF3\x07,\x02\x02\xF3\xF7\x03\x02\x02\x02\xF4\xF6\v\x02\x02" + + "\x02\xF5\xF4\x03\x02\x02\x02\xF6\xF9\x03\x02\x02\x02\xF7\xF8\x03\x02\x02" + + "\x02\xF7\xF5\x03\x02\x02\x02\xF8\xFA\x03\x02\x02\x02\xF9\xF7\x03\x02\x02" + + "\x02\xFA\xFB\x07,\x02\x02\xFB\xFC\x071\x02\x02\xFC\xFD\x03\x02\x02\x02" + + "\xFD\xFE\b\x02\x02\x02\xFE\x06\x03\x02\x02\x02\xFF\u0100\x071\x02\x02" + + "\u0100\u0101\x071\x02\x02\u0101\u0102\x03\x02\x02\x02\u0102\u0103\x05" + + "\xEFw\x02\u0103\u0104\x03\x02\x02\x02\u0104\u0105\b\x03\x02\x02\u0105" + + "\b\x03\x02\x02\x02\u0106\u0107\x07%\x02\x02\u0107\u0108\x07r\x02\x02\u0108" + + "\u0109\x07t\x02\x02\u0109\u010A\x07c\x02\x02\u010A\u010B\x07i\x02\x02" + + "\u010B\u010C\x07o\x02\x02\u010C\u010D\x07c\x02\x02\u010D\u010E\x03\x02" + + "\x02\x02\u010E\u010F\x05\xEFw\x02\u010F\u0110\x03\x02\x02\x02\u0110\u0111" + + "\b\x04\x03\x02\u0111\n\x03\x02\x02\x02\u0112\u0113\x07e\x02\x02\u0113" + + "\u0114\x07q\x02\x02\u0114\u0115\x07p\x02\x02\u0115\u0116\x07u\x02\x02" + + "\u0116\u0117\x07v\x02\x02\u0117\f\x03\x02\x02\x02\u0118\u0119\x07x\x02" + + "\x02\u0119\u011A\x07c\x02\x02\u011A\u011B\x07t\x02\x02\u011B\x0E\x03\x02" + + "\x02\x02\u011C\u011D\x07c\x02\x02\u011D\u011E\x07u\x02\x02\u011E\x10\x03" + + "\x02\x02\x02\u011F\u0120\x070\x02\x02\u0120\u0121\x070\x02\x02\u0121\u0122" + + "\x070\x02\x02\u0122\x12\x03\x02\x02\x02\u0123\u0124\x07u\x02\x02\u0124" + + "\u0125\x07y\x02\x02\u0125\u0126\x07k\x02\x02\u0126\u0127\x07v\x02\x02" + + "\u0127\u0128\x07e\x02\x02\u0128\u0129\x07j\x02\x02\u0129\x14\x03\x02\x02" + + "\x02\u012A\u012B\x07e\x02\x02\u012B\u012C\x07c\x02\x02\u012C\u012D\x07" + + "u\x02\x02\u012D\u012E\x07g\x02\x02\u012E\x16\x03\x02\x02\x02\u012F\u0130" + + "\x07f\x02\x02\u0130\u0131\x07g\x02\x02\u0131\u0132\x07h\x02\x02\u0132" + + "\u0133\x07c\x02\x02\u0133\u0134\x07w\x02\x02\u0134\u0135\x07n\x02\x02" + + "\u0135\u0136\x07v\x02\x02\u0136\x18\x03\x02\x02\x02\u0137\u0138\x07d\x02" + + "\x02\u0138\u0139\x07t\x02\x02\u0139\u013A\x07g\x02\x02\u013A\u013B\x07" + + "c\x02\x02\u013B\u013C\x07m\x02\x02\u013C\x1A\x03\x02\x02\x02\u013D\u013E" + + "\x07e\x02\x02\u013E\u013F\x07q\x02\x02\u013F\u0140\x07p\x02\x02\u0140" + + "\u0141\x07v\x02\x02\u0141\u0142\x07k\x02\x02\u0142\u0143\x07p\x02\x02" + + "\u0143\u0144\x07w\x02\x02\u0144\u0145\x07g\x02\x02\u0145\x1C\x03\x02\x02" + + "\x02\u0146\u0147\x07f\x02\x02\u0147\u0148\x07q\x02\x02\u0148\x1E\x03\x02" + + "\x02\x02\u0149\u014A\x07y\x02\x02\u014A\u014B\x07j\x02\x02\u014B\u014C" + + "\x07k\x02\x02\u014C\u014D\x07n\x02\x02\u014D\u014E\x07g\x02\x02\u014E" + + " \x03\x02\x02\x02\u014F\u0150\x07k\x02\x02\u0150\u0151\x07h\x02\x02\u0151" + + '"\x03\x02\x02\x02\u0152\u0153\x07g\x02\x02\u0153\u0154\x07n\x02\x02\u0154' + + "\u0155\x07u\x02\x02\u0155\u0156\x07g\x02\x02\u0156$\x03\x02\x02\x02\u0157" + + "\u0158\x07h\x02\x02\u0158\u0159\x07q\x02\x02\u0159\u015A\x07t\x02\x02" + + "\u015A&\x03\x02\x02\x02\u015B\u015C\x07g\x02\x02\u015C\u015D\x07p\x02" + + "\x02\u015D\u015E\x07w\x02\x02\u015E\u015F\x07o\x02\x02\u015F(\x03\x02" + + "\x02\x02\u0160\u0161\x07f\x02\x02\u0161\u0162\x07g\x02\x02\u0162\u0163" + + "\x07h\x02\x02\u0163*\x03\x02\x02\x02\u0164\u0165\x07t\x02\x02\u0165\u0166" + + "\x07g\x02\x02\u0166\u0167\x07v\x02\x02\u0167\u0168\x07w\x02\x02\u0168" + + "\u0169\x07t\x02\x02\u0169\u016A\x07p\x02\x02\u016A,\x03\x02\x02\x02\u016B" + + "\u016C\x07e\x02\x02\u016C\u016D\x07c\x02\x02\u016D\u016E\x07n\x02\x02" + + "\u016E\u016F\x07n\x02\x02\u016F.\x03\x02\x02\x02\u0170\u0171\x07/\x02" + + "\x02\u0171\u0172\x07@\x02\x02\u01720\x03\x02\x02\x02\u0173\u0174\x07e" + + "\x02\x02\u0174\u0175\x07n\x02\x02\u0175\u0176\x07c\x02\x02\u0176\u0177" + + "\x07u\x02\x02\u0177\u0178\x07u\x02\x02\u01782\x03\x02\x02\x02\u0179\u017A" + + "\x07k\x02\x02\u017A\u017B\x07p\x02\x02\u017B\u017C\x07v\x02\x02\u017C" + + "\u017D\x07g\x02\x02\u017D\u017E\x07t\x02\x02\u017E\u017F\x07h\x02\x02" + + "\u017F\u0180\x07c\x02\x02\u0180\u0181\x07e\x02\x02\u0181\u0182\x07g\x02" + + "\x02\u01824\x03\x02\x02\x02\u0183\u0184\x07v\x02\x02\u0184\u0185\x07t" + + "\x02\x02\u0185\u0186\x07w\x02\x02\u0186\u0187\x07g\x02\x02\u01876\x03" + + "\x02\x02\x02\u0188\u0189\x07h\x02\x02\u0189\u018A\x07c\x02\x02\u018A\u018B" + + "\x07n\x02\x02\u018B\u018C\x07u\x02\x02\u018C\u018D\x07g\x02\x02\u018D" + + "8\x03\x02\x02\x02\u018E\u018F\x07v\x02\x02\u018F\u0190\x07{\x02\x02\u0190" + + "\u0191\x07r\x02\x02\u0191\u0192\x07g\x02\x02\u0192\u0193\x07q\x02\x02" + + "\u0193\u0194\x07h\x02\x02\u0194:\x03\x02\x02\x02\u0195\u0196\x07x\x02" + + "\x02\u0196\u0197\x07q\x02\x02\u0197\u0198\x07k\x02\x02\u0198\u0199\x07" + + "f\x02\x02\u0199<\x03\x02\x02\x02\u019A\u019B\x07p\x02\x02\u019B\u019C" + + "\x07w\x02\x02\u019C\u019D\x07n\x02\x02\u019D\u019E\x07n\x02\x02\u019E" + + ">\x03\x02\x02\x02\u019F\u01A0\x07w\x02\x02\u01A0\u01A1\x07p\x02\x02\u01A1" + + "\u01A2\x07f\x02\x02\u01A2\u01A3\x07g\x02\x02\u01A3\u01A4\x07h\x02\x02" + + "\u01A4\u01A5\x07k\x02\x02\u01A5\u01A6\x07p\x02\x02\u01A6\u01A7\x07g\x02" + + "\x02\u01A7\u01A8\x07f\x02\x02\u01A8@\x03\x02\x02\x02\u01A9\u01AA\x07." + + "\x02\x02\u01AAB\x03\x02\x02\x02\u01AB\u01AC\x07=\x02\x02\u01ACD\x03\x02" + + "\x02\x02\u01AD\u01AE\x07A\x02\x02\u01AEF\x03\x02\x02\x02\u01AF\u01B0\x07" + + "<\x02\x02\u01B0H\x03\x02\x02\x02\u01B1\u01B2\x07*\x02\x02\u01B2J\x03\x02" + + "\x02\x02\u01B3\u01B4\x07+\x02\x02\u01B4L\x03\x02\x02\x02\u01B5\u01B6\x07" + + "]\x02\x02\u01B6N\x03\x02\x02\x02\u01B7\u01B8\x07_\x02\x02\u01B8P\x03\x02" + + "\x02\x02\u01B9\u01BA\x06(\x02\x02\u01BA\u01BB\x07\x7F\x02\x02\u01BB\u01BC" + + "\x03\x02\x02\x02\u01BC\u01BD\b(\x04\x02\u01BDR\x03\x02\x02\x02\u01BE\u01BF" + + "\x07}\x02\x02\u01BFT\x03\x02\x02\x02\u01C0\u01C1\x07\x7F\x02\x02\u01C1" + + "V\x03\x02\x02\x02\u01C2\u01C3\x07-\x02\x02\u01C3X\x03\x02\x02\x02\u01C4" + + "\u01C5\x07-\x02\x02\u01C5\u01C6\x07-\x02\x02\u01C6Z\x03\x02\x02\x02\u01C7" + + "\u01C8\x07/\x02\x02\u01C8\\\x03\x02\x02\x02\u01C9\u01CA\x07/\x02\x02\u01CA" + + "\u01CB\x07/\x02\x02\u01CB^\x03\x02\x02\x02\u01CC\u01CD\x07,\x02\x02\u01CD" + + "`\x03\x02\x02\x02\u01CE\u01CF\x071\x02\x02\u01CFb\x03\x02\x02\x02\u01D0" + + "\u01D1\x07'\x02\x02\u01D1d\x03\x02\x02\x02\u01D2\u01D3\x07,\x02\x02\u01D3" + + "\u01D4\x07,\x02\x02\u01D4f\x03\x02\x02\x02\u01D5\u01D6\x07(\x02\x02\u01D6" + + "\u01D7\x07(\x02\x02\u01D7h\x03\x02\x02\x02\u01D8\u01D9\x07~\x02\x02\u01D9" + + "\u01DA\x07~\x02\x02\u01DAj\x03\x02\x02\x02\u01DB\u01DC\x07#\x02\x02\u01DC" + + "l\x03\x02\x02\x02\u01DD\u01DE\x07?\x02\x02\u01DEn\x03\x02\x02\x02\u01DF" + + "\u01E0\x07-\x02\x02\u01E0\u01E1\x07?\x02\x02\u01E1p\x03\x02\x02\x02\u01E2" + + "\u01E3\x07/\x02\x02\u01E3\u01E4\x07?\x02\x02\u01E4r\x03\x02\x02\x02\u01E5" + + "\u01E6\x07,\x02\x02\u01E6\u01E7\x07?\x02\x02\u01E7t\x03\x02\x02\x02\u01E8" + + "\u01E9\x071\x02\x02\u01E9\u01EA\x07?\x02\x02\u01EAv\x03\x02\x02\x02\u01EB" + + "\u01EC\x07'\x02\x02\u01EC\u01ED\x07?\x02\x02\u01EDx\x03\x02\x02\x02\u01EE" + + "\u01EF\x07?\x02\x02\u01EF\u01F0\x07?\x02\x02\u01F0z\x03\x02\x02\x02\u01F1" + + "\u01F2\x07#\x02\x02\u01F2\u01F3\x07?\x02\x02\u01F3|\x03\x02\x02\x02\u01F4" + + "\u01F5\x07>\x02\x02\u01F5~\x03\x02\x02\x02\u01F6\u01F7\x07>\x02\x02\u01F7" + + "\u01F8\x07?\x02\x02\u01F8\x80\x03\x02\x02\x02\u01F9\u01FA\x07@\x02\x02" + + "\u01FA\x82\x03\x02\x02\x02\u01FB\u01FC\x07@\x02\x02\u01FC\u01FD\x07?\x02" + + "\x02\u01FD\x84\x03\x02\x02\x02\u01FE\u01FF\x07(\x02\x02\u01FF\x86\x03" + + "\x02\x02\x02\u0200\u0201\x07~\x02\x02\u0201\x88\x03\x02\x02\x02\u0202" + + "\u0203\x07`\x02\x02\u0203\x8A\x03\x02\x02\x02\u0204\u0205\x07\x80\x02" + + "\x02\u0205\x8C\x03\x02\x02\x02\u0206\u0207\x07>\x02\x02\u0207\u0208\x07" + + ">\x02\x02\u0208\x8E\x03\x02"; private static readonly _serializedATNSegment1: string = - "\x03\x02\x02\x02\u020C\u020E\x07)\x02\x02\u020D\u020F\x05\xE3q\x02\u020E" + - "\u020D\x03\x02\x02\x02\u020E\u020F\x03\x02\x02\x02\u020F\u0210\x03\x02" + - "\x02\x02\u0210\u0211\x07)\x02\x02\u0211\x96\x03\x02\x02\x02\u0212\u0214" + - "\x07$\x02\x02\u0213\u0215\x05\xE7s\x02\u0214\u0213\x03\x02\x02\x02\u0214" + - "\u0215\x03\x02\x02\x02\u0215\u0216\x03\x02\x02\x02\u0216\u0217\x07$\x02" + - "\x02\u0217\x98\x03\x02\x02\x02\u0218\u0219\x05\xC5b\x02\u0219\x9A\x03" + - "\x02\x02\x02\u021A\u021C\t\x02\x02\x02\u021B\u021A\x03\x02\x02\x02\u021C" + - "\u021D\x03\x02\x02\x02\u021D\u021B\x03\x02\x02\x02\u021D\u021E\x03\x02" + - "\x02\x02\u021E\u021F\x03\x02\x02\x02\u021F\u0220\bM\x05\x02\u0220\x9C" + - "\x03\x02\x02\x02\u0221\u0222\t\x03\x02\x02\u0222\u0223\x03\x02\x02\x02" + - "\u0223\u0224\bN\x05\x02\u0224\x9E\x03\x02\x02\x02\u0225\u0226\x07h\x02" + - "\x02\u0226\u0227\x07)\x02\x02\u0227\u0228\x03\x02\x02\x02\u0228\u0229" + - "\bO\x06\x02\u0229\u022A\x03\x02\x02\x02\u022A\u022B\bO\x07\x02\u022B\xA0" + - "\x03\x02\x02\x02\u022C\u022D\x07h\x02\x02\u022D\u022E\x07$\x02\x02\u022E" + - "\u022F\x03\x02\x02\x02\u022F\u0230\bP\b\x02\u0230\u0231\x03\x02\x02\x02" + - "\u0231\u0232\bP\t\x02\u0232\xA2\x03\x02\x02\x02\u0233\u0234\x06Q\x03\x02" + - "\u0234\u0235\x07}\x02\x02\u0235\u0236\x03\x02\x02\x02\u0236\u0237\bQ\n" + - "\x02\u0237\u0238\bQ\v\x02\u0238\xA4\x03\x02\x02\x02\u0239\u023A\x07)\x02" + - "\x02\u023A\u023B\bR\f\x02\u023B\u023C\x03\x02\x02\x02\u023C\u023D\bR\x04" + - "\x02\u023D\xA6\x03\x02\x02\x02\u023E\u023F\x05\xDBm\x02\u023F\xA8\x03" + - "\x02\x02\x02\u0240\u0241\x06T\x04\x02\u0241\u0242\x07}\x02\x02\u0242\u0243" + - "\x03\x02\x02\x02\u0243\u0244\bT\n\x02\u0244\u0245\bT\v\x02\u0245\xAA\x03" + - "\x02\x02\x02\u0246\u0247\x07$\x02\x02\u0247\u0248\bU\r\x02\u0248\u0249" + - "\x03\x02\x02\x02\u0249\u024A\bU\x04\x02\u024A\xAC\x03\x02\x02\x02\u024B" + - "\u024C\x05\xDFo\x02\u024C\xAE\x03\x02\x02\x02\u024D\u024E\x05\xB1X\x02" + - "\u024E\xB0\x03\x02\x02\x02\u024F\u0250\t\x04\x02\x02\u0250\xB2\x03\x02" + - "\x02\x02\u0251\u0252\t\x05\x02\x02\u0252\xB4\x03\x02\x02\x02\u0253\u0255" + - "\x05\xB3Y\x02\u0254\u0253\x03\x02\x02\x02\u0255\u0256\x03\x02\x02\x02" + - "\u0256\u0254\x03\x02\x02\x02\u0256\u0257\x03\x02\x02\x02\u0257\xB6\x03" + - "\x02\x02\x02\u0258\u0259\x072\x02\x02\u0259\u025B\t\x06\x02\x02\u025A" + - "\u025C\x05\xBF_\x02\u025B\u025A\x03\x02\x02\x02\u025C\u025D\x03\x02\x02" + - "\x02\u025D\u025B\x03\x02\x02\x02\u025D\u025E\x03\x02\x02\x02\u025E\xB8" + - "\x03\x02\x02\x02\u025F\u0260\x072\x02\x02\u0260\u0262\t\x07\x02\x02\u0261" + - "\u0263\x05\xC1`\x02\u0262\u0261\x03\x02\x02\x02\u0263\u0264\x03\x02\x02" + - "\x02\u0264\u0262\x03\x02\x02\x02\u0264\u0265\x03\x02\x02\x02\u0265\xBA" + - "\x03\x02\x02\x02\u0266\u0267\x072\x02\x02\u0267\u0269\t\b\x02\x02\u0268" + - "\u026A\x05\xC3a\x02\u0269\u0268\x03\x02\x02\x02\u026A\u026B\x03\x02\x02" + - "\x02\u026B\u0269\x03\x02\x02\x02\u026B\u026C\x03\x02\x02\x02\u026C\xBC" + - "\x03\x02\x02\x02\u026D\u026E\t\t\x02\x02\u026E\xBE\x03\x02\x02\x02\u026F" + - "\u0270\t\n\x02\x02\u0270\xC0\x03\x02\x02\x02\u0271\u0272\t\v\x02\x02\u0272" + - "\xC2\x03\x02\x02\x02\u0273\u0274\t\f\x02\x02\u0274\xC4\x03\x02\x02\x02" + - "\u0275\u0277\x05\xC7c\x02\u0276\u0278\x05\xC9d\x02\u0277\u0276\x03\x02" + - "\x02\x02\u0277\u0278\x03\x02\x02\x02\u0278\u027D\x03\x02\x02\x02\u0279" + - "\u027A\x05\xCBe\x02\u027A\u027B\x05\xC9d\x02\u027B\u027D\x03\x02\x02\x02" + - "\u027C\u0275\x03\x02\x02\x02\u027C\u0279\x03\x02\x02\x02\u027D\xC6\x03" + - "\x02\x02\x02\u027E\u0280\x05\xCBe\x02\u027F\u027E\x03\x02\x02\x02\u027F" + - "\u0280\x03\x02\x02\x02\u0280\u0281\x03\x02\x02\x02\u0281\u0282\x070\x02" + - "\x02\u0282\u0287\x05\xCBe\x02\u0283\u0284\x05\xCBe\x02\u0284\u0285\x07" + - "0\x02\x02\u0285\u0287\x03\x02\x02\x02\u0286\u027F\x03\x02\x02\x02\u0286" + - "\u0283\x03\x02\x02\x02\u0287\xC8\x03\x02\x02\x02\u0288\u028A\t\r\x02\x02" + - "\u0289\u028B\x05\xCDf\x02\u028A\u0289\x03\x02\x02\x02\u028A\u028B\x03" + - "\x02\x02\x02\u028B\u028C\x03\x02\x02\x02\u028C\u028D\x05\xCBe\x02\u028D" + - "\xCA\x03\x02\x02\x02\u028E\u0290\x05\xB3Y\x02\u028F\u028E\x03\x02\x02" + - "\x02\u0290\u0291\x03\x02\x02\x02\u0291\u028F\x03\x02\x02\x02\u0291\u0292" + - "\x03\x02\x02\x02\u0292\xCC\x03\x02\x02\x02\u0293\u0294\t\x0E\x02\x02\u0294" + - "\xCE\x03\x02\x02\x02\u0295\u0297\x05\xD1h\x02\u0296\u0295\x03\x02\x02" + - "\x02\u0297\u0298\x03\x02\x02\x02\u0298\u0296\x03\x02\x02\x02\u0298\u0299" + - "\x03\x02\x02\x02\u0299\xD0\x03\x02\x02\x02\u029A\u029D\n\x0F\x02\x02\u029B" + - "\u029D\x05\xD3i\x02\u029C\u029A\x03\x02\x02\x02\u029C\u029B\x03\x02\x02" + - "\x02\u029D\xD2\x03\x02\x02\x02\u029E\u02A2\x05\xD5j\x02\u029F\u02A2\x05" + - "\xD7k\x02\u02A0\u02A2\x05\xD9l\x02\u02A1\u029E\x03\x02\x02\x02\u02A1\u029F" + - "\x03\x02\x02\x02\u02A1\u02A0\x03\x02\x02\x02\u02A2\xD4\x03\x02\x02\x02" + - "\u02A3\u02A4\x07^\x02\x02\u02A4\u02A5\t\x10\x02\x02\u02A5\xD6\x03\x02" + - "\x02\x02\u02A6\u02A7\x07^\x02\x02\u02A7\u02A9\x05\xC1`\x02\u02A8\u02AA" + - "\x05\xC1`\x02\u02A9\u02A8\x03\x02\x02\x02\u02A9\u02AA\x03\x02\x02\x02" + - "\u02AA\u02AC\x03\x02\x02\x02\u02AB\u02AD\x05\xC1`\x02\u02AC\u02AB\x03" + - "\x02\x02\x02\u02AC\u02AD\x03\x02\x02\x02\u02AD\xD8\x03\x02\x02\x02\u02AE" + - "\u02AF\x07^\x02\x02\u02AF\u02B0\x07z\x02\x02\u02B0\u02B2\x03\x02\x02\x02" + - "\u02B1\u02B3\x05\xC3a\x02\u02B2\u02B1\x03\x02\x02\x02\u02B3\u02B4\x03" + - "\x02\x02\x02\u02B4\u02B2\x03\x02\x02\x02\u02B4\u02B5\x03\x02\x02\x02\u02B5" + - "\xDA\x03\x02\x02\x02\u02B6\u02B8\x05\xDDn\x02\u02B7\u02B6\x03\x02\x02" + - "\x02\u02B8\u02B9\x03\x02\x02\x02\u02B9\u02B7\x03\x02\x02\x02\u02B9\u02BA" + - "\x03\x02\x02\x02\u02BA\xDC\x03\x02\x02\x02\u02BB\u02BE\n\x11\x02\x02\u02BC" + - "\u02BE\x05\xD3i\x02\u02BD\u02BB\x03\x02\x02\x02\u02BD\u02BC\x03\x02\x02" + - "\x02\u02BE\xDE\x03\x02\x02\x02\u02BF\u02C1\x05\xE1p\x02\u02C0\u02BF\x03" + - "\x02\x02\x02\u02C1\u02C2\x03\x02\x02\x02\u02C2\u02C0\x03\x02\x02\x02\u02C2" + - "\u02C3\x03\x02\x02\x02\u02C3\xE0\x03\x02\x02\x02\u02C4\u02C7\n\x12\x02" + - "\x02\u02C5\u02C7\x05\xD3i\x02\u02C6\u02C4\x03\x02\x02\x02\u02C6\u02C5" + - "\x03\x02\x02\x02\u02C7\xE2\x03\x02\x02\x02\u02C8\u02CA\x05\xE5r\x02\u02C9" + - "\u02C8\x03\x02\x02\x02\u02CA\u02CB\x03\x02\x02\x02\u02CB\u02C9\x03\x02" + - "\x02\x02\u02CB\u02CC\x03\x02\x02\x02\u02CC\xE4\x03\x02\x02\x02\u02CD\u02D0" + - "\n\x0F\x02\x02\u02CE\u02D0\x05\xD3i\x02\u02CF\u02CD\x03\x02\x02\x02\u02CF" + - "\u02CE\x03\x02\x02\x02\u02D0\xE6\x03\x02\x02\x02\u02D1\u02D3\x05\xE9t" + - "\x02\u02D2\u02D1\x03\x02\x02\x02\u02D3\u02D4\x03\x02\x02\x02\u02D4\u02D2" + - "\x03\x02\x02\x02\u02D4\u02D5\x03\x02\x02\x02\u02D5\xE8\x03\x02\x02\x02" + - "\u02D6\u02D9\n\x13\x02\x02\u02D7\u02D9\x05\xD3i\x02\u02D8\u02D6\x03\x02" + - "\x02\x02\u02D8\u02D7\x03\x02\x02\x02\u02D9\xEA\x03\x02\x02\x02\u02DA\u02DC" + - "\n\x03\x02\x02\u02DB\u02DA\x03\x02\x02\x02\u02DC\u02DF\x03\x02\x02\x02" + - "\u02DD\u02DB\x03\x02\x02\x02\u02DD\u02DE\x03\x02\x02\x02\u02DE\xEC\x03" + - "\x02\x02\x02\u02DF\u02DD\x03\x02\x02\x02%\x02\x03\x04\xF3\u0201\u0203" + - "\u020A\u020E\u0214\u021D\u0256\u025D\u0264\u026B\u0277\u027C\u027F\u0286" + - "\u028A\u0291\u0298\u029C\u02A1\u02A9\u02AC\u02B4\u02B9\u02BD\u02C2\u02C6" + - "\u02CB\u02CF\u02D4\u02D8\u02DD\x0E\x02\x04\x02\x02\x05\x02\x06\x02\x02" + - "\x02\x03\x02\x03O\x02\x07\x03\x02\x03P\x03\x07\x04\x02\t\x03\x02\x07\x02" + - "\x02\x03R\x04\x03U\x05"; + "\x02\x02\u0209\u020A\x07@\x02\x02\u020A\u020B\x07@\x02\x02\u020B\x90\x03" + + "\x02\x02\x02\u020C\u020D\x07@\x02\x02\u020D\u020E\x07@\x02\x02\u020E\u020F" + + "\x07@\x02\x02\u020F\x92\x03\x02\x02\x02\u0210\u0211\x070\x02\x02\u0211" + + "\x94\x03\x02\x02\x02\u0212\u0217\x05\xB3Y\x02\u0213\u0216\x05\xB3Y\x02" + + "\u0214\u0216\x05\xB7[\x02\u0215\u0213\x03\x02\x02\x02\u0215\u0214\x03" + + "\x02\x02\x02\u0216\u0219\x03\x02\x02\x02\u0217\u0215\x03\x02\x02\x02\u0217" + + "\u0218\x03\x02\x02\x02\u0218\x96\x03\x02\x02\x02\u0219\u0217\x03\x02\x02" + + "\x02\u021A\u021F\x05\xB9\\\x02\u021B\u021F\x05\xBD^\x02\u021C\u021F\x05" + + "\xBF_\x02\u021D\u021F\x05\xBB]\x02\u021E\u021A\x03\x02\x02\x02\u021E\u021B" + + "\x03\x02\x02\x02\u021E\u021C\x03\x02\x02\x02\u021E\u021D\x03\x02\x02\x02" + + "\u021F\x98\x03\x02\x02\x02\u0220\u0222\x07)\x02\x02\u0221\u0223\x05\xE7" + + "s\x02\u0222\u0221\x03\x02\x02\x02\u0222\u0223\x03\x02\x02\x02\u0223\u0224" + + "\x03\x02\x02\x02\u0224\u0225\x07)\x02\x02\u0225\x9A\x03\x02\x02\x02\u0226" + + "\u0228\x07$\x02\x02\u0227\u0229\x05\xEBu\x02\u0228\u0227\x03\x02\x02\x02" + + "\u0228\u0229\x03\x02\x02\x02\u0229\u022A\x03\x02\x02\x02\u022A\u022B\x07" + + "$\x02\x02\u022B\x9C\x03\x02\x02\x02\u022C\u022D\x05\xC9d\x02\u022D\x9E" + + "\x03\x02\x02\x02\u022E\u0230\t\x02\x02\x02\u022F\u022E\x03\x02\x02\x02" + + "\u0230\u0231\x03\x02\x02\x02\u0231\u022F\x03\x02\x02\x02\u0231\u0232\x03" + + "\x02\x02\x02\u0232\u0233\x03\x02\x02\x02\u0233\u0234\bO\x05\x02\u0234" + + "\xA0\x03\x02\x02\x02\u0235\u0236\t\x03\x02\x02\u0236\u0237\x03\x02\x02" + + "\x02\u0237\u0238\bP\x05\x02\u0238\xA2\x03\x02\x02\x02\u0239\u023A\x07" + + "h\x02\x02\u023A\u023B\x07)\x02\x02\u023B\u023C\x03\x02\x02\x02\u023C\u023D" + + "\bQ\x06\x02\u023D\u023E\x03\x02\x02\x02\u023E\u023F\bQ\x07\x02\u023F\xA4" + + "\x03\x02\x02\x02\u0240\u0241\x07h\x02\x02\u0241\u0242\x07$\x02\x02\u0242" + + "\u0243\x03\x02\x02\x02\u0243\u0244\bR\b\x02\u0244\u0245\x03\x02\x02\x02" + + "\u0245\u0246\bR\t\x02\u0246\xA6\x03\x02\x02\x02\u0247\u0248\x06S\x03\x02" + + "\u0248\u0249\x07}\x02\x02\u0249\u024A\x03\x02\x02\x02\u024A\u024B\bS\n" + + "\x02\u024B\u024C\bS\v\x02\u024C\xA8\x03\x02\x02\x02\u024D\u024E\x07)\x02" + + "\x02\u024E\u024F\bT\f\x02\u024F\u0250\x03\x02\x02\x02\u0250\u0251\bT\x04" + + "\x02\u0251\xAA\x03\x02\x02\x02\u0252\u0253\x05\xDFo\x02\u0253\xAC\x03" + + "\x02\x02\x02\u0254\u0255\x06V\x04\x02\u0255\u0256\x07}\x02\x02\u0256\u0257" + + "\x03\x02\x02\x02\u0257\u0258\bV\n\x02\u0258\u0259\bV\v\x02\u0259\xAE\x03" + + "\x02\x02\x02\u025A\u025B\x07$\x02\x02\u025B\u025C\bW\r\x02\u025C\u025D" + + "\x03\x02\x02\x02\u025D\u025E\bW\x04\x02\u025E\xB0\x03\x02\x02\x02\u025F" + + "\u0260\x05\xE3q\x02\u0260\xB2\x03\x02\x02\x02\u0261\u0262\x05\xB5Z\x02" + + "\u0262\xB4\x03\x02\x02\x02\u0263\u0264\t\x04\x02\x02\u0264\xB6\x03\x02" + + "\x02\x02\u0265\u0266\t\x05\x02\x02\u0266\xB8\x03\x02\x02\x02\u0267\u0269" + + "\x05\xB7[\x02\u0268\u0267\x03\x02\x02\x02\u0269\u026A\x03\x02\x02\x02" + + "\u026A\u0268\x03\x02\x02\x02\u026A\u026B\x03\x02\x02\x02\u026B\xBA\x03" + + "\x02\x02\x02\u026C\u026D\x072\x02\x02\u026D\u026F\t\x06\x02\x02\u026E" + + "\u0270\x05\xC3a\x02\u026F\u026E\x03\x02\x02\x02\u0270\u0271\x03\x02\x02" + + "\x02\u0271\u026F\x03\x02\x02\x02\u0271\u0272\x03\x02\x02\x02\u0272\xBC" + + "\x03\x02\x02\x02\u0273\u0274\x072\x02\x02\u0274\u0276\t\x07\x02\x02\u0275" + + "\u0277\x05\xC5b\x02\u0276\u0275\x03\x02\x02\x02\u0277\u0278\x03\x02\x02" + + "\x02\u0278\u0276\x03\x02\x02\x02\u0278\u0279\x03\x02\x02\x02\u0279\xBE" + + "\x03\x02\x02\x02\u027A\u027B\x072\x02\x02\u027B\u027D\t\b\x02\x02\u027C" + + "\u027E\x05\xC7c\x02\u027D\u027C\x03\x02\x02\x02\u027E\u027F\x03\x02\x02" + + "\x02\u027F\u027D\x03\x02\x02\x02\u027F\u0280\x03\x02\x02\x02\u0280\xC0" + + "\x03\x02\x02\x02\u0281\u0282\t\t\x02\x02\u0282\xC2\x03\x02\x02\x02\u0283" + + "\u0284\t\n\x02\x02\u0284\xC4\x03\x02\x02\x02\u0285\u0286\t\v\x02\x02\u0286" + + "\xC6\x03\x02\x02\x02\u0287\u0288\t\f\x02\x02\u0288\xC8\x03\x02\x02\x02" + + "\u0289\u028B\x05\xCBe\x02\u028A\u028C\x05\xCDf\x02\u028B\u028A\x03\x02" + + "\x02\x02\u028B\u028C\x03\x02\x02\x02\u028C\u0291\x03\x02\x02\x02\u028D" + + "\u028E\x05\xCFg\x02\u028E\u028F\x05\xCDf\x02\u028F\u0291\x03\x02\x02\x02" + + "\u0290\u0289\x03\x02\x02\x02\u0290\u028D\x03\x02\x02\x02\u0291\xCA\x03" + + "\x02\x02\x02\u0292\u0294\x05\xCFg\x02\u0293\u0292\x03\x02\x02\x02\u0293" + + "\u0294\x03\x02\x02\x02\u0294\u0295\x03\x02\x02\x02\u0295\u0296\x070\x02" + + "\x02\u0296\u029B\x05\xCFg\x02\u0297\u0298\x05\xCFg\x02\u0298\u0299\x07" + + "0\x02\x02\u0299\u029B\x03\x02\x02\x02\u029A\u0293\x03\x02\x02\x02\u029A" + + "\u0297\x03\x02\x02\x02\u029B\xCC\x03\x02\x02\x02\u029C\u029E\t\r\x02\x02" + + "\u029D\u029F\x05\xD1h\x02\u029E\u029D\x03\x02\x02\x02\u029E\u029F\x03" + + "\x02\x02\x02\u029F\u02A0\x03\x02\x02\x02\u02A0\u02A1\x05\xCFg\x02\u02A1" + + "\xCE\x03\x02\x02\x02\u02A2\u02A4\x05\xB7[\x02\u02A3\u02A2\x03\x02\x02" + + "\x02\u02A4\u02A5\x03\x02\x02\x02\u02A5\u02A3\x03\x02\x02\x02\u02A5\u02A6" + + "\x03\x02\x02\x02\u02A6\xD0\x03\x02\x02\x02\u02A7\u02A8\t\x0E\x02\x02\u02A8" + + "\xD2\x03\x02\x02\x02\u02A9\u02AB\x05\xD5j\x02\u02AA\u02A9\x03\x02\x02" + + "\x02\u02AB\u02AC\x03\x02\x02\x02\u02AC\u02AA\x03\x02\x02\x02\u02AC\u02AD" + + "\x03\x02\x02\x02\u02AD\xD4\x03\x02\x02\x02\u02AE\u02B1\n\x0F\x02\x02\u02AF" + + "\u02B1\x05\xD7k\x02\u02B0\u02AE\x03\x02\x02\x02\u02B0\u02AF\x03\x02\x02" + + "\x02\u02B1\xD6\x03\x02\x02\x02\u02B2\u02B6\x05\xD9l\x02\u02B3\u02B6\x05" + + "\xDBm\x02\u02B4\u02B6\x05\xDDn\x02\u02B5\u02B2\x03\x02\x02\x02\u02B5\u02B3" + + "\x03\x02\x02\x02\u02B5\u02B4\x03\x02\x02\x02\u02B6\xD8\x03\x02\x02\x02" + + "\u02B7\u02B8\x07^\x02\x02\u02B8\u02B9\t\x10\x02\x02\u02B9\xDA\x03\x02" + + "\x02\x02\u02BA\u02BB\x07^\x02\x02\u02BB\u02BD\x05\xC5b\x02\u02BC\u02BE" + + "\x05\xC5b\x02\u02BD\u02BC\x03\x02\x02\x02\u02BD\u02BE\x03\x02\x02\x02" + + "\u02BE\u02C0\x03\x02\x02\x02\u02BF\u02C1\x05\xC5b\x02\u02C0\u02BF\x03" + + "\x02\x02\x02\u02C0\u02C1\x03\x02\x02\x02\u02C1\xDC\x03\x02\x02\x02\u02C2" + + "\u02C3\x07^\x02\x02\u02C3\u02C4\x07z\x02\x02\u02C4\u02C6\x03\x02\x02\x02" + + "\u02C5\u02C7\x05\xC7c\x02\u02C6\u02C5\x03\x02\x02\x02\u02C7\u02C8\x03" + + "\x02\x02\x02\u02C8\u02C6\x03\x02\x02\x02\u02C8\u02C9\x03\x02\x02\x02\u02C9" + + "\xDE\x03\x02\x02\x02\u02CA\u02CC\x05\xE1p\x02\u02CB\u02CA\x03\x02\x02" + + "\x02\u02CC\u02CD\x03\x02\x02\x02\u02CD\u02CB\x03\x02\x02\x02\u02CD\u02CE" + + "\x03\x02\x02\x02\u02CE\xE0\x03\x02\x02\x02\u02CF\u02D2\n\x11\x02\x02\u02D0" + + "\u02D2\x05\xD7k\x02\u02D1\u02CF\x03\x02\x02\x02\u02D1\u02D0\x03\x02\x02" + + "\x02\u02D2\xE2\x03\x02\x02\x02\u02D3\u02D5\x05\xE5r\x02\u02D4\u02D3\x03" + + "\x02\x02\x02\u02D5\u02D6\x03\x02\x02\x02\u02D6\u02D4\x03\x02\x02\x02\u02D6" + + "\u02D7\x03\x02\x02\x02\u02D7\xE4\x03\x02\x02\x02\u02D8\u02DB\n\x12\x02" + + "\x02\u02D9\u02DB\x05\xD7k\x02\u02DA\u02D8\x03\x02\x02\x02\u02DA\u02D9" + + "\x03\x02\x02\x02\u02DB\xE6\x03\x02\x02\x02\u02DC\u02DE\x05\xE9t\x02\u02DD" + + "\u02DC\x03\x02\x02\x02\u02DE\u02DF\x03\x02\x02\x02\u02DF\u02DD\x03\x02" + + "\x02\x02\u02DF\u02E0\x03\x02\x02\x02\u02E0\xE8\x03\x02\x02\x02\u02E1\u02E4" + + "\n\x0F\x02\x02\u02E2\u02E4\x05\xD7k\x02\u02E3\u02E1\x03\x02\x02\x02\u02E3" + + "\u02E2\x03\x02\x02\x02\u02E4\xEA\x03\x02\x02\x02\u02E5\u02E7\x05\xEDv" + + "\x02\u02E6\u02E5\x03\x02\x02\x02\u02E7\u02E8\x03\x02\x02\x02\u02E8\u02E6" + + "\x03\x02\x02\x02\u02E8\u02E9\x03\x02\x02\x02\u02E9\xEC\x03\x02\x02\x02" + + "\u02EA\u02ED\n\x13\x02\x02\u02EB\u02ED\x05\xD7k\x02\u02EC\u02EA\x03\x02" + + "\x02\x02\u02EC\u02EB\x03\x02\x02\x02\u02ED\xEE\x03\x02\x02\x02\u02EE\u02F0" + + "\n\x03\x02\x02\u02EF\u02EE\x03\x02\x02\x02\u02F0\u02F3\x03\x02\x02\x02" + + "\u02F1\u02EF\x03\x02\x02\x02\u02F1\u02F2\x03\x02\x02\x02\u02F2\xF0\x03" + + "\x02\x02\x02\u02F3\u02F1\x03\x02\x02\x02%\x02\x03\x04\xF7\u0215\u0217" + + "\u021E\u0222\u0228\u0231\u026A\u0271\u0278\u027F\u028B\u0290\u0293\u029A" + + "\u029E\u02A5\u02AC\u02B0\u02B5\u02BD\u02C0\u02C8\u02CD\u02D1\u02D6\u02DA" + + "\u02DF\u02E3\u02E8\u02EC\u02F1\x0E\x02\x04\x02\x02\x05\x02\x06\x02\x02" + + "\x02\x03\x02\x03Q\x02\x07\x03\x02\x03R\x03\x07\x04\x02\t\x03\x02\x07\x02" + + "\x02\x03T\x04\x03W\x05"; public static readonly _serializedATN: string = Utils.join( [KipperLexer._serializedATNSegment0, KipperLexer._serializedATNSegment1], "", diff --git a/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.interp b/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.interp index 6bc98c883..0fe5177d8 100644 --- a/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.interp +++ b/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.interp @@ -23,6 +23,8 @@ null 'return' 'call' '->' +'class' +'interface' 'true' 'false' 'typeof' @@ -110,6 +112,8 @@ DefFunc Return CallFunc RetIndicator +Class +Interface True False Typeof @@ -179,15 +183,17 @@ externalItem blockItemList blockItem declaration -functionDeclaration variableDeclaration storageTypeSpecifier +initDeclarator +initializer declarator directDeclarator -initDeclarator +functionDeclaration parameterList parameterDeclaration -initializer +interfaceDeclaration +classDeclaration statement compoundStatement expressionStatement @@ -253,4 +259,4 @@ typeSpecifierIdentifier atn: -[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 3, 86, 706, 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, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 4, 68, 9, 68, 4, 69, 9, 69, 4, 70, 9, 70, 4, 71, 9, 71, 4, 72, 9, 72, 4, 73, 9, 73, 4, 74, 9, 74, 4, 75, 9, 75, 4, 76, 9, 76, 4, 77, 9, 77, 4, 78, 9, 78, 3, 2, 5, 2, 158, 10, 2, 3, 2, 3, 2, 3, 3, 6, 3, 163, 10, 3, 13, 3, 14, 3, 164, 3, 4, 3, 4, 3, 5, 6, 5, 170, 10, 5, 13, 5, 14, 5, 171, 3, 6, 3, 6, 3, 6, 5, 6, 177, 10, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 5, 7, 184, 10, 7, 5, 7, 186, 10, 7, 3, 8, 3, 8, 3, 8, 3, 8, 5, 8, 192, 10, 8, 3, 8, 3, 8, 3, 8, 3, 8, 5, 8, 198, 10, 8, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 5, 13, 214, 10, 13, 3, 14, 3, 14, 3, 14, 7, 14, 219, 10, 14, 12, 14, 14, 14, 222, 11, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 5, 17, 236, 10, 17, 3, 18, 3, 18, 3, 18, 5, 18, 241, 10, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 5, 20, 252, 10, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 5, 21, 261, 10, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 7, 22, 269, 10, 22, 12, 22, 14, 22, 272, 11, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 5, 23, 284, 10, 23, 3, 24, 3, 24, 3, 24, 5, 24, 289, 10, 24, 3, 25, 3, 25, 3, 25, 3, 25, 5, 25, 295, 10, 25, 3, 25, 3, 25, 5, 25, 299, 10, 25, 3, 25, 3, 25, 3, 25, 3, 25, 5, 25, 305, 10, 25, 3, 25, 3, 25, 3, 25, 3, 25, 5, 25, 311, 10, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 5, 29, 335, 10, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 5, 30, 349, 10, 30, 3, 31, 3, 31, 5, 31, 353, 10, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 5, 31, 361, 10, 31, 3, 32, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 34, 3, 34, 3, 35, 3, 35, 3, 36, 3, 36, 5, 36, 375, 10, 36, 3, 37, 3, 37, 3, 38, 3, 38, 7, 38, 381, 10, 38, 12, 38, 14, 38, 384, 11, 38, 3, 38, 3, 38, 3, 38, 7, 38, 389, 10, 38, 12, 38, 14, 38, 392, 11, 38, 3, 38, 5, 38, 395, 10, 38, 3, 39, 3, 39, 3, 39, 5, 39, 400, 10, 39, 3, 39, 5, 39, 403, 10, 39, 3, 40, 3, 40, 3, 40, 5, 40, 408, 10, 40, 3, 40, 5, 40, 411, 10, 40, 3, 41, 3, 41, 3, 42, 3, 42, 3, 42, 3, 42, 7, 42, 419, 10, 42, 12, 42, 14, 42, 422, 11, 42, 5, 42, 424, 10, 42, 3, 42, 5, 42, 427, 10, 42, 3, 42, 3, 42, 3, 43, 3, 43, 3, 43, 3, 43, 7, 43, 435, 10, 43, 12, 43, 14, 43, 438, 11, 43, 5, 43, 440, 10, 43, 3, 43, 5, 43, 443, 10, 43, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 5, 46, 459, 10, 46, 3, 46, 3, 46, 3, 46, 5, 46, 464, 10, 46, 3, 46, 3, 46, 3, 46, 5, 46, 469, 10, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 7, 46, 485, 10, 46, 12, 46, 14, 46, 488, 11, 46, 3, 47, 3, 47, 3, 47, 7, 47, 493, 10, 47, 12, 47, 14, 47, 496, 11, 47, 3, 48, 3, 48, 3, 48, 3, 49, 3, 49, 3, 49, 3, 49, 3, 50, 3, 50, 3, 50, 3, 50, 5, 50, 509, 10, 50, 3, 50, 3, 50, 3, 50, 3, 50, 5, 50, 515, 10, 50, 3, 50, 3, 50, 3, 51, 3, 51, 5, 51, 521, 10, 51, 3, 52, 3, 52, 3, 52, 3, 53, 3, 53, 3, 53, 5, 53, 529, 10, 53, 3, 54, 3, 54, 3, 54, 3, 55, 3, 55, 3, 55, 3, 56, 3, 56, 3, 57, 3, 57, 3, 58, 3, 58, 3, 58, 3, 58, 3, 58, 5, 58, 546, 10, 58, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 7, 59, 554, 10, 59, 12, 59, 14, 59, 557, 11, 59, 3, 60, 3, 60, 3, 60, 3, 60, 3, 60, 3, 60, 7, 60, 565, 10, 60, 12, 60, 14, 60, 568, 11, 60, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 7, 61, 577, 10, 61, 12, 61, 14, 61, 580, 11, 61, 3, 62, 3, 62, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 7, 63, 590, 10, 63, 12, 63, 14, 63, 593, 11, 63, 3, 64, 3, 64, 3, 64, 3, 64, 3, 64, 3, 64, 7, 64, 601, 10, 64, 12, 64, 14, 64, 604, 11, 64, 3, 65, 3, 65, 3, 65, 3, 65, 3, 65, 3, 65, 7, 65, 612, 10, 65, 12, 65, 14, 65, 615, 11, 65, 3, 66, 3, 66, 3, 66, 3, 66, 3, 66, 3, 66, 7, 66, 623, 10, 66, 12, 66, 14, 66, 626, 11, 66, 3, 67, 3, 67, 3, 67, 3, 67, 3, 67, 3, 67, 7, 67, 634, 10, 67, 12, 67, 14, 67, 637, 11, 67, 3, 68, 3, 68, 3, 68, 3, 68, 3, 68, 3, 68, 7, 68, 645, 10, 68, 12, 68, 14, 68, 648, 11, 68, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 7, 69, 656, 10, 69, 12, 69, 14, 69, 659, 11, 69, 3, 70, 3, 70, 3, 70, 3, 70, 3, 70, 3, 70, 3, 70, 5, 70, 668, 10, 70, 3, 71, 3, 71, 3, 71, 3, 71, 3, 71, 5, 71, 675, 10, 71, 3, 72, 3, 72, 3, 73, 3, 73, 3, 73, 7, 73, 682, 10, 73, 12, 73, 14, 73, 685, 11, 73, 3, 74, 3, 74, 3, 74, 5, 74, 690, 10, 74, 3, 75, 3, 75, 3, 76, 3, 76, 3, 76, 3, 76, 3, 76, 3, 77, 3, 77, 3, 77, 3, 77, 3, 77, 3, 78, 3, 78, 3, 78, 2, 2, 13, 90, 116, 118, 120, 124, 126, 128, 130, 132, 134, 136, 79, 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, 50, 2, 52, 2, 54, 2, 56, 2, 58, 2, 60, 2, 62, 2, 64, 2, 66, 2, 68, 2, 70, 2, 72, 2, 74, 2, 76, 2, 78, 2, 80, 2, 82, 2, 84, 2, 86, 2, 88, 2, 90, 2, 92, 2, 94, 2, 96, 2, 98, 2, 100, 2, 102, 2, 104, 2, 106, 2, 108, 2, 110, 2, 112, 2, 114, 2, 116, 2, 118, 2, 120, 2, 122, 2, 124, 2, 126, 2, 128, 2, 130, 2, 132, 2, 134, 2, 136, 2, 138, 2, 140, 2, 142, 2, 144, 2, 146, 2, 148, 2, 150, 2, 152, 2, 154, 2, 2, 17, 3, 2, 7, 8, 3, 2, 14, 15, 3, 2, 26, 27, 3, 2, 76, 77, 4, 2, 75, 75, 78, 78, 3, 2, 29, 31, 4, 2, 44, 44, 46, 46, 6, 2, 43, 43, 45, 45, 53, 53, 69, 69, 3, 2, 47, 50, 4, 2, 43, 43, 45, 45, 3, 2, 70, 72, 3, 2, 62, 65, 3, 2, 60, 61, 3, 2, 54, 59, 4, 2, 29, 31, 74, 74, 2, 710, 2, 157, 3, 2, 2, 2, 4, 162, 3, 2, 2, 2, 6, 166, 3, 2, 2, 2, 8, 169, 3, 2, 2, 2, 10, 176, 3, 2, 2, 2, 12, 185, 3, 2, 2, 2, 14, 187, 3, 2, 2, 2, 16, 199, 3, 2, 2, 2, 18, 202, 3, 2, 2, 2, 20, 204, 3, 2, 2, 2, 22, 206, 3, 2, 2, 2, 24, 208, 3, 2, 2, 2, 26, 215, 3, 2, 2, 2, 28, 223, 3, 2, 2, 2, 30, 227, 3, 2, 2, 2, 32, 235, 3, 2, 2, 2, 34, 237, 3, 2, 2, 2, 36, 244, 3, 2, 2, 2, 38, 251, 3, 2, 2, 2, 40, 253, 3, 2, 2, 2, 42, 262, 3, 2, 2, 2, 44, 283, 3, 2, 2, 2, 46, 288, 3, 2, 2, 2, 48, 290, 3, 2, 2, 2, 50, 315, 3, 2, 2, 2, 52, 321, 3, 2, 2, 2, 54, 329, 3, 2, 2, 2, 56, 332, 3, 2, 2, 2, 58, 348, 3, 2, 2, 2, 60, 350, 3, 2, 2, 2, 62, 362, 3, 2, 2, 2, 64, 366, 3, 2, 2, 2, 66, 368, 3, 2, 2, 2, 68, 370, 3, 2, 2, 2, 70, 374, 3, 2, 2, 2, 72, 376, 3, 2, 2, 2, 74, 394, 3, 2, 2, 2, 76, 402, 3, 2, 2, 2, 78, 410, 3, 2, 2, 2, 80, 412, 3, 2, 2, 2, 82, 414, 3, 2, 2, 2, 84, 430, 3, 2, 2, 2, 86, 446, 3, 2, 2, 2, 88, 450, 3, 2, 2, 2, 90, 463, 3, 2, 2, 2, 92, 489, 3, 2, 2, 2, 94, 497, 3, 2, 2, 2, 96, 500, 3, 2, 2, 2, 98, 504, 3, 2, 2, 2, 100, 520, 3, 2, 2, 2, 102, 522, 3, 2, 2, 2, 104, 528, 3, 2, 2, 2, 106, 530, 3, 2, 2, 2, 108, 533, 3, 2, 2, 2, 110, 536, 3, 2, 2, 2, 112, 538, 3, 2, 2, 2, 114, 545, 3, 2, 2, 2, 116, 547, 3, 2, 2, 2, 118, 558, 3, 2, 2, 2, 120, 569, 3, 2, 2, 2, 122, 581, 3, 2, 2, 2, 124, 583, 3, 2, 2, 2, 126, 594, 3, 2, 2, 2, 128, 605, 3, 2, 2, 2, 130, 616, 3, 2, 2, 2, 132, 627, 3, 2, 2, 2, 134, 638, 3, 2, 2, 2, 136, 649, 3, 2, 2, 2, 138, 667, 3, 2, 2, 2, 140, 674, 3, 2, 2, 2, 142, 676, 3, 2, 2, 2, 144, 678, 3, 2, 2, 2, 146, 689, 3, 2, 2, 2, 148, 691, 3, 2, 2, 2, 150, 693, 3, 2, 2, 2, 152, 698, 3, 2, 2, 2, 154, 703, 3, 2, 2, 2, 156, 158, 5, 4, 3, 2, 157, 156, 3, 2, 2, 2, 157, 158, 3, 2, 2, 2, 158, 159, 3, 2, 2, 2, 159, 160, 7, 2, 2, 3, 160, 3, 3, 2, 2, 2, 161, 163, 5, 6, 4, 2, 162, 161, 3, 2, 2, 2, 163, 164, 3, 2, 2, 2, 164, 162, 3, 2, 2, 2, 164, 165, 3, 2, 2, 2, 165, 5, 3, 2, 2, 2, 166, 167, 5, 8, 5, 2, 167, 7, 3, 2, 2, 2, 168, 170, 5, 10, 6, 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, 9, 3, 2, 2, 2, 173, 177, 5, 32, 17, 2, 174, 177, 5, 12, 7, 2, 175, 177, 7, 33, 2, 2, 176, 173, 3, 2, 2, 2, 176, 174, 3, 2, 2, 2, 176, 175, 3, 2, 2, 2, 177, 11, 3, 2, 2, 2, 178, 179, 5, 16, 9, 2, 179, 180, 7, 33, 2, 2, 180, 186, 3, 2, 2, 2, 181, 183, 5, 14, 8, 2, 182, 184, 7, 33, 2, 2, 183, 182, 3, 2, 2, 2, 183, 184, 3, 2, 2, 2, 184, 186, 3, 2, 2, 2, 185, 178, 3, 2, 2, 2, 185, 181, 3, 2, 2, 2, 186, 13, 3, 2, 2, 2, 187, 188, 7, 22, 2, 2, 188, 189, 5, 20, 11, 2, 189, 191, 7, 36, 2, 2, 190, 192, 5, 26, 14, 2, 191, 190, 3, 2, 2, 2, 191, 192, 3, 2, 2, 2, 192, 193, 3, 2, 2, 2, 193, 194, 7, 37, 2, 2, 194, 195, 7, 25, 2, 2, 195, 197, 5, 146, 74, 2, 196, 198, 5, 34, 18, 2, 197, 196, 3, 2, 2, 2, 197, 198, 3, 2, 2, 2, 198, 15, 3, 2, 2, 2, 199, 200, 5, 18, 10, 2, 200, 201, 5, 24, 13, 2, 201, 17, 3, 2, 2, 2, 202, 203, 9, 2, 2, 2, 203, 19, 3, 2, 2, 2, 204, 205, 5, 22, 12, 2, 205, 21, 3, 2, 2, 2, 206, 207, 7, 74, 2, 2, 207, 23, 3, 2, 2, 2, 208, 209, 5, 20, 11, 2, 209, 210, 7, 35, 2, 2, 210, 213, 5, 146, 74, 2, 211, 212, 7, 54, 2, 2, 212, 214, 5, 30, 16, 2, 213, 211, 3, 2, 2, 2, 213, 214, 3, 2, 2, 2, 214, 25, 3, 2, 2, 2, 215, 220, 5, 28, 15, 2, 216, 217, 7, 32, 2, 2, 217, 219, 5, 28, 15, 2, 218, 216, 3, 2, 2, 2, 219, 222, 3, 2, 2, 2, 220, 218, 3, 2, 2, 2, 220, 221, 3, 2, 2, 2, 221, 27, 3, 2, 2, 2, 222, 220, 3, 2, 2, 2, 223, 224, 5, 20, 11, 2, 224, 225, 7, 35, 2, 2, 225, 226, 5, 146, 74, 2, 226, 29, 3, 2, 2, 2, 227, 228, 5, 140, 71, 2, 228, 31, 3, 2, 2, 2, 229, 236, 5, 36, 19, 2, 230, 236, 5, 38, 20, 2, 231, 236, 5, 46, 24, 2, 232, 236, 5, 54, 28, 2, 233, 236, 5, 56, 29, 2, 234, 236, 5, 34, 18, 2, 235, 229, 3, 2, 2, 2, 235, 230, 3, 2, 2, 2, 235, 231, 3, 2, 2, 2, 235, 232, 3, 2, 2, 2, 235, 233, 3, 2, 2, 2, 235, 234, 3, 2, 2, 2, 236, 33, 3, 2, 2, 2, 237, 238, 6, 18, 2, 2, 238, 240, 7, 41, 2, 2, 239, 241, 5, 8, 5, 2, 240, 239, 3, 2, 2, 2, 240, 241, 3, 2, 2, 2, 241, 242, 3, 2, 2, 2, 242, 243, 7, 42, 2, 2, 243, 35, 3, 2, 2, 2, 244, 245, 8, 19, 1, 2, 245, 246, 5, 144, 73, 2, 246, 247, 7, 33, 2, 2, 247, 248, 8, 19, 1, 2, 248, 37, 3, 2, 2, 2, 249, 252, 5, 40, 21, 2, 250, 252, 5, 42, 22, 2, 251, 249, 3, 2, 2, 2, 251, 250, 3, 2, 2, 2, 252, 39, 3, 2, 2, 2, 253, 254, 7, 18, 2, 2, 254, 255, 7, 36, 2, 2, 255, 256, 5, 144, 73, 2, 256, 257, 7, 37, 2, 2, 257, 260, 5, 32, 17, 2, 258, 259, 7, 19, 2, 2, 259, 261, 5, 32, 17, 2, 260, 258, 3, 2, 2, 2, 260, 261, 3, 2, 2, 2, 261, 41, 3, 2, 2, 2, 262, 263, 7, 11, 2, 2, 263, 264, 7, 36, 2, 2, 264, 265, 5, 144, 73, 2, 265, 266, 7, 37, 2, 2, 266, 270, 7, 41, 2, 2, 267, 269, 5, 44, 23, 2, 268, 267, 3, 2, 2, 2, 269, 272, 3, 2, 2, 2, 270, 268, 3, 2, 2, 2, 270, 271, 3, 2, 2, 2, 271, 273, 3, 2, 2, 2, 272, 270, 3, 2, 2, 2, 273, 274, 7, 42, 2, 2, 274, 43, 3, 2, 2, 2, 275, 276, 7, 12, 2, 2, 276, 277, 5, 144, 73, 2, 277, 278, 7, 35, 2, 2, 278, 279, 5, 32, 17, 2, 279, 284, 3, 2, 2, 2, 280, 281, 7, 13, 2, 2, 281, 282, 7, 35, 2, 2, 282, 284, 5, 32, 17, 2, 283, 275, 3, 2, 2, 2, 283, 280, 3, 2, 2, 2, 284, 45, 3, 2, 2, 2, 285, 289, 5, 48, 25, 2, 286, 289, 5, 50, 26, 2, 287, 289, 5, 52, 27, 2, 288, 285, 3, 2, 2, 2, 288, 286, 3, 2, 2, 2, 288, 287, 3, 2, 2, 2, 289, 47, 3, 2, 2, 2, 290, 291, 7, 20, 2, 2, 291, 298, 7, 36, 2, 2, 292, 295, 5, 16, 9, 2, 293, 295, 5, 144, 73, 2, 294, 292, 3, 2, 2, 2, 294, 293, 3, 2, 2, 2, 295, 296, 3, 2, 2, 2, 296, 297, 8, 25, 1, 2, 297, 299, 3, 2, 2, 2, 298, 294, 3, 2, 2, 2, 298, 299, 3, 2, 2, 2, 299, 300, 3, 2, 2, 2, 300, 304, 7, 33, 2, 2, 301, 302, 5, 144, 73, 2, 302, 303, 8, 25, 1, 2, 303, 305, 3, 2, 2, 2, 304, 301, 3, 2, 2, 2, 304, 305, 3, 2, 2, 2, 305, 306, 3, 2, 2, 2, 306, 310, 7, 33, 2, 2, 307, 308, 5, 144, 73, 2, 308, 309, 8, 25, 1, 2, 309, 311, 3, 2, 2, 2, 310, 307, 3, 2, 2, 2, 310, 311, 3, 2, 2, 2, 311, 312, 3, 2, 2, 2, 312, 313, 7, 37, 2, 2, 313, 314, 5, 32, 17, 2, 314, 49, 3, 2, 2, 2, 315, 316, 7, 17, 2, 2, 316, 317, 7, 36, 2, 2, 317, 318, 5, 144, 73, 2, 318, 319, 7, 37, 2, 2, 319, 320, 5, 32, 17, 2, 320, 51, 3, 2, 2, 2, 321, 322, 7, 16, 2, 2, 322, 323, 5, 32, 17, 2, 323, 324, 7, 17, 2, 2, 324, 325, 7, 36, 2, 2, 325, 326, 5, 144, 73, 2, 326, 327, 7, 37, 2, 2, 327, 328, 7, 33, 2, 2, 328, 53, 3, 2, 2, 2, 329, 330, 9, 3, 2, 2, 330, 331, 7, 33, 2, 2, 331, 55, 3, 2, 2, 2, 332, 334, 7, 23, 2, 2, 333, 335, 5, 144, 73, 2, 334, 333, 3, 2, 2, 2, 334, 335, 3, 2, 2, 2, 335, 336, 3, 2, 2, 2, 336, 337, 7, 33, 2, 2, 337, 57, 3, 2, 2, 2, 338, 349, 5, 62, 32, 2, 339, 349, 5, 82, 42, 2, 340, 349, 5, 84, 43, 2, 341, 349, 5, 64, 33, 2, 342, 349, 5, 66, 34, 2, 343, 349, 5, 72, 37, 2, 344, 349, 5, 74, 38, 2, 345, 349, 5, 80, 41, 2, 346, 349, 5, 88, 45, 2, 347, 349, 5, 60, 31, 2, 348, 338, 3, 2, 2, 2, 348, 339, 3, 2, 2, 2, 348, 340, 3, 2, 2, 2, 348, 341, 3, 2, 2, 2, 348, 342, 3, 2, 2, 2, 348, 343, 3, 2, 2, 2, 348, 344, 3, 2, 2, 2, 348, 345, 3, 2, 2, 2, 348, 346, 3, 2, 2, 2, 348, 347, 3, 2, 2, 2, 349, 59, 3, 2, 2, 2, 350, 352, 7, 36, 2, 2, 351, 353, 5, 26, 14, 2, 352, 351, 3, 2, 2, 2, 352, 353, 3, 2, 2, 2, 353, 354, 3, 2, 2, 2, 354, 355, 7, 37, 2, 2, 355, 356, 7, 35, 2, 2, 356, 357, 5, 146, 74, 2, 357, 360, 7, 25, 2, 2, 358, 361, 5, 144, 73, 2, 359, 361, 5, 34, 18, 2, 360, 358, 3, 2, 2, 2, 360, 359, 3, 2, 2, 2, 361, 61, 3, 2, 2, 2, 362, 363, 7, 36, 2, 2, 363, 364, 5, 144, 73, 2, 364, 365, 7, 37, 2, 2, 365, 63, 3, 2, 2, 2, 366, 367, 9, 4, 2, 2, 367, 65, 3, 2, 2, 2, 368, 369, 5, 68, 35, 2, 369, 67, 3, 2, 2, 2, 370, 371, 7, 74, 2, 2, 371, 69, 3, 2, 2, 2, 372, 375, 5, 68, 35, 2, 373, 375, 5, 72, 37, 2, 374, 372, 3, 2, 2, 2, 374, 373, 3, 2, 2, 2, 375, 71, 3, 2, 2, 2, 376, 377, 9, 5, 2, 2, 377, 73, 3, 2, 2, 2, 378, 382, 7, 81, 2, 2, 379, 381, 5, 76, 39, 2, 380, 379, 3, 2, 2, 2, 381, 384, 3, 2, 2, 2, 382, 380, 3, 2, 2, 2, 382, 383, 3, 2, 2, 2, 383, 385, 3, 2, 2, 2, 384, 382, 3, 2, 2, 2, 385, 395, 7, 83, 2, 2, 386, 390, 7, 82, 2, 2, 387, 389, 5, 78, 40, 2, 388, 387, 3, 2, 2, 2, 389, 392, 3, 2, 2, 2, 390, 388, 3, 2, 2, 2, 390, 391, 3, 2, 2, 2, 391, 393, 3, 2, 2, 2, 392, 390, 3, 2, 2, 2, 393, 395, 7, 85, 2, 2, 394, 378, 3, 2, 2, 2, 394, 386, 3, 2, 2, 2, 395, 75, 3, 2, 2, 2, 396, 403, 7, 84, 2, 2, 397, 399, 7, 3, 2, 2, 398, 400, 5, 144, 73, 2, 399, 398, 3, 2, 2, 2, 399, 400, 3, 2, 2, 2, 400, 401, 3, 2, 2, 2, 401, 403, 7, 40, 2, 2, 402, 396, 3, 2, 2, 2, 402, 397, 3, 2, 2, 2, 403, 77, 3, 2, 2, 2, 404, 411, 7, 86, 2, 2, 405, 407, 7, 3, 2, 2, 406, 408, 5, 144, 73, 2, 407, 406, 3, 2, 2, 2, 407, 408, 3, 2, 2, 2, 408, 409, 3, 2, 2, 2, 409, 411, 7, 40, 2, 2, 410, 404, 3, 2, 2, 2, 410, 405, 3, 2, 2, 2, 411, 79, 3, 2, 2, 2, 412, 413, 9, 6, 2, 2, 413, 81, 3, 2, 2, 2, 414, 423, 7, 38, 2, 2, 415, 420, 5, 144, 73, 2, 416, 417, 7, 32, 2, 2, 417, 419, 5, 144, 73, 2, 418, 416, 3, 2, 2, 2, 419, 422, 3, 2, 2, 2, 420, 418, 3, 2, 2, 2, 420, 421, 3, 2, 2, 2, 421, 424, 3, 2, 2, 2, 422, 420, 3, 2, 2, 2, 423, 415, 3, 2, 2, 2, 423, 424, 3, 2, 2, 2, 424, 426, 3, 2, 2, 2, 425, 427, 7, 32, 2, 2, 426, 425, 3, 2, 2, 2, 426, 427, 3, 2, 2, 2, 427, 428, 3, 2, 2, 2, 428, 429, 7, 39, 2, 2, 429, 83, 3, 2, 2, 2, 430, 439, 7, 41, 2, 2, 431, 436, 5, 86, 44, 2, 432, 433, 7, 32, 2, 2, 433, 435, 5, 86, 44, 2, 434, 432, 3, 2, 2, 2, 435, 438, 3, 2, 2, 2, 436, 434, 3, 2, 2, 2, 436, 437, 3, 2, 2, 2, 437, 440, 3, 2, 2, 2, 438, 436, 3, 2, 2, 2, 439, 431, 3, 2, 2, 2, 439, 440, 3, 2, 2, 2, 440, 442, 3, 2, 2, 2, 441, 443, 7, 32, 2, 2, 442, 441, 3, 2, 2, 2, 442, 443, 3, 2, 2, 2, 443, 444, 3, 2, 2, 2, 444, 445, 7, 42, 2, 2, 445, 85, 3, 2, 2, 2, 446, 447, 5, 70, 36, 2, 447, 448, 7, 35, 2, 2, 448, 449, 5, 144, 73, 2, 449, 87, 3, 2, 2, 2, 450, 451, 9, 7, 2, 2, 451, 89, 3, 2, 2, 2, 452, 453, 8, 46, 1, 2, 453, 464, 5, 58, 30, 2, 454, 455, 7, 24, 2, 2, 455, 456, 5, 90, 46, 2, 456, 458, 7, 36, 2, 2, 457, 459, 5, 92, 47, 2, 458, 457, 3, 2, 2, 2, 458, 459, 3, 2, 2, 2, 459, 460, 3, 2, 2, 2, 460, 461, 7, 37, 2, 2, 461, 462, 8, 46, 1, 2, 462, 464, 3, 2, 2, 2, 463, 452, 3, 2, 2, 2, 463, 454, 3, 2, 2, 2, 464, 486, 3, 2, 2, 2, 465, 466, 12, 7, 2, 2, 466, 468, 7, 36, 2, 2, 467, 469, 5, 92, 47, 2, 468, 467, 3, 2, 2, 2, 468, 469, 3, 2, 2, 2, 469, 470, 3, 2, 2, 2, 470, 471, 7, 37, 2, 2, 471, 485, 8, 46, 1, 2, 472, 473, 12, 5, 2, 2, 473, 474, 5, 94, 48, 2, 474, 475, 8, 46, 1, 2, 475, 485, 3, 2, 2, 2, 476, 477, 12, 4, 2, 2, 477, 478, 5, 96, 49, 2, 478, 479, 8, 46, 1, 2, 479, 485, 3, 2, 2, 2, 480, 481, 12, 3, 2, 2, 481, 482, 5, 98, 50, 2, 482, 483, 8, 46, 1, 2, 483, 485, 3, 2, 2, 2, 484, 465, 3, 2, 2, 2, 484, 472, 3, 2, 2, 2, 484, 476, 3, 2, 2, 2, 484, 480, 3, 2, 2, 2, 485, 488, 3, 2, 2, 2, 486, 484, 3, 2, 2, 2, 486, 487, 3, 2, 2, 2, 487, 91, 3, 2, 2, 2, 488, 486, 3, 2, 2, 2, 489, 494, 5, 140, 71, 2, 490, 491, 7, 32, 2, 2, 491, 493, 5, 140, 71, 2, 492, 490, 3, 2, 2, 2, 493, 496, 3, 2, 2, 2, 494, 492, 3, 2, 2, 2, 494, 495, 3, 2, 2, 2, 495, 93, 3, 2, 2, 2, 496, 494, 3, 2, 2, 2, 497, 498, 7, 73, 2, 2, 498, 499, 5, 68, 35, 2, 499, 95, 3, 2, 2, 2, 500, 501, 7, 38, 2, 2, 501, 502, 5, 144, 73, 2, 502, 503, 7, 39, 2, 2, 503, 97, 3, 2, 2, 2, 504, 508, 7, 38, 2, 2, 505, 506, 5, 144, 73, 2, 506, 507, 8, 50, 1, 2, 507, 509, 3, 2, 2, 2, 508, 505, 3, 2, 2, 2, 508, 509, 3, 2, 2, 2, 509, 510, 3, 2, 2, 2, 510, 514, 7, 35, 2, 2, 511, 512, 5, 144, 73, 2, 512, 513, 8, 50, 1, 2, 513, 515, 3, 2, 2, 2, 514, 511, 3, 2, 2, 2, 514, 515, 3, 2, 2, 2, 515, 516, 3, 2, 2, 2, 516, 517, 7, 39, 2, 2, 517, 99, 3, 2, 2, 2, 518, 521, 5, 90, 46, 2, 519, 521, 5, 102, 52, 2, 520, 518, 3, 2, 2, 2, 520, 519, 3, 2, 2, 2, 521, 101, 3, 2, 2, 2, 522, 523, 5, 90, 46, 2, 523, 524, 5, 110, 56, 2, 524, 103, 3, 2, 2, 2, 525, 529, 5, 100, 51, 2, 526, 529, 5, 106, 54, 2, 527, 529, 5, 108, 55, 2, 528, 525, 3, 2, 2, 2, 528, 526, 3, 2, 2, 2, 528, 527, 3, 2, 2, 2, 529, 105, 3, 2, 2, 2, 530, 531, 5, 110, 56, 2, 531, 532, 5, 100, 51, 2, 532, 107, 3, 2, 2, 2, 533, 534, 5, 112, 57, 2, 534, 535, 5, 100, 51, 2, 535, 109, 3, 2, 2, 2, 536, 537, 9, 8, 2, 2, 537, 111, 3, 2, 2, 2, 538, 539, 9, 9, 2, 2, 539, 113, 3, 2, 2, 2, 540, 546, 5, 104, 53, 2, 541, 542, 5, 104, 53, 2, 542, 543, 7, 9, 2, 2, 543, 544, 5, 146, 74, 2, 544, 546, 3, 2, 2, 2, 545, 540, 3, 2, 2, 2, 545, 541, 3, 2, 2, 2, 546, 115, 3, 2, 2, 2, 547, 548, 8, 59, 1, 2, 548, 549, 5, 114, 58, 2, 549, 555, 3, 2, 2, 2, 550, 551, 12, 3, 2, 2, 551, 552, 9, 10, 2, 2, 552, 554, 5, 114, 58, 2, 553, 550, 3, 2, 2, 2, 554, 557, 3, 2, 2, 2, 555, 553, 3, 2, 2, 2, 555, 556, 3, 2, 2, 2, 556, 117, 3, 2, 2, 2, 557, 555, 3, 2, 2, 2, 558, 559, 8, 60, 1, 2, 559, 560, 5, 116, 59, 2, 560, 566, 3, 2, 2, 2, 561, 562, 12, 3, 2, 2, 562, 563, 9, 11, 2, 2, 563, 565, 5, 116, 59, 2, 564, 561, 3, 2, 2, 2, 565, 568, 3, 2, 2, 2, 566, 564, 3, 2, 2, 2, 566, 567, 3, 2, 2, 2, 567, 119, 3, 2, 2, 2, 568, 566, 3, 2, 2, 2, 569, 570, 8, 61, 1, 2, 570, 571, 5, 118, 60, 2, 571, 578, 3, 2, 2, 2, 572, 573, 12, 3, 2, 2, 573, 574, 5, 122, 62, 2, 574, 575, 5, 128, 65, 2, 575, 577, 3, 2, 2, 2, 576, 572, 3, 2, 2, 2, 577, 580, 3, 2, 2, 2, 578, 576, 3, 2, 2, 2, 578, 579, 3, 2, 2, 2, 579, 121, 3, 2, 2, 2, 580, 578, 3, 2, 2, 2, 581, 582, 9, 12, 2, 2, 582, 123, 3, 2, 2, 2, 583, 584, 8, 63, 1, 2, 584, 585, 5, 120, 61, 2, 585, 591, 3, 2, 2, 2, 586, 587, 12, 3, 2, 2, 587, 588, 9, 13, 2, 2, 588, 590, 5, 120, 61, 2, 589, 586, 3, 2, 2, 2, 590, 593, 3, 2, 2, 2, 591, 589, 3, 2, 2, 2, 591, 592, 3, 2, 2, 2, 592, 125, 3, 2, 2, 2, 593, 591, 3, 2, 2, 2, 594, 595, 8, 64, 1, 2, 595, 596, 5, 124, 63, 2, 596, 602, 3, 2, 2, 2, 597, 598, 12, 3, 2, 2, 598, 599, 9, 14, 2, 2, 599, 601, 5, 124, 63, 2, 600, 597, 3, 2, 2, 2, 601, 604, 3, 2, 2, 2, 602, 600, 3, 2, 2, 2, 602, 603, 3, 2, 2, 2, 603, 127, 3, 2, 2, 2, 604, 602, 3, 2, 2, 2, 605, 606, 8, 65, 1, 2, 606, 607, 5, 126, 64, 2, 607, 613, 3, 2, 2, 2, 608, 609, 12, 3, 2, 2, 609, 610, 7, 66, 2, 2, 610, 612, 5, 126, 64, 2, 611, 608, 3, 2, 2, 2, 612, 615, 3, 2, 2, 2, 613, 611, 3, 2, 2, 2, 613, 614, 3, 2, 2, 2, 614, 129, 3, 2, 2, 2, 615, 613, 3, 2, 2, 2, 616, 617, 8, 66, 1, 2, 617, 618, 5, 128, 65, 2, 618, 624, 3, 2, 2, 2, 619, 620, 12, 3, 2, 2, 620, 621, 7, 68, 2, 2, 621, 623, 5, 128, 65, 2, 622, 619, 3, 2, 2, 2, 623, 626, 3, 2, 2, 2, 624, 622, 3, 2, 2, 2, 624, 625, 3, 2, 2, 2, 625, 131, 3, 2, 2, 2, 626, 624, 3, 2, 2, 2, 627, 628, 8, 67, 1, 2, 628, 629, 5, 130, 66, 2, 629, 635, 3, 2, 2, 2, 630, 631, 12, 3, 2, 2, 631, 632, 7, 67, 2, 2, 632, 634, 5, 130, 66, 2, 633, 630, 3, 2, 2, 2, 634, 637, 3, 2, 2, 2, 635, 633, 3, 2, 2, 2, 635, 636, 3, 2, 2, 2, 636, 133, 3, 2, 2, 2, 637, 635, 3, 2, 2, 2, 638, 639, 8, 68, 1, 2, 639, 640, 5, 132, 67, 2, 640, 646, 3, 2, 2, 2, 641, 642, 12, 3, 2, 2, 642, 643, 7, 51, 2, 2, 643, 645, 5, 132, 67, 2, 644, 641, 3, 2, 2, 2, 645, 648, 3, 2, 2, 2, 646, 644, 3, 2, 2, 2, 646, 647, 3, 2, 2, 2, 647, 135, 3, 2, 2, 2, 648, 646, 3, 2, 2, 2, 649, 650, 8, 69, 1, 2, 650, 651, 5, 134, 68, 2, 651, 657, 3, 2, 2, 2, 652, 653, 12, 3, 2, 2, 653, 654, 7, 52, 2, 2, 654, 656, 5, 134, 68, 2, 655, 652, 3, 2, 2, 2, 656, 659, 3, 2, 2, 2, 657, 655, 3, 2, 2, 2, 657, 658, 3, 2, 2, 2, 658, 137, 3, 2, 2, 2, 659, 657, 3, 2, 2, 2, 660, 668, 5, 136, 69, 2, 661, 662, 5, 136, 69, 2, 662, 663, 7, 34, 2, 2, 663, 664, 5, 138, 70, 2, 664, 665, 7, 35, 2, 2, 665, 666, 5, 138, 70, 2, 666, 668, 3, 2, 2, 2, 667, 660, 3, 2, 2, 2, 667, 661, 3, 2, 2, 2, 668, 139, 3, 2, 2, 2, 669, 675, 5, 138, 70, 2, 670, 671, 5, 90, 46, 2, 671, 672, 5, 142, 72, 2, 672, 673, 5, 140, 71, 2, 673, 675, 3, 2, 2, 2, 674, 669, 3, 2, 2, 2, 674, 670, 3, 2, 2, 2, 675, 141, 3, 2, 2, 2, 676, 677, 9, 15, 2, 2, 677, 143, 3, 2, 2, 2, 678, 683, 5, 140, 71, 2, 679, 680, 7, 32, 2, 2, 680, 682, 5, 140, 71, 2, 681, 679, 3, 2, 2, 2, 682, 685, 3, 2, 2, 2, 683, 681, 3, 2, 2, 2, 683, 684, 3, 2, 2, 2, 684, 145, 3, 2, 2, 2, 685, 683, 3, 2, 2, 2, 686, 690, 5, 148, 75, 2, 687, 690, 5, 150, 76, 2, 688, 690, 5, 152, 77, 2, 689, 686, 3, 2, 2, 2, 689, 687, 3, 2, 2, 2, 689, 688, 3, 2, 2, 2, 690, 147, 3, 2, 2, 2, 691, 692, 5, 154, 78, 2, 692, 149, 3, 2, 2, 2, 693, 694, 5, 154, 78, 2, 694, 695, 7, 62, 2, 2, 695, 696, 5, 154, 78, 2, 696, 697, 7, 64, 2, 2, 697, 151, 3, 2, 2, 2, 698, 699, 7, 28, 2, 2, 699, 700, 7, 36, 2, 2, 700, 701, 5, 154, 78, 2, 701, 702, 7, 37, 2, 2, 702, 153, 3, 2, 2, 2, 703, 704, 9, 16, 2, 2, 704, 155, 3, 2, 2, 2, 66, 157, 164, 171, 176, 183, 185, 191, 197, 213, 220, 235, 240, 251, 260, 270, 283, 288, 294, 298, 304, 310, 334, 348, 352, 360, 374, 382, 390, 394, 399, 402, 407, 410, 420, 423, 426, 436, 439, 442, 458, 463, 468, 484, 486, 494, 508, 514, 520, 528, 545, 555, 566, 578, 591, 602, 613, 624, 635, 646, 657, 667, 674, 683, 689] \ No newline at end of file +[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 3, 88, 719, 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, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 4, 68, 9, 68, 4, 69, 9, 69, 4, 70, 9, 70, 4, 71, 9, 71, 4, 72, 9, 72, 4, 73, 9, 73, 4, 74, 9, 74, 4, 75, 9, 75, 4, 76, 9, 76, 4, 77, 9, 77, 4, 78, 9, 78, 4, 79, 9, 79, 4, 80, 9, 80, 3, 2, 5, 2, 162, 10, 2, 3, 2, 3, 2, 3, 3, 6, 3, 167, 10, 3, 13, 3, 14, 3, 168, 3, 4, 3, 4, 3, 5, 6, 5, 174, 10, 5, 13, 5, 14, 5, 175, 3, 6, 3, 6, 3, 6, 5, 6, 181, 10, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 5, 7, 189, 10, 7, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 5, 10, 201, 10, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 5, 14, 213, 10, 14, 3, 14, 3, 14, 3, 14, 3, 14, 5, 14, 219, 10, 14, 3, 15, 3, 15, 3, 15, 7, 15, 224, 10, 15, 12, 15, 14, 15, 227, 11, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 5, 19, 249, 10, 19, 3, 20, 3, 20, 3, 20, 5, 20, 254, 10, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 5, 22, 265, 10, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 5, 23, 274, 10, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 7, 24, 282, 10, 24, 12, 24, 14, 24, 285, 11, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 5, 25, 297, 10, 25, 3, 26, 3, 26, 3, 26, 5, 26, 302, 10, 26, 3, 27, 3, 27, 3, 27, 3, 27, 5, 27, 308, 10, 27, 3, 27, 3, 27, 5, 27, 312, 10, 27, 3, 27, 3, 27, 3, 27, 3, 27, 5, 27, 318, 10, 27, 3, 27, 3, 27, 3, 27, 3, 27, 5, 27, 324, 10, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 5, 31, 348, 10, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 5, 32, 362, 10, 32, 3, 33, 3, 33, 5, 33, 366, 10, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 5, 33, 374, 10, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 36, 3, 36, 3, 37, 3, 37, 3, 38, 3, 38, 5, 38, 388, 10, 38, 3, 39, 3, 39, 3, 40, 3, 40, 7, 40, 394, 10, 40, 12, 40, 14, 40, 397, 11, 40, 3, 40, 3, 40, 3, 40, 7, 40, 402, 10, 40, 12, 40, 14, 40, 405, 11, 40, 3, 40, 5, 40, 408, 10, 40, 3, 41, 3, 41, 3, 41, 5, 41, 413, 10, 41, 3, 41, 5, 41, 416, 10, 41, 3, 42, 3, 42, 3, 42, 5, 42, 421, 10, 42, 3, 42, 5, 42, 424, 10, 42, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, 44, 7, 44, 432, 10, 44, 12, 44, 14, 44, 435, 11, 44, 5, 44, 437, 10, 44, 3, 44, 5, 44, 440, 10, 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 45, 3, 45, 7, 45, 448, 10, 45, 12, 45, 14, 45, 451, 11, 45, 5, 45, 453, 10, 45, 3, 45, 5, 45, 456, 10, 45, 3, 45, 3, 45, 3, 46, 3, 46, 3, 46, 3, 46, 3, 47, 3, 47, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 5, 48, 472, 10, 48, 3, 48, 3, 48, 3, 48, 5, 48, 477, 10, 48, 3, 48, 3, 48, 3, 48, 5, 48, 482, 10, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 7, 48, 498, 10, 48, 12, 48, 14, 48, 501, 11, 48, 3, 49, 3, 49, 3, 49, 7, 49, 506, 10, 49, 12, 49, 14, 49, 509, 11, 49, 3, 50, 3, 50, 3, 50, 3, 51, 3, 51, 3, 51, 3, 51, 3, 52, 3, 52, 3, 52, 3, 52, 5, 52, 522, 10, 52, 3, 52, 3, 52, 3, 52, 3, 52, 5, 52, 528, 10, 52, 3, 52, 3, 52, 3, 53, 3, 53, 5, 53, 534, 10, 53, 3, 54, 3, 54, 3, 54, 3, 55, 3, 55, 3, 55, 5, 55, 542, 10, 55, 3, 56, 3, 56, 3, 56, 3, 57, 3, 57, 3, 57, 3, 58, 3, 58, 3, 59, 3, 59, 3, 60, 3, 60, 3, 60, 3, 60, 3, 60, 5, 60, 559, 10, 60, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 7, 61, 567, 10, 61, 12, 61, 14, 61, 570, 11, 61, 3, 62, 3, 62, 3, 62, 3, 62, 3, 62, 3, 62, 7, 62, 578, 10, 62, 12, 62, 14, 62, 581, 11, 62, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 7, 63, 590, 10, 63, 12, 63, 14, 63, 593, 11, 63, 3, 64, 3, 64, 3, 65, 3, 65, 3, 65, 3, 65, 3, 65, 3, 65, 7, 65, 603, 10, 65, 12, 65, 14, 65, 606, 11, 65, 3, 66, 3, 66, 3, 66, 3, 66, 3, 66, 3, 66, 7, 66, 614, 10, 66, 12, 66, 14, 66, 617, 11, 66, 3, 67, 3, 67, 3, 67, 3, 67, 3, 67, 3, 67, 7, 67, 625, 10, 67, 12, 67, 14, 67, 628, 11, 67, 3, 68, 3, 68, 3, 68, 3, 68, 3, 68, 3, 68, 7, 68, 636, 10, 68, 12, 68, 14, 68, 639, 11, 68, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 7, 69, 647, 10, 69, 12, 69, 14, 69, 650, 11, 69, 3, 70, 3, 70, 3, 70, 3, 70, 3, 70, 3, 70, 7, 70, 658, 10, 70, 12, 70, 14, 70, 661, 11, 70, 3, 71, 3, 71, 3, 71, 3, 71, 3, 71, 3, 71, 7, 71, 669, 10, 71, 12, 71, 14, 71, 672, 11, 71, 3, 72, 3, 72, 3, 72, 3, 72, 3, 72, 3, 72, 3, 72, 5, 72, 681, 10, 72, 3, 73, 3, 73, 3, 73, 3, 73, 3, 73, 5, 73, 688, 10, 73, 3, 74, 3, 74, 3, 75, 3, 75, 3, 75, 7, 75, 695, 10, 75, 12, 75, 14, 75, 698, 11, 75, 3, 76, 3, 76, 3, 76, 5, 76, 703, 10, 76, 3, 77, 3, 77, 3, 78, 3, 78, 3, 78, 3, 78, 3, 78, 3, 79, 3, 79, 3, 79, 3, 79, 3, 79, 3, 80, 3, 80, 3, 80, 2, 2, 13, 94, 120, 122, 124, 128, 130, 132, 134, 136, 138, 140, 81, 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, 50, 2, 52, 2, 54, 2, 56, 2, 58, 2, 60, 2, 62, 2, 64, 2, 66, 2, 68, 2, 70, 2, 72, 2, 74, 2, 76, 2, 78, 2, 80, 2, 82, 2, 84, 2, 86, 2, 88, 2, 90, 2, 92, 2, 94, 2, 96, 2, 98, 2, 100, 2, 102, 2, 104, 2, 106, 2, 108, 2, 110, 2, 112, 2, 114, 2, 116, 2, 118, 2, 120, 2, 122, 2, 124, 2, 126, 2, 128, 2, 130, 2, 132, 2, 134, 2, 136, 2, 138, 2, 140, 2, 142, 2, 144, 2, 146, 2, 148, 2, 150, 2, 152, 2, 154, 2, 156, 2, 158, 2, 2, 17, 3, 2, 7, 8, 3, 2, 14, 15, 3, 2, 28, 29, 3, 2, 78, 79, 4, 2, 77, 77, 80, 80, 3, 2, 31, 33, 4, 2, 46, 46, 48, 48, 6, 2, 45, 45, 47, 47, 55, 55, 71, 71, 3, 2, 49, 52, 4, 2, 45, 45, 47, 47, 3, 2, 72, 74, 3, 2, 64, 67, 3, 2, 62, 63, 3, 2, 56, 61, 4, 2, 31, 33, 76, 76, 2, 722, 2, 161, 3, 2, 2, 2, 4, 166, 3, 2, 2, 2, 6, 170, 3, 2, 2, 2, 8, 173, 3, 2, 2, 2, 10, 180, 3, 2, 2, 2, 12, 188, 3, 2, 2, 2, 14, 190, 3, 2, 2, 2, 16, 193, 3, 2, 2, 2, 18, 195, 3, 2, 2, 2, 20, 202, 3, 2, 2, 2, 22, 204, 3, 2, 2, 2, 24, 206, 3, 2, 2, 2, 26, 208, 3, 2, 2, 2, 28, 220, 3, 2, 2, 2, 30, 228, 3, 2, 2, 2, 32, 232, 3, 2, 2, 2, 34, 237, 3, 2, 2, 2, 36, 248, 3, 2, 2, 2, 38, 250, 3, 2, 2, 2, 40, 257, 3, 2, 2, 2, 42, 264, 3, 2, 2, 2, 44, 266, 3, 2, 2, 2, 46, 275, 3, 2, 2, 2, 48, 296, 3, 2, 2, 2, 50, 301, 3, 2, 2, 2, 52, 303, 3, 2, 2, 2, 54, 328, 3, 2, 2, 2, 56, 334, 3, 2, 2, 2, 58, 342, 3, 2, 2, 2, 60, 345, 3, 2, 2, 2, 62, 361, 3, 2, 2, 2, 64, 363, 3, 2, 2, 2, 66, 375, 3, 2, 2, 2, 68, 379, 3, 2, 2, 2, 70, 381, 3, 2, 2, 2, 72, 383, 3, 2, 2, 2, 74, 387, 3, 2, 2, 2, 76, 389, 3, 2, 2, 2, 78, 407, 3, 2, 2, 2, 80, 415, 3, 2, 2, 2, 82, 423, 3, 2, 2, 2, 84, 425, 3, 2, 2, 2, 86, 427, 3, 2, 2, 2, 88, 443, 3, 2, 2, 2, 90, 459, 3, 2, 2, 2, 92, 463, 3, 2, 2, 2, 94, 476, 3, 2, 2, 2, 96, 502, 3, 2, 2, 2, 98, 510, 3, 2, 2, 2, 100, 513, 3, 2, 2, 2, 102, 517, 3, 2, 2, 2, 104, 533, 3, 2, 2, 2, 106, 535, 3, 2, 2, 2, 108, 541, 3, 2, 2, 2, 110, 543, 3, 2, 2, 2, 112, 546, 3, 2, 2, 2, 114, 549, 3, 2, 2, 2, 116, 551, 3, 2, 2, 2, 118, 558, 3, 2, 2, 2, 120, 560, 3, 2, 2, 2, 122, 571, 3, 2, 2, 2, 124, 582, 3, 2, 2, 2, 126, 594, 3, 2, 2, 2, 128, 596, 3, 2, 2, 2, 130, 607, 3, 2, 2, 2, 132, 618, 3, 2, 2, 2, 134, 629, 3, 2, 2, 2, 136, 640, 3, 2, 2, 2, 138, 651, 3, 2, 2, 2, 140, 662, 3, 2, 2, 2, 142, 680, 3, 2, 2, 2, 144, 687, 3, 2, 2, 2, 146, 689, 3, 2, 2, 2, 148, 691, 3, 2, 2, 2, 150, 702, 3, 2, 2, 2, 152, 704, 3, 2, 2, 2, 154, 706, 3, 2, 2, 2, 156, 711, 3, 2, 2, 2, 158, 716, 3, 2, 2, 2, 160, 162, 5, 4, 3, 2, 161, 160, 3, 2, 2, 2, 161, 162, 3, 2, 2, 2, 162, 163, 3, 2, 2, 2, 163, 164, 7, 2, 2, 3, 164, 3, 3, 2, 2, 2, 165, 167, 5, 6, 4, 2, 166, 165, 3, 2, 2, 2, 167, 168, 3, 2, 2, 2, 168, 166, 3, 2, 2, 2, 168, 169, 3, 2, 2, 2, 169, 5, 3, 2, 2, 2, 170, 171, 5, 8, 5, 2, 171, 7, 3, 2, 2, 2, 172, 174, 5, 10, 6, 2, 173, 172, 3, 2, 2, 2, 174, 175, 3, 2, 2, 2, 175, 173, 3, 2, 2, 2, 175, 176, 3, 2, 2, 2, 176, 9, 3, 2, 2, 2, 177, 181, 5, 36, 19, 2, 178, 181, 5, 12, 7, 2, 179, 181, 7, 35, 2, 2, 180, 177, 3, 2, 2, 2, 180, 178, 3, 2, 2, 2, 180, 179, 3, 2, 2, 2, 181, 11, 3, 2, 2, 2, 182, 183, 5, 14, 8, 2, 183, 184, 7, 35, 2, 2, 184, 189, 3, 2, 2, 2, 185, 189, 5, 26, 14, 2, 186, 189, 5, 32, 17, 2, 187, 189, 5, 34, 18, 2, 188, 182, 3, 2, 2, 2, 188, 185, 3, 2, 2, 2, 188, 186, 3, 2, 2, 2, 188, 187, 3, 2, 2, 2, 189, 13, 3, 2, 2, 2, 190, 191, 5, 16, 9, 2, 191, 192, 5, 18, 10, 2, 192, 15, 3, 2, 2, 2, 193, 194, 9, 2, 2, 2, 194, 17, 3, 2, 2, 2, 195, 196, 5, 22, 12, 2, 196, 197, 7, 37, 2, 2, 197, 200, 5, 150, 76, 2, 198, 199, 7, 56, 2, 2, 199, 201, 5, 20, 11, 2, 200, 198, 3, 2, 2, 2, 200, 201, 3, 2, 2, 2, 201, 19, 3, 2, 2, 2, 202, 203, 5, 144, 73, 2, 203, 21, 3, 2, 2, 2, 204, 205, 5, 24, 13, 2, 205, 23, 3, 2, 2, 2, 206, 207, 7, 76, 2, 2, 207, 25, 3, 2, 2, 2, 208, 209, 7, 22, 2, 2, 209, 210, 5, 22, 12, 2, 210, 212, 7, 38, 2, 2, 211, 213, 5, 28, 15, 2, 212, 211, 3, 2, 2, 2, 212, 213, 3, 2, 2, 2, 213, 214, 3, 2, 2, 2, 214, 215, 7, 39, 2, 2, 215, 216, 7, 25, 2, 2, 216, 218, 5, 150, 76, 2, 217, 219, 5, 38, 20, 2, 218, 217, 3, 2, 2, 2, 218, 219, 3, 2, 2, 2, 219, 27, 3, 2, 2, 2, 220, 225, 5, 30, 16, 2, 221, 222, 7, 34, 2, 2, 222, 224, 5, 30, 16, 2, 223, 221, 3, 2, 2, 2, 224, 227, 3, 2, 2, 2, 225, 223, 3, 2, 2, 2, 225, 226, 3, 2, 2, 2, 226, 29, 3, 2, 2, 2, 227, 225, 3, 2, 2, 2, 228, 229, 5, 22, 12, 2, 229, 230, 7, 37, 2, 2, 230, 231, 5, 150, 76, 2, 231, 31, 3, 2, 2, 2, 232, 233, 7, 27, 2, 2, 233, 234, 7, 76, 2, 2, 234, 235, 7, 43, 2, 2, 235, 236, 7, 44, 2, 2, 236, 33, 3, 2, 2, 2, 237, 238, 7, 26, 2, 2, 238, 239, 7, 76, 2, 2, 239, 240, 7, 43, 2, 2, 240, 241, 7, 44, 2, 2, 241, 35, 3, 2, 2, 2, 242, 249, 5, 40, 21, 2, 243, 249, 5, 42, 22, 2, 244, 249, 5, 50, 26, 2, 245, 249, 5, 58, 30, 2, 246, 249, 5, 60, 31, 2, 247, 249, 5, 38, 20, 2, 248, 242, 3, 2, 2, 2, 248, 243, 3, 2, 2, 2, 248, 244, 3, 2, 2, 2, 248, 245, 3, 2, 2, 2, 248, 246, 3, 2, 2, 2, 248, 247, 3, 2, 2, 2, 249, 37, 3, 2, 2, 2, 250, 251, 6, 20, 2, 2, 251, 253, 7, 43, 2, 2, 252, 254, 5, 8, 5, 2, 253, 252, 3, 2, 2, 2, 253, 254, 3, 2, 2, 2, 254, 255, 3, 2, 2, 2, 255, 256, 7, 44, 2, 2, 256, 39, 3, 2, 2, 2, 257, 258, 8, 21, 1, 2, 258, 259, 5, 148, 75, 2, 259, 260, 7, 35, 2, 2, 260, 261, 8, 21, 1, 2, 261, 41, 3, 2, 2, 2, 262, 265, 5, 44, 23, 2, 263, 265, 5, 46, 24, 2, 264, 262, 3, 2, 2, 2, 264, 263, 3, 2, 2, 2, 265, 43, 3, 2, 2, 2, 266, 267, 7, 18, 2, 2, 267, 268, 7, 38, 2, 2, 268, 269, 5, 148, 75, 2, 269, 270, 7, 39, 2, 2, 270, 273, 5, 36, 19, 2, 271, 272, 7, 19, 2, 2, 272, 274, 5, 36, 19, 2, 273, 271, 3, 2, 2, 2, 273, 274, 3, 2, 2, 2, 274, 45, 3, 2, 2, 2, 275, 276, 7, 11, 2, 2, 276, 277, 7, 38, 2, 2, 277, 278, 5, 148, 75, 2, 278, 279, 7, 39, 2, 2, 279, 283, 7, 43, 2, 2, 280, 282, 5, 48, 25, 2, 281, 280, 3, 2, 2, 2, 282, 285, 3, 2, 2, 2, 283, 281, 3, 2, 2, 2, 283, 284, 3, 2, 2, 2, 284, 286, 3, 2, 2, 2, 285, 283, 3, 2, 2, 2, 286, 287, 7, 44, 2, 2, 287, 47, 3, 2, 2, 2, 288, 289, 7, 12, 2, 2, 289, 290, 5, 148, 75, 2, 290, 291, 7, 37, 2, 2, 291, 292, 5, 36, 19, 2, 292, 297, 3, 2, 2, 2, 293, 294, 7, 13, 2, 2, 294, 295, 7, 37, 2, 2, 295, 297, 5, 36, 19, 2, 296, 288, 3, 2, 2, 2, 296, 293, 3, 2, 2, 2, 297, 49, 3, 2, 2, 2, 298, 302, 5, 52, 27, 2, 299, 302, 5, 54, 28, 2, 300, 302, 5, 56, 29, 2, 301, 298, 3, 2, 2, 2, 301, 299, 3, 2, 2, 2, 301, 300, 3, 2, 2, 2, 302, 51, 3, 2, 2, 2, 303, 304, 7, 20, 2, 2, 304, 311, 7, 38, 2, 2, 305, 308, 5, 14, 8, 2, 306, 308, 5, 148, 75, 2, 307, 305, 3, 2, 2, 2, 307, 306, 3, 2, 2, 2, 308, 309, 3, 2, 2, 2, 309, 310, 8, 27, 1, 2, 310, 312, 3, 2, 2, 2, 311, 307, 3, 2, 2, 2, 311, 312, 3, 2, 2, 2, 312, 313, 3, 2, 2, 2, 313, 317, 7, 35, 2, 2, 314, 315, 5, 148, 75, 2, 315, 316, 8, 27, 1, 2, 316, 318, 3, 2, 2, 2, 317, 314, 3, 2, 2, 2, 317, 318, 3, 2, 2, 2, 318, 319, 3, 2, 2, 2, 319, 323, 7, 35, 2, 2, 320, 321, 5, 148, 75, 2, 321, 322, 8, 27, 1, 2, 322, 324, 3, 2, 2, 2, 323, 320, 3, 2, 2, 2, 323, 324, 3, 2, 2, 2, 324, 325, 3, 2, 2, 2, 325, 326, 7, 39, 2, 2, 326, 327, 5, 36, 19, 2, 327, 53, 3, 2, 2, 2, 328, 329, 7, 17, 2, 2, 329, 330, 7, 38, 2, 2, 330, 331, 5, 148, 75, 2, 331, 332, 7, 39, 2, 2, 332, 333, 5, 36, 19, 2, 333, 55, 3, 2, 2, 2, 334, 335, 7, 16, 2, 2, 335, 336, 5, 36, 19, 2, 336, 337, 7, 17, 2, 2, 337, 338, 7, 38, 2, 2, 338, 339, 5, 148, 75, 2, 339, 340, 7, 39, 2, 2, 340, 341, 7, 35, 2, 2, 341, 57, 3, 2, 2, 2, 342, 343, 9, 3, 2, 2, 343, 344, 7, 35, 2, 2, 344, 59, 3, 2, 2, 2, 345, 347, 7, 23, 2, 2, 346, 348, 5, 148, 75, 2, 347, 346, 3, 2, 2, 2, 347, 348, 3, 2, 2, 2, 348, 349, 3, 2, 2, 2, 349, 350, 7, 35, 2, 2, 350, 61, 3, 2, 2, 2, 351, 362, 5, 66, 34, 2, 352, 362, 5, 86, 44, 2, 353, 362, 5, 88, 45, 2, 354, 362, 5, 68, 35, 2, 355, 362, 5, 70, 36, 2, 356, 362, 5, 76, 39, 2, 357, 362, 5, 78, 40, 2, 358, 362, 5, 84, 43, 2, 359, 362, 5, 92, 47, 2, 360, 362, 5, 64, 33, 2, 361, 351, 3, 2, 2, 2, 361, 352, 3, 2, 2, 2, 361, 353, 3, 2, 2, 2, 361, 354, 3, 2, 2, 2, 361, 355, 3, 2, 2, 2, 361, 356, 3, 2, 2, 2, 361, 357, 3, 2, 2, 2, 361, 358, 3, 2, 2, 2, 361, 359, 3, 2, 2, 2, 361, 360, 3, 2, 2, 2, 362, 63, 3, 2, 2, 2, 363, 365, 7, 38, 2, 2, 364, 366, 5, 28, 15, 2, 365, 364, 3, 2, 2, 2, 365, 366, 3, 2, 2, 2, 366, 367, 3, 2, 2, 2, 367, 368, 7, 39, 2, 2, 368, 369, 7, 37, 2, 2, 369, 370, 5, 150, 76, 2, 370, 373, 7, 25, 2, 2, 371, 374, 5, 148, 75, 2, 372, 374, 5, 38, 20, 2, 373, 371, 3, 2, 2, 2, 373, 372, 3, 2, 2, 2, 374, 65, 3, 2, 2, 2, 375, 376, 7, 38, 2, 2, 376, 377, 5, 148, 75, 2, 377, 378, 7, 39, 2, 2, 378, 67, 3, 2, 2, 2, 379, 380, 9, 4, 2, 2, 380, 69, 3, 2, 2, 2, 381, 382, 5, 72, 37, 2, 382, 71, 3, 2, 2, 2, 383, 384, 7, 76, 2, 2, 384, 73, 3, 2, 2, 2, 385, 388, 5, 72, 37, 2, 386, 388, 5, 76, 39, 2, 387, 385, 3, 2, 2, 2, 387, 386, 3, 2, 2, 2, 388, 75, 3, 2, 2, 2, 389, 390, 9, 5, 2, 2, 390, 77, 3, 2, 2, 2, 391, 395, 7, 83, 2, 2, 392, 394, 5, 80, 41, 2, 393, 392, 3, 2, 2, 2, 394, 397, 3, 2, 2, 2, 395, 393, 3, 2, 2, 2, 395, 396, 3, 2, 2, 2, 396, 398, 3, 2, 2, 2, 397, 395, 3, 2, 2, 2, 398, 408, 7, 85, 2, 2, 399, 403, 7, 84, 2, 2, 400, 402, 5, 82, 42, 2, 401, 400, 3, 2, 2, 2, 402, 405, 3, 2, 2, 2, 403, 401, 3, 2, 2, 2, 403, 404, 3, 2, 2, 2, 404, 406, 3, 2, 2, 2, 405, 403, 3, 2, 2, 2, 406, 408, 7, 87, 2, 2, 407, 391, 3, 2, 2, 2, 407, 399, 3, 2, 2, 2, 408, 79, 3, 2, 2, 2, 409, 416, 7, 86, 2, 2, 410, 412, 7, 3, 2, 2, 411, 413, 5, 148, 75, 2, 412, 411, 3, 2, 2, 2, 412, 413, 3, 2, 2, 2, 413, 414, 3, 2, 2, 2, 414, 416, 7, 42, 2, 2, 415, 409, 3, 2, 2, 2, 415, 410, 3, 2, 2, 2, 416, 81, 3, 2, 2, 2, 417, 424, 7, 88, 2, 2, 418, 420, 7, 3, 2, 2, 419, 421, 5, 148, 75, 2, 420, 419, 3, 2, 2, 2, 420, 421, 3, 2, 2, 2, 421, 422, 3, 2, 2, 2, 422, 424, 7, 42, 2, 2, 423, 417, 3, 2, 2, 2, 423, 418, 3, 2, 2, 2, 424, 83, 3, 2, 2, 2, 425, 426, 9, 6, 2, 2, 426, 85, 3, 2, 2, 2, 427, 436, 7, 40, 2, 2, 428, 433, 5, 148, 75, 2, 429, 430, 7, 34, 2, 2, 430, 432, 5, 148, 75, 2, 431, 429, 3, 2, 2, 2, 432, 435, 3, 2, 2, 2, 433, 431, 3, 2, 2, 2, 433, 434, 3, 2, 2, 2, 434, 437, 3, 2, 2, 2, 435, 433, 3, 2, 2, 2, 436, 428, 3, 2, 2, 2, 436, 437, 3, 2, 2, 2, 437, 439, 3, 2, 2, 2, 438, 440, 7, 34, 2, 2, 439, 438, 3, 2, 2, 2, 439, 440, 3, 2, 2, 2, 440, 441, 3, 2, 2, 2, 441, 442, 7, 41, 2, 2, 442, 87, 3, 2, 2, 2, 443, 452, 7, 43, 2, 2, 444, 449, 5, 90, 46, 2, 445, 446, 7, 34, 2, 2, 446, 448, 5, 90, 46, 2, 447, 445, 3, 2, 2, 2, 448, 451, 3, 2, 2, 2, 449, 447, 3, 2, 2, 2, 449, 450, 3, 2, 2, 2, 450, 453, 3, 2, 2, 2, 451, 449, 3, 2, 2, 2, 452, 444, 3, 2, 2, 2, 452, 453, 3, 2, 2, 2, 453, 455, 3, 2, 2, 2, 454, 456, 7, 34, 2, 2, 455, 454, 3, 2, 2, 2, 455, 456, 3, 2, 2, 2, 456, 457, 3, 2, 2, 2, 457, 458, 7, 44, 2, 2, 458, 89, 3, 2, 2, 2, 459, 460, 5, 74, 38, 2, 460, 461, 7, 37, 2, 2, 461, 462, 5, 148, 75, 2, 462, 91, 3, 2, 2, 2, 463, 464, 9, 7, 2, 2, 464, 93, 3, 2, 2, 2, 465, 466, 8, 48, 1, 2, 466, 477, 5, 62, 32, 2, 467, 468, 7, 24, 2, 2, 468, 469, 5, 94, 48, 2, 469, 471, 7, 38, 2, 2, 470, 472, 5, 96, 49, 2, 471, 470, 3, 2, 2, 2, 471, 472, 3, 2, 2, 2, 472, 473, 3, 2, 2, 2, 473, 474, 7, 39, 2, 2, 474, 475, 8, 48, 1, 2, 475, 477, 3, 2, 2, 2, 476, 465, 3, 2, 2, 2, 476, 467, 3, 2, 2, 2, 477, 499, 3, 2, 2, 2, 478, 479, 12, 7, 2, 2, 479, 481, 7, 38, 2, 2, 480, 482, 5, 96, 49, 2, 481, 480, 3, 2, 2, 2, 481, 482, 3, 2, 2, 2, 482, 483, 3, 2, 2, 2, 483, 484, 7, 39, 2, 2, 484, 498, 8, 48, 1, 2, 485, 486, 12, 5, 2, 2, 486, 487, 5, 98, 50, 2, 487, 488, 8, 48, 1, 2, 488, 498, 3, 2, 2, 2, 489, 490, 12, 4, 2, 2, 490, 491, 5, 100, 51, 2, 491, 492, 8, 48, 1, 2, 492, 498, 3, 2, 2, 2, 493, 494, 12, 3, 2, 2, 494, 495, 5, 102, 52, 2, 495, 496, 8, 48, 1, 2, 496, 498, 3, 2, 2, 2, 497, 478, 3, 2, 2, 2, 497, 485, 3, 2, 2, 2, 497, 489, 3, 2, 2, 2, 497, 493, 3, 2, 2, 2, 498, 501, 3, 2, 2, 2, 499, 497, 3, 2, 2, 2, 499, 500, 3, 2, 2, 2, 500, 95, 3, 2, 2, 2, 501, 499, 3, 2, 2, 2, 502, 507, 5, 144, 73, 2, 503, 504, 7, 34, 2, 2, 504, 506, 5, 144, 73, 2, 505, 503, 3, 2, 2, 2, 506, 509, 3, 2, 2, 2, 507, 505, 3, 2, 2, 2, 507, 508, 3, 2, 2, 2, 508, 97, 3, 2, 2, 2, 509, 507, 3, 2, 2, 2, 510, 511, 7, 75, 2, 2, 511, 512, 5, 72, 37, 2, 512, 99, 3, 2, 2, 2, 513, 514, 7, 40, 2, 2, 514, 515, 5, 148, 75, 2, 515, 516, 7, 41, 2, 2, 516, 101, 3, 2, 2, 2, 517, 521, 7, 40, 2, 2, 518, 519, 5, 148, 75, 2, 519, 520, 8, 52, 1, 2, 520, 522, 3, 2, 2, 2, 521, 518, 3, 2, 2, 2, 521, 522, 3, 2, 2, 2, 522, 523, 3, 2, 2, 2, 523, 527, 7, 37, 2, 2, 524, 525, 5, 148, 75, 2, 525, 526, 8, 52, 1, 2, 526, 528, 3, 2, 2, 2, 527, 524, 3, 2, 2, 2, 527, 528, 3, 2, 2, 2, 528, 529, 3, 2, 2, 2, 529, 530, 7, 41, 2, 2, 530, 103, 3, 2, 2, 2, 531, 534, 5, 94, 48, 2, 532, 534, 5, 106, 54, 2, 533, 531, 3, 2, 2, 2, 533, 532, 3, 2, 2, 2, 534, 105, 3, 2, 2, 2, 535, 536, 5, 94, 48, 2, 536, 537, 5, 114, 58, 2, 537, 107, 3, 2, 2, 2, 538, 542, 5, 104, 53, 2, 539, 542, 5, 110, 56, 2, 540, 542, 5, 112, 57, 2, 541, 538, 3, 2, 2, 2, 541, 539, 3, 2, 2, 2, 541, 540, 3, 2, 2, 2, 542, 109, 3, 2, 2, 2, 543, 544, 5, 114, 58, 2, 544, 545, 5, 104, 53, 2, 545, 111, 3, 2, 2, 2, 546, 547, 5, 116, 59, 2, 547, 548, 5, 104, 53, 2, 548, 113, 3, 2, 2, 2, 549, 550, 9, 8, 2, 2, 550, 115, 3, 2, 2, 2, 551, 552, 9, 9, 2, 2, 552, 117, 3, 2, 2, 2, 553, 559, 5, 108, 55, 2, 554, 555, 5, 108, 55, 2, 555, 556, 7, 9, 2, 2, 556, 557, 5, 150, 76, 2, 557, 559, 3, 2, 2, 2, 558, 553, 3, 2, 2, 2, 558, 554, 3, 2, 2, 2, 559, 119, 3, 2, 2, 2, 560, 561, 8, 61, 1, 2, 561, 562, 5, 118, 60, 2, 562, 568, 3, 2, 2, 2, 563, 564, 12, 3, 2, 2, 564, 565, 9, 10, 2, 2, 565, 567, 5, 118, 60, 2, 566, 563, 3, 2, 2, 2, 567, 570, 3, 2, 2, 2, 568, 566, 3, 2, 2, 2, 568, 569, 3, 2, 2, 2, 569, 121, 3, 2, 2, 2, 570, 568, 3, 2, 2, 2, 571, 572, 8, 62, 1, 2, 572, 573, 5, 120, 61, 2, 573, 579, 3, 2, 2, 2, 574, 575, 12, 3, 2, 2, 575, 576, 9, 11, 2, 2, 576, 578, 5, 120, 61, 2, 577, 574, 3, 2, 2, 2, 578, 581, 3, 2, 2, 2, 579, 577, 3, 2, 2, 2, 579, 580, 3, 2, 2, 2, 580, 123, 3, 2, 2, 2, 581, 579, 3, 2, 2, 2, 582, 583, 8, 63, 1, 2, 583, 584, 5, 122, 62, 2, 584, 591, 3, 2, 2, 2, 585, 586, 12, 3, 2, 2, 586, 587, 5, 126, 64, 2, 587, 588, 5, 132, 67, 2, 588, 590, 3, 2, 2, 2, 589, 585, 3, 2, 2, 2, 590, 593, 3, 2, 2, 2, 591, 589, 3, 2, 2, 2, 591, 592, 3, 2, 2, 2, 592, 125, 3, 2, 2, 2, 593, 591, 3, 2, 2, 2, 594, 595, 9, 12, 2, 2, 595, 127, 3, 2, 2, 2, 596, 597, 8, 65, 1, 2, 597, 598, 5, 124, 63, 2, 598, 604, 3, 2, 2, 2, 599, 600, 12, 3, 2, 2, 600, 601, 9, 13, 2, 2, 601, 603, 5, 124, 63, 2, 602, 599, 3, 2, 2, 2, 603, 606, 3, 2, 2, 2, 604, 602, 3, 2, 2, 2, 604, 605, 3, 2, 2, 2, 605, 129, 3, 2, 2, 2, 606, 604, 3, 2, 2, 2, 607, 608, 8, 66, 1, 2, 608, 609, 5, 128, 65, 2, 609, 615, 3, 2, 2, 2, 610, 611, 12, 3, 2, 2, 611, 612, 9, 14, 2, 2, 612, 614, 5, 128, 65, 2, 613, 610, 3, 2, 2, 2, 614, 617, 3, 2, 2, 2, 615, 613, 3, 2, 2, 2, 615, 616, 3, 2, 2, 2, 616, 131, 3, 2, 2, 2, 617, 615, 3, 2, 2, 2, 618, 619, 8, 67, 1, 2, 619, 620, 5, 130, 66, 2, 620, 626, 3, 2, 2, 2, 621, 622, 12, 3, 2, 2, 622, 623, 7, 68, 2, 2, 623, 625, 5, 130, 66, 2, 624, 621, 3, 2, 2, 2, 625, 628, 3, 2, 2, 2, 626, 624, 3, 2, 2, 2, 626, 627, 3, 2, 2, 2, 627, 133, 3, 2, 2, 2, 628, 626, 3, 2, 2, 2, 629, 630, 8, 68, 1, 2, 630, 631, 5, 132, 67, 2, 631, 637, 3, 2, 2, 2, 632, 633, 12, 3, 2, 2, 633, 634, 7, 70, 2, 2, 634, 636, 5, 132, 67, 2, 635, 632, 3, 2, 2, 2, 636, 639, 3, 2, 2, 2, 637, 635, 3, 2, 2, 2, 637, 638, 3, 2, 2, 2, 638, 135, 3, 2, 2, 2, 639, 637, 3, 2, 2, 2, 640, 641, 8, 69, 1, 2, 641, 642, 5, 134, 68, 2, 642, 648, 3, 2, 2, 2, 643, 644, 12, 3, 2, 2, 644, 645, 7, 69, 2, 2, 645, 647, 5, 134, 68, 2, 646, 643, 3, 2, 2, 2, 647, 650, 3, 2, 2, 2, 648, 646, 3, 2, 2, 2, 648, 649, 3, 2, 2, 2, 649, 137, 3, 2, 2, 2, 650, 648, 3, 2, 2, 2, 651, 652, 8, 70, 1, 2, 652, 653, 5, 136, 69, 2, 653, 659, 3, 2, 2, 2, 654, 655, 12, 3, 2, 2, 655, 656, 7, 53, 2, 2, 656, 658, 5, 136, 69, 2, 657, 654, 3, 2, 2, 2, 658, 661, 3, 2, 2, 2, 659, 657, 3, 2, 2, 2, 659, 660, 3, 2, 2, 2, 660, 139, 3, 2, 2, 2, 661, 659, 3, 2, 2, 2, 662, 663, 8, 71, 1, 2, 663, 664, 5, 138, 70, 2, 664, 670, 3, 2, 2, 2, 665, 666, 12, 3, 2, 2, 666, 667, 7, 54, 2, 2, 667, 669, 5, 138, 70, 2, 668, 665, 3, 2, 2, 2, 669, 672, 3, 2, 2, 2, 670, 668, 3, 2, 2, 2, 670, 671, 3, 2, 2, 2, 671, 141, 3, 2, 2, 2, 672, 670, 3, 2, 2, 2, 673, 681, 5, 140, 71, 2, 674, 675, 5, 140, 71, 2, 675, 676, 7, 36, 2, 2, 676, 677, 5, 142, 72, 2, 677, 678, 7, 37, 2, 2, 678, 679, 5, 142, 72, 2, 679, 681, 3, 2, 2, 2, 680, 673, 3, 2, 2, 2, 680, 674, 3, 2, 2, 2, 681, 143, 3, 2, 2, 2, 682, 688, 5, 142, 72, 2, 683, 684, 5, 94, 48, 2, 684, 685, 5, 146, 74, 2, 685, 686, 5, 144, 73, 2, 686, 688, 3, 2, 2, 2, 687, 682, 3, 2, 2, 2, 687, 683, 3, 2, 2, 2, 688, 145, 3, 2, 2, 2, 689, 690, 9, 15, 2, 2, 690, 147, 3, 2, 2, 2, 691, 696, 5, 144, 73, 2, 692, 693, 7, 34, 2, 2, 693, 695, 5, 144, 73, 2, 694, 692, 3, 2, 2, 2, 695, 698, 3, 2, 2, 2, 696, 694, 3, 2, 2, 2, 696, 697, 3, 2, 2, 2, 697, 149, 3, 2, 2, 2, 698, 696, 3, 2, 2, 2, 699, 703, 5, 152, 77, 2, 700, 703, 5, 154, 78, 2, 701, 703, 5, 156, 79, 2, 702, 699, 3, 2, 2, 2, 702, 700, 3, 2, 2, 2, 702, 701, 3, 2, 2, 2, 703, 151, 3, 2, 2, 2, 704, 705, 5, 158, 80, 2, 705, 153, 3, 2, 2, 2, 706, 707, 5, 158, 80, 2, 707, 708, 7, 64, 2, 2, 708, 709, 5, 158, 80, 2, 709, 710, 7, 66, 2, 2, 710, 155, 3, 2, 2, 2, 711, 712, 7, 30, 2, 2, 712, 713, 7, 38, 2, 2, 713, 714, 5, 158, 80, 2, 714, 715, 7, 39, 2, 2, 715, 157, 3, 2, 2, 2, 716, 717, 9, 16, 2, 2, 717, 159, 3, 2, 2, 2, 65, 161, 168, 175, 180, 188, 200, 212, 218, 225, 248, 253, 264, 273, 283, 296, 301, 307, 311, 317, 323, 347, 361, 365, 373, 387, 395, 403, 407, 412, 415, 420, 423, 433, 436, 439, 449, 452, 455, 471, 476, 481, 497, 499, 507, 521, 527, 533, 541, 558, 568, 579, 591, 604, 615, 626, 637, 648, 659, 670, 680, 687, 696, 702] \ No newline at end of file diff --git a/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.tokens b/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.tokens index 7c4c655e8..a380f4448 100644 --- a/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.tokens +++ b/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.tokens @@ -21,67 +21,69 @@ DefFunc=20 Return=21 CallFunc=22 RetIndicator=23 -True=24 -False=25 -Typeof=26 -Void=27 -Null=28 -Undefined=29 -Comma=30 -SemiColon=31 -QuestionMark=32 -Colon=33 -LeftParen=34 -RightParen=35 -LeftBracket=36 -RightBracket=37 -FStringExpEnd=38 -LeftBrace=39 -RightBrace=40 -Plus=41 -PlusPlus=42 -Minus=43 -MinusMinus=44 -Star=45 -Div=46 -Mod=47 -PowerTo=48 -AndAnd=49 -OrOr=50 -Not=51 -Assign=52 -PlusAssign=53 -MinusAssign=54 -StarAssign=55 -DivAssign=56 -ModAssign=57 -Equal=58 -NotEqual=59 -Less=60 -LessEqual=61 -Greater=62 -GreaterEqual=63 -BitwiseAnd=64 -BitwiseOr=65 -BitwiseXor=66 -BitwiseNot=67 -BitwiseZeroFillLeftShift=68 -BitwiseSignedRightShift=69 -BitwiseZeroFillRightShift=70 -Dot=71 -Identifier=72 -IntegerConstant=73 -SingleQuoteStringLiteral=74 -DoubleQuoteStringLiteral=75 -FloatingConstant=76 -Whitespace=77 -Newline=78 -FStringSingleQuoteStart=79 -FStringDoubleQuoteStart=80 -FStringSingleQuoteEnd=81 -FStringSingleQuoteAtom=82 -FStringDoubleQuoteEnd=83 -FStringDoubleQuoteAtom=84 +Class=24 +Interface=25 +True=26 +False=27 +Typeof=28 +Void=29 +Null=30 +Undefined=31 +Comma=32 +SemiColon=33 +QuestionMark=34 +Colon=35 +LeftParen=36 +RightParen=37 +LeftBracket=38 +RightBracket=39 +FStringExpEnd=40 +LeftBrace=41 +RightBrace=42 +Plus=43 +PlusPlus=44 +Minus=45 +MinusMinus=46 +Star=47 +Div=48 +Mod=49 +PowerTo=50 +AndAnd=51 +OrOr=52 +Not=53 +Assign=54 +PlusAssign=55 +MinusAssign=56 +StarAssign=57 +DivAssign=58 +ModAssign=59 +Equal=60 +NotEqual=61 +Less=62 +LessEqual=63 +Greater=64 +GreaterEqual=65 +BitwiseAnd=66 +BitwiseOr=67 +BitwiseXor=68 +BitwiseNot=69 +BitwiseZeroFillLeftShift=70 +BitwiseSignedRightShift=71 +BitwiseZeroFillRightShift=72 +Dot=73 +Identifier=74 +IntegerConstant=75 +SingleQuoteStringLiteral=76 +DoubleQuoteStringLiteral=77 +FloatingConstant=78 +Whitespace=79 +Newline=80 +FStringSingleQuoteStart=81 +FStringDoubleQuoteStart=82 +FStringSingleQuoteEnd=83 +FStringSingleQuoteAtom=84 +FStringDoubleQuoteEnd=85 +FStringDoubleQuoteAtom=86 'const'=5 'var'=6 'as'=7 @@ -101,50 +103,52 @@ FStringDoubleQuoteAtom=84 'return'=21 'call'=22 '->'=23 -'true'=24 -'false'=25 -'typeof'=26 -'void'=27 -'null'=28 -'undefined'=29 -','=30 -';'=31 -'?'=32 -':'=33 -'('=34 -')'=35 -'['=36 -']'=37 -'{'=39 -'}'=40 -'+'=41 -'++'=42 -'-'=43 -'--'=44 -'*'=45 -'/'=46 -'%'=47 -'**'=48 -'&&'=49 -'||'=50 -'!'=51 -'='=52 -'+='=53 -'-='=54 -'*='=55 -'/='=56 -'%='=57 -'=='=58 -'!='=59 -'<'=60 -'<='=61 -'>'=62 -'>='=63 -'&'=64 -'|'=65 -'^'=66 -'~'=67 -'<<'=68 -'>>'=69 -'>>>'=70 -'.'=71 +'class'=24 +'interface'=25 +'true'=26 +'false'=27 +'typeof'=28 +'void'=29 +'null'=30 +'undefined'=31 +','=32 +';'=33 +'?'=34 +':'=35 +'('=36 +')'=37 +'['=38 +']'=39 +'{'=41 +'}'=42 +'+'=43 +'++'=44 +'-'=45 +'--'=46 +'*'=47 +'/'=48 +'%'=49 +'**'=50 +'&&'=51 +'||'=52 +'!'=53 +'='=54 +'+='=55 +'-='=56 +'*='=57 +'/='=58 +'%='=59 +'=='=60 +'!='=61 +'<'=62 +'<='=63 +'>'=64 +'>='=65 +'&'=66 +'|'=67 +'^'=68 +'~'=69 +'<<'=70 +'>>'=71 +'>>>'=72 +'.'=73 diff --git a/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.ts b/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.ts index 2b3d3301c..497e4c2d7 100644 --- a/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.ts +++ b/kipper/core/src/compiler/lexer-parser/antlr/KipperParser.ts @@ -2,15 +2,20 @@ // Import the required class for the ctx super class, as well as the 'ASTKind' type defining all possible syntax // kind values. -import { ASTKind, KipperParserRuleContext, ParseRuleKindMapping } from ".."; +import { KipperParserRuleContext, ParseRuleKindMapping, ASTKind } from ".."; import KipperParserBase from "./base/KipperParserBase"; import { ATN } from "antlr4ts/atn/ATN"; import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer"; import { FailedPredicateException } from "antlr4ts/FailedPredicateException"; +import { NotNull } from "antlr4ts/Decorators"; import { NoViableAltException } from "antlr4ts/NoViableAltException"; +import { Override } from "antlr4ts/Decorators"; +import { Parser } from "antlr4ts/Parser"; import { ParserRuleContext } from "antlr4ts/ParserRuleContext"; import { ParserATNSimulator } from "antlr4ts/atn/ParserATNSimulator"; +import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener"; +import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor"; import { RecognitionException } from "antlr4ts/RecognitionException"; import { RuleContext } from "antlr4ts/RuleContext"; //import { RuleVersion } from "antlr4ts/RuleVersion"; @@ -49,144 +54,148 @@ export class KipperParser extends KipperParserBase { public static readonly Return = 21; public static readonly CallFunc = 22; public static readonly RetIndicator = 23; - public static readonly True = 24; - public static readonly False = 25; - public static readonly Typeof = 26; - public static readonly Void = 27; - public static readonly Null = 28; - public static readonly Undefined = 29; - public static readonly Comma = 30; - public static readonly SemiColon = 31; - public static readonly QuestionMark = 32; - public static readonly Colon = 33; - public static readonly LeftParen = 34; - public static readonly RightParen = 35; - public static readonly LeftBracket = 36; - public static readonly RightBracket = 37; - public static readonly FStringExpEnd = 38; - public static readonly LeftBrace = 39; - public static readonly RightBrace = 40; - public static readonly Plus = 41; - public static readonly PlusPlus = 42; - public static readonly Minus = 43; - public static readonly MinusMinus = 44; - public static readonly Star = 45; - public static readonly Div = 46; - public static readonly Mod = 47; - public static readonly PowerTo = 48; - public static readonly AndAnd = 49; - public static readonly OrOr = 50; - public static readonly Not = 51; - public static readonly Assign = 52; - public static readonly PlusAssign = 53; - public static readonly MinusAssign = 54; - public static readonly StarAssign = 55; - public static readonly DivAssign = 56; - public static readonly ModAssign = 57; - public static readonly Equal = 58; - public static readonly NotEqual = 59; - public static readonly Less = 60; - public static readonly LessEqual = 61; - public static readonly Greater = 62; - public static readonly GreaterEqual = 63; - public static readonly BitwiseAnd = 64; - public static readonly BitwiseOr = 65; - public static readonly BitwiseXor = 66; - public static readonly BitwiseNot = 67; - public static readonly BitwiseZeroFillLeftShift = 68; - public static readonly BitwiseSignedRightShift = 69; - public static readonly BitwiseZeroFillRightShift = 70; - public static readonly Dot = 71; - public static readonly Identifier = 72; - public static readonly IntegerConstant = 73; - public static readonly SingleQuoteStringLiteral = 74; - public static readonly DoubleQuoteStringLiteral = 75; - public static readonly FloatingConstant = 76; - public static readonly Whitespace = 77; - public static readonly Newline = 78; - public static readonly FStringSingleQuoteStart = 79; - public static readonly FStringDoubleQuoteStart = 80; - public static readonly FStringSingleQuoteEnd = 81; - public static readonly FStringSingleQuoteAtom = 82; - public static readonly FStringDoubleQuoteEnd = 83; - public static readonly FStringDoubleQuoteAtom = 84; + public static readonly Class = 24; + public static readonly Interface = 25; + public static readonly True = 26; + public static readonly False = 27; + public static readonly Typeof = 28; + public static readonly Void = 29; + public static readonly Null = 30; + public static readonly Undefined = 31; + public static readonly Comma = 32; + public static readonly SemiColon = 33; + public static readonly QuestionMark = 34; + public static readonly Colon = 35; + public static readonly LeftParen = 36; + public static readonly RightParen = 37; + public static readonly LeftBracket = 38; + public static readonly RightBracket = 39; + public static readonly FStringExpEnd = 40; + public static readonly LeftBrace = 41; + public static readonly RightBrace = 42; + public static readonly Plus = 43; + public static readonly PlusPlus = 44; + public static readonly Minus = 45; + public static readonly MinusMinus = 46; + public static readonly Star = 47; + public static readonly Div = 48; + public static readonly Mod = 49; + public static readonly PowerTo = 50; + public static readonly AndAnd = 51; + public static readonly OrOr = 52; + public static readonly Not = 53; + public static readonly Assign = 54; + public static readonly PlusAssign = 55; + public static readonly MinusAssign = 56; + public static readonly StarAssign = 57; + public static readonly DivAssign = 58; + public static readonly ModAssign = 59; + public static readonly Equal = 60; + public static readonly NotEqual = 61; + public static readonly Less = 62; + public static readonly LessEqual = 63; + public static readonly Greater = 64; + public static readonly GreaterEqual = 65; + public static readonly BitwiseAnd = 66; + public static readonly BitwiseOr = 67; + public static readonly BitwiseXor = 68; + public static readonly BitwiseNot = 69; + public static readonly BitwiseZeroFillLeftShift = 70; + public static readonly BitwiseSignedRightShift = 71; + public static readonly BitwiseZeroFillRightShift = 72; + public static readonly Dot = 73; + public static readonly Identifier = 74; + public static readonly IntegerConstant = 75; + public static readonly SingleQuoteStringLiteral = 76; + public static readonly DoubleQuoteStringLiteral = 77; + public static readonly FloatingConstant = 78; + public static readonly Whitespace = 79; + public static readonly Newline = 80; + public static readonly FStringSingleQuoteStart = 81; + public static readonly FStringDoubleQuoteStart = 82; + public static readonly FStringSingleQuoteEnd = 83; + public static readonly FStringSingleQuoteAtom = 84; + public static readonly FStringDoubleQuoteEnd = 85; + public static readonly FStringDoubleQuoteAtom = 86; public static readonly RULE_compilationUnit = 0; public static readonly RULE_translationUnit = 1; public static readonly RULE_externalItem = 2; public static readonly RULE_blockItemList = 3; public static readonly RULE_blockItem = 4; public static readonly RULE_declaration = 5; - public static readonly RULE_functionDeclaration = 6; - public static readonly RULE_variableDeclaration = 7; - public static readonly RULE_storageTypeSpecifier = 8; - public static readonly RULE_declarator = 9; - public static readonly RULE_directDeclarator = 10; - public static readonly RULE_initDeclarator = 11; - public static readonly RULE_parameterList = 12; - public static readonly RULE_parameterDeclaration = 13; - public static readonly RULE_initializer = 14; - public static readonly RULE_statement = 15; - public static readonly RULE_compoundStatement = 16; - public static readonly RULE_expressionStatement = 17; - public static readonly RULE_selectionStatement = 18; - public static readonly RULE_ifStatement = 19; - public static readonly RULE_switchStatement = 20; - public static readonly RULE_switchLabeledStatement = 21; - public static readonly RULE_iterationStatement = 22; - public static readonly RULE_forLoopIterationStatement = 23; - public static readonly RULE_whileLoopIterationStatement = 24; - public static readonly RULE_doWhileLoopIterationStatement = 25; - public static readonly RULE_jumpStatement = 26; - public static readonly RULE_returnStatement = 27; - public static readonly RULE_primaryExpression = 28; - public static readonly RULE_lambdaExpression = 29; - public static readonly RULE_tangledPrimaryExpression = 30; - public static readonly RULE_boolPrimaryExpression = 31; - public static readonly RULE_identifierPrimaryExpression = 32; - public static readonly RULE_identifier = 33; - public static readonly RULE_identifierOrStringPrimaryExpression = 34; - public static readonly RULE_stringPrimaryExpression = 35; - public static readonly RULE_fStringPrimaryExpression = 36; - public static readonly RULE_fStringSingleQuoteAtom = 37; - public static readonly RULE_fStringDoubleQuoteAtom = 38; - public static readonly RULE_numberPrimaryExpression = 39; - public static readonly RULE_arrayPrimaryExpression = 40; - public static readonly RULE_objectPrimaryExpression = 41; - public static readonly RULE_objectProperty = 42; - public static readonly RULE_voidOrNullOrUndefinedPrimaryExpression = 43; - public static readonly RULE_computedPrimaryExpression = 44; - public static readonly RULE_argumentExpressionList = 45; - public static readonly RULE_dotNotation = 46; - public static readonly RULE_bracketNotation = 47; - public static readonly RULE_sliceNotation = 48; - public static readonly RULE_postfixExpression = 49; - public static readonly RULE_incrementOrDecrementPostfixExpression = 50; - public static readonly RULE_unaryExpression = 51; - public static readonly RULE_incrementOrDecrementUnaryExpression = 52; - public static readonly RULE_operatorModifiedUnaryExpression = 53; - public static readonly RULE_incrementOrDecrementOperator = 54; - public static readonly RULE_unaryOperator = 55; - public static readonly RULE_castOrConvertExpression = 56; - public static readonly RULE_multiplicativeExpression = 57; - public static readonly RULE_additiveExpression = 58; - public static readonly RULE_bitwiseShiftExpression = 59; - public static readonly RULE_bitwiseShiftOperators = 60; - public static readonly RULE_relationalExpression = 61; - public static readonly RULE_equalityExpression = 62; - public static readonly RULE_bitwiseAndExpression = 63; - public static readonly RULE_bitwiseXorExpression = 64; - public static readonly RULE_bitwiseOrExpression = 65; - public static readonly RULE_logicalAndExpression = 66; - public static readonly RULE_logicalOrExpression = 67; - public static readonly RULE_conditionalExpression = 68; - public static readonly RULE_assignmentExpression = 69; - public static readonly RULE_assignmentOperator = 70; - public static readonly RULE_expression = 71; - public static readonly RULE_typeSpecifierExpression = 72; - public static readonly RULE_identifierTypeSpecifierExpression = 73; - public static readonly RULE_genericTypeSpecifierExpression = 74; - public static readonly RULE_typeofTypeSpecifierExpression = 75; - public static readonly RULE_typeSpecifierIdentifier = 76; + public static readonly RULE_variableDeclaration = 6; + public static readonly RULE_storageTypeSpecifier = 7; + public static readonly RULE_initDeclarator = 8; + public static readonly RULE_initializer = 9; + public static readonly RULE_declarator = 10; + public static readonly RULE_directDeclarator = 11; + public static readonly RULE_functionDeclaration = 12; + public static readonly RULE_parameterList = 13; + public static readonly RULE_parameterDeclaration = 14; + public static readonly RULE_interfaceDeclaration = 15; + public static readonly RULE_classDeclaration = 16; + public static readonly RULE_statement = 17; + public static readonly RULE_compoundStatement = 18; + public static readonly RULE_expressionStatement = 19; + public static readonly RULE_selectionStatement = 20; + public static readonly RULE_ifStatement = 21; + public static readonly RULE_switchStatement = 22; + public static readonly RULE_switchLabeledStatement = 23; + public static readonly RULE_iterationStatement = 24; + public static readonly RULE_forLoopIterationStatement = 25; + public static readonly RULE_whileLoopIterationStatement = 26; + public static readonly RULE_doWhileLoopIterationStatement = 27; + public static readonly RULE_jumpStatement = 28; + public static readonly RULE_returnStatement = 29; + public static readonly RULE_primaryExpression = 30; + public static readonly RULE_lambdaExpression = 31; + public static readonly RULE_tangledPrimaryExpression = 32; + public static readonly RULE_boolPrimaryExpression = 33; + public static readonly RULE_identifierPrimaryExpression = 34; + public static readonly RULE_identifier = 35; + public static readonly RULE_identifierOrStringPrimaryExpression = 36; + public static readonly RULE_stringPrimaryExpression = 37; + public static readonly RULE_fStringPrimaryExpression = 38; + public static readonly RULE_fStringSingleQuoteAtom = 39; + public static readonly RULE_fStringDoubleQuoteAtom = 40; + public static readonly RULE_numberPrimaryExpression = 41; + public static readonly RULE_arrayPrimaryExpression = 42; + public static readonly RULE_objectPrimaryExpression = 43; + public static readonly RULE_objectProperty = 44; + public static readonly RULE_voidOrNullOrUndefinedPrimaryExpression = 45; + public static readonly RULE_computedPrimaryExpression = 46; + public static readonly RULE_argumentExpressionList = 47; + public static readonly RULE_dotNotation = 48; + public static readonly RULE_bracketNotation = 49; + public static readonly RULE_sliceNotation = 50; + public static readonly RULE_postfixExpression = 51; + public static readonly RULE_incrementOrDecrementPostfixExpression = 52; + public static readonly RULE_unaryExpression = 53; + public static readonly RULE_incrementOrDecrementUnaryExpression = 54; + public static readonly RULE_operatorModifiedUnaryExpression = 55; + public static readonly RULE_incrementOrDecrementOperator = 56; + public static readonly RULE_unaryOperator = 57; + public static readonly RULE_castOrConvertExpression = 58; + public static readonly RULE_multiplicativeExpression = 59; + public static readonly RULE_additiveExpression = 60; + public static readonly RULE_bitwiseShiftExpression = 61; + public static readonly RULE_bitwiseShiftOperators = 62; + public static readonly RULE_relationalExpression = 63; + public static readonly RULE_equalityExpression = 64; + public static readonly RULE_bitwiseAndExpression = 65; + public static readonly RULE_bitwiseXorExpression = 66; + public static readonly RULE_bitwiseOrExpression = 67; + public static readonly RULE_logicalAndExpression = 68; + public static readonly RULE_logicalOrExpression = 69; + public static readonly RULE_conditionalExpression = 70; + public static readonly RULE_assignmentExpression = 71; + public static readonly RULE_assignmentOperator = 72; + public static readonly RULE_expression = 73; + public static readonly RULE_typeSpecifierExpression = 74; + public static readonly RULE_identifierTypeSpecifierExpression = 75; + public static readonly RULE_genericTypeSpecifierExpression = 76; + public static readonly RULE_typeofTypeSpecifierExpression = 77; + public static readonly RULE_typeSpecifierIdentifier = 78; // tslint:disable:no-trailing-whitespace public static readonly ruleNames: string[] = [ "compilationUnit", @@ -195,15 +204,17 @@ export class KipperParser extends KipperParserBase { "blockItemList", "blockItem", "declaration", - "functionDeclaration", "variableDeclaration", "storageTypeSpecifier", + "initDeclarator", + "initializer", "declarator", "directDeclarator", - "initDeclarator", + "functionDeclaration", "parameterList", "parameterDeclaration", - "initializer", + "interfaceDeclaration", + "classDeclaration", "statement", "compoundStatement", "expressionStatement", @@ -293,6 +304,8 @@ export class KipperParser extends KipperParserBase { "'return'", "'call'", "'->'", + "'class'", + "'interface'", "'true'", "'false'", "'typeof'", @@ -367,6 +380,8 @@ export class KipperParser extends KipperParserBase { "Return", "CallFunc", "RetIndicator", + "Class", + "Interface", "True", "False", "Typeof", @@ -436,366 +451,13 @@ export class KipperParser extends KipperParserBase { ); // @Override - private static readonly _serializedATNSegments: number = 2; - - // tslint:enable:no-trailing-whitespace - private static readonly _serializedATNSegment0: string = - "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x03V\u02C2\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(\x04)\t)\x04*\t*\x04+\t+" + - "\x04,\t,\x04-\t-\x04.\t.\x04/\t/\x040\t0\x041\t1\x042\t2\x043\t3\x044" + - "\t4\x045\t5\x046\t6\x047\t7\x048\t8\x049\t9\x04:\t:\x04;\t;\x04<\t<\x04" + - "=\t=\x04>\t>\x04?\t?\x04@\t@\x04A\tA\x04B\tB\x04C\tC\x04D\tD\x04E\tE\x04" + - "F\tF\x04G\tG\x04H\tH\x04I\tI\x04J\tJ\x04K\tK\x04L\tL\x04M\tM\x04N\tN\x03" + - "\x02\x05\x02\x9E\n\x02\x03\x02\x03\x02\x03\x03\x06\x03\xA3\n\x03\r\x03" + - "\x0E\x03\xA4\x03\x04\x03\x04\x03\x05\x06\x05\xAA\n\x05\r\x05\x0E\x05\xAB" + - "\x03\x06\x03\x06\x03\x06\x05\x06\xB1\n\x06\x03\x07\x03\x07\x03\x07\x03" + - "\x07\x03\x07\x05\x07\xB8\n\x07\x05\x07\xBA\n\x07\x03\b\x03\b\x03\b\x03" + - "\b\x05\b\xC0\n\b\x03\b\x03\b\x03\b\x03\b\x05\b\xC6\n\b\x03\t\x03\t\x03" + - "\t\x03\n\x03\n\x03\v\x03\v\x03\f\x03\f\x03\r\x03\r\x03\r\x03\r\x03\r\x05" + - "\r\xD6\n\r\x03\x0E\x03\x0E\x03\x0E\x07\x0E\xDB\n\x0E\f\x0E\x0E\x0E\xDE" + - "\v\x0E\x03\x0F\x03\x0F\x03\x0F\x03\x0F\x03\x10\x03\x10\x03\x11\x03\x11" + - "\x03\x11\x03\x11\x03\x11\x03\x11\x05\x11\xEC\n\x11\x03\x12\x03\x12\x03" + - "\x12\x05\x12\xF1\n\x12\x03\x12\x03\x12\x03\x13\x03\x13\x03\x13\x03\x13" + - "\x03\x13\x03\x14\x03\x14\x05\x14\xFC\n\x14\x03\x15\x03\x15\x03\x15\x03" + - "\x15\x03\x15\x03\x15\x03\x15\x05\x15\u0105\n\x15\x03\x16\x03\x16\x03\x16" + - "\x03\x16\x03\x16\x03\x16\x07\x16\u010D\n\x16\f\x16\x0E\x16\u0110\v\x16" + - "\x03\x16\x03\x16\x03\x17\x03\x17\x03\x17\x03\x17\x03\x17\x03\x17\x03\x17" + - "\x03\x17\x05\x17\u011C\n\x17\x03\x18\x03\x18\x03\x18\x05\x18\u0121\n\x18" + - "\x03\x19\x03\x19\x03\x19\x03\x19\x05\x19\u0127\n\x19\x03\x19\x03\x19\x05" + - "\x19\u012B\n\x19\x03\x19\x03\x19\x03\x19\x03\x19\x05\x19\u0131\n\x19\x03" + - "\x19\x03\x19\x03\x19\x03\x19\x05\x19\u0137\n\x19\x03\x19\x03\x19\x03\x19" + - "\x03\x1A\x03\x1A\x03\x1A\x03\x1A\x03\x1A\x03\x1A\x03\x1B\x03\x1B\x03\x1B" + - "\x03\x1B\x03\x1B\x03\x1B\x03\x1B\x03\x1B\x03\x1C\x03\x1C\x03\x1C\x03\x1D" + - "\x03\x1D\x05\x1D\u014F\n\x1D\x03\x1D\x03\x1D\x03\x1E\x03\x1E\x03\x1E\x03" + - "\x1E\x03\x1E\x03\x1E\x03\x1E\x03\x1E\x03\x1E\x03\x1E\x05\x1E\u015D\n\x1E" + - "\x03\x1F\x03\x1F\x05\x1F\u0161\n\x1F\x03\x1F\x03\x1F\x03\x1F\x03\x1F\x03" + - '\x1F\x03\x1F\x05\x1F\u0169\n\x1F\x03 \x03 \x03 \x03 \x03!\x03!\x03"\x03' + - '"\x03#\x03#\x03$\x03$\x05$\u0177\n$\x03%\x03%\x03&\x03&\x07&\u017D\n' + - "&\f&\x0E&\u0180\v&\x03&\x03&\x03&\x07&\u0185\n&\f&\x0E&\u0188\v&\x03&" + - "\x05&\u018B\n&\x03'\x03'\x03'\x05'\u0190\n'\x03'\x05'\u0193\n'" + - "\x03(\x03(\x03(\x05(\u0198\n(\x03(\x05(\u019B\n(\x03)\x03)\x03*\x03*\x03" + - "*\x03*\x07*\u01A3\n*\f*\x0E*\u01A6\v*\x05*\u01A8\n*\x03*\x05*\u01AB\n" + - "*\x03*\x03*\x03+\x03+\x03+\x03+\x07+\u01B3\n+\f+\x0E+\u01B6\v+\x05+\u01B8" + - "\n+\x03+\x05+\u01BB\n+\x03+\x03+\x03,\x03,\x03,\x03,\x03-\x03-\x03.\x03" + - ".\x03.\x03.\x03.\x03.\x05.\u01CB\n.\x03.\x03.\x03.\x05.\u01D0\n.\x03." + - "\x03.\x03.\x05.\u01D5\n.\x03.\x03.\x03.\x03.\x03.\x03.\x03.\x03.\x03." + - "\x03.\x03.\x03.\x03.\x03.\x07.\u01E5\n.\f.\x0E.\u01E8\v.\x03/\x03/\x03" + - "/\x07/\u01ED\n/\f/\x0E/\u01F0\v/\x030\x030\x030\x031\x031\x031\x031\x03" + - "2\x032\x032\x032\x052\u01FD\n2\x032\x032\x032\x032\x052\u0203\n2\x032" + - "\x032\x033\x033\x053\u0209\n3\x034\x034\x034\x035\x035\x035\x055\u0211" + - "\n5\x036\x036\x036\x037\x037\x037\x038\x038\x039\x039\x03:\x03:\x03:\x03" + - ":\x03:\x05:\u0222\n:\x03;\x03;\x03;\x03;\x03;\x03;\x07;\u022A\n;\f;\x0E" + - ";\u022D\v;\x03<\x03<\x03<\x03<\x03<\x03<\x07<\u0235\n<\f<\x0E<\u0238\v" + - "<\x03=\x03=\x03=\x03=\x03=\x03=\x03=\x07=\u0241\n=\f=\x0E=\u0244\v=\x03" + - ">\x03>\x03?\x03?\x03?\x03?\x03?\x03?\x07?\u024E\n?\f?\x0E?\u0251\v?\x03" + - "@\x03@\x03@\x03@\x03@\x03@\x07@\u0259\n@\f@\x0E@\u025C\v@\x03A\x03A\x03" + - "A\x03A\x03A\x03A\x07A\u0264\nA\fA\x0EA\u0267\vA\x03B\x03B\x03B\x03B\x03" + - "B\x03B\x07B\u026F\nB\fB\x0EB\u0272\vB\x03C\x03C\x03C\x03C\x03C\x03C\x07" + - "C\u027A\nC\fC\x0EC\u027D\vC\x03D\x03D\x03D\x03D\x03D\x03D\x07D\u0285\n" + - "D\fD\x0ED\u0288\vD\x03E\x03E\x03E\x03E\x03E\x03E\x07E\u0290\nE\fE\x0E" + - "E\u0293\vE\x03F\x03F\x03F\x03F\x03F\x03F\x03F\x05F\u029C\nF\x03G\x03G" + - "\x03G\x03G\x03G\x05G\u02A3\nG\x03H\x03H\x03I\x03I\x03I\x07I\u02AA\nI\f" + - "I\x0EI\u02AD\vI\x03J\x03J\x03J\x05J\u02B2\nJ\x03K\x03K\x03L\x03L\x03L" + - "\x03L\x03L\x03M\x03M\x03M\x03M\x03M\x03N\x03N\x03N\x02\x02\rZtvx|~\x80" + - "\x82\x84\x86\x88O\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\x022\x024\x026\x028\x02:\x02<\x02>\x02" + - "@\x02B\x02D\x02F\x02H\x02J\x02L\x02N\x02P\x02R\x02T\x02V\x02X\x02Z\x02" + - "\\\x02^\x02`\x02b\x02d\x02f\x02h\x02j\x02l\x02n\x02p\x02r\x02t\x02v\x02" + - "x\x02z\x02|\x02~\x02\x80\x02\x82\x02\x84\x02\x86\x02\x88\x02\x8A\x02\x8C" + - "\x02\x8E\x02\x90\x02\x92\x02\x94\x02\x96\x02\x98\x02\x9A\x02\x02\x11\x03" + - "\x02\x07\b\x03\x02\x0E\x0F\x03\x02\x1A\x1B\x03\x02LM\x04\x02KKNN\x03\x02" + - "\x1D\x1F\x04\x02,,..\x06\x02++--55EE\x03\x02/2\x04\x02++--\x03\x02FH\x03" + - "\x02>A\x03\x02<=\x03\x026;\x04\x02\x1D\x1FJJ\x02\u02C6\x02\x9D\x03\x02" + - "\x02\x02\x04\xA2\x03\x02\x02\x02\x06\xA6\x03\x02\x02\x02\b\xA9\x03\x02" + - "\x02\x02\n\xB0\x03\x02\x02\x02\f\xB9\x03\x02\x02\x02\x0E\xBB\x03\x02\x02" + - "\x02\x10\xC7\x03\x02\x02\x02\x12\xCA\x03\x02\x02\x02\x14\xCC\x03\x02\x02" + - "\x02\x16\xCE\x03\x02\x02\x02\x18\xD0\x03\x02\x02\x02\x1A\xD7\x03\x02\x02" + - "\x02\x1C\xDF\x03\x02\x02\x02\x1E\xE3\x03\x02\x02\x02 \xEB\x03\x02\x02" + - '\x02"\xED\x03\x02\x02\x02$\xF4\x03\x02\x02\x02&\xFB\x03\x02\x02\x02(' + - "\xFD\x03\x02\x02\x02*\u0106\x03\x02\x02\x02,\u011B\x03\x02\x02\x02.\u0120" + - "\x03\x02\x02\x020\u0122\x03\x02\x02\x022\u013B\x03\x02\x02\x024\u0141" + - "\x03\x02\x02\x026\u0149\x03\x02\x02\x028\u014C\x03\x02\x02\x02:\u015C" + - "\x03\x02\x02\x02<\u015E\x03\x02\x02\x02>\u016A\x03\x02\x02\x02@\u016E" + - "\x03\x02\x02\x02B\u0170\x03\x02\x02\x02D\u0172\x03\x02\x02\x02F\u0176" + - "\x03\x02\x02\x02H\u0178\x03\x02\x02\x02J\u018A\x03\x02\x02\x02L\u0192" + - "\x03\x02\x02\x02N\u019A\x03\x02\x02\x02P\u019C\x03\x02\x02\x02R\u019E" + - "\x03\x02\x02\x02T\u01AE\x03\x02\x02\x02V\u01BE\x03\x02\x02\x02X\u01C2" + - "\x03\x02\x02\x02Z\u01CF\x03\x02\x02\x02\\\u01E9\x03\x02\x02\x02^\u01F1" + - "\x03\x02\x02\x02`\u01F4\x03\x02\x02\x02b\u01F8\x03\x02\x02\x02d\u0208" + - "\x03\x02\x02\x02f\u020A\x03\x02\x02\x02h\u0210\x03\x02\x02\x02j\u0212" + - "\x03\x02\x02\x02l\u0215\x03\x02\x02\x02n\u0218\x03\x02\x02\x02p\u021A" + - "\x03\x02\x02\x02r\u0221\x03\x02\x02\x02t\u0223\x03\x02\x02\x02v\u022E" + - "\x03\x02\x02\x02x\u0239\x03\x02\x02\x02z\u0245\x03\x02\x02\x02|\u0247" + - "\x03\x02\x02\x02~\u0252\x03\x02\x02\x02\x80\u025D\x03\x02\x02\x02\x82" + - "\u0268\x03\x02\x02\x02\x84\u0273\x03\x02\x02\x02\x86\u027E\x03\x02\x02" + - "\x02\x88\u0289\x03\x02\x02\x02\x8A\u029B\x03\x02\x02\x02\x8C\u02A2\x03" + - "\x02\x02\x02\x8E\u02A4\x03\x02\x02\x02\x90\u02A6\x03\x02\x02\x02\x92\u02B1" + - "\x03\x02\x02\x02\x94\u02B3\x03\x02\x02\x02\x96\u02B5\x03\x02\x02\x02\x98" + - "\u02BA\x03\x02\x02\x02\x9A\u02BF\x03\x02\x02\x02\x9C\x9E\x05\x04\x03\x02" + - "\x9D\x9C\x03\x02\x02\x02\x9D\x9E\x03\x02\x02\x02\x9E\x9F\x03\x02\x02\x02" + - "\x9F\xA0\x07\x02\x02\x03\xA0\x03\x03\x02\x02\x02\xA1\xA3\x05\x06\x04\x02" + - "\xA2\xA1\x03\x02\x02\x02\xA3\xA4\x03\x02\x02\x02\xA4\xA2\x03\x02\x02\x02" + - "\xA4\xA5\x03\x02\x02\x02\xA5\x05\x03\x02\x02\x02\xA6\xA7\x05\b\x05\x02" + - "\xA7\x07\x03\x02\x02\x02\xA8\xAA\x05\n\x06\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\t\x03\x02\x02\x02\xAD\xB1\x05 \x11\x02\xAE\xB1\x05\f\x07\x02\xAF" + - "\xB1\x07!\x02\x02\xB0\xAD\x03\x02\x02\x02\xB0\xAE\x03\x02\x02\x02\xB0" + - "\xAF\x03\x02\x02\x02\xB1\v\x03\x02\x02\x02\xB2\xB3\x05\x10\t\x02\xB3\xB4" + - "\x07!\x02\x02\xB4\xBA\x03\x02\x02\x02\xB5\xB7\x05\x0E\b\x02\xB6\xB8\x07" + - "!\x02\x02\xB7\xB6\x03\x02\x02\x02\xB7\xB8\x03\x02\x02\x02\xB8\xBA\x03" + - "\x02\x02\x02\xB9\xB2\x03\x02\x02\x02\xB9\xB5\x03\x02\x02\x02\xBA\r\x03" + - "\x02\x02\x02\xBB\xBC\x07\x16\x02\x02\xBC\xBD\x05\x14\v\x02\xBD\xBF\x07" + - "$\x02\x02\xBE\xC0\x05\x1A\x0E\x02\xBF\xBE\x03\x02\x02\x02\xBF\xC0\x03" + - "\x02\x02\x02\xC0\xC1\x03\x02\x02\x02\xC1\xC2\x07%\x02\x02\xC2\xC3\x07" + - '\x19\x02\x02\xC3\xC5\x05\x92J\x02\xC4\xC6\x05"\x12\x02\xC5\xC4\x03\x02' + - "\x02\x02\xC5\xC6\x03\x02\x02\x02\xC6\x0F\x03\x02\x02\x02\xC7\xC8\x05\x12" + - "\n\x02\xC8\xC9\x05\x18\r\x02\xC9\x11\x03\x02\x02\x02\xCA\xCB\t\x02\x02" + - "\x02\xCB\x13\x03\x02\x02\x02\xCC\xCD\x05\x16\f\x02\xCD\x15\x03\x02\x02" + - "\x02\xCE\xCF\x07J\x02\x02\xCF\x17\x03\x02\x02\x02\xD0\xD1\x05\x14\v\x02" + - "\xD1\xD2\x07#\x02\x02\xD2\xD5\x05\x92J\x02\xD3\xD4\x076\x02\x02\xD4\xD6" + - "\x05\x1E\x10\x02\xD5\xD3\x03\x02\x02\x02\xD5\xD6\x03\x02\x02\x02\xD6\x19" + - "\x03\x02\x02\x02\xD7\xDC\x05\x1C\x0F\x02\xD8\xD9\x07 \x02\x02\xD9\xDB" + - "\x05\x1C\x0F\x02\xDA\xD8\x03\x02\x02\x02\xDB\xDE\x03\x02\x02\x02\xDC\xDA" + - "\x03\x02\x02\x02\xDC\xDD\x03\x02\x02\x02\xDD\x1B\x03\x02\x02\x02\xDE\xDC" + - "\x03\x02\x02\x02\xDF\xE0\x05\x14\v\x02\xE0\xE1\x07#\x02\x02\xE1\xE2\x05" + - "\x92J\x02\xE2\x1D\x03\x02\x02\x02\xE3\xE4\x05\x8CG\x02\xE4\x1F\x03\x02" + - "\x02\x02\xE5\xEC\x05$\x13\x02\xE6\xEC\x05&\x14\x02\xE7\xEC\x05.\x18\x02" + - '\xE8\xEC\x056\x1C\x02\xE9\xEC\x058\x1D\x02\xEA\xEC\x05"\x12\x02\xEB\xE5' + - "\x03\x02\x02\x02\xEB\xE6\x03\x02\x02\x02\xEB\xE7\x03\x02\x02\x02\xEB\xE8" + - "\x03\x02\x02\x02\xEB\xE9\x03\x02\x02\x02\xEB\xEA\x03\x02\x02\x02\xEC!" + - "\x03\x02\x02\x02\xED\xEE\x06\x12\x02\x02\xEE\xF0\x07)\x02\x02\xEF\xF1" + - "\x05\b\x05\x02\xF0\xEF\x03\x02\x02\x02\xF0\xF1\x03\x02\x02\x02\xF1\xF2" + - "\x03\x02\x02\x02\xF2\xF3\x07*\x02\x02\xF3#\x03\x02\x02\x02\xF4\xF5\b\x13" + - "\x01\x02\xF5\xF6\x05\x90I\x02\xF6\xF7\x07!\x02\x02\xF7\xF8\b\x13\x01\x02" + - "\xF8%\x03\x02\x02\x02\xF9\xFC\x05(\x15\x02\xFA\xFC\x05*\x16\x02\xFB\xF9" + - "\x03\x02\x02\x02\xFB\xFA\x03\x02\x02\x02\xFC'\x03\x02\x02\x02\xFD\xFE" + - "\x07\x12\x02\x02\xFE\xFF\x07$\x02\x02\xFF\u0100\x05\x90I\x02\u0100\u0101" + - "\x07%\x02\x02\u0101\u0104\x05 \x11\x02\u0102\u0103\x07\x13\x02\x02\u0103" + - "\u0105\x05 \x11\x02\u0104\u0102\x03\x02\x02\x02\u0104\u0105\x03\x02\x02" + - "\x02\u0105)\x03\x02\x02\x02\u0106\u0107\x07\v\x02\x02\u0107\u0108\x07" + - "$\x02\x02\u0108\u0109\x05\x90I\x02\u0109\u010A\x07%\x02\x02\u010A\u010E" + - "\x07)\x02\x02\u010B\u010D\x05,\x17\x02\u010C\u010B\x03\x02\x02\x02\u010D" + - "\u0110\x03\x02\x02\x02\u010E\u010C\x03\x02\x02\x02\u010E\u010F\x03\x02" + - "\x02\x02\u010F\u0111\x03\x02\x02\x02\u0110\u010E\x03\x02\x02\x02\u0111" + - "\u0112\x07*\x02\x02\u0112+\x03\x02\x02\x02\u0113\u0114\x07\f\x02\x02\u0114" + - "\u0115\x05\x90I\x02\u0115\u0116\x07#\x02\x02\u0116\u0117\x05 \x11\x02" + - "\u0117\u011C\x03\x02\x02\x02\u0118\u0119\x07\r\x02\x02\u0119\u011A\x07" + - "#\x02\x02\u011A\u011C\x05 \x11\x02\u011B\u0113\x03\x02\x02\x02\u011B\u0118" + - "\x03\x02\x02\x02\u011C-\x03\x02\x02\x02\u011D\u0121\x050\x19\x02\u011E" + - "\u0121\x052\x1A\x02\u011F\u0121\x054\x1B\x02\u0120\u011D\x03\x02\x02\x02" + - "\u0120\u011E\x03\x02\x02\x02\u0120\u011F\x03\x02\x02\x02\u0121/\x03\x02" + - "\x02\x02\u0122\u0123\x07\x14\x02\x02\u0123\u012A\x07$\x02\x02\u0124\u0127" + - "\x05\x10\t\x02\u0125\u0127\x05\x90I\x02\u0126\u0124\x03\x02\x02\x02\u0126" + - "\u0125\x03\x02\x02\x02\u0127\u0128\x03\x02\x02\x02\u0128\u0129\b\x19\x01" + - "\x02\u0129\u012B\x03\x02\x02\x02\u012A\u0126\x03\x02\x02\x02\u012A\u012B" + - "\x03\x02\x02\x02\u012B\u012C\x03\x02\x02\x02\u012C\u0130\x07!\x02\x02" + - "\u012D\u012E\x05\x90I\x02\u012E\u012F\b\x19\x01\x02\u012F\u0131\x03\x02" + - "\x02\x02\u0130\u012D\x03\x02\x02\x02\u0130\u0131\x03\x02\x02\x02\u0131" + - "\u0132\x03\x02\x02\x02\u0132\u0136\x07!\x02\x02\u0133\u0134\x05\x90I\x02" + - "\u0134\u0135\b\x19\x01\x02\u0135\u0137\x03\x02\x02\x02\u0136\u0133\x03" + - "\x02\x02\x02\u0136\u0137\x03\x02\x02\x02\u0137\u0138\x03\x02\x02\x02\u0138" + - "\u0139\x07%\x02\x02\u0139\u013A\x05 \x11\x02\u013A1\x03\x02\x02\x02\u013B" + - "\u013C\x07\x11\x02\x02\u013C\u013D\x07$\x02\x02\u013D\u013E\x05\x90I\x02" + - "\u013E\u013F\x07%\x02\x02\u013F\u0140\x05 \x11\x02\u01403\x03\x02\x02" + - "\x02\u0141\u0142\x07\x10\x02\x02\u0142\u0143\x05 \x11\x02\u0143\u0144" + - "\x07\x11\x02\x02\u0144\u0145\x07$\x02\x02\u0145\u0146\x05\x90I\x02\u0146" + - "\u0147\x07%\x02\x02\u0147\u0148\x07!\x02\x02\u01485\x03\x02\x02\x02\u0149" + - "\u014A\t\x03\x02\x02\u014A\u014B\x07!\x02\x02\u014B7\x03\x02\x02\x02\u014C" + - "\u014E\x07\x17\x02\x02\u014D\u014F\x05\x90I\x02\u014E\u014D\x03\x02\x02" + - "\x02\u014E\u014F\x03\x02\x02\x02\u014F\u0150\x03\x02\x02\x02\u0150\u0151" + - "\x07!\x02\x02\u01519\x03\x02\x02\x02\u0152\u015D\x05> \x02\u0153\u015D" + - "\x05R*\x02\u0154\u015D\x05T+\x02\u0155\u015D\x05@!\x02\u0156\u015D\x05" + - 'B"\x02\u0157\u015D\x05H%\x02\u0158\u015D\x05J&\x02\u0159\u015D\x05P)' + - "\x02\u015A\u015D\x05X-\x02\u015B\u015D\x05<\x1F\x02\u015C\u0152\x03\x02" + - "\x02\x02\u015C\u0153\x03\x02\x02\x02\u015C\u0154\x03\x02\x02\x02\u015C" + - "\u0155\x03\x02\x02\x02\u015C\u0156\x03\x02\x02\x02\u015C\u0157\x03\x02" + - "\x02\x02\u015C\u0158\x03\x02\x02\x02\u015C\u0159\x03\x02\x02\x02\u015C" + - "\u015A\x03\x02\x02\x02\u015C\u015B\x03\x02\x02\x02\u015D;\x03\x02\x02" + - "\x02\u015E\u0160\x07$\x02\x02\u015F\u0161\x05\x1A\x0E\x02\u0160\u015F" + - "\x03\x02\x02\x02\u0160\u0161\x03\x02\x02\x02\u0161\u0162\x03\x02\x02\x02" + - "\u0162\u0163\x07%\x02\x02\u0163\u0164\x07#\x02\x02\u0164\u0165\x05\x92" + - "J\x02\u0165\u0168\x07\x19\x02\x02\u0166\u0169\x05\x90I\x02\u0167\u0169" + - '\x05"\x12\x02\u0168\u0166\x03\x02\x02\x02\u0168\u0167\x03\x02\x02\x02' + - "\u0169=\x03\x02\x02\x02\u016A\u016B\x07$\x02\x02\u016B\u016C\x05\x90I" + - "\x02\u016C\u016D\x07%\x02\x02\u016D?\x03\x02\x02\x02\u016E\u016F\t\x04" + - "\x02\x02\u016FA\x03\x02\x02\x02\u0170\u0171\x05D#\x02\u0171C\x03\x02\x02" + - "\x02\u0172\u0173\x07J\x02\x02\u0173E\x03\x02\x02\x02\u0174\u0177\x05D" + - "#\x02\u0175\u0177\x05H%\x02\u0176\u0174\x03\x02\x02\x02\u0176\u0175\x03" + - "\x02\x02\x02\u0177G\x03\x02\x02\x02\u0178\u0179\t\x05\x02\x02\u0179I\x03" + - "\x02\x02\x02\u017A\u017E\x07Q\x02\x02\u017B\u017D\x05L'\x02\u017C\u017B" + - "\x03\x02\x02\x02\u017D\u0180\x03\x02\x02\x02\u017E\u017C\x03\x02\x02\x02" + - "\u017E\u017F\x03\x02\x02\x02\u017F\u0181\x03\x02\x02\x02\u0180\u017E\x03" + - "\x02\x02\x02\u0181\u018B\x07S\x02\x02\u0182\u0186\x07R\x02\x02\u0183\u0185" + - "\x05N(\x02\u0184\u0183\x03\x02\x02\x02\u0185\u0188\x03\x02\x02\x02\u0186" + - "\u0184\x03\x02\x02\x02\u0186\u0187\x03\x02\x02\x02\u0187\u0189\x03\x02" + - "\x02\x02\u0188\u0186\x03\x02\x02\x02\u0189\u018B\x07U\x02\x02\u018A\u017A" + - "\x03\x02\x02\x02\u018A\u0182\x03\x02\x02\x02\u018BK\x03\x02\x02\x02\u018C" + - "\u0193\x07T\x02\x02\u018D\u018F\x07\x03\x02\x02\u018E\u0190\x05\x90I\x02" + - "\u018F\u018E\x03\x02\x02\x02\u018F\u0190\x03\x02\x02\x02\u0190\u0191\x03" + - "\x02\x02\x02\u0191\u0193\x07(\x02\x02\u0192\u018C\x03\x02\x02\x02\u0192" + - "\u018D\x03\x02\x02\x02\u0193M\x03\x02\x02\x02\u0194\u019B\x07V\x02\x02" + - "\u0195\u0197\x07\x03\x02\x02\u0196\u0198\x05\x90I\x02\u0197\u0196\x03" + - "\x02\x02\x02\u0197\u0198\x03\x02\x02\x02\u0198\u0199\x03\x02\x02\x02\u0199" + - "\u019B\x07(\x02\x02\u019A\u0194\x03\x02\x02\x02\u019A\u0195\x03\x02\x02" + - "\x02\u019BO\x03\x02\x02\x02\u019C\u019D\t\x06\x02\x02\u019DQ\x03\x02\x02" + - "\x02\u019E\u01A7\x07&\x02\x02\u019F\u01A4\x05\x90I\x02\u01A0\u01A1\x07" + - " \x02\x02\u01A1\u01A3\x05\x90I\x02\u01A2\u01A0\x03\x02\x02\x02\u01A3\u01A6" + - "\x03\x02\x02\x02\u01A4\u01A2\x03\x02\x02\x02\u01A4\u01A5\x03\x02\x02\x02" + - "\u01A5\u01A8\x03\x02\x02\x02\u01A6\u01A4\x03\x02\x02\x02\u01A7\u019F\x03" + - "\x02\x02\x02\u01A7\u01A8\x03\x02\x02\x02\u01A8\u01AA\x03\x02\x02\x02\u01A9" + - "\u01AB\x07 \x02\x02\u01AA\u01A9\x03\x02\x02\x02\u01AA\u01AB\x03\x02\x02" + - "\x02\u01AB\u01AC\x03\x02\x02\x02\u01AC\u01AD\x07'\x02\x02\u01ADS\x03" + - "\x02\x02\x02\u01AE\u01B7\x07)\x02\x02\u01AF\u01B4\x05V,\x02\u01B0\u01B1" + - "\x07 \x02\x02\u01B1\u01B3\x05V,\x02\u01B2\u01B0\x03\x02\x02\x02\u01B3" + - "\u01B6\x03\x02\x02\x02\u01B4\u01B2\x03\x02\x02\x02\u01B4\u01B5\x03\x02" + - "\x02\x02\u01B5\u01B8\x03\x02\x02\x02\u01B6\u01B4\x03\x02\x02\x02\u01B7" + - "\u01AF\x03\x02\x02\x02\u01B7\u01B8\x03\x02\x02\x02\u01B8\u01BA\x03\x02" + - "\x02\x02\u01B9\u01BB\x07 \x02\x02\u01BA\u01B9\x03\x02\x02\x02\u01BA\u01BB" + - "\x03\x02\x02\x02\u01BB\u01BC\x03\x02\x02\x02\u01BC\u01BD\x07*\x02\x02" + - "\u01BDU\x03\x02\x02\x02\u01BE\u01BF\x05F$\x02\u01BF\u01C0\x07#\x02\x02" + - "\u01C0\u01C1\x05\x90I\x02\u01C1W\x03\x02\x02\x02\u01C2\u01C3\t\x07\x02" + - "\x02\u01C3Y\x03\x02\x02\x02\u01C4\u01C5\b.\x01\x02\u01C5\u01D0\x05:\x1E" + - "\x02\u01C6\u01C7\x07\x18\x02\x02\u01C7\u01C8\x05Z.\x02\u01C8\u01CA\x07" + - "$\x02\x02\u01C9\u01CB\x05\\/\x02\u01CA\u01C9\x03\x02\x02\x02\u01CA\u01CB" + - "\x03\x02\x02\x02\u01CB\u01CC\x03\x02\x02\x02\u01CC\u01CD\x07%\x02\x02" + - "\u01CD\u01CE\b.\x01\x02\u01CE\u01D0\x03\x02\x02\x02\u01CF\u01C4\x03\x02" + - "\x02\x02\u01CF\u01C6\x03\x02\x02\x02\u01D0\u01E6\x03\x02\x02\x02\u01D1" + - "\u01D2\f\x07\x02\x02\u01D2\u01D4\x07$\x02\x02\u01D3\u01D5\x05\\/\x02\u01D4" + - "\u01D3\x03\x02\x02\x02\u01D4\u01D5\x03\x02\x02\x02\u01D5\u01D6\x03\x02" + - "\x02\x02\u01D6\u01D7\x07%\x02\x02\u01D7\u01E5\b.\x01\x02\u01D8\u01D9\f" + - "\x05\x02\x02\u01D9\u01DA\x05^0\x02\u01DA\u01DB\b.\x01\x02\u01DB\u01E5" + - "\x03\x02\x02\x02\u01DC\u01DD\f\x04\x02\x02\u01DD\u01DE\x05`1\x02\u01DE" + - "\u01DF\b.\x01\x02\u01DF\u01E5\x03\x02\x02\x02\u01E0\u01E1\f\x03\x02\x02" + - "\u01E1\u01E2\x05b2\x02\u01E2\u01E3\b.\x01\x02\u01E3\u01E5\x03\x02\x02" + - "\x02\u01E4\u01D1\x03\x02\x02\x02\u01E4\u01D8\x03\x02\x02\x02\u01E4\u01DC" + - "\x03\x02\x02\x02\u01E4\u01E0\x03\x02\x02\x02\u01E5\u01E8\x03\x02\x02\x02" + - "\u01E6\u01E4\x03\x02\x02\x02\u01E6\u01E7\x03\x02\x02\x02\u01E7[\x03\x02" + - "\x02\x02\u01E8\u01E6\x03\x02\x02\x02\u01E9\u01EE\x05\x8CG\x02\u01EA\u01EB" + - "\x07 \x02\x02\u01EB\u01ED\x05\x8CG\x02\u01EC\u01EA\x03\x02\x02\x02\u01ED" + - "\u01F0\x03\x02\x02\x02\u01EE\u01EC\x03\x02\x02\x02\u01EE\u01EF\x03\x02" + - "\x02\x02\u01EF]\x03\x02\x02\x02\u01F0\u01EE\x03\x02\x02\x02\u01F1\u01F2" + - "\x07I\x02\x02\u01F2\u01F3\x05D#\x02\u01F3_\x03\x02\x02\x02\u01F4\u01F5" + - "\x07&\x02\x02\u01F5\u01F6\x05\x90I\x02\u01F6\u01F7\x07'\x02\x02\u01F7" + - "a\x03\x02\x02\x02\u01F8\u01FC\x07&\x02\x02\u01F9\u01FA\x05\x90I\x02\u01FA" + - "\u01FB\b2\x01\x02\u01FB\u01FD\x03\x02\x02\x02\u01FC\u01F9\x03\x02\x02" + - "\x02\u01FC\u01FD\x03\x02\x02\x02\u01FD\u01FE\x03\x02\x02\x02\u01FE\u0202" + - "\x07#\x02\x02\u01FF\u0200\x05\x90I\x02\u0200\u0201\b2\x01\x02\u0201\u0203" + - "\x03\x02\x02\x02\u0202\u01FF\x03\x02\x02\x02\u0202\u0203\x03\x02\x02\x02" + - "\u0203\u0204\x03\x02\x02\x02\u0204\u0205\x07'\x02\x02\u0205c\x03\x02" + - "\x02\x02\u0206\u0209\x05Z.\x02\u0207\u0209\x05f4\x02\u0208\u0206\x03\x02" + - "\x02\x02\u0208\u0207\x03\x02\x02\x02\u0209e\x03\x02\x02\x02\u020A\u020B" + - "\x05Z.\x02\u020B\u020C\x05n8\x02\u020Cg\x03\x02\x02\x02\u020D\u0211\x05" + - "d3\x02\u020E\u0211\x05j6\x02\u020F\u0211\x05l7\x02\u0210\u020D\x03\x02" + - "\x02\x02\u0210\u020E\x03\x02\x02\x02\u0210\u020F\x03\x02\x02\x02\u0211" + - "i\x03\x02\x02\x02\u0212\u0213\x05n8\x02\u0213\u0214\x05d3\x02\u0214k\x03" + - "\x02\x02\x02\u0215\u0216\x05p9\x02\u0216\u0217\x05d3\x02\u0217m\x03\x02" + - "\x02\x02\u0218\u0219\t\b\x02\x02\u0219o\x03\x02\x02\x02\u021A\u021B\t" + - "\t\x02\x02\u021Bq\x03\x02\x02\x02\u021C\u0222\x05h5\x02\u021D\u021E\x05" + - "h5\x02\u021E\u021F\x07\t\x02\x02\u021F\u0220\x05\x92J\x02\u0220\u0222" + - "\x03\x02\x02\x02\u0221\u021C\x03\x02\x02\x02\u0221\u021D\x03\x02\x02\x02" + - "\u0222s\x03\x02\x02\x02\u0223\u0224\b;\x01\x02\u0224\u0225\x05r:\x02\u0225" + - "\u022B\x03\x02\x02\x02\u0226\u0227\f\x03\x02\x02\u0227\u0228\t\n\x02\x02" + - "\u0228\u022A\x05r:\x02\u0229\u0226\x03"; - private static readonly _serializedATNSegment1: string = - "\x02\x02\x02\u022A\u022D\x03\x02\x02\x02\u022B\u0229\x03\x02\x02\x02\u022B" + - "\u022C\x03\x02\x02\x02\u022Cu\x03\x02\x02\x02\u022D\u022B\x03\x02\x02" + - "\x02\u022E\u022F\b<\x01\x02\u022F\u0230\x05t;\x02\u0230\u0236\x03\x02" + - "\x02\x02\u0231\u0232\f\x03\x02\x02\u0232\u0233\t\v\x02\x02\u0233\u0235" + - "\x05t;\x02\u0234\u0231\x03\x02\x02\x02\u0235\u0238\x03\x02\x02\x02\u0236" + - "\u0234\x03\x02\x02\x02\u0236\u0237\x03\x02\x02\x02\u0237w\x03\x02\x02" + - "\x02\u0238\u0236\x03\x02\x02\x02\u0239\u023A\b=\x01\x02\u023A\u023B\x05" + - "v<\x02\u023B\u0242\x03\x02\x02\x02\u023C\u023D\f\x03\x02\x02\u023D\u023E" + - "\x05z>\x02\u023E\u023F\x05\x80A\x02\u023F\u0241\x03\x02\x02\x02\u0240" + - "\u023C\x03\x02\x02\x02\u0241\u0244\x03\x02\x02\x02\u0242\u0240\x03\x02" + - "\x02\x02\u0242\u0243\x03\x02\x02\x02\u0243y\x03\x02\x02\x02\u0244\u0242" + - "\x03\x02\x02\x02\u0245\u0246\t\f\x02\x02\u0246{\x03\x02\x02\x02\u0247" + - "\u0248\b?\x01\x02\u0248\u0249\x05x=\x02\u0249\u024F\x03\x02\x02\x02\u024A" + - "\u024B\f\x03\x02\x02\u024B\u024C\t\r\x02\x02\u024C\u024E\x05x=\x02\u024D" + - "\u024A\x03\x02\x02\x02\u024E\u0251\x03\x02\x02\x02\u024F\u024D\x03\x02" + - "\x02\x02\u024F\u0250\x03\x02\x02\x02\u0250}\x03\x02\x02\x02\u0251\u024F" + - "\x03\x02\x02\x02\u0252\u0253\b@\x01\x02\u0253\u0254\x05|?\x02\u0254\u025A" + - "\x03\x02\x02\x02\u0255\u0256\f\x03\x02\x02\u0256\u0257\t\x0E\x02\x02\u0257" + - "\u0259\x05|?\x02\u0258\u0255\x03\x02\x02\x02\u0259\u025C\x03\x02\x02\x02" + - "\u025A\u0258\x03\x02\x02\x02\u025A\u025B\x03\x02\x02\x02\u025B\x7F\x03" + - "\x02\x02\x02\u025C\u025A\x03\x02\x02\x02\u025D\u025E\bA\x01\x02\u025E" + - "\u025F\x05~@\x02\u025F\u0265\x03\x02\x02\x02\u0260\u0261\f\x03\x02\x02" + - "\u0261\u0262\x07B\x02\x02\u0262\u0264\x05~@\x02\u0263\u0260\x03\x02\x02" + - "\x02\u0264\u0267\x03\x02\x02\x02\u0265\u0263\x03\x02\x02\x02\u0265\u0266" + - "\x03\x02\x02\x02\u0266\x81\x03\x02\x02\x02\u0267\u0265\x03\x02\x02\x02" + - "\u0268\u0269\bB\x01\x02\u0269\u026A\x05\x80A\x02\u026A\u0270\x03\x02\x02" + - "\x02\u026B\u026C\f\x03\x02\x02\u026C\u026D\x07D\x02\x02\u026D\u026F\x05" + - "\x80A\x02\u026E\u026B\x03\x02\x02\x02\u026F\u0272\x03\x02\x02\x02\u0270" + - "\u026E\x03\x02\x02\x02\u0270\u0271\x03\x02\x02\x02\u0271\x83\x03\x02\x02" + - "\x02\u0272\u0270\x03\x02\x02\x02\u0273\u0274\bC\x01\x02\u0274\u0275\x05" + - "\x82B\x02\u0275\u027B\x03\x02\x02\x02\u0276\u0277\f\x03\x02\x02\u0277" + - "\u0278\x07C\x02\x02\u0278\u027A\x05\x82B\x02\u0279\u0276\x03\x02\x02\x02" + - "\u027A\u027D\x03\x02\x02\x02\u027B\u0279\x03\x02\x02\x02\u027B\u027C\x03" + - "\x02\x02\x02\u027C\x85\x03\x02\x02\x02\u027D\u027B\x03\x02\x02\x02\u027E" + - "\u027F\bD\x01\x02\u027F\u0280\x05\x84C\x02\u0280\u0286\x03\x02\x02\x02" + - "\u0281\u0282\f\x03\x02\x02\u0282\u0283\x073\x02\x02\u0283\u0285\x05\x84" + - "C\x02\u0284\u0281\x03\x02\x02\x02\u0285\u0288\x03\x02\x02\x02\u0286\u0284" + - "\x03\x02\x02\x02\u0286\u0287\x03\x02\x02\x02\u0287\x87\x03\x02\x02\x02" + - "\u0288\u0286\x03\x02\x02\x02\u0289\u028A\bE\x01\x02\u028A\u028B\x05\x86" + - "D\x02\u028B\u0291\x03\x02\x02\x02\u028C\u028D\f\x03\x02\x02\u028D\u028E" + - "\x074\x02\x02\u028E\u0290\x05\x86D\x02\u028F\u028C\x03\x02\x02\x02\u0290" + - "\u0293\x03\x02\x02\x02\u0291\u028F\x03\x02\x02\x02\u0291\u0292\x03\x02" + - "\x02\x02\u0292\x89\x03\x02\x02\x02\u0293\u0291\x03\x02\x02\x02\u0294\u029C" + - '\x05\x88E\x02\u0295\u0296\x05\x88E\x02\u0296\u0297\x07"\x02\x02\u0297' + - "\u0298\x05\x8AF\x02\u0298\u0299\x07#\x02\x02\u0299\u029A\x05\x8AF\x02" + - "\u029A\u029C\x03\x02\x02\x02\u029B\u0294\x03\x02\x02\x02\u029B\u0295\x03" + - "\x02\x02\x02\u029C\x8B\x03\x02\x02\x02\u029D\u02A3\x05\x8AF\x02\u029E" + - "\u029F\x05Z.\x02\u029F\u02A0\x05\x8EH\x02\u02A0\u02A1\x05\x8CG\x02\u02A1" + - "\u02A3\x03\x02\x02\x02\u02A2\u029D\x03\x02\x02\x02\u02A2\u029E\x03\x02" + - "\x02\x02\u02A3\x8D\x03\x02\x02\x02\u02A4\u02A5\t\x0F\x02\x02\u02A5\x8F" + - "\x03\x02\x02\x02\u02A6\u02AB\x05\x8CG\x02\u02A7\u02A8\x07 \x02\x02\u02A8" + - "\u02AA\x05\x8CG\x02\u02A9\u02A7\x03\x02\x02\x02\u02AA\u02AD\x03\x02\x02" + - "\x02\u02AB\u02A9\x03\x02\x02\x02\u02AB\u02AC\x03\x02\x02\x02\u02AC\x91" + - "\x03\x02\x02\x02\u02AD\u02AB\x03\x02\x02\x02\u02AE\u02B2\x05\x94K\x02" + - "\u02AF\u02B2\x05\x96L\x02\u02B0\u02B2\x05\x98M\x02\u02B1\u02AE\x03\x02" + - "\x02\x02\u02B1\u02AF\x03\x02\x02\x02\u02B1\u02B0\x03\x02\x02\x02\u02B2" + - "\x93\x03\x02\x02\x02\u02B3\u02B4\x05\x9AN\x02\u02B4\x95\x03\x02\x02\x02" + - "\u02B5\u02B6\x05\x9AN\x02\u02B6\u02B7\x07>\x02\x02\u02B7\u02B8\x05\x9A" + - "N\x02\u02B8\u02B9\x07@\x02\x02\u02B9\x97\x03\x02\x02\x02\u02BA\u02BB\x07" + - "\x1C\x02\x02\u02BB\u02BC\x07$\x02\x02\u02BC\u02BD\x05\x9AN\x02\u02BD\u02BE" + - "\x07%\x02\x02\u02BE\x99\x03\x02\x02\x02\u02BF\u02C0\t\x10\x02\x02\u02C0" + - "\x9B\x03\x02\x02\x02B\x9D\xA4\xAB\xB0\xB7\xB9\xBF\xC5\xD5\xDC\xEB\xF0" + - "\xFB\u0104\u010E\u011B\u0120\u0126\u012A\u0130\u0136\u014E\u015C\u0160" + - "\u0168\u0176\u017E\u0186\u018A\u018F\u0192\u0197\u019A\u01A4\u01A7\u01AA" + - "\u01B4\u01B7\u01BA\u01CA\u01CF\u01D4\u01E4\u01E6\u01EE\u01FC\u0202\u0208" + - "\u0210\u0221\u022B\u0236\u0242\u024F\u025A\u0265\u0270\u027B\u0286\u0291" + - "\u029B\u02A2\u02AB\u02B1"; - public static readonly _serializedATN: string = Utils.join( - [KipperParser._serializedATNSegment0, KipperParser._serializedATNSegment1], - "", - ); - - constructor(input: TokenStream) { - super(input); - this._interp = new ParserATNSimulator(KipperParser._ATN, this); - } - - public static __ATN: ATN; - - public static get _ATN(): ATN { - if (!KipperParser.__ATN) { - KipperParser.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(KipperParser._serializedATN)); - } - - return KipperParser.__ATN; - } - // @NotNull public get vocabulary(): Vocabulary { return KipperParser.VOCABULARY; } + // tslint:enable:no-trailing-whitespace + // @Override public get grammarFileName(): string { return "KipperParser.g4"; @@ -811,6 +473,15 @@ export class KipperParser extends KipperParserBase { return KipperParser._serializedATN; } + protected createFailedPredicateException(predicate?: string, message?: string): FailedPredicateException { + return new FailedPredicateException(this, predicate, message); + } + + constructor(input: TokenStream) { + super(input); + this._interp = new ParserATNSimulator(KipperParser._ATN, this); + } + // @RuleVersion(0) public compilationUnit(): CompilationUnitContext { let _localctx: CompilationUnitContext = new CompilationUnitContext(this._ctx, this.state); @@ -818,17 +489,17 @@ export class KipperParser extends KipperParserBase { try { this.enterOuterAlt(_localctx, 1); { - this.state = 155; + this.state = 159; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 0, this._ctx)) { case 1: { - this.state = 154; + this.state = 158; this.translationUnit(); } break; } - this.state = 157; + this.state = 161; this.match(KipperParser.EOF); } } catch (re) { @@ -853,7 +524,7 @@ export class KipperParser extends KipperParserBase { let _alt: number; this.enterOuterAlt(_localctx, 1); { - this.state = 160; + this.state = 164; this._errHandler.sync(this); _alt = 1; do { @@ -861,7 +532,7 @@ export class KipperParser extends KipperParserBase { case 1: { { - this.state = 159; + this.state = 163; this.externalItem(); } } @@ -869,7 +540,7 @@ export class KipperParser extends KipperParserBase { default: throw new NoViableAltException(this); } - this.state = 162; + this.state = 166; this._errHandler.sync(this); _alt = this.interpreter.adaptivePredict(this._input, 1, this._ctx); } while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER); @@ -896,7 +567,7 @@ export class KipperParser extends KipperParserBase { _localctx = new ExternalBlockItemContext(_localctx); this.enterOuterAlt(_localctx, 1); { - this.state = 164; + this.state = 168; this.blockItemList(); } } catch (re) { @@ -921,7 +592,7 @@ export class KipperParser extends KipperParserBase { let _alt: number; this.enterOuterAlt(_localctx, 1); { - this.state = 167; + this.state = 171; this._errHandler.sync(this); _alt = 1; do { @@ -929,7 +600,7 @@ export class KipperParser extends KipperParserBase { case 1: { { - this.state = 166; + this.state = 170; this.blockItem(); } } @@ -937,7 +608,7 @@ export class KipperParser extends KipperParserBase { default: throw new NoViableAltException(this); } - this.state = 169; + this.state = 173; this._errHandler.sync(this); _alt = this.interpreter.adaptivePredict(this._input, 2, this._ctx); } while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER); @@ -963,26 +634,26 @@ export class KipperParser extends KipperParserBase { try { this.enterOuterAlt(_localctx, 1); { - this.state = 174; + this.state = 178; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 3, this._ctx)) { case 1: { - this.state = 171; + this.state = 175; this.statement(); } break; case 2: { - this.state = 172; + this.state = 176; this.declaration(); } break; case 3: { - this.state = 173; + this.state = 177; this.match(KipperParser.SemiColon); } break; @@ -1007,34 +678,38 @@ export class KipperParser extends KipperParserBase { let _localctx: DeclarationContext = new DeclarationContext(this._ctx, this.state); this.enterRule(_localctx, 10, KipperParser.RULE_declaration); try { - this.state = 183; + this.state = 186; this._errHandler.sync(this); switch (this._input.LA(1)) { case KipperParser.Const: case KipperParser.Var: this.enterOuterAlt(_localctx, 1); { - this.state = 176; + this.state = 180; this.variableDeclaration(); - this.state = 177; + this.state = 181; this.match(KipperParser.SemiColon); } break; case KipperParser.DefFunc: this.enterOuterAlt(_localctx, 2); { - this.state = 179; + this.state = 183; this.functionDeclaration(); - this.state = 181; - this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 4, this._ctx)) { - case 1: - { - this.state = 180; - this.match(KipperParser.SemiColon); - } - break; - } + } + break; + case KipperParser.Interface: + this.enterOuterAlt(_localctx, 3); + { + this.state = 184; + this.interfaceDeclaration(); + } + break; + case KipperParser.Class: + this.enterOuterAlt(_localctx, 4); + { + this.state = 185; + this.classDeclaration(); } break; default: @@ -1055,44 +730,50 @@ export class KipperParser extends KipperParserBase { } // @RuleVersion(0) - public functionDeclaration(): FunctionDeclarationContext { - let _localctx: FunctionDeclarationContext = new FunctionDeclarationContext(this._ctx, this.state); - this.enterRule(_localctx, 12, KipperParser.RULE_functionDeclaration); - let _la: number; + public variableDeclaration(): VariableDeclarationContext { + let _localctx: VariableDeclarationContext = new VariableDeclarationContext(this._ctx, this.state); + this.enterRule(_localctx, 12, KipperParser.RULE_variableDeclaration); try { this.enterOuterAlt(_localctx, 1); { - this.state = 185; - this.match(KipperParser.DefFunc); - this.state = 186; - this.declarator(); - this.state = 187; - this.match(KipperParser.LeftParen); + this.state = 188; + this.storageTypeSpecifier(); this.state = 189; - this._errHandler.sync(this); + this.initDeclarator(); + } + } 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 storageTypeSpecifier(): StorageTypeSpecifierContext { + let _localctx: StorageTypeSpecifierContext = new StorageTypeSpecifierContext(this._ctx, this.state); + this.enterRule(_localctx, 14, KipperParser.RULE_storageTypeSpecifier); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 191; _la = this._input.LA(1); - if (_la === KipperParser.Identifier) { - { - this.state = 188; - this.parameterList(); + if (!(_la === KipperParser.Const || _la === KipperParser.Var)) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; } - } - this.state = 191; - this.match(KipperParser.RightParen); - this.state = 192; - this.match(KipperParser.RetIndicator); - this.state = 193; - this.typeSpecifierExpression(); - this.state = 195; - this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 7, this._ctx)) { - case 1: - { - this.state = 194; - this.compoundStatement(); - } - break; + this._errHandler.reportMatch(this); + this.consume(); } } } catch (re) { @@ -1110,16 +791,30 @@ export class KipperParser extends KipperParserBase { } // @RuleVersion(0) - public variableDeclaration(): VariableDeclarationContext { - let _localctx: VariableDeclarationContext = new VariableDeclarationContext(this._ctx, this.state); - this.enterRule(_localctx, 14, KipperParser.RULE_variableDeclaration); + public initDeclarator(): InitDeclaratorContext { + let _localctx: InitDeclaratorContext = new InitDeclaratorContext(this._ctx, this.state); + this.enterRule(_localctx, 16, KipperParser.RULE_initDeclarator); + let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 197; - this.storageTypeSpecifier(); + this.state = 193; + this.declarator(); + this.state = 194; + this.match(KipperParser.Colon); + this.state = 195; + this.typeSpecifierExpression(); this.state = 198; - this.initDeclarator(); + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === KipperParser.Assign) { + { + this.state = 196; + this.match(KipperParser.Assign); + this.state = 197; + this.initializer(); + } + } } } catch (re) { if (re instanceof RecognitionException) { @@ -1136,25 +831,14 @@ export class KipperParser extends KipperParserBase { } // @RuleVersion(0) - public storageTypeSpecifier(): StorageTypeSpecifierContext { - let _localctx: StorageTypeSpecifierContext = new StorageTypeSpecifierContext(this._ctx, this.state); - this.enterRule(_localctx, 16, KipperParser.RULE_storageTypeSpecifier); - let _la: number; + public initializer(): InitializerContext { + let _localctx: InitializerContext = new InitializerContext(this._ctx, this.state); + this.enterRule(_localctx, 18, KipperParser.RULE_initializer); try { this.enterOuterAlt(_localctx, 1); { this.state = 200; - _la = this._input.LA(1); - if (!(_la === KipperParser.Const || _la === KipperParser.Var)) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } + this.assignmentExpression(); } } catch (re) { if (re instanceof RecognitionException) { @@ -1173,7 +857,7 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public declarator(): DeclaratorContext { let _localctx: DeclaratorContext = new DeclaratorContext(this._ctx, this.state); - this.enterRule(_localctx, 18, KipperParser.RULE_declarator); + this.enterRule(_localctx, 20, KipperParser.RULE_declarator); try { this.enterOuterAlt(_localctx, 1); { @@ -1197,7 +881,7 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public directDeclarator(): DirectDeclaratorContext { let _localctx: DirectDeclaratorContext = new DirectDeclaratorContext(this._ctx, this.state); - this.enterRule(_localctx, 20, KipperParser.RULE_directDeclarator); + this.enterRule(_localctx, 22, KipperParser.RULE_directDeclarator); try { this.enterOuterAlt(_localctx, 1); { @@ -1219,30 +903,45 @@ export class KipperParser extends KipperParserBase { } // @RuleVersion(0) - public initDeclarator(): InitDeclaratorContext { - let _localctx: InitDeclaratorContext = new InitDeclaratorContext(this._ctx, this.state); - this.enterRule(_localctx, 22, KipperParser.RULE_initDeclarator); + public functionDeclaration(): FunctionDeclarationContext { + let _localctx: FunctionDeclarationContext = new FunctionDeclarationContext(this._ctx, this.state); + this.enterRule(_localctx, 24, KipperParser.RULE_functionDeclaration); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 206; - this.declarator(); + this.match(KipperParser.DefFunc); this.state = 207; - this.match(KipperParser.Colon); + this.declarator(); this.state = 208; - this.typeSpecifierExpression(); - this.state = 211; + this.match(KipperParser.LeftParen); + this.state = 210; this._errHandler.sync(this); _la = this._input.LA(1); - if (_la === KipperParser.Assign) { + if (_la === KipperParser.Identifier) { { this.state = 209; - this.match(KipperParser.Assign); - this.state = 210; - this.initializer(); + this.parameterList(); } } + + this.state = 212; + this.match(KipperParser.RightParen); + this.state = 213; + this.match(KipperParser.RetIndicator); + this.state = 214; + this.typeSpecifierExpression(); + this.state = 216; + this._errHandler.sync(this); + switch (this.interpreter.adaptivePredict(this._input, 7, this._ctx)) { + case 1: + { + this.state = 215; + this.compoundStatement(); + } + break; + } } } catch (re) { if (re instanceof RecognitionException) { @@ -1261,26 +960,26 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public parameterList(): ParameterListContext { let _localctx: ParameterListContext = new ParameterListContext(this._ctx, this.state); - this.enterRule(_localctx, 24, KipperParser.RULE_parameterList); + this.enterRule(_localctx, 26, KipperParser.RULE_parameterList); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 213; - this.parameterDeclaration(); this.state = 218; + this.parameterDeclaration(); + this.state = 223; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === KipperParser.Comma) { { { - this.state = 214; + this.state = 219; this.match(KipperParser.Comma); - this.state = 215; + this.state = 220; this.parameterDeclaration(); } } - this.state = 220; + this.state = 225; this._errHandler.sync(this); _la = this._input.LA(1); } @@ -1302,15 +1001,15 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public parameterDeclaration(): ParameterDeclarationContext { let _localctx: ParameterDeclarationContext = new ParameterDeclarationContext(this._ctx, this.state); - this.enterRule(_localctx, 26, KipperParser.RULE_parameterDeclaration); + this.enterRule(_localctx, 28, KipperParser.RULE_parameterDeclaration); try { this.enterOuterAlt(_localctx, 1); { - this.state = 221; + this.state = 226; this.declarator(); - this.state = 222; + this.state = 227; this.match(KipperParser.Colon); - this.state = 223; + this.state = 228; this.typeSpecifierExpression(); } } catch (re) { @@ -1328,14 +1027,50 @@ export class KipperParser extends KipperParserBase { } // @RuleVersion(0) - public initializer(): InitializerContext { - let _localctx: InitializerContext = new InitializerContext(this._ctx, this.state); - this.enterRule(_localctx, 28, KipperParser.RULE_initializer); + public interfaceDeclaration(): InterfaceDeclarationContext { + let _localctx: InterfaceDeclarationContext = new InterfaceDeclarationContext(this._ctx, this.state); + this.enterRule(_localctx, 30, KipperParser.RULE_interfaceDeclaration); try { this.enterOuterAlt(_localctx, 1); { - this.state = 225; - this.assignmentExpression(); + this.state = 230; + this.match(KipperParser.Interface); + this.state = 231; + this.match(KipperParser.Identifier); + this.state = 232; + this.match(KipperParser.LeftBrace); + this.state = 233; + this.match(KipperParser.RightBrace); + } + } 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 classDeclaration(): ClassDeclarationContext { + let _localctx: ClassDeclarationContext = new ClassDeclarationContext(this._ctx, this.state); + this.enterRule(_localctx, 32, KipperParser.RULE_classDeclaration); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 235; + this.match(KipperParser.Class); + this.state = 236; + this.match(KipperParser.Identifier); + this.state = 237; + this.match(KipperParser.LeftBrace); + this.state = 238; + this.match(KipperParser.RightBrace); } } catch (re) { if (re instanceof RecognitionException) { @@ -1354,15 +1089,15 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public statement(): StatementContext { let _localctx: StatementContext = new StatementContext(this._ctx, this.state); - this.enterRule(_localctx, 30, KipperParser.RULE_statement); + this.enterRule(_localctx, 34, KipperParser.RULE_statement); try { - this.state = 233; + this.state = 246; this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 10, this._ctx)) { + switch (this.interpreter.adaptivePredict(this._input, 9, this._ctx)) { case 1: this.enterOuterAlt(_localctx, 1); { - this.state = 227; + this.state = 240; this.expressionStatement(); } break; @@ -1370,7 +1105,7 @@ export class KipperParser extends KipperParserBase { case 2: this.enterOuterAlt(_localctx, 2); { - this.state = 228; + this.state = 241; this.selectionStatement(); } break; @@ -1378,7 +1113,7 @@ export class KipperParser extends KipperParserBase { case 3: this.enterOuterAlt(_localctx, 3); { - this.state = 229; + this.state = 242; this.iterationStatement(); } break; @@ -1386,7 +1121,7 @@ export class KipperParser extends KipperParserBase { case 4: this.enterOuterAlt(_localctx, 4); { - this.state = 230; + this.state = 243; this.jumpStatement(); } break; @@ -1394,7 +1129,7 @@ export class KipperParser extends KipperParserBase { case 5: this.enterOuterAlt(_localctx, 5); { - this.state = 231; + this.state = 244; this.returnStatement(); } break; @@ -1402,7 +1137,7 @@ export class KipperParser extends KipperParserBase { case 6: this.enterOuterAlt(_localctx, 6); { - this.state = 232; + this.state = 245; this.compoundStatement(); } break; @@ -1424,27 +1159,27 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public compoundStatement(): CompoundStatementContext { let _localctx: CompoundStatementContext = new CompoundStatementContext(this._ctx, this.state); - this.enterRule(_localctx, 32, KipperParser.RULE_compoundStatement); + this.enterRule(_localctx, 36, KipperParser.RULE_compoundStatement); try { this.enterOuterAlt(_localctx, 1); { - this.state = 235; + this.state = 248; if (!this.notInsideExpressionStatement()) { throw this.createFailedPredicateException("this.notInsideExpressionStatement()"); } - this.state = 236; + this.state = 249; this.match(KipperParser.LeftBrace); - this.state = 238; + this.state = 251; this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 11, this._ctx)) { + switch (this.interpreter.adaptivePredict(this._input, 10, this._ctx)) { case 1: { - this.state = 237; + this.state = 250; this.blockItemList(); } break; } - this.state = 240; + this.state = 253; this.match(KipperParser.RightBrace); } } catch (re) { @@ -1464,14 +1199,14 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public expressionStatement(): ExpressionStatementContext { let _localctx: ExpressionStatementContext = new ExpressionStatementContext(this._ctx, this.state); - this.enterRule(_localctx, 34, KipperParser.RULE_expressionStatement); + this.enterRule(_localctx, 38, KipperParser.RULE_expressionStatement); try { this.enterOuterAlt(_localctx, 1); { this.enterExpressionStatement(); - this.state = 243; + this.state = 256; this.expression(); - this.state = 244; + this.state = 257; this.match(KipperParser.SemiColon); this.exitExpressionStatement(); } @@ -1492,22 +1227,22 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public selectionStatement(): SelectionStatementContext { let _localctx: SelectionStatementContext = new SelectionStatementContext(this._ctx, this.state); - this.enterRule(_localctx, 36, KipperParser.RULE_selectionStatement); + this.enterRule(_localctx, 40, KipperParser.RULE_selectionStatement); try { - this.state = 249; + this.state = 262; this._errHandler.sync(this); switch (this._input.LA(1)) { case KipperParser.If: this.enterOuterAlt(_localctx, 1); { - this.state = 247; + this.state = 260; this.ifStatement(); } break; case KipperParser.Switch: this.enterOuterAlt(_localctx, 2); { - this.state = 248; + this.state = 261; this.switchStatement(); } break; @@ -1531,28 +1266,28 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public ifStatement(): IfStatementContext { let _localctx: IfStatementContext = new IfStatementContext(this._ctx, this.state); - this.enterRule(_localctx, 38, KipperParser.RULE_ifStatement); + this.enterRule(_localctx, 42, KipperParser.RULE_ifStatement); try { this.enterOuterAlt(_localctx, 1); { - this.state = 251; + this.state = 264; this.match(KipperParser.If); - this.state = 252; + this.state = 265; this.match(KipperParser.LeftParen); - this.state = 253; + this.state = 266; this.expression(); - this.state = 254; + this.state = 267; this.match(KipperParser.RightParen); - this.state = 255; + this.state = 268; this.statement(); - this.state = 258; + this.state = 271; this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 13, this._ctx)) { + switch (this.interpreter.adaptivePredict(this._input, 12, this._ctx)) { case 1: { - this.state = 256; + this.state = 269; this.match(KipperParser.Else); - this.state = 257; + this.state = 270; this.statement(); } break; @@ -1575,36 +1310,36 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public switchStatement(): SwitchStatementContext { let _localctx: SwitchStatementContext = new SwitchStatementContext(this._ctx, this.state); - this.enterRule(_localctx, 40, KipperParser.RULE_switchStatement); + this.enterRule(_localctx, 44, KipperParser.RULE_switchStatement); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 260; + this.state = 273; this.match(KipperParser.Switch); - this.state = 261; + this.state = 274; this.match(KipperParser.LeftParen); - this.state = 262; + this.state = 275; this.expression(); - this.state = 263; + this.state = 276; this.match(KipperParser.RightParen); - this.state = 264; + this.state = 277; this.match(KipperParser.LeftBrace); - this.state = 268; + this.state = 281; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === KipperParser.Case || _la === KipperParser.Default) { { { - this.state = 265; + this.state = 278; this.switchLabeledStatement(); } } - this.state = 270; + this.state = 283; this._errHandler.sync(this); _la = this._input.LA(1); } - this.state = 271; + this.state = 284; this.match(KipperParser.RightBrace); } } catch (re) { @@ -1624,32 +1359,32 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public switchLabeledStatement(): SwitchLabeledStatementContext { let _localctx: SwitchLabeledStatementContext = new SwitchLabeledStatementContext(this._ctx, this.state); - this.enterRule(_localctx, 42, KipperParser.RULE_switchLabeledStatement); + this.enterRule(_localctx, 46, KipperParser.RULE_switchLabeledStatement); try { - this.state = 281; + this.state = 294; this._errHandler.sync(this); switch (this._input.LA(1)) { case KipperParser.Case: this.enterOuterAlt(_localctx, 1); { - this.state = 273; + this.state = 286; this.match(KipperParser.Case); - this.state = 274; + this.state = 287; this.expression(); - this.state = 275; + this.state = 288; this.match(KipperParser.Colon); - this.state = 276; + this.state = 289; this.statement(); } break; case KipperParser.Default: this.enterOuterAlt(_localctx, 2); { - this.state = 278; + this.state = 291; this.match(KipperParser.Default); - this.state = 279; + this.state = 292; this.match(KipperParser.Colon); - this.state = 280; + this.state = 293; this.statement(); } break; @@ -1673,29 +1408,29 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public iterationStatement(): IterationStatementContext { let _localctx: IterationStatementContext = new IterationStatementContext(this._ctx, this.state); - this.enterRule(_localctx, 44, KipperParser.RULE_iterationStatement); + this.enterRule(_localctx, 48, KipperParser.RULE_iterationStatement); try { - this.state = 286; + this.state = 299; this._errHandler.sync(this); switch (this._input.LA(1)) { case KipperParser.For: this.enterOuterAlt(_localctx, 1); { - this.state = 283; + this.state = 296; this.forLoopIterationStatement(); } break; case KipperParser.While: this.enterOuterAlt(_localctx, 2); { - this.state = 284; + this.state = 297; this.whileLoopIterationStatement(); } break; case KipperParser.Do: this.enterOuterAlt(_localctx, 3); { - this.state = 285; + this.state = 298; this.doWhileLoopIterationStatement(); } break; @@ -1719,16 +1454,16 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public forLoopIterationStatement(): ForLoopIterationStatementContext { let _localctx: ForLoopIterationStatementContext = new ForLoopIterationStatementContext(this._ctx, this.state); - this.enterRule(_localctx, 46, KipperParser.RULE_forLoopIterationStatement); + this.enterRule(_localctx, 50, KipperParser.RULE_forLoopIterationStatement); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 288; + this.state = 301; this.match(KipperParser.For); - this.state = 289; + this.state = 302; this.match(KipperParser.LeftParen); - this.state = 296; + this.state = 309; this._errHandler.sync(this); _la = this._input.LA(1); if ( @@ -1743,37 +1478,37 @@ export class KipperParser extends KipperParserBase { (1 << KipperParser.Null) | (1 << KipperParser.Undefined))) !== 0) || - (((_la - 34) & ~0x1f) === 0 && - ((1 << (_la - 34)) & - ((1 << (KipperParser.LeftParen - 34)) | - (1 << (KipperParser.LeftBracket - 34)) | - (1 << (KipperParser.LeftBrace - 34)) | - (1 << (KipperParser.Plus - 34)) | - (1 << (KipperParser.PlusPlus - 34)) | - (1 << (KipperParser.Minus - 34)) | - (1 << (KipperParser.MinusMinus - 34)) | - (1 << (KipperParser.Not - 34)))) !== + (((_la - 36) & ~0x1f) === 0 && + ((1 << (_la - 36)) & + ((1 << (KipperParser.LeftParen - 36)) | + (1 << (KipperParser.LeftBracket - 36)) | + (1 << (KipperParser.LeftBrace - 36)) | + (1 << (KipperParser.Plus - 36)) | + (1 << (KipperParser.PlusPlus - 36)) | + (1 << (KipperParser.Minus - 36)) | + (1 << (KipperParser.MinusMinus - 36)) | + (1 << (KipperParser.Not - 36)))) !== 0) || - (((_la - 67) & ~0x1f) === 0 && - ((1 << (_la - 67)) & - ((1 << (KipperParser.BitwiseNot - 67)) | - (1 << (KipperParser.Identifier - 67)) | - (1 << (KipperParser.IntegerConstant - 67)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 67)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 67)) | - (1 << (KipperParser.FloatingConstant - 67)) | - (1 << (KipperParser.FStringSingleQuoteStart - 67)) | - (1 << (KipperParser.FStringDoubleQuoteStart - 67)))) !== + (((_la - 69) & ~0x1f) === 0 && + ((1 << (_la - 69)) & + ((1 << (KipperParser.BitwiseNot - 69)) | + (1 << (KipperParser.Identifier - 69)) | + (1 << (KipperParser.IntegerConstant - 69)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 69)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 69)) | + (1 << (KipperParser.FloatingConstant - 69)) | + (1 << (KipperParser.FStringSingleQuoteStart - 69)) | + (1 << (KipperParser.FStringDoubleQuoteStart - 69)))) !== 0) ) { { - this.state = 292; + this.state = 305; this._errHandler.sync(this); switch (this._input.LA(1)) { case KipperParser.Const: case KipperParser.Var: { - this.state = 290; + this.state = 303; this.variableDeclaration(); } break; @@ -1800,7 +1535,7 @@ export class KipperParser extends KipperParserBase { case KipperParser.FStringSingleQuoteStart: case KipperParser.FStringDoubleQuoteStart: { - this.state = 291; + this.state = 304; this.expression(); } break; @@ -1811,9 +1546,9 @@ export class KipperParser extends KipperParserBase { } } - this.state = 298; + this.state = 311; this.match(KipperParser.SemiColon); - this.state = 302; + this.state = 315; this._errHandler.sync(this); _la = this._input.LA(1); if ( @@ -1834,28 +1569,28 @@ export class KipperParser extends KipperParserBase { (1 << (KipperParser.MinusMinus - 22)) | (1 << (KipperParser.Not - 22)))) !== 0) || - (((_la - 67) & ~0x1f) === 0 && - ((1 << (_la - 67)) & - ((1 << (KipperParser.BitwiseNot - 67)) | - (1 << (KipperParser.Identifier - 67)) | - (1 << (KipperParser.IntegerConstant - 67)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 67)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 67)) | - (1 << (KipperParser.FloatingConstant - 67)) | - (1 << (KipperParser.FStringSingleQuoteStart - 67)) | - (1 << (KipperParser.FStringDoubleQuoteStart - 67)))) !== + (((_la - 69) & ~0x1f) === 0 && + ((1 << (_la - 69)) & + ((1 << (KipperParser.BitwiseNot - 69)) | + (1 << (KipperParser.Identifier - 69)) | + (1 << (KipperParser.IntegerConstant - 69)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 69)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 69)) | + (1 << (KipperParser.FloatingConstant - 69)) | + (1 << (KipperParser.FStringSingleQuoteStart - 69)) | + (1 << (KipperParser.FStringDoubleQuoteStart - 69)))) !== 0) ) { { - this.state = 299; + this.state = 312; this.expression(); _localctx._forCondition = true; } } - this.state = 304; + this.state = 317; this.match(KipperParser.SemiColon); - this.state = 308; + this.state = 321; this._errHandler.sync(this); _la = this._input.LA(1); if ( @@ -1876,28 +1611,28 @@ export class KipperParser extends KipperParserBase { (1 << (KipperParser.MinusMinus - 22)) | (1 << (KipperParser.Not - 22)))) !== 0) || - (((_la - 67) & ~0x1f) === 0 && - ((1 << (_la - 67)) & - ((1 << (KipperParser.BitwiseNot - 67)) | - (1 << (KipperParser.Identifier - 67)) | - (1 << (KipperParser.IntegerConstant - 67)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 67)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 67)) | - (1 << (KipperParser.FloatingConstant - 67)) | - (1 << (KipperParser.FStringSingleQuoteStart - 67)) | - (1 << (KipperParser.FStringDoubleQuoteStart - 67)))) !== + (((_la - 69) & ~0x1f) === 0 && + ((1 << (_la - 69)) & + ((1 << (KipperParser.BitwiseNot - 69)) | + (1 << (KipperParser.Identifier - 69)) | + (1 << (KipperParser.IntegerConstant - 69)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 69)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 69)) | + (1 << (KipperParser.FloatingConstant - 69)) | + (1 << (KipperParser.FStringSingleQuoteStart - 69)) | + (1 << (KipperParser.FStringDoubleQuoteStart - 69)))) !== 0) ) { { - this.state = 305; + this.state = 318; this.expression(); _localctx._forIterationExp = true; } } - this.state = 310; + this.state = 323; this.match(KipperParser.RightParen); - this.state = 311; + this.state = 324; this.statement(); } } catch (re) { @@ -1917,19 +1652,19 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public whileLoopIterationStatement(): WhileLoopIterationStatementContext { let _localctx: WhileLoopIterationStatementContext = new WhileLoopIterationStatementContext(this._ctx, this.state); - this.enterRule(_localctx, 48, KipperParser.RULE_whileLoopIterationStatement); + this.enterRule(_localctx, 52, KipperParser.RULE_whileLoopIterationStatement); try { this.enterOuterAlt(_localctx, 1); { - this.state = 313; + this.state = 326; this.match(KipperParser.While); - this.state = 314; + this.state = 327; this.match(KipperParser.LeftParen); - this.state = 315; + this.state = 328; this.expression(); - this.state = 316; + this.state = 329; this.match(KipperParser.RightParen); - this.state = 317; + this.state = 330; this.statement(); } } catch (re) { @@ -1952,23 +1687,23 @@ export class KipperParser extends KipperParserBase { this._ctx, this.state, ); - this.enterRule(_localctx, 50, KipperParser.RULE_doWhileLoopIterationStatement); + this.enterRule(_localctx, 54, KipperParser.RULE_doWhileLoopIterationStatement); try { this.enterOuterAlt(_localctx, 1); { - this.state = 319; + this.state = 332; this.match(KipperParser.Do); - this.state = 320; + this.state = 333; this.statement(); - this.state = 321; + this.state = 334; this.match(KipperParser.While); - this.state = 322; + this.state = 335; this.match(KipperParser.LeftParen); - this.state = 323; + this.state = 336; this.expression(); - this.state = 324; + this.state = 337; this.match(KipperParser.RightParen); - this.state = 325; + this.state = 338; this.match(KipperParser.SemiColon); } } catch (re) { @@ -1988,12 +1723,12 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public jumpStatement(): JumpStatementContext { let _localctx: JumpStatementContext = new JumpStatementContext(this._ctx, this.state); - this.enterRule(_localctx, 52, KipperParser.RULE_jumpStatement); + this.enterRule(_localctx, 56, KipperParser.RULE_jumpStatement); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 327; + this.state = 340; _la = this._input.LA(1); if (!(_la === KipperParser.Break || _la === KipperParser.Continue)) { this._errHandler.recoverInline(this); @@ -2005,7 +1740,7 @@ export class KipperParser extends KipperParserBase { this._errHandler.reportMatch(this); this.consume(); } - this.state = 328; + this.state = 341; this.match(KipperParser.SemiColon); } } catch (re) { @@ -2025,14 +1760,14 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public returnStatement(): ReturnStatementContext { let _localctx: ReturnStatementContext = new ReturnStatementContext(this._ctx, this.state); - this.enterRule(_localctx, 54, KipperParser.RULE_returnStatement); + this.enterRule(_localctx, 58, KipperParser.RULE_returnStatement); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 330; + this.state = 343; this.match(KipperParser.Return); - this.state = 332; + this.state = 345; this._errHandler.sync(this); _la = this._input.LA(1); if ( @@ -2053,25 +1788,25 @@ export class KipperParser extends KipperParserBase { (1 << (KipperParser.MinusMinus - 22)) | (1 << (KipperParser.Not - 22)))) !== 0) || - (((_la - 67) & ~0x1f) === 0 && - ((1 << (_la - 67)) & - ((1 << (KipperParser.BitwiseNot - 67)) | - (1 << (KipperParser.Identifier - 67)) | - (1 << (KipperParser.IntegerConstant - 67)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 67)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 67)) | - (1 << (KipperParser.FloatingConstant - 67)) | - (1 << (KipperParser.FStringSingleQuoteStart - 67)) | - (1 << (KipperParser.FStringDoubleQuoteStart - 67)))) !== + (((_la - 69) & ~0x1f) === 0 && + ((1 << (_la - 69)) & + ((1 << (KipperParser.BitwiseNot - 69)) | + (1 << (KipperParser.Identifier - 69)) | + (1 << (KipperParser.IntegerConstant - 69)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 69)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 69)) | + (1 << (KipperParser.FloatingConstant - 69)) | + (1 << (KipperParser.FStringSingleQuoteStart - 69)) | + (1 << (KipperParser.FStringDoubleQuoteStart - 69)))) !== 0) ) { { - this.state = 331; + this.state = 344; this.expression(); } } - this.state = 334; + this.state = 347; this.match(KipperParser.SemiColon); } } catch (re) { @@ -2091,15 +1826,15 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public primaryExpression(): PrimaryExpressionContext { let _localctx: PrimaryExpressionContext = new PrimaryExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 56, KipperParser.RULE_primaryExpression); + this.enterRule(_localctx, 60, KipperParser.RULE_primaryExpression); try { - this.state = 346; + this.state = 359; this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 22, this._ctx)) { + switch (this.interpreter.adaptivePredict(this._input, 21, this._ctx)) { case 1: this.enterOuterAlt(_localctx, 1); { - this.state = 336; + this.state = 349; this.tangledPrimaryExpression(); } break; @@ -2107,7 +1842,7 @@ export class KipperParser extends KipperParserBase { case 2: this.enterOuterAlt(_localctx, 2); { - this.state = 337; + this.state = 350; this.arrayPrimaryExpression(); } break; @@ -2115,7 +1850,7 @@ export class KipperParser extends KipperParserBase { case 3: this.enterOuterAlt(_localctx, 3); { - this.state = 338; + this.state = 351; this.objectPrimaryExpression(); } break; @@ -2123,7 +1858,7 @@ export class KipperParser extends KipperParserBase { case 4: this.enterOuterAlt(_localctx, 4); { - this.state = 339; + this.state = 352; this.boolPrimaryExpression(); } break; @@ -2131,7 +1866,7 @@ export class KipperParser extends KipperParserBase { case 5: this.enterOuterAlt(_localctx, 5); { - this.state = 340; + this.state = 353; this.identifierPrimaryExpression(); } break; @@ -2139,7 +1874,7 @@ export class KipperParser extends KipperParserBase { case 6: this.enterOuterAlt(_localctx, 6); { - this.state = 341; + this.state = 354; this.stringPrimaryExpression(); } break; @@ -2147,7 +1882,7 @@ export class KipperParser extends KipperParserBase { case 7: this.enterOuterAlt(_localctx, 7); { - this.state = 342; + this.state = 355; this.fStringPrimaryExpression(); } break; @@ -2155,7 +1890,7 @@ export class KipperParser extends KipperParserBase { case 8: this.enterOuterAlt(_localctx, 8); { - this.state = 343; + this.state = 356; this.numberPrimaryExpression(); } break; @@ -2163,7 +1898,7 @@ export class KipperParser extends KipperParserBase { case 9: this.enterOuterAlt(_localctx, 9); { - this.state = 344; + this.state = 357; this.voidOrNullOrUndefinedPrimaryExpression(); } break; @@ -2171,7 +1906,7 @@ export class KipperParser extends KipperParserBase { case 10: this.enterOuterAlt(_localctx, 10); { - this.state = 345; + this.state = 358; this.lambdaExpression(); } break; @@ -2193,44 +1928,44 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public lambdaExpression(): LambdaExpressionContext { let _localctx: LambdaExpressionContext = new LambdaExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 58, KipperParser.RULE_lambdaExpression); + this.enterRule(_localctx, 62, KipperParser.RULE_lambdaExpression); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 348; + this.state = 361; this.match(KipperParser.LeftParen); - this.state = 350; + this.state = 363; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === KipperParser.Identifier) { { - this.state = 349; + this.state = 362; this.parameterList(); } } - this.state = 352; + this.state = 365; this.match(KipperParser.RightParen); - this.state = 353; + this.state = 366; this.match(KipperParser.Colon); - this.state = 354; + this.state = 367; this.typeSpecifierExpression(); - this.state = 355; + this.state = 368; this.match(KipperParser.RetIndicator); - this.state = 358; + this.state = 371; this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 24, this._ctx)) { + switch (this.interpreter.adaptivePredict(this._input, 23, this._ctx)) { case 1: { - this.state = 356; + this.state = 369; this.expression(); } break; case 2: { - this.state = 357; + this.state = 370; this.compoundStatement(); } break; @@ -2253,15 +1988,15 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public tangledPrimaryExpression(): TangledPrimaryExpressionContext { let _localctx: TangledPrimaryExpressionContext = new TangledPrimaryExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 60, KipperParser.RULE_tangledPrimaryExpression); + this.enterRule(_localctx, 64, KipperParser.RULE_tangledPrimaryExpression); try { this.enterOuterAlt(_localctx, 1); { - this.state = 360; + this.state = 373; this.match(KipperParser.LeftParen); - this.state = 361; + this.state = 374; this.expression(); - this.state = 362; + this.state = 375; this.match(KipperParser.RightParen); } } catch (re) { @@ -2281,12 +2016,12 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public boolPrimaryExpression(): BoolPrimaryExpressionContext { let _localctx: BoolPrimaryExpressionContext = new BoolPrimaryExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 62, KipperParser.RULE_boolPrimaryExpression); + this.enterRule(_localctx, 66, KipperParser.RULE_boolPrimaryExpression); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 364; + this.state = 377; _la = this._input.LA(1); if (!(_la === KipperParser.True || _la === KipperParser.False)) { this._errHandler.recoverInline(this); @@ -2316,11 +2051,11 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public identifierPrimaryExpression(): IdentifierPrimaryExpressionContext { let _localctx: IdentifierPrimaryExpressionContext = new IdentifierPrimaryExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 64, KipperParser.RULE_identifierPrimaryExpression); + this.enterRule(_localctx, 68, KipperParser.RULE_identifierPrimaryExpression); try { this.enterOuterAlt(_localctx, 1); { - this.state = 366; + this.state = 379; this.identifier(); } } catch (re) { @@ -2340,11 +2075,11 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public identifier(): IdentifierContext { let _localctx: IdentifierContext = new IdentifierContext(this._ctx, this.state); - this.enterRule(_localctx, 66, KipperParser.RULE_identifier); + this.enterRule(_localctx, 70, KipperParser.RULE_identifier); try { this.enterOuterAlt(_localctx, 1); { - this.state = 368; + this.state = 381; this.match(KipperParser.Identifier); } } catch (re) { @@ -2367,15 +2102,15 @@ export class KipperParser extends KipperParserBase { this._ctx, this.state, ); - this.enterRule(_localctx, 68, KipperParser.RULE_identifierOrStringPrimaryExpression); + this.enterRule(_localctx, 72, KipperParser.RULE_identifierOrStringPrimaryExpression); try { - this.state = 372; + this.state = 385; this._errHandler.sync(this); switch (this._input.LA(1)) { case KipperParser.Identifier: this.enterOuterAlt(_localctx, 1); { - this.state = 370; + this.state = 383; this.identifier(); } break; @@ -2383,7 +2118,7 @@ export class KipperParser extends KipperParserBase { case KipperParser.DoubleQuoteStringLiteral: this.enterOuterAlt(_localctx, 2); { - this.state = 371; + this.state = 384; this.stringPrimaryExpression(); } break; @@ -2407,12 +2142,12 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public stringPrimaryExpression(): StringPrimaryExpressionContext { let _localctx: StringPrimaryExpressionContext = new StringPrimaryExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 70, KipperParser.RULE_stringPrimaryExpression); + this.enterRule(_localctx, 74, KipperParser.RULE_stringPrimaryExpression); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 374; + this.state = 387; _la = this._input.LA(1); if (!(_la === KipperParser.SingleQuoteStringLiteral || _la === KipperParser.DoubleQuoteStringLiteral)) { this._errHandler.recoverInline(this); @@ -2442,55 +2177,55 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public fStringPrimaryExpression(): FStringPrimaryExpressionContext { let _localctx: FStringPrimaryExpressionContext = new FStringPrimaryExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 72, KipperParser.RULE_fStringPrimaryExpression); + this.enterRule(_localctx, 76, KipperParser.RULE_fStringPrimaryExpression); let _la: number; try { - this.state = 392; + this.state = 405; this._errHandler.sync(this); switch (this._input.LA(1)) { case KipperParser.FStringSingleQuoteStart: this.enterOuterAlt(_localctx, 1); { - this.state = 376; + this.state = 389; this.match(KipperParser.FStringSingleQuoteStart); - this.state = 380; + this.state = 393; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === KipperParser.FStringExpStart || _la === KipperParser.FStringSingleQuoteAtom) { { { - this.state = 377; + this.state = 390; this.fStringSingleQuoteAtom(); } } - this.state = 382; + this.state = 395; this._errHandler.sync(this); _la = this._input.LA(1); } - this.state = 383; + this.state = 396; this.match(KipperParser.FStringSingleQuoteEnd); } break; case KipperParser.FStringDoubleQuoteStart: this.enterOuterAlt(_localctx, 2); { - this.state = 384; + this.state = 397; this.match(KipperParser.FStringDoubleQuoteStart); - this.state = 388; + this.state = 401; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === KipperParser.FStringExpStart || _la === KipperParser.FStringDoubleQuoteAtom) { { { - this.state = 385; + this.state = 398; this.fStringDoubleQuoteAtom(); } } - this.state = 390; + this.state = 403; this._errHandler.sync(this); _la = this._input.LA(1); } - this.state = 391; + this.state = 404; this.match(KipperParser.FStringDoubleQuoteEnd); } break; @@ -2514,25 +2249,25 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public fStringSingleQuoteAtom(): FStringSingleQuoteAtomContext { let _localctx: FStringSingleQuoteAtomContext = new FStringSingleQuoteAtomContext(this._ctx, this.state); - this.enterRule(_localctx, 74, KipperParser.RULE_fStringSingleQuoteAtom); + this.enterRule(_localctx, 78, KipperParser.RULE_fStringSingleQuoteAtom); let _la: number; try { - this.state = 400; + this.state = 413; this._errHandler.sync(this); switch (this._input.LA(1)) { case KipperParser.FStringSingleQuoteAtom: this.enterOuterAlt(_localctx, 1); { - this.state = 394; + this.state = 407; this.match(KipperParser.FStringSingleQuoteAtom); } break; case KipperParser.FStringExpStart: this.enterOuterAlt(_localctx, 2); { - this.state = 395; + this.state = 408; this.match(KipperParser.FStringExpStart); - this.state = 397; + this.state = 410; this._errHandler.sync(this); _la = this._input.LA(1); if ( @@ -2553,25 +2288,25 @@ export class KipperParser extends KipperParserBase { (1 << (KipperParser.MinusMinus - 22)) | (1 << (KipperParser.Not - 22)))) !== 0) || - (((_la - 67) & ~0x1f) === 0 && - ((1 << (_la - 67)) & - ((1 << (KipperParser.BitwiseNot - 67)) | - (1 << (KipperParser.Identifier - 67)) | - (1 << (KipperParser.IntegerConstant - 67)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 67)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 67)) | - (1 << (KipperParser.FloatingConstant - 67)) | - (1 << (KipperParser.FStringSingleQuoteStart - 67)) | - (1 << (KipperParser.FStringDoubleQuoteStart - 67)))) !== + (((_la - 69) & ~0x1f) === 0 && + ((1 << (_la - 69)) & + ((1 << (KipperParser.BitwiseNot - 69)) | + (1 << (KipperParser.Identifier - 69)) | + (1 << (KipperParser.IntegerConstant - 69)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 69)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 69)) | + (1 << (KipperParser.FloatingConstant - 69)) | + (1 << (KipperParser.FStringSingleQuoteStart - 69)) | + (1 << (KipperParser.FStringDoubleQuoteStart - 69)))) !== 0) ) { { - this.state = 396; + this.state = 409; this.expression(); } } - this.state = 399; + this.state = 412; this.match(KipperParser.FStringExpEnd); } break; @@ -2595,25 +2330,25 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public fStringDoubleQuoteAtom(): FStringDoubleQuoteAtomContext { let _localctx: FStringDoubleQuoteAtomContext = new FStringDoubleQuoteAtomContext(this._ctx, this.state); - this.enterRule(_localctx, 76, KipperParser.RULE_fStringDoubleQuoteAtom); + this.enterRule(_localctx, 80, KipperParser.RULE_fStringDoubleQuoteAtom); let _la: number; try { - this.state = 408; + this.state = 421; this._errHandler.sync(this); switch (this._input.LA(1)) { case KipperParser.FStringDoubleQuoteAtom: this.enterOuterAlt(_localctx, 1); { - this.state = 402; + this.state = 415; this.match(KipperParser.FStringDoubleQuoteAtom); } break; case KipperParser.FStringExpStart: this.enterOuterAlt(_localctx, 2); { - this.state = 403; + this.state = 416; this.match(KipperParser.FStringExpStart); - this.state = 405; + this.state = 418; this._errHandler.sync(this); _la = this._input.LA(1); if ( @@ -2634,25 +2369,25 @@ export class KipperParser extends KipperParserBase { (1 << (KipperParser.MinusMinus - 22)) | (1 << (KipperParser.Not - 22)))) !== 0) || - (((_la - 67) & ~0x1f) === 0 && - ((1 << (_la - 67)) & - ((1 << (KipperParser.BitwiseNot - 67)) | - (1 << (KipperParser.Identifier - 67)) | - (1 << (KipperParser.IntegerConstant - 67)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 67)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 67)) | - (1 << (KipperParser.FloatingConstant - 67)) | - (1 << (KipperParser.FStringSingleQuoteStart - 67)) | - (1 << (KipperParser.FStringDoubleQuoteStart - 67)))) !== + (((_la - 69) & ~0x1f) === 0 && + ((1 << (_la - 69)) & + ((1 << (KipperParser.BitwiseNot - 69)) | + (1 << (KipperParser.Identifier - 69)) | + (1 << (KipperParser.IntegerConstant - 69)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 69)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 69)) | + (1 << (KipperParser.FloatingConstant - 69)) | + (1 << (KipperParser.FStringSingleQuoteStart - 69)) | + (1 << (KipperParser.FStringDoubleQuoteStart - 69)))) !== 0) ) { { - this.state = 404; + this.state = 417; this.expression(); } } - this.state = 407; + this.state = 420; this.match(KipperParser.FStringExpEnd); } break; @@ -2676,12 +2411,12 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public numberPrimaryExpression(): NumberPrimaryExpressionContext { let _localctx: NumberPrimaryExpressionContext = new NumberPrimaryExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 78, KipperParser.RULE_numberPrimaryExpression); + this.enterRule(_localctx, 82, KipperParser.RULE_numberPrimaryExpression); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 410; + this.state = 423; _la = this._input.LA(1); if (!(_la === KipperParser.IntegerConstant || _la === KipperParser.FloatingConstant)) { this._errHandler.recoverInline(this); @@ -2711,15 +2446,15 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public arrayPrimaryExpression(): ArrayPrimaryExpressionContext { let _localctx: ArrayPrimaryExpressionContext = new ArrayPrimaryExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 80, KipperParser.RULE_arrayPrimaryExpression); + this.enterRule(_localctx, 84, KipperParser.RULE_arrayPrimaryExpression); let _la: number; try { let _alt: number; this.enterOuterAlt(_localctx, 1); { - this.state = 412; + this.state = 425; this.match(KipperParser.LeftBracket); - this.state = 421; + this.state = 434; this._errHandler.sync(this); _la = this._input.LA(1); if ( @@ -2740,53 +2475,53 @@ export class KipperParser extends KipperParserBase { (1 << (KipperParser.MinusMinus - 22)) | (1 << (KipperParser.Not - 22)))) !== 0) || - (((_la - 67) & ~0x1f) === 0 && - ((1 << (_la - 67)) & - ((1 << (KipperParser.BitwiseNot - 67)) | - (1 << (KipperParser.Identifier - 67)) | - (1 << (KipperParser.IntegerConstant - 67)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 67)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 67)) | - (1 << (KipperParser.FloatingConstant - 67)) | - (1 << (KipperParser.FStringSingleQuoteStart - 67)) | - (1 << (KipperParser.FStringDoubleQuoteStart - 67)))) !== + (((_la - 69) & ~0x1f) === 0 && + ((1 << (_la - 69)) & + ((1 << (KipperParser.BitwiseNot - 69)) | + (1 << (KipperParser.Identifier - 69)) | + (1 << (KipperParser.IntegerConstant - 69)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 69)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 69)) | + (1 << (KipperParser.FloatingConstant - 69)) | + (1 << (KipperParser.FStringSingleQuoteStart - 69)) | + (1 << (KipperParser.FStringDoubleQuoteStart - 69)))) !== 0) ) { { - this.state = 413; + this.state = 426; this.expression(); - this.state = 418; + this.state = 431; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 33, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 32, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { { { - this.state = 414; + this.state = 427; this.match(KipperParser.Comma); - this.state = 415; + this.state = 428; this.expression(); } } } - this.state = 420; + this.state = 433; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 33, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 32, this._ctx); } } } - this.state = 424; + this.state = 437; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === KipperParser.Comma) { { - this.state = 423; + this.state = 436; this.match(KipperParser.Comma); } } - this.state = 426; + this.state = 439; this.match(KipperParser.RightBracket); } } catch (re) { @@ -2806,60 +2541,60 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public objectPrimaryExpression(): ObjectPrimaryExpressionContext { let _localctx: ObjectPrimaryExpressionContext = new ObjectPrimaryExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 82, KipperParser.RULE_objectPrimaryExpression); + this.enterRule(_localctx, 86, KipperParser.RULE_objectPrimaryExpression); let _la: number; try { let _alt: number; this.enterOuterAlt(_localctx, 1); { - this.state = 428; + this.state = 441; this.match(KipperParser.LeftBrace); - this.state = 437; + this.state = 450; this._errHandler.sync(this); _la = this._input.LA(1); if ( - ((_la - 72) & ~0x1f) === 0 && - ((1 << (_la - 72)) & - ((1 << (KipperParser.Identifier - 72)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 72)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 72)))) !== + ((_la - 74) & ~0x1f) === 0 && + ((1 << (_la - 74)) & + ((1 << (KipperParser.Identifier - 74)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 74)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 74)))) !== 0 ) { { - this.state = 429; + this.state = 442; this.objectProperty(); - this.state = 434; + this.state = 447; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 36, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 35, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { { { - this.state = 430; + this.state = 443; this.match(KipperParser.Comma); - this.state = 431; + this.state = 444; this.objectProperty(); } } } - this.state = 436; + this.state = 449; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 36, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 35, this._ctx); } } } - this.state = 440; + this.state = 453; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === KipperParser.Comma) { { - this.state = 439; + this.state = 452; this.match(KipperParser.Comma); } } - this.state = 442; + this.state = 455; this.match(KipperParser.RightBrace); } } catch (re) { @@ -2879,15 +2614,15 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public objectProperty(): ObjectPropertyContext { let _localctx: ObjectPropertyContext = new ObjectPropertyContext(this._ctx, this.state); - this.enterRule(_localctx, 84, KipperParser.RULE_objectProperty); + this.enterRule(_localctx, 88, KipperParser.RULE_objectProperty); try { this.enterOuterAlt(_localctx, 1); { - this.state = 444; + this.state = 457; this.identifierOrStringPrimaryExpression(); - this.state = 445; + this.state = 458; this.match(KipperParser.Colon); - this.state = 446; + this.state = 459; this.expression(); } } catch (re) { @@ -2910,12 +2645,12 @@ export class KipperParser extends KipperParserBase { this._ctx, this.state, ); - this.enterRule(_localctx, 86, KipperParser.RULE_voidOrNullOrUndefinedPrimaryExpression); + this.enterRule(_localctx, 90, KipperParser.RULE_voidOrNullOrUndefinedPrimaryExpression); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 448; + this.state = 461; _la = this._input.LA(1); if ( !( @@ -2948,9 +2683,7 @@ export class KipperParser extends KipperParserBase { } public computedPrimaryExpression(): ComputedPrimaryExpressionContext; - public computedPrimaryExpression(_p: number): ComputedPrimaryExpressionContext; - // @RuleVersion(0) public computedPrimaryExpression(_p?: number): ComputedPrimaryExpressionContext { if (_p === undefined) { @@ -2961,14 +2694,14 @@ export class KipperParser extends KipperParserBase { let _parentState: number = this.state; let _localctx: ComputedPrimaryExpressionContext = new ComputedPrimaryExpressionContext(this._ctx, _parentState); let _prevctx: ComputedPrimaryExpressionContext = _localctx; - let _startState: number = 88; - this.enterRecursionRule(_localctx, 88, KipperParser.RULE_computedPrimaryExpression, _p); + let _startState: number = 92; + this.enterRecursionRule(_localctx, 92, KipperParser.RULE_computedPrimaryExpression, _p); let _la: number; try { let _alt: number; this.enterOuterAlt(_localctx, 1); { - this.state = 461; + this.state = 474; this._errHandler.sync(this); switch (this._input.LA(1)) { case KipperParser.True: @@ -2991,7 +2724,7 @@ export class KipperParser extends KipperParserBase { this._ctx = _localctx; _prevctx = _localctx; - this.state = 451; + this.state = 464; this.primaryExpression(); } break; @@ -3000,13 +2733,13 @@ export class KipperParser extends KipperParserBase { _localctx = new ExplicitCallFunctionCallExpressionContext(_localctx); this._ctx = _localctx; _prevctx = _localctx; - this.state = 452; + this.state = 465; this.match(KipperParser.CallFunc); - this.state = 453; + this.state = 466; this.computedPrimaryExpression(0); - this.state = 454; + this.state = 467; this.match(KipperParser.LeftParen); - this.state = 456; + this.state = 469; this._errHandler.sync(this); _la = this._input.LA(1); if ( @@ -3027,25 +2760,25 @@ export class KipperParser extends KipperParserBase { (1 << (KipperParser.MinusMinus - 22)) | (1 << (KipperParser.Not - 22)))) !== 0) || - (((_la - 67) & ~0x1f) === 0 && - ((1 << (_la - 67)) & - ((1 << (KipperParser.BitwiseNot - 67)) | - (1 << (KipperParser.Identifier - 67)) | - (1 << (KipperParser.IntegerConstant - 67)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 67)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 67)) | - (1 << (KipperParser.FloatingConstant - 67)) | - (1 << (KipperParser.FStringSingleQuoteStart - 67)) | - (1 << (KipperParser.FStringDoubleQuoteStart - 67)))) !== + (((_la - 69) & ~0x1f) === 0 && + ((1 << (_la - 69)) & + ((1 << (KipperParser.BitwiseNot - 69)) | + (1 << (KipperParser.Identifier - 69)) | + (1 << (KipperParser.IntegerConstant - 69)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 69)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 69)) | + (1 << (KipperParser.FloatingConstant - 69)) | + (1 << (KipperParser.FStringSingleQuoteStart - 69)) | + (1 << (KipperParser.FStringDoubleQuoteStart - 69)))) !== 0) ) { { - this.state = 455; + this.state = 468; this.argumentExpressionList(); } } - this.state = 458; + this.state = 471; this.match(KipperParser.RightParen); _localctx._labelASTKind = ParseRuleKindMapping.RULE_functionCallExpression; } @@ -3054,9 +2787,9 @@ export class KipperParser extends KipperParserBase { throw new NoViableAltException(this); } this._ctx._stop = this._input.tryLT(-1); - this.state = 484; + this.state = 497; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 43, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 42, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { @@ -3064,22 +2797,22 @@ export class KipperParser extends KipperParserBase { } _prevctx = _localctx; { - this.state = 482; + this.state = 495; this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 42, this._ctx)) { + switch (this.interpreter.adaptivePredict(this._input, 41, this._ctx)) { case 1: { _localctx = new FunctionCallExpressionContext( new ComputedPrimaryExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_computedPrimaryExpression); - this.state = 463; + this.state = 476; if (!this.precpred(this._ctx, 5)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 5)"); } - this.state = 464; + this.state = 477; this.match(KipperParser.LeftParen); - this.state = 466; + this.state = 479; this._errHandler.sync(this); _la = this._input.LA(1); if ( @@ -3100,25 +2833,25 @@ export class KipperParser extends KipperParserBase { (1 << (KipperParser.MinusMinus - 22)) | (1 << (KipperParser.Not - 22)))) !== 0) || - (((_la - 67) & ~0x1f) === 0 && - ((1 << (_la - 67)) & - ((1 << (KipperParser.BitwiseNot - 67)) | - (1 << (KipperParser.Identifier - 67)) | - (1 << (KipperParser.IntegerConstant - 67)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 67)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 67)) | - (1 << (KipperParser.FloatingConstant - 67)) | - (1 << (KipperParser.FStringSingleQuoteStart - 67)) | - (1 << (KipperParser.FStringDoubleQuoteStart - 67)))) !== + (((_la - 69) & ~0x1f) === 0 && + ((1 << (_la - 69)) & + ((1 << (KipperParser.BitwiseNot - 69)) | + (1 << (KipperParser.Identifier - 69)) | + (1 << (KipperParser.IntegerConstant - 69)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 69)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 69)) | + (1 << (KipperParser.FloatingConstant - 69)) | + (1 << (KipperParser.FStringSingleQuoteStart - 69)) | + (1 << (KipperParser.FStringDoubleQuoteStart - 69)))) !== 0) ) { { - this.state = 465; + this.state = 478; this.argumentExpressionList(); } } - this.state = 468; + this.state = 481; this.match(KipperParser.RightParen); _localctx._labelASTKind = ParseRuleKindMapping.RULE_functionCallExpression; } @@ -3130,11 +2863,11 @@ export class KipperParser extends KipperParserBase { new ComputedPrimaryExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_computedPrimaryExpression); - this.state = 470; + this.state = 483; if (!this.precpred(this._ctx, 3)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 3)"); } - this.state = 471; + this.state = 484; this.dotNotation(); _localctx._labelASTKind = ParseRuleKindMapping.RULE_memberAccessExpression; } @@ -3146,11 +2879,11 @@ export class KipperParser extends KipperParserBase { new ComputedPrimaryExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_computedPrimaryExpression); - this.state = 474; + this.state = 487; if (!this.precpred(this._ctx, 2)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 2)"); } - this.state = 475; + this.state = 488; this.bracketNotation(); _localctx._labelASTKind = ParseRuleKindMapping.RULE_memberAccessExpression; } @@ -3162,11 +2895,11 @@ export class KipperParser extends KipperParserBase { new ComputedPrimaryExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_computedPrimaryExpression); - this.state = 478; + this.state = 491; if (!this.precpred(this._ctx, 1)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 1)"); } - this.state = 479; + this.state = 492; this.sliceNotation(); _localctx._labelASTKind = ParseRuleKindMapping.RULE_memberAccessExpression; } @@ -3174,9 +2907,9 @@ export class KipperParser extends KipperParserBase { } } } - this.state = 486; + this.state = 499; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 43, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 42, this._ctx); } } } catch (re) { @@ -3196,26 +2929,26 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public argumentExpressionList(): ArgumentExpressionListContext { let _localctx: ArgumentExpressionListContext = new ArgumentExpressionListContext(this._ctx, this.state); - this.enterRule(_localctx, 90, KipperParser.RULE_argumentExpressionList); + this.enterRule(_localctx, 94, KipperParser.RULE_argumentExpressionList); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 487; + this.state = 500; this.assignmentExpression(); - this.state = 492; + this.state = 505; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === KipperParser.Comma) { { { - this.state = 488; + this.state = 501; this.match(KipperParser.Comma); - this.state = 489; + this.state = 502; this.assignmentExpression(); } } - this.state = 494; + this.state = 507; this._errHandler.sync(this); _la = this._input.LA(1); } @@ -3237,13 +2970,13 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public dotNotation(): DotNotationContext { let _localctx: DotNotationContext = new DotNotationContext(this._ctx, this.state); - this.enterRule(_localctx, 92, KipperParser.RULE_dotNotation); + this.enterRule(_localctx, 96, KipperParser.RULE_dotNotation); try { this.enterOuterAlt(_localctx, 1); { - this.state = 495; + this.state = 508; this.match(KipperParser.Dot); - this.state = 496; + this.state = 509; this.identifier(); } } catch (re) { @@ -3263,15 +2996,15 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public bracketNotation(): BracketNotationContext { let _localctx: BracketNotationContext = new BracketNotationContext(this._ctx, this.state); - this.enterRule(_localctx, 94, KipperParser.RULE_bracketNotation); + this.enterRule(_localctx, 98, KipperParser.RULE_bracketNotation); try { this.enterOuterAlt(_localctx, 1); { - this.state = 498; + this.state = 511; this.match(KipperParser.LeftBracket); - this.state = 499; + this.state = 512; this.expression(); - this.state = 500; + this.state = 513; this.match(KipperParser.RightBracket); } } catch (re) { @@ -3291,14 +3024,14 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public sliceNotation(): SliceNotationContext { let _localctx: SliceNotationContext = new SliceNotationContext(this._ctx, this.state); - this.enterRule(_localctx, 96, KipperParser.RULE_sliceNotation); + this.enterRule(_localctx, 100, KipperParser.RULE_sliceNotation); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 502; + this.state = 515; this.match(KipperParser.LeftBracket); - this.state = 506; + this.state = 519; this._errHandler.sync(this); _la = this._input.LA(1); if ( @@ -3319,28 +3052,28 @@ export class KipperParser extends KipperParserBase { (1 << (KipperParser.MinusMinus - 22)) | (1 << (KipperParser.Not - 22)))) !== 0) || - (((_la - 67) & ~0x1f) === 0 && - ((1 << (_la - 67)) & - ((1 << (KipperParser.BitwiseNot - 67)) | - (1 << (KipperParser.Identifier - 67)) | - (1 << (KipperParser.IntegerConstant - 67)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 67)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 67)) | - (1 << (KipperParser.FloatingConstant - 67)) | - (1 << (KipperParser.FStringSingleQuoteStart - 67)) | - (1 << (KipperParser.FStringDoubleQuoteStart - 67)))) !== + (((_la - 69) & ~0x1f) === 0 && + ((1 << (_la - 69)) & + ((1 << (KipperParser.BitwiseNot - 69)) | + (1 << (KipperParser.Identifier - 69)) | + (1 << (KipperParser.IntegerConstant - 69)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 69)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 69)) | + (1 << (KipperParser.FloatingConstant - 69)) | + (1 << (KipperParser.FStringSingleQuoteStart - 69)) | + (1 << (KipperParser.FStringDoubleQuoteStart - 69)))) !== 0) ) { { - this.state = 503; + this.state = 516; this.expression(); _localctx.sliceStart = true; } } - this.state = 508; + this.state = 521; this.match(KipperParser.Colon); - this.state = 512; + this.state = 525; this._errHandler.sync(this); _la = this._input.LA(1); if ( @@ -3361,26 +3094,26 @@ export class KipperParser extends KipperParserBase { (1 << (KipperParser.MinusMinus - 22)) | (1 << (KipperParser.Not - 22)))) !== 0) || - (((_la - 67) & ~0x1f) === 0 && - ((1 << (_la - 67)) & - ((1 << (KipperParser.BitwiseNot - 67)) | - (1 << (KipperParser.Identifier - 67)) | - (1 << (KipperParser.IntegerConstant - 67)) | - (1 << (KipperParser.SingleQuoteStringLiteral - 67)) | - (1 << (KipperParser.DoubleQuoteStringLiteral - 67)) | - (1 << (KipperParser.FloatingConstant - 67)) | - (1 << (KipperParser.FStringSingleQuoteStart - 67)) | - (1 << (KipperParser.FStringDoubleQuoteStart - 67)))) !== + (((_la - 69) & ~0x1f) === 0 && + ((1 << (_la - 69)) & + ((1 << (KipperParser.BitwiseNot - 69)) | + (1 << (KipperParser.Identifier - 69)) | + (1 << (KipperParser.IntegerConstant - 69)) | + (1 << (KipperParser.SingleQuoteStringLiteral - 69)) | + (1 << (KipperParser.DoubleQuoteStringLiteral - 69)) | + (1 << (KipperParser.FloatingConstant - 69)) | + (1 << (KipperParser.FStringSingleQuoteStart - 69)) | + (1 << (KipperParser.FStringDoubleQuoteStart - 69)))) !== 0) ) { { - this.state = 509; + this.state = 522; this.expression(); _localctx.sliceEnd = true; } } - this.state = 514; + this.state = 527; this.match(KipperParser.RightBracket); } } catch (re) { @@ -3400,15 +3133,15 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public postfixExpression(): PostfixExpressionContext { let _localctx: PostfixExpressionContext = new PostfixExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 98, KipperParser.RULE_postfixExpression); + this.enterRule(_localctx, 102, KipperParser.RULE_postfixExpression); try { - this.state = 518; + this.state = 531; this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 47, this._ctx)) { + switch (this.interpreter.adaptivePredict(this._input, 46, this._ctx)) { case 1: this.enterOuterAlt(_localctx, 1); { - this.state = 516; + this.state = 529; this.computedPrimaryExpression(0); } break; @@ -3416,7 +3149,7 @@ export class KipperParser extends KipperParserBase { case 2: this.enterOuterAlt(_localctx, 2); { - this.state = 517; + this.state = 530; this.incrementOrDecrementPostfixExpression(); } break; @@ -3441,13 +3174,13 @@ export class KipperParser extends KipperParserBase { this._ctx, this.state, ); - this.enterRule(_localctx, 100, KipperParser.RULE_incrementOrDecrementPostfixExpression); + this.enterRule(_localctx, 104, KipperParser.RULE_incrementOrDecrementPostfixExpression); try { this.enterOuterAlt(_localctx, 1); { - this.state = 520; + this.state = 533; this.computedPrimaryExpression(0); - this.state = 521; + this.state = 534; this.incrementOrDecrementOperator(); } } catch (re) { @@ -3467,9 +3200,9 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public unaryExpression(): UnaryExpressionContext { let _localctx: UnaryExpressionContext = new UnaryExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 102, KipperParser.RULE_unaryExpression); + this.enterRule(_localctx, 106, KipperParser.RULE_unaryExpression); try { - this.state = 526; + this.state = 539; this._errHandler.sync(this); switch (this._input.LA(1)) { case KipperParser.CallFunc: @@ -3490,7 +3223,7 @@ export class KipperParser extends KipperParserBase { case KipperParser.FStringDoubleQuoteStart: this.enterOuterAlt(_localctx, 1); { - this.state = 523; + this.state = 536; this.postfixExpression(); } break; @@ -3498,7 +3231,7 @@ export class KipperParser extends KipperParserBase { case KipperParser.MinusMinus: this.enterOuterAlt(_localctx, 2); { - this.state = 524; + this.state = 537; this.incrementOrDecrementUnaryExpression(); } break; @@ -3508,7 +3241,7 @@ export class KipperParser extends KipperParserBase { case KipperParser.BitwiseNot: this.enterOuterAlt(_localctx, 3); { - this.state = 525; + this.state = 538; this.operatorModifiedUnaryExpression(); } break; @@ -3535,13 +3268,13 @@ export class KipperParser extends KipperParserBase { this._ctx, this.state, ); - this.enterRule(_localctx, 104, KipperParser.RULE_incrementOrDecrementUnaryExpression); + this.enterRule(_localctx, 108, KipperParser.RULE_incrementOrDecrementUnaryExpression); try { this.enterOuterAlt(_localctx, 1); { - this.state = 528; + this.state = 541; this.incrementOrDecrementOperator(); - this.state = 529; + this.state = 542; this.postfixExpression(); } } catch (re) { @@ -3564,13 +3297,13 @@ export class KipperParser extends KipperParserBase { this._ctx, this.state, ); - this.enterRule(_localctx, 106, KipperParser.RULE_operatorModifiedUnaryExpression); + this.enterRule(_localctx, 110, KipperParser.RULE_operatorModifiedUnaryExpression); try { this.enterOuterAlt(_localctx, 1); { - this.state = 531; + this.state = 544; this.unaryOperator(); - this.state = 532; + this.state = 545; this.postfixExpression(); } } catch (re) { @@ -3590,12 +3323,12 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public incrementOrDecrementOperator(): IncrementOrDecrementOperatorContext { let _localctx: IncrementOrDecrementOperatorContext = new IncrementOrDecrementOperatorContext(this._ctx, this.state); - this.enterRule(_localctx, 108, KipperParser.RULE_incrementOrDecrementOperator); + this.enterRule(_localctx, 112, KipperParser.RULE_incrementOrDecrementOperator); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 534; + this.state = 547; _la = this._input.LA(1); if (!(_la === KipperParser.PlusPlus || _la === KipperParser.MinusMinus)) { this._errHandler.recoverInline(this); @@ -3625,21 +3358,21 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public unaryOperator(): UnaryOperatorContext { let _localctx: UnaryOperatorContext = new UnaryOperatorContext(this._ctx, this.state); - this.enterRule(_localctx, 110, KipperParser.RULE_unaryOperator); + this.enterRule(_localctx, 114, KipperParser.RULE_unaryOperator); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 536; + this.state = 549; _la = this._input.LA(1); if ( !( - ((_la - 41) & ~0x1f) === 0 && - ((1 << (_la - 41)) & - ((1 << (KipperParser.Plus - 41)) | - (1 << (KipperParser.Minus - 41)) | - (1 << (KipperParser.Not - 41)) | - (1 << (KipperParser.BitwiseNot - 41)))) !== + ((_la - 43) & ~0x1f) === 0 && + ((1 << (_la - 43)) & + ((1 << (KipperParser.Plus - 43)) | + (1 << (KipperParser.Minus - 43)) | + (1 << (KipperParser.Not - 43)) | + (1 << (KipperParser.BitwiseNot - 43)))) !== 0 ) ) { @@ -3670,16 +3403,16 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public castOrConvertExpression(): CastOrConvertExpressionContext { let _localctx: CastOrConvertExpressionContext = new CastOrConvertExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 112, KipperParser.RULE_castOrConvertExpression); + this.enterRule(_localctx, 116, KipperParser.RULE_castOrConvertExpression); try { - this.state = 543; + this.state = 556; this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 49, this._ctx)) { + switch (this.interpreter.adaptivePredict(this._input, 48, this._ctx)) { case 1: _localctx = new PassOnCastOrConvertExpressionContext(_localctx); this.enterOuterAlt(_localctx, 1); { - this.state = 538; + this.state = 551; this.unaryExpression(); } break; @@ -3688,11 +3421,11 @@ export class KipperParser extends KipperParserBase { _localctx = new ActualCastOrConvertExpressionContext(_localctx); this.enterOuterAlt(_localctx, 2); { - this.state = 539; + this.state = 552; this.unaryExpression(); - this.state = 540; + this.state = 553; this.match(KipperParser.As); - this.state = 541; + this.state = 554; this.typeSpecifierExpression(); } break; @@ -3712,9 +3445,7 @@ export class KipperParser extends KipperParserBase { } public multiplicativeExpression(): MultiplicativeExpressionContext; - public multiplicativeExpression(_p: number): MultiplicativeExpressionContext; - // @RuleVersion(0) public multiplicativeExpression(_p?: number): MultiplicativeExpressionContext { if (_p === undefined) { @@ -3725,8 +3456,8 @@ export class KipperParser extends KipperParserBase { let _parentState: number = this.state; let _localctx: MultiplicativeExpressionContext = new MultiplicativeExpressionContext(this._ctx, _parentState); let _prevctx: MultiplicativeExpressionContext = _localctx; - let _startState: number = 114; - this.enterRecursionRule(_localctx, 114, KipperParser.RULE_multiplicativeExpression, _p); + let _startState: number = 118; + this.enterRecursionRule(_localctx, 118, KipperParser.RULE_multiplicativeExpression, _p); let _la: number; try { let _alt: number; @@ -3737,13 +3468,13 @@ export class KipperParser extends KipperParserBase { this._ctx = _localctx; _prevctx = _localctx; - this.state = 546; + this.state = 559; this.castOrConvertExpression(); } this._ctx._stop = this._input.tryLT(-1); - this.state = 553; + this.state = 566; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 50, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 49, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { @@ -3756,20 +3487,20 @@ export class KipperParser extends KipperParserBase { new MultiplicativeExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_multiplicativeExpression); - this.state = 548; + this.state = 561; if (!this.precpred(this._ctx, 1)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 1)"); } - this.state = 549; + this.state = 562; _la = this._input.LA(1); if ( !( - ((_la - 45) & ~0x1f) === 0 && - ((1 << (_la - 45)) & - ((1 << (KipperParser.Star - 45)) | - (1 << (KipperParser.Div - 45)) | - (1 << (KipperParser.Mod - 45)) | - (1 << (KipperParser.PowerTo - 45)))) !== + ((_la - 47) & ~0x1f) === 0 && + ((1 << (_la - 47)) & + ((1 << (KipperParser.Star - 47)) | + (1 << (KipperParser.Div - 47)) | + (1 << (KipperParser.Mod - 47)) | + (1 << (KipperParser.PowerTo - 47)))) !== 0 ) ) { @@ -3782,14 +3513,14 @@ export class KipperParser extends KipperParserBase { this._errHandler.reportMatch(this); this.consume(); } - this.state = 550; + this.state = 563; this.castOrConvertExpression(); } } } - this.state = 555; + this.state = 568; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 50, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 49, this._ctx); } } } catch (re) { @@ -3807,9 +3538,7 @@ export class KipperParser extends KipperParserBase { } public additiveExpression(): AdditiveExpressionContext; - public additiveExpression(_p: number): AdditiveExpressionContext; - // @RuleVersion(0) public additiveExpression(_p?: number): AdditiveExpressionContext { if (_p === undefined) { @@ -3820,8 +3549,8 @@ export class KipperParser extends KipperParserBase { let _parentState: number = this.state; let _localctx: AdditiveExpressionContext = new AdditiveExpressionContext(this._ctx, _parentState); let _prevctx: AdditiveExpressionContext = _localctx; - let _startState: number = 116; - this.enterRecursionRule(_localctx, 116, KipperParser.RULE_additiveExpression, _p); + let _startState: number = 120; + this.enterRecursionRule(_localctx, 120, KipperParser.RULE_additiveExpression, _p); let _la: number; try { let _alt: number; @@ -3832,13 +3561,13 @@ export class KipperParser extends KipperParserBase { this._ctx = _localctx; _prevctx = _localctx; - this.state = 557; + this.state = 570; this.multiplicativeExpression(0); } this._ctx._stop = this._input.tryLT(-1); - this.state = 564; + this.state = 577; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 51, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 50, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { @@ -3851,11 +3580,11 @@ export class KipperParser extends KipperParserBase { new AdditiveExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_additiveExpression); - this.state = 559; + this.state = 572; if (!this.precpred(this._ctx, 1)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 1)"); } - this.state = 560; + this.state = 573; _la = this._input.LA(1); if (!(_la === KipperParser.Plus || _la === KipperParser.Minus)) { this._errHandler.recoverInline(this); @@ -3867,14 +3596,14 @@ export class KipperParser extends KipperParserBase { this._errHandler.reportMatch(this); this.consume(); } - this.state = 561; + this.state = 574; this.multiplicativeExpression(0); } } } - this.state = 566; + this.state = 579; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 51, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 50, this._ctx); } } } catch (re) { @@ -3892,9 +3621,7 @@ export class KipperParser extends KipperParserBase { } public bitwiseShiftExpression(): BitwiseShiftExpressionContext; - public bitwiseShiftExpression(_p: number): BitwiseShiftExpressionContext; - // @RuleVersion(0) public bitwiseShiftExpression(_p?: number): BitwiseShiftExpressionContext { if (_p === undefined) { @@ -3905,8 +3632,8 @@ export class KipperParser extends KipperParserBase { let _parentState: number = this.state; let _localctx: BitwiseShiftExpressionContext = new BitwiseShiftExpressionContext(this._ctx, _parentState); let _prevctx: BitwiseShiftExpressionContext = _localctx; - let _startState: number = 118; - this.enterRecursionRule(_localctx, 118, KipperParser.RULE_bitwiseShiftExpression, _p); + let _startState: number = 122; + this.enterRecursionRule(_localctx, 122, KipperParser.RULE_bitwiseShiftExpression, _p); try { let _alt: number; this.enterOuterAlt(_localctx, 1); @@ -3916,13 +3643,13 @@ export class KipperParser extends KipperParserBase { this._ctx = _localctx; _prevctx = _localctx; - this.state = 568; + this.state = 581; this.additiveExpression(0); } this._ctx._stop = this._input.tryLT(-1); - this.state = 576; + this.state = 589; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 52, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 51, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { @@ -3935,20 +3662,20 @@ export class KipperParser extends KipperParserBase { new BitwiseShiftExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_bitwiseShiftExpression); - this.state = 570; + this.state = 583; if (!this.precpred(this._ctx, 1)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 1)"); } - this.state = 571; + this.state = 584; this.bitwiseShiftOperators(); - this.state = 572; + this.state = 585; this.bitwiseAndExpression(0); } } } - this.state = 578; + this.state = 591; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 52, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 51, this._ctx); } } } catch (re) { @@ -3968,20 +3695,20 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public bitwiseShiftOperators(): BitwiseShiftOperatorsContext { let _localctx: BitwiseShiftOperatorsContext = new BitwiseShiftOperatorsContext(this._ctx, this.state); - this.enterRule(_localctx, 120, KipperParser.RULE_bitwiseShiftOperators); + this.enterRule(_localctx, 124, KipperParser.RULE_bitwiseShiftOperators); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 579; + this.state = 592; _la = this._input.LA(1); if ( !( - ((_la - 68) & ~0x1f) === 0 && - ((1 << (_la - 68)) & - ((1 << (KipperParser.BitwiseZeroFillLeftShift - 68)) | - (1 << (KipperParser.BitwiseSignedRightShift - 68)) | - (1 << (KipperParser.BitwiseZeroFillRightShift - 68)))) !== + ((_la - 70) & ~0x1f) === 0 && + ((1 << (_la - 70)) & + ((1 << (KipperParser.BitwiseZeroFillLeftShift - 70)) | + (1 << (KipperParser.BitwiseSignedRightShift - 70)) | + (1 << (KipperParser.BitwiseZeroFillRightShift - 70)))) !== 0 ) ) { @@ -4010,9 +3737,7 @@ export class KipperParser extends KipperParserBase { } public relationalExpression(): RelationalExpressionContext; - public relationalExpression(_p: number): RelationalExpressionContext; - // @RuleVersion(0) public relationalExpression(_p?: number): RelationalExpressionContext { if (_p === undefined) { @@ -4023,8 +3748,8 @@ export class KipperParser extends KipperParserBase { let _parentState: number = this.state; let _localctx: RelationalExpressionContext = new RelationalExpressionContext(this._ctx, _parentState); let _prevctx: RelationalExpressionContext = _localctx; - let _startState: number = 122; - this.enterRecursionRule(_localctx, 122, KipperParser.RULE_relationalExpression, _p); + let _startState: number = 126; + this.enterRecursionRule(_localctx, 126, KipperParser.RULE_relationalExpression, _p); let _la: number; try { let _alt: number; @@ -4035,13 +3760,13 @@ export class KipperParser extends KipperParserBase { this._ctx = _localctx; _prevctx = _localctx; - this.state = 582; + this.state = 595; this.bitwiseShiftExpression(0); } this._ctx._stop = this._input.tryLT(-1); - this.state = 589; + this.state = 602; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 53, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 52, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { @@ -4054,20 +3779,20 @@ export class KipperParser extends KipperParserBase { new RelationalExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_relationalExpression); - this.state = 584; + this.state = 597; if (!this.precpred(this._ctx, 1)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 1)"); } - this.state = 585; + this.state = 598; _la = this._input.LA(1); if ( !( - ((_la - 60) & ~0x1f) === 0 && - ((1 << (_la - 60)) & - ((1 << (KipperParser.Less - 60)) | - (1 << (KipperParser.LessEqual - 60)) | - (1 << (KipperParser.Greater - 60)) | - (1 << (KipperParser.GreaterEqual - 60)))) !== + ((_la - 62) & ~0x1f) === 0 && + ((1 << (_la - 62)) & + ((1 << (KipperParser.Less - 62)) | + (1 << (KipperParser.LessEqual - 62)) | + (1 << (KipperParser.Greater - 62)) | + (1 << (KipperParser.GreaterEqual - 62)))) !== 0 ) ) { @@ -4080,14 +3805,14 @@ export class KipperParser extends KipperParserBase { this._errHandler.reportMatch(this); this.consume(); } - this.state = 586; + this.state = 599; this.bitwiseShiftExpression(0); } } } - this.state = 591; + this.state = 604; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 53, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 52, this._ctx); } } } catch (re) { @@ -4105,9 +3830,7 @@ export class KipperParser extends KipperParserBase { } public equalityExpression(): EqualityExpressionContext; - public equalityExpression(_p: number): EqualityExpressionContext; - // @RuleVersion(0) public equalityExpression(_p?: number): EqualityExpressionContext { if (_p === undefined) { @@ -4118,8 +3841,8 @@ export class KipperParser extends KipperParserBase { let _parentState: number = this.state; let _localctx: EqualityExpressionContext = new EqualityExpressionContext(this._ctx, _parentState); let _prevctx: EqualityExpressionContext = _localctx; - let _startState: number = 124; - this.enterRecursionRule(_localctx, 124, KipperParser.RULE_equalityExpression, _p); + let _startState: number = 128; + this.enterRecursionRule(_localctx, 128, KipperParser.RULE_equalityExpression, _p); let _la: number; try { let _alt: number; @@ -4130,13 +3853,13 @@ export class KipperParser extends KipperParserBase { this._ctx = _localctx; _prevctx = _localctx; - this.state = 593; + this.state = 606; this.relationalExpression(0); } this._ctx._stop = this._input.tryLT(-1); - this.state = 600; + this.state = 613; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 54, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 53, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { @@ -4149,11 +3872,11 @@ export class KipperParser extends KipperParserBase { new EqualityExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_equalityExpression); - this.state = 595; + this.state = 608; if (!this.precpred(this._ctx, 1)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 1)"); } - this.state = 596; + this.state = 609; _la = this._input.LA(1); if (!(_la === KipperParser.Equal || _la === KipperParser.NotEqual)) { this._errHandler.recoverInline(this); @@ -4165,14 +3888,14 @@ export class KipperParser extends KipperParserBase { this._errHandler.reportMatch(this); this.consume(); } - this.state = 597; + this.state = 610; this.relationalExpression(0); } } } - this.state = 602; + this.state = 615; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 54, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 53, this._ctx); } } } catch (re) { @@ -4190,9 +3913,7 @@ export class KipperParser extends KipperParserBase { } public bitwiseAndExpression(): BitwiseAndExpressionContext; - public bitwiseAndExpression(_p: number): BitwiseAndExpressionContext; - // @RuleVersion(0) public bitwiseAndExpression(_p?: number): BitwiseAndExpressionContext { if (_p === undefined) { @@ -4203,8 +3924,8 @@ export class KipperParser extends KipperParserBase { let _parentState: number = this.state; let _localctx: BitwiseAndExpressionContext = new BitwiseAndExpressionContext(this._ctx, _parentState); let _prevctx: BitwiseAndExpressionContext = _localctx; - let _startState: number = 126; - this.enterRecursionRule(_localctx, 126, KipperParser.RULE_bitwiseAndExpression, _p); + let _startState: number = 130; + this.enterRecursionRule(_localctx, 130, KipperParser.RULE_bitwiseAndExpression, _p); try { let _alt: number; this.enterOuterAlt(_localctx, 1); @@ -4214,13 +3935,13 @@ export class KipperParser extends KipperParserBase { this._ctx = _localctx; _prevctx = _localctx; - this.state = 604; + this.state = 617; this.equalityExpression(0); } this._ctx._stop = this._input.tryLT(-1); - this.state = 611; + this.state = 624; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 55, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 54, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { @@ -4233,20 +3954,20 @@ export class KipperParser extends KipperParserBase { new BitwiseAndExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_bitwiseAndExpression); - this.state = 606; + this.state = 619; if (!this.precpred(this._ctx, 1)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 1)"); } - this.state = 607; + this.state = 620; this.match(KipperParser.BitwiseAnd); - this.state = 608; + this.state = 621; this.equalityExpression(0); } } } - this.state = 613; + this.state = 626; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 55, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 54, this._ctx); } } } catch (re) { @@ -4264,9 +3985,7 @@ export class KipperParser extends KipperParserBase { } public bitwiseXorExpression(): BitwiseXorExpressionContext; - public bitwiseXorExpression(_p: number): BitwiseXorExpressionContext; - // @RuleVersion(0) public bitwiseXorExpression(_p?: number): BitwiseXorExpressionContext { if (_p === undefined) { @@ -4277,8 +3996,8 @@ export class KipperParser extends KipperParserBase { let _parentState: number = this.state; let _localctx: BitwiseXorExpressionContext = new BitwiseXorExpressionContext(this._ctx, _parentState); let _prevctx: BitwiseXorExpressionContext = _localctx; - let _startState: number = 128; - this.enterRecursionRule(_localctx, 128, KipperParser.RULE_bitwiseXorExpression, _p); + let _startState: number = 132; + this.enterRecursionRule(_localctx, 132, KipperParser.RULE_bitwiseXorExpression, _p); try { let _alt: number; this.enterOuterAlt(_localctx, 1); @@ -4288,13 +4007,13 @@ export class KipperParser extends KipperParserBase { this._ctx = _localctx; _prevctx = _localctx; - this.state = 615; + this.state = 628; this.bitwiseAndExpression(0); } this._ctx._stop = this._input.tryLT(-1); - this.state = 622; + this.state = 635; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 56, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 55, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { @@ -4307,20 +4026,20 @@ export class KipperParser extends KipperParserBase { new BitwiseXorExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_bitwiseXorExpression); - this.state = 617; + this.state = 630; if (!this.precpred(this._ctx, 1)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 1)"); } - this.state = 618; + this.state = 631; this.match(KipperParser.BitwiseXor); - this.state = 619; + this.state = 632; this.bitwiseAndExpression(0); } } } - this.state = 624; + this.state = 637; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 56, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 55, this._ctx); } } } catch (re) { @@ -4338,9 +4057,7 @@ export class KipperParser extends KipperParserBase { } public bitwiseOrExpression(): BitwiseOrExpressionContext; - public bitwiseOrExpression(_p: number): BitwiseOrExpressionContext; - // @RuleVersion(0) public bitwiseOrExpression(_p?: number): BitwiseOrExpressionContext { if (_p === undefined) { @@ -4351,8 +4068,8 @@ export class KipperParser extends KipperParserBase { let _parentState: number = this.state; let _localctx: BitwiseOrExpressionContext = new BitwiseOrExpressionContext(this._ctx, _parentState); let _prevctx: BitwiseOrExpressionContext = _localctx; - let _startState: number = 130; - this.enterRecursionRule(_localctx, 130, KipperParser.RULE_bitwiseOrExpression, _p); + let _startState: number = 134; + this.enterRecursionRule(_localctx, 134, KipperParser.RULE_bitwiseOrExpression, _p); try { let _alt: number; this.enterOuterAlt(_localctx, 1); @@ -4362,13 +4079,13 @@ export class KipperParser extends KipperParserBase { this._ctx = _localctx; _prevctx = _localctx; - this.state = 626; + this.state = 639; this.bitwiseXorExpression(0); } this._ctx._stop = this._input.tryLT(-1); - this.state = 633; + this.state = 646; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 57, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 56, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { @@ -4381,20 +4098,20 @@ export class KipperParser extends KipperParserBase { new BitwiseOrExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_bitwiseOrExpression); - this.state = 628; + this.state = 641; if (!this.precpred(this._ctx, 1)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 1)"); } - this.state = 629; + this.state = 642; this.match(KipperParser.BitwiseOr); - this.state = 630; + this.state = 643; this.bitwiseXorExpression(0); } } } - this.state = 635; + this.state = 648; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 57, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 56, this._ctx); } } } catch (re) { @@ -4412,9 +4129,7 @@ export class KipperParser extends KipperParserBase { } public logicalAndExpression(): LogicalAndExpressionContext; - public logicalAndExpression(_p: number): LogicalAndExpressionContext; - // @RuleVersion(0) public logicalAndExpression(_p?: number): LogicalAndExpressionContext { if (_p === undefined) { @@ -4425,8 +4140,8 @@ export class KipperParser extends KipperParserBase { let _parentState: number = this.state; let _localctx: LogicalAndExpressionContext = new LogicalAndExpressionContext(this._ctx, _parentState); let _prevctx: LogicalAndExpressionContext = _localctx; - let _startState: number = 132; - this.enterRecursionRule(_localctx, 132, KipperParser.RULE_logicalAndExpression, _p); + let _startState: number = 136; + this.enterRecursionRule(_localctx, 136, KipperParser.RULE_logicalAndExpression, _p); try { let _alt: number; this.enterOuterAlt(_localctx, 1); @@ -4436,13 +4151,13 @@ export class KipperParser extends KipperParserBase { this._ctx = _localctx; _prevctx = _localctx; - this.state = 637; + this.state = 650; this.bitwiseOrExpression(0); } this._ctx._stop = this._input.tryLT(-1); - this.state = 644; + this.state = 657; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 58, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 57, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { @@ -4455,20 +4170,20 @@ export class KipperParser extends KipperParserBase { new LogicalAndExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_logicalAndExpression); - this.state = 639; + this.state = 652; if (!this.precpred(this._ctx, 1)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 1)"); } - this.state = 640; + this.state = 653; this.match(KipperParser.AndAnd); - this.state = 641; + this.state = 654; this.bitwiseOrExpression(0); } } } - this.state = 646; + this.state = 659; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 58, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 57, this._ctx); } } } catch (re) { @@ -4486,9 +4201,7 @@ export class KipperParser extends KipperParserBase { } public logicalOrExpression(): LogicalOrExpressionContext; - public logicalOrExpression(_p: number): LogicalOrExpressionContext; - // @RuleVersion(0) public logicalOrExpression(_p?: number): LogicalOrExpressionContext { if (_p === undefined) { @@ -4499,8 +4212,8 @@ export class KipperParser extends KipperParserBase { let _parentState: number = this.state; let _localctx: LogicalOrExpressionContext = new LogicalOrExpressionContext(this._ctx, _parentState); let _prevctx: LogicalOrExpressionContext = _localctx; - let _startState: number = 134; - this.enterRecursionRule(_localctx, 134, KipperParser.RULE_logicalOrExpression, _p); + let _startState: number = 138; + this.enterRecursionRule(_localctx, 138, KipperParser.RULE_logicalOrExpression, _p); try { let _alt: number; this.enterOuterAlt(_localctx, 1); @@ -4510,13 +4223,13 @@ export class KipperParser extends KipperParserBase { this._ctx = _localctx; _prevctx = _localctx; - this.state = 648; + this.state = 661; this.logicalAndExpression(0); } this._ctx._stop = this._input.tryLT(-1); - this.state = 655; + this.state = 668; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 59, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 58, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { @@ -4529,20 +4242,20 @@ export class KipperParser extends KipperParserBase { new LogicalOrExpressionContext(_parentctx, _parentState), ); this.pushNewRecursionContext(_localctx, _startState, KipperParser.RULE_logicalOrExpression); - this.state = 650; + this.state = 663; if (!this.precpred(this._ctx, 1)) { throw this.createFailedPredicateException("this.precpred(this._ctx, 1)"); } - this.state = 651; + this.state = 664; this.match(KipperParser.OrOr); - this.state = 652; + this.state = 665; this.logicalAndExpression(0); } } } - this.state = 657; + this.state = 670; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 59, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 58, this._ctx); } } } catch (re) { @@ -4562,16 +4275,16 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public conditionalExpression(): ConditionalExpressionContext { let _localctx: ConditionalExpressionContext = new ConditionalExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 136, KipperParser.RULE_conditionalExpression); + this.enterRule(_localctx, 140, KipperParser.RULE_conditionalExpression); try { - this.state = 665; + this.state = 678; this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 60, this._ctx)) { + switch (this.interpreter.adaptivePredict(this._input, 59, this._ctx)) { case 1: _localctx = new PassOnConditionalExpressionContext(_localctx); this.enterOuterAlt(_localctx, 1); { - this.state = 658; + this.state = 671; this.logicalOrExpression(0); } break; @@ -4580,15 +4293,15 @@ export class KipperParser extends KipperParserBase { _localctx = new ActualConditionalExpressionContext(_localctx); this.enterOuterAlt(_localctx, 2); { - this.state = 659; + this.state = 672; this.logicalOrExpression(0); - this.state = 660; + this.state = 673; this.match(KipperParser.QuestionMark); - this.state = 661; + this.state = 674; this.conditionalExpression(); - this.state = 662; + this.state = 675; this.match(KipperParser.Colon); - this.state = 663; + this.state = 676; this.conditionalExpression(); } break; @@ -4610,16 +4323,16 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public assignmentExpression(): AssignmentExpressionContext { let _localctx: AssignmentExpressionContext = new AssignmentExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 138, KipperParser.RULE_assignmentExpression); + this.enterRule(_localctx, 142, KipperParser.RULE_assignmentExpression); try { - this.state = 672; + this.state = 685; this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 61, this._ctx)) { + switch (this.interpreter.adaptivePredict(this._input, 60, this._ctx)) { case 1: _localctx = new PassOnAssignmentExpressionContext(_localctx); this.enterOuterAlt(_localctx, 1); { - this.state = 667; + this.state = 680; this.conditionalExpression(); } break; @@ -4628,11 +4341,11 @@ export class KipperParser extends KipperParserBase { _localctx = new ActualAssignmentExpressionContext(_localctx); this.enterOuterAlt(_localctx, 2); { - this.state = 668; + this.state = 681; this.computedPrimaryExpression(0); - this.state = 669; + this.state = 682; this.assignmentOperator(); - this.state = 670; + this.state = 683; this.assignmentExpression(); } break; @@ -4654,23 +4367,23 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public assignmentOperator(): AssignmentOperatorContext { let _localctx: AssignmentOperatorContext = new AssignmentOperatorContext(this._ctx, this.state); - this.enterRule(_localctx, 140, KipperParser.RULE_assignmentOperator); + this.enterRule(_localctx, 144, KipperParser.RULE_assignmentOperator); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 674; + this.state = 687; _la = this._input.LA(1); if ( !( - ((_la - 52) & ~0x1f) === 0 && - ((1 << (_la - 52)) & - ((1 << (KipperParser.Assign - 52)) | - (1 << (KipperParser.PlusAssign - 52)) | - (1 << (KipperParser.MinusAssign - 52)) | - (1 << (KipperParser.StarAssign - 52)) | - (1 << (KipperParser.DivAssign - 52)) | - (1 << (KipperParser.ModAssign - 52)))) !== + ((_la - 54) & ~0x1f) === 0 && + ((1 << (_la - 54)) & + ((1 << (KipperParser.Assign - 54)) | + (1 << (KipperParser.PlusAssign - 54)) | + (1 << (KipperParser.MinusAssign - 54)) | + (1 << (KipperParser.StarAssign - 54)) | + (1 << (KipperParser.DivAssign - 54)) | + (1 << (KipperParser.ModAssign - 54)))) !== 0 ) ) { @@ -4701,30 +4414,30 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public expression(): ExpressionContext { let _localctx: ExpressionContext = new ExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 142, KipperParser.RULE_expression); + this.enterRule(_localctx, 146, KipperParser.RULE_expression); try { let _alt: number; this.enterOuterAlt(_localctx, 1); { - this.state = 676; + this.state = 689; this.assignmentExpression(); - this.state = 681; + this.state = 694; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 62, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 61, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { { { - this.state = 677; + this.state = 690; this.match(KipperParser.Comma); - this.state = 678; + this.state = 691; this.assignmentExpression(); } } } - this.state = 683; + this.state = 696; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 62, this._ctx); + _alt = this.interpreter.adaptivePredict(this._input, 61, this._ctx); } } } catch (re) { @@ -4744,15 +4457,15 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public typeSpecifierExpression(): TypeSpecifierExpressionContext { let _localctx: TypeSpecifierExpressionContext = new TypeSpecifierExpressionContext(this._ctx, this.state); - this.enterRule(_localctx, 144, KipperParser.RULE_typeSpecifierExpression); + this.enterRule(_localctx, 148, KipperParser.RULE_typeSpecifierExpression); try { - this.state = 687; + this.state = 700; this._errHandler.sync(this); - switch (this.interpreter.adaptivePredict(this._input, 63, this._ctx)) { + switch (this.interpreter.adaptivePredict(this._input, 62, this._ctx)) { case 1: this.enterOuterAlt(_localctx, 1); { - this.state = 684; + this.state = 697; this.identifierTypeSpecifierExpression(); } break; @@ -4760,7 +4473,7 @@ export class KipperParser extends KipperParserBase { case 2: this.enterOuterAlt(_localctx, 2); { - this.state = 685; + this.state = 698; this.genericTypeSpecifierExpression(); } break; @@ -4768,7 +4481,7 @@ export class KipperParser extends KipperParserBase { case 3: this.enterOuterAlt(_localctx, 3); { - this.state = 686; + this.state = 699; this.typeofTypeSpecifierExpression(); } break; @@ -4793,11 +4506,11 @@ export class KipperParser extends KipperParserBase { this._ctx, this.state, ); - this.enterRule(_localctx, 146, KipperParser.RULE_identifierTypeSpecifierExpression); + this.enterRule(_localctx, 150, KipperParser.RULE_identifierTypeSpecifierExpression); try { this.enterOuterAlt(_localctx, 1); { - this.state = 689; + this.state = 702; this.typeSpecifierIdentifier(); } } catch (re) { @@ -4820,17 +4533,17 @@ export class KipperParser extends KipperParserBase { this._ctx, this.state, ); - this.enterRule(_localctx, 148, KipperParser.RULE_genericTypeSpecifierExpression); + this.enterRule(_localctx, 152, KipperParser.RULE_genericTypeSpecifierExpression); try { this.enterOuterAlt(_localctx, 1); { - this.state = 691; + this.state = 704; this.typeSpecifierIdentifier(); - this.state = 692; + this.state = 705; this.match(KipperParser.Less); - this.state = 693; + this.state = 706; this.typeSpecifierIdentifier(); - this.state = 694; + this.state = 707; this.match(KipperParser.Greater); } } catch (re) { @@ -4853,17 +4566,17 @@ export class KipperParser extends KipperParserBase { this._ctx, this.state, ); - this.enterRule(_localctx, 150, KipperParser.RULE_typeofTypeSpecifierExpression); + this.enterRule(_localctx, 154, KipperParser.RULE_typeofTypeSpecifierExpression); try { this.enterOuterAlt(_localctx, 1); { - this.state = 696; + this.state = 709; this.match(KipperParser.Typeof); - this.state = 697; + this.state = 710; this.match(KipperParser.LeftParen); - this.state = 698; + this.state = 711; this.typeSpecifierIdentifier(); - this.state = 699; + this.state = 712; this.match(KipperParser.RightParen); } } catch (re) { @@ -4883,12 +4596,12 @@ export class KipperParser extends KipperParserBase { // @RuleVersion(0) public typeSpecifierIdentifier(): TypeSpecifierIdentifierContext { let _localctx: TypeSpecifierIdentifierContext = new TypeSpecifierIdentifierContext(this._ctx, this.state); - this.enterRule(_localctx, 152, KipperParser.RULE_typeSpecifierIdentifier); + this.enterRule(_localctx, 156, KipperParser.RULE_typeSpecifierIdentifier); let _la: number; try { this.enterOuterAlt(_localctx, 1); { - this.state = 701; + this.state = 714; _la = this._input.LA(1); if ( !( @@ -4924,49 +4637,45 @@ export class KipperParser extends KipperParserBase { public sempred(_localctx: RuleContext, ruleIndex: number, predIndex: number): boolean { switch (ruleIndex) { - case 16: + case 18: return this.compoundStatement_sempred(_localctx as CompoundStatementContext, predIndex); - case 44: + case 46: return this.computedPrimaryExpression_sempred(_localctx as ComputedPrimaryExpressionContext, predIndex); - case 57: + case 59: return this.multiplicativeExpression_sempred(_localctx as MultiplicativeExpressionContext, predIndex); - case 58: + case 60: return this.additiveExpression_sempred(_localctx as AdditiveExpressionContext, predIndex); - case 59: + case 61: return this.bitwiseShiftExpression_sempred(_localctx as BitwiseShiftExpressionContext, predIndex); - case 61: + case 63: return this.relationalExpression_sempred(_localctx as RelationalExpressionContext, predIndex); - case 62: + case 64: return this.equalityExpression_sempred(_localctx as EqualityExpressionContext, predIndex); - case 63: + case 65: return this.bitwiseAndExpression_sempred(_localctx as BitwiseAndExpressionContext, predIndex); - case 64: + case 66: return this.bitwiseXorExpression_sempred(_localctx as BitwiseXorExpressionContext, predIndex); - case 65: + case 67: return this.bitwiseOrExpression_sempred(_localctx as BitwiseOrExpressionContext, predIndex); - case 66: + case 68: return this.logicalAndExpression_sempred(_localctx as LogicalAndExpressionContext, predIndex); - case 67: + case 69: return this.logicalOrExpression_sempred(_localctx as LogicalOrExpressionContext, predIndex); } return true; } - protected createFailedPredicateException(predicate?: string, message?: string): FailedPredicateException { - return new FailedPredicateException(this, predicate, message); - } - private compoundStatement_sempred(_localctx: CompoundStatementContext, predIndex: number): boolean { switch (predIndex) { case 0: @@ -5071,18 +4780,360 @@ export class KipperParser extends KipperParserBase { } return true; } -} -export class CompilationUnitContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } + private static readonly _serializedATNSegments: number = 2; + private static readonly _serializedATNSegment0: string = + "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x03X\u02CF\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(\x04)\t)\x04*\t*\x04+\t+" + + "\x04,\t,\x04-\t-\x04.\t.\x04/\t/\x040\t0\x041\t1\x042\t2\x043\t3\x044" + + "\t4\x045\t5\x046\t6\x047\t7\x048\t8\x049\t9\x04:\t:\x04;\t;\x04<\t<\x04" + + "=\t=\x04>\t>\x04?\t?\x04@\t@\x04A\tA\x04B\tB\x04C\tC\x04D\tD\x04E\tE\x04" + + "F\tF\x04G\tG\x04H\tH\x04I\tI\x04J\tJ\x04K\tK\x04L\tL\x04M\tM\x04N\tN\x04" + + "O\tO\x04P\tP\x03\x02\x05\x02\xA2\n\x02\x03\x02\x03\x02\x03\x03\x06\x03" + + "\xA7\n\x03\r\x03\x0E\x03\xA8\x03\x04\x03\x04\x03\x05\x06\x05\xAE\n\x05" + + "\r\x05\x0E\x05\xAF\x03\x06\x03\x06\x03\x06\x05\x06\xB5\n\x06\x03\x07\x03" + + "\x07\x03\x07\x03\x07\x03\x07\x03\x07\x05\x07\xBD\n\x07\x03\b\x03\b\x03" + + "\b\x03\t\x03\t\x03\n\x03\n\x03\n\x03\n\x03\n\x05\n\xC9\n\n\x03\v\x03\v" + + "\x03\f\x03\f\x03\r\x03\r\x03\x0E\x03\x0E\x03\x0E\x03\x0E\x05\x0E\xD5\n" + + "\x0E\x03\x0E\x03\x0E\x03\x0E\x03\x0E\x05\x0E\xDB\n\x0E\x03\x0F\x03\x0F" + + "\x03\x0F\x07\x0F\xE0\n\x0F\f\x0F\x0E\x0F\xE3\v\x0F\x03\x10\x03\x10\x03" + + "\x10\x03\x10\x03\x11\x03\x11\x03\x11\x03\x11\x03\x11\x03\x12\x03\x12\x03" + + "\x12\x03\x12\x03\x12\x03\x13\x03\x13\x03\x13\x03\x13\x03\x13\x03\x13\x05" + + "\x13\xF9\n\x13\x03\x14\x03\x14\x03\x14\x05\x14\xFE\n\x14\x03\x14\x03\x14" + + "\x03\x15\x03\x15\x03\x15\x03\x15\x03\x15\x03\x16\x03\x16\x05\x16\u0109" + + "\n\x16\x03\x17\x03\x17\x03\x17\x03\x17\x03\x17\x03\x17\x03\x17\x05\x17" + + "\u0112\n\x17\x03\x18\x03\x18\x03\x18\x03\x18\x03\x18\x03\x18\x07\x18\u011A" + + "\n\x18\f\x18\x0E\x18\u011D\v\x18\x03\x18\x03\x18\x03\x19\x03\x19\x03\x19" + + "\x03\x19\x03\x19\x03\x19\x03\x19\x03\x19\x05\x19\u0129\n\x19\x03\x1A\x03" + + "\x1A\x03\x1A\x05\x1A\u012E\n\x1A\x03\x1B\x03\x1B\x03\x1B\x03\x1B\x05\x1B" + + "\u0134\n\x1B\x03\x1B\x03\x1B\x05\x1B\u0138\n\x1B\x03\x1B\x03\x1B\x03\x1B" + + "\x03\x1B\x05\x1B\u013E\n\x1B\x03\x1B\x03\x1B\x03\x1B\x03\x1B\x05\x1B\u0144" + + "\n\x1B\x03\x1B\x03\x1B\x03\x1B\x03\x1C\x03\x1C\x03\x1C\x03\x1C\x03\x1C" + + "\x03\x1C\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1D" + + "\x03\x1E\x03\x1E\x03\x1E\x03\x1F\x03\x1F\x05\x1F\u015C\n\x1F\x03\x1F\x03" + + "\x1F\x03 \x03 \x03 \x03 \x03 \x03 \x03 \x03 \x03 \x03 \x05 \u016A\n \x03" + + '!\x03!\x05!\u016E\n!\x03!\x03!\x03!\x03!\x03!\x03!\x05!\u0176\n!\x03"' + + '\x03"\x03"\x03"\x03#\x03#\x03$\x03$\x03%\x03%\x03&\x03&\x05&\u0184' + + "\n&\x03'\x03'\x03(\x03(\x07(\u018A\n(\f(\x0E(\u018D\v(\x03(\x03(\x03" + + "(\x07(\u0192\n(\f(\x0E(\u0195\v(\x03(\x05(\u0198\n(\x03)\x03)\x03)\x05" + + ")\u019D\n)\x03)\x05)\u01A0\n)\x03*\x03*\x03*\x05*\u01A5\n*\x03*\x05*\u01A8" + + "\n*\x03+\x03+\x03,\x03,\x03,\x03,\x07,\u01B0\n,\f,\x0E,\u01B3\v,\x05," + + "\u01B5\n,\x03,\x05,\u01B8\n,\x03,\x03,\x03-\x03-\x03-\x03-\x07-\u01C0" + + "\n-\f-\x0E-\u01C3\v-\x05-\u01C5\n-\x03-\x05-\u01C8\n-\x03-\x03-\x03.\x03" + + ".\x03.\x03.\x03/\x03/\x030\x030\x030\x030\x030\x030\x050\u01D8\n0\x03" + + "0\x030\x030\x050\u01DD\n0\x030\x030\x030\x050\u01E2\n0\x030\x030\x030" + + "\x030\x030\x030\x030\x030\x030\x030\x030\x030\x030\x030\x070\u01F2\n0" + + "\f0\x0E0\u01F5\v0\x031\x031\x031\x071\u01FA\n1\f1\x0E1\u01FD\v1\x032\x03" + + "2\x032\x033\x033\x033\x033\x034\x034\x034\x034\x054\u020A\n4\x034\x03" + + "4\x034\x034\x054\u0210\n4\x034\x034\x035\x035\x055\u0216\n5\x036\x036" + + "\x036\x037\x037\x037\x057\u021E\n7\x038\x038\x038\x039\x039\x039\x03:" + + "\x03:\x03;\x03;\x03<\x03<\x03<\x03<\x03<\x05<\u022F\n<\x03=\x03=\x03=" + + "\x03=\x03=\x03=\x07=\u0237\n=\f=\x0E=\u023A\v=\x03>\x03>\x03>\x03>\x03" + + ">\x03>\x07>\u0242\n>\f>\x0E>\u0245\v>\x03?\x03?\x03?\x03?\x03?\x03?\x03" + + "?\x07?\u024E\n?\f?\x0E?\u0251\v?\x03@\x03@\x03A\x03A\x03A\x03A\x03A\x03" + + "A\x07A\u025B\nA\fA\x0EA\u025E\vA\x03B\x03B\x03B\x03B\x03B\x03B\x07B\u0266" + + "\nB\fB\x0EB\u0269\vB\x03C\x03C\x03C\x03C\x03C\x03C\x07C\u0271\nC\fC\x0E" + + "C\u0274\vC\x03D\x03D\x03D\x03D\x03D\x03D\x07D\u027C\nD\fD\x0ED\u027F\v" + + "D\x03E\x03E\x03E\x03E\x03E\x03E\x07E\u0287\nE\fE\x0EE\u028A\vE\x03F\x03" + + "F\x03F\x03F\x03F\x03F\x07F\u0292\nF\fF\x0EF\u0295\vF\x03G\x03G\x03G\x03" + + "G\x03G\x03G\x07G\u029D\nG\fG\x0EG\u02A0\vG\x03H\x03H\x03H\x03H\x03H\x03" + + "H\x03H\x05H\u02A9\nH\x03I\x03I\x03I\x03I\x03I\x05I\u02B0\nI\x03J\x03J" + + "\x03K\x03K\x03K\x07K\u02B7\nK\fK\x0EK\u02BA\vK\x03L\x03L\x03L\x05L\u02BF" + + "\nL\x03M\x03M\x03N\x03N\x03N\x03N\x03N\x03O\x03O\x03O\x03O\x03O\x03P\x03" + + "P\x03P\x02\x02\r^xz|\x80\x82\x84\x86\x88\x8A\x8CQ\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' + + "2\x024\x026\x028\x02:\x02<\x02>\x02@\x02B\x02D\x02F\x02H\x02J\x02L\x02" + + "N\x02P\x02R\x02T\x02V\x02X\x02Z\x02\\\x02^\x02`\x02b\x02d\x02f\x02h\x02" + + "j\x02l\x02n\x02p\x02r\x02t\x02v\x02x\x02z\x02|\x02~\x02\x80\x02\x82\x02" + + "\x84\x02\x86\x02\x88\x02\x8A\x02\x8C\x02\x8E\x02\x90\x02\x92\x02\x94\x02" + + "\x96\x02\x98\x02\x9A\x02\x9C\x02\x9E\x02\x02\x11\x03\x02\x07\b\x03\x02" + + "\x0E\x0F\x03\x02\x1C\x1D\x03\x02NO\x04\x02MMPP\x03\x02\x1F!\x04\x02.." + + "00\x06\x02--//77GG\x03\x0214\x04\x02--//\x03\x02HJ\x03\x02@C\x03\x02>" + + "?\x03\x028=\x04\x02\x1F!LL\x02\u02D2\x02\xA1\x03\x02\x02\x02\x04\xA6\x03" + + "\x02\x02\x02\x06\xAA\x03\x02\x02\x02\b\xAD\x03\x02\x02\x02\n\xB4\x03\x02" + + "\x02\x02\f\xBC\x03\x02\x02\x02\x0E\xBE\x03\x02\x02\x02\x10\xC1\x03\x02" + + "\x02\x02\x12\xC3\x03\x02\x02\x02\x14\xCA\x03\x02\x02\x02\x16\xCC\x03\x02" + + "\x02\x02\x18\xCE\x03\x02\x02\x02\x1A\xD0\x03\x02\x02\x02\x1C\xDC\x03\x02" + + '\x02\x02\x1E\xE4\x03\x02\x02\x02 \xE8\x03\x02\x02\x02"\xED\x03\x02\x02' + + "\x02$\xF8\x03\x02\x02\x02&\xFA\x03\x02\x02\x02(\u0101\x03\x02\x02\x02" + + "*\u0108\x03\x02\x02\x02,\u010A\x03\x02\x02\x02.\u0113\x03\x02\x02\x02" + + "0\u0128\x03\x02\x02\x022\u012D\x03\x02\x02\x024\u012F\x03\x02\x02\x02" + + "6\u0148\x03\x02\x02\x028\u014E\x03\x02\x02\x02:\u0156\x03\x02\x02\x02" + + "<\u0159\x03\x02\x02\x02>\u0169\x03\x02\x02\x02@\u016B\x03\x02\x02\x02" + + "B\u0177\x03\x02\x02\x02D\u017B\x03\x02\x02\x02F\u017D\x03\x02\x02\x02" + + "H\u017F\x03\x02\x02\x02J\u0183\x03\x02\x02\x02L\u0185\x03\x02\x02\x02" + + "N\u0197\x03\x02\x02\x02P\u019F\x03\x02\x02\x02R\u01A7\x03\x02\x02\x02" + + "T\u01A9\x03\x02\x02\x02V\u01AB\x03\x02\x02\x02X\u01BB\x03\x02\x02\x02" + + "Z\u01CB\x03\x02\x02\x02\\\u01CF\x03\x02\x02\x02^\u01DC\x03\x02\x02\x02" + + "`\u01F6\x03\x02\x02\x02b\u01FE\x03\x02\x02\x02d\u0201\x03\x02\x02\x02" + + "f\u0205\x03\x02\x02\x02h\u0215\x03\x02\x02\x02j\u0217\x03\x02\x02\x02" + + "l\u021D\x03\x02\x02\x02n\u021F\x03\x02\x02\x02p\u0222\x03\x02\x02\x02" + + "r\u0225\x03\x02\x02\x02t\u0227\x03\x02\x02\x02v\u022E\x03\x02\x02\x02" + + "x\u0230\x03\x02\x02\x02z\u023B\x03\x02\x02\x02|\u0246\x03\x02\x02\x02" + + "~\u0252\x03\x02\x02\x02\x80\u0254\x03\x02\x02\x02\x82\u025F\x03\x02\x02" + + "\x02\x84\u026A\x03\x02\x02\x02\x86\u0275\x03\x02\x02\x02\x88\u0280\x03" + + "\x02\x02\x02\x8A\u028B\x03\x02\x02\x02\x8C\u0296\x03\x02\x02\x02\x8E\u02A8" + + "\x03\x02\x02\x02\x90\u02AF\x03\x02\x02\x02\x92\u02B1\x03\x02\x02\x02\x94" + + "\u02B3\x03\x02\x02\x02\x96\u02BE\x03\x02\x02\x02\x98\u02C0\x03\x02\x02" + + "\x02\x9A\u02C2\x03\x02\x02\x02\x9C\u02C7\x03\x02\x02\x02\x9E\u02CC\x03" + + "\x02\x02\x02\xA0\xA2\x05\x04\x03\x02\xA1\xA0\x03\x02\x02\x02\xA1\xA2\x03" + + "\x02\x02\x02\xA2\xA3\x03\x02\x02\x02\xA3\xA4\x07\x02\x02\x03\xA4\x03\x03" + + "\x02\x02\x02\xA5\xA7\x05\x06\x04\x02\xA6\xA5\x03\x02\x02\x02\xA7\xA8\x03" + + "\x02\x02\x02\xA8\xA6\x03\x02\x02\x02\xA8\xA9\x03\x02\x02\x02\xA9\x05\x03" + + "\x02\x02\x02\xAA\xAB\x05\b\x05\x02\xAB\x07\x03\x02\x02\x02\xAC\xAE\x05" + + "\n\x06\x02\xAD\xAC\x03\x02\x02\x02\xAE\xAF\x03\x02\x02\x02\xAF\xAD\x03" + + "\x02\x02\x02\xAF\xB0\x03\x02\x02\x02\xB0\t\x03\x02\x02\x02\xB1\xB5\x05" + + "$\x13\x02\xB2\xB5\x05\f\x07\x02\xB3\xB5\x07#\x02\x02\xB4\xB1\x03\x02\x02" + + "\x02\xB4\xB2\x03\x02\x02\x02\xB4\xB3\x03\x02\x02\x02\xB5\v\x03\x02\x02" + + "\x02\xB6\xB7\x05\x0E\b\x02\xB7\xB8\x07#\x02\x02\xB8\xBD\x03\x02\x02\x02" + + '\xB9\xBD\x05\x1A\x0E\x02\xBA\xBD\x05 \x11\x02\xBB\xBD\x05"\x12\x02\xBC' + + "\xB6\x03\x02\x02\x02\xBC\xB9\x03\x02\x02\x02\xBC\xBA\x03\x02\x02\x02\xBC" + + "\xBB\x03\x02\x02\x02\xBD\r\x03\x02\x02\x02\xBE\xBF\x05\x10\t\x02\xBF\xC0" + + "\x05\x12\n\x02\xC0\x0F\x03\x02\x02\x02\xC1\xC2\t\x02\x02\x02\xC2\x11\x03" + + "\x02\x02\x02\xC3\xC4\x05\x16\f\x02\xC4\xC5\x07%\x02\x02\xC5\xC8\x05\x96" + + "L\x02\xC6\xC7\x078\x02\x02\xC7\xC9\x05\x14\v\x02\xC8\xC6\x03\x02\x02\x02" + + "\xC8\xC9\x03\x02\x02\x02\xC9\x13\x03\x02\x02\x02\xCA\xCB\x05\x90I\x02" + + "\xCB\x15\x03\x02\x02\x02\xCC\xCD\x05\x18\r\x02\xCD\x17\x03\x02\x02\x02" + + "\xCE\xCF\x07L\x02\x02\xCF\x19\x03\x02\x02\x02\xD0\xD1\x07\x16\x02\x02" + + "\xD1\xD2\x05\x16\f\x02\xD2\xD4\x07&\x02\x02\xD3\xD5\x05\x1C\x0F\x02\xD4" + + "\xD3\x03\x02\x02\x02\xD4\xD5\x03\x02\x02\x02\xD5\xD6\x03\x02\x02\x02\xD6" + + "\xD7\x07'\x02\x02\xD7\xD8\x07\x19\x02\x02\xD8\xDA\x05\x96L\x02\xD9\xDB" + + "\x05&\x14\x02\xDA\xD9\x03\x02\x02\x02\xDA\xDB\x03\x02\x02\x02\xDB\x1B" + + '\x03\x02\x02\x02\xDC\xE1\x05\x1E\x10\x02\xDD\xDE\x07"\x02\x02\xDE\xE0' + + "\x05\x1E\x10\x02\xDF\xDD\x03\x02\x02\x02\xE0\xE3\x03\x02\x02\x02\xE1\xDF" + + "\x03\x02\x02\x02\xE1\xE2\x03\x02\x02\x02\xE2\x1D\x03\x02\x02\x02\xE3\xE1" + + "\x03\x02\x02\x02\xE4\xE5\x05\x16\f\x02\xE5\xE6\x07%\x02\x02\xE6\xE7\x05" + + "\x96L\x02\xE7\x1F\x03\x02\x02\x02\xE8\xE9\x07\x1B\x02\x02\xE9\xEA\x07" + + "L\x02\x02\xEA\xEB\x07+\x02\x02\xEB\xEC\x07,\x02\x02\xEC!\x03\x02\x02\x02" + + "\xED\xEE\x07\x1A\x02\x02\xEE\xEF\x07L\x02\x02\xEF\xF0\x07+\x02\x02\xF0" + + "\xF1\x07,\x02\x02\xF1#\x03\x02\x02\x02\xF2\xF9\x05(\x15\x02\xF3\xF9\x05" + + "*\x16\x02\xF4\xF9\x052\x1A\x02\xF5\xF9\x05:\x1E\x02\xF6\xF9\x05<\x1F\x02" + + "\xF7\xF9\x05&\x14\x02\xF8\xF2\x03\x02\x02\x02\xF8\xF3\x03\x02\x02\x02" + + "\xF8\xF4\x03\x02\x02\x02\xF8\xF5\x03\x02\x02\x02\xF8\xF6\x03\x02\x02\x02" + + "\xF8\xF7\x03\x02\x02\x02\xF9%\x03\x02\x02\x02\xFA\xFB\x06\x14\x02\x02" + + "\xFB\xFD\x07+\x02\x02\xFC\xFE\x05\b\x05\x02\xFD\xFC\x03\x02\x02\x02\xFD" + + "\xFE\x03\x02\x02\x02\xFE\xFF\x03\x02\x02\x02\xFF\u0100\x07,\x02\x02\u0100" + + "'\x03\x02\x02\x02\u0101\u0102\b\x15\x01\x02\u0102\u0103\x05\x94K\x02" + + "\u0103\u0104\x07#\x02\x02\u0104\u0105\b\x15\x01\x02\u0105)\x03\x02\x02" + + "\x02\u0106\u0109\x05,\x17\x02\u0107\u0109\x05.\x18\x02\u0108\u0106\x03" + + "\x02\x02\x02\u0108\u0107\x03\x02\x02\x02\u0109+\x03\x02\x02\x02\u010A" + + "\u010B\x07\x12\x02\x02\u010B\u010C\x07&\x02\x02\u010C\u010D\x05\x94K\x02" + + "\u010D\u010E\x07'\x02\x02\u010E\u0111\x05$\x13\x02\u010F\u0110\x07\x13" + + "\x02\x02\u0110\u0112\x05$\x13\x02\u0111\u010F\x03\x02\x02\x02\u0111\u0112" + + "\x03\x02\x02\x02\u0112-\x03\x02\x02\x02\u0113\u0114\x07\v\x02\x02\u0114" + + "\u0115\x07&\x02\x02\u0115\u0116\x05\x94K\x02\u0116\u0117\x07'\x02\x02" + + "\u0117\u011B\x07+\x02\x02\u0118\u011A\x050\x19\x02\u0119\u0118\x03\x02" + + "\x02\x02\u011A\u011D\x03\x02\x02\x02\u011B\u0119\x03\x02\x02\x02\u011B" + + "\u011C\x03\x02\x02\x02\u011C\u011E\x03\x02\x02\x02\u011D\u011B\x03\x02" + + "\x02\x02\u011E\u011F\x07,\x02\x02\u011F/\x03\x02\x02\x02\u0120\u0121\x07" + + "\f\x02\x02\u0121\u0122\x05\x94K\x02\u0122\u0123\x07%\x02\x02\u0123\u0124" + + "\x05$\x13\x02\u0124\u0129\x03\x02\x02\x02\u0125\u0126\x07\r\x02\x02\u0126" + + "\u0127\x07%\x02\x02\u0127\u0129\x05$\x13\x02\u0128\u0120\x03\x02\x02\x02" + + "\u0128\u0125\x03\x02\x02\x02\u01291\x03\x02\x02\x02\u012A\u012E\x054\x1B" + + "\x02\u012B\u012E\x056\x1C\x02\u012C\u012E\x058\x1D\x02\u012D\u012A\x03" + + "\x02\x02\x02\u012D\u012B\x03\x02\x02\x02\u012D\u012C\x03\x02\x02\x02\u012E" + + "3\x03\x02\x02\x02\u012F\u0130\x07\x14\x02\x02\u0130\u0137\x07&\x02\x02" + + "\u0131\u0134\x05\x0E\b\x02\u0132\u0134\x05\x94K\x02\u0133\u0131\x03\x02" + + "\x02\x02\u0133\u0132\x03\x02\x02\x02\u0134\u0135\x03\x02\x02\x02\u0135" + + "\u0136\b\x1B\x01\x02\u0136\u0138\x03\x02\x02\x02\u0137\u0133\x03\x02\x02" + + "\x02\u0137\u0138\x03\x02\x02\x02\u0138\u0139\x03\x02\x02\x02\u0139\u013D" + + "\x07#\x02\x02\u013A\u013B\x05\x94K\x02\u013B\u013C\b\x1B\x01\x02\u013C" + + "\u013E\x03\x02\x02\x02\u013D\u013A\x03\x02\x02\x02\u013D\u013E\x03\x02" + + "\x02\x02\u013E\u013F\x03\x02\x02\x02\u013F\u0143\x07#\x02\x02\u0140\u0141" + + "\x05\x94K\x02\u0141\u0142\b\x1B\x01\x02\u0142\u0144\x03\x02\x02\x02\u0143" + + "\u0140\x03\x02\x02\x02\u0143\u0144\x03\x02\x02\x02\u0144\u0145\x03\x02" + + "\x02\x02\u0145\u0146\x07'\x02\x02\u0146\u0147\x05$\x13\x02\u01475\x03" + + "\x02\x02\x02\u0148\u0149\x07\x11\x02\x02\u0149\u014A\x07&\x02\x02\u014A" + + "\u014B\x05\x94K\x02\u014B\u014C\x07'\x02\x02\u014C\u014D\x05$\x13\x02" + + "\u014D7\x03\x02\x02\x02\u014E\u014F\x07\x10\x02\x02\u014F\u0150\x05$\x13" + + "\x02\u0150\u0151\x07\x11\x02\x02\u0151\u0152\x07&\x02\x02\u0152\u0153" + + "\x05\x94K\x02\u0153\u0154\x07'\x02\x02\u0154\u0155\x07#\x02\x02\u0155" + + "9\x03\x02\x02\x02\u0156\u0157\t\x03\x02\x02\u0157\u0158\x07#\x02\x02\u0158" + + ";\x03\x02\x02\x02\u0159\u015B\x07\x17\x02\x02\u015A\u015C\x05\x94K\x02" + + "\u015B\u015A\x03\x02\x02\x02\u015B\u015C\x03\x02\x02\x02\u015C\u015D\x03" + + "\x02\x02\x02\u015D\u015E\x07#\x02\x02\u015E=\x03\x02\x02\x02\u015F\u016A" + + '\x05B"\x02\u0160\u016A\x05V,\x02\u0161\u016A\x05X-\x02\u0162\u016A\x05' + + "D#\x02\u0163\u016A\x05F$\x02\u0164\u016A\x05L'\x02\u0165\u016A\x05N(" + + "\x02\u0166\u016A\x05T+\x02\u0167\u016A\x05\\/\x02\u0168\u016A\x05@!\x02" + + "\u0169\u015F\x03\x02\x02\x02\u0169\u0160\x03\x02\x02\x02\u0169\u0161\x03" + + "\x02\x02\x02\u0169\u0162\x03\x02\x02\x02\u0169\u0163\x03\x02\x02\x02\u0169" + + "\u0164\x03\x02\x02\x02\u0169\u0165\x03\x02\x02\x02\u0169\u0166\x03\x02" + + "\x02\x02\u0169\u0167\x03\x02\x02\x02\u0169\u0168\x03\x02\x02\x02\u016A" + + "?\x03\x02\x02\x02\u016B\u016D\x07&\x02\x02\u016C\u016E\x05\x1C\x0F\x02" + + "\u016D\u016C\x03\x02\x02\x02\u016D\u016E\x03\x02\x02\x02\u016E\u016F\x03" + + "\x02\x02\x02\u016F\u0170\x07'\x02\x02\u0170\u0171\x07%\x02\x02\u0171" + + "\u0172\x05\x96L\x02\u0172\u0175\x07\x19\x02\x02\u0173\u0176\x05\x94K\x02" + + "\u0174\u0176\x05&\x14\x02\u0175\u0173\x03\x02\x02\x02\u0175\u0174\x03" + + "\x02\x02\x02\u0176A\x03\x02\x02\x02\u0177\u0178\x07&\x02\x02\u0178\u0179" + + "\x05\x94K\x02\u0179\u017A\x07'\x02\x02\u017AC\x03\x02\x02\x02\u017B\u017C" + + "\t\x04\x02\x02\u017CE\x03\x02\x02\x02\u017D\u017E\x05H%\x02\u017EG\x03" + + "\x02\x02\x02\u017F\u0180\x07L\x02\x02\u0180I\x03\x02\x02\x02\u0181\u0184" + + "\x05H%\x02\u0182\u0184\x05L'\x02\u0183\u0181\x03\x02\x02\x02\u0183\u0182" + + "\x03\x02\x02\x02\u0184K\x03\x02\x02\x02\u0185\u0186\t\x05\x02\x02\u0186" + + "M\x03\x02\x02\x02\u0187\u018B\x07S\x02\x02\u0188\u018A\x05P)\x02\u0189" + + "\u0188\x03\x02\x02\x02\u018A\u018D\x03\x02\x02\x02\u018B\u0189\x03\x02" + + "\x02\x02\u018B\u018C\x03\x02\x02\x02\u018C\u018E\x03\x02\x02\x02\u018D" + + "\u018B\x03\x02\x02\x02\u018E\u0198\x07U\x02\x02\u018F\u0193\x07T\x02\x02" + + "\u0190\u0192\x05R*\x02\u0191\u0190\x03\x02\x02\x02\u0192\u0195\x03\x02" + + "\x02\x02\u0193\u0191\x03\x02\x02\x02\u0193\u0194\x03\x02\x02\x02\u0194" + + "\u0196\x03\x02\x02\x02\u0195\u0193\x03\x02\x02\x02\u0196\u0198\x07W\x02" + + "\x02\u0197\u0187\x03\x02\x02\x02\u0197\u018F\x03\x02\x02\x02\u0198O\x03" + + "\x02\x02\x02\u0199\u01A0\x07V\x02\x02\u019A\u019C\x07\x03\x02\x02\u019B" + + "\u019D\x05\x94K\x02\u019C\u019B\x03\x02\x02\x02\u019C\u019D\x03\x02\x02" + + "\x02\u019D\u019E\x03\x02\x02\x02\u019E\u01A0\x07*\x02\x02\u019F\u0199" + + "\x03\x02\x02\x02\u019F\u019A\x03\x02\x02\x02\u01A0Q\x03\x02\x02\x02\u01A1" + + "\u01A8\x07X\x02\x02\u01A2\u01A4\x07\x03\x02\x02\u01A3\u01A5\x05\x94K\x02" + + "\u01A4\u01A3\x03\x02\x02\x02\u01A4\u01A5\x03\x02\x02\x02\u01A5\u01A6\x03" + + "\x02\x02\x02\u01A6\u01A8\x07*\x02\x02\u01A7\u01A1\x03\x02\x02\x02\u01A7" + + "\u01A2\x03\x02\x02\x02\u01A8S\x03\x02\x02\x02\u01A9\u01AA\t\x06\x02\x02" + + "\u01AAU\x03\x02\x02\x02\u01AB\u01B4\x07(\x02\x02\u01AC\u01B1\x05\x94K" + + '\x02\u01AD\u01AE\x07"\x02\x02\u01AE\u01B0\x05\x94K\x02\u01AF\u01AD\x03' + + "\x02\x02\x02\u01B0\u01B3\x03\x02\x02\x02\u01B1\u01AF\x03\x02\x02\x02\u01B1" + + "\u01B2\x03\x02\x02\x02\u01B2\u01B5\x03\x02\x02\x02\u01B3\u01B1\x03\x02" + + "\x02\x02\u01B4\u01AC\x03\x02\x02\x02\u01B4\u01B5\x03\x02\x02\x02\u01B5" + + '\u01B7\x03\x02\x02\x02\u01B6\u01B8\x07"\x02\x02\u01B7\u01B6\x03\x02\x02' + + "\x02\u01B7\u01B8\x03\x02\x02\x02\u01B8\u01B9\x03\x02\x02\x02\u01B9\u01BA" + + "\x07)\x02\x02\u01BAW\x03\x02\x02\x02\u01BB\u01C4\x07+\x02\x02\u01BC\u01C1" + + '\x05Z.\x02\u01BD\u01BE\x07"\x02\x02\u01BE\u01C0\x05Z.\x02\u01BF\u01BD' + + "\x03\x02\x02\x02\u01C0\u01C3\x03\x02\x02\x02\u01C1\u01BF\x03\x02\x02\x02" + + "\u01C1\u01C2\x03\x02\x02\x02\u01C2\u01C5\x03\x02\x02\x02\u01C3\u01C1\x03" + + "\x02\x02\x02\u01C4\u01BC\x03\x02\x02\x02\u01C4\u01C5\x03\x02\x02\x02\u01C5" + + '\u01C7\x03\x02\x02\x02\u01C6\u01C8\x07"\x02\x02\u01C7\u01C6\x03\x02\x02' + + "\x02\u01C7\u01C8\x03\x02\x02\x02\u01C8\u01C9\x03\x02\x02\x02\u01C9\u01CA" + + "\x07,\x02\x02\u01CAY\x03\x02\x02\x02\u01CB\u01CC\x05J&\x02\u01CC\u01CD" + + "\x07%\x02\x02\u01CD\u01CE\x05\x94K\x02\u01CE[\x03\x02\x02\x02\u01CF\u01D0" + + "\t\x07\x02\x02\u01D0]\x03\x02\x02\x02\u01D1\u01D2\b0\x01\x02\u01D2\u01DD" + + "\x05> \x02\u01D3\u01D4\x07\x18\x02\x02\u01D4\u01D5\x05^0\x02\u01D5\u01D7" + + "\x07&\x02\x02\u01D6\u01D8\x05`1\x02\u01D7\u01D6\x03\x02\x02\x02\u01D7" + + "\u01D8\x03\x02\x02\x02\u01D8\u01D9\x03\x02\x02\x02\u01D9\u01DA\x07'\x02" + + "\x02\u01DA\u01DB\b0\x01\x02\u01DB\u01DD\x03\x02\x02\x02\u01DC\u01D1\x03" + + "\x02\x02\x02\u01DC\u01D3\x03\x02\x02\x02\u01DD\u01F3\x03\x02\x02\x02\u01DE" + + "\u01DF\f\x07\x02\x02\u01DF\u01E1\x07&\x02\x02\u01E0\u01E2\x05`1\x02\u01E1" + + "\u01E0\x03\x02\x02\x02\u01E1\u01E2\x03\x02\x02\x02\u01E2\u01E3\x03\x02" + + "\x02\x02\u01E3\u01E4\x07'\x02\x02\u01E4\u01F2\b0\x01\x02\u01E5\u01E6" + + "\f\x05\x02\x02\u01E6\u01E7\x05b2\x02\u01E7\u01E8\b0\x01\x02\u01E8\u01F2" + + "\x03\x02\x02\x02\u01E9\u01EA\f\x04\x02\x02\u01EA\u01EB\x05d3\x02\u01EB" + + "\u01EC\b0\x01\x02\u01EC\u01F2\x03\x02\x02\x02\u01ED\u01EE\f\x03\x02\x02" + + "\u01EE\u01EF\x05f4\x02\u01EF\u01F0\b0\x01\x02\u01F0\u01F2\x03\x02\x02" + + "\x02\u01F1\u01DE\x03\x02\x02\x02\u01F1\u01E5\x03\x02\x02\x02\u01F1\u01E9" + + "\x03\x02\x02\x02\u01F1\u01ED\x03\x02\x02\x02\u01F2\u01F5\x03\x02\x02\x02" + + "\u01F3\u01F1\x03\x02\x02\x02\u01F3\u01F4\x03\x02\x02\x02\u01F4_\x03\x02" + + "\x02\x02\u01F5\u01F3\x03\x02\x02\x02\u01F6\u01FB\x05\x90I\x02\u01F7\u01F8" + + '\x07"\x02\x02\u01F8\u01FA\x05\x90I\x02\u01F9\u01F7\x03\x02\x02\x02\u01FA' + + "\u01FD\x03\x02\x02\x02\u01FB\u01F9\x03\x02\x02\x02\u01FB\u01FC\x03\x02" + + "\x02\x02\u01FCa\x03\x02\x02\x02\u01FD\u01FB\x03\x02\x02\x02\u01FE\u01FF" + + "\x07K\x02\x02\u01FF\u0200\x05H%\x02\u0200c\x03\x02\x02\x02\u0201\u0202" + + "\x07(\x02\x02\u0202\u0203\x05\x94K\x02\u0203\u0204\x07)\x02\x02\u0204" + + "e\x03\x02\x02\x02\u0205\u0209\x07(\x02\x02\u0206\u0207\x05\x94K\x02\u0207" + + "\u0208\b4\x01\x02\u0208\u020A\x03\x02\x02\x02\u0209\u0206\x03\x02\x02" + + "\x02\u0209\u020A\x03\x02\x02\x02\u020A\u020B\x03\x02\x02\x02\u020B\u020F" + + "\x07%\x02\x02\u020C\u020D\x05\x94K\x02\u020D\u020E\b4\x01\x02\u020E\u0210" + + "\x03\x02\x02\x02\u020F\u020C\x03\x02\x02\x02\u020F\u0210\x03\x02\x02\x02" + + "\u0210\u0211\x03\x02\x02\x02\u0211\u0212\x07)\x02\x02\u0212g\x03\x02\x02" + + "\x02\u0213\u0216\x05^0\x02\u0214\u0216\x05j6\x02\u0215\u0213\x03\x02\x02" + + "\x02\u0215\u0214\x03\x02\x02\x02\u0216i\x03\x02\x02\x02\u0217\u0218\x05" + + "^0\x02\u0218\u0219\x05r:\x02\u0219k\x03\x02\x02\x02\u021A\u021E\x05h5" + + "\x02\u021B\u021E\x05n8\x02\u021C\u021E\x05p9\x02\u021D\u021A\x03\x02\x02" + + "\x02\u021D\u021B\x03\x02\x02\x02\u021D\u021C\x03\x02\x02\x02\u021Em\x03" + + "\x02\x02\x02\u021F\u0220\x05r:\x02\u0220\u0221\x05h5\x02\u0221o\x03\x02" + + "\x02\x02\u0222\u0223\x05t;\x02\u0223\u0224\x05h5\x02\u0224q\x03\x02\x02" + + "\x02\u0225\u0226\t\b\x02\x02\u0226s\x03\x02"; + private static readonly _serializedATNSegment1: string = + "\x02\x02\u0227\u0228\t\t\x02\x02\u0228u\x03\x02\x02\x02\u0229\u022F\x05" + + "l7\x02\u022A\u022B\x05l7\x02\u022B\u022C\x07\t\x02\x02\u022C\u022D\x05" + + "\x96L\x02\u022D\u022F\x03\x02\x02\x02\u022E\u0229\x03\x02\x02\x02\u022E" + + "\u022A\x03\x02\x02\x02\u022Fw\x03\x02\x02\x02\u0230\u0231\b=\x01\x02\u0231" + + "\u0232\x05v<\x02\u0232\u0238\x03\x02\x02\x02\u0233\u0234\f\x03\x02\x02" + + "\u0234\u0235\t\n\x02\x02\u0235\u0237\x05v<\x02\u0236\u0233\x03\x02\x02" + + "\x02\u0237\u023A\x03\x02\x02\x02\u0238\u0236\x03\x02\x02\x02\u0238\u0239" + + "\x03\x02\x02\x02\u0239y\x03\x02\x02\x02\u023A\u0238\x03\x02\x02\x02\u023B" + + "\u023C\b>\x01\x02\u023C\u023D\x05x=\x02\u023D\u0243\x03\x02\x02\x02\u023E" + + "\u023F\f\x03\x02\x02\u023F\u0240\t\v\x02\x02\u0240\u0242\x05x=\x02\u0241" + + "\u023E\x03\x02\x02\x02\u0242\u0245\x03\x02\x02\x02\u0243\u0241\x03\x02" + + "\x02\x02\u0243\u0244\x03\x02\x02\x02\u0244{\x03\x02\x02\x02\u0245\u0243" + + "\x03\x02\x02\x02\u0246\u0247\b?\x01\x02\u0247\u0248\x05z>\x02\u0248\u024F" + + "\x03\x02\x02\x02\u0249\u024A\f\x03\x02\x02\u024A\u024B\x05~@\x02\u024B" + + "\u024C\x05\x84C\x02\u024C\u024E\x03\x02\x02\x02\u024D\u0249\x03\x02\x02" + + "\x02\u024E\u0251\x03\x02\x02\x02\u024F\u024D\x03\x02\x02\x02\u024F\u0250" + + "\x03\x02\x02\x02\u0250}\x03\x02\x02\x02\u0251\u024F\x03\x02\x02\x02\u0252" + + "\u0253\t\f\x02\x02\u0253\x7F\x03\x02\x02\x02\u0254\u0255\bA\x01\x02\u0255" + + "\u0256\x05|?\x02\u0256\u025C\x03\x02\x02\x02\u0257\u0258\f\x03\x02\x02" + + "\u0258\u0259\t\r\x02\x02\u0259\u025B\x05|?\x02\u025A\u0257\x03\x02\x02" + + "\x02\u025B\u025E\x03\x02\x02\x02\u025C\u025A\x03\x02\x02\x02\u025C\u025D" + + "\x03\x02\x02\x02\u025D\x81\x03\x02\x02\x02\u025E\u025C\x03\x02\x02\x02" + + "\u025F\u0260\bB\x01\x02\u0260\u0261\x05\x80A\x02\u0261\u0267\x03\x02\x02" + + "\x02\u0262\u0263\f\x03\x02\x02\u0263\u0264\t\x0E\x02\x02\u0264\u0266\x05" + + "\x80A\x02\u0265\u0262\x03\x02\x02\x02\u0266\u0269\x03\x02\x02\x02\u0267" + + "\u0265\x03\x02\x02\x02\u0267\u0268\x03\x02\x02\x02\u0268\x83\x03\x02\x02" + + "\x02\u0269\u0267\x03\x02\x02\x02\u026A\u026B\bC\x01\x02\u026B\u026C\x05" + + "\x82B\x02\u026C\u0272\x03\x02\x02\x02\u026D\u026E\f\x03\x02\x02\u026E" + + "\u026F\x07D\x02\x02\u026F\u0271\x05\x82B\x02\u0270\u026D\x03\x02\x02\x02" + + "\u0271\u0274\x03\x02\x02\x02\u0272\u0270\x03\x02\x02\x02\u0272\u0273\x03" + + "\x02\x02\x02\u0273\x85\x03\x02\x02\x02\u0274\u0272\x03\x02\x02\x02\u0275" + + "\u0276\bD\x01\x02\u0276\u0277\x05\x84C\x02\u0277\u027D\x03\x02\x02\x02" + + "\u0278\u0279\f\x03\x02\x02\u0279\u027A\x07F\x02\x02\u027A\u027C\x05\x84" + + "C\x02\u027B\u0278\x03\x02\x02\x02\u027C\u027F\x03\x02\x02\x02\u027D\u027B" + + "\x03\x02\x02\x02\u027D\u027E\x03\x02\x02\x02\u027E\x87\x03\x02\x02\x02" + + "\u027F\u027D\x03\x02\x02\x02\u0280\u0281\bE\x01\x02\u0281\u0282\x05\x86" + + "D\x02\u0282\u0288\x03\x02\x02\x02\u0283\u0284\f\x03\x02\x02\u0284\u0285" + + "\x07E\x02\x02\u0285\u0287\x05\x86D\x02\u0286\u0283\x03\x02\x02\x02\u0287" + + "\u028A\x03\x02\x02\x02\u0288\u0286\x03\x02\x02\x02\u0288\u0289\x03\x02" + + "\x02\x02\u0289\x89\x03\x02\x02\x02\u028A\u0288\x03\x02\x02\x02\u028B\u028C" + + "\bF\x01\x02\u028C\u028D\x05\x88E\x02\u028D\u0293\x03\x02\x02\x02\u028E" + + "\u028F\f\x03\x02\x02\u028F\u0290\x075\x02\x02\u0290\u0292\x05\x88E\x02" + + "\u0291\u028E\x03\x02\x02\x02\u0292\u0295\x03\x02\x02\x02\u0293\u0291\x03" + + "\x02\x02\x02\u0293\u0294\x03\x02\x02\x02\u0294\x8B\x03\x02\x02\x02\u0295" + + "\u0293\x03\x02\x02\x02\u0296\u0297\bG\x01\x02\u0297\u0298\x05\x8AF\x02" + + "\u0298\u029E\x03\x02\x02\x02\u0299\u029A\f\x03\x02\x02\u029A\u029B\x07" + + "6\x02\x02\u029B\u029D\x05\x8AF\x02\u029C\u0299\x03\x02\x02\x02\u029D\u02A0" + + "\x03\x02\x02\x02\u029E\u029C\x03\x02\x02\x02\u029E\u029F\x03\x02\x02\x02" + + "\u029F\x8D\x03\x02\x02\x02\u02A0\u029E\x03\x02\x02\x02\u02A1\u02A9\x05" + + "\x8CG\x02\u02A2\u02A3\x05\x8CG\x02\u02A3\u02A4\x07$\x02\x02\u02A4\u02A5" + + "\x05\x8EH\x02\u02A5\u02A6\x07%\x02\x02\u02A6\u02A7\x05\x8EH\x02\u02A7" + + "\u02A9\x03\x02\x02\x02\u02A8\u02A1\x03\x02\x02\x02\u02A8\u02A2\x03\x02" + + "\x02\x02\u02A9\x8F\x03\x02\x02\x02\u02AA\u02B0\x05\x8EH\x02\u02AB\u02AC" + + "\x05^0\x02\u02AC\u02AD\x05\x92J\x02\u02AD\u02AE\x05\x90I\x02\u02AE\u02B0" + + "\x03\x02\x02\x02\u02AF\u02AA\x03\x02\x02\x02\u02AF\u02AB\x03\x02\x02\x02" + + "\u02B0\x91\x03\x02\x02\x02\u02B1\u02B2\t\x0F\x02\x02\u02B2\x93\x03\x02" + + '\x02\x02\u02B3\u02B8\x05\x90I\x02\u02B4\u02B5\x07"\x02\x02\u02B5\u02B7' + + "\x05\x90I\x02\u02B6\u02B4\x03\x02\x02\x02\u02B7\u02BA\x03\x02\x02\x02" + + "\u02B8\u02B6\x03\x02\x02\x02\u02B8\u02B9\x03\x02\x02\x02\u02B9\x95\x03" + + "\x02\x02\x02\u02BA\u02B8\x03\x02\x02\x02\u02BB\u02BF\x05\x98M\x02\u02BC" + + "\u02BF\x05\x9AN\x02\u02BD\u02BF\x05\x9CO\x02\u02BE\u02BB\x03\x02\x02\x02" + + "\u02BE\u02BC\x03\x02\x02\x02\u02BE\u02BD\x03\x02\x02\x02\u02BF\x97\x03" + + "\x02\x02\x02\u02C0\u02C1\x05\x9EP\x02\u02C1\x99\x03\x02\x02\x02\u02C2" + + "\u02C3\x05\x9EP\x02\u02C3\u02C4\x07@\x02\x02\u02C4\u02C5\x05\x9EP\x02" + + "\u02C5\u02C6\x07B\x02\x02\u02C6\x9B\x03\x02\x02\x02\u02C7\u02C8\x07\x1E" + + "\x02\x02\u02C8\u02C9\x07&\x02\x02\u02C9\u02CA\x05\x9EP\x02\u02CA\u02CB" + + "\x07'\x02\x02\u02CB\x9D\x03\x02\x02\x02\u02CC\u02CD\t\x10\x02\x02\u02CD" + + "\x9F\x03\x02\x02\x02A\xA1\xA8\xAF\xB4\xBC\xC8\xD4\xDA\xE1\xF8\xFD\u0108" + + "\u0111\u011B\u0128\u012D\u0133\u0137\u013D\u0143\u015B\u0169\u016D\u0175" + + "\u0183\u018B\u0193\u0197\u019C\u019F\u01A4\u01A7\u01B1\u01B4\u01B7\u01C1" + + "\u01C4\u01C7\u01D7\u01DC\u01E1\u01F1\u01F3\u01FB\u0209\u020F\u0215\u021D" + + "\u022E\u0238\u0243\u024F\u025C\u0267\u0272\u027D\u0288\u0293\u029E\u02A8" + + "\u02AF\u02B8\u02BE"; + public static readonly _serializedATN: string = Utils.join( + [KipperParser._serializedATNSegment0, KipperParser._serializedATNSegment1], + "", + ); + public static __ATN: ATN; + public static get _ATN(): ATN { + if (!KipperParser.__ATN) { + KipperParser.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(KipperParser._serializedATN)); + } - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_compilationUnit; + return KipperParser.__ATN; } +} +export class CompilationUnitContext extends KipperParserRuleContext { public EOF(): TerminalNode { return this.getToken(KipperParser.EOF, 0); } @@ -5091,6 +5142,15 @@ export class CompilationUnitContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, TranslationUnitContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_compilationUnit; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterCompilationUnit) { @@ -5116,19 +5176,8 @@ export class CompilationUnitContext extends KipperParserRuleContext { } export class TranslationUnitContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_translationUnit; - } - public externalItem(): ExternalItemContext[]; - public externalItem(i: number): ExternalItemContext; - public externalItem(i?: number): ExternalItemContext | ExternalItemContext[] { if (i === undefined) { return this.getRuleContexts(ExternalItemContext); @@ -5137,6 +5186,15 @@ export class TranslationUnitContext extends KipperParserRuleContext { } } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_translationUnit; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterTranslationUnit) { @@ -5177,15 +5235,15 @@ export class ExternalItemContext extends KipperParserRuleContext { } export class ExternalBlockItemContext extends ExternalItemContext { + public blockItemList(): BlockItemListContext { + return this.getRuleContext(0, BlockItemListContext); + } + constructor(ctx: ExternalItemContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public blockItemList(): BlockItemListContext { - return this.getRuleContext(0, BlockItemListContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterExternalBlockItem) { @@ -5211,19 +5269,8 @@ export class ExternalBlockItemContext extends ExternalItemContext { } export class BlockItemListContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_blockItemList; - } - public blockItem(): BlockItemContext[]; - public blockItem(i: number): BlockItemContext; - public blockItem(i?: number): BlockItemContext | BlockItemContext[] { if (i === undefined) { return this.getRuleContexts(BlockItemContext); @@ -5232,6 +5279,15 @@ export class BlockItemListContext extends KipperParserRuleContext { } } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_blockItemList; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterBlockItemList) { @@ -5257,15 +5313,6 @@ export class BlockItemListContext extends KipperParserRuleContext { } export class BlockItemContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_blockItem; - } - public statement(): StatementContext | undefined { return this.tryGetRuleContext(0, StatementContext); } @@ -5278,6 +5325,15 @@ export class BlockItemContext extends KipperParserRuleContext { return this.tryGetToken(KipperParser.SemiColon, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_blockItem; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterBlockItem) { @@ -5303,15 +5359,6 @@ export class BlockItemContext extends KipperParserRuleContext { } export class DeclarationContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_declaration; - } - public variableDeclaration(): VariableDeclarationContext | undefined { return this.tryGetRuleContext(0, VariableDeclarationContext); } @@ -5324,6 +5371,23 @@ export class DeclarationContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, FunctionDeclarationContext); } + public interfaceDeclaration(): InterfaceDeclarationContext | undefined { + return this.tryGetRuleContext(0, InterfaceDeclarationContext); + } + + public classDeclaration(): ClassDeclarationContext | undefined { + return this.tryGetRuleContext(0, ClassDeclarationContext); + } + + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_declaration; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterDeclaration) { @@ -5348,150 +5412,176 @@ export class DeclarationContext extends KipperParserRuleContext { } } -export class FunctionDeclarationContext extends KipperParserRuleContext { +export class VariableDeclarationContext extends KipperParserRuleContext { + public storageTypeSpecifier(): StorageTypeSpecifierContext { + return this.getRuleContext(0, StorageTypeSpecifierContext); + } + + public initDeclarator(): InitDeclaratorContext { + return this.getRuleContext(0, InitDeclaratorContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override public get ruleIndex(): number { - return KipperParser.RULE_functionDeclaration; - } - - public DefFunc(): TerminalNode { - return this.getToken(KipperParser.DefFunc, 0); + return KipperParser.RULE_variableDeclaration; } - public declarator(): DeclaratorContext { - return this.getRuleContext(0, DeclaratorContext); + // @Override + public enterRule(listener: KipperParserListener): void { + if (listener.enterVariableDeclaration) { + listener.enterVariableDeclaration(this); + } } - public LeftParen(): TerminalNode { - return this.getToken(KipperParser.LeftParen, 0); + // @Override + public exitRule(listener: KipperParserListener): void { + if (listener.exitVariableDeclaration) { + listener.exitVariableDeclaration(this); + } } - public RightParen(): TerminalNode { - return this.getToken(KipperParser.RightParen, 0); + // @Override + public accept(visitor: KipperParserVisitor): Result { + if (visitor.visitVariableDeclaration) { + return visitor.visitVariableDeclaration(this); + } else { + return visitor.visitChildren(this); + } } +} - public RetIndicator(): TerminalNode { - return this.getToken(KipperParser.RetIndicator, 0); +export class StorageTypeSpecifierContext extends KipperParserRuleContext { + public Var(): TerminalNode | undefined { + return this.tryGetToken(KipperParser.Var, 0); } - public typeSpecifierExpression(): TypeSpecifierExpressionContext { - return this.getRuleContext(0, TypeSpecifierExpressionContext); + public Const(): TerminalNode | undefined { + return this.tryGetToken(KipperParser.Const, 0); } - public parameterList(): ParameterListContext | undefined { - return this.tryGetRuleContext(0, ParameterListContext); + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); } - public compoundStatement(): CompoundStatementContext | undefined { - return this.tryGetRuleContext(0, CompoundStatementContext); + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_storageTypeSpecifier; } // @Override public enterRule(listener: KipperParserListener): void { - if (listener.enterFunctionDeclaration) { - listener.enterFunctionDeclaration(this); + if (listener.enterStorageTypeSpecifier) { + listener.enterStorageTypeSpecifier(this); } } // @Override public exitRule(listener: KipperParserListener): void { - if (listener.exitFunctionDeclaration) { - listener.exitFunctionDeclaration(this); + if (listener.exitStorageTypeSpecifier) { + listener.exitStorageTypeSpecifier(this); } } // @Override public accept(visitor: KipperParserVisitor): Result { - if (visitor.visitFunctionDeclaration) { - return visitor.visitFunctionDeclaration(this); + if (visitor.visitStorageTypeSpecifier) { + return visitor.visitStorageTypeSpecifier(this); } else { return visitor.visitChildren(this); } } } -export class VariableDeclarationContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); +export class InitDeclaratorContext extends KipperParserRuleContext { + public declarator(): DeclaratorContext { + return this.getRuleContext(0, DeclaratorContext); } - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_variableDeclaration; + public Colon(): TerminalNode { + return this.getToken(KipperParser.Colon, 0); } - public storageTypeSpecifier(): StorageTypeSpecifierContext { - return this.getRuleContext(0, StorageTypeSpecifierContext); + public typeSpecifierExpression(): TypeSpecifierExpressionContext { + return this.getRuleContext(0, TypeSpecifierExpressionContext); } - public initDeclarator(): InitDeclaratorContext { - return this.getRuleContext(0, InitDeclaratorContext); + public Assign(): TerminalNode | undefined { + return this.tryGetToken(KipperParser.Assign, 0); + } + + public initializer(): InitializerContext | undefined { + return this.tryGetRuleContext(0, InitializerContext); + } + + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_initDeclarator; } // @Override public enterRule(listener: KipperParserListener): void { - if (listener.enterVariableDeclaration) { - listener.enterVariableDeclaration(this); + if (listener.enterInitDeclarator) { + listener.enterInitDeclarator(this); } } // @Override public exitRule(listener: KipperParserListener): void { - if (listener.exitVariableDeclaration) { - listener.exitVariableDeclaration(this); + if (listener.exitInitDeclarator) { + listener.exitInitDeclarator(this); } } // @Override public accept(visitor: KipperParserVisitor): Result { - if (visitor.visitVariableDeclaration) { - return visitor.visitVariableDeclaration(this); + if (visitor.visitInitDeclarator) { + return visitor.visitInitDeclarator(this); } else { return visitor.visitChildren(this); } } } -export class StorageTypeSpecifierContext extends KipperParserRuleContext { +export class InitializerContext extends KipperParserRuleContext { + public assignmentExpression(): AssignmentExpressionContext { + return this.getRuleContext(0, AssignmentExpressionContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override public get ruleIndex(): number { - return KipperParser.RULE_storageTypeSpecifier; - } - - public Var(): TerminalNode | undefined { - return this.tryGetToken(KipperParser.Var, 0); - } - - public Const(): TerminalNode | undefined { - return this.tryGetToken(KipperParser.Const, 0); + return KipperParser.RULE_initializer; } // @Override public enterRule(listener: KipperParserListener): void { - if (listener.enterStorageTypeSpecifier) { - listener.enterStorageTypeSpecifier(this); + if (listener.enterInitializer) { + listener.enterInitializer(this); } } // @Override public exitRule(listener: KipperParserListener): void { - if (listener.exitStorageTypeSpecifier) { - listener.exitStorageTypeSpecifier(this); + if (listener.exitInitializer) { + listener.exitInitializer(this); } } // @Override public accept(visitor: KipperParserVisitor): Result { - if (visitor.visitStorageTypeSpecifier) { - return visitor.visitStorageTypeSpecifier(this); + if (visitor.visitInitializer) { + return visitor.visitInitializer(this); } else { return visitor.visitChildren(this); } @@ -5499,6 +5589,10 @@ export class StorageTypeSpecifierContext extends KipperParserRuleContext { } export class DeclaratorContext extends KipperParserRuleContext { + public directDeclarator(): DirectDeclaratorContext { + return this.getRuleContext(0, DirectDeclaratorContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -5508,10 +5602,6 @@ export class DeclaratorContext extends KipperParserRuleContext { return KipperParser.RULE_declarator; } - public directDeclarator(): DirectDeclaratorContext { - return this.getRuleContext(0, DirectDeclaratorContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterDeclarator) { @@ -5537,6 +5627,10 @@ export class DeclaratorContext extends KipperParserRuleContext { } export class DirectDeclaratorContext extends KipperParserRuleContext { + public Identifier(): TerminalNode { + return this.getToken(KipperParser.Identifier, 0); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -5546,10 +5640,6 @@ export class DirectDeclaratorContext extends KipperParserRuleContext { return KipperParser.RULE_directDeclarator; } - public Identifier(): TerminalNode { - return this.getToken(KipperParser.Identifier, 0); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterDirectDeclarator) { @@ -5574,54 +5664,66 @@ export class DirectDeclaratorContext extends KipperParserRuleContext { } } -export class InitDeclaratorContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_initDeclarator; +export class FunctionDeclarationContext extends KipperParserRuleContext { + public DefFunc(): TerminalNode { + return this.getToken(KipperParser.DefFunc, 0); } public declarator(): DeclaratorContext { return this.getRuleContext(0, DeclaratorContext); } - public Colon(): TerminalNode { - return this.getToken(KipperParser.Colon, 0); + public LeftParen(): TerminalNode { + return this.getToken(KipperParser.LeftParen, 0); + } + + public RightParen(): TerminalNode { + return this.getToken(KipperParser.RightParen, 0); + } + + public RetIndicator(): TerminalNode { + return this.getToken(KipperParser.RetIndicator, 0); } public typeSpecifierExpression(): TypeSpecifierExpressionContext { return this.getRuleContext(0, TypeSpecifierExpressionContext); } - public Assign(): TerminalNode | undefined { - return this.tryGetToken(KipperParser.Assign, 0); + public parameterList(): ParameterListContext | undefined { + return this.tryGetRuleContext(0, ParameterListContext); } - public initializer(): InitializerContext | undefined { - return this.tryGetRuleContext(0, InitializerContext); + public compoundStatement(): CompoundStatementContext | undefined { + return this.tryGetRuleContext(0, CompoundStatementContext); + } + + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_functionDeclaration; } // @Override public enterRule(listener: KipperParserListener): void { - if (listener.enterInitDeclarator) { - listener.enterInitDeclarator(this); + if (listener.enterFunctionDeclaration) { + listener.enterFunctionDeclaration(this); } } // @Override public exitRule(listener: KipperParserListener): void { - if (listener.exitInitDeclarator) { - listener.exitInitDeclarator(this); + if (listener.exitFunctionDeclaration) { + listener.exitFunctionDeclaration(this); } } // @Override public accept(visitor: KipperParserVisitor): Result { - if (visitor.visitInitDeclarator) { - return visitor.visitInitDeclarator(this); + if (visitor.visitFunctionDeclaration) { + return visitor.visitFunctionDeclaration(this); } else { return visitor.visitChildren(this); } @@ -5629,19 +5731,8 @@ export class InitDeclaratorContext extends KipperParserRuleContext { } export class ParameterListContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_parameterList; - } - public parameterDeclaration(): ParameterDeclarationContext[]; - public parameterDeclaration(i: number): ParameterDeclarationContext; - public parameterDeclaration(i?: number): ParameterDeclarationContext | ParameterDeclarationContext[] { if (i === undefined) { return this.getRuleContexts(ParameterDeclarationContext); @@ -5651,9 +5742,7 @@ export class ParameterListContext extends KipperParserRuleContext { } public Comma(): TerminalNode[]; - public Comma(i: number): TerminalNode; - public Comma(i?: number): TerminalNode | TerminalNode[] { if (i === undefined) { return this.getTokens(KipperParser.Comma); @@ -5662,6 +5751,15 @@ export class ParameterListContext extends KipperParserRuleContext { } } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_parameterList; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterParameterList) { @@ -5687,15 +5785,6 @@ export class ParameterListContext extends KipperParserRuleContext { } export class ParameterDeclarationContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_parameterDeclaration; - } - public declarator(): DeclaratorContext { return this.getRuleContext(0, DeclaratorContext); } @@ -5708,6 +5797,15 @@ export class ParameterDeclarationContext extends KipperParserRuleContext { return this.getRuleContext(0, TypeSpecifierExpressionContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_parameterDeclaration; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterParameterDeclaration) { @@ -5732,54 +5830,107 @@ export class ParameterDeclarationContext extends KipperParserRuleContext { } } -export class InitializerContext extends KipperParserRuleContext { +export class InterfaceDeclarationContext extends KipperParserRuleContext { + public Interface(): TerminalNode { + return this.getToken(KipperParser.Interface, 0); + } + + public Identifier(): TerminalNode { + return this.getToken(KipperParser.Identifier, 0); + } + + public LeftBrace(): TerminalNode { + return this.getToken(KipperParser.LeftBrace, 0); + } + + public RightBrace(): TerminalNode { + return this.getToken(KipperParser.RightBrace, 0); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override public get ruleIndex(): number { - return KipperParser.RULE_initializer; - } - - public assignmentExpression(): AssignmentExpressionContext { - return this.getRuleContext(0, AssignmentExpressionContext); + return KipperParser.RULE_interfaceDeclaration; } // @Override public enterRule(listener: KipperParserListener): void { - if (listener.enterInitializer) { - listener.enterInitializer(this); + if (listener.enterInterfaceDeclaration) { + listener.enterInterfaceDeclaration(this); } } // @Override public exitRule(listener: KipperParserListener): void { - if (listener.exitInitializer) { - listener.exitInitializer(this); + if (listener.exitInterfaceDeclaration) { + listener.exitInterfaceDeclaration(this); } } // @Override public accept(visitor: KipperParserVisitor): Result { - if (visitor.visitInitializer) { - return visitor.visitInitializer(this); + if (visitor.visitInterfaceDeclaration) { + return visitor.visitInterfaceDeclaration(this); } else { return visitor.visitChildren(this); } } } -export class StatementContext extends KipperParserRuleContext { +export class ClassDeclarationContext extends KipperParserRuleContext { + public Class(): TerminalNode { + return this.getToken(KipperParser.Class, 0); + } + + public Identifier(): TerminalNode { + return this.getToken(KipperParser.Identifier, 0); + } + + public LeftBrace(): TerminalNode { + return this.getToken(KipperParser.LeftBrace, 0); + } + + public RightBrace(): TerminalNode { + return this.getToken(KipperParser.RightBrace, 0); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } // @Override public get ruleIndex(): number { - return KipperParser.RULE_statement; + return KipperParser.RULE_classDeclaration; + } + + // @Override + public enterRule(listener: KipperParserListener): void { + if (listener.enterClassDeclaration) { + listener.enterClassDeclaration(this); + } } + // @Override + public exitRule(listener: KipperParserListener): void { + if (listener.exitClassDeclaration) { + listener.exitClassDeclaration(this); + } + } + + // @Override + public accept(visitor: KipperParserVisitor): Result { + if (visitor.visitClassDeclaration) { + return visitor.visitClassDeclaration(this); + } else { + return visitor.visitChildren(this); + } + } +} + +export class StatementContext extends KipperParserRuleContext { public expressionStatement(): ExpressionStatementContext | undefined { return this.tryGetRuleContext(0, ExpressionStatementContext); } @@ -5804,6 +5955,15 @@ export class StatementContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, CompoundStatementContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_statement; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterStatement) { @@ -5829,15 +5989,6 @@ export class StatementContext extends KipperParserRuleContext { } export class CompoundStatementContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_compoundStatement; - } - public LeftBrace(): TerminalNode { return this.getToken(KipperParser.LeftBrace, 0); } @@ -5850,6 +6001,15 @@ export class CompoundStatementContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, BlockItemListContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_compoundStatement; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterCompoundStatement) { @@ -5875,6 +6035,14 @@ export class CompoundStatementContext extends KipperParserRuleContext { } export class ExpressionStatementContext extends KipperParserRuleContext { + public expression(): ExpressionContext { + return this.getRuleContext(0, ExpressionContext); + } + + public SemiColon(): TerminalNode { + return this.getToken(KipperParser.SemiColon, 0); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -5884,14 +6052,6 @@ export class ExpressionStatementContext extends KipperParserRuleContext { return KipperParser.RULE_expressionStatement; } - public expression(): ExpressionContext { - return this.getRuleContext(0, ExpressionContext); - } - - public SemiColon(): TerminalNode { - return this.getToken(KipperParser.SemiColon, 0); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterExpressionStatement) { @@ -5917,6 +6077,14 @@ export class ExpressionStatementContext extends KipperParserRuleContext { } export class SelectionStatementContext extends KipperParserRuleContext { + public ifStatement(): IfStatementContext | undefined { + return this.tryGetRuleContext(0, IfStatementContext); + } + + public switchStatement(): SwitchStatementContext | undefined { + return this.tryGetRuleContext(0, SwitchStatementContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -5926,14 +6094,6 @@ export class SelectionStatementContext extends KipperParserRuleContext { return KipperParser.RULE_selectionStatement; } - public ifStatement(): IfStatementContext | undefined { - return this.tryGetRuleContext(0, IfStatementContext); - } - - public switchStatement(): SwitchStatementContext | undefined { - return this.tryGetRuleContext(0, SwitchStatementContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterSelectionStatement) { @@ -5959,15 +6119,6 @@ export class SelectionStatementContext extends KipperParserRuleContext { } export class IfStatementContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_ifStatement; - } - public If(): TerminalNode { return this.getToken(KipperParser.If, 0); } @@ -5985,9 +6136,7 @@ export class IfStatementContext extends KipperParserRuleContext { } public statement(): StatementContext[]; - public statement(i: number): StatementContext; - public statement(i?: number): StatementContext | StatementContext[] { if (i === undefined) { return this.getRuleContexts(StatementContext); @@ -6000,6 +6149,15 @@ export class IfStatementContext extends KipperParserRuleContext { return this.tryGetToken(KipperParser.Else, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_ifStatement; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterIfStatement) { @@ -6025,15 +6183,6 @@ export class IfStatementContext extends KipperParserRuleContext { } export class SwitchStatementContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_switchStatement; - } - public Switch(): TerminalNode { return this.getToken(KipperParser.Switch, 0); } @@ -6059,9 +6208,7 @@ export class SwitchStatementContext extends KipperParserRuleContext { } public switchLabeledStatement(): SwitchLabeledStatementContext[]; - public switchLabeledStatement(i: number): SwitchLabeledStatementContext; - public switchLabeledStatement(i?: number): SwitchLabeledStatementContext | SwitchLabeledStatementContext[] { if (i === undefined) { return this.getRuleContexts(SwitchLabeledStatementContext); @@ -6070,6 +6217,15 @@ export class SwitchStatementContext extends KipperParserRuleContext { } } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_switchStatement; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterSwitchStatement) { @@ -6095,15 +6251,6 @@ export class SwitchStatementContext extends KipperParserRuleContext { } export class SwitchLabeledStatementContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_switchLabeledStatement; - } - public Case(): TerminalNode | undefined { return this.tryGetToken(KipperParser.Case, 0); } @@ -6124,6 +6271,15 @@ export class SwitchLabeledStatementContext extends KipperParserRuleContext { return this.tryGetToken(KipperParser.Default, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_switchLabeledStatement; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterSwitchLabeledStatement) { @@ -6148,16 +6304,7 @@ export class SwitchLabeledStatementContext extends KipperParserRuleContext { } } -export class IterationStatementContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_iterationStatement; - } - +export class IterationStatementContext extends KipperParserRuleContext { public forLoopIterationStatement(): ForLoopIterationStatementContext | undefined { return this.tryGetRuleContext(0, ForLoopIterationStatementContext); } @@ -6170,6 +6317,15 @@ export class IterationStatementContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, DoWhileLoopIterationStatementContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_iterationStatement; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterIterationStatement) { @@ -6199,15 +6355,6 @@ export class ForLoopIterationStatementContext extends KipperParserRuleContext { public _forCondition: boolean = false; public _forIterationExp: boolean = false; - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_forLoopIterationStatement; - } - public For(): TerminalNode { return this.getToken(KipperParser.For, 0); } @@ -6217,9 +6364,7 @@ export class ForLoopIterationStatementContext extends KipperParserRuleContext { } public SemiColon(): TerminalNode[]; - public SemiColon(i: number): TerminalNode; - public SemiColon(i?: number): TerminalNode | TerminalNode[] { if (i === undefined) { return this.getTokens(KipperParser.SemiColon); @@ -6237,9 +6382,7 @@ export class ForLoopIterationStatementContext extends KipperParserRuleContext { } public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { if (i === undefined) { return this.getRuleContexts(ExpressionContext); @@ -6252,6 +6395,15 @@ export class ForLoopIterationStatementContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, VariableDeclarationContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_forLoopIterationStatement; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterForLoopIterationStatement) { @@ -6277,15 +6429,6 @@ export class ForLoopIterationStatementContext extends KipperParserRuleContext { } export class WhileLoopIterationStatementContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_whileLoopIterationStatement; - } - public While(): TerminalNode { return this.getToken(KipperParser.While, 0); } @@ -6306,6 +6449,15 @@ export class WhileLoopIterationStatementContext extends KipperParserRuleContext return this.getRuleContext(0, StatementContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_whileLoopIterationStatement; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterWhileLoopIterationStatement) { @@ -6331,15 +6483,6 @@ export class WhileLoopIterationStatementContext extends KipperParserRuleContext } export class DoWhileLoopIterationStatementContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_doWhileLoopIterationStatement; - } - public Do(): TerminalNode { return this.getToken(KipperParser.Do, 0); } @@ -6368,6 +6511,15 @@ export class DoWhileLoopIterationStatementContext extends KipperParserRuleContex return this.getToken(KipperParser.SemiColon, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_doWhileLoopIterationStatement; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterDoWhileLoopIterationStatement) { @@ -6393,15 +6545,6 @@ export class DoWhileLoopIterationStatementContext extends KipperParserRuleContex } export class JumpStatementContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_jumpStatement; - } - public SemiColon(): TerminalNode { return this.getToken(KipperParser.SemiColon, 0); } @@ -6414,6 +6557,15 @@ export class JumpStatementContext extends KipperParserRuleContext { return this.tryGetToken(KipperParser.Break, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_jumpStatement; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterJumpStatement) { @@ -6439,15 +6591,6 @@ export class JumpStatementContext extends KipperParserRuleContext { } export class ReturnStatementContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_returnStatement; - } - public Return(): TerminalNode { return this.getToken(KipperParser.Return, 0); } @@ -6460,6 +6603,15 @@ export class ReturnStatementContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, ExpressionContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_returnStatement; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterReturnStatement) { @@ -6485,15 +6637,6 @@ export class ReturnStatementContext extends KipperParserRuleContext { } export class PrimaryExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_primaryExpression; - } - public tangledPrimaryExpression(): TangledPrimaryExpressionContext | undefined { return this.tryGetRuleContext(0, TangledPrimaryExpressionContext); } @@ -6534,6 +6677,15 @@ export class PrimaryExpressionContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, LambdaExpressionContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_primaryExpression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPrimaryExpression) { @@ -6559,15 +6711,6 @@ export class PrimaryExpressionContext extends KipperParserRuleContext { } export class LambdaExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_lambdaExpression; - } - public LeftParen(): TerminalNode { return this.getToken(KipperParser.LeftParen, 0); } @@ -6600,6 +6743,15 @@ export class LambdaExpressionContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, ParameterListContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_lambdaExpression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterLambdaExpression) { @@ -6625,15 +6777,6 @@ export class LambdaExpressionContext extends KipperParserRuleContext { } export class TangledPrimaryExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_tangledPrimaryExpression; - } - public LeftParen(): TerminalNode { return this.getToken(KipperParser.LeftParen, 0); } @@ -6646,6 +6789,15 @@ export class TangledPrimaryExpressionContext extends KipperParserRuleContext { return this.getToken(KipperParser.RightParen, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_tangledPrimaryExpression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterTangledPrimaryExpression) { @@ -6671,6 +6823,14 @@ export class TangledPrimaryExpressionContext extends KipperParserRuleContext { } export class BoolPrimaryExpressionContext extends KipperParserRuleContext { + public True(): TerminalNode | undefined { + return this.tryGetToken(KipperParser.True, 0); + } + + public False(): TerminalNode | undefined { + return this.tryGetToken(KipperParser.False, 0); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -6680,14 +6840,6 @@ export class BoolPrimaryExpressionContext extends KipperParserRuleContext { return KipperParser.RULE_boolPrimaryExpression; } - public True(): TerminalNode | undefined { - return this.tryGetToken(KipperParser.True, 0); - } - - public False(): TerminalNode | undefined { - return this.tryGetToken(KipperParser.False, 0); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterBoolPrimaryExpression) { @@ -6713,6 +6865,10 @@ export class BoolPrimaryExpressionContext extends KipperParserRuleContext { } export class IdentifierPrimaryExpressionContext extends KipperParserRuleContext { + public identifier(): IdentifierContext { + return this.getRuleContext(0, IdentifierContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -6722,10 +6878,6 @@ export class IdentifierPrimaryExpressionContext extends KipperParserRuleContext return KipperParser.RULE_identifierPrimaryExpression; } - public identifier(): IdentifierContext { - return this.getRuleContext(0, IdentifierContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterIdentifierPrimaryExpression) { @@ -6751,6 +6903,10 @@ export class IdentifierPrimaryExpressionContext extends KipperParserRuleContext } export class IdentifierContext extends KipperParserRuleContext { + public Identifier(): TerminalNode { + return this.getToken(KipperParser.Identifier, 0); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -6760,10 +6916,6 @@ export class IdentifierContext extends KipperParserRuleContext { return KipperParser.RULE_identifier; } - public Identifier(): TerminalNode { - return this.getToken(KipperParser.Identifier, 0); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterIdentifier) { @@ -6789,6 +6941,14 @@ export class IdentifierContext extends KipperParserRuleContext { } export class IdentifierOrStringPrimaryExpressionContext extends KipperParserRuleContext { + public identifier(): IdentifierContext | undefined { + return this.tryGetRuleContext(0, IdentifierContext); + } + + public stringPrimaryExpression(): StringPrimaryExpressionContext | undefined { + return this.tryGetRuleContext(0, StringPrimaryExpressionContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -6798,14 +6958,6 @@ export class IdentifierOrStringPrimaryExpressionContext extends KipperParserRule return KipperParser.RULE_identifierOrStringPrimaryExpression; } - public identifier(): IdentifierContext | undefined { - return this.tryGetRuleContext(0, IdentifierContext); - } - - public stringPrimaryExpression(): StringPrimaryExpressionContext | undefined { - return this.tryGetRuleContext(0, StringPrimaryExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterIdentifierOrStringPrimaryExpression) { @@ -6831,6 +6983,14 @@ export class IdentifierOrStringPrimaryExpressionContext extends KipperParserRule } export class StringPrimaryExpressionContext extends KipperParserRuleContext { + public SingleQuoteStringLiteral(): TerminalNode | undefined { + return this.tryGetToken(KipperParser.SingleQuoteStringLiteral, 0); + } + + public DoubleQuoteStringLiteral(): TerminalNode | undefined { + return this.tryGetToken(KipperParser.DoubleQuoteStringLiteral, 0); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -6840,14 +7000,6 @@ export class StringPrimaryExpressionContext extends KipperParserRuleContext { return KipperParser.RULE_stringPrimaryExpression; } - public SingleQuoteStringLiteral(): TerminalNode | undefined { - return this.tryGetToken(KipperParser.SingleQuoteStringLiteral, 0); - } - - public DoubleQuoteStringLiteral(): TerminalNode | undefined { - return this.tryGetToken(KipperParser.DoubleQuoteStringLiteral, 0); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterStringPrimaryExpression) { @@ -6873,15 +7025,6 @@ export class StringPrimaryExpressionContext extends KipperParserRuleContext { } export class FStringPrimaryExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_fStringPrimaryExpression; - } - public FStringSingleQuoteStart(): TerminalNode | undefined { return this.tryGetToken(KipperParser.FStringSingleQuoteStart, 0); } @@ -6891,9 +7034,7 @@ export class FStringPrimaryExpressionContext extends KipperParserRuleContext { } public fStringSingleQuoteAtom(): FStringSingleQuoteAtomContext[]; - public fStringSingleQuoteAtom(i: number): FStringSingleQuoteAtomContext; - public fStringSingleQuoteAtom(i?: number): FStringSingleQuoteAtomContext | FStringSingleQuoteAtomContext[] { if (i === undefined) { return this.getRuleContexts(FStringSingleQuoteAtomContext); @@ -6911,9 +7052,7 @@ export class FStringPrimaryExpressionContext extends KipperParserRuleContext { } public fStringDoubleQuoteAtom(): FStringDoubleQuoteAtomContext[]; - public fStringDoubleQuoteAtom(i: number): FStringDoubleQuoteAtomContext; - public fStringDoubleQuoteAtom(i?: number): FStringDoubleQuoteAtomContext | FStringDoubleQuoteAtomContext[] { if (i === undefined) { return this.getRuleContexts(FStringDoubleQuoteAtomContext); @@ -6922,6 +7061,15 @@ export class FStringPrimaryExpressionContext extends KipperParserRuleContext { } } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_fStringPrimaryExpression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterFStringPrimaryExpression) { @@ -6942,20 +7090,11 @@ export class FStringPrimaryExpressionContext extends KipperParserRuleContext { return visitor.visitFStringPrimaryExpression(this); } else { return visitor.visitChildren(this); - } - } -} - -export class FStringSingleQuoteAtomContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_fStringSingleQuoteAtom; + } } +} +export class FStringSingleQuoteAtomContext extends KipperParserRuleContext { public FStringSingleQuoteAtom(): TerminalNode | undefined { return this.tryGetToken(KipperParser.FStringSingleQuoteAtom, 0); } @@ -6972,6 +7111,15 @@ export class FStringSingleQuoteAtomContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, ExpressionContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_fStringSingleQuoteAtom; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterFStringSingleQuoteAtom) { @@ -6997,15 +7145,6 @@ export class FStringSingleQuoteAtomContext extends KipperParserRuleContext { } export class FStringDoubleQuoteAtomContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_fStringDoubleQuoteAtom; - } - public FStringDoubleQuoteAtom(): TerminalNode | undefined { return this.tryGetToken(KipperParser.FStringDoubleQuoteAtom, 0); } @@ -7022,6 +7161,15 @@ export class FStringDoubleQuoteAtomContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, ExpressionContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_fStringDoubleQuoteAtom; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterFStringDoubleQuoteAtom) { @@ -7047,6 +7195,14 @@ export class FStringDoubleQuoteAtomContext extends KipperParserRuleContext { } export class NumberPrimaryExpressionContext extends KipperParserRuleContext { + public IntegerConstant(): TerminalNode | undefined { + return this.tryGetToken(KipperParser.IntegerConstant, 0); + } + + public FloatingConstant(): TerminalNode | undefined { + return this.tryGetToken(KipperParser.FloatingConstant, 0); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -7056,14 +7212,6 @@ export class NumberPrimaryExpressionContext extends KipperParserRuleContext { return KipperParser.RULE_numberPrimaryExpression; } - public IntegerConstant(): TerminalNode | undefined { - return this.tryGetToken(KipperParser.IntegerConstant, 0); - } - - public FloatingConstant(): TerminalNode | undefined { - return this.tryGetToken(KipperParser.FloatingConstant, 0); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterNumberPrimaryExpression) { @@ -7089,15 +7237,6 @@ export class NumberPrimaryExpressionContext extends KipperParserRuleContext { } export class ArrayPrimaryExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_arrayPrimaryExpression; - } - public LeftBracket(): TerminalNode { return this.getToken(KipperParser.LeftBracket, 0); } @@ -7107,9 +7246,7 @@ export class ArrayPrimaryExpressionContext extends KipperParserRuleContext { } public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { if (i === undefined) { return this.getRuleContexts(ExpressionContext); @@ -7119,9 +7256,7 @@ export class ArrayPrimaryExpressionContext extends KipperParserRuleContext { } public Comma(): TerminalNode[]; - public Comma(i: number): TerminalNode; - public Comma(i?: number): TerminalNode | TerminalNode[] { if (i === undefined) { return this.getTokens(KipperParser.Comma); @@ -7130,6 +7265,15 @@ export class ArrayPrimaryExpressionContext extends KipperParserRuleContext { } } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_arrayPrimaryExpression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterArrayPrimaryExpression) { @@ -7155,15 +7299,6 @@ export class ArrayPrimaryExpressionContext extends KipperParserRuleContext { } export class ObjectPrimaryExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_objectPrimaryExpression; - } - public LeftBrace(): TerminalNode { return this.getToken(KipperParser.LeftBrace, 0); } @@ -7173,9 +7308,7 @@ export class ObjectPrimaryExpressionContext extends KipperParserRuleContext { } public objectProperty(): ObjectPropertyContext[]; - public objectProperty(i: number): ObjectPropertyContext; - public objectProperty(i?: number): ObjectPropertyContext | ObjectPropertyContext[] { if (i === undefined) { return this.getRuleContexts(ObjectPropertyContext); @@ -7185,9 +7318,7 @@ export class ObjectPrimaryExpressionContext extends KipperParserRuleContext { } public Comma(): TerminalNode[]; - public Comma(i: number): TerminalNode; - public Comma(i?: number): TerminalNode | TerminalNode[] { if (i === undefined) { return this.getTokens(KipperParser.Comma); @@ -7196,6 +7327,15 @@ export class ObjectPrimaryExpressionContext extends KipperParserRuleContext { } } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_objectPrimaryExpression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterObjectPrimaryExpression) { @@ -7221,15 +7361,6 @@ export class ObjectPrimaryExpressionContext extends KipperParserRuleContext { } export class ObjectPropertyContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_objectProperty; - } - public identifierOrStringPrimaryExpression(): IdentifierOrStringPrimaryExpressionContext { return this.getRuleContext(0, IdentifierOrStringPrimaryExpressionContext); } @@ -7242,6 +7373,15 @@ export class ObjectPropertyContext extends KipperParserRuleContext { return this.getRuleContext(0, ExpressionContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_objectProperty; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterObjectProperty) { @@ -7267,15 +7407,6 @@ export class ObjectPropertyContext extends KipperParserRuleContext { } export class VoidOrNullOrUndefinedPrimaryExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_voidOrNullOrUndefinedPrimaryExpression; - } - public Void(): TerminalNode | undefined { return this.tryGetToken(KipperParser.Void, 0); } @@ -7288,6 +7419,15 @@ export class VoidOrNullOrUndefinedPrimaryExpressionContext extends KipperParserR return this.tryGetToken(KipperParser.Undefined, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_voidOrNullOrUndefinedPrimaryExpression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterVoidOrNullOrUndefinedPrimaryExpression) { @@ -7331,15 +7471,15 @@ export class ComputedPrimaryExpressionContext extends KipperParserRuleContext { } export class PassOncomputedPrimaryExpressionContext extends ComputedPrimaryExpressionContext { + public primaryExpression(): PrimaryExpressionContext { + return this.getRuleContext(0, PrimaryExpressionContext); + } + constructor(ctx: ComputedPrimaryExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public primaryExpression(): PrimaryExpressionContext { - return this.getRuleContext(0, PrimaryExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOncomputedPrimaryExpression) { @@ -7365,11 +7505,6 @@ export class PassOncomputedPrimaryExpressionContext extends ComputedPrimaryExpre } export class FunctionCallExpressionContext extends ComputedPrimaryExpressionContext { - constructor(ctx: ComputedPrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public computedPrimaryExpression(): ComputedPrimaryExpressionContext { return this.getRuleContext(0, ComputedPrimaryExpressionContext); } @@ -7386,6 +7521,11 @@ export class FunctionCallExpressionContext extends ComputedPrimaryExpressionCont return this.tryGetRuleContext(0, ArgumentExpressionListContext); } + constructor(ctx: ComputedPrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterFunctionCallExpression) { @@ -7411,11 +7551,6 @@ export class FunctionCallExpressionContext extends ComputedPrimaryExpressionCont } export class ExplicitCallFunctionCallExpressionContext extends ComputedPrimaryExpressionContext { - constructor(ctx: ComputedPrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public CallFunc(): TerminalNode { return this.getToken(KipperParser.CallFunc, 0); } @@ -7436,6 +7571,11 @@ export class ExplicitCallFunctionCallExpressionContext extends ComputedPrimaryEx return this.tryGetRuleContext(0, ArgumentExpressionListContext); } + constructor(ctx: ComputedPrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterExplicitCallFunctionCallExpression) { @@ -7461,11 +7601,6 @@ export class ExplicitCallFunctionCallExpressionContext extends ComputedPrimaryEx } export class DotNotationMemberAccessExpressionContext extends ComputedPrimaryExpressionContext { - constructor(ctx: ComputedPrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public computedPrimaryExpression(): ComputedPrimaryExpressionContext { return this.getRuleContext(0, ComputedPrimaryExpressionContext); } @@ -7474,6 +7609,11 @@ export class DotNotationMemberAccessExpressionContext extends ComputedPrimaryExp return this.getRuleContext(0, DotNotationContext); } + constructor(ctx: ComputedPrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterDotNotationMemberAccessExpression) { @@ -7499,11 +7639,6 @@ export class DotNotationMemberAccessExpressionContext extends ComputedPrimaryExp } export class BracketNotationMemberAccessExpressionContext extends ComputedPrimaryExpressionContext { - constructor(ctx: ComputedPrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public computedPrimaryExpression(): ComputedPrimaryExpressionContext { return this.getRuleContext(0, ComputedPrimaryExpressionContext); } @@ -7512,6 +7647,11 @@ export class BracketNotationMemberAccessExpressionContext extends ComputedPrimar return this.getRuleContext(0, BracketNotationContext); } + constructor(ctx: ComputedPrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterBracketNotationMemberAccessExpression) { @@ -7537,11 +7677,6 @@ export class BracketNotationMemberAccessExpressionContext extends ComputedPrimar } export class SliceNotationMemberAccessExpressionContext extends ComputedPrimaryExpressionContext { - constructor(ctx: ComputedPrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public computedPrimaryExpression(): ComputedPrimaryExpressionContext { return this.getRuleContext(0, ComputedPrimaryExpressionContext); } @@ -7550,6 +7685,11 @@ export class SliceNotationMemberAccessExpressionContext extends ComputedPrimaryE return this.getRuleContext(0, SliceNotationContext); } + constructor(ctx: ComputedPrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterSliceNotationMemberAccessExpression) { @@ -7575,19 +7715,8 @@ export class SliceNotationMemberAccessExpressionContext extends ComputedPrimaryE } export class ArgumentExpressionListContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_argumentExpressionList; - } - public assignmentExpression(): AssignmentExpressionContext[]; - public assignmentExpression(i: number): AssignmentExpressionContext; - public assignmentExpression(i?: number): AssignmentExpressionContext | AssignmentExpressionContext[] { if (i === undefined) { return this.getRuleContexts(AssignmentExpressionContext); @@ -7597,9 +7726,7 @@ export class ArgumentExpressionListContext extends KipperParserRuleContext { } public Comma(): TerminalNode[]; - public Comma(i: number): TerminalNode; - public Comma(i?: number): TerminalNode | TerminalNode[] { if (i === undefined) { return this.getTokens(KipperParser.Comma); @@ -7608,6 +7735,15 @@ export class ArgumentExpressionListContext extends KipperParserRuleContext { } } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_argumentExpressionList; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterArgumentExpressionList) { @@ -7633,6 +7769,14 @@ export class ArgumentExpressionListContext extends KipperParserRuleContext { } export class DotNotationContext extends KipperParserRuleContext { + public Dot(): TerminalNode { + return this.getToken(KipperParser.Dot, 0); + } + + public identifier(): IdentifierContext { + return this.getRuleContext(0, IdentifierContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -7642,14 +7786,6 @@ export class DotNotationContext extends KipperParserRuleContext { return KipperParser.RULE_dotNotation; } - public Dot(): TerminalNode { - return this.getToken(KipperParser.Dot, 0); - } - - public identifier(): IdentifierContext { - return this.getRuleContext(0, IdentifierContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterDotNotation) { @@ -7675,15 +7811,6 @@ export class DotNotationContext extends KipperParserRuleContext { } export class BracketNotationContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_bracketNotation; - } - public LeftBracket(): TerminalNode { return this.getToken(KipperParser.LeftBracket, 0); } @@ -7696,6 +7823,15 @@ export class BracketNotationContext extends KipperParserRuleContext { return this.getToken(KipperParser.RightBracket, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_bracketNotation; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterBracketNotation) { @@ -7715,23 +7851,14 @@ export class BracketNotationContext extends KipperParserRuleContext { if (visitor.visitBracketNotation) { return visitor.visitBracketNotation(this); } else { - return visitor.visitChildren(this); - } - } -} - -export class SliceNotationContext extends KipperParserRuleContext { - public sliceStart: boolean = false; - public sliceEnd: boolean = false; - - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_sliceNotation; + return visitor.visitChildren(this); + } } +} + +export class SliceNotationContext extends KipperParserRuleContext { + public sliceStart: boolean = false; + public sliceEnd: boolean = false; public LeftBracket(): TerminalNode { return this.getToken(KipperParser.LeftBracket, 0); @@ -7746,9 +7873,7 @@ export class SliceNotationContext extends KipperParserRuleContext { } public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { if (i === undefined) { return this.getRuleContexts(ExpressionContext); @@ -7757,6 +7882,15 @@ export class SliceNotationContext extends KipperParserRuleContext { } } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_sliceNotation; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterSliceNotation) { @@ -7782,6 +7916,14 @@ export class SliceNotationContext extends KipperParserRuleContext { } export class PostfixExpressionContext extends KipperParserRuleContext { + public computedPrimaryExpression(): ComputedPrimaryExpressionContext | undefined { + return this.tryGetRuleContext(0, ComputedPrimaryExpressionContext); + } + + public incrementOrDecrementPostfixExpression(): IncrementOrDecrementPostfixExpressionContext | undefined { + return this.tryGetRuleContext(0, IncrementOrDecrementPostfixExpressionContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -7791,14 +7933,6 @@ export class PostfixExpressionContext extends KipperParserRuleContext { return KipperParser.RULE_postfixExpression; } - public computedPrimaryExpression(): ComputedPrimaryExpressionContext | undefined { - return this.tryGetRuleContext(0, ComputedPrimaryExpressionContext); - } - - public incrementOrDecrementPostfixExpression(): IncrementOrDecrementPostfixExpressionContext | undefined { - return this.tryGetRuleContext(0, IncrementOrDecrementPostfixExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPostfixExpression) { @@ -7824,6 +7958,14 @@ export class PostfixExpressionContext extends KipperParserRuleContext { } export class IncrementOrDecrementPostfixExpressionContext extends KipperParserRuleContext { + public computedPrimaryExpression(): ComputedPrimaryExpressionContext { + return this.getRuleContext(0, ComputedPrimaryExpressionContext); + } + + public incrementOrDecrementOperator(): IncrementOrDecrementOperatorContext { + return this.getRuleContext(0, IncrementOrDecrementOperatorContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -7833,14 +7975,6 @@ export class IncrementOrDecrementPostfixExpressionContext extends KipperParserRu return KipperParser.RULE_incrementOrDecrementPostfixExpression; } - public computedPrimaryExpression(): ComputedPrimaryExpressionContext { - return this.getRuleContext(0, ComputedPrimaryExpressionContext); - } - - public incrementOrDecrementOperator(): IncrementOrDecrementOperatorContext { - return this.getRuleContext(0, IncrementOrDecrementOperatorContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterIncrementOrDecrementPostfixExpression) { @@ -7866,15 +8000,6 @@ export class IncrementOrDecrementPostfixExpressionContext extends KipperParserRu } export class UnaryExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_unaryExpression; - } - public postfixExpression(): PostfixExpressionContext | undefined { return this.tryGetRuleContext(0, PostfixExpressionContext); } @@ -7887,6 +8012,15 @@ export class UnaryExpressionContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, OperatorModifiedUnaryExpressionContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_unaryExpression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterUnaryExpression) { @@ -7912,6 +8046,14 @@ export class UnaryExpressionContext extends KipperParserRuleContext { } export class IncrementOrDecrementUnaryExpressionContext extends KipperParserRuleContext { + public incrementOrDecrementOperator(): IncrementOrDecrementOperatorContext { + return this.getRuleContext(0, IncrementOrDecrementOperatorContext); + } + + public postfixExpression(): PostfixExpressionContext { + return this.getRuleContext(0, PostfixExpressionContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -7921,14 +8063,6 @@ export class IncrementOrDecrementUnaryExpressionContext extends KipperParserRule return KipperParser.RULE_incrementOrDecrementUnaryExpression; } - public incrementOrDecrementOperator(): IncrementOrDecrementOperatorContext { - return this.getRuleContext(0, IncrementOrDecrementOperatorContext); - } - - public postfixExpression(): PostfixExpressionContext { - return this.getRuleContext(0, PostfixExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterIncrementOrDecrementUnaryExpression) { @@ -7954,6 +8088,14 @@ export class IncrementOrDecrementUnaryExpressionContext extends KipperParserRule } export class OperatorModifiedUnaryExpressionContext extends KipperParserRuleContext { + public unaryOperator(): UnaryOperatorContext { + return this.getRuleContext(0, UnaryOperatorContext); + } + + public postfixExpression(): PostfixExpressionContext { + return this.getRuleContext(0, PostfixExpressionContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -7963,14 +8105,6 @@ export class OperatorModifiedUnaryExpressionContext extends KipperParserRuleCont return KipperParser.RULE_operatorModifiedUnaryExpression; } - public unaryOperator(): UnaryOperatorContext { - return this.getRuleContext(0, UnaryOperatorContext); - } - - public postfixExpression(): PostfixExpressionContext { - return this.getRuleContext(0, PostfixExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterOperatorModifiedUnaryExpression) { @@ -7996,6 +8130,14 @@ export class OperatorModifiedUnaryExpressionContext extends KipperParserRuleCont } export class IncrementOrDecrementOperatorContext extends KipperParserRuleContext { + public PlusPlus(): TerminalNode | undefined { + return this.tryGetToken(KipperParser.PlusPlus, 0); + } + + public MinusMinus(): TerminalNode | undefined { + return this.tryGetToken(KipperParser.MinusMinus, 0); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -8005,14 +8147,6 @@ export class IncrementOrDecrementOperatorContext extends KipperParserRuleContext return KipperParser.RULE_incrementOrDecrementOperator; } - public PlusPlus(): TerminalNode | undefined { - return this.tryGetToken(KipperParser.PlusPlus, 0); - } - - public MinusMinus(): TerminalNode | undefined { - return this.tryGetToken(KipperParser.MinusMinus, 0); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterIncrementOrDecrementOperator) { @@ -8038,15 +8172,6 @@ export class IncrementOrDecrementOperatorContext extends KipperParserRuleContext } export class UnaryOperatorContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_unaryOperator; - } - public Plus(): TerminalNode | undefined { return this.tryGetToken(KipperParser.Plus, 0); } @@ -8063,6 +8188,15 @@ export class UnaryOperatorContext extends KipperParserRuleContext { return this.tryGetToken(KipperParser.BitwiseNot, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_unaryOperator; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterUnaryOperator) { @@ -8103,15 +8237,15 @@ export class CastOrConvertExpressionContext extends KipperParserRuleContext { } export class PassOnCastOrConvertExpressionContext extends CastOrConvertExpressionContext { + public unaryExpression(): UnaryExpressionContext { + return this.getRuleContext(0, UnaryExpressionContext); + } + constructor(ctx: CastOrConvertExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public unaryExpression(): UnaryExpressionContext { - return this.getRuleContext(0, UnaryExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnCastOrConvertExpression) { @@ -8137,11 +8271,6 @@ export class PassOnCastOrConvertExpressionContext extends CastOrConvertExpressio } export class ActualCastOrConvertExpressionContext extends CastOrConvertExpressionContext { - constructor(ctx: CastOrConvertExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public unaryExpression(): UnaryExpressionContext { return this.getRuleContext(0, UnaryExpressionContext); } @@ -8154,6 +8283,11 @@ export class ActualCastOrConvertExpressionContext extends CastOrConvertExpressio return this.getRuleContext(0, TypeSpecifierExpressionContext); } + constructor(ctx: CastOrConvertExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualCastOrConvertExpression) { @@ -8194,15 +8328,15 @@ export class MultiplicativeExpressionContext extends KipperParserRuleContext { } export class PassOnMultiplicativeExpressionContext extends MultiplicativeExpressionContext { + public castOrConvertExpression(): CastOrConvertExpressionContext { + return this.getRuleContext(0, CastOrConvertExpressionContext); + } + constructor(ctx: MultiplicativeExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public castOrConvertExpression(): CastOrConvertExpressionContext { - return this.getRuleContext(0, CastOrConvertExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnMultiplicativeExpression) { @@ -8228,11 +8362,6 @@ export class PassOnMultiplicativeExpressionContext extends MultiplicativeExpress } export class ActualMultiplicativeExpressionContext extends MultiplicativeExpressionContext { - constructor(ctx: MultiplicativeExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public multiplicativeExpression(): MultiplicativeExpressionContext { return this.getRuleContext(0, MultiplicativeExpressionContext); } @@ -8257,6 +8386,11 @@ export class ActualMultiplicativeExpressionContext extends MultiplicativeExpress return this.tryGetToken(KipperParser.PowerTo, 0); } + constructor(ctx: MultiplicativeExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualMultiplicativeExpression) { @@ -8297,15 +8431,15 @@ export class AdditiveExpressionContext extends KipperParserRuleContext { } export class PassOnAdditiveExpressionContext extends AdditiveExpressionContext { + public multiplicativeExpression(): MultiplicativeExpressionContext { + return this.getRuleContext(0, MultiplicativeExpressionContext); + } + constructor(ctx: AdditiveExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public multiplicativeExpression(): MultiplicativeExpressionContext { - return this.getRuleContext(0, MultiplicativeExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnAdditiveExpression) { @@ -8331,11 +8465,6 @@ export class PassOnAdditiveExpressionContext extends AdditiveExpressionContext { } export class ActualAdditiveExpressionContext extends AdditiveExpressionContext { - constructor(ctx: AdditiveExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public additiveExpression(): AdditiveExpressionContext { return this.getRuleContext(0, AdditiveExpressionContext); } @@ -8352,6 +8481,11 @@ export class ActualAdditiveExpressionContext extends AdditiveExpressionContext { return this.tryGetToken(KipperParser.Minus, 0); } + constructor(ctx: AdditiveExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualAdditiveExpression) { @@ -8392,15 +8526,15 @@ export class BitwiseShiftExpressionContext extends KipperParserRuleContext { } export class PassOnBitwiseShiftExpressionContext extends BitwiseShiftExpressionContext { + public additiveExpression(): AdditiveExpressionContext { + return this.getRuleContext(0, AdditiveExpressionContext); + } + constructor(ctx: BitwiseShiftExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public additiveExpression(): AdditiveExpressionContext { - return this.getRuleContext(0, AdditiveExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnBitwiseShiftExpression) { @@ -8426,11 +8560,6 @@ export class PassOnBitwiseShiftExpressionContext extends BitwiseShiftExpressionC } export class ActualBitwiseShiftExpressionContext extends BitwiseShiftExpressionContext { - constructor(ctx: BitwiseShiftExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public bitwiseShiftExpression(): BitwiseShiftExpressionContext { return this.getRuleContext(0, BitwiseShiftExpressionContext); } @@ -8443,6 +8572,11 @@ export class ActualBitwiseShiftExpressionContext extends BitwiseShiftExpressionC return this.getRuleContext(0, BitwiseAndExpressionContext); } + constructor(ctx: BitwiseShiftExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualBitwiseShiftExpression) { @@ -8468,15 +8602,6 @@ export class ActualBitwiseShiftExpressionContext extends BitwiseShiftExpressionC } export class BitwiseShiftOperatorsContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_bitwiseShiftOperators; - } - public BitwiseZeroFillLeftShift(): TerminalNode | undefined { return this.tryGetToken(KipperParser.BitwiseZeroFillLeftShift, 0); } @@ -8489,6 +8614,15 @@ export class BitwiseShiftOperatorsContext extends KipperParserRuleContext { return this.tryGetToken(KipperParser.BitwiseZeroFillRightShift, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_bitwiseShiftOperators; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterBitwiseShiftOperators) { @@ -8529,15 +8663,15 @@ export class RelationalExpressionContext extends KipperParserRuleContext { } export class PassOnRelationalExpressionContext extends RelationalExpressionContext { + public bitwiseShiftExpression(): BitwiseShiftExpressionContext { + return this.getRuleContext(0, BitwiseShiftExpressionContext); + } + constructor(ctx: RelationalExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public bitwiseShiftExpression(): BitwiseShiftExpressionContext { - return this.getRuleContext(0, BitwiseShiftExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnRelationalExpression) { @@ -8563,11 +8697,6 @@ export class PassOnRelationalExpressionContext extends RelationalExpressionConte } export class ActualRelationalExpressionContext extends RelationalExpressionContext { - constructor(ctx: RelationalExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public relationalExpression(): RelationalExpressionContext { return this.getRuleContext(0, RelationalExpressionContext); } @@ -8592,6 +8721,11 @@ export class ActualRelationalExpressionContext extends RelationalExpressionConte return this.tryGetToken(KipperParser.GreaterEqual, 0); } + constructor(ctx: RelationalExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualRelationalExpression) { @@ -8632,15 +8766,15 @@ export class EqualityExpressionContext extends KipperParserRuleContext { } export class PassOnEqualityExpressionContext extends EqualityExpressionContext { + public relationalExpression(): RelationalExpressionContext { + return this.getRuleContext(0, RelationalExpressionContext); + } + constructor(ctx: EqualityExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public relationalExpression(): RelationalExpressionContext { - return this.getRuleContext(0, RelationalExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnEqualityExpression) { @@ -8665,12 +8799,7 @@ export class PassOnEqualityExpressionContext extends EqualityExpressionContext { } } -export class ActualEqualityExpressionContext extends EqualityExpressionContext { - constructor(ctx: EqualityExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - +export class ActualEqualityExpressionContext extends EqualityExpressionContext { public equalityExpression(): EqualityExpressionContext { return this.getRuleContext(0, EqualityExpressionContext); } @@ -8687,6 +8816,11 @@ export class ActualEqualityExpressionContext extends EqualityExpressionContext { return this.tryGetToken(KipperParser.NotEqual, 0); } + constructor(ctx: EqualityExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualEqualityExpression) { @@ -8727,15 +8861,15 @@ export class BitwiseAndExpressionContext extends KipperParserRuleContext { } export class PassOnBitwiseAndExpressionContext extends BitwiseAndExpressionContext { + public equalityExpression(): EqualityExpressionContext { + return this.getRuleContext(0, EqualityExpressionContext); + } + constructor(ctx: BitwiseAndExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public equalityExpression(): EqualityExpressionContext { - return this.getRuleContext(0, EqualityExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnBitwiseAndExpression) { @@ -8761,11 +8895,6 @@ export class PassOnBitwiseAndExpressionContext extends BitwiseAndExpressionConte } export class ActualBitwiseAndExpressionContext extends BitwiseAndExpressionContext { - constructor(ctx: BitwiseAndExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public bitwiseAndExpression(): BitwiseAndExpressionContext { return this.getRuleContext(0, BitwiseAndExpressionContext); } @@ -8778,6 +8907,11 @@ export class ActualBitwiseAndExpressionContext extends BitwiseAndExpressionConte return this.getRuleContext(0, EqualityExpressionContext); } + constructor(ctx: BitwiseAndExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualBitwiseAndExpression) { @@ -8818,15 +8952,15 @@ export class BitwiseXorExpressionContext extends KipperParserRuleContext { } export class PassOnBitwiseXorExpressionContext extends BitwiseXorExpressionContext { + public bitwiseAndExpression(): BitwiseAndExpressionContext { + return this.getRuleContext(0, BitwiseAndExpressionContext); + } + constructor(ctx: BitwiseXorExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public bitwiseAndExpression(): BitwiseAndExpressionContext { - return this.getRuleContext(0, BitwiseAndExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnBitwiseXorExpression) { @@ -8852,11 +8986,6 @@ export class PassOnBitwiseXorExpressionContext extends BitwiseXorExpressionConte } export class ActualBitwiseXorExpressionContext extends BitwiseXorExpressionContext { - constructor(ctx: BitwiseXorExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public bitwiseXorExpression(): BitwiseXorExpressionContext { return this.getRuleContext(0, BitwiseXorExpressionContext); } @@ -8869,6 +8998,11 @@ export class ActualBitwiseXorExpressionContext extends BitwiseXorExpressionConte return this.getRuleContext(0, BitwiseAndExpressionContext); } + constructor(ctx: BitwiseXorExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualBitwiseXorExpression) { @@ -8909,15 +9043,15 @@ export class BitwiseOrExpressionContext extends KipperParserRuleContext { } export class PassOnBitwiseOrExpressionContext extends BitwiseOrExpressionContext { + public bitwiseXorExpression(): BitwiseXorExpressionContext { + return this.getRuleContext(0, BitwiseXorExpressionContext); + } + constructor(ctx: BitwiseOrExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public bitwiseXorExpression(): BitwiseXorExpressionContext { - return this.getRuleContext(0, BitwiseXorExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnBitwiseOrExpression) { @@ -8943,11 +9077,6 @@ export class PassOnBitwiseOrExpressionContext extends BitwiseOrExpressionContext } export class ActualBitwiseOrExpressionContext extends BitwiseOrExpressionContext { - constructor(ctx: BitwiseOrExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public bitwiseOrExpression(): BitwiseOrExpressionContext { return this.getRuleContext(0, BitwiseOrExpressionContext); } @@ -8960,6 +9089,11 @@ export class ActualBitwiseOrExpressionContext extends BitwiseOrExpressionContext return this.getRuleContext(0, BitwiseXorExpressionContext); } + constructor(ctx: BitwiseOrExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualBitwiseOrExpression) { @@ -9000,15 +9134,15 @@ export class LogicalAndExpressionContext extends KipperParserRuleContext { } export class PassOnLogicalAndExpressionContext extends LogicalAndExpressionContext { + public bitwiseOrExpression(): BitwiseOrExpressionContext { + return this.getRuleContext(0, BitwiseOrExpressionContext); + } + constructor(ctx: LogicalAndExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public bitwiseOrExpression(): BitwiseOrExpressionContext { - return this.getRuleContext(0, BitwiseOrExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnLogicalAndExpression) { @@ -9034,11 +9168,6 @@ export class PassOnLogicalAndExpressionContext extends LogicalAndExpressionConte } export class ActualLogicalAndExpressionContext extends LogicalAndExpressionContext { - constructor(ctx: LogicalAndExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public logicalAndExpression(): LogicalAndExpressionContext { return this.getRuleContext(0, LogicalAndExpressionContext); } @@ -9051,6 +9180,11 @@ export class ActualLogicalAndExpressionContext extends LogicalAndExpressionConte return this.getRuleContext(0, BitwiseOrExpressionContext); } + constructor(ctx: LogicalAndExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualLogicalAndExpression) { @@ -9091,15 +9225,15 @@ export class LogicalOrExpressionContext extends KipperParserRuleContext { } export class PassOnLogicalOrExpressionContext extends LogicalOrExpressionContext { + public logicalAndExpression(): LogicalAndExpressionContext { + return this.getRuleContext(0, LogicalAndExpressionContext); + } + constructor(ctx: LogicalOrExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public logicalAndExpression(): LogicalAndExpressionContext { - return this.getRuleContext(0, LogicalAndExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnLogicalOrExpression) { @@ -9125,11 +9259,6 @@ export class PassOnLogicalOrExpressionContext extends LogicalOrExpressionContext } export class ActualLogicalOrExpressionContext extends LogicalOrExpressionContext { - constructor(ctx: LogicalOrExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public logicalOrExpression(): LogicalOrExpressionContext { return this.getRuleContext(0, LogicalOrExpressionContext); } @@ -9142,6 +9271,11 @@ export class ActualLogicalOrExpressionContext extends LogicalOrExpressionContext return this.getRuleContext(0, LogicalAndExpressionContext); } + constructor(ctx: LogicalOrExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualLogicalOrExpression) { @@ -9182,15 +9316,15 @@ export class ConditionalExpressionContext extends KipperParserRuleContext { } export class PassOnConditionalExpressionContext extends ConditionalExpressionContext { + public logicalOrExpression(): LogicalOrExpressionContext { + return this.getRuleContext(0, LogicalOrExpressionContext); + } + constructor(ctx: ConditionalExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public logicalOrExpression(): LogicalOrExpressionContext { - return this.getRuleContext(0, LogicalOrExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnConditionalExpression) { @@ -9216,11 +9350,6 @@ export class PassOnConditionalExpressionContext extends ConditionalExpressionCon } export class ActualConditionalExpressionContext extends ConditionalExpressionContext { - constructor(ctx: ConditionalExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public logicalOrExpression(): LogicalOrExpressionContext { return this.getRuleContext(0, LogicalOrExpressionContext); } @@ -9230,9 +9359,7 @@ export class ActualConditionalExpressionContext extends ConditionalExpressionCon } public conditionalExpression(): ConditionalExpressionContext[]; - public conditionalExpression(i: number): ConditionalExpressionContext; - public conditionalExpression(i?: number): ConditionalExpressionContext | ConditionalExpressionContext[] { if (i === undefined) { return this.getRuleContexts(ConditionalExpressionContext); @@ -9245,6 +9372,11 @@ export class ActualConditionalExpressionContext extends ConditionalExpressionCon return this.getToken(KipperParser.Colon, 0); } + constructor(ctx: ConditionalExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualConditionalExpression) { @@ -9285,15 +9417,15 @@ export class AssignmentExpressionContext extends KipperParserRuleContext { } export class PassOnAssignmentExpressionContext extends AssignmentExpressionContext { + public conditionalExpression(): ConditionalExpressionContext { + return this.getRuleContext(0, ConditionalExpressionContext); + } + constructor(ctx: AssignmentExpressionContext) { super(ctx.parent, ctx.invokingState); this.copyFrom(ctx); } - public conditionalExpression(): ConditionalExpressionContext { - return this.getRuleContext(0, ConditionalExpressionContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterPassOnAssignmentExpression) { @@ -9319,11 +9451,6 @@ export class PassOnAssignmentExpressionContext extends AssignmentExpressionConte } export class ActualAssignmentExpressionContext extends AssignmentExpressionContext { - constructor(ctx: AssignmentExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - public computedPrimaryExpression(): ComputedPrimaryExpressionContext { return this.getRuleContext(0, ComputedPrimaryExpressionContext); } @@ -9336,6 +9463,11 @@ export class ActualAssignmentExpressionContext extends AssignmentExpressionConte return this.getRuleContext(0, AssignmentExpressionContext); } + constructor(ctx: AssignmentExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterActualAssignmentExpression) { @@ -9361,15 +9493,6 @@ export class ActualAssignmentExpressionContext extends AssignmentExpressionConte } export class AssignmentOperatorContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_assignmentOperator; - } - public Assign(): TerminalNode | undefined { return this.tryGetToken(KipperParser.Assign, 0); } @@ -9394,6 +9517,15 @@ export class AssignmentOperatorContext extends KipperParserRuleContext { return this.tryGetToken(KipperParser.MinusAssign, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_assignmentOperator; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterAssignmentOperator) { @@ -9419,19 +9551,8 @@ export class AssignmentOperatorContext extends KipperParserRuleContext { } export class ExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_expression; - } - public assignmentExpression(): AssignmentExpressionContext[]; - public assignmentExpression(i: number): AssignmentExpressionContext; - public assignmentExpression(i?: number): AssignmentExpressionContext | AssignmentExpressionContext[] { if (i === undefined) { return this.getRuleContexts(AssignmentExpressionContext); @@ -9441,9 +9562,7 @@ export class ExpressionContext extends KipperParserRuleContext { } public Comma(): TerminalNode[]; - public Comma(i: number): TerminalNode; - public Comma(i?: number): TerminalNode | TerminalNode[] { if (i === undefined) { return this.getTokens(KipperParser.Comma); @@ -9452,6 +9571,15 @@ export class ExpressionContext extends KipperParserRuleContext { } } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_expression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterExpression) { @@ -9477,15 +9605,6 @@ export class ExpressionContext extends KipperParserRuleContext { } export class TypeSpecifierExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_typeSpecifierExpression; - } - public identifierTypeSpecifierExpression(): IdentifierTypeSpecifierExpressionContext | undefined { return this.tryGetRuleContext(0, IdentifierTypeSpecifierExpressionContext); } @@ -9498,6 +9617,15 @@ export class TypeSpecifierExpressionContext extends KipperParserRuleContext { return this.tryGetRuleContext(0, TypeofTypeSpecifierExpressionContext); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_typeSpecifierExpression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterTypeSpecifierExpression) { @@ -9523,6 +9651,10 @@ export class TypeSpecifierExpressionContext extends KipperParserRuleContext { } export class IdentifierTypeSpecifierExpressionContext extends KipperParserRuleContext { + public typeSpecifierIdentifier(): TypeSpecifierIdentifierContext { + return this.getRuleContext(0, TypeSpecifierIdentifierContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { super(parent, invokingState); } @@ -9532,10 +9664,6 @@ export class IdentifierTypeSpecifierExpressionContext extends KipperParserRuleCo return KipperParser.RULE_identifierTypeSpecifierExpression; } - public typeSpecifierIdentifier(): TypeSpecifierIdentifierContext { - return this.getRuleContext(0, TypeSpecifierIdentifierContext); - } - // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterIdentifierTypeSpecifierExpression) { @@ -9561,19 +9689,8 @@ export class IdentifierTypeSpecifierExpressionContext extends KipperParserRuleCo } export class GenericTypeSpecifierExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_genericTypeSpecifierExpression; - } - public typeSpecifierIdentifier(): TypeSpecifierIdentifierContext[]; - public typeSpecifierIdentifier(i: number): TypeSpecifierIdentifierContext; - public typeSpecifierIdentifier(i?: number): TypeSpecifierIdentifierContext | TypeSpecifierIdentifierContext[] { if (i === undefined) { return this.getRuleContexts(TypeSpecifierIdentifierContext); @@ -9590,6 +9707,15 @@ export class GenericTypeSpecifierExpressionContext extends KipperParserRuleConte return this.getToken(KipperParser.Greater, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_genericTypeSpecifierExpression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterGenericTypeSpecifierExpression) { @@ -9615,15 +9741,6 @@ export class GenericTypeSpecifierExpressionContext extends KipperParserRuleConte } export class TypeofTypeSpecifierExpressionContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_typeofTypeSpecifierExpression; - } - public Typeof(): TerminalNode { return this.getToken(KipperParser.Typeof, 0); } @@ -9640,6 +9757,15 @@ export class TypeofTypeSpecifierExpressionContext extends KipperParserRuleContex return this.getToken(KipperParser.RightParen, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_typeofTypeSpecifierExpression; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterTypeofTypeSpecifierExpression) { @@ -9665,15 +9791,6 @@ export class TypeofTypeSpecifierExpressionContext extends KipperParserRuleContex } export class TypeSpecifierIdentifierContext extends KipperParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - - // @Override - public get ruleIndex(): number { - return KipperParser.RULE_typeSpecifierIdentifier; - } - public Identifier(): TerminalNode | undefined { return this.tryGetToken(KipperParser.Identifier, 0); } @@ -9690,6 +9807,15 @@ export class TypeSpecifierIdentifierContext extends KipperParserRuleContext { return this.tryGetToken(KipperParser.Void, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + + // @Override + public get ruleIndex(): number { + return KipperParser.RULE_typeSpecifierIdentifier; + } + // @Override public enterRule(listener: KipperParserListener): void { if (listener.enterTypeSpecifierIdentifier) { diff --git a/kipper/core/src/compiler/lexer-parser/antlr/KipperParserListener.ts b/kipper/core/src/compiler/lexer-parser/antlr/KipperParserListener.ts index 2e42e6526..0f9e0739b 100644 --- a/kipper/core/src/compiler/lexer-parser/antlr/KipperParserListener.ts +++ b/kipper/core/src/compiler/lexer-parser/antlr/KipperParserListener.ts @@ -46,15 +46,17 @@ import { ExternalItemContext } from "./KipperParser"; import { BlockItemListContext } from "./KipperParser"; import { BlockItemContext } from "./KipperParser"; import { DeclarationContext } from "./KipperParser"; -import { FunctionDeclarationContext } from "./KipperParser"; import { VariableDeclarationContext } from "./KipperParser"; import { StorageTypeSpecifierContext } from "./KipperParser"; +import { InitDeclaratorContext } from "./KipperParser"; +import { InitializerContext } from "./KipperParser"; import { DeclaratorContext } from "./KipperParser"; import { DirectDeclaratorContext } from "./KipperParser"; -import { InitDeclaratorContext } from "./KipperParser"; +import { FunctionDeclarationContext } from "./KipperParser"; import { ParameterListContext } from "./KipperParser"; import { ParameterDeclarationContext } from "./KipperParser"; -import { InitializerContext } from "./KipperParser"; +import { InterfaceDeclarationContext } from "./KipperParser"; +import { ClassDeclarationContext } from "./KipperParser"; import { StatementContext } from "./KipperParser"; import { CompoundStatementContext } from "./KipperParser"; import { ExpressionStatementContext } from "./KipperParser"; @@ -618,17 +620,6 @@ export interface KipperParserListener extends ParseTreeListener { */ exitDeclaration?: (ctx: DeclarationContext) => void; - /** - * Enter a parse tree produced by `KipperParser.functionDeclaration`. - * @param ctx the parse tree - */ - enterFunctionDeclaration?: (ctx: FunctionDeclarationContext) => void; - /** - * Exit a parse tree produced by `KipperParser.functionDeclaration`. - * @param ctx the parse tree - */ - exitFunctionDeclaration?: (ctx: FunctionDeclarationContext) => void; - /** * Enter a parse tree produced by `KipperParser.variableDeclaration`. * @param ctx the parse tree @@ -651,6 +642,28 @@ export interface KipperParserListener extends ParseTreeListener { */ exitStorageTypeSpecifier?: (ctx: StorageTypeSpecifierContext) => void; + /** + * Enter a parse tree produced by `KipperParser.initDeclarator`. + * @param ctx the parse tree + */ + enterInitDeclarator?: (ctx: InitDeclaratorContext) => void; + /** + * Exit a parse tree produced by `KipperParser.initDeclarator`. + * @param ctx the parse tree + */ + exitInitDeclarator?: (ctx: InitDeclaratorContext) => void; + + /** + * Enter a parse tree produced by `KipperParser.initializer`. + * @param ctx the parse tree + */ + enterInitializer?: (ctx: InitializerContext) => void; + /** + * Exit a parse tree produced by `KipperParser.initializer`. + * @param ctx the parse tree + */ + exitInitializer?: (ctx: InitializerContext) => void; + /** * Enter a parse tree produced by `KipperParser.declarator`. * @param ctx the parse tree @@ -674,15 +687,15 @@ export interface KipperParserListener extends ParseTreeListener { exitDirectDeclarator?: (ctx: DirectDeclaratorContext) => void; /** - * Enter a parse tree produced by `KipperParser.initDeclarator`. + * Enter a parse tree produced by `KipperParser.functionDeclaration`. * @param ctx the parse tree */ - enterInitDeclarator?: (ctx: InitDeclaratorContext) => void; + enterFunctionDeclaration?: (ctx: FunctionDeclarationContext) => void; /** - * Exit a parse tree produced by `KipperParser.initDeclarator`. + * Exit a parse tree produced by `KipperParser.functionDeclaration`. * @param ctx the parse tree */ - exitInitDeclarator?: (ctx: InitDeclaratorContext) => void; + exitFunctionDeclaration?: (ctx: FunctionDeclarationContext) => void; /** * Enter a parse tree produced by `KipperParser.parameterList`. @@ -707,15 +720,26 @@ export interface KipperParserListener extends ParseTreeListener { exitParameterDeclaration?: (ctx: ParameterDeclarationContext) => void; /** - * Enter a parse tree produced by `KipperParser.initializer`. + * Enter a parse tree produced by `KipperParser.interfaceDeclaration`. * @param ctx the parse tree */ - enterInitializer?: (ctx: InitializerContext) => void; + enterInterfaceDeclaration?: (ctx: InterfaceDeclarationContext) => void; /** - * Exit a parse tree produced by `KipperParser.initializer`. + * Exit a parse tree produced by `KipperParser.interfaceDeclaration`. * @param ctx the parse tree */ - exitInitializer?: (ctx: InitializerContext) => void; + exitInterfaceDeclaration?: (ctx: InterfaceDeclarationContext) => void; + + /** + * Enter a parse tree produced by `KipperParser.classDeclaration`. + * @param ctx the parse tree + */ + enterClassDeclaration?: (ctx: ClassDeclarationContext) => void; + /** + * Exit a parse tree produced by `KipperParser.classDeclaration`. + * @param ctx the parse tree + */ + exitClassDeclaration?: (ctx: ClassDeclarationContext) => void; /** * Enter a parse tree produced by `KipperParser.statement`. diff --git a/kipper/core/src/compiler/lexer-parser/antlr/KipperParserVisitor.ts b/kipper/core/src/compiler/lexer-parser/antlr/KipperParserVisitor.ts index 88f8677f7..3e8d7b3ef 100644 --- a/kipper/core/src/compiler/lexer-parser/antlr/KipperParserVisitor.ts +++ b/kipper/core/src/compiler/lexer-parser/antlr/KipperParserVisitor.ts @@ -46,15 +46,17 @@ import { ExternalItemContext } from "./KipperParser"; import { BlockItemListContext } from "./KipperParser"; import { BlockItemContext } from "./KipperParser"; import { DeclarationContext } from "./KipperParser"; -import { FunctionDeclarationContext } from "./KipperParser"; import { VariableDeclarationContext } from "./KipperParser"; import { StorageTypeSpecifierContext } from "./KipperParser"; +import { InitDeclaratorContext } from "./KipperParser"; +import { InitializerContext } from "./KipperParser"; import { DeclaratorContext } from "./KipperParser"; import { DirectDeclaratorContext } from "./KipperParser"; -import { InitDeclaratorContext } from "./KipperParser"; +import { FunctionDeclarationContext } from "./KipperParser"; import { ParameterListContext } from "./KipperParser"; import { ParameterDeclarationContext } from "./KipperParser"; -import { InitializerContext } from "./KipperParser"; +import { InterfaceDeclarationContext } from "./KipperParser"; +import { ClassDeclarationContext } from "./KipperParser"; import { StatementContext } from "./KipperParser"; import { CompoundStatementContext } from "./KipperParser"; import { ExpressionStatementContext } from "./KipperParser"; @@ -433,25 +435,32 @@ export interface KipperParserVisitor extends ParseTreeVisitor { visitDeclaration?: (ctx: DeclarationContext) => Result; /** - * Visit a parse tree produced by `KipperParser.functionDeclaration`. + * Visit a parse tree produced by `KipperParser.variableDeclaration`. * @param ctx the parse tree * @return the visitor result */ - visitFunctionDeclaration?: (ctx: FunctionDeclarationContext) => Result; + visitVariableDeclaration?: (ctx: VariableDeclarationContext) => Result; /** - * Visit a parse tree produced by `KipperParser.variableDeclaration`. + * Visit a parse tree produced by `KipperParser.storageTypeSpecifier`. * @param ctx the parse tree * @return the visitor result */ - visitVariableDeclaration?: (ctx: VariableDeclarationContext) => Result; + visitStorageTypeSpecifier?: (ctx: StorageTypeSpecifierContext) => Result; /** - * Visit a parse tree produced by `KipperParser.storageTypeSpecifier`. + * Visit a parse tree produced by `KipperParser.initDeclarator`. * @param ctx the parse tree * @return the visitor result */ - visitStorageTypeSpecifier?: (ctx: StorageTypeSpecifierContext) => Result; + visitInitDeclarator?: (ctx: InitDeclaratorContext) => Result; + + /** + * Visit a parse tree produced by `KipperParser.initializer`. + * @param ctx the parse tree + * @return the visitor result + */ + visitInitializer?: (ctx: InitializerContext) => Result; /** * Visit a parse tree produced by `KipperParser.declarator`. @@ -468,11 +477,11 @@ export interface KipperParserVisitor extends ParseTreeVisitor { visitDirectDeclarator?: (ctx: DirectDeclaratorContext) => Result; /** - * Visit a parse tree produced by `KipperParser.initDeclarator`. + * Visit a parse tree produced by `KipperParser.functionDeclaration`. * @param ctx the parse tree * @return the visitor result */ - visitInitDeclarator?: (ctx: InitDeclaratorContext) => Result; + visitFunctionDeclaration?: (ctx: FunctionDeclarationContext) => Result; /** * Visit a parse tree produced by `KipperParser.parameterList`. @@ -489,11 +498,18 @@ export interface KipperParserVisitor extends ParseTreeVisitor { visitParameterDeclaration?: (ctx: ParameterDeclarationContext) => Result; /** - * Visit a parse tree produced by `KipperParser.initializer`. + * Visit a parse tree produced by `KipperParser.interfaceDeclaration`. * @param ctx the parse tree * @return the visitor result */ - visitInitializer?: (ctx: InitializerContext) => Result; + visitInterfaceDeclaration?: (ctx: InterfaceDeclarationContext) => Result; + + /** + * Visit a parse tree produced by `KipperParser.classDeclaration`. + * @param ctx the parse tree + * @return the visitor result + */ + visitClassDeclaration?: (ctx: ClassDeclarationContext) => Result; /** * Visit a parse tree produced by `KipperParser.statement`. diff --git a/kipper/core/src/compiler/lexer-parser/parse-rule-kind-mapping.ts b/kipper/core/src/compiler/lexer-parser/parse-rule-kind-mapping.ts index 24f4cca66..adbf6c939 100644 --- a/kipper/core/src/compiler/lexer-parser/parse-rule-kind-mapping.ts +++ b/kipper/core/src/compiler/lexer-parser/parse-rule-kind-mapping.ts @@ -25,15 +25,17 @@ export const ParseRuleKindMapping = { RULE_blockItemList: KipperParser.RULE_blockItemList, RULE_blockItem: KipperParser.RULE_blockItem, RULE_declaration: KipperParser.RULE_declaration, - RULE_functionDeclaration: KipperParser.RULE_functionDeclaration, RULE_variableDeclaration: KipperParser.RULE_variableDeclaration, RULE_storageTypeSpecifier: KipperParser.RULE_storageTypeSpecifier, + RULE_initDeclarator: KipperParser.RULE_initDeclarator, + RULE_initializer: KipperParser.RULE_initializer, RULE_declarator: KipperParser.RULE_declarator, RULE_directDeclarator: KipperParser.RULE_directDeclarator, - RULE_initDeclarator: KipperParser.RULE_initDeclarator, + RULE_functionDeclaration: KipperParser.RULE_functionDeclaration, RULE_parameterList: KipperParser.RULE_parameterList, RULE_parameterDeclaration: KipperParser.RULE_parameterDeclaration, - RULE_initializer: KipperParser.RULE_initializer, + RULE_interfaceDeclaration: KipperParser.RULE_interfaceDeclaration, + RULE_classDeclaration: KipperParser.RULE_classDeclaration, RULE_statement: KipperParser.RULE_statement, RULE_compoundStatement: KipperParser.RULE_compoundStatement, RULE_expressionStatement: KipperParser.RULE_expressionStatement, diff --git a/kipper/core/src/compiler/optimiser/optimiser.ts b/kipper/core/src/compiler/optimiser/optimiser.ts index 244a11f9e..b1eded86a 100644 --- a/kipper/core/src/compiler/optimiser/optimiser.ts +++ b/kipper/core/src/compiler/optimiser/optimiser.ts @@ -4,7 +4,7 @@ */ import type { RootASTNode } from "../ast"; import type { KipperProgramContext } from "../program-ctx"; -import type { BuiltInFunction, BuiltInVariable, InternalFunction } from "../runtime-built-ins"; +import type { InternalFunction, Reference, ScopeFunctionDeclaration, ScopeVariableDeclaration } from "../semantics/"; /** * The options available for an optimisation run in {@link KipperOptimiser.optimise}. @@ -48,33 +48,57 @@ export class KipperOptimiser { this.programCtx = programCtx; } + /** + * Optimises the {@link astTree} and {@link programCtx} based on the {@link options} argument. + * + * This function takes in an abstract syntax tree that was semantically analysed and outputs a new optimised abstract + * syntax tree that can be translated into a target language. + * @param astTree + * @param options + * @since 0.8.0 + */ + public async optimise( + astTree: RootASTNode, + options: OptimisationOptions = defaultOptimisationOptions, + ): Promise { + if (options.optimiseInternals) { + await this.optimiseInternals(); + } + if (options.optimiseBuiltIns) { + await this.optimiseBuiltIns(); + } + + return astTree; + } + /** * Optimises the built-in functions of Kipper by removing any unneeded built-in definition. * @private * @since 0.8.0 */ private async optimiseBuiltIns(): Promise { - // Optimise the registered built-in variables by optimising them using the stored references. - const newBuiltInVariables: Array = []; + const strippedBuiltInVariables: Array> = []; for (const ref of this.programCtx.builtInVariableReferences) { - const alreadyIncluded: boolean = newBuiltInVariables.find((r) => r === ref.refTarget) !== undefined; - if (!alreadyIncluded) { - newBuiltInVariables.push(ref.refTarget); + const included: boolean = + strippedBuiltInVariables.find((includedRef) => includedRef.refTarget === ref.refTarget) !== undefined; + if (!included) { + strippedBuiltInVariables.push(ref); } } this.programCtx.clearBuiltInVariables(); - this.programCtx.registerBuiltInVariables(newBuiltInVariables); + this.programCtx.registerBuiltInVariables(strippedBuiltInVariables.map((v) => v.refTarget.builtInStructure!!)); // Optimise the registered built-in functions by optimising them using the stored references. - const newBuiltInFunctions: Array = []; + const strippedBuiltInFunctions: Array> = []; for (const ref of this.programCtx.builtInFunctionReferences) { - const alreadyIncluded: boolean = newBuiltInFunctions.find((r) => r === ref.refTarget) !== undefined; + const alreadyIncluded: boolean = + strippedBuiltInFunctions.find((includedRef) => includedRef.refTarget === ref.refTarget) !== undefined; if (!alreadyIncluded) { - newBuiltInFunctions.push(ref.refTarget); + strippedBuiltInFunctions.push(ref); } } this.programCtx.clearBuiltInFunctions(); - this.programCtx.registerBuiltInFunctions(newBuiltInFunctions); + this.programCtx.registerBuiltInFunctions(strippedBuiltInFunctions.map((v) => v.refTarget.builtInStructure!!)); } /** @@ -95,27 +119,4 @@ export class KipperOptimiser { this.programCtx.internals.splice(0); this.programCtx.internals.push(...newInternals); } - - /** - * Optimises the {@link astTree} and {@link programCtx} based on the {@link options} argument. - * - * This function takes in an abstract syntax tree that was semantically analysed and outputs a new optimised abstract - * syntax tree that can be translated into a target language. - * @param astTree - * @param options - * @since 0.8.0 - */ - public async optimise( - astTree: RootASTNode, - options: OptimisationOptions = defaultOptimisationOptions, - ): Promise { - if (options.optimiseInternals) { - await this.optimiseInternals(); - } - if (options.optimiseBuiltIns) { - await this.optimiseBuiltIns(); - } - - return astTree; - } } diff --git a/kipper/core/src/compiler/program-ctx.ts b/kipper/core/src/compiler/program-ctx.ts index 931fb5a3c..13910739f 100644 --- a/kipper/core/src/compiler/program-ctx.ts +++ b/kipper/core/src/compiler/program-ctx.ts @@ -8,26 +8,41 @@ import type { ANTLRErrorListener, Token, TokenStream } from "antlr4ts"; import type { CompilationUnitContext, + KipperFileStream, KipperLexer, KipperParser, LexerParserData, - KipperFileStream, } from "./lexer-parser"; -import type { BuiltInFunction, BuiltInVariable, InternalFunction } from "./runtime-built-ins"; import type { KipperCompileTarget } from "./target-presets"; import type { TranslatedCodeLine } from "./const"; import type { KipperWarning } from "../warnings"; import type { CompilableASTNode, Expression, RootASTNode } from "./ast"; import { KipperFileASTGenerator } from "./ast"; import type { EvaluatedCompileConfig } from "./compile-config"; -import type { InternalReference, Reference } from "./analysis"; -import { GlobalScope, KipperSemanticChecker, KipperTypeChecker } from "./analysis"; +import type { + BuiltInFunction, + BuiltInVariable, + GlobalScope, + InternalFunction, + InternalReference, + Reference, + ScopeFunctionDeclaration, +} from "./semantics"; +import { ScopeVariableDeclaration } from "./semantics"; +import { + BuiltInFunctions, + BuiltInTypes, + BuiltInVariables, + KipperSemanticChecker, + KipperTypeChecker, + UniverseScope, +} from "./semantics"; import { KipperError, KipperInternalError, UndefinedSemanticsError } from "../errors"; import type { OptimisationOptions } from "./optimiser"; import { KipperOptimiser } from "./optimiser"; import type { KipperLogger } from "../logger"; import { LogLevel } from "../logger"; -import { KipperWarningIssuer } from "./analysis/analyser/warning-issuer"; +import { KipperWarningIssuer } from "./semantics/analyser/warning-issuer"; import { ParseTreeWalker } from "antlr4ts/tree"; /** @@ -46,9 +61,9 @@ export class KipperProgramContext { private readonly _warnings: Array; - private readonly _builtInFunctionReferences: Array>; + private readonly _builtInFunctionReferences: Array>; - private readonly _builtInVariableReferences: Array>; + private readonly _builtInVariableReferences: Array>; private readonly _internalReferences: Array>; @@ -60,7 +75,7 @@ export class KipperProgramContext { */ private readonly _channels: LexerParserData["channels"]; - private _abstractSyntaxTree: RootASTNode | undefined; + private _rootASTNode: RootASTNode | undefined; /** * The field compiledCode that will store the cached code, once 'compileProgram' has been called. This is @@ -69,12 +84,6 @@ export class KipperProgramContext { */ private _compiledCode: Array | undefined; - /** - * The global scope of this program, containing all variable and function declarations - * @private - */ - private readonly _globalScope: GlobalScope; - /** * Represents the compilation translation target for the program. This contains the: * - {@link KipperTargetSemanticAnalyser}, which performs semantic analysis specific for the target. @@ -164,6 +173,12 @@ export class KipperProgramContext { */ public readonly builtInVariables: Array; + /** + * The universe scope, which contains all built-in types and functions. + * @since 0.11.0 + */ + private readonly _universeScope: UniverseScope; + constructor( lexerParserData: LexerParserData, logger: KipperLogger, @@ -190,27 +205,14 @@ export class KipperProgramContext { this._stream = lexerParserData.fileStream; this._channels = lexerParserData.channels; this._antlrParseTree = lexerParserData.parseTree; - this._globalScope = new GlobalScope(this); - this._abstractSyntaxTree = undefined; + this._universeScope = new UniverseScope(this); + this._rootASTNode = undefined; this._builtInFunctionReferences = []; this._builtInVariableReferences = []; this._internalReferences = []; this._warnings = []; this._errors = []; - - // Register all built-in functions - const globalFunctions = [...compileConfig.builtInFunctions, ...compileConfig.extendBuiltInFunctions]; - this.registerBuiltInFunctions(globalFunctions); - this.logger.debug( - `Registered ${globalFunctions.length} global function${globalFunctions.length === 1 ? "" : "s"}.`, - ); - - // Register all built-in variables - const globalVariables = [...compileConfig.builtInVariables, ...compileConfig.extendBuiltInVariables]; - this.registerBuiltInVariables(globalVariables); - this.logger.debug( - `Registered ${globalVariables.length} global variable${globalVariables.length === 1 ? "" : "s"}.`, - ); + this._initUniversalReferencables(compileConfig); } // @ts-ignore @@ -301,9 +303,20 @@ export class KipperProgramContext { /** * The global scope of this file, which contains all {@link ScopeDeclaration} instances that are accessible in the * entire program. + * @since 0.11.0 + */ + public get universeScope(): UniverseScope { + return this._universeScope; + } + + /** + * The global scope of this file, which contains all {@link ScopeDeclaration} instances that are accessible in the + * entire program. + * + * May be undefined if {@link generateAbstractSyntaxTree} has not been called yet. */ - public get globalScope(): GlobalScope { - return this._globalScope; + public get globalScope(): GlobalScope | undefined { + return this._rootASTNode?.innerScope; } /** @@ -335,7 +348,7 @@ export class KipperProgramContext { * so they will not be generated. * @since 0.10.0 */ - public get builtInFunctionReferences(): Array> { + public get builtInFunctionReferences(): Array> { return this._builtInFunctionReferences; } @@ -347,7 +360,7 @@ export class KipperProgramContext { * so they will not be generated. * @since 0.10.0 */ - public get builtInVariableReferences(): Array> { + public get builtInVariableReferences(): Array> { return this._builtInVariableReferences; } @@ -357,8 +370,8 @@ export class KipperProgramContext { * * If the function {@link compileProgram} has not been called yet, this item will be {@link undefined}. */ - public get abstractSyntaxTree(): RootASTNode | undefined { - return this._abstractSyntaxTree; + public get rootASTNode(): RootASTNode | undefined { + return this._rootASTNode; } /** @@ -463,7 +476,7 @@ export class KipperProgramContext { } // Caching the result - this._abstractSyntaxTree = listener.rootNode; + this._rootASTNode = listener.rootNode; const countNodes: number = listener.rootNode.children.length; this.logger.debug(`Finished generation of Kipper AST.`); @@ -471,6 +484,19 @@ export class KipperProgramContext { return listener.rootNode; } + /** + * Sets up the built-ins for this program. This function should be called before the semantic analysis is run. + * + * TODO! For now this only registers the built-in types in the global scope so they can be use, but in the future + * this should also generate the built-in functions and variables. + * @since 0.11.0 + */ + public async setUpBuiltInsInGlobalScope(): Promise { + for (const [_, type] of Object.entries(BuiltInTypes)) { + this._universeScope.addType(type); + } + } + /** * Runs the semantic analysis for this {@link KipperProgramContext program}. This function will log debugging messages * and warnings using the {@link this.logger logger of this instance} and throw errors in case any logical issues are @@ -483,11 +509,11 @@ export class KipperProgramContext { */ public async semanticAnalysis(): Promise { try { - if (!this._abstractSyntaxTree) { - this._abstractSyntaxTree = await this.generateAbstractSyntaxTree(); + if (!this._rootASTNode) { + this._rootASTNode = await this.generateAbstractSyntaxTree(); } - await this._abstractSyntaxTree.semanticAnalysis(); + await this._rootASTNode.semanticAnalysis(); } catch (e) { if (e instanceof KipperError) { // Log the Kipper error @@ -503,22 +529,22 @@ export class KipperProgramContext { } /** - * Processes the {@link abstractSyntaxTree} and generates a new optimised one based on the {@link options}. + * Processes the {@link rootASTNode} and generates a new optimised one based on the {@link options}. * @param options The options for the optimisation. If undefined, the {@link defaultOptimisationOptions} are used. * @since 0.8.0 * @see {@link compileProgram} */ public async optimise(options?: OptimisationOptions): Promise { - if (!this.abstractSyntaxTree) { + if (!this.rootASTNode) { // TODO! Change this error to a more fitting one throw new UndefinedSemanticsError(); } try { - const result = await this.optimiser.optimise(this.abstractSyntaxTree, options); + const result = await this.optimiser.optimise(this.rootASTNode, options); // Caching the result - this._abstractSyntaxTree = result; + this._rootASTNode = result; return result; } catch (e) { @@ -541,13 +567,13 @@ export class KipperProgramContext { * @see {@link compileProgram} */ public async translate(): Promise> { - if (!this.abstractSyntaxTree) { + if (!this.rootASTNode) { // TODO! Change this error to a more fitting one throw new UndefinedSemanticsError(); } try { - return await this.abstractSyntaxTree.translate(); + return await this.rootASTNode.translate(); } catch (e) { if (e instanceof KipperError) { // Log the Kipper error @@ -570,13 +596,15 @@ export class KipperProgramContext { */ public async compileProgram(): Promise | undefined> { // Getting the processed AST tree - this._abstractSyntaxTree = await this.generateAbstractSyntaxTree(); + this._rootASTNode = await this.generateAbstractSyntaxTree(); // Running the semantic analysis for the AST + this.logger.debug("Setting up built-ins in global scope."); + await this.setUpBuiltInsInGlobalScope(); this.logger.info(`Analysing semantics.`); await this.semanticAnalysis(); - // If the semantic analysis failed, return an empty array + // If the semantic analysis failed, return nothing if (this.hasFailed) { return undefined; } @@ -590,7 +618,7 @@ export class KipperProgramContext { let genCode: Array = await this.translate(); this.logger.debug(`Lines of generated code: ${genCode.length}.`); - this.logger.debug(`Number of processed root items: ${this._abstractSyntaxTree.children.length}.`); + this.logger.debug(`Number of processed root items: ${this._rootASTNode.children.length}.`); // Cache the result this._compiledCode = genCode; @@ -697,8 +725,8 @@ export class KipperProgramContext { builtInVariables = Array.isArray(builtInVariables) ? builtInVariables : [builtInVariables]; // Make sure the global is valid and doesn't interfere with other identifiers + // If an error occurs, line 1 and col 1 will be used, as the ctx is undefined. for (let g of builtInVariables) { - // If an error occurs, line 1 and col 1 will be used, as the ctx is undefined. this.semanticCheck(undefined).globalCanBeRegistered(g.identifier); } this.builtInVariables.push(...builtInVariables); @@ -710,6 +738,7 @@ export class KipperProgramContext { */ public clearBuiltInFunctions() { this.builtInFunctions.splice(0); + this.universeScope.clearUniversalFunctions(); } /** @@ -718,6 +747,7 @@ export class KipperProgramContext { */ public clearBuiltInVariables() { this.builtInVariables.splice(0); + this.universeScope.clearUniversalVariables(); } /** @@ -726,16 +756,16 @@ export class KipperProgramContext { * @param refTarget The built-in identifier referenced. * @since 0.8.0 */ - public addBuiltInReference(exp: Expression, refTarget: BuiltInFunction | BuiltInVariable) { + public addBuiltInReference(exp: Expression, refTarget: ScopeVariableDeclaration | ScopeFunctionDeclaration) { const ref = { refTarget: refTarget, srcExpr: exp, - } satisfies Reference; + } satisfies Reference; - if ("valueType" in ref.refTarget) { - this._builtInVariableReferences.push(>ref); + if (ref.refTarget instanceof ScopeVariableDeclaration) { + this._builtInVariableReferences.push(>ref); } else { - this._builtInFunctionReferences.push(>ref); + this._builtInFunctionReferences.push(>ref); } } @@ -751,4 +781,37 @@ export class KipperProgramContext { srcExpr: exp, }); } + + /** + * Initialises the universal referencables for the program context, by registering all built-in functions and + * variables as well as adding all the extension functions and variables. + * + * This will initialise {@link this._universeScope}. + * @param compileConfig The compile configuration for the program. + * @private + * @since 0.11.0 + */ + private _initUniversalReferencables(compileConfig: EvaluatedCompileConfig) { + // Register all built-in functions + const globalFunctions = [...Object.values(BuiltInFunctions), ...compileConfig.extendBuiltInFunctions]; + this.registerBuiltInFunctions(globalFunctions); + this.logger.debug( + `Registered ${globalFunctions.length} global function${globalFunctions.length === 1 ? "" : "s"}.`, + ); + + // Register all built-in variables + const globalVariables = [...Object.values(BuiltInVariables), ...compileConfig.extendBuiltInVariables]; + this.registerBuiltInVariables(globalVariables); + this.logger.debug( + `Registered ${globalVariables.length} global variable${globalVariables.length === 1 ? "" : "s"}.`, + ); + + this._universeScope.init(); + for (const extFunction of compileConfig.extendBuiltInFunctions) { + this._universeScope.addFunction(extFunction); + } + for (const extVariable of compileConfig.extendBuiltInVariables) { + this._universeScope.addVariable(extVariable); + } + } } diff --git a/kipper/core/src/compiler/runtime-built-ins.ts b/kipper/core/src/compiler/runtime-built-ins.ts deleted file mode 100644 index 3e44c9814..000000000 --- a/kipper/core/src/compiler/runtime-built-ins.ts +++ /dev/null @@ -1,313 +0,0 @@ -/** - * Built-Ins file, which provides the blueprints for the Kipper built-in functions and variables. - * @since 0.1.0 - */ -import type { KipperCompilableType } from "./const"; - -/** - * Interface representation of an argument of a {@link BuiltInFunction}. - * @since 0.1.0 - */ -export interface BuiltInFunctionArgument { - /** - * The identifier of the argument inside the function - * - * This value does not affect the behaviour of the language, as named-arguments are not implemented in Kipper. This - * only serves the purpose of readability and allowing easier differentiation. - * @since 0.6.0 - */ - identifier: string; - /** - * The type of the argument inside the function - * - * @example - * def func(x: num, y: str) -> void {} - * - * // x is of type 'num' - * // y is of type 'str' - */ - valueType: KipperCompilableType; -} - -/** - * Interface representation of a {@link BuiltInFunction}, which is available inside a Kipper program using the specified - * metadata. - * @since 0.1.0 - */ -export interface BuiltInFunction { - /** - * The identifier of the global function that should be available inside the program. - * - * The identifier may only contain default numbers and alphabet characters! - * @example - * call print(); // 'print' is the global function identifier - */ - identifier: string; - /** - * The args that are accepted inside this function. These are represented using {@link BuiltInFunctionArgument}. - * - * The index in the array also represents the argument position inside the function. Meaning the first item in the - * array maps to the first argument inside the function. - */ - params: Array; - /** - * The expected return of the function. If the return type is {@link KipperVoidType void}, then the function will not - * return anything. - */ - returnType: KipperCompilableType; -} - -/** - * Interface representation of an argument of a {@link InternalFunction}. - * @since 0.10.0 - */ -export interface InternalFunctionArgument { - /** - * The identifier of the argument inside the function - * - * This value does not affect the behaviour of the language, as named-arguments are not implemented in Kipper. This - * only serves the purpose of readability and allowing easier differentiation. - * @since 0.6.0 - */ - identifier: string; - /** - * The type of the argument inside the function - * - * Unlike {@link BuiltInFunction}, this can also be an array of types, which means that the value type may be a union. - * @example - * def func(x: num, y: str) -> void {} - * - * // x is of type 'num' - * // y is of type 'str' - */ - valueType: KipperCompilableType | Array; -} - -/** - * Interface representation of a {@link InternalFunction}, which is used to provide functionality for Kipper specific - * keywords, internal logic and other implementation related handling that must be present for a program to work. - * @since 0.8.0 - */ -export interface InternalFunction { - /** - * The identifier of the internal function. - * - * The identifier may only contain default numbers and alphabet characters! - * @example - * "4" as num; // 'strAsNum' is the internal function used to perform this expression - * @since 0.8.0 - */ - identifier: string; - /** - * The args that are accepted inside this function. These are represented using {@link InternalFunctionArgument}. - * - * The index in the array also represents the argument position inside the function. Meaning the first item in the - * array maps to the first argument inside the function. - * @since 0.8.0 - */ - params: Array; - /** - * The expected return of the function. If the return type is {@link KipperVoidType void}, then the function will not - * return anything. - * - * Unlike {@link BuiltInFunction}, this can also be an array of types, which means that the function return may be a - * union. - * @since 0.8.0 - */ - returnType: KipperCompilableType; -} - -/** - * Interface representation of a {@link BuiltInVariable}, which is available inside a Kipper program using the specified - * metadata. - * @since 0.10.0 - */ -export interface BuiltInVariable { - /** - * The identifier of the global variable that should be available inside the program. - * @since 0.10.0 - */ - identifier: string; - /** - * The type of the variable. - * @since 0.10.0 - */ - valueType: KipperCompilableType; - /** - * If true then the variable is local to the current file. If false then the variable is global and can be accessed - * from any file. - * - * This is primarily used to differentiate between local and global variables during the code generation process, - * since local ones will usually be initialised like any other variables, while globals will be registered on a global - * object. - * @since 0.10.0 - */ - local: boolean; -} - -/** - * Contains all the built-in functions in Kipper that are available per default in every program. - * - * This contains *every* builtin that also must be implemented by every target in the {@link KipperTargetBuiltInGenerator}. - * @since 0.7.0 - */ -export const kipperRuntimeBuiltInFunctions: Record = { - print: { - identifier: "print", - params: [ - { - identifier: "msg", - valueType: "str", - }, - ], - returnType: "void", - }, - len: { - identifier: "len", - params: [ - { - identifier: "arrayLike", - valueType: "str", // TODO: Implement this for all arrayLike types (At the moment only strings are supported) - }, - ], - returnType: "num", - }, -}; - -/** - * Contains all the internal built-in functions, which are used by Kipper to provide internal functionality. These - * internal built-ins are commonly used to provide the functionality for keywords and other internal logic. - * - * This contains *every* builtin that also must be implemented by every target in the {@link KipperTargetBuiltInGenerator}. - * @since 0.8.0 - */ -export const kipperInternalBuiltInFunctions = { - numToStr: { - identifier: "numToStr", - params: [ - { - identifier: "value", - valueType: "num", - }, - ], - returnType: "str", - }, - boolToStr: { - identifier: "boolToStr", - params: [ - { - identifier: "value", - valueType: "bool", - }, - ], - returnType: "str", - }, - voidToStr: { - identifier: "voidToStr", - params: [ - { - identifier: "value", - valueType: "void", - }, - ], - returnType: "str", - }, - nullToStr: { - identifier: "nullToStr", - params: [ - { - identifier: "value", - valueType: "null", - }, - ], - returnType: "str", - }, - undefinedToStr: { - identifier: "undefinedToStr", - params: [ - { - identifier: "value", - valueType: "undefined", - }, - ], - returnType: "str", - }, - strToNum: { - identifier: "strToNum", - params: [ - { - identifier: "value", - valueType: "str", - }, - ], - returnType: "num", - }, - boolToNum: { - identifier: "boolToNum", - params: [ - { - identifier: "value", - valueType: "bool", - }, - ], - returnType: "num", - }, - slice: { - identifier: "slice", - params: [ - { - identifier: "objLike", - valueType: "str", // TODO: Implement this for all objLike types (At the moment only strings are supported) - }, - { - identifier: "start", - valueType: ["num", "undefined"], // Optional - }, - { - identifier: "end", - valueType: ["num", "undefined"], // Optional - }, - ], - returnType: "str", // TODO: Implement this for all objLike types (At the moment only strings are supported) - }, - index: { - identifier: "index", - params: [ - { - identifier: "arrayLike", - valueType: "str", // TODO: Implement this for all arrayLike types (At the moment only strings are supported) - }, - { - identifier: "indexOrKey", - valueType: "num", - }, - ], - returnType: "str", // TODO: Implement this for all arrayLike types (At the moment only strings are supported) - }, - repeatString: { - identifier: "repeatString", - params: [ - { - identifier: "toRepeat", - valueType: "str", - }, - { - identifier: "times", - valueType: "num", - }, - ], - returnType: "str", - }, -} satisfies Record; - -/** - * Contains all the built-in variables in Kipper that are available per default in every program. - * @since 0.10.0 - */ -export const kipperRuntimeBuiltInVariables: Record = { - __name__: { - identifier: "__name__", - valueType: "str", - local: true, - }, -}; diff --git a/kipper/core/src/compiler/analysis/analyser/err-handler/index.ts b/kipper/core/src/compiler/semantics/analyser/err-handler/index.ts similarity index 100% rename from kipper/core/src/compiler/analysis/analyser/err-handler/index.ts rename to kipper/core/src/compiler/semantics/analyser/err-handler/index.ts diff --git a/kipper/core/src/compiler/analysis/analyser/err-handler/semantics-asserter.ts b/kipper/core/src/compiler/semantics/analyser/err-handler/semantics-asserter.ts similarity index 94% rename from kipper/core/src/compiler/analysis/analyser/err-handler/semantics-asserter.ts rename to kipper/core/src/compiler/semantics/analyser/err-handler/semantics-asserter.ts index 739fb7d19..c26120f31 100644 --- a/kipper/core/src/compiler/analysis/analyser/err-handler/semantics-asserter.ts +++ b/kipper/core/src/compiler/semantics/analyser/err-handler/semantics-asserter.ts @@ -4,8 +4,7 @@ * @since 0.7.0 */ import type { KipperProgramContext } from "../../../program-ctx"; -import type { KipperError } from "../../../../errors"; -import type { KipperNotImplementedError } from "../../../../errors"; +import type { KipperError, KipperNotImplementedError } from "../../../../errors"; import type { CompilableASTNode } from "../../../ast"; import { KipperSemanticErrorHandler } from "./semantics-error-handler"; import { getParseRuleSource } from "../../../../tools"; diff --git a/kipper/core/src/compiler/analysis/analyser/err-handler/semantics-error-handler.ts b/kipper/core/src/compiler/semantics/analyser/err-handler/semantics-error-handler.ts similarity index 100% rename from kipper/core/src/compiler/analysis/analyser/err-handler/semantics-error-handler.ts rename to kipper/core/src/compiler/semantics/analyser/err-handler/semantics-error-handler.ts diff --git a/kipper/core/src/compiler/analysis/analyser/index.ts b/kipper/core/src/compiler/semantics/analyser/index.ts similarity index 100% rename from kipper/core/src/compiler/analysis/analyser/index.ts rename to kipper/core/src/compiler/semantics/analyser/index.ts diff --git a/kipper/core/src/compiler/analysis/analyser/semantic-checker.ts b/kipper/core/src/compiler/semantics/analyser/semantic-checker.ts similarity index 85% rename from kipper/core/src/compiler/analysis/analyser/semantic-checker.ts rename to kipper/core/src/compiler/semantics/analyser/semantic-checker.ts index 165de7f7f..ae6ae683d 100644 --- a/kipper/core/src/compiler/analysis/analyser/semantic-checker.ts +++ b/kipper/core/src/compiler/semantics/analyser/semantic-checker.ts @@ -10,19 +10,12 @@ import type { CompilableNodeParent, JumpStatement, ReturnStatement, - ScopeNode, VariableDeclaration, } from "../../ast"; -import { LambdaExpression } from "../../ast"; -import { - CompoundStatement, - Expression, - FunctionDeclaration, - IdentifierPrimaryExpression, - IterationStatement, -} from "../../ast"; +import { LambdaExpression, Expression } from "../../ast"; +import { CompoundStatement, FunctionDeclaration, IdentifierPrimaryExpression, IterationStatement } from "../../ast"; import { KipperSemanticsAsserter } from "./err-handler"; -import type { LocalScope, Scope } from "../symbol-table"; +import type { Scope } from "../symbol-table"; import { ScopeDeclaration, ScopeFunctionDeclaration, ScopeVariableDeclaration } from "../symbol-table"; import { BuiltInOrInternalGeneratorFunctionNotFoundError, @@ -53,28 +46,21 @@ export class KipperSemanticChecker extends KipperSemanticsAsserter { /** * Tries to find a reference for the given identifier and scope. * @param identifier The identifier to search for. - * @param scopeCtx The scopeCtx to search in. If undefined, the global scope is used. + * @param scope The scope to search in. * @since 0.8.0 */ - protected getReference(identifier: string, scopeCtx?: ScopeNode): KipperReferenceable | undefined { - return ( - (scopeCtx // First try to fetch from the local scope if it is defined - ? scopeCtx.innerScope.getEntryRecursively(identifier) - : this.programCtx.globalScope.getEntry(identifier)) ?? - this.programCtx.globalScope.getEntry(identifier) ?? // Fall back to looking globally - this.programCtx.getBuiltInFunction(identifier) ?? // Fall back to searching through built-in functions - this.programCtx.getBuiltInVariable(identifier) // Fall back to searching through built-in variables - ); + protected getReference(identifier: string, scope: Scope): KipperReferenceable | undefined { + return scope.getEntryRecursively(identifier); } /** * Tries to fetch the function, and if it fails it will throw an {@link UnknownReferenceError}. * @param identifier The identifier to fetch. - * @param localScopeNode The ctx of the local scope, which will be also checked if it is defined. + * @param scope The scope to search in. * @since 0.7.0 */ - public getExistingReference(identifier: string, localScopeNode?: ScopeNode): KipperReferenceable { - const ref = this.getReference(identifier, localScopeNode); + public getExistingReference(identifier: string, scope: Scope): KipperReferenceable { + const ref = this.getReference(identifier, scope); if (!ref) { throw this.assertError(new UnknownReferenceError(identifier)); } @@ -88,7 +74,7 @@ export class KipperSemanticChecker extends KipperSemanticsAsserter { * @since 0.10.0 */ public refTargetDefined(ref: KipperReferenceable): void { - if (ref instanceof ScopeDeclaration && !ref.hasValue) { + if (!ref.hasValue) { throw this.assertError(new UndefinedReferenceError(ref.identifier)); } } @@ -129,7 +115,7 @@ export class KipperSemanticChecker extends KipperSemanticsAsserter { * @since 0.7.0 */ public builtInNotDefined(identifier: string): void { - if (this.programCtx.getBuiltInFunction(identifier)) { + if (this.programCtx.universeScope.getEntry(identifier) !== undefined) { throw this.assertError(new BuiltInOverwriteError(identifier)); } } @@ -141,7 +127,7 @@ export class KipperSemanticChecker extends KipperSemanticsAsserter { * @since 0.7.0 */ public globalCanBeRegistered(identifier: string): void { - let identifierAlreadyExists: boolean = this.programCtx.globalScope.getEntry(identifier) !== undefined; + let identifierAlreadyExists: boolean = this.programCtx.universeScope.getEntry(identifier) !== undefined; let globalAlreadyExists: boolean = this.programCtx.getBuiltInFunction(identifier) !== undefined || this.programCtx.getBuiltInVariable(identifier) !== undefined; diff --git a/kipper/core/src/compiler/analysis/analyser/type-checker.ts b/kipper/core/src/compiler/semantics/analyser/type-checker.ts similarity index 68% rename from kipper/core/src/compiler/analysis/analyser/type-checker.ts rename to kipper/core/src/compiler/semantics/analyser/type-checker.ts index edb48e90a..cf3b44a27 100644 --- a/kipper/core/src/compiler/analysis/analyser/type-checker.ts +++ b/kipper/core/src/compiler/semantics/analyser/type-checker.ts @@ -3,19 +3,19 @@ * invalid use of types and identifiers is detected. * @since 0.7.0 */ -import type { BuiltInFunctionArgument } from "../../runtime-built-ins"; +import type { BuiltInFunctionArgument } from "../runtime-built-ins"; import type { KipperProgramContext } from "../../program-ctx"; import type { - IncrementOrDecrementPostfixExpressionSemantics, - ParameterDeclarationSemantics, - UnaryExpressionSemantics, AssignmentExpression, FunctionDeclaration, IncrementOrDecrementPostfixExpression, + IncrementOrDecrementPostfixExpressionSemantics, MemberAccessExpression, + ParameterDeclarationSemantics, RelationalExpression, Statement, UnaryExpression, + UnaryExpressionSemantics, LambdaExpression, } from "../../ast"; import { @@ -28,25 +28,24 @@ import { Expression, } from "../../ast"; import { KipperSemanticsAsserter } from "./err-handler"; -import { ScopeDeclaration, ScopeParameterDeclaration, ScopeVariableDeclaration } from "../symbol-table"; -import type { - KipperArithmeticOperator, - KipperBitwiseOperator, - KipperCompilableType, - KipperReferenceableFunction, -} from "../../const"; +import type { Scope, ScopeFunctionDeclaration } from "../symbol-table"; +import { + BuiltInTypes, + ScopeDeclaration, + ScopeParameterDeclaration, + ScopeTypeDeclaration, + ScopeVariableDeclaration, +} from "../symbol-table"; +import type { KipperArithmeticOperator, KipperBitwiseOperator, KipperReferenceable } from "../../const"; import { - kipperCompilableTypes, kipperIncrementOrDecrementOperators, kipperMultiplicativeOperators, kipperPlusOperator, - kipperStrType, kipperSupportedConversions, } from "../../const"; +import type { TypeError } from "../../../errors"; import { - ArgumentTypeError, ArithmeticOperationTypeError, - AssignmentTypeError, BitwiseOperationTypeError, ExpressionNotCallableError, IncompleteReturnsInCodePathsError, @@ -59,11 +58,12 @@ import { KipperError, KipperNotImplementedError, ReadOnlyWriteTypeError, + ReferenceCanNotBeUsedAsTypeError, UnknownTypeError, ValueNotIndexableTypeError, } from "../../../errors"; -import type { UncheckedType } from "../type"; -import { CheckedType, UndefinedCustomType } from "../type"; +import type { RawType, ProcessedType } from "../types"; +import { UndefinedType } from "../types"; import type { Reference } from "../reference"; /** @@ -77,47 +77,35 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { } /** - * Gets the type that should be used for the type checking from the provided {@link CheckedType}. - * - * This function is intended to check for {@link UndefinedCustomType}, which is a special type that is created - * during error recovery to indicate a type is invalid/undefined. This type should be always ignored and as such - * this function will return undefined, so that they type checking is skipped. (This is fine, since the compiler - * should have already thrown an error at the creation of the {@link UndefinedCustomType}.) - * @param type The {@link CheckedType} instance. - */ - public static getTypeForAnalysis(type: CheckedType): KipperCompilableType | undefined { - if (type.isCompilable) { - return type.kipperType; - } - return undefined; - } - - /** - * Asserts that the passed type identifier exists. + * Fetches the type from the identifier and throws an error if the type is not found. * @param type The type to check. + * @param scope The scope to check in. * @since 0.7.0 */ - public typeExists(type: string): void { - if (kipperCompilableTypes.find((val) => val === type) === undefined) { + public getTypeFromIdentifier(type: string, scope: Scope): ScopeTypeDeclaration { + const scopeEntry = scope.getEntryRecursively(type); + if (scopeEntry === undefined) { throw this.assertError(new UnknownTypeError(type)); + } else if (!(scopeEntry instanceof ScopeTypeDeclaration)) { + throw this.assertError(new ReferenceCanNotBeUsedAsTypeError(type)); } + return scopeEntry; } /** - * Creates a new {@link CheckedType} instance based on the passed {@link KipperType}. + * Creates a new {@link ProcessedType} instance based on the passed {@link KipperType}. * - * If the type is invalid, the function will still return a {@link CheckedType}, but the field - * {@link CheckedType.isCompilable} will be false and the instance WILL NOT be usable for a compilation. - * @param type The unchecked type to analyse. + * If the rawType is invalid, the function will still return a {@link ProcessedType}, but the field + * {@link ProcessedType.isCompilable} will be false and the instance WILL NOT be usable for a compilation. + * @param rawType The unchecked rawType to analyse. + * @param scope The scope to check in. */ - public getCheckedType(type: UncheckedType): CheckedType { + public getCheckedType(rawType: RawType, scope: Scope): ProcessedType { try { - // Ensure the type exists - this.typeExists(type.identifier); - - return CheckedType.fromCompilableType(type.identifier); + const type = this.getTypeFromIdentifier(rawType.identifier, scope); + return type.typeValue; } catch (e) { - // If the error is not a KipperError, rethrow it (since it is not a type error, and we don't know what happened) + // If the error is not a KipperError, rethrow it (since it is not a rawType error, and we don't know what happened) if (!(e instanceof KipperError)) { throw e; } @@ -127,8 +115,8 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { // throwing any errors, which would be VERY bad.) this.programCtx.reportError(e); - // Recover from the error by wrapping the undefined type - return CheckedType.fromKipperType(new UndefinedCustomType(type.identifier)); + // Recover from the error by wrapping the undefined rawType + return new UndefinedType(rawType.identifier); } // If error recovery is not enabled, we shouldn't bother trying to handle invalid types @@ -136,24 +124,6 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { } } - /** - * Checks whether the passed types are matching. - * @param type1 The first type that is given. - * @param type2 The second type that is given. - * @returns True if the types are matching, otherwise false. - * @since 0.10.0 - */ - public checkMatchingTypes(type1: KipperCompilableType, type2: KipperCompilableType): boolean { - if (type1 !== type2) { - // 'void' is compatible with 'undefined' - let interchangeableTypes = ["void", "undefined"]; - - // Ensure that 'true' is still returned when type1 and type2 are compatible - return interchangeableTypes.includes(type1) && interchangeableTypes.includes(type2); - } - return true; - } - /** * Asserts that the passed {@link ref} is callable. This function will only check {@link ScopeDeclaration} instances, * since {@link BuiltInFunction built-in functions} will always be callable. @@ -164,15 +134,15 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { public refTargetCallable(ref: Expression | Reference): void { if ("refTarget" in ref && ref.refTarget instanceof ScopeDeclaration) { const target = ref.refTarget; - const targetType = KipperTypeChecker.getTypeForAnalysis(target.type); - if (targetType === undefined) { + const targetType = target.type; + if (!targetType.isCompilable) { return; // Ignore undefined types - Skip type checking (the type is invalid anyway) } // If the reference is not callable, throw an error if (!target.isCallable) { - throw this.assertError(new ExpressionNotCallableError(targetType)); - } else if (target instanceof ScopeParameterDeclaration || target instanceof ScopeVariableDeclaration) { + throw this.assertError(new ExpressionNotCallableError(targetType.identifier)); + } else if (ref instanceof ScopeParameterDeclaration || ref instanceof ScopeVariableDeclaration) { // Calling a function stored in a variable or parameter is not implemented yet throw this.notImplementedError( new KipperNotImplementedError("Function calls from variable references are not implemented yet."), @@ -206,23 +176,25 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { } // Get the compile-types for the left and right hand side - const varType = KipperTypeChecker.getTypeForAnalysis(leftExpTypeData.evaluatedType); - const valueType = KipperTypeChecker.getTypeForAnalysis(rightExpTypeData.evaluatedType); + const varType = leftExpTypeData.evaluatedType; + const valueType = rightExpTypeData.evaluatedType; - // If either one of the types is undefined, skip type checking (the types are invalid anyway) - if (varType === undefined || valueType === undefined) { + // If either one of the types can't be compiled or evaluated then we skip this step + if (!varType.isCompilable || !valueType.isCompilable) { return; } // Ensure that the types are matching - if not, throw an error - if (!this.checkMatchingTypes(varType, valueType)) { - throw this.assertError(new AssignmentTypeError(varType, valueType)); + try { + valueType.assertAssignableTo(varType); + } catch (e) { + throw this.assertError(e); } // Ensure that all arithmetic assignment operators except '+=' are only used on numbers - if (semanticData.operator !== "=" && valueType !== "num") { + if (semanticData.operator !== "=" && valueType !== BuiltInTypes.num) { // Strings may use the '+=' operator to concatenate (e.g. 'str += str') - if (!(semanticData.operator === "+=" && valueType === "str")) { + if (!(semanticData.operator === "+=" && valueType === BuiltInTypes.str)) { throw this.assertError(new ArithmeticOperationTypeError()); } } @@ -237,17 +209,19 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { */ public validVariableDefinition(scopeEntry: ScopeVariableDeclaration, value: Expression): void { // Get the compile-types for the left and right hand side - const leftExpType = KipperTypeChecker.getTypeForAnalysis(scopeEntry.type); - const rightExpType = KipperTypeChecker.getTypeForAnalysis(value.getTypeSemanticData().evaluatedType); + const leftExpType = scopeEntry.type; + const rightExpType = value.getTypeSemanticData().evaluatedType; - // If either one of the types is undefined, skip type checking (the types are invalid anyway) - if (leftExpType === undefined || rightExpType === undefined) { + // If either one of the types can't be compiled or evaluated then we skip this step + if (!leftExpType.isCompilable || !rightExpType.isCompilable) { return; } // Ensure the value of the definition match the definition type - if (!this.checkMatchingTypes(leftExpType, rightExpType)) { - throw this.assertError(new AssignmentTypeError(rightExpType, leftExpType)); + try { + rightExpType.assertAssignableTo(leftExpType); + } catch (e) { + throw this.assertError(e); } } @@ -257,12 +231,12 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { * @param receivedType The type that was received. * @example * call print("x"); // <-- Parameter type 'str' must match type of argument "x" - * @throws {ArgumentTypeError} If the given argument type does not match the parameter type. + * @throws {ArgumentAssignmentTypeError} If the given argument type does not match the parameter type. * @since 0.7.0 */ - public validArgumentValue(arg: ParameterDeclaration | BuiltInFunctionArgument, receivedType: CheckedType): void { + public validArgumentValue(arg: ParameterDeclaration | BuiltInFunctionArgument, receivedType: ProcessedType): void { let semanticData: ParameterDeclarationSemantics | BuiltInFunctionArgument; - let argType: CheckedType; + let argType: ProcessedType; // Get the proper semantic data and value type if (arg instanceof ParameterDeclaration) { @@ -270,20 +244,18 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { argType = arg.getTypeSemanticData().valueType; } else { semanticData = arg; - argType = CheckedType.fromCompilableType(arg.valueType); + argType = arg.valueType; } - // Get the compile-types for the parameter and argument (value provided) - const receivedCompileType = KipperTypeChecker.getTypeForAnalysis(receivedType); - const argCompileType = KipperTypeChecker.getTypeForAnalysis(argType); - - // If either one of the types is undefined, skip type checking (the types are invalid anyway) - if (receivedCompileType === undefined || argCompileType === undefined) { + // If either one of the types can't be compiled or evaluated then we skip this step + if (!receivedType.isCompilable || !argType.isCompilable) { return; } - if (!this.checkMatchingTypes(argCompileType, receivedCompileType)) { - throw this.assertError(new ArgumentTypeError(semanticData.identifier, argCompileType, receivedCompileType)); + try { + receivedType.assertAssignableTo(argType, undefined, semanticData.identifier); + } catch (e) { + throw this.assertError(e); } } @@ -292,10 +264,10 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { * @param func The function that is called. * @param args The arguments for the call expression. * @throws {InvalidAmountOfArgumentsError} If the amount of arguments is invalid e.g. too many or too few. - * @throws {ArgumentTypeError} If any given argument type does not match the required parameter type. + * @throws {ArgumentAssignmentTypeError} If any given argument type does not match the required parameter type. * @since 0.7.0 */ - public validFunctionCallArguments(func: KipperReferenceableFunction, args: Array): void { + public validFunctionCallArguments(func: ScopeFunctionDeclaration, args: Array): void { if (func.params.length != args.length) { throw this.assertError(new InvalidAmountOfArgumentsError(func.identifier, func.params.length, args.length)); } @@ -321,17 +293,17 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { const rightOpTypeData = semanticData.rightOp.getTypeSemanticData(); // Get the compile-types for the operands - const leftOpType = KipperTypeChecker.getTypeForAnalysis(leftOpTypeData.evaluatedType); - const rightOpType = KipperTypeChecker.getTypeForAnalysis(rightOpTypeData.evaluatedType); + const leftOpType = leftOpTypeData.evaluatedType; + const rightOpType = rightOpTypeData.evaluatedType; - // If either one of the types is undefined, skip type checking (the types are invalid anyway) - if (leftOpType === undefined || rightOpType === undefined) { + // If either one of the types can't be compiled or evaluated then we skip this step + if (!leftOpType.isCompilable || !rightOpType.isCompilable) { return; } // Ensure that both expressions are of type 'num' - if (leftOpType !== "num" || rightOpType !== "num") { - throw this.assertError(new InvalidRelationalComparisonTypeError(leftOpType, rightOpType)); + if (leftOpType !== BuiltInTypes.num || rightOpType !== BuiltInTypes.num) { + throw this.assertError(new InvalidRelationalComparisonTypeError(leftOpType.identifier, rightOpType.identifier)); } } @@ -344,22 +316,20 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { * @since 0.9.0 */ public validUnaryExpression(operand: UnaryExpression | IncrementOrDecrementPostfixExpression): void { - const semanticData = ( - operand.getSemanticData() - ); + const semanticData = operand.getSemanticData() as + | UnaryExpressionSemantics + | IncrementOrDecrementPostfixExpressionSemantics; const expTypeSemantics = semanticData.operand.getTypeSemanticData(); + const expType = expTypeSemantics.evaluatedType; - // Get the compile-types type of the expression - const expType = KipperTypeChecker.getTypeForAnalysis(expTypeSemantics.evaluatedType); - - // If the expression type is undefined, skip type checking (the type is invalid anyway) - if (expType === undefined) { + // If the type is undefined, skip type checking (the type is invalid anyway) + if (!expType.isCompilable) { return; } // Ensure that the operator '+', '-', '++' and '--' are only used on numbers - if (semanticData.operator !== "!" && expType !== "num") { - throw this.assertError(new InvalidUnaryExpressionTypeError(semanticData.operator, expType)); + if (semanticData.operator !== "!" && expType !== BuiltInTypes.num) { + throw this.assertError(new InvalidUnaryExpressionTypeError(semanticData.operator, expType.identifier)); } // Ensure that the operand of an '++' and '--' modifier expression is a reference @@ -392,8 +362,8 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { */ public validArithmeticExpression(leftOp: Expression, rightOp: Expression, op: KipperArithmeticOperator): void { // Get the compile-types for both operands - const leftOpType = KipperTypeChecker.getTypeForAnalysis(leftOp.getTypeSemanticData().evaluatedType); - const rightOpType = KipperTypeChecker.getTypeForAnalysis(rightOp.getTypeSemanticData().evaluatedType); + const leftOpType = leftOp.getTypeSemanticData().evaluatedType; + const rightOpType = rightOp.getTypeSemanticData().evaluatedType; // If either one of the types is undefined, skip type checking (the types are invalid anyway) if (leftOpType === undefined || rightOpType === undefined) { @@ -401,19 +371,23 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { } // Numbers may use all arithmetic operators - if (leftOpType !== "num" || rightOpType !== "num") { + if (leftOpType !== BuiltInTypes.num || rightOpType !== BuiltInTypes.num) { // Strings can use '+' to concat strings - if (op === kipperPlusOperator && leftOpType == kipperStrType && rightOpType == kipperStrType) { + if (op === kipperPlusOperator && leftOpType == BuiltInTypes.str && rightOpType == BuiltInTypes.str) { return; } // Strings can use * to repeat a string n times - if (op === kipperMultiplicativeOperators[0] && leftOpType == kipperStrType && rightOpType == "num") { + if ( + op === kipperMultiplicativeOperators[0] && + leftOpType == BuiltInTypes.str && + rightOpType == BuiltInTypes.num + ) { return; } // If types are not matching, not numeric, and they are not of string-like types, throw an error - throw this.assertError(new ArithmeticOperationTypeError(leftOpType, rightOpType)); + throw this.assertError(new ArithmeticOperationTypeError(leftOpType.identifier, rightOpType.identifier)); } } @@ -426,17 +400,17 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { * @since 0.11.0 */ public validBitwiseExpression(leftOp: Expression, rightOp: Expression, op: KipperBitwiseOperator): void { - const leftOpType = KipperTypeChecker.getTypeForAnalysis(leftOp.getTypeSemanticData().evaluatedType); - const rightOpType = KipperTypeChecker.getTypeForAnalysis(rightOp.getTypeSemanticData().evaluatedType); + const leftOpType = leftOp.getTypeSemanticData().evaluatedType; + const rightOpType = rightOp.getTypeSemanticData().evaluatedType; // If either one of the types is undefined, skip type checking (the types are invalid anyway) - if (leftOpType === undefined || rightOpType === undefined) { + if (!leftOpType.isCompilable || !rightOpType.isCompilable) { return; } // Ensure that both expressions are of type 'num' - if (leftOpType !== "num" || rightOpType !== "num") { - throw this.assertError(new BitwiseOperationTypeError(leftOpType, rightOpType)); + if (leftOpType !== BuiltInTypes.num || rightOpType !== BuiltInTypes.num) { + throw this.assertError(new BitwiseOperationTypeError(leftOpType.identifier, rightOpType.identifier)); } } @@ -447,25 +421,30 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { * @throws {InvalidConversionTypeError} If the conversion is invalid/impossible. * @since 0.8.0 */ - public validConversion(operand: Expression, targetType: CheckedType): void { + public validConversion(operand: Expression, targetType: ProcessedType): void { // Get the compile-types for the specified conversion types - const originalCompileType = KipperTypeChecker.getTypeForAnalysis(operand.getTypeSemanticData().evaluatedType); - const targetCompileType = KipperTypeChecker.getTypeForAnalysis(targetType); + const originalCompileType = operand.getTypeSemanticData().evaluatedType; + const targetCompileType = targetType; // If either one of the types is undefined, skip type checking (the types are invalid anyway) - if (originalCompileType === undefined || targetCompileType === undefined) { + if (!originalCompileType.isCompilable || !targetCompileType.isCompilable) { + return; + } + + // Return early if the types are the same + if (originalCompileType === targetCompileType) { return; } - // Check whether a supported pair of types exist. + // Check whether a supported pair of types exist const viableConversion = kipperSupportedConversions.find( - (types) => types[0] === originalCompileType && types[1] === targetType.kipperType, + (types) => BuiltInTypes[types[0]] === originalCompileType && BuiltInTypes[types[1]] === targetType, ) !== undefined; - - // In case that the targetType are not the same and no conversion is possible, throw an error! - if (originalCompileType !== targetCompileType && !viableConversion) { - throw this.assertError(new InvalidConversionTypeError(originalCompileType, targetCompileType)); + if (!viableConversion) { + throw this.assertError( + new InvalidConversionTypeError(originalCompileType.identifier, targetCompileType.identifier), + ); } } @@ -479,12 +458,13 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { const semanticData = returnStatement.getSemanticData(); // If the return statement has no return value, then the value is automatically 'void' - const statementValueType = KipperTypeChecker.getTypeForAnalysis( - semanticData.returnValue?.getTypeSemanticData().evaluatedType ?? CheckedType.fromCompilableType("void"), - ); - const functionReturnType = KipperTypeChecker.getTypeForAnalysis( - // TODO! DON'T DO THIS. THIS IS PUTTING TYPE CHECKING OF A PARENT INTO A CHILD - this.getCheckedType(semanticData.function.getSemanticData().returnType), + const statementValueType = semanticData.returnValue?.getTypeSemanticData().evaluatedType ?? BuiltInTypes.void; + + // TODO! DON'T DO THIS. THIS IS PUTTING TYPE CHECKING OF A PARENT INTO A CHILD + // TODO! REALLY WE NEED TO REMOVE THIS SOON + const functionReturnType = this.getCheckedType( + semanticData.function.getSemanticData().returnType, + semanticData.function.scope, ); // If either one of the types is undefined, skip type checking (the types are invalid anyway) @@ -494,8 +474,10 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { // We need to check whether the types are matching, but *not* if the function return type is valid, since that // will be done later by the function itself during the type checking. - if (statementValueType && !this.checkMatchingTypes(statementValueType, functionReturnType)) { - throw this.assertError(new AssignmentTypeError(statementValueType, functionReturnType)); + try { + statementValueType.assertAssignableTo(functionReturnType); + } catch (e) { + throw this.assertError(e); } } @@ -510,7 +492,7 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { public validReturnCodePathsInFunctionBody(func: FunctionDeclaration | LambdaExpression): void { const semanticData = func.getSemanticData(); const typeData = func.getTypeSemanticData(); - const returnType = KipperTypeChecker.getTypeForAnalysis(typeData.returnType); + const returnType = typeData.returnType; // If the return type is undefined, skip type checking (the type is invalid anyway) if (returnType === undefined) { @@ -520,7 +502,7 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { // If the function return type is not 'void' then there must be a return statement in all code paths // Note: We will ignore types here, since the return statements themselves with check later if they have the proper // return type. - if (returnType !== "void") { + if (returnType !== BuiltInTypes.void) { // Recursively check all code paths to ensure all return a value. const checkChildrenCodePaths = (parent: Statement | Expression | CompoundStatement): boolean => { let returnPathsCovered = false; @@ -591,7 +573,7 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { * @since 0.10.0 */ public objectLikeIsIndexableOrAccessible(objLike: Expression): void { - const objType = KipperTypeChecker.getTypeForAnalysis(objLike.getTypeSemanticData().evaluatedType); + const objType = objLike.getTypeSemanticData().evaluatedType; // If the obj type is undefined, skip type checking (the type is invalid anyway) if (objType === undefined) { @@ -599,8 +581,8 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { } // TODO! Add support for 'object' types once they are implemented - if (objType !== "str" && objType !== "list") { - throw this.assertError(new ValueNotIndexableTypeError(objType)); + if (objType !== BuiltInTypes.str && objType !== BuiltInTypes.list) { + throw this.assertError(new ValueNotIndexableTypeError(objType.identifier)); } } @@ -612,8 +594,8 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { * @since 0.10.0 */ public validBracketNotationKey(objLike: Expression, key: Expression): void { - const objType = KipperTypeChecker.getTypeForAnalysis(objLike.getTypeSemanticData().evaluatedType); - const keyType = KipperTypeChecker.getTypeForAnalysis(key.getTypeSemanticData().evaluatedType); + const objType = objLike.getTypeSemanticData().evaluatedType; + const keyType = key.getTypeSemanticData().evaluatedType; // If the obj or key type are undefined, skip type checking (the types are invalid anyway) if (objType === undefined || keyType === undefined) { @@ -621,8 +603,8 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { } // As currently only strings and lists are indexable, for now we only need to check for numeric indexes - if (keyType !== "num") { - throw this.assertError(new InvalidKeyTypeError(objType, keyType)); + if (keyType !== BuiltInTypes.num) { + throw this.assertError(new InvalidKeyTypeError(objType.identifier, keyType.identifier)); } } @@ -634,13 +616,9 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { * @since 0.10.0 */ public validSliceNotationKey(objLike: Expression, key: { start?: Expression; end?: Expression }): void { - const objType = KipperTypeChecker.getTypeForAnalysis(objLike.getTypeSemanticData().evaluatedType); - const startType = key.start - ? KipperTypeChecker.getTypeForAnalysis(key.start.getTypeSemanticData().evaluatedType) - : undefined; - const endType = key.end - ? KipperTypeChecker.getTypeForAnalysis(key.end.getTypeSemanticData().evaluatedType) - : undefined; + const objType = objLike.getTypeSemanticData().evaluatedType; + const startType = key.start ? key.start.getTypeSemanticData().evaluatedType : undefined; + const endType = key.end ? key.end.getTypeSemanticData().evaluatedType : undefined; // If the obj type is undefined, skip type checking (the type is invalid anyway) if (objType === undefined) { @@ -648,10 +626,10 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { } // As currently only strings and lists are indexable, for now we only need to check for numeric indexes - if (startType !== undefined && startType !== "num") { - throw this.assertError(new InvalidKeyTypeError(objType, startType), key.start); - } else if (endType !== undefined && endType !== "num") { - throw this.assertError(new InvalidKeyTypeError(objType, endType), key.end); + if (startType !== undefined && startType !== BuiltInTypes.num) { + throw this.assertError(new InvalidKeyTypeError(objType.identifier, startType.identifier), key.start); + } else if (endType !== undefined && endType !== BuiltInTypes.num) { + throw this.assertError(new InvalidKeyTypeError(objType.identifier, endType.identifier), key.end); } } @@ -660,14 +638,14 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { * @param memberAccess The member access expression to get the type for. * @since 0.10.0 */ - public getTypeOfMemberAccessExpression(memberAccess: MemberAccessExpression): CheckedType { + public getTypeOfMemberAccessExpression(memberAccess: MemberAccessExpression): ProcessedType { const semanticData = memberAccess.getSemanticData(); // First ensure the object is indexable this.objectLikeIsIndexableOrAccessible(semanticData.objectLike); const preAnalysisType = semanticData.objectLike.getTypeSemanticData().evaluatedType; - const objType = KipperTypeChecker.getTypeForAnalysis(preAnalysisType); + const objType = preAnalysisType; // If the obj type is undefined, skip type checking (the type is invalid anyway) if (objType === undefined) { @@ -680,11 +658,11 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { new KipperNotImplementedError("Member access expression using dot notation is not implemented yet"), ); case "bracket": { - if (objType === "str") { + if (objType === BuiltInTypes.str) { // Also ensure the key is valid this.validBracketNotationKey(semanticData.objectLike, semanticData.propertyIndexOrKeyOrSlice); - return CheckedType.fromCompilableType("str"); + return BuiltInTypes.str; } else { // Must be a list -> Not implemented yet throw this.notImplementedError( @@ -693,14 +671,14 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { } } case "slice": { - if (objType === "str") { + if (objType === BuiltInTypes.str) { // Also ensure the key is valid this.validSliceNotationKey( semanticData.objectLike, <{ start?: Expression; end?: Expression }>semanticData.propertyIndexOrKeyOrSlice, ); - return CheckedType.fromCompilableType("str"); + return BuiltInTypes.str; } else { // Must be a list -> Not implemented yet throw this.notImplementedError( @@ -719,8 +697,8 @@ export class KipperTypeChecker extends KipperSemanticsAsserter { * @since 0.11.0 */ validConditionalExpression(trueBranch: Expression, falseBranch: Expression) { - const trueBranchType = KipperTypeChecker.getTypeForAnalysis(trueBranch.getTypeSemanticData().evaluatedType); - const falseBranchType = KipperTypeChecker.getTypeForAnalysis(falseBranch.getTypeSemanticData().evaluatedType); + const trueBranchType = trueBranch.getTypeSemanticData().evaluatedType; + const falseBranchType = falseBranch.getTypeSemanticData().evaluatedType; // If the branch types are undefined, skip type checking (the types are invalid anyway) if (trueBranchType === undefined || falseBranchType === undefined) { diff --git a/kipper/core/src/compiler/analysis/analyser/warning-issuer.ts b/kipper/core/src/compiler/semantics/analyser/warning-issuer.ts similarity index 100% rename from kipper/core/src/compiler/analysis/analyser/warning-issuer.ts rename to kipper/core/src/compiler/semantics/analyser/warning-issuer.ts diff --git a/kipper/core/src/compiler/analysis/handle-error.ts b/kipper/core/src/compiler/semantics/handle-error.ts similarity index 100% rename from kipper/core/src/compiler/analysis/handle-error.ts rename to kipper/core/src/compiler/semantics/handle-error.ts diff --git a/kipper/core/src/compiler/analysis/index.ts b/kipper/core/src/compiler/semantics/index.ts similarity index 72% rename from kipper/core/src/compiler/analysis/index.ts rename to kipper/core/src/compiler/semantics/index.ts index 90404a5a2..5bddc3ffa 100644 --- a/kipper/core/src/compiler/analysis/index.ts +++ b/kipper/core/src/compiler/semantics/index.ts @@ -3,7 +3,9 @@ * @since 0.7.0 */ export * from "./handle-error"; +export * from "./runtime-internals"; +export * from "./runtime-built-ins"; export * from "./analyser/"; export * from "./symbol-table/"; -export * from "./type"; +export * from "./types"; export * from "./reference"; diff --git a/kipper/core/src/compiler/analysis/reference.ts b/kipper/core/src/compiler/semantics/reference.ts similarity index 95% rename from kipper/core/src/compiler/analysis/reference.ts rename to kipper/core/src/compiler/semantics/reference.ts index 61a0c2575..06f761ad6 100644 --- a/kipper/core/src/compiler/analysis/reference.ts +++ b/kipper/core/src/compiler/semantics/reference.ts @@ -4,7 +4,7 @@ */ import type { Expression } from "../ast"; import type { KipperReferenceable } from "../const"; -import type { InternalFunction } from "../runtime-built-ins"; +import type { InternalFunction } from "./runtime-internals"; /** * A {@link KipperReferenceable reference} to an identifier that stores a value or function. diff --git a/kipper/core/src/compiler/semantics/runtime-built-ins/built-in-function-argument.ts b/kipper/core/src/compiler/semantics/runtime-built-ins/built-in-function-argument.ts new file mode 100644 index 000000000..fd711bbdd --- /dev/null +++ b/kipper/core/src/compiler/semantics/runtime-built-ins/built-in-function-argument.ts @@ -0,0 +1,35 @@ +import { KipperBuiltInTypeLiteral } from "../../const"; +import type { ProcessedType } from "../types"; +import { UniverseScope } from "../symbol-table"; + +/** + * Interface representation of an argument of a {@link BuiltInFunction}. + * @since 0.1.0 + * @since 0.11.0 Became a class instead of an interface. + */ +export class BuiltInFunctionArgument { + /** + * The identifier of the argument inside the function + * + * This value does not affect the behaviour of the language, as named-arguments are not implemented in Kipper. This + * only serves the purpose of readability and allowing easier differentiation. + * @since 0.6.0 + */ + public readonly identifier: string; + + /** + * The type of the argument inside the function + * + * @example + * def func(x: num, y: str) -> void {} + * + * // x is of type 'num' + * // y is of type 'str' + */ + public readonly valueType: ProcessedType; + + public constructor(identifier: string, valueType: ProcessedType) { + this.identifier = identifier; + this.valueType = valueType; + } +} diff --git a/kipper/core/src/compiler/semantics/runtime-built-ins/built-in-function.ts b/kipper/core/src/compiler/semantics/runtime-built-ins/built-in-function.ts new file mode 100644 index 000000000..9dc0326b3 --- /dev/null +++ b/kipper/core/src/compiler/semantics/runtime-built-ins/built-in-function.ts @@ -0,0 +1,39 @@ +import type { ProcessedType } from "../types"; +import type { BuiltInFunctionArgument } from "./built-in-function-argument"; + +/** + * Interface representation of a {@link BuiltInFunction}, which is available inside a Kipper program using the specified + * metadata. + * @since 0.1.0 + * @since 0.11.0 Became a class instead of an interface. + */ +export class BuiltInFunction { + /** + * The identifier of the global function that should be available inside the program. + * + * The identifier may only contain default numbers and alphabet characters! + * @example + * print(); // 'print' is the global function identifier + */ + public readonly identifier: string; + + /** + * The args that are accepted inside this function. These are represented using {@link BuiltInFunctionArgument}. + * + * The index in the array also represents the argument position inside the function. Meaning the first item in the + * array maps to the first argument inside the function. + */ + public readonly params: Array; + + /** + * The expected return of the function. If the return type is {@link KipperVoidType void}, then the function will not + * return anything. + */ + public readonly returnType: ProcessedType; + + public constructor(identifier: string, params: Array, returnType: ProcessedType) { + this.identifier = identifier; + this.params = params; + this.returnType = returnType; + } +} diff --git a/kipper/core/src/compiler/semantics/runtime-built-ins/built-in-variable.ts b/kipper/core/src/compiler/semantics/runtime-built-ins/built-in-variable.ts new file mode 100644 index 000000000..2ac55430a --- /dev/null +++ b/kipper/core/src/compiler/semantics/runtime-built-ins/built-in-variable.ts @@ -0,0 +1,39 @@ +import { KipperBuiltInTypeLiteral } from "../../const"; +import type { ProcessedType } from "../types"; +import { UniverseScope } from "../symbol-table"; + +/** + * Interface representation of a {@link BuiltInVariable}, which is available inside a Kipper program using the specified + * metadata. + * @since 0.10.0 + */ +export class BuiltInVariable { + /** + * The identifier of the global variable that should be available inside the program. + * @since 0.10.0 + */ + public readonly identifier: string; + + /** + * The type of the variable. + * @since 0.10.0 + */ + public readonly valueType: ProcessedType; + + /** + * If true then the variable is local to the current file. If false then the variable is global and can be accessed + * from any file. + * + * This is primarily used to differentiate between local and global variables during the code generation process, + * since local ones will usually be initialised like any other variables, while globals will be registered on a global + * object. + * @since 0.10.0 + */ + public readonly local: boolean; + + public constructor(identifier: string, valueType: ProcessedType, local: boolean) { + this.identifier = identifier; + this.valueType = valueType; + this.local = local; + } +} diff --git a/kipper/core/src/compiler/semantics/runtime-built-ins/index.ts b/kipper/core/src/compiler/semantics/runtime-built-ins/index.ts new file mode 100644 index 000000000..23590e5fc --- /dev/null +++ b/kipper/core/src/compiler/semantics/runtime-built-ins/index.ts @@ -0,0 +1,7 @@ +/** + * Runtime built-ins are functions that are available to the user at runtime. + * @since 0.11.0 + */ +export * from "./built-in-function"; +export * from "./built-in-function-argument"; +export * from "./built-in-variable"; diff --git a/kipper/core/src/compiler/semantics/runtime-internals/index.ts b/kipper/core/src/compiler/semantics/runtime-internals/index.ts new file mode 100644 index 000000000..1547bde23 --- /dev/null +++ b/kipper/core/src/compiler/semantics/runtime-internals/index.ts @@ -0,0 +1,7 @@ +/** + * This file is used to export all the internal classes and functions that are used by the runtime. + * @since 0.11.0 + */ +export * from "./internal-function"; +export * from "./internal-function-argument"; +export * from "./internals"; diff --git a/kipper/core/src/compiler/semantics/runtime-internals/internal-function-argument.ts b/kipper/core/src/compiler/semantics/runtime-internals/internal-function-argument.ts new file mode 100644 index 000000000..72b79588d --- /dev/null +++ b/kipper/core/src/compiler/semantics/runtime-internals/internal-function-argument.ts @@ -0,0 +1,35 @@ +import { KipperBuiltInTypeLiteral } from "../../const"; +import type { ProcessedType } from "../types"; + +/** + * Interface representation of an argument of a {@link InternalFunction}. + * @since 0.10.0 + * @since 0.11.0 Became a class instead of an interface. + */ +export class InternalFunctionArgument { + /** + * The identifier of the argument inside the function + * + * This value does not affect the behaviour of the language, as named-arguments are not implemented in Kipper. This + * only serves the purpose of readability and allowing easier differentiation. + * @since 0.6.0 + */ + public readonly identifier: string; + + /** + * The type of the argument inside the function + * + * Unlike {@link BuiltInFunction}, this can also be an array of types, which means that the value type may be a union. + * @example + * def func(x: num, y: str) -> void {} + * + * // x is of type 'num' + * // y is of type 'str' + */ + public readonly valueType: ProcessedType | Array; + + public constructor(identifier: string, valueType: ProcessedType | Array) { + this.identifier = identifier; + this.valueType = valueType; + } +} diff --git a/kipper/core/src/compiler/semantics/runtime-internals/internal-function.ts b/kipper/core/src/compiler/semantics/runtime-internals/internal-function.ts new file mode 100644 index 000000000..f99f6d5a6 --- /dev/null +++ b/kipper/core/src/compiler/semantics/runtime-internals/internal-function.ts @@ -0,0 +1,46 @@ +import type { InternalFunctionArgument } from "./internal-function-argument"; +import { KipperBuiltInTypeLiteral } from "../../const"; +import type { ProcessedType } from "../types"; + +/** + * Interface representation of a {@link InternalFunction}, which is used to provide functionality for Kipper specific + * keywords, internal logic and other implementation related handling that must be present for a program to work. + * @since 0.8.0 + * @since 0.11.0 Became a class instead of an interface. + */ +export class InternalFunction { + /** + * The identifier of the internal function. + * + * The identifier may only contain default numbers and alphabet characters! + * @example + * "4" as num; // 'strAsNum' is the internal function used to perform this expression + * @since 0.8.0 + */ + public readonly identifier: string; + + /** + * The args that are accepted inside this function. These are represented using {@link InternalFunctionArgument}. + * + * The index in the array also represents the argument position inside the function. Meaning the first item in the + * array maps to the first argument inside the function. + * @since 0.8.0 + */ + public readonly params: Array; + + /** + * The expected return of the function. If the return type is {@link KipperVoidType void}, then the function will not + * return anything. + * + * Unlike {@link BuiltInFunction}, this can also be an array of types, which means that the function return may be a + * union. + * @since 0.8.0 + */ + public readonly returnType: ProcessedType; + + public constructor(identifier: string, params: Array, returnType: ProcessedType) { + this.identifier = identifier; + this.params = params; + this.returnType = returnType; + } +} diff --git a/kipper/core/src/compiler/semantics/runtime-internals/internals.ts b/kipper/core/src/compiler/semantics/runtime-internals/internals.ts new file mode 100644 index 000000000..c11082c68 --- /dev/null +++ b/kipper/core/src/compiler/semantics/runtime-internals/internals.ts @@ -0,0 +1,128 @@ +import type { InternalFunction } from "./internal-function"; +import { BuiltInTypes } from "../symbol-table"; + +/** + * Contains all the internal built-in functions, which are used by Kipper to provide internal functionality. These + * internal built-ins are commonly used to provide the functionality for keywords and other internal logic. + * + * This contains *every* builtin that also must be implemented by every target in the {@link KipperTargetBuiltInGenerator}. + * @since 0.8.0 + */ +export const kipperInternalBuiltInFunctions = { + numToStr: { + identifier: "numToStr", + params: [ + { + identifier: "value", + valueType: BuiltInTypes.num, + }, + ], + returnType: BuiltInTypes.str, + }, + boolToStr: { + identifier: "boolToStr", + params: [ + { + identifier: "value", + valueType: BuiltInTypes.bool, + }, + ], + returnType: BuiltInTypes.str, + }, + voidToStr: { + identifier: "voidToStr", + params: [ + { + identifier: "value", + valueType: BuiltInTypes.void, + }, + ], + returnType: BuiltInTypes.str, + }, + nullToStr: { + identifier: "nullToStr", + params: [ + { + identifier: "value", + valueType: BuiltInTypes.null, + }, + ], + returnType: BuiltInTypes.str, + }, + undefinedToStr: { + identifier: "undefinedToStr", + params: [ + { + identifier: "value", + valueType: BuiltInTypes.undefined, + }, + ], + returnType: BuiltInTypes.str, + }, + strToNum: { + identifier: "strToNum", + params: [ + { + identifier: "value", + valueType: BuiltInTypes.str, + }, + ], + returnType: BuiltInTypes.num, + }, + boolToNum: { + identifier: "boolToNum", + params: [ + { + identifier: "value", + valueType: BuiltInTypes.bool, + }, + ], + returnType: BuiltInTypes.num, + }, + slice: { + identifier: "slice", + params: [ + { + identifier: "objLike", + valueType: BuiltInTypes.str, // TODO: Implement this for all objLike types (At the moment only strings are supported) + }, + { + identifier: "start", + valueType: [BuiltInTypes.num, BuiltInTypes.undefined], // Optional + }, + { + identifier: "end", + valueType: [BuiltInTypes.num, BuiltInTypes.undefined], // Optional + }, + ], + returnType: BuiltInTypes.str, // TODO: Implement this for all objLike types (At the moment only strings are supported) + }, + index: { + identifier: "index", + params: [ + { + identifier: "arrayLike", + valueType: BuiltInTypes.str, // TODO: Implement this for all arrayLike types (At the moment only strings are supported) + }, + { + identifier: "indexOrKey", + valueType: BuiltInTypes.num, + }, + ], + returnType: BuiltInTypes.str, // TODO: Implement this for all arrayLike types (At the moment only strings are supported) + }, + repeatString: { + identifier: "repeatString", + params: [ + { + identifier: "toRepeat", + valueType: BuiltInTypes.str, + }, + { + identifier: "times", + valueType: BuiltInTypes.num, + }, + ], + returnType: BuiltInTypes.str, + }, +} satisfies Record; diff --git a/kipper/core/src/compiler/semantics/symbol-table/base/index.ts b/kipper/core/src/compiler/semantics/symbol-table/base/index.ts new file mode 100644 index 000000000..f768dee46 --- /dev/null +++ b/kipper/core/src/compiler/semantics/symbol-table/base/index.ts @@ -0,0 +1,6 @@ +/** + * Symbol table base classes and interfaces. + * @since 0.11.0 + */ +export * from "./symbol-table"; +export * from "./scope"; diff --git a/kipper/core/src/compiler/analysis/symbol-table/scope.ts b/kipper/core/src/compiler/semantics/symbol-table/base/scope.ts similarity index 76% rename from kipper/core/src/compiler/analysis/symbol-table/scope.ts rename to kipper/core/src/compiler/semantics/symbol-table/base/scope.ts index 566c03c44..21d83158e 100644 --- a/kipper/core/src/compiler/analysis/symbol-table/scope.ts +++ b/kipper/core/src/compiler/semantics/symbol-table/base/scope.ts @@ -2,8 +2,12 @@ * A symbol-table implementation in form of a scope that may contain both variables and functions. * @since 0.8.0 */ -import type { FunctionDeclaration, VariableDeclaration } from "../../ast"; -import type { ScopeDeclaration, ScopeFunctionDeclaration, ScopeVariableDeclaration } from "./entry"; +import type { + ScopeDeclaration, + ScopeFunctionDeclaration, + ScopeTypeDeclaration, + ScopeVariableDeclaration, +} from "../entry"; import type { SymbolTable } from "./symbol-table"; /** @@ -13,7 +17,7 @@ import type { SymbolTable } from "./symbol-table"; * A scope can be a child of another scope or the global scope of a {@link KipperProgramContext program}. * @since 0.8.0 */ -export abstract class Scope implements SymbolTable { +export abstract class Scope implements SymbolTable { protected readonly _entries: Map; protected constructor() { @@ -40,7 +44,7 @@ export abstract class Scope implements SymbolTable { * @returns The generated {@link ScopeVariableDeclaration scope declaration}. * @since 0.8.0 */ - public abstract addVariable(declaration: VariableDeclaration): ScopeVariableDeclaration; + public abstract addVariable(declaration: VarT): ScopeVariableDeclaration; /** * Adds a new function declaration to the {@link entries symbol table entries}. @@ -48,7 +52,15 @@ export abstract class Scope implements SymbolTable { * @returns The generated {@link ScopeFunctionDeclaration scope declaration}. * @since 0.8.0 */ - public abstract addFunction(declaration: FunctionDeclaration): ScopeFunctionDeclaration; + public abstract addFunction(declaration: FuncT): ScopeFunctionDeclaration; + + /** + * Adds a new type declaration to the {@link entries symbol table entries}. + * @param declaration The declaration to add. + * @returns The generated {@link ScopeTypeDeclaration scope declaration}. + * @since 0.11.0 + */ + public abstract addType(declaration: TypeT): ScopeTypeDeclaration; /** * Searches for a reference/entry with the specific identifier in the local hash table entries (local scope). diff --git a/kipper/core/src/compiler/analysis/symbol-table/symbol-table.ts b/kipper/core/src/compiler/semantics/symbol-table/base/symbol-table.ts similarity index 87% rename from kipper/core/src/compiler/analysis/symbol-table/symbol-table.ts rename to kipper/core/src/compiler/semantics/symbol-table/base/symbol-table.ts index 8228ee664..1812e02fd 100644 --- a/kipper/core/src/compiler/analysis/symbol-table/symbol-table.ts +++ b/kipper/core/src/compiler/semantics/symbol-table/base/symbol-table.ts @@ -1,4 +1,4 @@ -import type { ScopeDeclaration } from "./entry"; +import type { ScopeDeclaration } from "../entry"; /** * A simple interface defining the basic functionality of a symbol table. diff --git a/kipper/core/src/compiler/semantics/symbol-table/class-scope.ts b/kipper/core/src/compiler/semantics/symbol-table/class-scope.ts new file mode 100644 index 000000000..6efc40e4b --- /dev/null +++ b/kipper/core/src/compiler/semantics/symbol-table/class-scope.ts @@ -0,0 +1,17 @@ +/** + * File containing the definition for a class-specific scope that is bound to a {@link InterfaceDeclaration} and not + * the global namespace. + * @since 0.11.0 + */ +import type { ClassDeclaration } from "../../ast"; +import { LocalScope } from "./local-scope"; + +/** + * A function-specific scope that is bound to a {@link FunctionDeclaration} and not the global namespace. + * @since 0.11.0 + */ +export class ClassScope extends LocalScope { + constructor(public ctx: ClassDeclaration) { + super(ctx); + } +} diff --git a/kipper/core/src/compiler/analysis/symbol-table/entry/index.ts b/kipper/core/src/compiler/semantics/symbol-table/entry/index.ts similarity index 88% rename from kipper/core/src/compiler/analysis/symbol-table/entry/index.ts rename to kipper/core/src/compiler/semantics/symbol-table/entry/index.ts index b4864c2d1..fb71b9033 100644 --- a/kipper/core/src/compiler/analysis/symbol-table/entry/index.ts +++ b/kipper/core/src/compiler/semantics/symbol-table/entry/index.ts @@ -6,3 +6,4 @@ export * from "./scope-declaration"; export * from "./scope-variable-declaration"; export * from "./scope-parameter-declaration"; export * from "./scope-function-declaration"; +export * from "./scope-type-declaration"; diff --git a/kipper/core/src/compiler/analysis/symbol-table/entry/scope-declaration.ts b/kipper/core/src/compiler/semantics/symbol-table/entry/scope-declaration.ts similarity index 65% rename from kipper/core/src/compiler/analysis/symbol-table/entry/scope-declaration.ts rename to kipper/core/src/compiler/semantics/symbol-table/entry/scope-declaration.ts index a2d77bdec..173737f97 100644 --- a/kipper/core/src/compiler/analysis/symbol-table/entry/scope-declaration.ts +++ b/kipper/core/src/compiler/semantics/symbol-table/entry/scope-declaration.ts @@ -4,7 +4,8 @@ */ import type { Declaration } from "../../../ast"; import type { KipperProgramContext } from "../../../program-ctx"; -import type { CheckedType } from "../../type"; +import type { BuiltInType, ProcessedType } from "../../types"; +import type { BuiltInFunction, BuiltInVariable } from "../../runtime-built-ins"; /** * An symbol table entry of a variable, parameter or function declaration inside a Kipper scope. @@ -15,22 +16,34 @@ import type { CheckedType } from "../../type"; * @since 0.1.2 */ export abstract class ScopeDeclaration { - public abstract get node(): Declaration; + public abstract get node(): Declaration | undefined; public abstract get identifier(): string; /** * Fetches the {@link KipperProgramContext program context instance} for this token. */ - public get programCtx(): KipperProgramContext { - return this.node.programCtx; + public get programCtx(): KipperProgramContext | undefined { + return this.node?.programCtx; } + /** + * Returns whether this declaration is a built-in declaration. + * @since 0.11.0 + */ + public abstract get isBuiltIn(): boolean; + + /** + * Returns the built-in structure of this declaration, if this declaration is based on one. + * @since 0.11.0 + */ + public abstract get builtInStructure(): BuiltInVariable | BuiltInFunction | BuiltInType | undefined; + /** * The value type of this declaration. * @since 0.10.0 */ - public abstract get type(): CheckedType; + public abstract get type(): ProcessedType; /** * Returns whether the scope declaration was defined during its declaration. diff --git a/kipper/core/src/compiler/semantics/symbol-table/entry/scope-function-declaration.ts b/kipper/core/src/compiler/semantics/symbol-table/entry/scope-function-declaration.ts new file mode 100644 index 000000000..b9ffbd055 --- /dev/null +++ b/kipper/core/src/compiler/semantics/symbol-table/entry/scope-function-declaration.ts @@ -0,0 +1,150 @@ +/** + * A symbol table entry for a function declaration. + * @since 0.10.0 + */ +import type { + FunctionDeclaration, + FunctionDeclarationSemantics, + FunctionDeclarationTypeSemantics, + ParameterDeclaration, +} from "../../../ast"; +import { ScopeDeclaration } from "./scope-declaration"; +import type { ProcessedType } from "../../types"; +import type { BuiltInFunction, BuiltInFunctionArgument } from "../../runtime-built-ins"; +import type { UniverseScope } from "../universum-scope"; +import { BuiltInTypes } from "../universum-scope"; + +/** + * Represents the definition of a function inside a {@link Scope}. + * @since 0.1.2 + */ +export class ScopeFunctionDeclaration extends ScopeDeclaration { + private constructor( + private readonly _declaration?: FunctionDeclaration, + private readonly _builtInFunction?: BuiltInFunction, + private readonly _universeScope?: UniverseScope, + ) { + super(); + } + + /** + * Creates a new scope function declaration from a function declaration. + * @param declaration The function declaration node. + */ + public static fromFunctionDeclaration(declaration: FunctionDeclaration): ScopeFunctionDeclaration { + return new ScopeFunctionDeclaration(declaration); + } + + /** + * Creates a new scope function declaration from a function declaration. + * @param declaration The function declaration node. + */ + static fromBuiltInFunction(declaration: BuiltInFunction, universeScope: UniverseScope): ScopeFunctionDeclaration { + return new ScopeFunctionDeclaration(undefined, declaration, universeScope); + } + + /** + * Returns whether this function declaration is a built-in function. + * @since 0.11.0 + */ + public override get isBuiltIn(): boolean { + return this._builtInFunction !== undefined; + } + + /** + * Returns the built-in structure of this declaration, if this declaration is based on one. + * @since 0.11.0 + */ + public override get builtInStructure(): BuiltInFunction | undefined { + return this._builtInFunction; + } + + /** + * The semantic data of this declaration. + * @throws UndefinedSemanticsError If this is accessed, before semantic analysis was performed. + * @private + */ + private get semanticData(): FunctionDeclarationSemantics | undefined { + return this._declaration?.getSemanticData(); + } + + /** + * The type data of this declaration. + * @throws UndefinedSemanticsError If this is accessed, before type checking was performed. + * @private + */ + private get typeData(): FunctionDeclarationTypeSemantics | undefined { + return this._declaration?.getTypeSemanticData(); + } + + /** + * Returns the {@link FunctionDeclaration AST node} this scope function declaration bases on. + */ + public get node(): FunctionDeclaration | undefined { + return this._declaration; + } + + /** + * The identifier of this function. + */ + public get identifier(): string { + return this.semanticData?.identifier ?? this._builtInFunction!!.identifier; + } + + /** + * The type of this function. This is always "func". + * @since 0.10.0 + */ + public get type(): ProcessedType { + return BuiltInTypes.func; + } + + /** + * The return type of this function. This can be every {@link KipperType} except {@link KipperFuncType}. + */ + public get returnType(): ProcessedType { + return this.typeData?.returnType ?? this._builtInFunction?.returnType!!; + } + + /** + * Returns the scope associated with this {@link ScopeDeclaration}. + */ + public get scope() { + return this._declaration?.scope ?? this._universeScope!!; + } + + /** + * The parameters that are accepted inside this function. These are represented using the {@link ParameterDeclaration} + * class. + * + * The index in the array represents the position inside the function. Meaning the first item in the array maps to + * the first parameter inside the function. + */ + public get params(): Array | Array { + return this.semanticData?.params ?? this._builtInFunction?.params!!; + } + + /** + * Returns whether the function declaration is defined and has a function body set during declaration. + * @since 0.3.0 + */ + public get isDefined(): boolean { + return this.semanticData?.isDefined ?? true; + } + + /** + * Returns whether the function declaration has a value. + * @since 0.10.0 + */ + public get hasValue(): boolean { + return this.isDefined; + } + + /** + * Returns whether the declaration has a callable value (function). + * @since 0.10.0 + */ + public get isCallable(): boolean { + return true; + } +} diff --git a/kipper/core/src/compiler/analysis/symbol-table/entry/scope-parameter-declaration.ts b/kipper/core/src/compiler/semantics/symbol-table/entry/scope-parameter-declaration.ts similarity index 68% rename from kipper/core/src/compiler/analysis/symbol-table/entry/scope-parameter-declaration.ts rename to kipper/core/src/compiler/semantics/symbol-table/entry/scope-parameter-declaration.ts index 7dd4627e7..21b06566a 100644 --- a/kipper/core/src/compiler/analysis/symbol-table/entry/scope-parameter-declaration.ts +++ b/kipper/core/src/compiler/semantics/symbol-table/entry/scope-parameter-declaration.ts @@ -10,8 +10,10 @@ import type { ParameterDeclarationSemantics, ParameterDeclarationTypeSemantics, } from "../../../ast"; -import type { LocalScope } from "../index"; -import type { CheckedType } from "../../type"; +import type { FunctionScope } from "../index"; +import { LocalScope } from "../index"; +import { BuiltInTypes } from "../index"; +import type { ProcessedType } from "../../types"; /** * Represents the definition of a parameter inside a {@link FunctionDeclaration function}. @@ -20,11 +22,39 @@ import type { CheckedType } from "../../type"; export class ScopeParameterDeclaration extends ScopeDeclaration { private readonly _node: ParameterDeclaration; - public constructor(node: ParameterDeclaration) { + private constructor(node: ParameterDeclaration) { super(); this._node = node; } + /** + * Creates a new scope parameter declaration from a parameter declaration. + * @param node The parameter declaration node. + */ + public static fromParameterDeclaration(node: ParameterDeclaration): ScopeParameterDeclaration { + return new ScopeParameterDeclaration(node); + } + + /** + * Returns whether this parameter declaration is a built-in declaration. + * + * This will always be false, since a parameter declaration is never a built-in declaration. + * @since 0.11.0 + */ + public override get isBuiltIn(): false { + return false; + } + + /** + * Returns the built-in structure of this declaration, if this declaration is based on one. + * + * This will always be undefined, since a parameter declaration is never a built-in declaration. + * @since 0.11.0 + */ + public override get builtInStructure(): undefined { + return undefined; + } + /** * The semantic data of this declaration. * @throws UndefinedSemanticsError If this is accessed, before semantic analysis was performed. @@ -65,7 +95,7 @@ export class ScopeParameterDeclaration extends ScopeDeclaration { * The type of this parameter. * @since 0.10.0 */ - public get type(): CheckedType { + public get type(): ProcessedType { return this.typeData.valueType; } @@ -73,7 +103,7 @@ export class ScopeParameterDeclaration extends ScopeDeclaration { * Returns the scope associated with this {@link ScopeDeclaration}. * @since 0.10.0 */ - public get scope(): LocalScope { + public get scope(): FunctionScope { return this.func.innerScope; } @@ -112,6 +142,6 @@ export class ScopeParameterDeclaration extends ScopeDeclaration { * @since 0.10.0 */ public get isCallable(): boolean { - return this.type.kipperType === "func"; + return this.type === BuiltInTypes.func; } } diff --git a/kipper/core/src/compiler/semantics/symbol-table/entry/scope-type-declaration.ts b/kipper/core/src/compiler/semantics/symbol-table/entry/scope-type-declaration.ts new file mode 100644 index 000000000..80d4b6a46 --- /dev/null +++ b/kipper/core/src/compiler/semantics/symbol-table/entry/scope-type-declaration.ts @@ -0,0 +1,135 @@ +/** + * A symbol table entry for a type declaration such as a class or interface. + * @since 0.11.0 + */ +import { ScopeDeclaration } from "./scope-declaration"; +import type { TypeDeclaration, TypeDeclarationSemantics } from "../../../ast"; +import type { BuiltInType, CustomType, ProcessedType } from "../../types"; +import type { UniverseScope } from "../universum-scope"; +import { BuiltInTypes } from "../universum-scope"; + +/** + * Represents the definition of a type such as a class or interface in a scope. + * @since 0.11.0 + */ +export class ScopeTypeDeclaration extends ScopeDeclaration { + private constructor( + private readonly _declaration?: TypeDeclaration, + private readonly _builtInType?: BuiltInType, + private readonly _universeScope?: UniverseScope, + ) { + super(); + } + + /** + * Creates a new scope type declaration from a type declaration. + * @param node The type declaration node. + * @since 0.11.0 + */ + public static fromTypeDeclaration(node: TypeDeclaration): ScopeTypeDeclaration { + return new ScopeTypeDeclaration(node); + } + + /** + * Creates a new scope type declaration from a built-in type. + * @param identifier The identifier of the built-in type. + * @param universeScope The universe scope this type is associated with. + * @since 0.11.0 + */ + public static fromBuiltInType(type: BuiltInType, universeScope: UniverseScope): ScopeTypeDeclaration { + return new ScopeTypeDeclaration(undefined, type, universeScope); + } + + /** + * Returns whether this type declaration is a built-in type. + * @since 0.11.0 + */ + public override get isBuiltIn(): boolean { + return this._builtInType !== undefined; + } + + /** + * Returns the built-in structure of this declaration, if this declaration is based on one. + * @since 0.11.0 + */ + public override get builtInStructure(): BuiltInType | undefined { + return this._builtInType; + } + + /** + * The semantic data of this declaration. + * @throws UndefinedSemanticsError If this is accessed, before semantic analysis was performed. + * @private + */ + private get semanticData(): TypeDeclarationSemantics | undefined { + return this._declaration?.getSemanticData(); + } + + /** + * Returns the {@link InterfaceDeclaration} or {@link ClassDeclaration AST node} this scope type declaration bases on. + */ + public get node(): TypeDeclaration | undefined { + return this._declaration; + } + + /** + * The identifier of this type. + */ + public get identifier(): string { + return this.semanticData?.identifier || this._builtInType!!.identifier; + } + + /** + * The type of this type. This is always "type". + * @since 0.11.0 + */ + public get type(): ProcessedType { + return BuiltInTypes.type; + } + + /** + * The value of this type, which is the type itself i.e. what value does this type represent. + * @throws {UndefinedSemanticsError} If this is accessed, before the type for the declaration finished. + * @since 0.11.0 + */ + public get typeValue(): CustomType | ProcessedType { + return this.node?.getTypeSemanticData()?.type || this._builtInType!!; + } + + /** + * Returns whether the declaration has a value. + * + * As this is a type, it will always be false. + * @since 0.11.0 + */ + public get isDefined(): false { + return false; + } + + /** + * Returns the scope associated with this {@link ScopeDeclaration}. + */ + public get scope() { + return this._declaration?.scope ?? this._universeScope!!; + } + + /** + * Returns whether the declaration has a value. + * + * As this is a type, it will always be false. + * @since 0.11.0 + */ + public get hasValue(): false { + return false; + } + + /** + * Returns whether the declaration has a callable value (function). + * + * As this is a type, it will always be false. + * @since 0.11.0 + */ + public get isCallable(): false { + return false; + } +} diff --git a/kipper/core/src/compiler/semantics/symbol-table/entry/scope-variable-declaration.ts b/kipper/core/src/compiler/semantics/symbol-table/entry/scope-variable-declaration.ts new file mode 100644 index 000000000..ccffe7131 --- /dev/null +++ b/kipper/core/src/compiler/semantics/symbol-table/entry/scope-variable-declaration.ts @@ -0,0 +1,160 @@ +/** + * A symbol table entry for a variable declaration. + * @since 0.10.0 + */ +import type { VariableDeclaration, VariableDeclarationSemantics, VariableDeclarationTypeSemantics } from "../../../ast"; +import type { KipperStorageType } from "../../../const"; +import type { UniverseScope } from "../index"; +import { BuiltInTypes } from "../index"; +import type { ProcessedType } from "../../types"; +import { ScopeDeclaration } from "./scope-declaration"; +import type { BuiltInVariable } from "../../runtime-built-ins"; + +/** + * Represents a variable scope entry that may be a child of the global scope or local scope. + * @since 0.1.0 + */ +export class ScopeVariableDeclaration extends ScopeDeclaration { + private _valueWasUpdated: boolean = false; + + public constructor( + private readonly _declaration?: VariableDeclaration, + private readonly _builtInVariable?: BuiltInVariable, + private readonly _universeScope?: UniverseScope, + ) { + super(); + } + + /** + * Creates a new scope variable declaration from a variable declaration. + * @param declaration The variable declaration node. + */ + public static fromVariableDeclaration(declaration: VariableDeclaration): ScopeVariableDeclaration { + return new ScopeVariableDeclaration(declaration); + } + + /** + * Creates a new scope variable declaration from a built-in variable. + * @param builtInVariable The built-in variable. + * @param universeScope The universe scope this variable is associated with. + */ + public static fromBuiltInVariable( + builtInVariable: BuiltInVariable, + universeScope: UniverseScope, + ): ScopeVariableDeclaration { + return new ScopeVariableDeclaration(undefined, builtInVariable, universeScope); + } + + /** + * Returns whether this variable declaration is a built-in declaration. + * @since 0.11.0 + */ + public override get isBuiltIn(): boolean { + return this._builtInVariable !== undefined; + } + + /** + * Returns the built-in structure of this declaration, if this declaration is based on one. + * @since 0.11.0 + */ + public override get builtInStructure(): BuiltInVariable | undefined { + return this._builtInVariable; + } + + /** + * The semantic data of this declaration. + * @throws UndefinedSemanticsError If this is accessed, before semantic analysis was performed. + * @private + */ + private get semanticData(): VariableDeclarationSemantics | undefined { + return this._declaration?.getSemanticData(); + } + + /** + * The type data of this declaration. + * @throws UndefinedSemanticsError If this is accessed, before type checking was performed. + * @private + */ + private get typeData(): VariableDeclarationTypeSemantics | undefined { + return this._declaration?.getTypeSemanticData(); + } + + /** + * Returns the {@link VariableDeclaration AST node} this scope declaration bases on. + */ + public get node(): VariableDeclaration | undefined { + return this._declaration; + } + + /** + * The identifier of this variable. + */ + public get identifier(): string { + return this.semanticData?.identifier ?? this._builtInVariable!!.identifier; + } + + /** + * The value type of this variable. + */ + public get type(): ProcessedType { + return this.typeData?.valueType ?? this._builtInVariable!!.valueType; + } + + /** + * The storage type of this variable. + */ + public get storageType(): KipperStorageType { + return this.semanticData?.storageType ?? "built-in"; + } + + /** + * Returns the scope associated with this {@link ScopeDeclaration}. + */ + public get scope() { + return this._declaration?.scope ?? this._universeScope!!; + } + + /** + * Returns whether the variable declaration is defined and has a value set during declaration. + */ + public get isDefined(): boolean { + return this.semanticData?.isDefined ?? true; + } + + /** + * Returns whether the value of the variable was updated after the initial declaration. + * @since 0.10.0 + */ + public get valueWasUpdated(): boolean { + return this._valueWasUpdated; + } + + /** + * Notifies the declaration that the value was updated. + * + * Sets the {@link valueWasUpdated} property to true. + * @since 0.11.0 + */ + public notifyOfUpdate() { + this._valueWasUpdated = true; + } + + /** + * Returns whether the variable declaration has a value. + * + * This is different from {@link isDefined}, since this also considers variable assignments *after* the initial + * declaration. + * @since 0.10.0 + */ + public get hasValue(): boolean { + return this.isDefined || this.valueWasUpdated; + } + + /** + * Returns whether the declaration has a callable value (function). + * @since 0.10.0 + */ + public get isCallable(): boolean { + return this.type === BuiltInTypes.func; + } +} diff --git a/kipper/core/src/compiler/analysis/symbol-table/function-scope.ts b/kipper/core/src/compiler/semantics/symbol-table/function-scope.ts similarity index 79% rename from kipper/core/src/compiler/analysis/symbol-table/function-scope.ts rename to kipper/core/src/compiler/semantics/symbol-table/function-scope.ts index ee8d1dcfe..ef568efdf 100644 --- a/kipper/core/src/compiler/analysis/symbol-table/function-scope.ts +++ b/kipper/core/src/compiler/semantics/symbol-table/function-scope.ts @@ -42,7 +42,7 @@ export class FunctionScope extends LocalScope { // Ensuring that the declaration does not overwrite other declarations this.ctx.programCtx.semanticCheck(declaration).identifierNotUsed(identifier, this); - const scopeDeclaration = new ScopeParameterDeclaration(declaration); + const scopeDeclaration = ScopeParameterDeclaration.fromParameterDeclaration(declaration); this.arguments.set(scopeDeclaration.identifier, scopeDeclaration); return scopeDeclaration; } @@ -59,18 +59,4 @@ export class FunctionScope extends LocalScope { public override getEntry(identifier: string): ScopeDeclaration | undefined { return this.getArgument(identifier) ?? this.entries.get(identifier); } - - public override getEntryRecursively(identifier: string): ScopeDeclaration | undefined { - const localRef = this.getEntry(identifier); - if (!localRef) { - // If the scope of the ctx (Compound statement) is another local scope, then go upwards recursively again. - if (this.ctx.scope instanceof LocalScope) { - return this.ctx.scope.getEntryRecursively(identifier); - } else { - // Fetching from the global scope - return this.ctx.scope.getEntry(identifier); - } - } - return localRef; - } } diff --git a/kipper/core/src/compiler/analysis/symbol-table/global-scope.ts b/kipper/core/src/compiler/semantics/symbol-table/global-scope.ts similarity index 53% rename from kipper/core/src/compiler/analysis/symbol-table/global-scope.ts rename to kipper/core/src/compiler/semantics/symbol-table/global-scope.ts index 38f36fb3e..913df1ca1 100644 --- a/kipper/core/src/compiler/analysis/symbol-table/global-scope.ts +++ b/kipper/core/src/compiler/semantics/symbol-table/global-scope.ts @@ -4,18 +4,19 @@ * @since 0.8.0 */ import type { KipperProgramContext } from "../../program-ctx"; -import type { FunctionDeclaration, VariableDeclaration } from "../../ast"; import type { ScopeDeclaration } from "./entry"; -import { ScopeFunctionDeclaration, ScopeVariableDeclaration } from "./entry"; -import { Scope } from "./scope"; +import type { FunctionDeclaration, RootASTNode, TypeDeclaration, VariableDeclaration } from "../../ast"; +import { ScopeFunctionDeclaration, ScopeTypeDeclaration, ScopeVariableDeclaration } from "./entry"; +import { Scope } from "./base/scope"; +import type { UniverseScope } from "./universum-scope"; /** * The global scope of a {@link KipperProgramContext}, which contains the global variables and functions of a * Kipper program. * @since 0.8.0 */ -export class GlobalScope extends Scope { - constructor(public programCtx: KipperProgramContext) { +export class GlobalScope extends Scope { + constructor(public readonly ctx: RootASTNode, public readonly universe: UniverseScope) { super(); } @@ -23,15 +24,15 @@ export class GlobalScope extends Scope { * The parent scope of this global scope. This is always `undefined`. * @since 0.10.0 */ - public parent = undefined; + public parent = this.universe; public addFunction(declaration: FunctionDeclaration): ScopeFunctionDeclaration { const identifier = declaration.getSemanticData().identifier; // Ensuring that the declaration does not overwrite other declarations - this.programCtx.semanticCheck(declaration).identifierNotUsed(identifier, this.programCtx.globalScope); + this.ctx.programCtx.semanticCheck(declaration).identifierNotUsed(identifier, this); - const scopeDeclaration = new ScopeFunctionDeclaration(declaration); + const scopeDeclaration = ScopeFunctionDeclaration.fromFunctionDeclaration(declaration); this.entries.set(identifier, scopeDeclaration); return scopeDeclaration; } @@ -40,19 +41,26 @@ export class GlobalScope extends Scope { const identifier = declaration.getSemanticData().identifier; // Ensuring that the declaration does not overwrite other declarations - this.programCtx.semanticCheck(declaration).identifierNotUsed(identifier, this.programCtx.globalScope); + this.ctx.programCtx.semanticCheck(declaration).identifierNotUsed(identifier, this); const scopeDeclaration = new ScopeVariableDeclaration(declaration); this.entries.set(identifier, scopeDeclaration); return scopeDeclaration; } + public addType(declarationOrIdentifier: TypeDeclaration): ScopeTypeDeclaration { + // Depending on the type of the argument, create either a built-in type or a custom type + const scopeDeclaration = ScopeTypeDeclaration.fromTypeDeclaration(declarationOrIdentifier); + + this.entries.set(scopeDeclaration.identifier, scopeDeclaration); + return scopeDeclaration; + } + public getEntry(identifier: string): ScopeDeclaration | undefined { return this.entries.get(identifier); } public getEntryRecursively(identifier: string): ScopeDeclaration | undefined { - // No recursion, since the global scope is the top-most scope - return this.getEntry(identifier); + return this.getEntry(identifier) ?? this.parent.getEntryRecursively(identifier); } } diff --git a/kipper/core/src/compiler/analysis/symbol-table/index.ts b/kipper/core/src/compiler/semantics/symbol-table/index.ts similarity index 72% rename from kipper/core/src/compiler/analysis/symbol-table/index.ts rename to kipper/core/src/compiler/semantics/symbol-table/index.ts index 33d24b650..31af94b38 100644 --- a/kipper/core/src/compiler/analysis/symbol-table/index.ts +++ b/kipper/core/src/compiler/semantics/symbol-table/index.ts @@ -2,9 +2,10 @@ * Symbol table, which store the information about variables, functions and other declarations. * @since 0.10.0 */ +export * from "./base/"; export * from "./entry/"; -export * from "./scope"; export * from "./global-scope"; export * from "./local-scope"; export * from "./function-scope"; -export * from "./symbol-table"; +export * from "./universum-scope"; +export * from "./lambda-scope"; diff --git a/kipper/core/src/compiler/analysis/symbol-table/lambda-scope.ts b/kipper/core/src/compiler/semantics/symbol-table/lambda-scope.ts similarity index 100% rename from kipper/core/src/compiler/analysis/symbol-table/lambda-scope.ts rename to kipper/core/src/compiler/semantics/symbol-table/lambda-scope.ts index 80ba580a0..18c9126df 100644 --- a/kipper/core/src/compiler/analysis/symbol-table/lambda-scope.ts +++ b/kipper/core/src/compiler/semantics/symbol-table/lambda-scope.ts @@ -1,8 +1,8 @@ +import { FunctionScope } from "./function-scope"; + /** * File containing the definition for a lambda-specific scope that is bound to a {@link LambdaExpression} and not * the global namespace. * @since 0.11.0 */ -import { FunctionScope } from "./function-scope"; - export class LambdaScope extends FunctionScope {} diff --git a/kipper/core/src/compiler/analysis/symbol-table/local-scope.ts b/kipper/core/src/compiler/semantics/symbol-table/local-scope.ts similarity index 70% rename from kipper/core/src/compiler/analysis/symbol-table/local-scope.ts rename to kipper/core/src/compiler/semantics/symbol-table/local-scope.ts index 8aedaa557..9bc419301 100644 --- a/kipper/core/src/compiler/analysis/symbol-table/local-scope.ts +++ b/kipper/core/src/compiler/semantics/symbol-table/local-scope.ts @@ -3,19 +3,25 @@ * namespace. * @since 0.8.0 */ -import type { FunctionDeclaration, ScopeNode, VariableDeclaration } from "../../ast/"; +import type { + CompilableASTNode, + FunctionDeclaration, + ScopeNode, + TypeDeclaration, + VariableDeclaration, +} from "../../ast/"; import type { GlobalScope } from "./global-scope"; import { KipperNotImplementedError } from "../../../errors"; -import type { ScopeDeclaration, ScopeFunctionDeclaration } from "./entry"; +import type { ScopeDeclaration, ScopeFunctionDeclaration, ScopeTypeDeclaration } from "./entry"; import { ScopeVariableDeclaration } from "./entry"; -import { Scope } from "./scope"; +import { Scope } from "./base/scope"; /** * A scope that is bound to a {@link CompoundStatement} and not the global namespace. * @since 0.8.0 */ -export class LocalScope extends Scope { - constructor(public ctx: ScopeNode) { +export class LocalScope extends Scope { + constructor(public ctx: ScopeNode & CompilableASTNode) { super(); } @@ -45,6 +51,12 @@ export class LocalScope extends Scope { return scopeDeclaration; } + public addType(declaration: TypeDeclaration): ScopeTypeDeclaration { + throw this.ctx.programCtx + .semanticCheck(declaration) + .notImplementedError(new KipperNotImplementedError("Local types have not been implemented yet.")); + } + public getEntry(identifier: string): ScopeDeclaration | undefined { return this.entries.get(identifier); } @@ -52,13 +64,7 @@ export class LocalScope extends Scope { public getEntryRecursively(identifier: string): ScopeDeclaration | undefined { const localRef = this.getEntry(identifier); if (!localRef) { - // If the scope of the ctx (Compound statement) is another local scope, then go upwards recursively again. - if (this.ctx.scope instanceof LocalScope) { - return this.parent.getEntryRecursively(identifier); - } else { - // Fetching from the global scope - return this.parent.getEntry(identifier); - } + return this.parent.getEntryRecursively(identifier); } return localRef; } diff --git a/kipper/core/src/compiler/semantics/symbol-table/universum-scope.ts b/kipper/core/src/compiler/semantics/symbol-table/universum-scope.ts new file mode 100644 index 000000000..f9fefe5f1 --- /dev/null +++ b/kipper/core/src/compiler/semantics/symbol-table/universum-scope.ts @@ -0,0 +1,158 @@ +import { Scope } from "./base"; +import type { ScopeDeclaration } from "./entry"; +import { ScopeFunctionDeclaration, ScopeTypeDeclaration, ScopeVariableDeclaration } from "./entry"; +import { BuiltInType } from "../types"; +import type { KipperProgramContext } from "../../program-ctx"; +import { BuiltInFunction, BuiltInVariable } from "../runtime-built-ins"; +import type { KipperBuiltInTypeLiteral } from "../../const"; + +/** + * Contains all the built-in types that are used in the type analysis phase. + * @since 0.11.0 + */ +export const BuiltInTypes = { + type: new BuiltInType("type"), + undefined: new BuiltInType("undefined"), + void: new BuiltInType("void"), + null: new BuiltInType("null"), + bool: new BuiltInType("bool"), + num: new BuiltInType("num"), + str: new BuiltInType("str"), + func: new BuiltInType("func"), + list: new BuiltInType("list"), +} satisfies Record; + +/** + * Contains all the built-in functions in Kipper that are available per default in every program. + */ +export const BuiltInFunctions = { + print: new BuiltInFunction( + "print", + [ + { + identifier: "msg", + valueType: BuiltInTypes.str, + }, + ], + BuiltInTypes.void, + ), + len: new BuiltInFunction( + "len", + [ + { + identifier: "arrayLike", + // TODO: Implement this for all arrayLike types (At the moment only strings are supported) + valueType: BuiltInTypes.str, + }, + ], + BuiltInTypes.num, + ), +} satisfies Record; + +/** + * Contains all the built-in variables in Kipper that are available per default in every program. + * @since 0.10.0 + */ +export const BuiltInVariables = { + __name__: new BuiltInVariable("__name__", BuiltInTypes.str, true), +} satisfies Record; + +/** + * The universal scope which only defines built-ins and is not bound to any specific context. + * @since 0.11.0 + */ +export class UniverseScope extends Scope { + public readonly parent: undefined; + + public constructor(public ctx: KipperProgramContext) { + super(); + } + + /** + * Initializes the universal scope by adding all built-in types, functions and variables. + * @since 0.11.0 + */ + public init(): void { + for (const type of Object.values(BuiltInTypes)) { + this.addType(type); + } + for (const variable of Object.values(BuiltInVariables)) { + this.addVariable(variable); + } + for (const func of Object.values(BuiltInFunctions)) { + this.addFunction(func); + } + } + + /** + * Adds a built-in variable to the universal scope. + * @param declaration The built-in variable to add. + * @returns The scope declaration of the added variable. + * @since 0.11.0 + */ + public addVariable(declaration: BuiltInVariable): ScopeVariableDeclaration { + const scopeDeclaration = ScopeVariableDeclaration.fromBuiltInVariable(declaration, this); + this.entries.set(scopeDeclaration.identifier, scopeDeclaration); + return scopeDeclaration; + } + + /** + * Adds a built-in function to the universal scope. + * @param declaration The built-in function to add. + * @returns The scope declaration of the added function. + * @since 0.11.0 + */ + public addFunction(declaration: BuiltInFunction): ScopeFunctionDeclaration { + const scopeDeclaration = ScopeFunctionDeclaration.fromBuiltInFunction(declaration, this); + this.entries.set(scopeDeclaration.identifier, scopeDeclaration); + return scopeDeclaration; + } + + /** + * Adds a built-in type to the universal scope. + * @param declarationOrIdentifier The built-in type to add. + * @returns The scope declaration of the added type. + * @since 0.11.0 + */ + public addType(declarationOrIdentifier: BuiltInType): ScopeTypeDeclaration { + const scopeDeclaration = ScopeTypeDeclaration.fromBuiltInType(declarationOrIdentifier, this); + this.entries.set(scopeDeclaration.identifier, scopeDeclaration); + return scopeDeclaration; + } + + /** + * Retrieves a scope declaration from the universal scope. + * @param identifier The identifier of the declaration to retrieve. + * @returns The scope declaration if it exists, otherwise `undefined`. + * @since 0.11.0 + */ + public getEntry(identifier: string): ScopeDeclaration | undefined { + return this.entries.get(identifier); + } + + /** + * Retrieves a scope declaration from the universal scope recursively. + * @param identifier The identifier of the declaration to retrieve. + * @returns The scope declaration if it exists, otherwise `undefined`. + * @since 0.11.0 + */ + public getEntryRecursively(identifier: string): ScopeDeclaration | undefined { + return this.getEntry(identifier); + } + + /** + * DANGEROUS METHOD! Clears all the universal functions and create dangling references. + * @since 0.11.0 + */ + public clearUniversalFunctions(): void { + this.entries.clear(); + } + + /** + * DANGEROUS METHOD! Clears all the universal variables and create dangling references. + * @since 0.11.0 + */ + public clearUniversalVariables(): void { + this.entries.clear(); + } +} diff --git a/kipper/core/src/compiler/semantics/types/base/compilable-type.ts b/kipper/core/src/compiler/semantics/types/base/compilable-type.ts new file mode 100644 index 000000000..29fcdf037 --- /dev/null +++ b/kipper/core/src/compiler/semantics/types/base/compilable-type.ts @@ -0,0 +1,18 @@ +/** + * Represents a type that can be compiled i.e. a type that exists and type checks can be done on it. + * @since 0.11.0 + */ +export interface CompilableType { + /** + * The identifier of this type. + * @since 0.11.0 + */ + readonly identifier: string; + /** + * Returns whether the type is compilable. Is always true for this type. + * + * This only exists to differentiate this type from the base {@link ProcessedType}. + * @since 0.11.0 + */ + readonly isCompilable: true; +} diff --git a/kipper/core/src/compiler/semantics/types/base/index.ts b/kipper/core/src/compiler/semantics/types/base/index.ts new file mode 100644 index 000000000..6b44e81e4 --- /dev/null +++ b/kipper/core/src/compiler/semantics/types/base/index.ts @@ -0,0 +1,7 @@ +/** + * Abstract classes and interfaces, which are used to represent types in the type analysis phase. + * @since 0.11.0 + */ +export * from "./type"; +export * from "./processed-type"; +export * from "./compilable-type"; diff --git a/kipper/core/src/compiler/semantics/types/base/processed-type.ts b/kipper/core/src/compiler/semantics/types/base/processed-type.ts new file mode 100644 index 000000000..0b8ea29b3 --- /dev/null +++ b/kipper/core/src/compiler/semantics/types/base/processed-type.ts @@ -0,0 +1,57 @@ +import type { CompilableType } from "./compilable-type"; +import { TypeNotCompilableError, type TypeError } from "../../../../errors"; +import { Type } from "./type"; + +/** + * A processed type that may be used for type checking and compilation. This type is the general type that will be used + * throughout type checking, as there can be references to invalid + * @since 0.10.0 + */ +export abstract class ProcessedType extends Type { + protected constructor(identifier: string) { + super(identifier); + } + + /** + * The identifier of this type. + */ + public get identifier(): string { + return this._identifier; + } + + /** + * Returns whether the type is compilable. + * + * This function exists, since during type checking an undefined/invalid type may be encountered that should still + * be stored using this class though (but NOT compiled!). + * @since 0.10.0 + */ + public abstract get isCompilable(): boolean; + + /** + * Gets the compilable type for this type. + * + * This function throws an error instead of returning undefined, since it's intended to be used in circumstances, + * where only due to a bug the type is not compilable. As such, it makes sense to strictly assert it will be + * compilable, unless an error occurs. + * @throws UndefinedType If the {@link isCompilable} is false, which should only occur if the identifier is of + * type {@link UndefinedType}. + * @since 0.10.0 + */ + public getCompilableType(): CompilableType { + if (!this.isCompilable) { + throw new TypeNotCompilableError(); + } + return this; + } + + /** + * Returns whether this type is assignable to the given {@link type}. + * @param type The type to check against. + * @param propertyName The name of the property that is being assigned. This is used for error messages. + * @param argumentName The name of the argument that is being assigned to. This is used for error messages. + * @throws TypeError If the types are not assignable. + * @since 0.12.0 + */ + public abstract assertAssignableTo(type: ProcessedType, propertyName?: string, argumentName?: string): void; +} diff --git a/kipper/core/src/compiler/semantics/types/base/type.ts b/kipper/core/src/compiler/semantics/types/base/type.ts new file mode 100644 index 000000000..d2e44183f --- /dev/null +++ b/kipper/core/src/compiler/semantics/types/base/type.ts @@ -0,0 +1,22 @@ +/** + * The abstract base type of a general type that may exist/be valid, but also + * may not. This is a general representation to store a type's information + * in the {@link CompilableASTNode.semanticData semantic data} and + * {@link CompilableASTNode.typeData type data} of an {@link CompilableASTNode}. + * @since 0.10.0 + */ +export abstract class Type { + protected readonly _identifier: string; + + protected constructor(identifier: string) { + this._identifier = identifier; + } + + /** + * The identifier of this type. + * @since 0.10.0 + */ + public get identifier(): string { + return this._identifier; + } +} diff --git a/kipper/core/src/compiler/semantics/types/built-in-type.ts b/kipper/core/src/compiler/semantics/types/built-in-type.ts new file mode 100644 index 000000000..1a4a2b0e1 --- /dev/null +++ b/kipper/core/src/compiler/semantics/types/built-in-type.ts @@ -0,0 +1,53 @@ +import { ProcessedType } from "./base/processed-type"; +import type { KipperBuiltInTypeLiteral } from "../../const"; +import type { CompilableType } from "./base/compilable-type"; +import { ArgumentAssignmentTypeError, AssignmentTypeError, PropertyAssignmentTypeError } from "../../../errors"; + +/** + * Represents a built-in type that is used in the type analysis phase. + * @since 0.11.0 + */ +export class BuiltInType extends ProcessedType implements CompilableType { + public static readonly interchangeableTypes = ["void", "undefined"]; + + public constructor(identifier: KipperBuiltInTypeLiteral) { + super(identifier); + } + + /** + * Returns whether the type is compilable. + * + * This is ALWAYS true, since built-in types are always compilable. + * @since 0.11.0 + */ + public get isCompilable(): true { + return true; + } + + /** + * Returns whether this type is assignable to another type. + * @param type The type to check against. + * @param propertyName The name of the property that is being assigned. This is used for error messages. + * @param argumentName The name of the argument that is being assigned to. This is used for error messages. + * @throws AssignmentTypeError If the types are not assignable. + * @throws PropertyAssignmentTypeError If a property is not assignable. + * @throws ArgumentAssignmentTypeError If an argument is not assignable. + * @since 0.11.0 + */ + public assertAssignableTo(type: ProcessedType, propertyName?: string, argumentName?: string): void { + if (this === type) { + return; + } else if ( + BuiltInType.interchangeableTypes.includes(this.identifier) && + BuiltInType.interchangeableTypes.includes(type.identifier) + ) { + return; + } else if (propertyName) { + throw new PropertyAssignmentTypeError(propertyName, type.identifier, this.identifier); + } else if (argumentName) { + throw new ArgumentAssignmentTypeError(argumentName, type.identifier, this.identifier); + } else { + throw new AssignmentTypeError(type.identifier, this.identifier); + } + } +} diff --git a/kipper/core/src/compiler/semantics/types/custom-type.ts b/kipper/core/src/compiler/semantics/types/custom-type.ts new file mode 100644 index 000000000..a843f899a --- /dev/null +++ b/kipper/core/src/compiler/semantics/types/custom-type.ts @@ -0,0 +1,170 @@ +import { ProcessedType } from "./base"; +import type { TypeError } from "../../../errors"; +import { KipperInternalError } from "../../../errors"; +import { + ArgumentAssignmentTypeError, + AssignmentTypeError, + PropertyAssignmentTypeError, + PropertyNotFoundError, +} from "../../../errors"; +import type { ClassDeclaration, InterfaceDeclaration, ObjectPrimaryExpression } from "../../ast"; + +/** + * Represents the kind of a custom type. + * @since 0.12.0 + */ +export type CustomTypeKind = "interface" | "class"; + +/** + * Represents a field of a custom type. This is simply another type. + * @since 0.12.0 + */ +export type CustomTypeField = ProcessedType; + +/** + * Represents a map of field names to their types. + * @since 0.12.0 + */ +export type CustomTypeFields = Map; + +/** + * Represents a custom type which is not a built-in type. + * + * This type implements its own type constraints and can be used to represent complex type structures. + * @since 0.12.0 + */ +export class CustomType extends ProcessedType { + /** + * The kind of this type. This is simply used to differentiate between classes and interfaces. + * @since 0.12.0 + */ + public readonly kind: CustomTypeKind; + private readonly _fields: CustomTypeFields; + + protected constructor(identifier: string, kind: CustomTypeKind, fields: CustomTypeFields) { + super(identifier); + this._fields = fields; + this.kind = kind; + } + + /** + * Returns whether the type is compilable. + * + * This runs through all fields and checks if they are compilable. As such this is an expensive operation and should + * only be used once during type checking. + * @since 0.12.0 + */ + public override get isCompilable(): boolean { + return Object.values(this._fields).every((field) => field.isCompilable); + } + + /** + * The fields of this type. + * @since 0.12.0 + */ + public get fields(): CustomTypeFields { + return this._fields; + } + + /** + * Creates a custom type from a class declaration. + * + * This can only be run AFTER the class declaration has passed semantic validation. + * @param classDeclaration The class declaration to create the custom type from. + * @since 0.12.0 + */ + public static fromClassDeclaration(classDeclaration: ClassDeclaration): CustomType { + classDeclaration.ensureSemanticallyValid(); + throw new KipperInternalError("Internal class representations are not implemented."); + + // TODO! Implement custom type generation from class declaration + // const fields: CustomTypeFields = new Map(); + // for (const field of objectSemantics.fields) { + // fields.set(field.identifier, field.type); + // } + // return new CustomType(objectSemantics.identifier, "class", fields); + } + + /** + * Creates a custom type from an interface declaration. + * + * This can only be run AFTER the interface declaration has passed semantic validation. + * @param interfaceDeclaration The interface declaration to create the custom type from. + * @since 0.12.0 + */ + public static fromInterfaceDeclaration(interfaceDeclaration: InterfaceDeclaration): CustomType { + interfaceDeclaration.ensureSemanticallyValid(); + throw new KipperInternalError("Internal interface representations are not implemented."); + + // TODO! Implement custom type generation from interface declaration + // const fields: CustomTypeFields = new Map(); + // for (const field of interfaceSemantics.fields) { + // fields.set(field.identifier, field.type); + // } + // return new CustomType(interfaceSemantics.identifier, "interface", fields); + } + + /** + * Creates a custom type from an object literal. + * + * This can only be run AFTER the object primary expression has passed semantic validation. + * @param objectPrimaryExpression The object primary expression to create the custom type from. + * @since 0.12.0 + */ + public static fromObjectLiteral(objectPrimaryExpression: ObjectPrimaryExpression): CustomType { + objectPrimaryExpression.ensureSemanticallyValid(); + throw new KipperInternalError("Object literal custom types are not implemented."); + + // TODO! Implement custom type generation from object literal + // const fields: CustomTypeFields = new Map(); + // for (const field of objectLiteral.fields) { + // fields.set(field.identifier, field.type); + // } + // return new CustomType("object", "interface", fields); + } + + /** + * Checks whether this type is assignable to another type. + * + * This assumes that {@link this} is being assigned to {@link type}. + * @param type The type to check against. + * @param propertyName The name of the property that is being assigned to. This is used for error messages. + * @param argumentName The name of the argument that is being assigned to. This is used for error messages. + * @throws AssignmentTypeError If the types are not assignable. + * @throws PropertyAssignmentTypeError If a property is not assignable. + * @throws ArgumentAssignmentTypeError If an argument is not assignable. + * @throws PropertyNotFoundError If a property is not found. + * @since 0.12.0 + */ + assertAssignableTo(type: ProcessedType, propertyName?: string, argumentName?: string): void { + if (type === this) { + return; + } else if (type instanceof CustomType && type.kind === "interface") { + for (const [fieldName, fieldType] of this.fields) { + const targetTypeField = type.fields.get(fieldName); + if (!targetTypeField) { + throw new PropertyNotFoundError(type.identifier, fieldName); + } + + try { + fieldType.assertAssignableTo(targetTypeField, fieldName); + } catch (error) { + if (propertyName) { + throw new PropertyAssignmentTypeError(propertyName, type.identifier, this.identifier, error); + } else if (argumentName) { + throw new ArgumentAssignmentTypeError(argumentName, type.identifier, this.identifier, error); + } else { + throw new AssignmentTypeError(type.identifier, this.identifier, error); + } + } + } + return; + } else if (propertyName) { + throw new PropertyAssignmentTypeError(propertyName, type.identifier, this.identifier); + } else if (argumentName) { + throw new ArgumentAssignmentTypeError(argumentName, type.identifier, this.identifier); + } else { + throw new AssignmentTypeError(type.identifier, this.identifier); + } + } +} diff --git a/kipper/core/src/compiler/semantics/types/index.ts b/kipper/core/src/compiler/semantics/types/index.ts new file mode 100644 index 000000000..e46f92fb9 --- /dev/null +++ b/kipper/core/src/compiler/semantics/types/index.ts @@ -0,0 +1,9 @@ +/** + * Types which are used in the type analysis phase. + * @since 0.11.0 + */ +export * from "./base/"; +export * from "./raw-type"; +export * from "./undefined-type"; +export * from "./custom-type"; +export * from "./built-in-type"; diff --git a/kipper/core/src/compiler/semantics/types/raw-type.ts b/kipper/core/src/compiler/semantics/types/raw-type.ts new file mode 100644 index 000000000..6f46ac43e --- /dev/null +++ b/kipper/core/src/compiler/semantics/types/raw-type.ts @@ -0,0 +1,21 @@ +import { Type } from "./base"; + +/** + * An unchecked type wrapper that may contain any type, even if it does not exist or is invalid. + * @since 0.10.0 + */ +export class RawType extends Type { + constructor(identifier: string) { + super(identifier); + } + + /** + * The identifier of this type. + * + * This identifier has not been type-checked yet, and may not exist/be valid. + * @since 0.10.0 + */ + public get identifier(): string { + return super.identifier; + } +} diff --git a/kipper/core/src/compiler/semantics/types/undefined-type.ts b/kipper/core/src/compiler/semantics/types/undefined-type.ts new file mode 100644 index 000000000..73f724471 --- /dev/null +++ b/kipper/core/src/compiler/semantics/types/undefined-type.ts @@ -0,0 +1,34 @@ +import { ProcessedType } from "./base"; +import { TypeCanNotBeUsedForTypeCheckingError } from "../../../errors"; + +/** + * Represents an undefined custom type that was specified by the user, but can not be evaluated. + * + * This is used to represent an invalid type that can not be used for type checking. If a type like this is encountered, + * then the type checking will silently fail, as this type should have already thrown an error. + * @since 0.10.0 + */ +export class UndefinedType extends ProcessedType { + constructor(identifier: string) { + super(identifier); + } + + /** + * Returns whether the type is compilable. + * + * This is ALWAYS false, since this type can not be used for type checking. + * @since 0.10.0 + */ + public get isCompilable(): false { + return false; + } + + /** + * Checks whether this type is assignable to another type. + * @param type The type to check against. + * @since 0.10.0 + */ + assertAssignableTo(type: ProcessedType): boolean { + throw new TypeCanNotBeUsedForTypeCheckingError(); + } +} diff --git a/kipper/core/src/compiler/target-presets/semantic-analyser.ts b/kipper/core/src/compiler/target-presets/semantic-analyser.ts index e9e4fabd6..58aefd256 100644 --- a/kipper/core/src/compiler/target-presets/semantic-analyser.ts +++ b/kipper/core/src/compiler/target-presets/semantic-analyser.ts @@ -7,8 +7,13 @@ import type { AnalysableASTNode, ArrayPrimaryExpression, AssignmentExpression, + BitwiseAndExpression, + BitwiseOrExpression, + BitwiseShiftExpression, + BitwiseXorExpression, BoolPrimaryExpression, CastOrConvertExpression, + ClassDeclaration, CompoundStatement, ConditionalExpression, DoWhileLoopIterationStatement, @@ -24,6 +29,7 @@ import type { IfStatement, IncrementOrDecrementPostfixExpression, IncrementOrDecrementUnaryExpression, + InterfaceDeclaration, JumpStatement, LambdaExpression, LogicalAndExpression, @@ -46,9 +52,8 @@ import type { VoidOrNullOrUndefinedPrimaryExpression, WhileLoopIterationStatement, } from "../ast"; -import type { BitwiseAndExpression, BitwiseOrExpression, BitwiseShiftExpression, BitwiseXorExpression } from "../ast"; -import { KipperSemanticErrorHandler } from "../analysis"; -import type { ObjectProperty } from "../ast"; +import { KipperSemanticErrorHandler } from "../semantics"; +import type { ObjectProperty } from "../ast/nodes/expressions/primary-expression/object-primary-expression/object-property/object-property"; /** * Represents a function that checks the semantics for a {@link AnalysableASTNode}. @@ -131,6 +136,16 @@ export abstract class KipperTargetSemanticAnalyser extends KipperSemanticErrorHa */ public abstract variableDeclaration?: TargetASTNodeSemanticAnalyser; + /** + * Performs translation-specific semantic analysis for {@link ClassDeclaration} instances. + */ + public abstract classDeclaration?: TargetASTNodeSemanticAnalyser; + + /** + * Performs translation-specific semantic analysis for {@link InterfaceDeclaration} instances. + */ + public abstract interfaceDeclaration?: TargetASTNodeSemanticAnalyser; + /** * Performs translation-specific semantic analysis for {@link NumberPrimaryExpression} instances. */ diff --git a/kipper/core/src/compiler/target-presets/translation/built-ins-generator.ts b/kipper/core/src/compiler/target-presets/translation/built-ins-generator.ts index 8e158034a..da9b95b59 100644 --- a/kipper/core/src/compiler/target-presets/translation/built-ins-generator.ts +++ b/kipper/core/src/compiler/target-presets/translation/built-ins-generator.ts @@ -3,9 +3,9 @@ * @since 0.10.0 */ import type { TranslatedCodeLine } from "../../const"; -import type { BuiltInFunction, BuiltInVariable } from "../../runtime-built-ins"; -import type { InternalFunction } from "../../runtime-built-ins"; +import type { BuiltInFunction, BuiltInVariable } from "../../semantics"; import type { KipperProgramContext } from "../../program-ctx"; +import type { InternalFunction } from "../../semantics"; /** * Generator for the Kipper built-ins that are specific for a target. diff --git a/kipper/core/src/compiler/target-presets/translation/code-generator.ts b/kipper/core/src/compiler/target-presets/translation/code-generator.ts index 22dfa0cae..69dd397cf 100644 --- a/kipper/core/src/compiler/target-presets/translation/code-generator.ts +++ b/kipper/core/src/compiler/target-presets/translation/code-generator.ts @@ -12,6 +12,7 @@ import type { BitwiseXorExpression, BoolPrimaryExpression, CastOrConvertExpression, + ClassDeclaration, CompilableASTNode, CompoundStatement, ConditionalExpression, @@ -28,6 +29,7 @@ import type { IfStatement, IncrementOrDecrementPostfixExpression, IncrementOrDecrementUnaryExpression, + InterfaceDeclaration, JumpStatement, LambdaExpression, LogicalAndExpression, @@ -181,6 +183,16 @@ export abstract class KipperTargetCodeGenerator { */ public abstract variableDeclaration: TargetASTNodeCodeGenerator>; + /** + * Translates a {@link VariableDeclaration} into a specific language. + */ + public abstract classDeclaration: TargetASTNodeCodeGenerator>; + + /** + * Translates a {@link VariableDeclaration} into a specific language. + */ + public abstract interfaceDeclaration: TargetASTNodeCodeGenerator>; + /** * Translates a {@link NumberPrimaryExpression} into a specific language. */ diff --git a/kipper/core/src/errors.ts b/kipper/core/src/errors.ts index 9ddad64d8..832edc3a5 100644 --- a/kipper/core/src/errors.ts +++ b/kipper/core/src/errors.ts @@ -7,9 +7,8 @@ import type { InputMismatchException, LexerNoViableAltException, NoViableAltExce import type { FailedPredicateException } from "antlr4ts/FailedPredicateException"; import type { RecognitionException } from "antlr4ts/RecognitionException"; import type { Recognizer } from "antlr4ts/Recognizer"; -import type { KipperFileStream } from "./compiler"; -import type { CompilableASTNode, KipperProgramContext } from "./compiler"; -import { getParseRuleSource } from "./tools"; +import type { CompilableASTNode, KipperFileStream, KipperProgramContext } from "./compiler"; +import { addLeftIndent, getParseRuleSource } from "./tools"; /** * The interface representing the traceback data for a {@link KipperError}. @@ -274,7 +273,7 @@ export class UnableToGetInnerScopeError extends KipperInternalError { /** * Error that is thrown whenever {@link CheckedType.getCompilableType} is called, despite the type not being compilable. * - * This is thrown to avoid the compiler from using {@link UndefinedCustomType} for a compilation, as that would cause + * This is thrown to avoid the compiler from using {@link UndefinedType} for a compilation, as that would cause * undefined behavior. * @since 0.10.0 */ @@ -287,6 +286,16 @@ export class TypeNotCompilableError extends KipperInternalError { } } +/** + * Error that is thrown whenever a type is used for type checking that can not be used for type checking. + * @since 0.11.0 + */ +export class TypeCanNotBeUsedForTypeCheckingError extends KipperInternalError { + constructor() { + super("This Type can not be used for type checking. This is a bug in the compiler."); + } +} + /** * Error that is thrown whenever a parent node attempts to access the {@link CompilableASTNode.semanticData} of a child, * but the child had an error during semantic analysis. This is to prevent the parent from using the child's data @@ -550,8 +559,8 @@ export class ReservedIdentifierOverwriteError extends IdentifierError { * @since 0.7.0 */ export class TypeError extends KipperError { - constructor(msg: string) { - super(msg); + constructor(msg: string, cause?: TypeError) { + super(msg + (cause?.message ? `\n${addLeftIndent(cause.message)}` : "")); this.name = "TypeError"; } } @@ -578,22 +587,20 @@ export class ArithmeticOperationTypeError extends TypeError { * @since 0.6.0 */ export class BitwiseOperationTypeError extends TypeError { - constructor(firstType?: string, secondType?: string) { - if (firstType && secondType) { - // If the types caused the error, specify them in the error message - super(`Invalid bitwise operation between operands of type '${firstType}' and '${secondType}'.`); - } else { - super(`Invalid bitwise operation.`); - } + constructor(firstType: string, secondType: string) { + super(`Bitwise expressions are only allowed for type 'num'. Received '${firstType}' and '${secondType}'.`); } } /** * Error that is thrown whenever an argument is not assignable to the parameter's type. */ -export class ArgumentTypeError extends TypeError { - constructor(paramIdentifier: string, expectedType: string, receivedType: string) { - super(`Type '${receivedType}' is not assignable to parameter '${paramIdentifier}' of type '${expectedType}'.`); +export class ArgumentAssignmentTypeError extends TypeError { + constructor(paramIdentifier: string, expectedType: string, receivedType: string, cause?: TypeError) { + super( + `Type '${receivedType}' is not assignable to parameter '${paramIdentifier}' of type '${expectedType}'.`, + cause, + ); } } @@ -604,8 +611,28 @@ export class ArgumentTypeError extends TypeError { * @since 0.8.3 */ export class AssignmentTypeError extends TypeError { - constructor(leftExpType: string, rightExpType: string) { - super(`Type '${rightExpType}' is not assignable to type '${leftExpType}'.`); + constructor(leftExpType: string, rightExpType: string, cause?: TypeError) { + super(`Type '${rightExpType}' is not assignable to type '${leftExpType}'.`, cause); + } +} + +/** + * Error that is thrown whenever a property is assigned to that is not defined in the object. + * @since 0.11.0 + */ +export class PropertyAssignmentTypeError extends TypeError { + constructor(identifier: string, propertyType: string, valueType: string, cause?: TypeError) { + super(`Type '${valueType}' is not assignable to property '${identifier}' of type '${propertyType}'.`, cause); + } +} + +/** + * Error that is thrown whenever a property can not be found in the object. + * @since 0.11.0 + */ +export class PropertyNotFoundError extends TypeError { + constructor(objType: string, identifier: string) { + super(`Property '${identifier}' not found in object of type '${objType}'.`); } } @@ -638,6 +665,16 @@ export class UnknownTypeError extends TypeError { } } +/** + * Error that is thrown whenever a type is used that is not a type. + * @since 0.11.0 + */ +export class ReferenceCanNotBeUsedAsTypeError extends TypeError { + constructor(identifier: string) { + super(`Reference '${identifier}' can not be used as a type.`); + } +} + /** * Error that is thrown whenever a relational comparison is used with types that are not comparable. * @since 0.9.0 diff --git a/kipper/core/src/tools/functions/indent.ts b/kipper/core/src/tools/functions/indent.ts new file mode 100644 index 000000000..7f94b394b --- /dev/null +++ b/kipper/core/src/tools/functions/indent.ts @@ -0,0 +1,12 @@ +/** + * Adds a left indentation to the message with the specified amount of spaces. + * @param msg The message to indent. + * @param spaces The amount of spaces to indent the message with. + * @since 0.11.0 + */ +export function addLeftIndent(msg: string, spaces: number = 2): string { + return msg + .split("\n") + .map((line: string): string => `${" ".repeat(spaces)}${line}`) + .join("\n"); +} diff --git a/kipper/core/src/tools/functions/index.ts b/kipper/core/src/tools/functions/index.ts index ff4aaa92f..ca2545621 100644 --- a/kipper/core/src/tools/functions/index.ts +++ b/kipper/core/src/tools/functions/index.ts @@ -6,3 +6,4 @@ export * from "./parser-rules"; export * from "./inverse-map"; export * from "./replace-obj-keys"; export * from "./other"; +export * from "./indent"; diff --git a/kipper/target-js/src/code-generator.ts b/kipper/target-js/src/code-generator.ts index f905043ef..1ec5cf1a5 100644 --- a/kipper/target-js/src/code-generator.ts +++ b/kipper/target-js/src/code-generator.ts @@ -54,6 +54,8 @@ import type { TypeofTypeSpecifierExpression, VoidOrNullOrUndefinedPrimaryExpression, WhileLoopIterationStatement, + InterfaceDeclaration, + ClassDeclaration, } from "@kipper/core"; import { CompoundStatement, @@ -64,6 +66,7 @@ import { ScopeFunctionDeclaration, VariableDeclaration, Expression, + BuiltInTypes, } from "@kipper/core"; import { createJSFunctionSignature, getJSFunctionSignature, indentLines, removeBraces } from "./tools"; import { TargetJS, version } from "./index"; @@ -384,6 +387,20 @@ export class JavaScriptTargetCodeGenerator extends KipperTargetCodeGenerator { return [[storage, " ", semanticData.identifier, ...(assign.length > 0 ? [" ", "=", " ", ...assign] : []), ";"]]; }; + /** + * Translates a {@link AssignmentExpression} into the JavaScript language. + */ + interfaceDeclaration = async (node: InterfaceDeclaration): Promise> => { + return []; + }; + + /** + * Translates a {@link ClassDeclaration} into the JavaScript language. + */ + classDeclaration = async (node: ClassDeclaration): Promise> => { + return []; + }; + /** * Translates a {@link NumberPrimaryExpression} into the JavaScript language. */ @@ -422,14 +439,11 @@ export class JavaScriptTargetCodeGenerator extends KipperTargetCodeGenerator { * Translates a {@link IdentifierPrimaryExpression} into the JavaScript language. */ identifierPrimaryExpression = async (node: IdentifierPrimaryExpression): Promise => { - const semanticData = node.getSemanticData(); - let identifier: string = semanticData.identifier; + const refTarget = node.getSemanticData().ref.refTarget; + let identifier: string = refTarget.isBuiltIn + ? TargetJS.getBuiltInIdentifier(refTarget.builtInStructure!!) + : refTarget.identifier; - // If the identifier is not declared by the user, assume it's a built-in function and format the identifier - // accordingly. - if (!(semanticData.ref.refTarget instanceof ScopeDeclaration)) { - identifier = TargetJS.getBuiltInIdentifier(semanticData.ref.refTarget); - } return [identifier]; }; @@ -565,8 +579,7 @@ export class JavaScriptTargetCodeGenerator extends KipperTargetCodeGenerator { const func = node.getTypeSemanticData().func; // Get the proper identifier for the function - const identifier = - func instanceof ScopeFunctionDeclaration ? func.identifier : TargetJS.getBuiltInIdentifier(func.identifier); + const identifier = func.isBuiltIn ? TargetJS.getBuiltInIdentifier(func.builtInStructure!!) : func.identifier; // Generate the arguments let args: TranslatedExpression = []; @@ -622,7 +635,9 @@ export class JavaScriptTargetCodeGenerator extends KipperTargetCodeGenerator { // If both types are the same we will only return the translated expression to avoid useless conversions. return exp; } else { - const func: string = TargetJS.getBuiltInIdentifier(getConversionFunctionIdentifier(originalType, destType)); + const func: string = TargetJS.getBuiltInIdentifier( + getConversionFunctionIdentifier(originalType.identifier, destType.identifier), + ); return [func, "(", ...exp, ")"]; } }; @@ -639,7 +654,7 @@ export class JavaScriptTargetCodeGenerator extends KipperTargetCodeGenerator { const exp2: TranslatedExpression = await semanticData.rightOp.translateCtxAndChildren(); // In this case it should be a string multiplication - if (semanticData.leftOp.getTypeSemanticData().evaluatedType.getCompilableType() === "str") { + if (semanticData.leftOp.getTypeSemanticData().evaluatedType === BuiltInTypes.str) { return [stringRepeatFunction, "(", ...exp1, ", ", ...exp2, ")"]; } @@ -758,20 +773,18 @@ export class JavaScriptTargetCodeGenerator extends KipperTargetCodeGenerator { */ assignmentExpression = async (node: AssignmentExpression): Promise => { const semanticData = node.getSemanticData(); - let identifier = semanticData.identifier; - - // If the identifier is not found in the global scope, assume it's a built-in function and format the identifier - // accordingly. - if (!(semanticData.assignTarget.refTarget instanceof ScopeDeclaration)) { - identifier = TargetJS.getBuiltInIdentifier(identifier); - } - - // The expression that is assigned to the reference + const refTarget = semanticData.assignTarget.refTarget; + const identifier = refTarget.isBuiltIn + ? TargetJS.getBuiltInIdentifier(refTarget.builtInStructure!!) + : refTarget.identifier; const assignExp = await semanticData.value.translateCtxAndChildren(); return [identifier, " ", semanticData.operator, " ", ...assignExp]; }; + /** + * Translates a {@link LambdaExpression} into the JavaScript language. + */ lambdaExpression = async (node: LambdaExpression): Promise => { // Step 1: Extract Semantic Data const semanticData = node.getSemanticData(); diff --git a/kipper/target-js/src/semantic-analyser.ts b/kipper/target-js/src/semantic-analyser.ts index b50e10535..a7d6279f5 100644 --- a/kipper/target-js/src/semantic-analyser.ts +++ b/kipper/target-js/src/semantic-analyser.ts @@ -2,7 +2,14 @@ * The TypeScript target-specific semantic analyser. * @since 0.10.0 */ -import type { FunctionDeclaration, ParameterDeclaration, VariableDeclaration } from "@kipper/core"; +import type { + ClassDeclaration, + Declaration, + FunctionDeclaration, + InterfaceDeclaration, + ParameterDeclaration, + VariableDeclaration, +} from "@kipper/core"; import { KipperTargetSemanticAnalyser, ReservedIdentifierOverwriteError } from "@kipper/core"; import { TargetJS } from "./target"; @@ -17,9 +24,7 @@ export class JavaScriptTargetSemanticAnalyser extends KipperTargetSemanticAnalys * @param declaration The variable, function or parameter declaration. * @private */ - protected checkViabilityOfIdentifier( - declaration: ParameterDeclaration | FunctionDeclaration | VariableDeclaration, - ): void { + protected checkViabilityOfIdentifier(declaration: Declaration): void { const identifier = declaration.getSemanticData().identifier; // Throw an error in case the declaration identifier is reserved @@ -103,6 +108,14 @@ export class JavaScriptTargetSemanticAnalyser extends KipperTargetSemanticAnalys this.checkViabilityOfIdentifier(node); }; + interfaceDeclaration = async (node: InterfaceDeclaration) => { + this.checkViabilityOfIdentifier(node); + }; + + classDeclaration = async (node: ClassDeclaration) => { + this.checkViabilityOfIdentifier(node); + }; + /** * Performs typescript-specific semantic analysis for {@link NumberPrimaryExpression} instances. */ @@ -222,44 +235,44 @@ export class JavaScriptTargetSemanticAnalyser extends KipperTargetSemanticAnalys equalityExpression = undefined; /** - * Performs typescript-specific semantic analysis for {@link LogicalAndExpression} instances. + * Performs typescript-specific semantic analysis for {@link BitwiseAndExpression} instances. */ - logicalAndExpression = undefined; + bitwiseAndExpression = undefined; /** - * Performs typescript-specific semantic analysis for {@link LogicalOrExpression} instances. + * Performs typescript-specific semantic analysis for {@link BitwiseOrExpression} instances. */ - logicalOrExpression = undefined; + bitwiseOrExpression = undefined; /** - * Performs typescript-specific semantic analysis for {@link ConditionalExpression} instances. + * Performs typescript-specific semantic analysis for {@link BitwiseXorExpression} instances. */ - conditionalExpression = undefined; + bitwiseXorExpression = undefined; /** - * Performs typescript-specific semantic analysis for {@link AssignmentExpression} instances. + * Performs typescript-specific semantic analysis for {@link BitwiseShiftExpression} instances. */ - assignmentExpression = undefined; + bitwiseShiftExpression = undefined; /** - * Performs typescript-specific semantic analysis for {@link BitwiseAndExpression} instances. + * Performs typescript-specific semantic analysis for {@link LogicalAndExpression} instances. */ - bitwiseAndExpression = undefined; + logicalAndExpression = undefined; /** - * Performs typescript-specific semantic analysis for {@link BitwiseOrExpression} instances. + * Performs typescript-specific semantic analysis for {@link LogicalOrExpression} instances. */ - bitwiseOrExpression = undefined; + logicalOrExpression = undefined; /** - * Performs typescript-specific semantic analysis for {@link BitwiseXorExpression} instances. + * Performs typescript-specific semantic analysis for {@link ConditionalExpression} instances. */ - bitwiseXorExpression = undefined; + conditionalExpression = undefined; /** - * Performs typescript-specific semantic analysis for {@link BitwiseShiftExpression} instances. + * Performs typescript-specific semantic analysis for {@link AssignmentExpression} instances. */ - bitwiseShiftExpression = undefined; + assignmentExpression = undefined; /** * Performs typescript-specific semantic analysis for {@link LambdaExpression} instances. diff --git a/kipper/target-js/src/target.ts b/kipper/target-js/src/target.ts index 64f9a617c..5bddeedb1 100644 --- a/kipper/target-js/src/target.ts +++ b/kipper/target-js/src/target.ts @@ -4,7 +4,8 @@ * @copyright 2021-2022 Luna Klatzer * @since 0.10.0 */ -import type { BuiltInFunction, BuiltInVariable } from "@kipper/core"; +import type { BuiltInFunction, BuiltInType } from "@kipper/core"; +import { BuiltInVariable } from "@kipper/core"; import { KipperCompileTarget } from "@kipper/core"; import { JavaScriptTargetSemanticAnalyser } from "./semantic-analyser"; import { JavaScriptTargetCodeGenerator } from "./code-generator"; @@ -99,16 +100,16 @@ export class KipperJavaScriptTarget extends KipperCompileTarget { /** * Fetches the reserved identifier for the translated code. * - * This will also ensure that {@link BuiltInVariable.local local variables} are not registered onto the global object. + * This will also ensure that {@link BuiltInVariable local variables} are not registered onto the global object. * Those will simply stay as local variables with the same identifier. * @param signature The identifier or signature object to translate to its JavaScript form. * @since 0.10.0 */ - public static getBuiltInIdentifier(signature: string | BuiltInVariable | BuiltInFunction): string { + public static getBuiltInIdentifier(signature: string | BuiltInVariable | BuiltInFunction | BuiltInType): string { if (typeof signature === "string") { return `${this.internalObjectIdentifier}.${signature}`; } - return "local" in signature && signature.local + return signature instanceof BuiltInVariable && signature.local ? signature.identifier : this.getBuiltInIdentifier(signature.identifier); } diff --git a/kipper/target-ts/src/built-in-generator.ts b/kipper/target-ts/src/built-in-generator.ts index f8338178b..d5b3f8c57 100644 --- a/kipper/target-ts/src/built-in-generator.ts +++ b/kipper/target-ts/src/built-in-generator.ts @@ -6,7 +6,7 @@ import type { BuiltInFunction, InternalFunction, TranslatedCodeLine } from "@kipper/core"; import { JavaScriptTargetBuiltInGenerator } from "@kipper/target-js"; import { getTSFunctionSignature, createTSFunctionSignature } from "./tools"; -import type { BuiltInVariable, KipperCompilableType, KipperProgramContext } from "@kipper/core"; +import type { BuiltInVariable, KipperBuiltInTypeLiteral, KipperProgramContext } from "@kipper/core"; import { TargetTS } from "./target"; /** @@ -19,8 +19,8 @@ import { TargetTS } from "./target"; export function genTSFunction( signature: { identifier: string; - params: Array<{ identifier: string; type: KipperCompilableType | Array }>; - returnType: KipperCompilableType | Array; + params: Array<{ identifier: string; type: string | Array }>; + returnType: string | Array; }, body: string, ignoreParams: boolean = false, @@ -50,7 +50,7 @@ export function genTSVariable(varSpec: BuiltInVariable, value: string): Translat TargetTS.getBuiltInIdentifier(varSpec), ":", " ", - TargetTS.getTypeScriptType(varSpec.valueType), + TargetTS.getTypeScriptType(varSpec.valueType.identifier), " ", "=", " ", diff --git a/kipper/target-ts/src/code-generator.ts b/kipper/target-ts/src/code-generator.ts index 49283d8ad..57bc71f8c 100644 --- a/kipper/target-ts/src/code-generator.ts +++ b/kipper/target-ts/src/code-generator.ts @@ -35,7 +35,7 @@ export class TypeScriptTargetCodeGenerator extends JavaScriptTargetCodeGenerator const typeData = node.getTypeSemanticData(); const storage = semanticData.storageType === "const" ? "const" : "let"; - const tsType = TargetTS.getTypeScriptType(typeData.valueType.getCompilableType()); + const tsType = TargetTS.getTypeScriptType(typeData.valueType.identifier); const assign = semanticData.value ? await semanticData.value.translateCtxAndChildren() : []; // Only add ' = EXP' if assignValue is defined diff --git a/kipper/target-ts/src/target.ts b/kipper/target-ts/src/target.ts index 2028cbfdf..2e41465f6 100644 --- a/kipper/target-ts/src/target.ts +++ b/kipper/target-ts/src/target.ts @@ -2,19 +2,19 @@ * The TypeScript translation target for the Kipper language. * @since 0.10.0 */ -import type { BuiltInFunction, BuiltInVariable, KipperCompilableType } from "@kipper/core"; +import type { BuiltInFunction, BuiltInVariable, KipperBuiltInTypeLiteral } from "@kipper/core"; import { - kipperBoolType, + kipperBoolTypeLiteral, KipperCompileTarget, - kipperFuncType, - kipperListType, - kipperMetaType, + kipperFuncTypeLiteral, + kipperListTypeLiteral, + kipperMetaTypeLiteral, KipperNotImplementedError, - kipperNullType, - kipperNumType, - kipperStrType, - kipperUndefinedType, - kipperVoidType, + kipperNullTypeLiteral, + kipperNumTypeLiteral, + kipperStrTypeLiteral, + kipperUndefinedTypeLiteral, + kipperVoidTypeLiteral, } from "@kipper/core"; import { TypeScriptTargetSemanticAnalyser } from "./semantic-analyser"; import { TypeScriptTargetCodeGenerator } from "./code-generator"; @@ -59,34 +59,34 @@ export class KipperTypeScriptTarget extends KipperCompileTarget { } /** - * Fetches the typescript equivalent for a {@link KipperCompilableType}. + * Fetches the typescript equivalent for a {@link KipperBuiltInTypeLiteral}. * @param kipperType The type to get the equivalent for. * @since 0.8.0 */ - public static getTypeScriptType(kipperType: KipperCompilableType | Array): string { + public static getTypeScriptType(kipperType: T | Array): string { if (Array.isArray(kipperType)) { // Recursively call this function for each type in the array return `${kipperType.map(this.getTypeScriptType).join(" | ")}`; } switch (kipperType) { - case kipperBoolType: + case kipperBoolTypeLiteral: return "boolean"; - case kipperFuncType: + case kipperFuncTypeLiteral: return "Function"; - case kipperListType: + case kipperListTypeLiteral: return "Array"; - case kipperMetaType: + case kipperMetaTypeLiteral: return "object"; - case kipperNullType: + case kipperNullTypeLiteral: return "null"; - case kipperNumType: + case kipperNumTypeLiteral: return "number"; - case kipperStrType: + case kipperStrTypeLiteral: return "string"; - case kipperUndefinedType: + case kipperUndefinedTypeLiteral: return "undefined"; - case kipperVoidType: + case kipperVoidTypeLiteral: return "void"; default: throw new KipperNotImplementedError(`TypeScript type for ${kipperType} not implemented.`); diff --git a/kipper/target-ts/src/tools.ts b/kipper/target-ts/src/tools.ts index 6d2d1662e..0fcc89918 100644 --- a/kipper/target-ts/src/tools.ts +++ b/kipper/target-ts/src/tools.ts @@ -6,7 +6,7 @@ import type { FunctionDeclaration, BuiltInFunction, BuiltInFunctionArgument, - KipperCompilableType, + KipperBuiltInTypeLiteral, InternalFunction, InternalFunctionArgument, } from "@kipper/core"; @@ -19,8 +19,8 @@ import { TargetTS } from "./target"; */ export function getTSFunctionSignature(funcSpec: InternalFunction | BuiltInFunction | FunctionDeclaration): { identifier: string; - params: Array<{ identifier: string; type: KipperCompilableType | Array }>; - returnType: KipperCompilableType | Array; + params: Array<{ identifier: string; type: string | Array }>; + returnType: string | Array; } { if ("antlrRuleCtx" in funcSpec) { const semanticData = funcSpec.getSemanticData(); @@ -31,18 +31,21 @@ export function getTSFunctionSignature(funcSpec: InternalFunction | BuiltInFunct params: semanticData.params.map((param) => { return { identifier: param.getSemanticData().identifier, - type: param.getTypeSemanticData().valueType.getCompilableType(), + type: param.getTypeSemanticData().valueType.identifier, }; }), - returnType: typeData.returnType.getCompilableType(), + returnType: typeData.returnType.identifier, }; } else { return { identifier: funcSpec.identifier, params: funcSpec.params.map((arg: BuiltInFunctionArgument | InternalFunctionArgument) => { - return { identifier: arg.identifier, type: arg.valueType }; + return { + identifier: arg.identifier, + type: Array.isArray(arg.valueType) ? arg.valueType.map((t) => t.identifier) : arg.valueType.identifier, + }; }), - returnType: funcSpec.returnType, + returnType: funcSpec.returnType.identifier, }; } } @@ -56,8 +59,8 @@ export function getTSFunctionSignature(funcSpec: InternalFunction | BuiltInFunct export function createTSFunctionSignature( signature: { identifier: string; - params: Array<{ identifier: string; type: KipperCompilableType | Array }>; - returnType: KipperCompilableType | Array; + params: Array<{ identifier: string; type: string | Array }>; + returnType: string | Array; }, ignoreParams: boolean = false, ): string { diff --git a/test/kipper-files/main.kip b/test/kipper-files/main.kip index 81461db02..a6b34cf37 100644 --- a/test/kipper-files/main.kip +++ b/test/kipper-files/main.kip @@ -2,7 +2,7 @@ var y: num = 4; var x: num = 4; const z: num = 3333 + x + y; -def func() -> num { +def fun() -> num { // Basic definitions of variables var localX: str = "string"; var localY: str = localX + localX; @@ -14,4 +14,4 @@ def func() -> num { return 1; } -call func(); +call fun(); diff --git a/test/kipper-files/nested-scopes.kip b/test/kipper-files/nested-scopes.kip index 97d1e1871..40bba978f 100644 --- a/test/kipper-files/nested-scopes.kip +++ b/test/kipper-files/nested-scopes.kip @@ -2,7 +2,7 @@ var x: bool; var y: num = 4; const z: str = "1"; -def func() -> void { +def fun() -> void { { var rx: bool; var ry: num = 5 * y; diff --git a/test/kipper-files/single-function-definition.kip b/test/kipper-files/single-function-definition.kip index 1582912f0..dea586b70 100644 --- a/test/kipper-files/single-function-definition.kip +++ b/test/kipper-files/single-function-definition.kip @@ -1,4 +1,4 @@ -def func() -> void { +def fun() -> void { { { var lx: bool; diff --git a/test/module/core/ast-node.test.ts b/test/module/core/ast-node.test.ts index 670a40095..1fd46e0a7 100644 --- a/test/module/core/ast-node.test.ts +++ b/test/module/core/ast-node.test.ts @@ -77,7 +77,7 @@ describe("AST Nodes", () => { const result = await new KipperCompiler().compile("var valid: str = '1';", { target: defaultTarget }); assert.isDefined(result.programCtx); - const ast = result.programCtx!!.abstractSyntaxTree; + const ast = result.programCtx!!.rootASTNode; assert.notEqual(ast, undefined, "Expected AST to be present"); assert.equal(ast.children.length, 1, "Expected 1 child for RootASTNode"); @@ -88,7 +88,7 @@ describe("AST Nodes", () => { const result = await new KipperCompiler().compile("var invalid: str = 1;", { target: defaultTarget }); assert.isDefined(result.programCtx); - const ast = result.programCtx!!.abstractSyntaxTree; + const ast = result.programCtx!!.rootASTNode; assert.notEqual(ast, undefined, "Expected AST to be present"); assert.equal(ast.children.length, 1, "Expected 1 child for RootASTNode"); @@ -103,7 +103,7 @@ describe("AST Nodes", () => { const result = await new KipperCompiler().compile("", { target: defaultTarget }); assert.isDefined(result.programCtx); - const ast = result.programCtx!!.abstractSyntaxTree; + const ast = result.programCtx!!.rootASTNode; assert.notEqual(ast, undefined, "Expected AST to be present"); assert.equal(ast.sourceCode, "", "Expected source code to be empty"); @@ -114,7 +114,7 @@ describe("AST Nodes", () => { const result = await new KipperCompiler().compile(sourceCode, { target: defaultTarget }); assert.isDefined(result.programCtx); - const ast = result.programCtx!!.abstractSyntaxTree; + const ast = result.programCtx!!.rootASTNode; assert.notEqual(ast, undefined, "Expected AST to be present"); assert.equal(ast.sourceCode, sourceCode, "Expected source code to match"); @@ -126,7 +126,7 @@ describe("AST Nodes", () => { const result = await new KipperCompiler().compile("var valid: str = '1';", { target: defaultTarget }); assert.isDefined(result.programCtx); - const ast = result.programCtx!!.abstractSyntaxTree; + const ast = result.programCtx!!.rootASTNode; assert.notEqual(ast, undefined, "Expected AST to be present"); assert.equal(ast.hasFailed, false, "Expected 'hasFailed' to be false"); @@ -136,7 +136,7 @@ describe("AST Nodes", () => { const result = await new KipperCompiler().compile("var invalid: str = 1;", { target: defaultTarget }); assert.isDefined(result.programCtx); - const ast = result.programCtx!!.abstractSyntaxTree; + const ast = result.programCtx!!.rootASTNode; assert.notEqual(ast, undefined, "Expected AST to be present"); assert.isTrue(ast.hasFailed, "Expected 'hasFailed' to be false"); @@ -148,7 +148,7 @@ describe("AST Nodes", () => { const result = await new KipperCompiler().compile("", { target: defaultTarget }); assert.isDefined(result.programCtx); - const ast = result.programCtx!!.abstractSyntaxTree; + const ast = result.programCtx!!.rootASTNode; assert.notEqual(ast, undefined, "Expected AST to be present"); assert.equal(ast.children.length, 0, "Expected 0 children"); @@ -161,7 +161,7 @@ describe("AST Nodes", () => { { target: defaultTarget }, ); assert.isDefined(result.programCtx); - const ast = result.programCtx!!.abstractSyntaxTree; + const ast = result.programCtx!!.rootASTNode; assert.notEqual(ast, undefined, "Expected AST to be present"); assert.equal(ast.children.length, 1, "Expected 1 child"); @@ -174,7 +174,7 @@ describe("AST Nodes", () => { { target: defaultTarget }, ); assert.isDefined(result.programCtx); - const ast = result.programCtx!!.abstractSyntaxTree; + const ast = result.programCtx!!.rootASTNode; assert.notEqual(ast, undefined, "Expected AST to be present"); assert.equal(ast.children.length, 3, "Expected 2 children"); @@ -191,10 +191,10 @@ describe("AST Nodes", () => { // Generate the AST by compiling the program (as 'generateAbstractSyntaxTree' is private) await programCtx.compileProgram(); - const ast = programCtx.abstractSyntaxTree; + const ast = programCtx.rootASTNode; assert.notEqual(programCtx, undefined, "Expected programCtx to be present"); - assert.notEqual(programCtx.abstractSyntaxTree, undefined, "Expected AST to be present"); + assert.notEqual(programCtx.rootASTNode, undefined, "Expected AST to be present"); assert.equal(ast.programCtx, programCtx, "Expected programCtx to match"); }); @@ -208,10 +208,10 @@ describe("AST Nodes", () => { // Generate the AST by compiling the program (as 'generateAbstractSyntaxTree' is private) await programCtx.compileProgram(); - const ast = programCtx.abstractSyntaxTree; + const ast = programCtx.rootASTNode; assert.notEqual(programCtx, undefined, "Expected programCtx to be present"); - assert.notEqual(programCtx.abstractSyntaxTree, undefined, "Expected AST to be present"); + assert.notEqual(programCtx.rootASTNode, undefined, "Expected AST to be present"); assert.equal(ast.parent, undefined, "Expected parent to be undefined"); }); }); diff --git a/test/module/core/built-ins.test.ts b/test/module/core/built-ins.test.ts index 65b89c6c3..4e52bfdab 100644 --- a/test/module/core/built-ins.test.ts +++ b/test/module/core/built-ins.test.ts @@ -70,7 +70,7 @@ describe("Built-ins", () => { try { await compiler.compile(fileContent, config); } catch (e) { - assert.equal((e).constructor.name, "ArgumentTypeError", "Expected different error"); + assert.equal((e).constructor.name, "ArgumentAssignmentTypeError", "Expected different error"); assert((e).name === "TypeError", "Expected different error"); return; } @@ -124,7 +124,7 @@ describe("Built-ins", () => { try { await compiler.compile(fileContent, config); } catch (e) { - assert.equal((e).constructor.name, "ArgumentTypeError", "Expected different error"); + assert.equal((e).constructor.name, "ArgumentAssignmentTypeError", "Expected different error"); assert((e).name === "TypeError", "Expected different error"); return; } diff --git a/test/module/core/compiler.test.ts b/test/module/core/compiler.test.ts index 4a140d13a..f41d8712d 100644 --- a/test/module/core/compiler.test.ts +++ b/test/module/core/compiler.test.ts @@ -294,7 +294,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 4, "Expected four global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 4, "Expected four global scope entries"); }); it(`Arithmetics [${target.fileExtension}]`, async () => { @@ -304,7 +304,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 0, "Expected no global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 0, "Expected no global scope entries"); assert.include(result.write(), fileContent, "Expected compiled code to not change"); }); @@ -315,7 +315,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 1, "Expected one global scope entry"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 1, "Expected one global scope entry"); }); it(`Nested scopes [${target.fileExtension}]`, async () => { @@ -325,7 +325,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 4, "Expected four global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 4, "Expected four global scope entries"); }); it(`Single Function call [${target.fileExtension}]`, async () => { @@ -335,7 +335,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 0, "Expected no global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 0, "Expected no global scope entries"); // Compile the program to JavaScript and evaluate it const jsCode = ts.transpile(result.write()); @@ -360,7 +360,7 @@ describe("KipperCompiler", () => { assert(result.programCtx); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 0, "Expected no global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 0, "Expected no global scope entries"); // Compile the program to JavaScript and evaluate it const jsCode = ts.transpile(result.write()); @@ -377,7 +377,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 1, "Expected one global scope entry"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 1, "Expected one global scope entry"); }); it(`Multi Function definition [${target.fileExtension}]`, async () => { @@ -387,7 +387,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 3, "Expected three global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 3, "Expected three global scope entries"); }); it(`Function call argument [${target.fileExtension}]`, async () => { @@ -397,7 +397,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 0, "Expected no global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 0, "Expected no global scope entries"); // Compile the program to JavaScript and evaluate it const jsCode = ts.transpile(result.write()); @@ -414,7 +414,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 1, "Expected one global scope entry"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 1, "Expected one global scope entry"); // Compile the program to JavaScript and evaluate it const jsCode = ts.transpile(result.write()); @@ -430,7 +430,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 1, "Expected one global scope entry"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 1, "Expected one global scope entry"); }); it(`Bool [${target.fileExtension}]`, async () => { @@ -440,7 +440,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 2, "Expected two global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 2, "Expected two global scope entries"); }); it(`Type conversion [${target.fileExtension}]`, async () => { @@ -450,7 +450,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 4, "Expected four global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 4, "Expected four global scope entries"); const code = result.write(); assert(code); @@ -467,7 +467,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 3, "Expected three global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 3, "Expected three global scope entries"); const code = result.write(); assert(code); @@ -482,7 +482,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 0, "Expected no global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 0, "Expected no global scope entries"); // Compile the program to JavaScript and evaluate it const jsCode = ts.transpile(result.write()); @@ -498,7 +498,7 @@ describe("KipperCompiler", () => { assert.isDefined(result.programCtx); assert.isDefined(result.programCtx!!.internals); assert.equal(result.programCtx!!.errors.length, 0, "Expected no compilation errors"); - assert.equal(result.programCtx!!.globalScope.entries.size, 0, "Expected no global scope entries"); + assert.equal(result.programCtx!!.globalScope!!.entries.size, 0, "Expected no global scope entries"); const code = result.write(); assert(code); diff --git a/test/module/core/errors/index.ts b/test/module/core/errors/index.ts index d55cd1ec1..726c54e68 100644 --- a/test/module/core/errors/index.ts +++ b/test/module/core/errors/index.ts @@ -27,7 +27,7 @@ export function ensureTracebackDataExists(e: KipperError): void { export function ensureErrorWasReported(programCtx?: KipperProgramContext): void { if (programCtx) { assert(programCtx.hasFailed, "Expected program to have failed"); - assert(programCtx.abstractSyntaxTree?.hasFailed, "Expected AST root-node to have failed"); + assert(programCtx.rootASTNode?.hasFailed, "Expected AST root-node to have failed"); } } diff --git a/test/module/core/errors/semantic-errors/builtin-overwrite.ts b/test/module/core/errors/semantic-errors/builtin-overwrite.ts index d6c612a87..f0fa4230b 100644 --- a/test/module/core/errors/semantic-errors/builtin-overwrite.ts +++ b/test/module/core/errors/semantic-errors/builtin-overwrite.ts @@ -1,4 +1,5 @@ import type { CompileConfig, KipperError } from "@kipper/core"; +import { BuiltInTypes } from "@kipper/core"; import { KipperCompiler } from "@kipper/core"; import { defaultConfig, ensureTracebackDataExists } from "../index"; import { assert } from "chai"; @@ -11,7 +12,7 @@ describe("BuiltInOverwriteError", () => { const config: CompileConfig = { ...defaultConfig, // prettier-ignore - extendBuiltInFunctions: test.i !== "print" ? [{ identifier: test.i, params: [], returnType: "void", }, ] : [], + extendBuiltInFunctions: test.i !== "print" ? [{ identifier: test.i, params: [], returnType: BuiltInTypes.void, }, ] : [], }; describe(`Global Scope - Overwrite [${test.t}]`, () => { diff --git a/test/module/core/errors/semantic-errors/invalid-global.ts b/test/module/core/errors/semantic-errors/invalid-global.ts index 8accd1d4d..05840b46f 100644 --- a/test/module/core/errors/semantic-errors/invalid-global.ts +++ b/test/module/core/errors/semantic-errors/invalid-global.ts @@ -1,4 +1,5 @@ import type { KipperError, KipperProgramContext, LexerParserData } from "@kipper/core"; +import { BuiltInTypes } from "@kipper/core"; import { KipperCompiler, KipperFileStream } from "@kipper/core"; import { defaultConfig } from "../index"; import { assert } from "chai"; @@ -14,8 +15,8 @@ describe("InvalidGlobalError", () => { const programCtx: KipperProgramContext = await compiler.getProgramCtx(parseData, defaultConfig); // Duplicate identifier - programCtx.registerBuiltInFunctions({ identifier: globalName, params: [], returnType: "void" }); - programCtx.registerBuiltInFunctions({ identifier: globalName, params: [], returnType: "void" }); + programCtx.registerBuiltInFunctions({ identifier: globalName, params: [], returnType: BuiltInTypes.void }); + programCtx.registerBuiltInFunctions({ identifier: globalName, params: [], returnType: BuiltInTypes.void }); } catch (e) { assert.equal((e).constructor.name, "InvalidGlobalError", "Expected different error"); assert((e).line !== undefined, "Expected existing 'line' meta field"); diff --git a/test/module/core/errors/type-errors/argument-type-error.ts b/test/module/core/errors/type-errors/argument-type-error.ts index 5e91d674f..57d4e4695 100644 --- a/test/module/core/errors/type-errors/argument-type-error.ts +++ b/test/module/core/errors/type-errors/argument-type-error.ts @@ -3,30 +3,30 @@ import { KipperCompiler } from "@kipper/core"; import { assert } from "chai"; import { defaultConfig, ensureTracebackDataExists } from "../index"; -describe("ArgumentTypeError", () => { +describe("ArgumentAssignmentTypeError", () => { describe("Error", () => { it("Single argument (One invalid)", async () => { try { await new KipperCompiler().compile(`print(1);`, defaultConfig); } catch (e) { - assert.equal((e).constructor.name, "ArgumentTypeError", "Expected different error"); + assert.equal((e).constructor.name, "ArgumentAssignmentTypeError", "Expected different error"); assert((e).name === "TypeError", "Expected different error"); ensureTracebackDataExists(e); return; } - assert.fail("Expected 'ArgumentTypeError'"); + assert.fail("Expected 'ArgumentAssignmentTypeError'"); }); it("Two arguments (One invalid)", async () => { try { await new KipperCompiler().compile(`def test(p1: str, p2: str) -> void {}; test("Hello", 1);`, defaultConfig); } catch (e) { - assert.equal((e).constructor.name, "ArgumentTypeError", "Expected different error"); + assert.equal((e).constructor.name, "ArgumentAssignmentTypeError", "Expected different error"); assert((e).name === "TypeError", "Expected different error"); ensureTracebackDataExists(e); return; } - assert.fail("Expected 'ArgumentTypeError'"); + assert.fail("Expected 'ArgumentAssignmentTypeError'"); }); it("Three arguments (One invalid)", async () => { @@ -36,12 +36,12 @@ describe("ArgumentTypeError", () => { defaultConfig, ); } catch (e) { - assert.equal((e).constructor.name, "ArgumentTypeError", "Expected different error"); + assert.equal((e).constructor.name, "ArgumentAssignmentTypeError", "Expected different error"); assert((e).name === "TypeError", "Expected different error"); ensureTracebackDataExists(e); return; } - assert.fail("Expected 'ArgumentTypeError'"); + assert.fail("Expected 'ArgumentAssignmentTypeError'"); }); }); diff --git a/test/module/core/global-scope.test.ts b/test/module/core/global-scope.test.ts index bae4f6bd0..087b0d49c 100644 --- a/test/module/core/global-scope.test.ts +++ b/test/module/core/global-scope.test.ts @@ -1,25 +1,24 @@ import type { ScopeFunctionDeclaration } from "@kipper/core"; +import { BuiltInTypes } from "@kipper/core"; import { KipperCompiler, ScopeVariableDeclaration } from "@kipper/core"; import { KipperTypeScriptTarget } from "@kipper/target-ts"; import { assert } from "chai"; -describe("GlobalScope", () => { +describe("Global scope", () => { const defaultTarget = new KipperTypeScriptTarget(); - describe("constructor", () => { - it("should have an empty hash map", async () => { - const compileResult = await new KipperCompiler().compile("", { target: defaultTarget }); - assert.isDefined(compileResult.programCtx); - const scope = compileResult.programCtx!!.globalScope; - assert.equal(scope.entries.size, 0); - }); + it("created on ctx creation", async () => { + const compileResult = await new KipperCompiler().compile("", { target: defaultTarget }); + assert.isDefined(compileResult.programCtx); + const scope = compileResult.programCtx!!.globalScope!!; + assert.equal(scope.entries.size, 0); }); describe("addVariable", () => { it("one", async () => { const compileResult = await new KipperCompiler().compile("var test: num = 5;", { target: defaultTarget }); assert.isDefined(compileResult.programCtx); - const scope = compileResult.programCtx!!.globalScope; + const scope = compileResult.programCtx!!.globalScope!!; // Should have one variable assert.equal(scope.entries.size, 1); @@ -28,7 +27,7 @@ describe("GlobalScope", () => { let entry = scope.entries.get(iter.next().value); assert.instanceOf(entry, ScopeVariableDeclaration); assert.equal(entry.identifier, "test"); - assert.equal(entry.type.getCompilableType(), "num"); + assert.equal(entry.type.getCompilableType(), BuiltInTypes.num); assert.equal(entry.storageType, "var"); assert.equal(entry.hasValue, true); assert.equal(entry.isDefined, true); @@ -42,7 +41,7 @@ describe("GlobalScope", () => { target: defaultTarget, }); assert.isDefined(compileResult.programCtx); - const scope = compileResult.programCtx!!.globalScope; + const scope = compileResult.programCtx!!.globalScope!!; // Should have two variables assert.equal(scope.entries.size, 2); @@ -78,7 +77,7 @@ describe("GlobalScope", () => { { target: defaultTarget }, ); assert.isDefined(compileResult.programCtx); - const scope = compileResult.programCtx!!.globalScope; + const scope = compileResult.programCtx!!.globalScope!!; // Should have three variables assert.equal(scope.entries.size, 3); @@ -126,7 +125,7 @@ describe("GlobalScope", () => { target: defaultTarget, }); assert.isDefined(compileResult.programCtx); - const scope = compileResult.programCtx!!.globalScope; + const scope = compileResult.programCtx!!.globalScope!!; // Should have one function assert.equal(scope.entries.size, 1); @@ -151,7 +150,7 @@ describe("GlobalScope", () => { { target: defaultTarget }, ); assert.isDefined(compileResult.programCtx); - const scope = compileResult.programCtx!!.globalScope; + const scope = compileResult.programCtx!!.globalScope!!; // Should have two functions assert.equal(scope.entries.size, 2); @@ -189,7 +188,7 @@ describe("GlobalScope", () => { { target: defaultTarget }, ); assert.isDefined(compileResult.programCtx); - const scope = compileResult.programCtx!!.globalScope; + const scope = compileResult.programCtx!!.globalScope!!; // Should have three functions assert.equal(scope.entries.size, 3); diff --git a/test/module/core/program-ctx.test.ts b/test/module/core/program-ctx.test.ts index 451676ef4..5f2c9df32 100644 --- a/test/module/core/program-ctx.test.ts +++ b/test/module/core/program-ctx.test.ts @@ -1,5 +1,6 @@ import { assert } from "chai"; import type { BuiltInFunction } from "@kipper/core"; +import { BuiltInFunctions, BuiltInTypes, BuiltInVariables } from "@kipper/core"; import { EvaluatedCompileConfig, InvalidGlobalError, KipperCompiler, KipperFileStream } from "@kipper/core"; import { promises as fs } from "fs"; import { KipperTypeScriptTarget } from "@kipper/target-ts"; @@ -22,8 +23,10 @@ describe("KipperProgramContext", async () => { assert.equal( programCtx.builtIns.length, Object.values([ - ...EvaluatedCompileConfig.defaults.builtInFunctions, - ...EvaluatedCompileConfig.defaults.builtInVariables, + ...Object.values(BuiltInFunctions), + ...Object.values(BuiltInVariables), + ...EvaluatedCompileConfig.defaults.extendBuiltInFunctions, + ...EvaluatedCompileConfig.defaults.extendBuiltInVariables, ]).length, "Expected the program ctx built-ins to match the default built-ins", ); @@ -38,8 +41,10 @@ describe("KipperProgramContext", async () => { assert.equal( programCtx.builtIns.length, Object.values([ - ...EvaluatedCompileConfig.defaults.builtInFunctions, - ...EvaluatedCompileConfig.defaults.builtInVariables, + ...Object.values(BuiltInFunctions), + ...Object.values(BuiltInVariables), + ...EvaluatedCompileConfig.defaults.extendBuiltInFunctions, + ...EvaluatedCompileConfig.defaults.extendBuiltInVariables, ]).length, "Expected the program ctx built-ins to match the default built-ins", ); @@ -48,15 +53,17 @@ describe("KipperProgramContext", async () => { let func: BuiltInFunction = { identifier: "test", params: [], - returnType: "void", + returnType: BuiltInTypes.void, }; programCtx.registerBuiltInFunctions(func); assert.equal( programCtx.builtIns.length, Object.values([ - ...EvaluatedCompileConfig.defaults.builtInFunctions, - ...EvaluatedCompileConfig.defaults.builtInVariables, + ...Object.values(BuiltInFunctions), + ...Object.values(BuiltInVariables), + ...EvaluatedCompileConfig.defaults.extendBuiltInFunctions, + ...EvaluatedCompileConfig.defaults.extendBuiltInVariables, ]).length + 1, "Expected the program ctx built-ins to match the default built-ins", ); @@ -71,8 +78,10 @@ describe("KipperProgramContext", async () => { assert.equal( programCtx.builtIns.length, Object.values([ - ...EvaluatedCompileConfig.defaults.builtInFunctions, - ...EvaluatedCompileConfig.defaults.builtInVariables, + ...Object.values(BuiltInFunctions), + ...Object.values(BuiltInVariables), + ...EvaluatedCompileConfig.defaults.extendBuiltInFunctions, + ...EvaluatedCompileConfig.defaults.extendBuiltInVariables, ]).length, "Expected the program ctx built-ins to match the default built-ins", ); @@ -81,15 +90,17 @@ describe("KipperProgramContext", async () => { let func: BuiltInFunction = { identifier: "test", params: [], - returnType: "void", + returnType: BuiltInTypes.void, }; programCtx.registerBuiltInFunctions(func); assert.equal( programCtx.builtIns.length, Object.values([ - ...EvaluatedCompileConfig.defaults.builtInFunctions, - ...EvaluatedCompileConfig.defaults.builtInVariables, + ...Object.values(BuiltInFunctions), + ...Object.values(BuiltInVariables), + ...EvaluatedCompileConfig.defaults.extendBuiltInFunctions, + ...EvaluatedCompileConfig.defaults.extendBuiltInVariables, ]).length + 1, "Expected the program ctx built-ins to match the default built-ins", ); @@ -118,8 +129,10 @@ describe("KipperProgramContext", async () => { assert.equal( programCtx.builtIns.length, Object.values([ - ...EvaluatedCompileConfig.defaults.builtInFunctions, - ...EvaluatedCompileConfig.defaults.builtInVariables, + ...Object.values(BuiltInFunctions), + ...Object.values(BuiltInVariables), + ...EvaluatedCompileConfig.defaults.extendBuiltInFunctions, + ...EvaluatedCompileConfig.defaults.extendBuiltInVariables, ]).length, "Expected the program ctx built-ins to match the default built-ins", ); @@ -130,7 +143,7 @@ describe("KipperProgramContext", async () => { let func: BuiltInFunction = { identifier: "test", params: [], - returnType: "void", + returnType: BuiltInTypes.void, }; programCtx.registerBuiltInFunctions(func); @@ -147,15 +160,17 @@ describe("KipperProgramContext", async () => { let func: BuiltInFunction = { identifier: "test", params: [], - returnType: "void", + returnType: BuiltInTypes.void, }; programCtx.registerBuiltInFunctions(func); assert.equal( programCtx.builtIns.length, Object.values([ - ...EvaluatedCompileConfig.defaults.builtInFunctions, - ...EvaluatedCompileConfig.defaults.builtInVariables, + ...Object.values(BuiltInFunctions), + ...Object.values(BuiltInVariables), + ...EvaluatedCompileConfig.defaults.extendBuiltInFunctions, + ...EvaluatedCompileConfig.defaults.extendBuiltInVariables, ]).length + 1, "Expected one additional built-in function after registration", ); diff --git a/test/module/core/universe-scope.test.ts b/test/module/core/universe-scope.test.ts new file mode 100644 index 000000000..ab1120b6e --- /dev/null +++ b/test/module/core/universe-scope.test.ts @@ -0,0 +1,21 @@ +import { BuiltInFunctions, BuiltInVariables } from "@kipper/core"; +import { BuiltInTypes } from "@kipper/core"; +import { KipperCompiler } from "@kipper/core"; +import { KipperTypeScriptTarget } from "@kipper/target-ts"; +import { assert } from "chai"; + +const DEFAULT_BUILTIN_COUNT = + Object.values(BuiltInVariables).length + Object.values(BuiltInFunctions).length + Object.values(BuiltInTypes).length; + +describe("UniverseScope", () => { + const defaultTarget = new KipperTypeScriptTarget(); + + describe("constructor", () => { + it("should have an empty hash map", async () => { + const compileResult = await new KipperCompiler().compile("", { target: defaultTarget }); + assert.isDefined(compileResult.programCtx); + const scope = compileResult.programCtx!!.universeScope; + assert.equal(scope.entries.size, DEFAULT_BUILTIN_COUNT); + }); + }); +});