diff --git a/.gitignore b/.gitignore index d5ceba7b27..167268902a 100644 --- a/.gitignore +++ b/.gitignore @@ -313,3 +313,6 @@ package-lock.json *.tsbuildinfo *.js.map + +consumer-test/**.js +consumer-test/**.json diff --git a/README.md b/README.md index f0027b13fe..1ebeeec993 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This repo is part the [Microsoft Bot Framework](https://github.com/microsoft/bot | Branch | Description | Build Status | Coverage Status | Windows Bot Test Status | Linux Bot Test Status |Browser Functional Tests |----|---------------|--------------|-----------------|--|--|--| -|Master | 4.8.* Preview Builds |[![Build status](https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/JS/BotBuilder-JS-master-daily)](https://fuselabs.visualstudio.com/SDK_v4/_build/latest?definitionId=460)|[![Coverage Status](https://coveralls.io/repos/github/microsoft/botbuilder-js/badge.svg?branch=master)](https://coveralls.io/github/microsoft/botbuilder-js?branch=master)|[![Build Status](https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/JS/Run-JS-Functional-Tests-Windows?branchName=master)](https://fuselabs.visualstudio.com/SDK_v4/_build/latest?definitionId=548&branchName=master)|[![Build Status](https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/JS/Run-JS-Functional-Tests-Linux?branchName=master)](https://fuselabs.visualstudio.com/SDK_v4/_build/latest?definitionId=549&branchName=master)|[![Build Status](https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/SDK_v4-CI?branchName=master)](https://fuselabs.visualstudio.com/SDK_v4/_build/latest?definitionId=731&branchName=master) +|Master | 4.9.* Preview Builds |[![Build status](https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/JS/BotBuilder-JS-master-daily)](https://fuselabs.visualstudio.com/SDK_v4/_build/latest?definitionId=460)|[![Coverage Status](https://coveralls.io/repos/github/microsoft/botbuilder-js/badge.svg?branch=master)](https://coveralls.io/github/microsoft/botbuilder-js?branch=master)|[![Build Status](https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/JS/Run-JS-Functional-Tests-Windows?branchName=master)](https://fuselabs.visualstudio.com/SDK_v4/_build/latest?definitionId=548&branchName=master)|[![Build Status](https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/JS/Run-JS-Functional-Tests-Linux?branchName=master)](https://fuselabs.visualstudio.com/SDK_v4/_build/latest?definitionId=549&branchName=master)|[![Build Status](https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/SDK_v4-CI?branchName=master)](https://fuselabs.visualstudio.com/SDK_v4/_build/latest?definitionId=731&branchName=master) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Microsoft/botbuilder-js/blob/master/LICENSE) [![Gitter](https://img.shields.io/gitter/room/Microsoft/BotBuilder.svg)](https://gitter.im/Microsoft/BotBuilder) diff --git a/consumer-test/test.ts b/consumer-test/test.ts new file mode 100644 index 0000000000..f624fd4a50 --- /dev/null +++ b/consumer-test/test.ts @@ -0,0 +1,27 @@ +import * as l1 from '../libraries/adaptive-expressions'; +import * as l2 from '../libraries/botbuilder'; +import * as l3 from '../libraries/botbuilder-ai'; +import * as l4 from '../libraries/botbuilder-applicationinsights'; +import * as l5 from '../libraries/botbuilder-azure'; +import * as l6 from '../libraries/botbuilder-core'; +import * as l7 from '../libraries/botbuilder-dialogs'; +import * as l8 from '../libraries/botbuilder-lg'; +import * as l9 from '../libraries/botbuilder-testing'; +import * as l10 from '../libraries/botframework-config'; +import * as l11 from '../libraries/botframework-connector'; +import * as l13 from '../libraries/botframework-schema'; +import * as l14 from '../libraries/botframework-streaming'; + +console.log(Object.keys(l1)); +console.log(Object.keys(l2)); +console.log(Object.keys(l3)); +console.log(Object.keys(l4)); +console.log(Object.keys(l5)); +console.log(Object.keys(l6)); +console.log(Object.keys(l7)); +console.log(Object.keys(l8)); +console.log(Object.keys(l9)); +console.log(Object.keys(l10)); +console.log(Object.keys(l11)); +console.log(Object.keys(l13)); +console.log(Object.keys(l14)); \ No newline at end of file diff --git a/libraries/adaptive-expressions/package.json b/libraries/adaptive-expressions/package.json index 9b5f81d35b..8e007077cd 100644 --- a/libraries/adaptive-expressions/package.json +++ b/libraries/adaptive-expressions/package.json @@ -36,7 +36,8 @@ "@types/node": "^10.12.18", "nyc": "^15.0.0", "ts-node": "^4.1.0", - "typescript": "3.5.3" + "typescript": "3.5.3", + "mocha": "^5.2.0" }, "scripts": { "build": "tsc", diff --git a/libraries/adaptive-expressions/src/CommonRegex.g4 b/libraries/adaptive-expressions/src/CommonRegex.g4 index 8d74f3d1d6..620e3f970f 100644 --- a/libraries/adaptive-expressions/src/CommonRegex.g4 +++ b/libraries/adaptive-expressions/src/CommonRegex.g4 @@ -92,6 +92,13 @@ option_flag | 's' ; +// QUOTING +// +// \x where x is non-alphanumeric is a literal x +// \Q...\E treat enclosed characters as literal +Quoted : '\\' NonAlphaNumeric; +BlockQuoted : '\\Q' .*? '\\E'; + atom : shared_atom | literal @@ -152,6 +159,8 @@ shared_literal | CarriageReturn | Tab | HexChar + | Quoted + | BlockQuoted | OpenBrace | CloseBrace | Comma diff --git a/libraries/adaptive-expressions/src/commonRegex.ts b/libraries/adaptive-expressions/src/commonRegex.ts index bf47e67aab..ae95b0d02a 100644 --- a/libraries/adaptive-expressions/src/commonRegex.ts +++ b/libraries/adaptive-expressions/src/commonRegex.ts @@ -32,7 +32,7 @@ export class CommonRegex { result = this.regexCache.get(pattern); } else { if (!pattern || !this.isCommonRegex(pattern)) { - throw new Error(`A regular expression parsing error occurred.`); + throw new Error(`'${ pattern }' is not a valid regex.`); } result = this.getRegExpFromString(pattern); diff --git a/libraries/adaptive-expressions/src/componentExpressionFunctions.ts b/libraries/adaptive-expressions/src/componentExpressionFunctions.ts index 0d24838282..8d4724c56c 100644 --- a/libraries/adaptive-expressions/src/componentExpressionFunctions.ts +++ b/libraries/adaptive-expressions/src/componentExpressionFunctions.ts @@ -9,7 +9,7 @@ import { ExpressionEvaluator } from './expressionEvaluator'; /** - * Interface for adding custom functions to the expression engine. + * Interface for adding custom functions to the expression parser. */ export interface ComponentExpressionFunctionsInteerface { diff --git a/libraries/adaptive-expressions/src/constant.ts b/libraries/adaptive-expressions/src/constant.ts index 9ed0a3b9ca..dcb449ed7c 100644 --- a/libraries/adaptive-expressions/src/constant.ts +++ b/libraries/adaptive-expressions/src/constant.ts @@ -14,6 +14,8 @@ import { ExpressionType } from './expressionType'; */ export class Constant extends Expression { + // original regex: (? '\'\\')); + return `'${ result }'`; + } else if (typeof this.value === 'number') { + return this.value.toString(); + } else if(typeof this.value === 'object') { + return JSON.stringify(this.value); } - if (typeof this.value === 'string') { - return `'${ this.value }'`; + return this.value.toString(); + } + + private reverseString(str: string | undefined): string { + if (!str) { + return str; } - return !this.value ? undefined : this.value.toString(); + return str.split('').reverse().join(''); } } diff --git a/libraries/adaptive-expressions/src/formatConverter.ts b/libraries/adaptive-expressions/src/datetimeFormatConverter.ts similarity index 100% rename from libraries/adaptive-expressions/src/formatConverter.ts rename to libraries/adaptive-expressions/src/datetimeFormatConverter.ts diff --git a/libraries/adaptive-expressions/src/expression.ts b/libraries/adaptive-expressions/src/expression.ts index a87f4675d6..6af972ff7c 100644 --- a/libraries/adaptive-expressions/src/expression.ts +++ b/libraries/adaptive-expressions/src/expression.ts @@ -7,11 +7,11 @@ */ import { ExpressionFunctions } from './expressionFunctions'; import { Constant } from './constant'; -import { ExpressionEvaluator, EvaluateExpressionDelegate } from './expressionEvaluator'; +import { ExpressionEvaluator, EvaluateExpressionDelegate, EvaluatorLookup } from './expressionEvaluator'; import { ExpressionType } from './expressionType'; import { SimpleObjectMemory, MemoryInterface } from './memory'; import { Extensions } from './extensions'; -import { ExpressionEngine } from './parser'; +import { ExpressionParser } from './parser'; /** * Type expected from evalating an expression. @@ -67,20 +67,270 @@ export class Expression { protected readonly evaluator: ExpressionEvaluator; /** - * xpression constructor. + * FunctionTable is a dictionary which merges BuiltinFunctions.Functions with a CustomDictionary. + */ + private static readonly FunctionTable = class implements Map { + private readonly customFunctions = new Map(); + + public keys(): IterableIterator { + const keysOfAllFunctions = Array.from(ExpressionFunctions.standardFunctions.keys()).concat(Array.from(this.customFunctions.keys())); + return keysOfAllFunctions[Symbol.iterator](); + } + + public values(): IterableIterator { + const valuesOfAllFunctions = Array.from(ExpressionFunctions.standardFunctions.values()).concat(Array.from(this.customFunctions.values())); + return valuesOfAllFunctions[Symbol.iterator](); + } + + public get size(): number { + return ExpressionFunctions.standardFunctions.size + this.customFunctions.size; + } + + public get isReadOnly(): boolean { + return false; + } + + public get(key: string): ExpressionEvaluator { + + if(ExpressionFunctions.standardFunctions.get(key)) { + return ExpressionFunctions.standardFunctions.get(key); + } + + if (this.customFunctions.get(key)) { + return this.customFunctions.get(key); + } + + return undefined; + } + + public set(key: string, value: ExpressionEvaluator): this { + if(ExpressionFunctions.standardFunctions.get(key)) { + throw Error(`You can't overwrite a built in function.`); + } + + this.customFunctions.set(key, value); + return this; + + } + + public add(item: {key: string; value: ExpressionEvaluator} | string, value: ExpressionEvaluator|undefined): void{ + if(arguments.length === 1 && item instanceof Object) { + this.set(item.key, item.value); + } else if (arguments.length == 2 && typeof item === 'string') { + this.set(item, value); + } + } + + public clear(): void { + this.customFunctions.clear(); + } + + public has(key: string): boolean { + return ExpressionFunctions.standardFunctions.has(key) || this.customFunctions.has(key); + } + + public delete(key: string): boolean { + return this.customFunctions.delete(key); + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public forEach(_callbackfn: (value: ExpressionEvaluator, key: string, map: Map) => void, thisArg?: any): void { + throw Error(`forEach function not implemented`); + } + + public entries(): IterableIterator<[string, ExpressionEvaluator]> { + throw Error(`entries function not implemented`); + } + + public get [Symbol.iterator](): () => IterableIterator<[string, ExpressionEvaluator]> { + throw Error(`Symbol.iterator function not implemented`); + } + + public get [Symbol.toStringTag](): string { + throw Error(`Symbol.toStringTag function not implemented`); + } + } + /** + * Dictionary of function => ExpressionEvaluator. + * This is all available functions, you can add custom functions to it, but you cannot + * replace builtin functions. If you clear the dictionary, it will be reset to the built in functions. + */ + public static readonly functions: Map = new Expression.FunctionTable(); + + /** + * expression constructor. * @param type Type of expression from ExpressionType * @param evaluator Information about how to validate and evaluate expression. * @param children Child expressions. */ public constructor(type: string, evaluator: ExpressionEvaluator, ...children: Expression[]) { - this.evaluator = evaluator === undefined ? ExpressionFunctions.lookup(type) : evaluator; - this.children = children; + if(evaluator) { + this.evaluator = evaluator; + this.children = children; + } else if(type !== undefined) { + if (!Expression.functions.get(type)) { + throw Error(`${ type } does not have an evaluator, it's not a built-in function or a custom function.`); + } + + this.evaluator = Expression.functions.get(type); + this.children = children; + } + } + + /** + * Do a deep equality between expressions. + * @param other Other expression. + * @returns True if expressions are the same. + */ + public deepEquals(other: Expression): boolean { + let eq = false; + if (!other) { + eq = this.type === other.type; + if (eq) { + eq = this.children.length === other.children.length; + if (this.type === ExpressionType.And || this.type === ExpressionType.Or) { + // And/Or do not depand on order + for(let i = 0; eq && i< this.children.length; i++) { + const primary = this.children[0]; + let found = false; + for (var j = 0; j < this.children.length; j++) { + if (primary.deepEquals(other.children[j])) { + found = true; + break; + } + } + + eq = found; + } + } else { + for (let i = 0; eq && i< this.children.length; i++) { + eq = this.children[i].deepEquals(other.children[i]); + } + } + } + } + return eq; + } + + /** + * Return the static reference paths to memory. + * Return all static paths to memory. If there is a computed element index, then the path is terminated there, + * but you might get other paths from the computed part as well. + * @param expression Expression to get references from. + * @returns List of the static reference paths. + */ + public references(): string[] { + const {path, refs} = this.referenceWalk(this); + if (path !== undefined) { + refs.add(path); + } + return Array.from(refs); + } + + /** + * Walking function for identifying static memory references in an expression. + * @param expression Expression to analyze. + * @param references Tracking for references found. + * @param extension If present, called to override lookup for things like template expansion. + * @returns Accessor path of expression. + */ + public referenceWalk(expression: Expression, + extension?: (arg0: Expression) => boolean): {path: string; refs: Set} { + let path: string; + let refs = new Set(); + if (extension === undefined || !extension(expression)) { + const children: Expression[] = expression.children; + if (expression.type === ExpressionType.Accessor) { + const prop: string = (children[0] as Constant).value as string; + + if (children.length === 1) { + path = prop; + } + + if (children.length === 2) { + ({path, refs} = this.referenceWalk(children[1], extension)); + if (path !== undefined) { + path = path.concat('.', prop); + } + // if path is null we still keep it null, won't append prop + // because for example, first(items).x should not return x as refs + } + } else if (expression.type === ExpressionType.Element) { + ({path, refs} = this.referenceWalk(children[0], extension)); + if (path !== undefined) { + if (children[1] instanceof Constant) { + const cnst: Constant = children[1] as Constant; + if (cnst.returnType === ReturnType.String) { + path += `.${ cnst.value }`; + } else { + path += `[${ cnst.value }]`; + } + } else { + refs.add(path); + } + } + const result = this.referenceWalk(children[1], extension); + const idxPath = result.path; + const refs1 = result.refs; + refs = new Set([...refs, ...refs1]); + if (idxPath !== undefined) { + refs.add(idxPath); + } + } else if (expression.type === ExpressionType.Foreach || + expression.type === ExpressionType.Where || + expression.type === ExpressionType.Select ) { + let result = this.referenceWalk(children[0], extension); + const child0Path = result.path; + const refs0 = result.refs; + if (child0Path !== undefined) { + refs0.add(child0Path); + } + + result = this.referenceWalk(children[2], extension); + const child2Path = result.path; + const refs2 = result.refs; + if (child2Path !== undefined) { + refs2.add(child2Path); + } + + const iteratorName = (children[1].children[0] as Constant).value as string; + var nonLocalRefs2 = Array.from(refs2).filter((x): boolean => !(x === iteratorName || x.startsWith(iteratorName + '.') || x.startsWith(iteratorName + '['))); + refs = new Set([...refs, ...refs0, ...nonLocalRefs2]); + + } else { + for (const child of expression.children) { + const result = this.referenceWalk(child, extension); + const childPath = result.path; + const refs0 = result.refs; + refs = new Set([...refs, ...refs0]); + if (childPath !== undefined) { + refs.add(childPath); + } + } + } + } + + return {path, refs}; } - public static parse(expression: string): Expression { - return new ExpressionEngine().parse(expression); + public static parse(expression: string, lookup?: EvaluatorLookup): Expression { + return new ExpressionParser(lookup || Expression.lookup).parse(expression); } + /** + * Lookup a ExpressionEvaluator (function) by name. + * @param functionName name of function to lookup + * @returns a ExpressionEvaluator that corresponding to the funtion name + */ + public static lookup(functionName: string): ExpressionEvaluator { + const exprEvaluator = Expression.functions.get(functionName); + if (!exprEvaluator) { + return undefined; + } + + return exprEvaluator; + }; + /** * Make an expression and validate it. * @param type Type of expression from ExpressionType diff --git a/libraries/adaptive-expressions/src/expressionEvaluator.ts b/libraries/adaptive-expressions/src/expressionEvaluator.ts index 1659cdcc0b..db1aaa1e0d 100644 --- a/libraries/adaptive-expressions/src/expressionEvaluator.ts +++ b/libraries/adaptive-expressions/src/expressionEvaluator.ts @@ -56,9 +56,8 @@ export class ExpressionEvaluator { this.type = type; this._evaluator = evaluator; this.returnType = returnType; - // tslint:disable-next-line: no-empty // eslint-disable-next-line @typescript-eslint/no-unused-vars - this._validator = validator === undefined ? ((expr: Expression): any => { }) : validator; + this._validator = validator || ((expr: Expression): any => { }); } /** @@ -71,6 +70,5 @@ export class ExpressionEvaluator { * Validate an expression. * @param expression Expression to validate. */ - // tslint:disable-next-line: informative-docs public validateExpression = (expression: Expression): void => this._validator(expression); } diff --git a/libraries/adaptive-expressions/src/expressionFunctions.ts b/libraries/adaptive-expressions/src/expressionFunctions.ts index 43d2848b6d..b46fb0ccd8 100644 --- a/libraries/adaptive-expressions/src/expressionFunctions.ts +++ b/libraries/adaptive-expressions/src/expressionFunctions.ts @@ -18,7 +18,7 @@ import { EvaluateExpressionDelegate, ExpressionEvaluator, ValidateExpressionDele import { ExpressionType } from './expressionType'; import { Extensions } from './extensions'; import { TimeZoneConverter } from './timeZoneConverter'; -import { convertCSharpDateTimeToMomentJS } from './formatConverter'; +import { convertCSharpDateTimeToMomentJS } from './datetimeFormatConverter'; import { MemoryInterface, SimpleObjectMemory, StackedMemory } from './memory'; /** @@ -54,7 +54,10 @@ export class ExpressionFunctions { */ public static readonly UnixMilliSecondToTicksConstant: number = 621355968000000000; - public static _functions: Map = ExpressionFunctions.buildFunctionLookup(); + /** + * Read only Dictionary of built in functions. + */ + public static readonly standardFunctions: ReadonlyMap = ExpressionFunctions.getStandardFunctions(); /** * Validate that expression has a certain number of children that are of any of the supported types. @@ -528,7 +531,6 @@ export class ExpressionFunctions { (args: any []): any => { const binaryArgs: any[] = [undefined, undefined]; let soFar: any = args[0]; - // tslint:disable-next-line: prefer-for-of for (let i = 1; i < args.length; i++) { binaryArgs[0] = soFar; binaryArgs[1] = args[i]; @@ -554,7 +556,6 @@ export class ExpressionFunctions { let soFar: any = args[0]; let value: any; let error: string; - // tslint:disable-next-line: prefer-for-of for (let i = 1; i < args.length; i++) { binaryArgs[0] = soFar; binaryArgs[1] = args[i]; @@ -599,7 +600,7 @@ export class ExpressionFunctions { * @param func Function to apply. */ public static multivariateNumeric(type: string, func: (arg0: any []) => any, verify?: VerifyExpression): ExpressionEvaluator { - return new ExpressionEvaluator(type, ExpressionFunctions.applySequence(func, verify !== undefined ? verify : ExpressionFunctions.verifyNumber), + return new ExpressionEvaluator(type, ExpressionFunctions.applySequence(func, verify || ExpressionFunctions.verifyNumber), ReturnType.Number, ExpressionFunctions.validateTwoOrMoreThanTwoNumbers); } /** @@ -689,32 +690,98 @@ export class ExpressionFunctions { return { value: result, error }; }, ReturnType.String, - // tslint:disable-next-line: no-void-expression (expr: Expression): void => ExpressionFunctions.validateArityAndAnyType(expr, 2, 3, ReturnType.String, ReturnType.Number)); } - private static parseTimestamp(timeStamp: string, transform?: (arg0: moment.Moment) => any): { value: any; error: string } { + /** + * Lookup a property in IDictionary, JObject or through reflection. + * @param instance Instance with property. + * @param property Property to lookup. + * @returns Value and error information if any. + */ + public static accessProperty(instance: any, property: string): { value: any; error: string } { + // NOTE: This returns null rather than an error if property is not present + if (!instance) { + return { value: undefined, error: undefined }; + } + let value: any; - const error: string = this.verifyISOTimestamp(timeStamp); - if (!error) { - const parsed: moment.Moment = moment(timeStamp).utc(); - value = transform !== undefined ? transform(parsed) : parsed; + let error: string; + // todo, Is there a better way to access value, or any case is not listed below? + if (instance instanceof Map && instance as Map!== undefined) { + const instanceMap: Map = instance as Map; + value = instanceMap.get(property); + if (value === undefined) { + const prop: string = Array.from(instanceMap.keys()).find((k: string): boolean => k.toLowerCase() === property.toLowerCase()); + if (prop !== undefined) { + value = instanceMap.get(prop); + } + } + } else { + const prop: string = Object.keys(instance).find((k: string): boolean => k.toLowerCase() === property.toLowerCase()); + if (prop !== undefined) { + value = instance[prop]; + } } return { value, error }; } /** - * Lookup a built-in function information by type. - * @param type Type to look up. + * Set a property in Map or Object. + * @param instance Instance to set. + * @param property Property to set. + * @param value Value to set. + * @returns set value. */ - public static lookup(type: string): ExpressionEvaluator { - const evaluator: ExpressionEvaluator = ExpressionFunctions._functions.get(type); - if (!evaluator) { - throw new Error(`${ type } does not have an evaluator, it's not a built-in function or a customized function`); + public static setProperty(instance: any, property: string, value: any): { value: any; error: string } { + const result: any = value; + if (instance instanceof Map) { + instance.set(property, value); + } else { + instance[property] = value; } - return evaluator; + return {value: result, error: undefined}; + } + + /** + * Lookup a property in IDictionary, JObject or through reflection. + * @param instance Instance with property. + * @param property Property to lookup. + * @returns Value and error information if any. + */ + public static accessIndex(instance: any, index: number): { value: any; error: string } { + // NOTE: This returns null rather than an error if property is not present + if (instance === null || instance === undefined) { + return { value: undefined, error: undefined }; + } + + let value: any; + let error: string; + + if (Array.isArray(instance)) { + if (index >= 0 && index < instance.length) { + value = instance[index]; + } else { + error = `${ index } is out of range for ${ instance }`; + } + } else { + error = `${ instance } is not a collection.`; + } + + return { value, error }; + } + + private static parseTimestamp(timeStamp: string, transform?: (arg0: moment.Moment) => any): { value: any; error: string } { + let value: any; + const error: string = this.verifyISOTimestamp(timeStamp); + if (!error) { + const parsed: moment.Moment = moment(timeStamp).utc(); + value = transform !== undefined ? transform(parsed) : parsed; + } + + return { value, error }; } public static timestampFormatter(formatter: string): string { @@ -780,7 +847,6 @@ export class ExpressionFunctions { private static newGuid(): string { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c: any): string => { const r: number = Math.random() * 16 | 0; - // tslint:disable-next-line: no-bitwise const v: number = c === 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); @@ -951,9 +1017,9 @@ export class ExpressionFunctions { ({ value: idxValue, error } = index.tryEvaluate(state)); if (!error) { if (Number.isInteger(idxValue)) { - ({ value, error } = Extensions.accessIndex(inst, Number(idxValue))); + ({ value, error } = ExpressionFunctions.accessIndex(inst, Number(idxValue))); } else if (typeof idxValue === 'string') { - ({ value, error } = Extensions.accessProperty(inst, idxValue.toString())); + ({ value, error } = ExpressionFunctions.accessProperty(inst, idxValue.toString())); } else { error = `Could not coerce ${ index } to an int or string.`; } @@ -963,24 +1029,6 @@ export class ExpressionFunctions { } } - private static canBeModified(value: any, property: string, expected?: number): boolean { - let modifiable = false; - if (expected !== undefined) { - // Modifiable list - modifiable = Array.isArray(value); - } else { - // Modifiable object - modifiable = value instanceof Map; - if (!modifiable) { - if (typeof value === 'object') { - modifiable = value.hasOwnProperty(property); - } - } - } - - return modifiable; - } - private static setPathToValue(expression: Expression, state: MemoryInterface): { value: any; error: string } { let path: string; let left: Expression; @@ -1016,13 +1064,12 @@ export class ExpressionFunctions { } if (!error) { - // 2nd parameter has been rewrite to $local.item const iteratorName = (expression.children[1].children[0] as Constant).value as string; let arr = []; if (Array.isArray(instance)) { arr = instance; } else if (typeof instance === 'object') { - Object.keys(instance).forEach(u => arr.push({key: u, value: instance[u]})); + Object.keys(instance).forEach((u): number => arr.push({key: u, value: instance[u]})); } else { error = `${ expression.children[0] } is not a collection or structure object to run foreach`; } @@ -1064,7 +1111,7 @@ export class ExpressionFunctions { arr = instance; isInstanceArray = true; } else if (typeof instance === 'object') { - Object.keys(instance).forEach(u => arr.push({key: u, value: instance[u]})); + Object.keys(instance).forEach((u): number => arr.push({key: u, value: instance[u]})); } else { error = `${ expression.children[0] } is not a collection or structure object to run foreach`; } @@ -1126,8 +1173,7 @@ export class ExpressionFunctions { const second: Expression = expression.children[1]; if (second.returnType === ReturnType.String && second.type === ExpressionType.Constant) { - // tslint:disable-next-line: restrict-plus-operands - CommonRegex.CreateRegex((second as Constant).value + ''); + CommonRegex.CreateRegex((second as Constant).value.toString()); } } @@ -1399,7 +1445,7 @@ export class ExpressionFunctions { ({value: propertyName, error} = expression.children[1].tryEvaluate(state)); if (!error) { - propertyName = propertyName === undefined ? '' : propertyName; + propertyName = propertyName || ''; } if (isDescending) { result = lodash.sortBy(arr, propertyName).reverse(); @@ -1449,7 +1495,6 @@ export class ExpressionFunctions { let result = ''; for (const element of stringToConvert) { const binaryElement: string = element.charCodeAt(0).toString(2); - // tslint:disable-next-line: prefer-array-literal result += new Array(9 - binaryElement.length).join('0').concat(binaryElement); } @@ -1794,9 +1839,8 @@ export class ExpressionFunctions { } private static flatten(arr: any[], dept: number): any[]{ - dept = typeof dept === 'undefined' ? 1 : dept; - if (typeof dept !== 'number') { - return; + if (!ExpressionFunctions.isNumber(dept) || dept < 1) { + dept = 1; } let res = JSON.parse(JSON.stringify(arr)); @@ -1812,9 +1856,7 @@ export class ExpressionFunctions { return res; } - // tslint:disable-next-line: max-func-body-length - private static buildFunctionLookup(): Map { - // tslint:disable-next-line: no-unnecessary-local-variable + private static getStandardFunctions(): ReadonlyMap { const functions: ExpressionEvaluator[] = [ //Math new ExpressionEvaluator(ExpressionType.Element, ExpressionFunctions.extractElement, ReturnType.Object, this.validateBinary), @@ -1969,7 +2011,6 @@ export class ExpressionFunctions { error = 'Second paramter must be more than zero'; } - // tslint:disable-next-line: prefer-array-literal const result: number[] = [...Array(args[1]).keys()].map((u: number): number => u + Number(args[0])); return { value: result, error }; @@ -2042,7 +2083,7 @@ export class ExpressionFunctions { new ExpressionEvaluator( ExpressionType.Flatten, ExpressionFunctions.apply( - args => { + (args: any []): any[] => { let array = args[0]; let depth = args.length > 1 ? args[1] : 100; return ExpressionFunctions.flatten(array, depth); @@ -2052,7 +2093,7 @@ export class ExpressionFunctions { ), new ExpressionEvaluator( ExpressionType.Unique, - ExpressionFunctions.apply(args => [... new Set(args[0])]), + ExpressionFunctions.apply((args: any []): any[] => [... new Set(args[0])]), ReturnType.Object, (expression: Expression): void => ExpressionFunctions.validateOrder(expression, [], ReturnType.Object) ), @@ -2095,7 +2136,7 @@ export class ExpressionFunctions { found = (args[0] as Map).get(args[1]) !== undefined; } else if (typeof args[1] === 'string') { let value: any; - ({ value, error } = Extensions.accessProperty(args[0], args[1])); + ({ value, error } = ExpressionFunctions.accessProperty(args[0], args[1])); found = !error && value !== undefined; } } @@ -2183,7 +2224,7 @@ export class ExpressionFunctions { (expression: Expression): void => ExpressionFunctions.validateArityAndAnyType(expression, 3, 3, ReturnType.String)), new ExpressionEvaluator( ExpressionType.Split, - ExpressionFunctions.apply((args: any []): string[] => ExpressionFunctions.parseStringOrNull(args[0]).split(ExpressionFunctions.parseStringOrNull(args[1]? args[1]: '')), ExpressionFunctions.verifyStringOrNull), + ExpressionFunctions.apply((args: any []): string[] => ExpressionFunctions.parseStringOrNull(args[0]).split(ExpressionFunctions.parseStringOrNull(args[1] || '')), ExpressionFunctions.verifyStringOrNull), ReturnType.Object, (expression: Expression): void => ExpressionFunctions.validateArityAndAnyType(expression, 1, 2, ReturnType.String)), new ExpressionEvaluator( @@ -2831,7 +2872,6 @@ export class ExpressionFunctions { error = `Min value ${ args[0] } cannot be greater than max value ${ args[1] }.`; } - // tslint:disable-next-line: insecure-random const value: any = Math.floor(Math.random() * (Number(args[1]) - Number(args[0])) + Number(args[0])); return { value, error }; @@ -2840,11 +2880,6 @@ export class ExpressionFunctions { ReturnType.Number, ExpressionFunctions.validateBinaryNumber), new ExpressionEvaluator(ExpressionType.CreateArray, ExpressionFunctions.apply((args: any []): any[] => Array.from(args)), ReturnType.Object), - new ExpressionEvaluator( - ExpressionType.Array, - ExpressionFunctions.apply((args: any []): any[] => [args[0]], ExpressionFunctions.verifyString), - ReturnType.Object, - ExpressionFunctions.validateUnary), new ExpressionEvaluator( ExpressionType.Binary, ExpressionFunctions.apply((args: any []): string => this.toBinary(args[0]), ExpressionFunctions.verifyString), @@ -2863,7 +2898,6 @@ export class ExpressionFunctions { ExpressionFunctions.validateUnary), new ExpressionEvaluator( ExpressionType.DataUriToString, - // tslint:disable-next-line: restrict-plus-operands ExpressionFunctions.apply((args: Readonly): string => Buffer.from(args[0].slice(args[0].indexOf(',') + 1), 'base64').toString(), ExpressionFunctions.verifyString), ReturnType.String, ExpressionFunctions.validateUnary), @@ -2902,7 +2936,7 @@ export class ExpressionFunctions { } if (Array.isArray(args[0]) && args[0].length > 0) { - first = Extensions.accessIndex(args[0], 0).value; + first = ExpressionFunctions.accessIndex(args[0], 0).value; } return first; @@ -2919,7 +2953,7 @@ export class ExpressionFunctions { } if (Array.isArray(args[0]) && args[0].length > 0) { - last = Extensions.accessIndex(args[0], args[0].length - 1).value; + last = ExpressionFunctions.accessIndex(args[0], args[0].length - 1).value; } return last; @@ -2933,12 +2967,18 @@ export class ExpressionFunctions { (expression: Expression): void => ExpressionFunctions.validateOrder(expression, undefined, ReturnType.String)), new ExpressionEvaluator( ExpressionType.AddProperty, - ExpressionFunctions.apply( + ExpressionFunctions.applyWithError( (args: any []): any => { + let error: string; const temp: any = args[0]; - temp[String(args[1])] = args[2]; + const prop = String(args[1]); + if (prop in temp) { + error = `${ prop } already exists`; + } else { + temp[String(args[1])] = args[2]; + } - return temp; + return {value: temp, error}; }), ReturnType.Object, (expression: Expression): void => ExpressionFunctions.validateOrder(expression, undefined, ReturnType.Object, ReturnType.String, ReturnType.Object)), @@ -3004,14 +3044,44 @@ export class ExpressionFunctions { value = false; error = 'regular expression is empty.'; } else { - const regex: RegExp = CommonRegex.CreateRegex(args[1]); - value = regex.test(args[0]); + const regex: RegExp = CommonRegex.CreateRegex(args[1].toString()); + value = regex.test(args[0].toString()); } return {value, error}; - }), + }, ExpressionFunctions.verifyStringOrNull), ReturnType.Boolean, - ExpressionFunctions.validateIsMatch) + ExpressionFunctions.validateIsMatch), + + // Type Checking Functions + new ExpressionEvaluator(ExpressionType.isString, ExpressionFunctions.apply( + (args: any[]): boolean => typeof args[0] === 'string'), + ReturnType.Boolean, + ExpressionFunctions.validateUnary), + new ExpressionEvaluator(ExpressionType.isInteger, ExpressionFunctions.apply( + (args: any[]): boolean => this.isNumber(args[0]) && Number.isInteger(args[0])), + ReturnType.Boolean, + ExpressionFunctions.validateUnary), + new ExpressionEvaluator(ExpressionType.isFloat, ExpressionFunctions.apply( + (args: any[]): boolean => this.isNumber(args[0]) && !Number.isInteger(args[0])), + ReturnType.Boolean, + ExpressionFunctions.validateUnary), + new ExpressionEvaluator(ExpressionType.isArray, ExpressionFunctions.apply( + (args: any[]): boolean => Array.isArray(args[0])), + ReturnType.Boolean, + ExpressionFunctions.validateUnary), + new ExpressionEvaluator(ExpressionType.isObject, ExpressionFunctions.apply( + (args: any[]): boolean => typeof args[0] === 'object'), + ReturnType.Boolean, + ExpressionFunctions.validateUnary), + new ExpressionEvaluator(ExpressionType.isBoolean, ExpressionFunctions.apply( + (args: any[]): boolean => typeof args[0] === 'boolean'), + ReturnType.Boolean, + ExpressionFunctions.validateUnary), + new ExpressionEvaluator(ExpressionType.isDateTime, ExpressionFunctions.apply( + (args: any[]): boolean => typeof args[0] === 'string' && this.verifyISOTimestamp(args[0]) === undefined), + ReturnType.Boolean, + ExpressionFunctions.validateUnary) ]; const lookup: Map = new Map(); @@ -3038,6 +3108,6 @@ export class ExpressionFunctions { lookup.set('or', lookup.get(ExpressionType.Or)); lookup.set('&', lookup.get(ExpressionType.Concat)); - return lookup; + return lookup as ReadonlyMap; } } diff --git a/libraries/adaptive-expressions/src/expressionParser.ts b/libraries/adaptive-expressions/src/expressionParserInterface.ts similarity index 100% rename from libraries/adaptive-expressions/src/expressionParser.ts rename to libraries/adaptive-expressions/src/expressionParserInterface.ts diff --git a/libraries/adaptive-expressions/src/expressionType.ts b/libraries/adaptive-expressions/src/expressionType.ts index ccaedab558..b2433cdcc2 100644 --- a/libraries/adaptive-expressions/src/expressionType.ts +++ b/libraries/adaptive-expressions/src/expressionType.ts @@ -90,7 +90,6 @@ export class ExpressionType { public static readonly Int: string = 'int'; public static readonly String: string = 'string'; public static readonly Bool: string = 'bool'; - public static readonly Array: string = 'array'; public static readonly Binary: string = 'binary'; public static readonly DataUri: string = 'dataUri'; public static readonly DataUriToBinary: string = 'dataUriToBinary'; @@ -100,8 +99,6 @@ export class ExpressionType { public static readonly Base64ToBinary: string = 'base64ToBinary'; public static readonly Base64ToString: string = 'base64ToString'; public static readonly UriComponent: string = 'uriComponent'; - // TODO - // xml // Memory public static readonly Accessor: string = 'Accessor'; @@ -144,7 +141,7 @@ export class ExpressionType { // TODO // xPath - // jPath + // xml // URI parsing functions public static readonly UriHost: string = 'uriHost'; @@ -156,4 +153,13 @@ export class ExpressionType { // Regar expression public static readonly IsMatch: string = 'isMatch'; + + //Type Checking + public static readonly isString: string = 'isString'; + public static readonly isInteger: string = 'isInteger'; + public static readonly isArray: string = 'isArray'; + public static readonly isObject: string = 'isObject'; + public static readonly isFloat: string = 'isFloat'; + public static readonly isDateTime: string = 'isDateTime'; + public static readonly isBoolean: string = 'isBoolean'; } diff --git a/libraries/adaptive-expressions/src/extensions.ts b/libraries/adaptive-expressions/src/extensions.ts index f9cd52b8f4..f8683a0523 100644 --- a/libraries/adaptive-expressions/src/extensions.ts +++ b/libraries/adaptive-expressions/src/extensions.ts @@ -5,30 +5,11 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { Constant } from './constant'; -import { Expression, ReturnType } from './expression'; -import { ExpressionType } from './expressionType'; /** * Some util and extension functions */ export class Extensions { - - /** - * Return the static reference paths to memory. - * Return all static paths to memory. If there is a computed element index, then the path is terminated there, - * but you might get other paths from the computed part as well. - * @param expression Expression to get references from. - * @returns List of the static reference paths. - */ - public static references(expression: Expression): string[] { - const {path, refs} = this.referenceWalk(expression); - if (path !== undefined) { - refs.add(path); - } - return Array.from(refs); - } - /** * Patch method * TODO: is there any better solution? @@ -46,179 +27,4 @@ export class Extensions { return 'getValue' in obj && 'setValue' in obj && 'version' in obj && typeof obj.getValue === 'function' && typeof obj.setValue === 'function' && typeof obj.version === 'function'; } - - /** - * Walking function for identifying static memory references in an expression. - * @param expression Expression to analyze. - * @param references Tracking for references found. - * @param extension If present, called to override lookup for things like template expansion. - * @returns Accessor path of expression. - */ - public static referenceWalk(expression: Expression, - extension?: (arg0: Expression) => boolean): {path:string; refs:Set} { - let path: string; - let refs = new Set(); - if (extension === undefined || !extension(expression)) { - const children: Expression[] = expression.children; - if (expression.type === ExpressionType.Accessor) { - const prop: string = (children[0] as Constant).value as string; - - if (children.length === 1) { - path = prop; - } - - if (children.length === 2) { - ({path, refs} = Extensions.referenceWalk(children[1], extension)); - if (path !== undefined) { - path = path.concat('.', prop); - } - // if path is null we still keep it null, won't append prop - // because for example, first(items).x should not return x as refs - } - } else if (expression.type === ExpressionType.Element) { - ({path, refs} = Extensions.referenceWalk(children[0], extension)); - if (path !== undefined) { - if (children[1] instanceof Constant) { - const cnst: Constant = children[1] as Constant; - if (cnst.returnType === ReturnType.String) { - path += `.${ cnst.value }`; - } else { - path += `[${ cnst.value }]`; - } - } else { - refs.add(path); - } - } - const result = Extensions.referenceWalk(children[1], extension); - const idxPath = result.path; - const refs1 = result.refs; - refs = new Set([...refs, ...refs1]); - if (idxPath !== undefined) { - refs.add(idxPath); - } - } else if (expression.type === ExpressionType.Foreach || - expression.type === ExpressionType.Where || - expression.type === ExpressionType.Select ) { - let result = Extensions.referenceWalk(children[0], extension); - const child0Path = result.path; - const refs0 = result.refs; - if (child0Path !== undefined) { - refs0.add(child0Path); - } - - result = Extensions.referenceWalk(children[2], extension); - const child2Path = result.path; - const refs2 = result.refs; - if (child2Path !== undefined) { - refs2.add(child2Path); - } - - const iteratorName = (children[1].children[0] as Constant).value as string; - var nonLocalRefs2 = Array.from(refs2).filter(x => !(x === iteratorName || x.startsWith(iteratorName + '.') || x.startsWith(iteratorName + '['))); - refs = new Set([...refs, ...refs0, ...nonLocalRefs2]); - - } else { - for (const child of expression.children) { - const result = Extensions.referenceWalk(child, extension); - const childPath = result.path; - const refs0 = result.refs; - refs = new Set([...refs, ...refs0]) - if (childPath !== undefined) { - refs.add(childPath); - } - } - } - } - - return {path, refs} - } - - /** - * Lookup a property in IDictionary, JObject or through reflection. - * @param instance Instance with property. - * @param property Property to lookup. - * @returns Value and error information if any. - */ - public static accessProperty(instance: any, property: string): { value: any; error: string } { - // NOTE: This returns null rather than an error if property is not present - if (!instance) { - return { value: undefined, error: undefined }; - } - - let value: any; - // tslint:disable-next-line: prefer-const - let error: string; - // todo, Is there a better way to access value, or any case is not listed below? - if (instance instanceof Map && instance as Map!== undefined) { - const instanceMap: Map = instance as Map; - value = instanceMap.get(property); - if (value === undefined) { - const prop: string = Array.from(instanceMap.keys()).find((k: string): boolean => k.toLowerCase() === property.toLowerCase()); - if (prop !== undefined) { - value = instanceMap.get(prop); - } - } - } else { - const prop: string = Object.keys(instance).find((k: string): boolean => k.toLowerCase() === property.toLowerCase()); - if (prop !== undefined) { - value = instance[prop]; - } - } - - return { value, error }; - } - - /** - * Set a property in Map or Object. - * @param instance Instance to set. - * @param property Property to set. - * @param value Value to set. - * @returns set value. - */ - public static setProperty(instance: any, property: string, value: any): { value: any; error: string } { - const result: any = value; - if (instance instanceof Map) { - instance.set(property, value); - } else { - instance[property] = value; - } - - return {value: result, error: undefined}; - } - - /** - * Lookup a property in IDictionary, JObject or through reflection. - * @param instance Instance with property. - * @param property Property to lookup. - * @returns Value and error information if any. - */ - public static accessIndex(instance: any, index: number): { value: any; error: string } { - // NOTE: This returns null rather than an error if property is not present - if (instance === null || instance === undefined) { - return { value: undefined, error: undefined }; - } - - let value: any; - let error: string; - - let count = -1; - if (Array.isArray(instance)) { - count = instance.length; - } else if (instance instanceof Map) { - count = (instance as Map).size; - } - const indexer: string[] = Object.keys(instance); - if (count !== -1 && indexer.length > 0) { - if (index >= 0 && count > index) { - const idyn: any = instance; - value = idyn[index]; - } else { - error = `${ index } is out of range for ${ instance }`; - } - } else { - error = `${ instance } is not a collection.`; - } - - return { value, error }; - } } diff --git a/libraries/adaptive-expressions/src/generated/CommonRegexLexer.ts b/libraries/adaptive-expressions/src/generated/CommonRegexLexer.ts index c297f84397..8a2fd88620 100644 --- a/libraries/adaptive-expressions/src/generated/CommonRegexLexer.ts +++ b/libraries/adaptive-expressions/src/generated/CommonRegexLexer.ts @@ -23,120 +23,122 @@ import * as Utils from "antlr4ts/misc/Utils"; export class CommonRegexLexer extends Lexer { - public static readonly BellChar = 1; - public static readonly ControlChar = 2; - public static readonly EscapeChar = 3; - public static readonly FormFeed = 4; - public static readonly NewLine = 5; - public static readonly CarriageReturn = 6; - public static readonly Tab = 7; - public static readonly Backslash = 8; - public static readonly HexChar = 9; - public static readonly Dot = 10; - public static readonly DecimalDigit = 11; - public static readonly NotDecimalDigit = 12; - public static readonly CharWithProperty = 13; - public static readonly CharWithoutProperty = 14; - public static readonly WhiteSpace = 15; - public static readonly NotWhiteSpace = 16; - public static readonly WordChar = 17; - public static readonly NotWordChar = 18; - public static readonly CharacterClassStart = 19; - public static readonly CharacterClassEnd = 20; - public static readonly Caret = 21; - public static readonly Hyphen = 22; - public static readonly QuestionMark = 23; - public static readonly Plus = 24; - public static readonly Star = 25; - public static readonly OpenBrace = 26; - public static readonly CloseBrace = 27; - public static readonly Comma = 28; - public static readonly EndOfSubject = 29; - public static readonly Pipe = 30; - public static readonly OpenParen = 31; - public static readonly CloseParen = 32; - public static readonly LessThan = 33; - public static readonly GreaterThan = 34; - public static readonly SingleQuote = 35; - public static readonly Underscore = 36; - public static readonly Colon = 37; - public static readonly Hash = 38; - public static readonly Equals = 39; - public static readonly Exclamation = 40; - public static readonly Ampersand = 41; - public static readonly ALC = 42; - public static readonly BLC = 43; - public static readonly CLC = 44; - public static readonly DLC = 45; - public static readonly ELC = 46; - public static readonly FLC = 47; - public static readonly GLC = 48; - public static readonly HLC = 49; - public static readonly ILC = 50; - public static readonly JLC = 51; - public static readonly KLC = 52; - public static readonly LLC = 53; - public static readonly MLC = 54; - public static readonly NLC = 55; - public static readonly OLC = 56; - public static readonly PLC = 57; - public static readonly QLC = 58; - public static readonly RLC = 59; - public static readonly SLC = 60; - public static readonly TLC = 61; - public static readonly ULC = 62; - public static readonly VLC = 63; - public static readonly WLC = 64; - public static readonly XLC = 65; - public static readonly YLC = 66; - public static readonly ZLC = 67; - public static readonly AUC = 68; - public static readonly BUC = 69; - public static readonly CUC = 70; - public static readonly DUC = 71; - public static readonly EUC = 72; - public static readonly FUC = 73; - public static readonly GUC = 74; - public static readonly HUC = 75; - public static readonly IUC = 76; - public static readonly JUC = 77; - public static readonly KUC = 78; - public static readonly LUC = 79; - public static readonly MUC = 80; - public static readonly NUC = 81; - public static readonly OUC = 82; - public static readonly PUC = 83; - public static readonly QUC = 84; - public static readonly RUC = 85; - public static readonly SUC = 86; - public static readonly TUC = 87; - public static readonly UUC = 88; - public static readonly VUC = 89; - public static readonly WUC = 90; - public static readonly XUC = 91; - public static readonly YUC = 92; - public static readonly ZUC = 93; - public static readonly D1 = 94; - public static readonly D2 = 95; - public static readonly D3 = 96; - public static readonly D4 = 97; - public static readonly D5 = 98; - public static readonly D6 = 99; - public static readonly D7 = 100; - public static readonly D8 = 101; - public static readonly D9 = 102; - public static readonly D0 = 103; - public static readonly OtherChar = 104; + public static readonly Quoted = 1; + public static readonly BlockQuoted = 2; + public static readonly BellChar = 3; + public static readonly ControlChar = 4; + public static readonly EscapeChar = 5; + public static readonly FormFeed = 6; + public static readonly NewLine = 7; + public static readonly CarriageReturn = 8; + public static readonly Tab = 9; + public static readonly Backslash = 10; + public static readonly HexChar = 11; + public static readonly Dot = 12; + public static readonly DecimalDigit = 13; + public static readonly NotDecimalDigit = 14; + public static readonly CharWithProperty = 15; + public static readonly CharWithoutProperty = 16; + public static readonly WhiteSpace = 17; + public static readonly NotWhiteSpace = 18; + public static readonly WordChar = 19; + public static readonly NotWordChar = 20; + public static readonly CharacterClassStart = 21; + public static readonly CharacterClassEnd = 22; + public static readonly Caret = 23; + public static readonly Hyphen = 24; + public static readonly QuestionMark = 25; + public static readonly Plus = 26; + public static readonly Star = 27; + public static readonly OpenBrace = 28; + public static readonly CloseBrace = 29; + public static readonly Comma = 30; + public static readonly EndOfSubject = 31; + public static readonly Pipe = 32; + public static readonly OpenParen = 33; + public static readonly CloseParen = 34; + public static readonly LessThan = 35; + public static readonly GreaterThan = 36; + public static readonly SingleQuote = 37; + public static readonly Underscore = 38; + public static readonly Colon = 39; + public static readonly Hash = 40; + public static readonly Equals = 41; + public static readonly Exclamation = 42; + public static readonly Ampersand = 43; + public static readonly ALC = 44; + public static readonly BLC = 45; + public static readonly CLC = 46; + public static readonly DLC = 47; + public static readonly ELC = 48; + public static readonly FLC = 49; + public static readonly GLC = 50; + public static readonly HLC = 51; + public static readonly ILC = 52; + public static readonly JLC = 53; + public static readonly KLC = 54; + public static readonly LLC = 55; + public static readonly MLC = 56; + public static readonly NLC = 57; + public static readonly OLC = 58; + public static readonly PLC = 59; + public static readonly QLC = 60; + public static readonly RLC = 61; + public static readonly SLC = 62; + public static readonly TLC = 63; + public static readonly ULC = 64; + public static readonly VLC = 65; + public static readonly WLC = 66; + public static readonly XLC = 67; + public static readonly YLC = 68; + public static readonly ZLC = 69; + public static readonly AUC = 70; + public static readonly BUC = 71; + public static readonly CUC = 72; + public static readonly DUC = 73; + public static readonly EUC = 74; + public static readonly FUC = 75; + public static readonly GUC = 76; + public static readonly HUC = 77; + public static readonly IUC = 78; + public static readonly JUC = 79; + public static readonly KUC = 80; + public static readonly LUC = 81; + public static readonly MUC = 82; + public static readonly NUC = 83; + public static readonly OUC = 84; + public static readonly PUC = 85; + public static readonly QUC = 86; + public static readonly RUC = 87; + public static readonly SUC = 88; + public static readonly TUC = 89; + public static readonly UUC = 90; + public static readonly VUC = 91; + public static readonly WUC = 92; + public static readonly XUC = 93; + public static readonly YUC = 94; + public static readonly ZUC = 95; + public static readonly D1 = 96; + public static readonly D2 = 97; + public static readonly D3 = 98; + public static readonly D4 = 99; + public static readonly D5 = 100; + public static readonly D6 = 101; + public static readonly D7 = 102; + public static readonly D8 = 103; + public static readonly D9 = 104; + public static readonly D0 = 105; + public static readonly OtherChar = 106; // tslint:disable:no-trailing-whitespace public static readonly modeNames: string[] = [ "DEFAULT_MODE", ]; public static readonly ruleNames: string[] = [ - "BellChar", "ControlChar", "EscapeChar", "FormFeed", "NewLine", "CarriageReturn", - "Tab", "Backslash", "HexChar", "Dot", "DecimalDigit", "NotDecimalDigit", - "CharWithProperty", "CharWithoutProperty", "WhiteSpace", "NotWhiteSpace", - "WordChar", "NotWordChar", "CharacterClassStart", "CharacterClassEnd", + "Quoted", "BlockQuoted", "BellChar", "ControlChar", "EscapeChar", "FormFeed", + "NewLine", "CarriageReturn", "Tab", "Backslash", "HexChar", "Dot", "DecimalDigit", + "NotDecimalDigit", "CharWithProperty", "CharWithoutProperty", "WhiteSpace", + "NotWhiteSpace", "WordChar", "NotWordChar", "CharacterClassStart", "CharacterClassEnd", "Caret", "Hyphen", "QuestionMark", "Plus", "Star", "OpenBrace", "CloseBrace", "Comma", "EndOfSubject", "Pipe", "OpenParen", "CloseParen", "LessThan", "GreaterThan", "SingleQuote", "Underscore", "Colon", "Hash", "Equals", @@ -151,33 +153,34 @@ export class CommonRegexLexer extends Lexer { ]; private static readonly _LITERAL_NAMES: Array = [ - undefined, "'\\a'", "'\\c'", "'\\e'", "'\\f'", "'\\n'", "'\\r'", "'\\t'", - "'\\'", undefined, "'.'", "'\\d'", "'\\D'", undefined, undefined, "'\\s'", - "'\\S'", "'\\w'", "'\\W'", "'['", "']'", "'^'", "'-'", "'?'", "'+'", "'*'", - "'{'", "'}'", "','", "'$'", "'|'", "'('", "')'", "'<'", "'>'", "'''", - "'_'", "':'", "'#'", "'='", "'!'", "'&'", "'a'", "'b'", "'c'", "'d'", - "'e'", "'f'", "'g'", "'h'", "'i'", "'j'", "'k'", "'l'", "'m'", "'n'", - "'o'", "'p'", "'q'", "'r'", "'s'", "'t'", "'u'", "'v'", "'w'", "'x'", - "'y'", "'z'", "'A'", "'B'", "'C'", "'D'", "'E'", "'F'", "'G'", "'H'", - "'I'", "'J'", "'K'", "'L'", "'M'", "'N'", "'O'", "'P'", "'Q'", "'R'", - "'S'", "'T'", "'U'", "'V'", "'W'", "'X'", "'Y'", "'Z'", "'1'", "'2'", - "'3'", "'4'", "'5'", "'6'", "'7'", "'8'", "'9'", "'0'", + undefined, undefined, undefined, "'\\a'", "'\\c'", "'\\e'", "'\\f'", "'\\n'", + "'\\r'", "'\\t'", "'\\'", undefined, "'.'", "'\\d'", "'\\D'", undefined, + undefined, "'\\s'", "'\\S'", "'\\w'", "'\\W'", "'['", "']'", "'^'", "'-'", + "'?'", "'+'", "'*'", "'{'", "'}'", "','", "'$'", "'|'", "'('", "')'", + "'<'", "'>'", "'''", "'_'", "':'", "'#'", "'='", "'!'", "'&'", "'a'", + "'b'", "'c'", "'d'", "'e'", "'f'", "'g'", "'h'", "'i'", "'j'", "'k'", + "'l'", "'m'", "'n'", "'o'", "'p'", "'q'", "'r'", "'s'", "'t'", "'u'", + "'v'", "'w'", "'x'", "'y'", "'z'", "'A'", "'B'", "'C'", "'D'", "'E'", + "'F'", "'G'", "'H'", "'I'", "'J'", "'K'", "'L'", "'M'", "'N'", "'O'", + "'P'", "'Q'", "'R'", "'S'", "'T'", "'U'", "'V'", "'W'", "'X'", "'Y'", + "'Z'", "'1'", "'2'", "'3'", "'4'", "'5'", "'6'", "'7'", "'8'", "'9'", + "'0'", ]; private static readonly _SYMBOLIC_NAMES: Array = [ - undefined, "BellChar", "ControlChar", "EscapeChar", "FormFeed", "NewLine", - "CarriageReturn", "Tab", "Backslash", "HexChar", "Dot", "DecimalDigit", - "NotDecimalDigit", "CharWithProperty", "CharWithoutProperty", "WhiteSpace", - "NotWhiteSpace", "WordChar", "NotWordChar", "CharacterClassStart", "CharacterClassEnd", - "Caret", "Hyphen", "QuestionMark", "Plus", "Star", "OpenBrace", "CloseBrace", - "Comma", "EndOfSubject", "Pipe", "OpenParen", "CloseParen", "LessThan", - "GreaterThan", "SingleQuote", "Underscore", "Colon", "Hash", "Equals", - "Exclamation", "Ampersand", "ALC", "BLC", "CLC", "DLC", "ELC", "FLC", - "GLC", "HLC", "ILC", "JLC", "KLC", "LLC", "MLC", "NLC", "OLC", "PLC", - "QLC", "RLC", "SLC", "TLC", "ULC", "VLC", "WLC", "XLC", "YLC", "ZLC", - "AUC", "BUC", "CUC", "DUC", "EUC", "FUC", "GUC", "HUC", "IUC", "JUC", - "KUC", "LUC", "MUC", "NUC", "OUC", "PUC", "QUC", "RUC", "SUC", "TUC", - "UUC", "VUC", "WUC", "XUC", "YUC", "ZUC", "D1", "D2", "D3", "D4", "D5", - "D6", "D7", "D8", "D9", "D0", "OtherChar", + undefined, "Quoted", "BlockQuoted", "BellChar", "ControlChar", "EscapeChar", + "FormFeed", "NewLine", "CarriageReturn", "Tab", "Backslash", "HexChar", + "Dot", "DecimalDigit", "NotDecimalDigit", "CharWithProperty", "CharWithoutProperty", + "WhiteSpace", "NotWhiteSpace", "WordChar", "NotWordChar", "CharacterClassStart", + "CharacterClassEnd", "Caret", "Hyphen", "QuestionMark", "Plus", "Star", + "OpenBrace", "CloseBrace", "Comma", "EndOfSubject", "Pipe", "OpenParen", + "CloseParen", "LessThan", "GreaterThan", "SingleQuote", "Underscore", + "Colon", "Hash", "Equals", "Exclamation", "Ampersand", "ALC", "BLC", "CLC", + "DLC", "ELC", "FLC", "GLC", "HLC", "ILC", "JLC", "KLC", "LLC", "MLC", + "NLC", "OLC", "PLC", "QLC", "RLC", "SLC", "TLC", "ULC", "VLC", "WLC", + "XLC", "YLC", "ZLC", "AUC", "BUC", "CUC", "DUC", "EUC", "FUC", "GUC", + "HUC", "IUC", "JUC", "KUC", "LUC", "MUC", "NUC", "OUC", "PUC", "QUC", + "RUC", "SUC", "TUC", "UUC", "VUC", "WUC", "XUC", "YUC", "ZUC", "D1", "D2", + "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D0", "OtherChar", ]; public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(CommonRegexLexer._LITERAL_NAMES, CommonRegexLexer._SYMBOLIC_NAMES, []); @@ -207,7 +210,7 @@ export class CommonRegexLexer extends Lexer { public get modeNames(): string[] { return CommonRegexLexer.modeNames; } public static readonly _serializedATN: string = - "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x02j\u01E9\b\x01" + + "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x02l\u01FC\b\x01" + "\x04\x02\t\x02\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06\t\x06" + "\x04\x07\t\x07\x04\b\t\b\x04\t\t\t\x04\n\t\n\x04\v\t\v\x04\f\t\f\x04\r" + "\t\r\x04\x0E\t\x0E\x04\x0F\t\x0F\x04\x10\t\x10\x04\x11\t\x11\x04\x12\t" + @@ -222,210 +225,220 @@ export class CommonRegexLexer extends Lexer { "O\tO\x04P\tP\x04Q\tQ\x04R\tR\x04S\tS\x04T\tT\x04U\tU\x04V\tV\x04W\tW\x04" + "X\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\x04g\tg\x04h\th\x04" + - "i\ti\x04j\tj\x04k\tk\x04l\tl\x04m\tm\x04n\tn\x04o\to\x03\x02\x03\x02\x03" + - "\x02\x03\x03\x03\x03\x03\x03\x03\x04\x03\x04\x03\x04\x03\x05\x03\x05\x03" + - "\x05\x03\x06\x03\x06\x03\x06\x03\x07\x03\x07\x03\x07\x03\b\x03\b\x03\b" + - "\x03\t\x03\t\x03\n\x03\n\x03\n\x03\n\x03\n\x03\n\x03\n\x03\n\x03\n\x03" + - "\n\x06\n\u0101\n\n\r\n\x0E\n\u0102\x03\n\x03\n\x05\n\u0107\n\n\x03\v\x03" + - "\v\x03\f\x03\f\x03\f\x03\r\x03\r\x03\r\x03\x0E\x03\x0E\x03\x0E\x03\x0E" + - "\x03\x0E\x03\x0E\x03\x0E\x03\x0F\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\x12\x03\x12" + - "\x03\x12\x03\x13\x03\x13\x03\x13\x03\x14\x03\x14\x03\x15\x03\x15\x03\x16" + - "\x03\x16\x03\x17\x03\x17\x03\x18\x03\x18\x03\x19\x03\x19\x03\x1A\x03\x1A" + - "\x03\x1B\x03\x1B\x03\x1C\x03\x1C\x03\x1D\x03\x1D\x03\x1E\x03\x1E\x03\x1F" + - "\x03\x1F\x03 \x03 \x03!\x03!\x03\"\x03\"\x03#\x03#\x03$\x03$\x03%\x03" + - "%\x03&\x03&\x03\'\x03\'\x03(\x03(\x03)\x03)\x03*\x03*\x03+\x03+\x03,\x03" + - ",\x03-\x03-\x03.\x03.\x03/\x03/\x030\x030\x031\x031\x032\x032\x033\x03" + - "3\x034\x034\x035\x035\x036\x036\x037\x037\x038\x038\x039\x039\x03:\x03" + - ":\x03;\x03;\x03<\x03<\x03=\x03=\x03>\x03>\x03?\x03?\x03@\x03@\x03A\x03" + - "A\x03B\x03B\x03C\x03C\x03D\x03D\x03E\x03E\x03F\x03F\x03G\x03G\x03H\x03" + - "H\x03I\x03I\x03J\x03J\x03K\x03K\x03L\x03L\x03M\x03M\x03N\x03N\x03O\x03" + - "O\x03P\x03P\x03Q\x03Q\x03R\x03R\x03S\x03S\x03T\x03T\x03U\x03U\x03V\x03" + - "V\x03W\x03W\x03X\x03X\x03Y\x03Y\x03Z\x03Z\x03[\x03[\x03\\\x03\\\x03]\x03" + - "]\x03^\x03^\x03_\x03_\x03`\x03`\x03a\x03a\x03b\x03b\x03c\x03c\x03d\x03" + - "d\x03e\x03e\x03f\x03f\x03g\x03g\x03h\x03h\x03i\x03i\x03j\x03j\x06j\u01D9" + - "\nj\rj\x0Ej\u01DA\x03k\x06k\u01DE\nk\rk\x0Ek\u01DF\x03l\x03l\x03m\x03" + - "m\x03n\x03n\x03o\x03o\x02\x02\x02p\x03\x02\x03\x05\x02\x04\x07\x02\x05" + - "\t\x02\x06\v\x02\x07\r\x02\b\x0F\x02\t\x11\x02\n\x13\x02\v\x15\x02\f\x17" + - "\x02\r\x19\x02\x0E\x1B\x02\x0F\x1D\x02\x10\x1F\x02\x11!\x02\x12#\x02\x13" + - "%\x02\x14\'\x02\x15)\x02\x16+\x02\x17-\x02\x18/\x02\x191\x02\x1A3\x02" + - "\x1B5\x02\x1C7\x02\x1D9\x02\x1E;\x02\x1F=\x02 ?\x02!A\x02\"C\x02#E\x02" + - "$G\x02%I\x02&K\x02\'M\x02(O\x02)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" + - "\x02U\xA9\x02V\xAB\x02W\xAD\x02X\xAF\x02Y\xB1\x02Z\xB3\x02[\xB5\x02\\" + - "\xB7\x02]\xB9\x02^\xBB\x02_\xBD\x02`\xBF\x02a\xC1\x02b\xC3\x02c\xC5\x02" + - "d\xC7\x02e\xC9\x02f\xCB\x02g\xCD\x02h\xCF\x02i\xD1\x02j\xD3\x02\x02\xD5" + - "\x02\x02\xD7\x02\x02\xD9\x02\x02\xDB\x02\x02\xDD\x02\x02\x03\x02\x05\x05" + - "\x022;C\\c|\x05\x022;CHch\x03\x02\x02\x81\u01E7\x02\x03\x03\x02\x02\x02" + - "\x02\x05\x03\x02\x02\x02\x02\x07\x03\x02\x02\x02\x02\t\x03\x02\x02\x02" + - "\x02\v\x03\x02\x02\x02\x02\r\x03\x02\x02\x02\x02\x0F\x03\x02\x02\x02\x02" + - "\x11\x03\x02\x02\x02\x02\x13\x03\x02\x02\x02\x02\x15\x03\x02\x02\x02\x02" + - "\x17\x03\x02\x02\x02\x02\x19\x03\x02\x02\x02\x02\x1B\x03\x02\x02\x02\x02" + - "\x1D\x03\x02\x02\x02\x02\x1F\x03\x02\x02\x02\x02!\x03\x02\x02\x02\x02" + - "#\x03\x02\x02\x02\x02%\x03\x02\x02\x02\x02\'\x03\x02\x02\x02\x02)\x03" + - "\x02\x02\x02\x02+\x03\x02\x02\x02\x02-\x03\x02\x02\x02\x02/\x03\x02\x02" + - "\x02\x021\x03\x02\x02\x02\x023\x03\x02\x02\x02\x025\x03\x02\x02\x02\x02" + - "7\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\x02" + - "Y\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\x02\xA7\x03\x02\x02\x02\x02\xA9\x03\x02\x02\x02\x02\xAB" + - "\x03\x02\x02\x02\x02\xAD\x03\x02\x02\x02\x02\xAF\x03\x02\x02\x02\x02\xB1" + - "\x03\x02\x02\x02\x02\xB3\x03\x02\x02\x02\x02\xB5\x03\x02\x02\x02\x02\xB7" + - "\x03\x02\x02\x02\x02\xB9\x03\x02\x02\x02\x02\xBB\x03\x02\x02\x02\x02\xBD" + - "\x03\x02\x02\x02\x02\xBF\x03\x02\x02\x02\x02\xC1\x03\x02\x02\x02\x02\xC3" + - "\x03\x02\x02\x02\x02\xC5\x03\x02\x02\x02\x02\xC7\x03\x02\x02\x02\x02\xC9" + - "\x03\x02\x02\x02\x02\xCB\x03\x02\x02\x02\x02\xCD\x03\x02\x02\x02\x02\xCF" + - "\x03\x02\x02\x02\x02\xD1\x03\x02\x02\x02\x03\xDF\x03\x02\x02\x02\x05\xE2" + - "\x03\x02\x02\x02\x07\xE5\x03\x02\x02\x02\t\xE8\x03\x02\x02\x02\v\xEB\x03" + - "\x02\x02\x02\r\xEE\x03\x02\x02\x02\x0F\xF1\x03\x02\x02\x02\x11\xF4\x03" + - "\x02\x02\x02\x13\xF6\x03\x02\x02\x02\x15\u0108\x03\x02\x02\x02\x17\u010A" + - "\x03\x02\x02\x02\x19\u010D\x03\x02\x02\x02\x1B\u0110\x03\x02\x02\x02\x1D" + - "\u0117\x03\x02\x02\x02\x1F\u011E\x03\x02\x02\x02!\u0121\x03\x02\x02\x02" + - "#\u0124\x03\x02\x02\x02%\u0127\x03\x02\x02\x02\'\u012A\x03\x02\x02\x02" + - ")\u012C\x03\x02\x02\x02+\u012E\x03\x02\x02\x02-\u0130\x03\x02\x02\x02" + - "/\u0132\x03\x02\x02\x021\u0134\x03\x02\x02\x023\u0136\x03\x02\x02\x02" + - "5\u0138\x03\x02\x02\x027\u013A\x03\x02\x02\x029\u013C\x03\x02\x02\x02" + - ";\u013E\x03\x02\x02\x02=\u0140\x03\x02\x02\x02?\u0142\x03\x02\x02\x02" + - "A\u0144\x03\x02\x02\x02C\u0146\x03\x02\x02\x02E\u0148\x03\x02\x02\x02" + - "G\u014A\x03\x02\x02\x02I\u014C\x03\x02\x02\x02K\u014E\x03\x02\x02\x02" + - "M\u0150\x03\x02\x02\x02O\u0152\x03\x02\x02\x02Q\u0154\x03\x02\x02\x02" + - "S\u0156\x03\x02\x02\x02U\u0158\x03\x02\x02\x02W\u015A\x03\x02\x02\x02" + - "Y\u015C\x03\x02\x02\x02[\u015E\x03\x02\x02\x02]\u0160\x03\x02\x02\x02" + - "_\u0162\x03\x02\x02\x02a\u0164\x03\x02\x02\x02c\u0166\x03\x02\x02\x02" + - "e\u0168\x03\x02\x02\x02g\u016A\x03\x02\x02\x02i\u016C\x03\x02\x02\x02" + - "k\u016E\x03\x02\x02\x02m\u0170\x03\x02\x02\x02o\u0172\x03\x02\x02\x02" + - "q\u0174\x03\x02\x02\x02s\u0176\x03\x02\x02\x02u\u0178\x03\x02\x02\x02" + - "w\u017A\x03\x02\x02\x02y\u017C\x03\x02\x02\x02{\u017E\x03\x02\x02\x02" + - "}\u0180\x03\x02\x02\x02\x7F\u0182\x03\x02\x02\x02\x81\u0184\x03\x02\x02" + - "\x02\x83\u0186\x03\x02\x02\x02\x85\u0188\x03\x02\x02\x02\x87\u018A\x03" + - "\x02\x02\x02\x89\u018C\x03\x02\x02\x02\x8B\u018E\x03\x02\x02\x02\x8D\u0190" + - "\x03\x02\x02\x02\x8F\u0192\x03\x02\x02\x02\x91\u0194\x03\x02\x02\x02\x93" + - "\u0196\x03\x02\x02\x02\x95\u0198\x03\x02\x02\x02\x97\u019A\x03\x02\x02" + - "\x02\x99\u019C\x03\x02\x02\x02\x9B\u019E\x03\x02\x02\x02\x9D\u01A0\x03" + - "\x02\x02\x02\x9F\u01A2\x03\x02\x02\x02\xA1\u01A4\x03\x02\x02\x02\xA3\u01A6" + - "\x03\x02\x02\x02\xA5\u01A8\x03\x02\x02\x02\xA7\u01AA\x03\x02\x02\x02\xA9" + - "\u01AC\x03\x02\x02\x02\xAB\u01AE\x03\x02\x02\x02\xAD\u01B0\x03\x02\x02" + - "\x02\xAF\u01B2\x03\x02\x02\x02\xB1\u01B4\x03\x02\x02\x02\xB3\u01B6\x03" + - "\x02\x02\x02\xB5\u01B8\x03\x02\x02\x02\xB7\u01BA\x03\x02\x02\x02\xB9\u01BC" + - "\x03\x02\x02\x02\xBB\u01BE\x03\x02\x02\x02\xBD\u01C0\x03\x02\x02\x02\xBF" + - "\u01C2\x03\x02\x02\x02\xC1\u01C4\x03\x02\x02\x02\xC3\u01C6\x03\x02\x02" + - "\x02\xC5\u01C8\x03\x02\x02\x02\xC7\u01CA\x03\x02\x02\x02\xC9\u01CC\x03" + - "\x02\x02\x02\xCB\u01CE\x03\x02\x02\x02\xCD\u01D0\x03\x02\x02\x02\xCF\u01D2" + - "\x03\x02\x02\x02\xD1\u01D4\x03\x02\x02\x02\xD3\u01D8\x03\x02\x02\x02\xD5" + - "\u01DD\x03\x02\x02\x02\xD7\u01E1\x03\x02\x02\x02\xD9\u01E3\x03\x02\x02" + - "\x02\xDB\u01E5\x03\x02\x02\x02\xDD\u01E7\x03\x02\x02\x02\xDF\xE0\x07^" + - "\x02\x02\xE0\xE1\x07c\x02\x02\xE1\x04\x03\x02\x02\x02\xE2\xE3\x07^\x02" + - "\x02\xE3\xE4\x07e\x02\x02\xE4\x06\x03\x02\x02\x02\xE5\xE6\x07^\x02\x02" + - "\xE6\xE7\x07g\x02\x02\xE7\b\x03\x02\x02\x02\xE8\xE9\x07^\x02\x02\xE9\xEA" + - "\x07h\x02\x02\xEA\n\x03\x02\x02\x02\xEB\xEC\x07^\x02\x02\xEC\xED\x07p" + - "\x02\x02\xED\f\x03\x02\x02\x02\xEE\xEF\x07^\x02\x02\xEF\xF0\x07t\x02\x02" + - "\xF0\x0E\x03\x02\x02\x02\xF1\xF2\x07^\x02\x02\xF2\xF3\x07v\x02\x02\xF3" + - "\x10\x03\x02\x02\x02\xF4\xF5\x07^\x02\x02\xF5\x12\x03\x02\x02\x02\xF6" + - "\xF7\x07^\x02\x02\xF7\xF8\x07z\x02\x02\xF8\u0106\x03\x02\x02\x02\xF9\xFA" + - "\x05\xDBn\x02\xFA\xFB\x05\xDBn\x02\xFB\u0107\x03\x02\x02\x02\xFC\xFD\x07" + - "}\x02\x02\xFD\xFE\x05\xDBn\x02\xFE\u0100\x05\xDBn\x02\xFF\u0101\x05\xDB" + - "n\x02\u0100\xFF\x03\x02\x02\x02\u0101\u0102\x03\x02\x02\x02\u0102\u0100" + - "\x03\x02\x02\x02\u0102\u0103\x03\x02\x02\x02\u0103\u0104\x03\x02\x02\x02" + - "\u0104\u0105\x07\x7F\x02\x02\u0105\u0107\x03\x02\x02\x02\u0106\xF9\x03" + - "\x02\x02\x02\u0106\xFC\x03\x02\x02\x02\u0107\x14\x03\x02\x02\x02\u0108" + - "\u0109\x070\x02\x02\u0109\x16\x03\x02\x02\x02\u010A\u010B\x07^\x02\x02" + - "\u010B\u010C\x07f\x02\x02\u010C\x18\x03\x02\x02\x02\u010D\u010E\x07^\x02" + - "\x02\u010E\u010F\x07F\x02\x02\u010F\x1A\x03\x02\x02\x02\u0110\u0111\x07" + - "^\x02\x02\u0111\u0112\x07r\x02\x02\u0112\u0113\x07}\x02\x02\u0113\u0114" + - "\x03\x02\x02\x02\u0114\u0115\x05\xD3j\x02\u0115\u0116\x07\x7F\x02\x02" + - "\u0116\x1C\x03\x02\x02\x02\u0117\u0118\x07^\x02\x02\u0118\u0119\x07R\x02" + - "\x02\u0119\u011A\x07}\x02\x02\u011A\u011B\x03\x02\x02\x02\u011B\u011C" + - "\x05\xD3j\x02\u011C\u011D\x07\x7F\x02\x02\u011D\x1E\x03\x02\x02\x02\u011E" + - "\u011F\x07^\x02\x02\u011F\u0120\x07u\x02\x02\u0120 \x03\x02\x02\x02\u0121" + - "\u0122\x07^\x02\x02\u0122\u0123\x07U\x02\x02\u0123\"\x03\x02\x02\x02\u0124" + - "\u0125\x07^\x02\x02\u0125\u0126\x07y\x02\x02\u0126$\x03\x02\x02\x02\u0127" + - "\u0128\x07^\x02\x02\u0128\u0129\x07Y\x02\x02\u0129&\x03\x02\x02\x02\u012A" + - "\u012B\x07]\x02\x02\u012B(\x03\x02\x02\x02\u012C\u012D\x07_\x02\x02\u012D" + - "*\x03\x02\x02\x02\u012E\u012F\x07`\x02\x02\u012F,\x03\x02\x02\x02\u0130" + - "\u0131\x07/\x02\x02\u0131.\x03\x02\x02\x02\u0132\u0133\x07A\x02\x02\u0133" + - "0\x03\x02\x02\x02\u0134\u0135\x07-\x02\x02\u01352\x03\x02\x02\x02\u0136" + - "\u0137\x07,\x02\x02\u01374\x03\x02\x02\x02\u0138\u0139\x07}\x02\x02\u0139" + - "6\x03\x02\x02\x02\u013A\u013B\x07\x7F\x02\x02\u013B8\x03\x02\x02\x02\u013C" + - "\u013D\x07.\x02\x02\u013D:\x03\x02\x02\x02\u013E\u013F\x07&\x02\x02\u013F" + - "<\x03\x02\x02\x02\u0140\u0141\x07~\x02\x02\u0141>\x03\x02\x02\x02\u0142" + - "\u0143\x07*\x02\x02\u0143@\x03\x02\x02\x02\u0144\u0145\x07+\x02\x02\u0145" + - "B\x03\x02\x02\x02\u0146\u0147\x07>\x02\x02\u0147D\x03\x02\x02\x02\u0148" + - "\u0149\x07@\x02\x02\u0149F\x03\x02\x02\x02\u014A\u014B\x07)\x02\x02\u014B" + - "H\x03\x02\x02\x02\u014C\u014D\x07a\x02\x02\u014DJ\x03\x02\x02\x02\u014E" + - "\u014F\x07<\x02\x02\u014FL\x03\x02\x02\x02\u0150\u0151\x07%\x02\x02\u0151" + - "N\x03\x02\x02\x02\u0152\u0153\x07?\x02\x02\u0153P\x03\x02\x02\x02\u0154" + - "\u0155\x07#\x02\x02\u0155R\x03\x02\x02\x02\u0156\u0157\x07(\x02\x02\u0157" + - "T\x03\x02\x02\x02\u0158\u0159\x07c\x02\x02\u0159V\x03\x02\x02\x02\u015A" + - "\u015B\x07d\x02\x02\u015BX\x03\x02\x02\x02\u015C\u015D\x07e\x02\x02\u015D" + - "Z\x03\x02\x02\x02\u015E\u015F\x07f\x02\x02\u015F\\\x03\x02\x02\x02\u0160" + - "\u0161\x07g\x02\x02\u0161^\x03\x02\x02\x02\u0162\u0163\x07h\x02\x02\u0163" + - "`\x03\x02\x02\x02\u0164\u0165\x07i\x02\x02\u0165b\x03\x02\x02\x02\u0166" + - "\u0167\x07j\x02\x02\u0167d\x03\x02\x02\x02\u0168\u0169\x07k\x02\x02\u0169" + - "f\x03\x02\x02\x02\u016A\u016B\x07l\x02\x02\u016Bh\x03\x02\x02\x02\u016C" + - "\u016D\x07m\x02\x02\u016Dj\x03\x02\x02\x02\u016E\u016F\x07n\x02\x02\u016F" + - "l\x03\x02\x02\x02\u0170\u0171\x07o\x02\x02\u0171n\x03\x02\x02\x02\u0172" + - "\u0173\x07p\x02\x02\u0173p\x03\x02\x02\x02\u0174\u0175\x07q\x02\x02\u0175" + - "r\x03\x02\x02\x02\u0176\u0177\x07r\x02\x02\u0177t\x03\x02\x02\x02\u0178" + - "\u0179\x07s\x02\x02\u0179v\x03\x02\x02\x02\u017A\u017B\x07t\x02\x02\u017B" + - "x\x03\x02\x02\x02\u017C\u017D\x07u\x02\x02\u017Dz\x03\x02\x02\x02\u017E" + - "\u017F\x07v\x02\x02\u017F|\x03\x02\x02\x02\u0180\u0181\x07w\x02\x02\u0181" + - "~\x03\x02\x02\x02\u0182\u0183\x07x\x02\x02\u0183\x80\x03\x02\x02\x02\u0184" + - "\u0185\x07y\x02\x02\u0185\x82\x03\x02\x02\x02\u0186\u0187\x07z\x02\x02" + - "\u0187\x84\x03\x02\x02\x02\u0188\u0189\x07{\x02\x02\u0189\x86\x03\x02" + - "\x02\x02\u018A\u018B\x07|\x02\x02\u018B\x88\x03\x02\x02\x02\u018C\u018D" + - "\x07C\x02\x02\u018D\x8A\x03\x02\x02\x02\u018E\u018F\x07D\x02\x02\u018F" + - "\x8C\x03\x02\x02\x02\u0190\u0191\x07E\x02\x02\u0191\x8E\x03\x02\x02\x02" + - "\u0192\u0193\x07F\x02\x02\u0193\x90\x03\x02\x02\x02\u0194\u0195\x07G\x02" + - "\x02\u0195\x92\x03\x02\x02\x02\u0196\u0197\x07H\x02\x02\u0197\x94\x03" + - "\x02\x02\x02\u0198\u0199\x07I\x02\x02\u0199\x96\x03\x02\x02\x02\u019A" + - "\u019B\x07J\x02\x02\u019B\x98\x03\x02\x02\x02\u019C\u019D\x07K\x02\x02" + - "\u019D\x9A\x03\x02\x02\x02\u019E\u019F\x07L\x02\x02\u019F\x9C\x03\x02" + - "\x02\x02\u01A0\u01A1\x07M\x02\x02\u01A1\x9E\x03\x02\x02\x02\u01A2\u01A3" + - "\x07N\x02\x02\u01A3\xA0\x03\x02\x02\x02\u01A4\u01A5\x07O\x02\x02\u01A5" + - "\xA2\x03\x02\x02\x02\u01A6\u01A7\x07P\x02\x02\u01A7\xA4\x03\x02\x02\x02" + - "\u01A8\u01A9\x07Q\x02\x02\u01A9\xA6\x03\x02\x02\x02\u01AA\u01AB\x07R\x02" + - "\x02\u01AB\xA8\x03\x02\x02\x02\u01AC\u01AD\x07S\x02\x02\u01AD\xAA\x03" + - "\x02\x02\x02\u01AE\u01AF\x07T\x02\x02\u01AF\xAC\x03\x02\x02\x02\u01B0" + - "\u01B1\x07U\x02\x02\u01B1\xAE\x03\x02\x02\x02\u01B2\u01B3\x07V\x02\x02" + - "\u01B3\xB0\x03\x02\x02\x02\u01B4\u01B5\x07W\x02\x02\u01B5\xB2\x03\x02" + - "\x02\x02\u01B6\u01B7\x07X\x02\x02\u01B7\xB4\x03\x02\x02\x02\u01B8\u01B9" + - "\x07Y\x02\x02\u01B9\xB6\x03\x02\x02\x02\u01BA\u01BB\x07Z\x02\x02\u01BB" + - "\xB8\x03\x02\x02\x02\u01BC\u01BD\x07[\x02\x02\u01BD\xBA\x03\x02\x02\x02" + - "\u01BE\u01BF\x07\\\x02\x02\u01BF\xBC\x03\x02\x02\x02\u01C0\u01C1\x073" + - "\x02\x02\u01C1\xBE\x03\x02\x02\x02\u01C2\u01C3\x074\x02\x02\u01C3\xC0" + - "\x03\x02\x02\x02\u01C4\u01C5\x075\x02\x02\u01C5\xC2\x03\x02\x02\x02\u01C6" + - "\u01C7\x076\x02\x02\u01C7\xC4\x03\x02\x02\x02\u01C8\u01C9\x077\x02\x02" + - "\u01C9\xC6\x03\x02\x02\x02\u01CA\u01CB\x078\x02\x02\u01CB\xC8\x03\x02" + - "\x02\x02\u01CC\u01CD\x079\x02\x02\u01CD\xCA\x03\x02\x02\x02\u01CE\u01CF" + - "\x07:\x02\x02\u01CF\xCC\x03\x02\x02\x02\u01D0\u01D1\x07;\x02\x02\u01D1" + - "\xCE\x03\x02\x02\x02\u01D2\u01D3\x072\x02\x02\u01D3\xD0\x03\x02\x02\x02" + - "\u01D4\u01D5\v\x02\x02\x02\u01D5\xD2\x03\x02\x02\x02\u01D6\u01D9\x07a" + - "\x02\x02\u01D7\u01D9\x05\xD7l\x02\u01D8\u01D6\x03\x02\x02\x02\u01D8\u01D7" + - "\x03\x02\x02\x02\u01D9\u01DA\x03\x02\x02\x02\u01DA\u01D8\x03\x02\x02\x02" + - "\u01DA\u01DB\x03\x02\x02\x02\u01DB\xD4\x03\x02\x02\x02\u01DC\u01DE\x05" + - "\xD7l\x02\u01DD\u01DC\x03\x02\x02\x02\u01DE\u01DF\x03\x02\x02\x02\u01DF" + - "\u01DD\x03\x02\x02\x02\u01DF\u01E0\x03\x02\x02\x02\u01E0\xD6\x03\x02\x02" + - "\x02\u01E1\u01E2\t\x02\x02\x02\u01E2\xD8\x03\x02\x02\x02\u01E3\u01E4\n" + - "\x02\x02\x02\u01E4\xDA\x03\x02\x02\x02\u01E5\u01E6\t\x03\x02\x02\u01E6" + - "\xDC\x03\x02\x02\x02\u01E7\u01E8\t\x04\x02\x02\u01E8\xDE\x03\x02\x02\x02" + - "\b\x02\u0102\u0106\u01D8\u01DA\u01DF\x02"; + "i\ti\x04j\tj\x04k\tk\x04l\tl\x04m\tm\x04n\tn\x04o\to\x04p\tp\x04q\tq\x03" + + "\x02\x03\x02\x03\x02\x03\x03\x03\x03\x03\x03\x03\x03\x07\x03\xEB\n\x03" + + "\f\x03\x0E\x03\xEE\v\x03\x03\x03\x03\x03\x03\x03\x03\x04\x03\x04\x03\x04" + + "\x03\x05\x03\x05\x03\x05\x03\x06\x03\x06\x03\x06\x03\x07\x03\x07\x03\x07" + + "\x03\b\x03\b\x03\b\x03\t\x03\t\x03\t\x03\n\x03\n\x03\n\x03\v\x03\v\x03" + + "\f\x03\f\x03\f\x03\f\x03\f\x03\f\x03\f\x03\f\x03\f\x03\f\x06\f\u0114\n" + + "\f\r\f\x0E\f\u0115\x03\f\x03\f\x05\f\u011A\n\f\x03\r\x03\r\x03\x0E\x03" + + "\x0E\x03\x0E\x03\x0F\x03\x0F\x03\x0F\x03\x10\x03\x10\x03\x10\x03\x10\x03" + + "\x10\x03\x10\x03\x10\x03\x11\x03\x11\x03\x11\x03\x11\x03\x11\x03\x11\x03" + + "\x11\x03\x12\x03\x12\x03\x12\x03\x13\x03\x13\x03\x13\x03\x14\x03\x14\x03" + + "\x14\x03\x15\x03\x15\x03\x15\x03\x16\x03\x16\x03\x17\x03\x17\x03\x18\x03" + + "\x18\x03\x19\x03\x19\x03\x1A\x03\x1A\x03\x1B\x03\x1B\x03\x1C\x03\x1C\x03" + + "\x1D\x03\x1D\x03\x1E\x03\x1E\x03\x1F\x03\x1F\x03 \x03 \x03!\x03!\x03\"" + + "\x03\"\x03#\x03#\x03$\x03$\x03%\x03%\x03&\x03&\x03\'\x03\'\x03(\x03(\x03" + + ")\x03)\x03*\x03*\x03+\x03+\x03,\x03,\x03-\x03-\x03.\x03.\x03/\x03/\x03" + + "0\x030\x031\x031\x032\x032\x033\x033\x034\x034\x035\x035\x036\x036\x03" + + "7\x037\x038\x038\x039\x039\x03:\x03:\x03;\x03;\x03<\x03<\x03=\x03=\x03" + + ">\x03>\x03?\x03?\x03@\x03@\x03A\x03A\x03B\x03B\x03C\x03C\x03D\x03D\x03" + + "E\x03E\x03F\x03F\x03G\x03G\x03H\x03H\x03I\x03I\x03J\x03J\x03K\x03K\x03" + + "L\x03L\x03M\x03M\x03N\x03N\x03O\x03O\x03P\x03P\x03Q\x03Q\x03R\x03R\x03" + + "S\x03S\x03T\x03T\x03U\x03U\x03V\x03V\x03W\x03W\x03X\x03X\x03Y\x03Y\x03" + + "Z\x03Z\x03[\x03[\x03\\\x03\\\x03]\x03]\x03^\x03^\x03_\x03_\x03`\x03`\x03" + + "a\x03a\x03b\x03b\x03c\x03c\x03d\x03d\x03e\x03e\x03f\x03f\x03g\x03g\x03" + + "h\x03h\x03i\x03i\x03j\x03j\x03k\x03k\x03l\x03l\x06l\u01EC\nl\rl\x0El\u01ED" + + "\x03m\x06m\u01F1\nm\rm\x0Em\u01F2\x03n\x03n\x03o\x03o\x03p\x03p\x03q\x03" + + "q\x03\xEC\x02\x02r\x03\x02\x03\x05\x02\x04\x07\x02\x05\t\x02\x06\v\x02" + + "\x07\r\x02\b\x0F\x02\t\x11\x02\n\x13\x02\v\x15\x02\f\x17\x02\r\x19\x02" + + "\x0E\x1B\x02\x0F\x1D\x02\x10\x1F\x02\x11!\x02\x12#\x02\x13%\x02\x14\'" + + "\x02\x15)\x02\x16+\x02\x17-\x02\x18/\x02\x191\x02\x1A3\x02\x1B5\x02\x1C" + + "7\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\x02" + + "F\x8B\x02G\x8D\x02H\x8F\x02I\x91\x02J\x93\x02K\x95\x02L\x97\x02M\x99\x02" + + "N\x9B\x02O\x9D\x02P\x9F\x02Q\xA1\x02R\xA3\x02S\xA5\x02T\xA7\x02U\xA9\x02" + + "V\xAB\x02W\xAD\x02X\xAF\x02Y\xB1\x02Z\xB3\x02[\xB5\x02\\\xB7\x02]\xB9" + + "\x02^\xBB\x02_\xBD\x02`\xBF\x02a\xC1\x02b\xC3\x02c\xC5\x02d\xC7\x02e\xC9" + + "\x02f\xCB\x02g\xCD\x02h\xCF\x02i\xD1\x02j\xD3\x02k\xD5\x02l\xD7\x02\x02" + + "\xD9\x02\x02\xDB\x02\x02\xDD\x02\x02\xDF\x02\x02\xE1\x02\x02\x03\x02\x05" + + "\x05\x022;C\\c|\x05\x022;CHch\x03\x02\x02\x81\u01FB\x02\x03\x03\x02\x02" + + "\x02\x02\x05\x03\x02\x02\x02\x02\x07\x03\x02\x02\x02\x02\t\x03\x02\x02" + + "\x02\x02\v\x03\x02\x02\x02\x02\r\x03\x02\x02\x02\x02\x0F\x03\x02\x02\x02" + + "\x02\x11\x03\x02\x02\x02\x02\x13\x03\x02\x02\x02\x02\x15\x03\x02\x02\x02" + + "\x02\x17\x03\x02\x02\x02\x02\x19\x03\x02\x02\x02\x02\x1B\x03\x02\x02\x02" + + "\x02\x1D\x03\x02\x02\x02\x02\x1F\x03\x02\x02\x02\x02!\x03\x02\x02\x02" + + "\x02#\x03\x02\x02\x02\x02%\x03\x02\x02\x02\x02\'\x03\x02\x02\x02\x02)" + + "\x03\x02\x02\x02\x02+\x03\x02\x02\x02\x02-\x03\x02\x02\x02\x02/\x03\x02" + + "\x02\x02\x021\x03\x02\x02\x02\x023\x03\x02\x02\x02\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\x02\xA3\x03\x02\x02\x02\x02" + + "\xA5\x03\x02\x02\x02\x02\xA7\x03\x02\x02\x02\x02\xA9\x03\x02\x02\x02\x02" + + "\xAB\x03\x02\x02\x02\x02\xAD\x03\x02\x02\x02\x02\xAF\x03\x02\x02\x02\x02" + + "\xB1\x03\x02\x02\x02\x02\xB3\x03\x02\x02\x02\x02\xB5\x03\x02\x02\x02\x02" + + "\xB7\x03\x02\x02\x02\x02\xB9\x03\x02\x02\x02\x02\xBB\x03\x02\x02\x02\x02" + + "\xBD\x03\x02\x02\x02\x02\xBF\x03\x02\x02\x02\x02\xC1\x03\x02\x02\x02\x02" + + "\xC3\x03\x02\x02\x02\x02\xC5\x03\x02\x02\x02\x02\xC7\x03\x02\x02\x02\x02" + + "\xC9\x03\x02\x02\x02\x02\xCB\x03\x02\x02\x02\x02\xCD\x03\x02\x02\x02\x02" + + "\xCF\x03\x02\x02\x02\x02\xD1\x03\x02\x02\x02\x02\xD3\x03\x02\x02\x02\x02" + + "\xD5\x03\x02\x02\x02\x03\xE3\x03\x02\x02\x02\x05\xE6\x03\x02\x02\x02\x07" + + "\xF2\x03\x02\x02\x02\t\xF5\x03\x02\x02\x02\v\xF8\x03\x02\x02\x02\r\xFB" + + "\x03\x02\x02\x02\x0F\xFE\x03\x02\x02\x02\x11\u0101\x03\x02\x02\x02\x13" + + "\u0104\x03\x02\x02\x02\x15\u0107\x03\x02\x02\x02\x17\u0109\x03\x02\x02" + + "\x02\x19\u011B\x03\x02\x02\x02\x1B\u011D\x03\x02\x02\x02\x1D\u0120\x03" + + "\x02\x02\x02\x1F\u0123\x03\x02\x02\x02!\u012A\x03\x02\x02\x02#\u0131\x03" + + "\x02\x02\x02%\u0134\x03\x02\x02\x02\'\u0137\x03\x02\x02\x02)\u013A\x03" + + "\x02\x02\x02+\u013D\x03\x02\x02\x02-\u013F\x03\x02\x02\x02/\u0141\x03" + + "\x02\x02\x021\u0143\x03\x02\x02\x023\u0145\x03\x02\x02\x025\u0147\x03" + + "\x02\x02\x027\u0149\x03\x02\x02\x029\u014B\x03\x02\x02\x02;\u014D\x03" + + "\x02\x02\x02=\u014F\x03\x02\x02\x02?\u0151\x03\x02\x02\x02A\u0153\x03" + + "\x02\x02\x02C\u0155\x03\x02\x02\x02E\u0157\x03\x02\x02\x02G\u0159\x03" + + "\x02\x02\x02I\u015B\x03\x02\x02\x02K\u015D\x03\x02\x02\x02M\u015F\x03" + + "\x02\x02\x02O\u0161\x03\x02\x02\x02Q\u0163\x03\x02\x02\x02S\u0165\x03" + + "\x02\x02\x02U\u0167\x03\x02\x02\x02W\u0169\x03\x02\x02\x02Y\u016B\x03" + + "\x02\x02\x02[\u016D\x03\x02\x02\x02]\u016F\x03\x02\x02\x02_\u0171\x03" + + "\x02\x02\x02a\u0173\x03\x02\x02\x02c\u0175\x03\x02\x02\x02e\u0177\x03" + + "\x02\x02\x02g\u0179\x03\x02\x02\x02i\u017B\x03\x02\x02\x02k\u017D\x03" + + "\x02\x02\x02m\u017F\x03\x02\x02\x02o\u0181\x03\x02\x02\x02q\u0183\x03" + + "\x02\x02\x02s\u0185\x03\x02\x02\x02u\u0187\x03\x02\x02\x02w\u0189\x03" + + "\x02\x02\x02y\u018B\x03\x02\x02\x02{\u018D\x03\x02\x02\x02}\u018F\x03" + + "\x02\x02\x02\x7F\u0191\x03\x02\x02\x02\x81\u0193\x03\x02\x02\x02\x83\u0195" + + "\x03\x02\x02\x02\x85\u0197\x03\x02\x02\x02\x87\u0199\x03\x02\x02\x02\x89" + + "\u019B\x03\x02\x02\x02\x8B\u019D\x03\x02\x02\x02\x8D\u019F\x03\x02\x02" + + "\x02\x8F\u01A1\x03\x02\x02\x02\x91\u01A3\x03\x02\x02\x02\x93\u01A5\x03" + + "\x02\x02\x02\x95\u01A7\x03\x02\x02\x02\x97\u01A9\x03\x02\x02\x02\x99\u01AB" + + "\x03\x02\x02\x02\x9B\u01AD\x03\x02\x02\x02\x9D\u01AF\x03\x02\x02\x02\x9F" + + "\u01B1\x03\x02\x02\x02\xA1\u01B3\x03\x02\x02\x02\xA3\u01B5\x03\x02\x02" + + "\x02\xA5\u01B7\x03\x02\x02\x02\xA7\u01B9\x03\x02\x02\x02\xA9\u01BB\x03" + + "\x02\x02\x02\xAB\u01BD\x03\x02\x02\x02\xAD\u01BF\x03\x02\x02\x02\xAF\u01C1" + + "\x03\x02\x02\x02\xB1\u01C3\x03\x02\x02\x02\xB3\u01C5\x03\x02\x02\x02\xB5" + + "\u01C7\x03\x02\x02\x02\xB7\u01C9\x03\x02\x02\x02\xB9\u01CB\x03\x02\x02" + + "\x02\xBB\u01CD\x03\x02\x02\x02\xBD\u01CF\x03\x02\x02\x02\xBF\u01D1\x03" + + "\x02\x02\x02\xC1\u01D3\x03\x02\x02\x02\xC3\u01D5\x03\x02\x02\x02\xC5\u01D7" + + "\x03\x02\x02\x02\xC7\u01D9\x03\x02\x02\x02\xC9\u01DB\x03\x02\x02\x02\xCB" + + "\u01DD\x03\x02\x02\x02\xCD\u01DF\x03\x02\x02\x02\xCF\u01E1\x03\x02\x02" + + "\x02\xD1\u01E3\x03\x02\x02\x02\xD3\u01E5\x03\x02\x02\x02\xD5\u01E7\x03" + + "\x02\x02\x02\xD7\u01EB\x03\x02\x02\x02\xD9\u01F0\x03\x02\x02\x02\xDB\u01F4" + + "\x03\x02\x02\x02\xDD\u01F6\x03\x02\x02\x02\xDF\u01F8\x03\x02\x02\x02\xE1" + + "\u01FA\x03\x02\x02\x02\xE3\xE4\x07^\x02\x02\xE4\xE5\x05\xDDo\x02\xE5\x04" + + "\x03\x02\x02\x02\xE6\xE7\x07^\x02\x02\xE7\xE8\x07S\x02\x02\xE8\xEC\x03" + + "\x02\x02\x02\xE9\xEB\v\x02\x02\x02\xEA\xE9\x03\x02\x02\x02\xEB\xEE\x03" + + "\x02\x02\x02\xEC\xED\x03\x02\x02\x02\xEC\xEA\x03\x02\x02\x02\xED\xEF\x03" + + "\x02\x02\x02\xEE\xEC\x03\x02\x02\x02\xEF\xF0\x07^\x02\x02\xF0\xF1\x07" + + "G\x02\x02\xF1\x06\x03\x02\x02\x02\xF2\xF3\x07^\x02\x02\xF3\xF4\x07c\x02" + + "\x02\xF4\b\x03\x02\x02\x02\xF5\xF6\x07^\x02\x02\xF6\xF7\x07e\x02\x02\xF7" + + "\n\x03\x02\x02\x02\xF8\xF9\x07^\x02\x02\xF9\xFA\x07g\x02\x02\xFA\f\x03" + + "\x02\x02\x02\xFB\xFC\x07^\x02\x02\xFC\xFD\x07h\x02\x02\xFD\x0E\x03\x02" + + "\x02\x02\xFE\xFF\x07^\x02\x02\xFF\u0100\x07p\x02\x02\u0100\x10\x03\x02" + + "\x02\x02\u0101\u0102\x07^\x02\x02\u0102\u0103\x07t\x02\x02\u0103\x12\x03" + + "\x02\x02\x02\u0104\u0105\x07^\x02\x02\u0105\u0106\x07v\x02\x02\u0106\x14" + + "\x03\x02\x02\x02\u0107\u0108\x07^\x02\x02\u0108\x16\x03\x02\x02\x02\u0109" + + "\u010A\x07^\x02\x02\u010A\u010B\x07z\x02\x02\u010B\u0119\x03\x02\x02\x02" + + "\u010C\u010D\x05\xDFp\x02\u010D\u010E\x05\xDFp\x02\u010E\u011A\x03\x02" + + "\x02\x02\u010F\u0110\x07}\x02\x02\u0110\u0111\x05\xDFp\x02\u0111\u0113" + + "\x05\xDFp\x02\u0112\u0114\x05\xDFp\x02\u0113\u0112\x03\x02\x02\x02\u0114" + + "\u0115\x03\x02\x02\x02\u0115\u0113\x03\x02\x02\x02\u0115\u0116\x03\x02" + + "\x02\x02\u0116\u0117\x03\x02\x02\x02\u0117\u0118\x07\x7F\x02\x02\u0118" + + "\u011A\x03\x02\x02\x02\u0119\u010C\x03\x02\x02\x02\u0119\u010F\x03\x02" + + "\x02\x02\u011A\x18\x03\x02\x02\x02\u011B\u011C\x070\x02\x02\u011C\x1A" + + "\x03\x02\x02\x02\u011D\u011E\x07^\x02\x02\u011E\u011F\x07f\x02\x02\u011F" + + "\x1C\x03\x02\x02\x02\u0120\u0121\x07^\x02\x02\u0121\u0122\x07F\x02\x02" + + "\u0122\x1E\x03\x02\x02\x02\u0123\u0124\x07^\x02\x02\u0124\u0125\x07r\x02" + + "\x02\u0125\u0126\x07}\x02\x02\u0126\u0127\x03\x02\x02\x02\u0127\u0128" + + "\x05\xD7l\x02\u0128\u0129\x07\x7F\x02\x02\u0129 \x03\x02\x02\x02\u012A" + + "\u012B\x07^\x02\x02\u012B\u012C\x07R\x02\x02\u012C\u012D\x07}\x02\x02" + + "\u012D\u012E\x03\x02\x02\x02\u012E\u012F\x05\xD7l\x02\u012F\u0130\x07" + + "\x7F\x02\x02\u0130\"\x03\x02\x02\x02\u0131\u0132\x07^\x02\x02\u0132\u0133" + + "\x07u\x02\x02\u0133$\x03\x02\x02\x02\u0134\u0135\x07^\x02\x02\u0135\u0136" + + "\x07U\x02\x02\u0136&\x03\x02\x02\x02\u0137\u0138\x07^\x02\x02\u0138\u0139" + + "\x07y\x02\x02\u0139(\x03\x02\x02\x02\u013A\u013B\x07^\x02\x02\u013B\u013C" + + "\x07Y\x02\x02\u013C*\x03\x02\x02\x02\u013D\u013E\x07]\x02\x02\u013E,\x03" + + "\x02\x02\x02\u013F\u0140\x07_\x02\x02\u0140.\x03\x02\x02\x02\u0141\u0142" + + "\x07`\x02\x02\u01420\x03\x02\x02\x02\u0143\u0144\x07/\x02\x02\u01442\x03" + + "\x02\x02\x02\u0145\u0146\x07A\x02\x02\u01464\x03\x02\x02\x02\u0147\u0148" + + "\x07-\x02\x02\u01486\x03\x02\x02\x02\u0149\u014A\x07,\x02\x02\u014A8\x03" + + "\x02\x02\x02\u014B\u014C\x07}\x02\x02\u014C:\x03\x02\x02\x02\u014D\u014E" + + "\x07\x7F\x02\x02\u014E<\x03\x02\x02\x02\u014F\u0150\x07.\x02\x02\u0150" + + ">\x03\x02\x02\x02\u0151\u0152\x07&\x02\x02\u0152@\x03\x02\x02\x02\u0153" + + "\u0154\x07~\x02\x02\u0154B\x03\x02\x02\x02\u0155\u0156\x07*\x02\x02\u0156" + + "D\x03\x02\x02\x02\u0157\u0158\x07+\x02\x02\u0158F\x03\x02\x02\x02\u0159" + + "\u015A\x07>\x02\x02\u015AH\x03\x02\x02\x02\u015B\u015C\x07@\x02\x02\u015C" + + "J\x03\x02\x02\x02\u015D\u015E\x07)\x02\x02\u015EL\x03\x02\x02\x02\u015F" + + "\u0160\x07a\x02\x02\u0160N\x03\x02\x02\x02\u0161\u0162\x07<\x02\x02\u0162" + + "P\x03\x02\x02\x02\u0163\u0164\x07%\x02\x02\u0164R\x03\x02\x02\x02\u0165" + + "\u0166\x07?\x02\x02\u0166T\x03\x02\x02\x02\u0167\u0168\x07#\x02\x02\u0168" + + "V\x03\x02\x02\x02\u0169\u016A\x07(\x02\x02\u016AX\x03\x02\x02\x02\u016B" + + "\u016C\x07c\x02\x02\u016CZ\x03\x02\x02\x02\u016D\u016E\x07d\x02\x02\u016E" + + "\\\x03\x02\x02\x02\u016F\u0170\x07e\x02\x02\u0170^\x03\x02\x02\x02\u0171" + + "\u0172\x07f\x02\x02\u0172`\x03\x02\x02\x02\u0173\u0174\x07g\x02\x02\u0174" + + "b\x03\x02\x02\x02\u0175\u0176\x07h\x02\x02\u0176d\x03\x02\x02\x02\u0177" + + "\u0178\x07i\x02\x02\u0178f\x03\x02\x02\x02\u0179\u017A\x07j\x02\x02\u017A" + + "h\x03\x02\x02\x02\u017B\u017C\x07k\x02\x02\u017Cj\x03\x02\x02\x02\u017D" + + "\u017E\x07l\x02\x02\u017El\x03\x02\x02\x02\u017F\u0180\x07m\x02\x02\u0180" + + "n\x03\x02\x02\x02\u0181\u0182\x07n\x02\x02\u0182p\x03\x02\x02\x02\u0183" + + "\u0184\x07o\x02\x02\u0184r\x03\x02\x02\x02\u0185\u0186\x07p\x02\x02\u0186" + + "t\x03\x02\x02\x02\u0187\u0188\x07q\x02\x02\u0188v\x03\x02\x02\x02\u0189" + + "\u018A\x07r\x02\x02\u018Ax\x03\x02\x02\x02\u018B\u018C\x07s\x02\x02\u018C" + + "z\x03\x02\x02\x02\u018D\u018E\x07t\x02\x02\u018E|\x03\x02\x02\x02\u018F" + + "\u0190\x07u\x02\x02\u0190~\x03\x02\x02\x02\u0191\u0192\x07v\x02\x02\u0192" + + "\x80\x03\x02\x02\x02\u0193\u0194\x07w\x02\x02\u0194\x82\x03\x02\x02\x02" + + "\u0195\u0196\x07x\x02\x02\u0196\x84\x03\x02\x02\x02\u0197\u0198\x07y\x02" + + "\x02\u0198\x86\x03\x02\x02\x02\u0199\u019A\x07z\x02\x02\u019A\x88\x03" + + "\x02\x02\x02\u019B\u019C\x07{\x02\x02\u019C\x8A\x03\x02\x02\x02\u019D" + + "\u019E\x07|\x02\x02\u019E\x8C\x03\x02\x02\x02\u019F\u01A0\x07C\x02\x02" + + "\u01A0\x8E\x03\x02\x02\x02\u01A1\u01A2\x07D\x02\x02\u01A2\x90\x03\x02" + + "\x02\x02\u01A3\u01A4\x07E\x02\x02\u01A4\x92\x03\x02\x02\x02\u01A5\u01A6" + + "\x07F\x02\x02\u01A6\x94\x03\x02\x02\x02\u01A7\u01A8\x07G\x02\x02\u01A8" + + "\x96\x03\x02\x02\x02\u01A9\u01AA\x07H\x02\x02\u01AA\x98\x03\x02\x02\x02" + + "\u01AB\u01AC\x07I\x02\x02\u01AC\x9A\x03\x02\x02\x02\u01AD\u01AE\x07J\x02" + + "\x02\u01AE\x9C\x03\x02\x02\x02\u01AF\u01B0\x07K\x02\x02\u01B0\x9E\x03" + + "\x02\x02\x02\u01B1\u01B2\x07L\x02\x02\u01B2\xA0\x03\x02\x02\x02\u01B3" + + "\u01B4\x07M\x02\x02\u01B4\xA2\x03\x02\x02\x02\u01B5\u01B6\x07N\x02\x02" + + "\u01B6\xA4\x03\x02\x02\x02\u01B7\u01B8\x07O\x02\x02\u01B8\xA6\x03\x02" + + "\x02\x02\u01B9\u01BA\x07P\x02\x02\u01BA\xA8\x03\x02\x02\x02\u01BB\u01BC" + + "\x07Q\x02\x02\u01BC\xAA\x03\x02\x02\x02\u01BD\u01BE\x07R\x02\x02\u01BE" + + "\xAC\x03\x02\x02\x02\u01BF\u01C0\x07S\x02\x02\u01C0\xAE\x03\x02\x02\x02" + + "\u01C1\u01C2\x07T\x02\x02\u01C2\xB0\x03\x02\x02\x02\u01C3\u01C4\x07U\x02" + + "\x02\u01C4\xB2\x03\x02\x02\x02\u01C5\u01C6\x07V\x02\x02\u01C6\xB4\x03" + + "\x02\x02\x02\u01C7\u01C8\x07W\x02\x02\u01C8\xB6\x03\x02\x02\x02\u01C9" + + "\u01CA\x07X\x02\x02\u01CA\xB8\x03\x02\x02\x02\u01CB\u01CC\x07Y\x02\x02" + + "\u01CC\xBA\x03\x02\x02\x02\u01CD\u01CE\x07Z\x02\x02\u01CE\xBC\x03\x02" + + "\x02\x02\u01CF\u01D0\x07[\x02\x02\u01D0\xBE\x03\x02\x02\x02\u01D1\u01D2" + + "\x07\\\x02\x02\u01D2\xC0\x03\x02\x02\x02\u01D3\u01D4\x073\x02\x02\u01D4" + + "\xC2\x03\x02\x02\x02\u01D5\u01D6\x074\x02\x02\u01D6\xC4\x03\x02\x02\x02" + + "\u01D7\u01D8\x075\x02\x02\u01D8\xC6\x03\x02\x02\x02\u01D9\u01DA\x076\x02" + + "\x02\u01DA\xC8\x03\x02\x02\x02\u01DB\u01DC\x077\x02\x02\u01DC\xCA\x03" + + "\x02\x02\x02\u01DD\u01DE\x078\x02\x02\u01DE\xCC\x03\x02\x02\x02\u01DF" + + "\u01E0\x079\x02\x02\u01E0\xCE\x03\x02\x02\x02\u01E1\u01E2\x07:\x02\x02" + + "\u01E2\xD0\x03\x02\x02\x02\u01E3\u01E4\x07;\x02\x02\u01E4\xD2\x03\x02" + + "\x02\x02\u01E5\u01E6\x072\x02\x02\u01E6\xD4\x03\x02\x02\x02\u01E7\u01E8" + + "\v\x02\x02\x02\u01E8\xD6\x03\x02\x02\x02\u01E9\u01EC\x07a\x02\x02\u01EA" + + "\u01EC\x05\xDBn\x02\u01EB\u01E9\x03\x02\x02\x02\u01EB\u01EA\x03\x02\x02" + + "\x02\u01EC\u01ED\x03\x02\x02\x02\u01ED\u01EB\x03\x02\x02\x02\u01ED\u01EE" + + "\x03\x02\x02\x02\u01EE\xD8\x03\x02\x02\x02\u01EF\u01F1\x05\xDBn\x02\u01F0" + + "\u01EF\x03\x02\x02\x02\u01F1\u01F2\x03\x02\x02\x02\u01F2\u01F0\x03\x02" + + "\x02\x02\u01F2\u01F3\x03\x02\x02\x02\u01F3\xDA\x03\x02\x02\x02\u01F4\u01F5" + + "\t\x02\x02\x02\u01F5\xDC\x03\x02\x02\x02\u01F6\u01F7\n\x02\x02\x02\u01F7" + + "\xDE\x03\x02\x02\x02\u01F8\u01F9\t\x03\x02\x02\u01F9\xE0\x03\x02\x02\x02" + + "\u01FA\u01FB\t\x04\x02\x02\u01FB\xE2\x03\x02\x02\x02\t\x02\xEC\u0115\u0119" + + "\u01EB\u01ED\u01F2\x02"; public static __ATN: ATN; public static get _ATN(): ATN { if (!CommonRegexLexer.__ATN) { diff --git a/libraries/adaptive-expressions/src/generated/CommonRegexParser.ts b/libraries/adaptive-expressions/src/generated/CommonRegexParser.ts index e5b2cbd506..faf45cb079 100644 --- a/libraries/adaptive-expressions/src/generated/CommonRegexParser.ts +++ b/libraries/adaptive-expressions/src/generated/CommonRegexParser.ts @@ -35,110 +35,112 @@ import { CommonRegexVisitor } from "./CommonRegexVisitor"; export class CommonRegexParser extends Parser { - public static readonly BellChar = 1; - public static readonly ControlChar = 2; - public static readonly EscapeChar = 3; - public static readonly FormFeed = 4; - public static readonly NewLine = 5; - public static readonly CarriageReturn = 6; - public static readonly Tab = 7; - public static readonly Backslash = 8; - public static readonly HexChar = 9; - public static readonly Dot = 10; - public static readonly DecimalDigit = 11; - public static readonly NotDecimalDigit = 12; - public static readonly CharWithProperty = 13; - public static readonly CharWithoutProperty = 14; - public static readonly WhiteSpace = 15; - public static readonly NotWhiteSpace = 16; - public static readonly WordChar = 17; - public static readonly NotWordChar = 18; - public static readonly CharacterClassStart = 19; - public static readonly CharacterClassEnd = 20; - public static readonly Caret = 21; - public static readonly Hyphen = 22; - public static readonly QuestionMark = 23; - public static readonly Plus = 24; - public static readonly Star = 25; - public static readonly OpenBrace = 26; - public static readonly CloseBrace = 27; - public static readonly Comma = 28; - public static readonly EndOfSubject = 29; - public static readonly Pipe = 30; - public static readonly OpenParen = 31; - public static readonly CloseParen = 32; - public static readonly LessThan = 33; - public static readonly GreaterThan = 34; - public static readonly SingleQuote = 35; - public static readonly Underscore = 36; - public static readonly Colon = 37; - public static readonly Hash = 38; - public static readonly Equals = 39; - public static readonly Exclamation = 40; - public static readonly Ampersand = 41; - public static readonly ALC = 42; - public static readonly BLC = 43; - public static readonly CLC = 44; - public static readonly DLC = 45; - public static readonly ELC = 46; - public static readonly FLC = 47; - public static readonly GLC = 48; - public static readonly HLC = 49; - public static readonly ILC = 50; - public static readonly JLC = 51; - public static readonly KLC = 52; - public static readonly LLC = 53; - public static readonly MLC = 54; - public static readonly NLC = 55; - public static readonly OLC = 56; - public static readonly PLC = 57; - public static readonly QLC = 58; - public static readonly RLC = 59; - public static readonly SLC = 60; - public static readonly TLC = 61; - public static readonly ULC = 62; - public static readonly VLC = 63; - public static readonly WLC = 64; - public static readonly XLC = 65; - public static readonly YLC = 66; - public static readonly ZLC = 67; - public static readonly AUC = 68; - public static readonly BUC = 69; - public static readonly CUC = 70; - public static readonly DUC = 71; - public static readonly EUC = 72; - public static readonly FUC = 73; - public static readonly GUC = 74; - public static readonly HUC = 75; - public static readonly IUC = 76; - public static readonly JUC = 77; - public static readonly KUC = 78; - public static readonly LUC = 79; - public static readonly MUC = 80; - public static readonly NUC = 81; - public static readonly OUC = 82; - public static readonly PUC = 83; - public static readonly QUC = 84; - public static readonly RUC = 85; - public static readonly SUC = 86; - public static readonly TUC = 87; - public static readonly UUC = 88; - public static readonly VUC = 89; - public static readonly WUC = 90; - public static readonly XUC = 91; - public static readonly YUC = 92; - public static readonly ZUC = 93; - public static readonly D1 = 94; - public static readonly D2 = 95; - public static readonly D3 = 96; - public static readonly D4 = 97; - public static readonly D5 = 98; - public static readonly D6 = 99; - public static readonly D7 = 100; - public static readonly D8 = 101; - public static readonly D9 = 102; - public static readonly D0 = 103; - public static readonly OtherChar = 104; + public static readonly Quoted = 1; + public static readonly BlockQuoted = 2; + public static readonly BellChar = 3; + public static readonly ControlChar = 4; + public static readonly EscapeChar = 5; + public static readonly FormFeed = 6; + public static readonly NewLine = 7; + public static readonly CarriageReturn = 8; + public static readonly Tab = 9; + public static readonly Backslash = 10; + public static readonly HexChar = 11; + public static readonly Dot = 12; + public static readonly DecimalDigit = 13; + public static readonly NotDecimalDigit = 14; + public static readonly CharWithProperty = 15; + public static readonly CharWithoutProperty = 16; + public static readonly WhiteSpace = 17; + public static readonly NotWhiteSpace = 18; + public static readonly WordChar = 19; + public static readonly NotWordChar = 20; + public static readonly CharacterClassStart = 21; + public static readonly CharacterClassEnd = 22; + public static readonly Caret = 23; + public static readonly Hyphen = 24; + public static readonly QuestionMark = 25; + public static readonly Plus = 26; + public static readonly Star = 27; + public static readonly OpenBrace = 28; + public static readonly CloseBrace = 29; + public static readonly Comma = 30; + public static readonly EndOfSubject = 31; + public static readonly Pipe = 32; + public static readonly OpenParen = 33; + public static readonly CloseParen = 34; + public static readonly LessThan = 35; + public static readonly GreaterThan = 36; + public static readonly SingleQuote = 37; + public static readonly Underscore = 38; + public static readonly Colon = 39; + public static readonly Hash = 40; + public static readonly Equals = 41; + public static readonly Exclamation = 42; + public static readonly Ampersand = 43; + public static readonly ALC = 44; + public static readonly BLC = 45; + public static readonly CLC = 46; + public static readonly DLC = 47; + public static readonly ELC = 48; + public static readonly FLC = 49; + public static readonly GLC = 50; + public static readonly HLC = 51; + public static readonly ILC = 52; + public static readonly JLC = 53; + public static readonly KLC = 54; + public static readonly LLC = 55; + public static readonly MLC = 56; + public static readonly NLC = 57; + public static readonly OLC = 58; + public static readonly PLC = 59; + public static readonly QLC = 60; + public static readonly RLC = 61; + public static readonly SLC = 62; + public static readonly TLC = 63; + public static readonly ULC = 64; + public static readonly VLC = 65; + public static readonly WLC = 66; + public static readonly XLC = 67; + public static readonly YLC = 68; + public static readonly ZLC = 69; + public static readonly AUC = 70; + public static readonly BUC = 71; + public static readonly CUC = 72; + public static readonly DUC = 73; + public static readonly EUC = 74; + public static readonly FUC = 75; + public static readonly GUC = 76; + public static readonly HUC = 77; + public static readonly IUC = 78; + public static readonly JUC = 79; + public static readonly KUC = 80; + public static readonly LUC = 81; + public static readonly MUC = 82; + public static readonly NUC = 83; + public static readonly OUC = 84; + public static readonly PUC = 85; + public static readonly QUC = 86; + public static readonly RUC = 87; + public static readonly SUC = 88; + public static readonly TUC = 89; + public static readonly UUC = 90; + public static readonly VUC = 91; + public static readonly WUC = 92; + public static readonly XUC = 93; + public static readonly YUC = 94; + public static readonly ZUC = 95; + public static readonly D1 = 96; + public static readonly D2 = 97; + public static readonly D3 = 98; + public static readonly D4 = 99; + public static readonly D5 = 100; + public static readonly D6 = 101; + public static readonly D7 = 102; + public static readonly D8 = 103; + public static readonly D9 = 104; + public static readonly D0 = 105; + public static readonly OtherChar = 106; public static readonly RULE_parse = 0; public static readonly RULE_alternation = 1; public static readonly RULE_expr = 2; @@ -176,33 +178,34 @@ export class CommonRegexParser extends Parser { ]; private static readonly _LITERAL_NAMES: Array = [ - undefined, "'\\a'", "'\\c'", "'\\e'", "'\\f'", "'\\n'", "'\\r'", "'\\t'", - "'\\'", undefined, "'.'", "'\\d'", "'\\D'", undefined, undefined, "'\\s'", - "'\\S'", "'\\w'", "'\\W'", "'['", "']'", "'^'", "'-'", "'?'", "'+'", "'*'", - "'{'", "'}'", "','", "'$'", "'|'", "'('", "')'", "'<'", "'>'", "'''", - "'_'", "':'", "'#'", "'='", "'!'", "'&'", "'a'", "'b'", "'c'", "'d'", - "'e'", "'f'", "'g'", "'h'", "'i'", "'j'", "'k'", "'l'", "'m'", "'n'", - "'o'", "'p'", "'q'", "'r'", "'s'", "'t'", "'u'", "'v'", "'w'", "'x'", - "'y'", "'z'", "'A'", "'B'", "'C'", "'D'", "'E'", "'F'", "'G'", "'H'", - "'I'", "'J'", "'K'", "'L'", "'M'", "'N'", "'O'", "'P'", "'Q'", "'R'", - "'S'", "'T'", "'U'", "'V'", "'W'", "'X'", "'Y'", "'Z'", "'1'", "'2'", - "'3'", "'4'", "'5'", "'6'", "'7'", "'8'", "'9'", "'0'", + undefined, undefined, undefined, "'\\a'", "'\\c'", "'\\e'", "'\\f'", "'\\n'", + "'\\r'", "'\\t'", "'\\'", undefined, "'.'", "'\\d'", "'\\D'", undefined, + undefined, "'\\s'", "'\\S'", "'\\w'", "'\\W'", "'['", "']'", "'^'", "'-'", + "'?'", "'+'", "'*'", "'{'", "'}'", "','", "'$'", "'|'", "'('", "')'", + "'<'", "'>'", "'''", "'_'", "':'", "'#'", "'='", "'!'", "'&'", "'a'", + "'b'", "'c'", "'d'", "'e'", "'f'", "'g'", "'h'", "'i'", "'j'", "'k'", + "'l'", "'m'", "'n'", "'o'", "'p'", "'q'", "'r'", "'s'", "'t'", "'u'", + "'v'", "'w'", "'x'", "'y'", "'z'", "'A'", "'B'", "'C'", "'D'", "'E'", + "'F'", "'G'", "'H'", "'I'", "'J'", "'K'", "'L'", "'M'", "'N'", "'O'", + "'P'", "'Q'", "'R'", "'S'", "'T'", "'U'", "'V'", "'W'", "'X'", "'Y'", + "'Z'", "'1'", "'2'", "'3'", "'4'", "'5'", "'6'", "'7'", "'8'", "'9'", + "'0'", ]; private static readonly _SYMBOLIC_NAMES: Array = [ - undefined, "BellChar", "ControlChar", "EscapeChar", "FormFeed", "NewLine", - "CarriageReturn", "Tab", "Backslash", "HexChar", "Dot", "DecimalDigit", - "NotDecimalDigit", "CharWithProperty", "CharWithoutProperty", "WhiteSpace", - "NotWhiteSpace", "WordChar", "NotWordChar", "CharacterClassStart", "CharacterClassEnd", - "Caret", "Hyphen", "QuestionMark", "Plus", "Star", "OpenBrace", "CloseBrace", - "Comma", "EndOfSubject", "Pipe", "OpenParen", "CloseParen", "LessThan", - "GreaterThan", "SingleQuote", "Underscore", "Colon", "Hash", "Equals", - "Exclamation", "Ampersand", "ALC", "BLC", "CLC", "DLC", "ELC", "FLC", - "GLC", "HLC", "ILC", "JLC", "KLC", "LLC", "MLC", "NLC", "OLC", "PLC", - "QLC", "RLC", "SLC", "TLC", "ULC", "VLC", "WLC", "XLC", "YLC", "ZLC", - "AUC", "BUC", "CUC", "DUC", "EUC", "FUC", "GUC", "HUC", "IUC", "JUC", - "KUC", "LUC", "MUC", "NUC", "OUC", "PUC", "QUC", "RUC", "SUC", "TUC", - "UUC", "VUC", "WUC", "XUC", "YUC", "ZUC", "D1", "D2", "D3", "D4", "D5", - "D6", "D7", "D8", "D9", "D0", "OtherChar", + undefined, "Quoted", "BlockQuoted", "BellChar", "ControlChar", "EscapeChar", + "FormFeed", "NewLine", "CarriageReturn", "Tab", "Backslash", "HexChar", + "Dot", "DecimalDigit", "NotDecimalDigit", "CharWithProperty", "CharWithoutProperty", + "WhiteSpace", "NotWhiteSpace", "WordChar", "NotWordChar", "CharacterClassStart", + "CharacterClassEnd", "Caret", "Hyphen", "QuestionMark", "Plus", "Star", + "OpenBrace", "CloseBrace", "Comma", "EndOfSubject", "Pipe", "OpenParen", + "CloseParen", "LessThan", "GreaterThan", "SingleQuote", "Underscore", + "Colon", "Hash", "Equals", "Exclamation", "Ampersand", "ALC", "BLC", "CLC", + "DLC", "ELC", "FLC", "GLC", "HLC", "ILC", "JLC", "KLC", "LLC", "MLC", + "NLC", "OLC", "PLC", "QLC", "RLC", "SLC", "TLC", "ULC", "VLC", "WLC", + "XLC", "YLC", "ZLC", "AUC", "BUC", "CUC", "DUC", "EUC", "FUC", "GUC", + "HUC", "IUC", "JUC", "KUC", "LUC", "MUC", "NUC", "OUC", "PUC", "QUC", + "RUC", "SUC", "TUC", "UUC", "VUC", "WUC", "XUC", "YUC", "ZUC", "D1", "D2", + "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D0", "OtherChar", ]; public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(CommonRegexParser._LITERAL_NAMES, CommonRegexParser._SYMBOLIC_NAMES, []); @@ -306,7 +309,7 @@ export class CommonRegexParser extends Parser { this.state = 68; this._errHandler.sync(this); _la = this._input.LA(1); - while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << CommonRegexParser.BellChar) | (1 << CommonRegexParser.ControlChar) | (1 << CommonRegexParser.EscapeChar) | (1 << CommonRegexParser.FormFeed) | (1 << CommonRegexParser.NewLine) | (1 << CommonRegexParser.CarriageReturn) | (1 << CommonRegexParser.Tab) | (1 << CommonRegexParser.Backslash) | (1 << CommonRegexParser.HexChar) | (1 << CommonRegexParser.Dot) | (1 << CommonRegexParser.DecimalDigit) | (1 << CommonRegexParser.NotDecimalDigit) | (1 << CommonRegexParser.CharWithProperty) | (1 << CommonRegexParser.CharWithoutProperty) | (1 << CommonRegexParser.WhiteSpace) | (1 << CommonRegexParser.NotWhiteSpace) | (1 << CommonRegexParser.WordChar) | (1 << CommonRegexParser.NotWordChar) | (1 << CommonRegexParser.CharacterClassStart) | (1 << CommonRegexParser.CharacterClassEnd) | (1 << CommonRegexParser.Caret) | (1 << CommonRegexParser.Hyphen) | (1 << CommonRegexParser.OpenBrace) | (1 << CommonRegexParser.CloseBrace) | (1 << CommonRegexParser.Comma) | (1 << CommonRegexParser.EndOfSubject) | (1 << CommonRegexParser.OpenParen))) !== 0) || ((((_la - 33)) & ~0x1F) === 0 && ((1 << (_la - 33)) & ((1 << (CommonRegexParser.LessThan - 33)) | (1 << (CommonRegexParser.GreaterThan - 33)) | (1 << (CommonRegexParser.SingleQuote - 33)) | (1 << (CommonRegexParser.Underscore - 33)) | (1 << (CommonRegexParser.Colon - 33)) | (1 << (CommonRegexParser.Hash - 33)) | (1 << (CommonRegexParser.Equals - 33)) | (1 << (CommonRegexParser.Exclamation - 33)) | (1 << (CommonRegexParser.Ampersand - 33)) | (1 << (CommonRegexParser.ALC - 33)) | (1 << (CommonRegexParser.BLC - 33)) | (1 << (CommonRegexParser.CLC - 33)) | (1 << (CommonRegexParser.DLC - 33)) | (1 << (CommonRegexParser.ELC - 33)) | (1 << (CommonRegexParser.FLC - 33)) | (1 << (CommonRegexParser.GLC - 33)) | (1 << (CommonRegexParser.HLC - 33)) | (1 << (CommonRegexParser.ILC - 33)) | (1 << (CommonRegexParser.JLC - 33)) | (1 << (CommonRegexParser.KLC - 33)) | (1 << (CommonRegexParser.LLC - 33)) | (1 << (CommonRegexParser.MLC - 33)) | (1 << (CommonRegexParser.NLC - 33)) | (1 << (CommonRegexParser.OLC - 33)) | (1 << (CommonRegexParser.PLC - 33)) | (1 << (CommonRegexParser.QLC - 33)) | (1 << (CommonRegexParser.RLC - 33)) | (1 << (CommonRegexParser.SLC - 33)) | (1 << (CommonRegexParser.TLC - 33)) | (1 << (CommonRegexParser.ULC - 33)) | (1 << (CommonRegexParser.VLC - 33)) | (1 << (CommonRegexParser.WLC - 33)))) !== 0) || ((((_la - 65)) & ~0x1F) === 0 && ((1 << (_la - 65)) & ((1 << (CommonRegexParser.XLC - 65)) | (1 << (CommonRegexParser.YLC - 65)) | (1 << (CommonRegexParser.ZLC - 65)) | (1 << (CommonRegexParser.AUC - 65)) | (1 << (CommonRegexParser.BUC - 65)) | (1 << (CommonRegexParser.CUC - 65)) | (1 << (CommonRegexParser.DUC - 65)) | (1 << (CommonRegexParser.EUC - 65)) | (1 << (CommonRegexParser.FUC - 65)) | (1 << (CommonRegexParser.GUC - 65)) | (1 << (CommonRegexParser.HUC - 65)) | (1 << (CommonRegexParser.IUC - 65)) | (1 << (CommonRegexParser.JUC - 65)) | (1 << (CommonRegexParser.KUC - 65)) | (1 << (CommonRegexParser.LUC - 65)) | (1 << (CommonRegexParser.MUC - 65)) | (1 << (CommonRegexParser.NUC - 65)) | (1 << (CommonRegexParser.OUC - 65)) | (1 << (CommonRegexParser.PUC - 65)) | (1 << (CommonRegexParser.QUC - 65)) | (1 << (CommonRegexParser.RUC - 65)) | (1 << (CommonRegexParser.SUC - 65)) | (1 << (CommonRegexParser.TUC - 65)) | (1 << (CommonRegexParser.UUC - 65)) | (1 << (CommonRegexParser.VUC - 65)) | (1 << (CommonRegexParser.WUC - 65)) | (1 << (CommonRegexParser.XUC - 65)) | (1 << (CommonRegexParser.YUC - 65)) | (1 << (CommonRegexParser.ZUC - 65)) | (1 << (CommonRegexParser.D1 - 65)) | (1 << (CommonRegexParser.D2 - 65)) | (1 << (CommonRegexParser.D3 - 65)))) !== 0) || ((((_la - 97)) & ~0x1F) === 0 && ((1 << (_la - 97)) & ((1 << (CommonRegexParser.D4 - 97)) | (1 << (CommonRegexParser.D5 - 97)) | (1 << (CommonRegexParser.D6 - 97)) | (1 << (CommonRegexParser.D7 - 97)) | (1 << (CommonRegexParser.D8 - 97)) | (1 << (CommonRegexParser.D9 - 97)) | (1 << (CommonRegexParser.D0 - 97)) | (1 << (CommonRegexParser.OtherChar - 97)))) !== 0)) { + while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << CommonRegexParser.Quoted) | (1 << CommonRegexParser.BlockQuoted) | (1 << CommonRegexParser.BellChar) | (1 << CommonRegexParser.ControlChar) | (1 << CommonRegexParser.EscapeChar) | (1 << CommonRegexParser.FormFeed) | (1 << CommonRegexParser.NewLine) | (1 << CommonRegexParser.CarriageReturn) | (1 << CommonRegexParser.Tab) | (1 << CommonRegexParser.Backslash) | (1 << CommonRegexParser.HexChar) | (1 << CommonRegexParser.Dot) | (1 << CommonRegexParser.DecimalDigit) | (1 << CommonRegexParser.NotDecimalDigit) | (1 << CommonRegexParser.CharWithProperty) | (1 << CommonRegexParser.CharWithoutProperty) | (1 << CommonRegexParser.WhiteSpace) | (1 << CommonRegexParser.NotWhiteSpace) | (1 << CommonRegexParser.WordChar) | (1 << CommonRegexParser.NotWordChar) | (1 << CommonRegexParser.CharacterClassStart) | (1 << CommonRegexParser.CharacterClassEnd) | (1 << CommonRegexParser.Caret) | (1 << CommonRegexParser.Hyphen) | (1 << CommonRegexParser.OpenBrace) | (1 << CommonRegexParser.CloseBrace) | (1 << CommonRegexParser.Comma) | (1 << CommonRegexParser.EndOfSubject))) !== 0) || ((((_la - 33)) & ~0x1F) === 0 && ((1 << (_la - 33)) & ((1 << (CommonRegexParser.OpenParen - 33)) | (1 << (CommonRegexParser.LessThan - 33)) | (1 << (CommonRegexParser.GreaterThan - 33)) | (1 << (CommonRegexParser.SingleQuote - 33)) | (1 << (CommonRegexParser.Underscore - 33)) | (1 << (CommonRegexParser.Colon - 33)) | (1 << (CommonRegexParser.Hash - 33)) | (1 << (CommonRegexParser.Equals - 33)) | (1 << (CommonRegexParser.Exclamation - 33)) | (1 << (CommonRegexParser.Ampersand - 33)) | (1 << (CommonRegexParser.ALC - 33)) | (1 << (CommonRegexParser.BLC - 33)) | (1 << (CommonRegexParser.CLC - 33)) | (1 << (CommonRegexParser.DLC - 33)) | (1 << (CommonRegexParser.ELC - 33)) | (1 << (CommonRegexParser.FLC - 33)) | (1 << (CommonRegexParser.GLC - 33)) | (1 << (CommonRegexParser.HLC - 33)) | (1 << (CommonRegexParser.ILC - 33)) | (1 << (CommonRegexParser.JLC - 33)) | (1 << (CommonRegexParser.KLC - 33)) | (1 << (CommonRegexParser.LLC - 33)) | (1 << (CommonRegexParser.MLC - 33)) | (1 << (CommonRegexParser.NLC - 33)) | (1 << (CommonRegexParser.OLC - 33)) | (1 << (CommonRegexParser.PLC - 33)) | (1 << (CommonRegexParser.QLC - 33)) | (1 << (CommonRegexParser.RLC - 33)) | (1 << (CommonRegexParser.SLC - 33)) | (1 << (CommonRegexParser.TLC - 33)) | (1 << (CommonRegexParser.ULC - 33)))) !== 0) || ((((_la - 65)) & ~0x1F) === 0 && ((1 << (_la - 65)) & ((1 << (CommonRegexParser.VLC - 65)) | (1 << (CommonRegexParser.WLC - 65)) | (1 << (CommonRegexParser.XLC - 65)) | (1 << (CommonRegexParser.YLC - 65)) | (1 << (CommonRegexParser.ZLC - 65)) | (1 << (CommonRegexParser.AUC - 65)) | (1 << (CommonRegexParser.BUC - 65)) | (1 << (CommonRegexParser.CUC - 65)) | (1 << (CommonRegexParser.DUC - 65)) | (1 << (CommonRegexParser.EUC - 65)) | (1 << (CommonRegexParser.FUC - 65)) | (1 << (CommonRegexParser.GUC - 65)) | (1 << (CommonRegexParser.HUC - 65)) | (1 << (CommonRegexParser.IUC - 65)) | (1 << (CommonRegexParser.JUC - 65)) | (1 << (CommonRegexParser.KUC - 65)) | (1 << (CommonRegexParser.LUC - 65)) | (1 << (CommonRegexParser.MUC - 65)) | (1 << (CommonRegexParser.NUC - 65)) | (1 << (CommonRegexParser.OUC - 65)) | (1 << (CommonRegexParser.PUC - 65)) | (1 << (CommonRegexParser.QUC - 65)) | (1 << (CommonRegexParser.RUC - 65)) | (1 << (CommonRegexParser.SUC - 65)) | (1 << (CommonRegexParser.TUC - 65)) | (1 << (CommonRegexParser.UUC - 65)) | (1 << (CommonRegexParser.VUC - 65)) | (1 << (CommonRegexParser.WUC - 65)) | (1 << (CommonRegexParser.XUC - 65)) | (1 << (CommonRegexParser.YUC - 65)) | (1 << (CommonRegexParser.ZUC - 65)) | (1 << (CommonRegexParser.D1 - 65)))) !== 0) || ((((_la - 97)) & ~0x1F) === 0 && ((1 << (_la - 97)) & ((1 << (CommonRegexParser.D2 - 97)) | (1 << (CommonRegexParser.D3 - 97)) | (1 << (CommonRegexParser.D4 - 97)) | (1 << (CommonRegexParser.D5 - 97)) | (1 << (CommonRegexParser.D6 - 97)) | (1 << (CommonRegexParser.D7 - 97)) | (1 << (CommonRegexParser.D8 - 97)) | (1 << (CommonRegexParser.D9 - 97)) | (1 << (CommonRegexParser.D0 - 97)) | (1 << (CommonRegexParser.OtherChar - 97)))) !== 0)) { { { this.state = 65; @@ -492,6 +495,8 @@ export class CommonRegexParser extends Parser { } break; case CommonRegexParser.EOF: + case CommonRegexParser.Quoted: + case CommonRegexParser.BlockQuoted: case CommonRegexParser.BellChar: case CommonRegexParser.ControlChar: case CommonRegexParser.EscapeChar: @@ -645,7 +650,7 @@ export class CommonRegexParser extends Parser { this.state = 111; this._errHandler.sync(this); _la = this._input.LA(1); - } while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << CommonRegexParser.BellChar) | (1 << CommonRegexParser.ControlChar) | (1 << CommonRegexParser.EscapeChar) | (1 << CommonRegexParser.FormFeed) | (1 << CommonRegexParser.NewLine) | (1 << CommonRegexParser.CarriageReturn) | (1 << CommonRegexParser.Tab) | (1 << CommonRegexParser.Backslash) | (1 << CommonRegexParser.HexChar) | (1 << CommonRegexParser.Dot) | (1 << CommonRegexParser.DecimalDigit) | (1 << CommonRegexParser.NotDecimalDigit) | (1 << CommonRegexParser.CharWithProperty) | (1 << CommonRegexParser.CharWithoutProperty) | (1 << CommonRegexParser.WhiteSpace) | (1 << CommonRegexParser.NotWhiteSpace) | (1 << CommonRegexParser.WordChar) | (1 << CommonRegexParser.NotWordChar) | (1 << CommonRegexParser.CharacterClassStart) | (1 << CommonRegexParser.Caret) | (1 << CommonRegexParser.Hyphen) | (1 << CommonRegexParser.QuestionMark) | (1 << CommonRegexParser.Plus) | (1 << CommonRegexParser.Star) | (1 << CommonRegexParser.OpenBrace) | (1 << CommonRegexParser.CloseBrace) | (1 << CommonRegexParser.Comma) | (1 << CommonRegexParser.EndOfSubject) | (1 << CommonRegexParser.Pipe) | (1 << CommonRegexParser.OpenParen))) !== 0) || ((((_la - 32)) & ~0x1F) === 0 && ((1 << (_la - 32)) & ((1 << (CommonRegexParser.CloseParen - 32)) | (1 << (CommonRegexParser.LessThan - 32)) | (1 << (CommonRegexParser.GreaterThan - 32)) | (1 << (CommonRegexParser.SingleQuote - 32)) | (1 << (CommonRegexParser.Underscore - 32)) | (1 << (CommonRegexParser.Colon - 32)) | (1 << (CommonRegexParser.Hash - 32)) | (1 << (CommonRegexParser.Equals - 32)) | (1 << (CommonRegexParser.Exclamation - 32)) | (1 << (CommonRegexParser.Ampersand - 32)) | (1 << (CommonRegexParser.ALC - 32)) | (1 << (CommonRegexParser.BLC - 32)) | (1 << (CommonRegexParser.CLC - 32)) | (1 << (CommonRegexParser.DLC - 32)) | (1 << (CommonRegexParser.ELC - 32)) | (1 << (CommonRegexParser.FLC - 32)) | (1 << (CommonRegexParser.GLC - 32)) | (1 << (CommonRegexParser.HLC - 32)) | (1 << (CommonRegexParser.ILC - 32)) | (1 << (CommonRegexParser.JLC - 32)) | (1 << (CommonRegexParser.KLC - 32)) | (1 << (CommonRegexParser.LLC - 32)) | (1 << (CommonRegexParser.MLC - 32)) | (1 << (CommonRegexParser.NLC - 32)) | (1 << (CommonRegexParser.OLC - 32)) | (1 << (CommonRegexParser.PLC - 32)) | (1 << (CommonRegexParser.QLC - 32)) | (1 << (CommonRegexParser.RLC - 32)) | (1 << (CommonRegexParser.SLC - 32)) | (1 << (CommonRegexParser.TLC - 32)) | (1 << (CommonRegexParser.ULC - 32)) | (1 << (CommonRegexParser.VLC - 32)))) !== 0) || ((((_la - 64)) & ~0x1F) === 0 && ((1 << (_la - 64)) & ((1 << (CommonRegexParser.WLC - 64)) | (1 << (CommonRegexParser.XLC - 64)) | (1 << (CommonRegexParser.YLC - 64)) | (1 << (CommonRegexParser.ZLC - 64)) | (1 << (CommonRegexParser.AUC - 64)) | (1 << (CommonRegexParser.BUC - 64)) | (1 << (CommonRegexParser.CUC - 64)) | (1 << (CommonRegexParser.DUC - 64)) | (1 << (CommonRegexParser.EUC - 64)) | (1 << (CommonRegexParser.FUC - 64)) | (1 << (CommonRegexParser.GUC - 64)) | (1 << (CommonRegexParser.HUC - 64)) | (1 << (CommonRegexParser.IUC - 64)) | (1 << (CommonRegexParser.JUC - 64)) | (1 << (CommonRegexParser.KUC - 64)) | (1 << (CommonRegexParser.LUC - 64)) | (1 << (CommonRegexParser.MUC - 64)) | (1 << (CommonRegexParser.NUC - 64)) | (1 << (CommonRegexParser.OUC - 64)) | (1 << (CommonRegexParser.PUC - 64)) | (1 << (CommonRegexParser.QUC - 64)) | (1 << (CommonRegexParser.RUC - 64)) | (1 << (CommonRegexParser.SUC - 64)) | (1 << (CommonRegexParser.TUC - 64)) | (1 << (CommonRegexParser.UUC - 64)) | (1 << (CommonRegexParser.VUC - 64)) | (1 << (CommonRegexParser.WUC - 64)) | (1 << (CommonRegexParser.XUC - 64)) | (1 << (CommonRegexParser.YUC - 64)) | (1 << (CommonRegexParser.ZUC - 64)) | (1 << (CommonRegexParser.D1 - 64)) | (1 << (CommonRegexParser.D2 - 64)))) !== 0) || ((((_la - 96)) & ~0x1F) === 0 && ((1 << (_la - 96)) & ((1 << (CommonRegexParser.D3 - 96)) | (1 << (CommonRegexParser.D4 - 96)) | (1 << (CommonRegexParser.D5 - 96)) | (1 << (CommonRegexParser.D6 - 96)) | (1 << (CommonRegexParser.D7 - 96)) | (1 << (CommonRegexParser.D8 - 96)) | (1 << (CommonRegexParser.D9 - 96)) | (1 << (CommonRegexParser.D0 - 96)) | (1 << (CommonRegexParser.OtherChar - 96)))) !== 0)); + } while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << CommonRegexParser.Quoted) | (1 << CommonRegexParser.BlockQuoted) | (1 << CommonRegexParser.BellChar) | (1 << CommonRegexParser.ControlChar) | (1 << CommonRegexParser.EscapeChar) | (1 << CommonRegexParser.FormFeed) | (1 << CommonRegexParser.NewLine) | (1 << CommonRegexParser.CarriageReturn) | (1 << CommonRegexParser.Tab) | (1 << CommonRegexParser.Backslash) | (1 << CommonRegexParser.HexChar) | (1 << CommonRegexParser.Dot) | (1 << CommonRegexParser.DecimalDigit) | (1 << CommonRegexParser.NotDecimalDigit) | (1 << CommonRegexParser.CharWithProperty) | (1 << CommonRegexParser.CharWithoutProperty) | (1 << CommonRegexParser.WhiteSpace) | (1 << CommonRegexParser.NotWhiteSpace) | (1 << CommonRegexParser.WordChar) | (1 << CommonRegexParser.NotWordChar) | (1 << CommonRegexParser.CharacterClassStart) | (1 << CommonRegexParser.Caret) | (1 << CommonRegexParser.Hyphen) | (1 << CommonRegexParser.QuestionMark) | (1 << CommonRegexParser.Plus) | (1 << CommonRegexParser.Star) | (1 << CommonRegexParser.OpenBrace) | (1 << CommonRegexParser.CloseBrace) | (1 << CommonRegexParser.Comma) | (1 << CommonRegexParser.EndOfSubject))) !== 0) || ((((_la - 32)) & ~0x1F) === 0 && ((1 << (_la - 32)) & ((1 << (CommonRegexParser.Pipe - 32)) | (1 << (CommonRegexParser.OpenParen - 32)) | (1 << (CommonRegexParser.CloseParen - 32)) | (1 << (CommonRegexParser.LessThan - 32)) | (1 << (CommonRegexParser.GreaterThan - 32)) | (1 << (CommonRegexParser.SingleQuote - 32)) | (1 << (CommonRegexParser.Underscore - 32)) | (1 << (CommonRegexParser.Colon - 32)) | (1 << (CommonRegexParser.Hash - 32)) | (1 << (CommonRegexParser.Equals - 32)) | (1 << (CommonRegexParser.Exclamation - 32)) | (1 << (CommonRegexParser.Ampersand - 32)) | (1 << (CommonRegexParser.ALC - 32)) | (1 << (CommonRegexParser.BLC - 32)) | (1 << (CommonRegexParser.CLC - 32)) | (1 << (CommonRegexParser.DLC - 32)) | (1 << (CommonRegexParser.ELC - 32)) | (1 << (CommonRegexParser.FLC - 32)) | (1 << (CommonRegexParser.GLC - 32)) | (1 << (CommonRegexParser.HLC - 32)) | (1 << (CommonRegexParser.ILC - 32)) | (1 << (CommonRegexParser.JLC - 32)) | (1 << (CommonRegexParser.KLC - 32)) | (1 << (CommonRegexParser.LLC - 32)) | (1 << (CommonRegexParser.MLC - 32)) | (1 << (CommonRegexParser.NLC - 32)) | (1 << (CommonRegexParser.OLC - 32)) | (1 << (CommonRegexParser.PLC - 32)) | (1 << (CommonRegexParser.QLC - 32)) | (1 << (CommonRegexParser.RLC - 32)) | (1 << (CommonRegexParser.SLC - 32)) | (1 << (CommonRegexParser.TLC - 32)))) !== 0) || ((((_la - 64)) & ~0x1F) === 0 && ((1 << (_la - 64)) & ((1 << (CommonRegexParser.ULC - 64)) | (1 << (CommonRegexParser.VLC - 64)) | (1 << (CommonRegexParser.WLC - 64)) | (1 << (CommonRegexParser.XLC - 64)) | (1 << (CommonRegexParser.YLC - 64)) | (1 << (CommonRegexParser.ZLC - 64)) | (1 << (CommonRegexParser.AUC - 64)) | (1 << (CommonRegexParser.BUC - 64)) | (1 << (CommonRegexParser.CUC - 64)) | (1 << (CommonRegexParser.DUC - 64)) | (1 << (CommonRegexParser.EUC - 64)) | (1 << (CommonRegexParser.FUC - 64)) | (1 << (CommonRegexParser.GUC - 64)) | (1 << (CommonRegexParser.HUC - 64)) | (1 << (CommonRegexParser.IUC - 64)) | (1 << (CommonRegexParser.JUC - 64)) | (1 << (CommonRegexParser.KUC - 64)) | (1 << (CommonRegexParser.LUC - 64)) | (1 << (CommonRegexParser.MUC - 64)) | (1 << (CommonRegexParser.NUC - 64)) | (1 << (CommonRegexParser.OUC - 64)) | (1 << (CommonRegexParser.PUC - 64)) | (1 << (CommonRegexParser.QUC - 64)) | (1 << (CommonRegexParser.RUC - 64)) | (1 << (CommonRegexParser.SUC - 64)) | (1 << (CommonRegexParser.TUC - 64)) | (1 << (CommonRegexParser.UUC - 64)) | (1 << (CommonRegexParser.VUC - 64)) | (1 << (CommonRegexParser.WUC - 64)) | (1 << (CommonRegexParser.XUC - 64)) | (1 << (CommonRegexParser.YUC - 64)) | (1 << (CommonRegexParser.ZUC - 64)))) !== 0) || ((((_la - 96)) & ~0x1F) === 0 && ((1 << (_la - 96)) & ((1 << (CommonRegexParser.D1 - 96)) | (1 << (CommonRegexParser.D2 - 96)) | (1 << (CommonRegexParser.D3 - 96)) | (1 << (CommonRegexParser.D4 - 96)) | (1 << (CommonRegexParser.D5 - 96)) | (1 << (CommonRegexParser.D6 - 96)) | (1 << (CommonRegexParser.D7 - 96)) | (1 << (CommonRegexParser.D8 - 96)) | (1 << (CommonRegexParser.D9 - 96)) | (1 << (CommonRegexParser.D0 - 96)) | (1 << (CommonRegexParser.OtherChar - 96)))) !== 0)); this.state = 113; this.match(CommonRegexParser.CharacterClassEnd); } @@ -669,7 +674,7 @@ export class CommonRegexParser extends Parser { this.state = 119; this._errHandler.sync(this); _la = this._input.LA(1); - } while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << CommonRegexParser.BellChar) | (1 << CommonRegexParser.ControlChar) | (1 << CommonRegexParser.EscapeChar) | (1 << CommonRegexParser.FormFeed) | (1 << CommonRegexParser.NewLine) | (1 << CommonRegexParser.CarriageReturn) | (1 << CommonRegexParser.Tab) | (1 << CommonRegexParser.Backslash) | (1 << CommonRegexParser.HexChar) | (1 << CommonRegexParser.Dot) | (1 << CommonRegexParser.DecimalDigit) | (1 << CommonRegexParser.NotDecimalDigit) | (1 << CommonRegexParser.CharWithProperty) | (1 << CommonRegexParser.CharWithoutProperty) | (1 << CommonRegexParser.WhiteSpace) | (1 << CommonRegexParser.NotWhiteSpace) | (1 << CommonRegexParser.WordChar) | (1 << CommonRegexParser.NotWordChar) | (1 << CommonRegexParser.CharacterClassStart) | (1 << CommonRegexParser.Caret) | (1 << CommonRegexParser.Hyphen) | (1 << CommonRegexParser.QuestionMark) | (1 << CommonRegexParser.Plus) | (1 << CommonRegexParser.Star) | (1 << CommonRegexParser.OpenBrace) | (1 << CommonRegexParser.CloseBrace) | (1 << CommonRegexParser.Comma) | (1 << CommonRegexParser.EndOfSubject) | (1 << CommonRegexParser.Pipe) | (1 << CommonRegexParser.OpenParen))) !== 0) || ((((_la - 32)) & ~0x1F) === 0 && ((1 << (_la - 32)) & ((1 << (CommonRegexParser.CloseParen - 32)) | (1 << (CommonRegexParser.LessThan - 32)) | (1 << (CommonRegexParser.GreaterThan - 32)) | (1 << (CommonRegexParser.SingleQuote - 32)) | (1 << (CommonRegexParser.Underscore - 32)) | (1 << (CommonRegexParser.Colon - 32)) | (1 << (CommonRegexParser.Hash - 32)) | (1 << (CommonRegexParser.Equals - 32)) | (1 << (CommonRegexParser.Exclamation - 32)) | (1 << (CommonRegexParser.Ampersand - 32)) | (1 << (CommonRegexParser.ALC - 32)) | (1 << (CommonRegexParser.BLC - 32)) | (1 << (CommonRegexParser.CLC - 32)) | (1 << (CommonRegexParser.DLC - 32)) | (1 << (CommonRegexParser.ELC - 32)) | (1 << (CommonRegexParser.FLC - 32)) | (1 << (CommonRegexParser.GLC - 32)) | (1 << (CommonRegexParser.HLC - 32)) | (1 << (CommonRegexParser.ILC - 32)) | (1 << (CommonRegexParser.JLC - 32)) | (1 << (CommonRegexParser.KLC - 32)) | (1 << (CommonRegexParser.LLC - 32)) | (1 << (CommonRegexParser.MLC - 32)) | (1 << (CommonRegexParser.NLC - 32)) | (1 << (CommonRegexParser.OLC - 32)) | (1 << (CommonRegexParser.PLC - 32)) | (1 << (CommonRegexParser.QLC - 32)) | (1 << (CommonRegexParser.RLC - 32)) | (1 << (CommonRegexParser.SLC - 32)) | (1 << (CommonRegexParser.TLC - 32)) | (1 << (CommonRegexParser.ULC - 32)) | (1 << (CommonRegexParser.VLC - 32)))) !== 0) || ((((_la - 64)) & ~0x1F) === 0 && ((1 << (_la - 64)) & ((1 << (CommonRegexParser.WLC - 64)) | (1 << (CommonRegexParser.XLC - 64)) | (1 << (CommonRegexParser.YLC - 64)) | (1 << (CommonRegexParser.ZLC - 64)) | (1 << (CommonRegexParser.AUC - 64)) | (1 << (CommonRegexParser.BUC - 64)) | (1 << (CommonRegexParser.CUC - 64)) | (1 << (CommonRegexParser.DUC - 64)) | (1 << (CommonRegexParser.EUC - 64)) | (1 << (CommonRegexParser.FUC - 64)) | (1 << (CommonRegexParser.GUC - 64)) | (1 << (CommonRegexParser.HUC - 64)) | (1 << (CommonRegexParser.IUC - 64)) | (1 << (CommonRegexParser.JUC - 64)) | (1 << (CommonRegexParser.KUC - 64)) | (1 << (CommonRegexParser.LUC - 64)) | (1 << (CommonRegexParser.MUC - 64)) | (1 << (CommonRegexParser.NUC - 64)) | (1 << (CommonRegexParser.OUC - 64)) | (1 << (CommonRegexParser.PUC - 64)) | (1 << (CommonRegexParser.QUC - 64)) | (1 << (CommonRegexParser.RUC - 64)) | (1 << (CommonRegexParser.SUC - 64)) | (1 << (CommonRegexParser.TUC - 64)) | (1 << (CommonRegexParser.UUC - 64)) | (1 << (CommonRegexParser.VUC - 64)) | (1 << (CommonRegexParser.WUC - 64)) | (1 << (CommonRegexParser.XUC - 64)) | (1 << (CommonRegexParser.YUC - 64)) | (1 << (CommonRegexParser.ZUC - 64)) | (1 << (CommonRegexParser.D1 - 64)) | (1 << (CommonRegexParser.D2 - 64)))) !== 0) || ((((_la - 96)) & ~0x1F) === 0 && ((1 << (_la - 96)) & ((1 << (CommonRegexParser.D3 - 96)) | (1 << (CommonRegexParser.D4 - 96)) | (1 << (CommonRegexParser.D5 - 96)) | (1 << (CommonRegexParser.D6 - 96)) | (1 << (CommonRegexParser.D7 - 96)) | (1 << (CommonRegexParser.D8 - 96)) | (1 << (CommonRegexParser.D9 - 96)) | (1 << (CommonRegexParser.D0 - 96)) | (1 << (CommonRegexParser.OtherChar - 96)))) !== 0)); + } while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << CommonRegexParser.Quoted) | (1 << CommonRegexParser.BlockQuoted) | (1 << CommonRegexParser.BellChar) | (1 << CommonRegexParser.ControlChar) | (1 << CommonRegexParser.EscapeChar) | (1 << CommonRegexParser.FormFeed) | (1 << CommonRegexParser.NewLine) | (1 << CommonRegexParser.CarriageReturn) | (1 << CommonRegexParser.Tab) | (1 << CommonRegexParser.Backslash) | (1 << CommonRegexParser.HexChar) | (1 << CommonRegexParser.Dot) | (1 << CommonRegexParser.DecimalDigit) | (1 << CommonRegexParser.NotDecimalDigit) | (1 << CommonRegexParser.CharWithProperty) | (1 << CommonRegexParser.CharWithoutProperty) | (1 << CommonRegexParser.WhiteSpace) | (1 << CommonRegexParser.NotWhiteSpace) | (1 << CommonRegexParser.WordChar) | (1 << CommonRegexParser.NotWordChar) | (1 << CommonRegexParser.CharacterClassStart) | (1 << CommonRegexParser.Caret) | (1 << CommonRegexParser.Hyphen) | (1 << CommonRegexParser.QuestionMark) | (1 << CommonRegexParser.Plus) | (1 << CommonRegexParser.Star) | (1 << CommonRegexParser.OpenBrace) | (1 << CommonRegexParser.CloseBrace) | (1 << CommonRegexParser.Comma) | (1 << CommonRegexParser.EndOfSubject))) !== 0) || ((((_la - 32)) & ~0x1F) === 0 && ((1 << (_la - 32)) & ((1 << (CommonRegexParser.Pipe - 32)) | (1 << (CommonRegexParser.OpenParen - 32)) | (1 << (CommonRegexParser.CloseParen - 32)) | (1 << (CommonRegexParser.LessThan - 32)) | (1 << (CommonRegexParser.GreaterThan - 32)) | (1 << (CommonRegexParser.SingleQuote - 32)) | (1 << (CommonRegexParser.Underscore - 32)) | (1 << (CommonRegexParser.Colon - 32)) | (1 << (CommonRegexParser.Hash - 32)) | (1 << (CommonRegexParser.Equals - 32)) | (1 << (CommonRegexParser.Exclamation - 32)) | (1 << (CommonRegexParser.Ampersand - 32)) | (1 << (CommonRegexParser.ALC - 32)) | (1 << (CommonRegexParser.BLC - 32)) | (1 << (CommonRegexParser.CLC - 32)) | (1 << (CommonRegexParser.DLC - 32)) | (1 << (CommonRegexParser.ELC - 32)) | (1 << (CommonRegexParser.FLC - 32)) | (1 << (CommonRegexParser.GLC - 32)) | (1 << (CommonRegexParser.HLC - 32)) | (1 << (CommonRegexParser.ILC - 32)) | (1 << (CommonRegexParser.JLC - 32)) | (1 << (CommonRegexParser.KLC - 32)) | (1 << (CommonRegexParser.LLC - 32)) | (1 << (CommonRegexParser.MLC - 32)) | (1 << (CommonRegexParser.NLC - 32)) | (1 << (CommonRegexParser.OLC - 32)) | (1 << (CommonRegexParser.PLC - 32)) | (1 << (CommonRegexParser.QLC - 32)) | (1 << (CommonRegexParser.RLC - 32)) | (1 << (CommonRegexParser.SLC - 32)) | (1 << (CommonRegexParser.TLC - 32)))) !== 0) || ((((_la - 64)) & ~0x1F) === 0 && ((1 << (_la - 64)) & ((1 << (CommonRegexParser.ULC - 64)) | (1 << (CommonRegexParser.VLC - 64)) | (1 << (CommonRegexParser.WLC - 64)) | (1 << (CommonRegexParser.XLC - 64)) | (1 << (CommonRegexParser.YLC - 64)) | (1 << (CommonRegexParser.ZLC - 64)) | (1 << (CommonRegexParser.AUC - 64)) | (1 << (CommonRegexParser.BUC - 64)) | (1 << (CommonRegexParser.CUC - 64)) | (1 << (CommonRegexParser.DUC - 64)) | (1 << (CommonRegexParser.EUC - 64)) | (1 << (CommonRegexParser.FUC - 64)) | (1 << (CommonRegexParser.GUC - 64)) | (1 << (CommonRegexParser.HUC - 64)) | (1 << (CommonRegexParser.IUC - 64)) | (1 << (CommonRegexParser.JUC - 64)) | (1 << (CommonRegexParser.KUC - 64)) | (1 << (CommonRegexParser.LUC - 64)) | (1 << (CommonRegexParser.MUC - 64)) | (1 << (CommonRegexParser.NUC - 64)) | (1 << (CommonRegexParser.OUC - 64)) | (1 << (CommonRegexParser.PUC - 64)) | (1 << (CommonRegexParser.QUC - 64)) | (1 << (CommonRegexParser.RUC - 64)) | (1 << (CommonRegexParser.SUC - 64)) | (1 << (CommonRegexParser.TUC - 64)) | (1 << (CommonRegexParser.UUC - 64)) | (1 << (CommonRegexParser.VUC - 64)) | (1 << (CommonRegexParser.WUC - 64)) | (1 << (CommonRegexParser.XUC - 64)) | (1 << (CommonRegexParser.YUC - 64)) | (1 << (CommonRegexParser.ZUC - 64)))) !== 0) || ((((_la - 96)) & ~0x1F) === 0 && ((1 << (_la - 96)) & ((1 << (CommonRegexParser.D1 - 96)) | (1 << (CommonRegexParser.D2 - 96)) | (1 << (CommonRegexParser.D3 - 96)) | (1 << (CommonRegexParser.D4 - 96)) | (1 << (CommonRegexParser.D5 - 96)) | (1 << (CommonRegexParser.D6 - 96)) | (1 << (CommonRegexParser.D7 - 96)) | (1 << (CommonRegexParser.D8 - 96)) | (1 << (CommonRegexParser.D9 - 96)) | (1 << (CommonRegexParser.D0 - 96)) | (1 << (CommonRegexParser.OtherChar - 96)))) !== 0)); this.state = 121; this.match(CommonRegexParser.CharacterClassEnd); } @@ -803,7 +808,7 @@ export class CommonRegexParser extends Parser { this.state = 150; this._errHandler.sync(this); _la = this._input.LA(1); - } while (((((_la - 50)) & ~0x1F) === 0 && ((1 << (_la - 50)) & ((1 << (CommonRegexParser.ILC - 50)) | (1 << (CommonRegexParser.MLC - 50)) | (1 << (CommonRegexParser.SLC - 50)))) !== 0)); + } while (((((_la - 52)) & ~0x1F) === 0 && ((1 << (_la - 52)) & ((1 << (CommonRegexParser.ILC - 52)) | (1 << (CommonRegexParser.MLC - 52)) | (1 << (CommonRegexParser.SLC - 52)))) !== 0)); this.state = 152; this.match(CommonRegexParser.CloseParen); } @@ -832,7 +837,7 @@ export class CommonRegexParser extends Parser { { this.state = 154; _la = this._input.LA(1); - if (!(((((_la - 50)) & ~0x1F) === 0 && ((1 << (_la - 50)) & ((1 << (CommonRegexParser.ILC - 50)) | (1 << (CommonRegexParser.MLC - 50)) | (1 << (CommonRegexParser.SLC - 50)))) !== 0))) { + if (!(((((_la - 52)) & ~0x1F) === 0 && ((1 << (_la - 52)) & ((1 << (CommonRegexParser.ILC - 52)) | (1 << (CommonRegexParser.MLC - 52)) | (1 << (CommonRegexParser.SLC - 52)))) !== 0))) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token.EOF) { @@ -1048,6 +1053,8 @@ export class CommonRegexParser extends Parser { this.state = 179; this._errHandler.sync(this); switch (this._input.LA(1)) { + case CommonRegexParser.Quoted: + case CommonRegexParser.BlockQuoted: case CommonRegexParser.BellChar: case CommonRegexParser.EscapeChar: case CommonRegexParser.FormFeed: @@ -1171,6 +1178,8 @@ export class CommonRegexParser extends Parser { this.state = 192; this._errHandler.sync(this); switch (this._input.LA(1)) { + case CommonRegexParser.Quoted: + case CommonRegexParser.BlockQuoted: case CommonRegexParser.BellChar: case CommonRegexParser.EscapeChar: case CommonRegexParser.FormFeed: @@ -1354,7 +1363,7 @@ export class CommonRegexParser extends Parser { let _localctx: Shared_literalContext = new Shared_literalContext(this._ctx, this.state); this.enterRule(_localctx, 32, CommonRegexParser.RULE_shared_literal); try { - this.state = 218; + this.state = 220; this._errHandler.sync(this); switch (this._input.LA(1)) { case CommonRegexParser.Backslash: @@ -1487,101 +1496,115 @@ export class CommonRegexParser extends Parser { this.match(CommonRegexParser.HexChar); } break; - case CommonRegexParser.OpenBrace: + case CommonRegexParser.Quoted: this.enterOuterAlt(_localctx, 11); { this.state = 204; - this.match(CommonRegexParser.OpenBrace); + this.match(CommonRegexParser.Quoted); } break; - case CommonRegexParser.CloseBrace: + case CommonRegexParser.BlockQuoted: this.enterOuterAlt(_localctx, 12); { this.state = 205; - this.match(CommonRegexParser.CloseBrace); + this.match(CommonRegexParser.BlockQuoted); } break; - case CommonRegexParser.Comma: + case CommonRegexParser.OpenBrace: this.enterOuterAlt(_localctx, 13); { this.state = 206; - this.match(CommonRegexParser.Comma); + this.match(CommonRegexParser.OpenBrace); } break; - case CommonRegexParser.Hyphen: + case CommonRegexParser.CloseBrace: this.enterOuterAlt(_localctx, 14); { this.state = 207; - this.match(CommonRegexParser.Hyphen); + this.match(CommonRegexParser.CloseBrace); } break; - case CommonRegexParser.LessThan: + case CommonRegexParser.Comma: this.enterOuterAlt(_localctx, 15); { this.state = 208; - this.match(CommonRegexParser.LessThan); + this.match(CommonRegexParser.Comma); } break; - case CommonRegexParser.GreaterThan: + case CommonRegexParser.Hyphen: this.enterOuterAlt(_localctx, 16); { this.state = 209; - this.match(CommonRegexParser.GreaterThan); + this.match(CommonRegexParser.Hyphen); } break; - case CommonRegexParser.SingleQuote: + case CommonRegexParser.LessThan: this.enterOuterAlt(_localctx, 17); { this.state = 210; - this.match(CommonRegexParser.SingleQuote); + this.match(CommonRegexParser.LessThan); } break; - case CommonRegexParser.Underscore: + case CommonRegexParser.GreaterThan: this.enterOuterAlt(_localctx, 18); { this.state = 211; - this.match(CommonRegexParser.Underscore); + this.match(CommonRegexParser.GreaterThan); } break; - case CommonRegexParser.Colon: + case CommonRegexParser.SingleQuote: this.enterOuterAlt(_localctx, 19); { this.state = 212; - this.match(CommonRegexParser.Colon); + this.match(CommonRegexParser.SingleQuote); } break; - case CommonRegexParser.Hash: + case CommonRegexParser.Underscore: this.enterOuterAlt(_localctx, 20); { this.state = 213; - this.match(CommonRegexParser.Hash); + this.match(CommonRegexParser.Underscore); } break; - case CommonRegexParser.Equals: + case CommonRegexParser.Colon: this.enterOuterAlt(_localctx, 21); { this.state = 214; - this.match(CommonRegexParser.Equals); + this.match(CommonRegexParser.Colon); } break; - case CommonRegexParser.Exclamation: + case CommonRegexParser.Hash: this.enterOuterAlt(_localctx, 22); { this.state = 215; - this.match(CommonRegexParser.Exclamation); + this.match(CommonRegexParser.Hash); } break; - case CommonRegexParser.Ampersand: + case CommonRegexParser.Equals: this.enterOuterAlt(_localctx, 23); { this.state = 216; - this.match(CommonRegexParser.Ampersand); + this.match(CommonRegexParser.Equals); } break; - case CommonRegexParser.OtherChar: + case CommonRegexParser.Exclamation: this.enterOuterAlt(_localctx, 24); { this.state = 217; + this.match(CommonRegexParser.Exclamation); + } + break; + case CommonRegexParser.Ampersand: + this.enterOuterAlt(_localctx, 25); + { + this.state = 218; + this.match(CommonRegexParser.Ampersand); + } + break; + case CommonRegexParser.OtherChar: + this.enterOuterAlt(_localctx, 26); + { + this.state = 219; this.match(CommonRegexParser.OtherChar); } break; @@ -1610,7 +1633,7 @@ export class CommonRegexParser extends Parser { try { this.enterOuterAlt(_localctx, 1); { - this.state = 220; + this.state = 222; this.digits(); } } @@ -1636,16 +1659,16 @@ export class CommonRegexParser extends Parser { try { this.enterOuterAlt(_localctx, 1); { - this.state = 231; + this.state = 233; this._errHandler.sync(this); switch ( this.interpreter.adaptivePredict(this._input, 15, this._ctx) ) { case 1: { - this.state = 222; + this.state = 224; this.match(CommonRegexParser.Backslash); - this.state = 223; + this.state = 225; _la = this._input.LA(1); - if (!(((((_la - 94)) & ~0x1F) === 0 && ((1 << (_la - 94)) & ((1 << (CommonRegexParser.D1 - 94)) | (1 << (CommonRegexParser.D2 - 94)) | (1 << (CommonRegexParser.D3 - 94)) | (1 << (CommonRegexParser.D0 - 94)))) !== 0))) { + if (!(((((_la - 96)) & ~0x1F) === 0 && ((1 << (_la - 96)) & ((1 << (CommonRegexParser.D1 - 96)) | (1 << (CommonRegexParser.D2 - 96)) | (1 << (CommonRegexParser.D3 - 96)) | (1 << (CommonRegexParser.D0 - 96)))) !== 0))) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token.EOF) { @@ -1655,20 +1678,20 @@ export class CommonRegexParser extends Parser { this._errHandler.reportMatch(this); this.consume(); } - this.state = 224; + this.state = 226; this.octal_digit(); - this.state = 225; + this.state = 227; this.octal_digit(); } break; case 2: { - this.state = 227; + this.state = 229; this.match(CommonRegexParser.Backslash); - this.state = 228; + this.state = 230; this.octal_digit(); - this.state = 229; + this.state = 231; this.octal_digit(); } break; @@ -1697,9 +1720,9 @@ export class CommonRegexParser extends Parser { try { this.enterOuterAlt(_localctx, 1); { - this.state = 233; + this.state = 235; _la = this._input.LA(1); - if (!(((((_la - 94)) & ~0x1F) === 0 && ((1 << (_la - 94)) & ((1 << (CommonRegexParser.D1 - 94)) | (1 << (CommonRegexParser.D2 - 94)) | (1 << (CommonRegexParser.D3 - 94)) | (1 << (CommonRegexParser.D4 - 94)) | (1 << (CommonRegexParser.D5 - 94)) | (1 << (CommonRegexParser.D6 - 94)) | (1 << (CommonRegexParser.D7 - 94)) | (1 << (CommonRegexParser.D0 - 94)))) !== 0))) { + if (!(((((_la - 96)) & ~0x1F) === 0 && ((1 << (_la - 96)) & ((1 << (CommonRegexParser.D1 - 96)) | (1 << (CommonRegexParser.D2 - 96)) | (1 << (CommonRegexParser.D3 - 96)) | (1 << (CommonRegexParser.D4 - 96)) | (1 << (CommonRegexParser.D5 - 96)) | (1 << (CommonRegexParser.D6 - 96)) | (1 << (CommonRegexParser.D7 - 96)) | (1 << (CommonRegexParser.D0 - 96)))) !== 0))) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token.EOF) { @@ -1733,20 +1756,20 @@ export class CommonRegexParser extends Parser { try { this.enterOuterAlt(_localctx, 1); { - this.state = 236; + this.state = 238; this._errHandler.sync(this); _la = this._input.LA(1); do { { { - this.state = 235; + this.state = 237; this.digit(); } } - this.state = 238; + this.state = 240; this._errHandler.sync(this); _la = this._input.LA(1); - } while (((((_la - 94)) & ~0x1F) === 0 && ((1 << (_la - 94)) & ((1 << (CommonRegexParser.D1 - 94)) | (1 << (CommonRegexParser.D2 - 94)) | (1 << (CommonRegexParser.D3 - 94)) | (1 << (CommonRegexParser.D4 - 94)) | (1 << (CommonRegexParser.D5 - 94)) | (1 << (CommonRegexParser.D6 - 94)) | (1 << (CommonRegexParser.D7 - 94)) | (1 << (CommonRegexParser.D8 - 94)) | (1 << (CommonRegexParser.D9 - 94)) | (1 << (CommonRegexParser.D0 - 94)))) !== 0)); + } while (((((_la - 96)) & ~0x1F) === 0 && ((1 << (_la - 96)) & ((1 << (CommonRegexParser.D1 - 96)) | (1 << (CommonRegexParser.D2 - 96)) | (1 << (CommonRegexParser.D3 - 96)) | (1 << (CommonRegexParser.D4 - 96)) | (1 << (CommonRegexParser.D5 - 96)) | (1 << (CommonRegexParser.D6 - 96)) | (1 << (CommonRegexParser.D7 - 96)) | (1 << (CommonRegexParser.D8 - 96)) | (1 << (CommonRegexParser.D9 - 96)) | (1 << (CommonRegexParser.D0 - 96)))) !== 0)); } } catch (re) { @@ -1771,9 +1794,9 @@ export class CommonRegexParser extends Parser { try { this.enterOuterAlt(_localctx, 1); { - this.state = 240; + this.state = 242; _la = this._input.LA(1); - if (!(((((_la - 94)) & ~0x1F) === 0 && ((1 << (_la - 94)) & ((1 << (CommonRegexParser.D1 - 94)) | (1 << (CommonRegexParser.D2 - 94)) | (1 << (CommonRegexParser.D3 - 94)) | (1 << (CommonRegexParser.D4 - 94)) | (1 << (CommonRegexParser.D5 - 94)) | (1 << (CommonRegexParser.D6 - 94)) | (1 << (CommonRegexParser.D7 - 94)) | (1 << (CommonRegexParser.D8 - 94)) | (1 << (CommonRegexParser.D9 - 94)) | (1 << (CommonRegexParser.D0 - 94)))) !== 0))) { + if (!(((((_la - 96)) & ~0x1F) === 0 && ((1 << (_la - 96)) & ((1 << (CommonRegexParser.D1 - 96)) | (1 << (CommonRegexParser.D2 - 96)) | (1 << (CommonRegexParser.D3 - 96)) | (1 << (CommonRegexParser.D4 - 96)) | (1 << (CommonRegexParser.D5 - 96)) | (1 << (CommonRegexParser.D6 - 96)) | (1 << (CommonRegexParser.D7 - 96)) | (1 << (CommonRegexParser.D8 - 96)) | (1 << (CommonRegexParser.D9 - 96)) | (1 << (CommonRegexParser.D0 - 96)))) !== 0))) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token.EOF) { @@ -1806,7 +1829,7 @@ export class CommonRegexParser extends Parser { try { this.enterOuterAlt(_localctx, 1); { - this.state = 242; + this.state = 244; this.alpha_nums(); } } @@ -1832,7 +1855,7 @@ export class CommonRegexParser extends Parser { try { this.enterOuterAlt(_localctx, 1); { - this.state = 246; + this.state = 248; this._errHandler.sync(this); switch (this._input.LA(1)) { case CommonRegexParser.ALC: @@ -1888,25 +1911,25 @@ export class CommonRegexParser extends Parser { case CommonRegexParser.YUC: case CommonRegexParser.ZUC: { - this.state = 244; + this.state = 246; this.letter(); } break; case CommonRegexParser.Underscore: { - this.state = 245; + this.state = 247; this.match(CommonRegexParser.Underscore); } break; default: throw new NoViableAltException(this); } - this.state = 253; + this.state = 255; this._errHandler.sync(this); _la = this._input.LA(1); - while (((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & ((1 << (CommonRegexParser.Underscore - 36)) | (1 << (CommonRegexParser.ALC - 36)) | (1 << (CommonRegexParser.BLC - 36)) | (1 << (CommonRegexParser.CLC - 36)) | (1 << (CommonRegexParser.DLC - 36)) | (1 << (CommonRegexParser.ELC - 36)) | (1 << (CommonRegexParser.FLC - 36)) | (1 << (CommonRegexParser.GLC - 36)) | (1 << (CommonRegexParser.HLC - 36)) | (1 << (CommonRegexParser.ILC - 36)) | (1 << (CommonRegexParser.JLC - 36)) | (1 << (CommonRegexParser.KLC - 36)) | (1 << (CommonRegexParser.LLC - 36)) | (1 << (CommonRegexParser.MLC - 36)) | (1 << (CommonRegexParser.NLC - 36)) | (1 << (CommonRegexParser.OLC - 36)) | (1 << (CommonRegexParser.PLC - 36)) | (1 << (CommonRegexParser.QLC - 36)) | (1 << (CommonRegexParser.RLC - 36)) | (1 << (CommonRegexParser.SLC - 36)) | (1 << (CommonRegexParser.TLC - 36)) | (1 << (CommonRegexParser.ULC - 36)) | (1 << (CommonRegexParser.VLC - 36)) | (1 << (CommonRegexParser.WLC - 36)) | (1 << (CommonRegexParser.XLC - 36)) | (1 << (CommonRegexParser.YLC - 36)) | (1 << (CommonRegexParser.ZLC - 36)))) !== 0) || ((((_la - 68)) & ~0x1F) === 0 && ((1 << (_la - 68)) & ((1 << (CommonRegexParser.AUC - 68)) | (1 << (CommonRegexParser.BUC - 68)) | (1 << (CommonRegexParser.CUC - 68)) | (1 << (CommonRegexParser.DUC - 68)) | (1 << (CommonRegexParser.EUC - 68)) | (1 << (CommonRegexParser.FUC - 68)) | (1 << (CommonRegexParser.GUC - 68)) | (1 << (CommonRegexParser.HUC - 68)) | (1 << (CommonRegexParser.IUC - 68)) | (1 << (CommonRegexParser.JUC - 68)) | (1 << (CommonRegexParser.KUC - 68)) | (1 << (CommonRegexParser.LUC - 68)) | (1 << (CommonRegexParser.MUC - 68)) | (1 << (CommonRegexParser.NUC - 68)) | (1 << (CommonRegexParser.OUC - 68)) | (1 << (CommonRegexParser.PUC - 68)) | (1 << (CommonRegexParser.QUC - 68)) | (1 << (CommonRegexParser.RUC - 68)) | (1 << (CommonRegexParser.SUC - 68)) | (1 << (CommonRegexParser.TUC - 68)) | (1 << (CommonRegexParser.UUC - 68)) | (1 << (CommonRegexParser.VUC - 68)) | (1 << (CommonRegexParser.WUC - 68)) | (1 << (CommonRegexParser.XUC - 68)) | (1 << (CommonRegexParser.YUC - 68)) | (1 << (CommonRegexParser.ZUC - 68)) | (1 << (CommonRegexParser.D1 - 68)) | (1 << (CommonRegexParser.D2 - 68)) | (1 << (CommonRegexParser.D3 - 68)) | (1 << (CommonRegexParser.D4 - 68)) | (1 << (CommonRegexParser.D5 - 68)) | (1 << (CommonRegexParser.D6 - 68)))) !== 0) || ((((_la - 100)) & ~0x1F) === 0 && ((1 << (_la - 100)) & ((1 << (CommonRegexParser.D7 - 100)) | (1 << (CommonRegexParser.D8 - 100)) | (1 << (CommonRegexParser.D9 - 100)) | (1 << (CommonRegexParser.D0 - 100)))) !== 0)) { + while (((((_la - 38)) & ~0x1F) === 0 && ((1 << (_la - 38)) & ((1 << (CommonRegexParser.Underscore - 38)) | (1 << (CommonRegexParser.ALC - 38)) | (1 << (CommonRegexParser.BLC - 38)) | (1 << (CommonRegexParser.CLC - 38)) | (1 << (CommonRegexParser.DLC - 38)) | (1 << (CommonRegexParser.ELC - 38)) | (1 << (CommonRegexParser.FLC - 38)) | (1 << (CommonRegexParser.GLC - 38)) | (1 << (CommonRegexParser.HLC - 38)) | (1 << (CommonRegexParser.ILC - 38)) | (1 << (CommonRegexParser.JLC - 38)) | (1 << (CommonRegexParser.KLC - 38)) | (1 << (CommonRegexParser.LLC - 38)) | (1 << (CommonRegexParser.MLC - 38)) | (1 << (CommonRegexParser.NLC - 38)) | (1 << (CommonRegexParser.OLC - 38)) | (1 << (CommonRegexParser.PLC - 38)) | (1 << (CommonRegexParser.QLC - 38)) | (1 << (CommonRegexParser.RLC - 38)) | (1 << (CommonRegexParser.SLC - 38)) | (1 << (CommonRegexParser.TLC - 38)) | (1 << (CommonRegexParser.ULC - 38)) | (1 << (CommonRegexParser.VLC - 38)) | (1 << (CommonRegexParser.WLC - 38)) | (1 << (CommonRegexParser.XLC - 38)) | (1 << (CommonRegexParser.YLC - 38)) | (1 << (CommonRegexParser.ZLC - 38)))) !== 0) || ((((_la - 70)) & ~0x1F) === 0 && ((1 << (_la - 70)) & ((1 << (CommonRegexParser.AUC - 70)) | (1 << (CommonRegexParser.BUC - 70)) | (1 << (CommonRegexParser.CUC - 70)) | (1 << (CommonRegexParser.DUC - 70)) | (1 << (CommonRegexParser.EUC - 70)) | (1 << (CommonRegexParser.FUC - 70)) | (1 << (CommonRegexParser.GUC - 70)) | (1 << (CommonRegexParser.HUC - 70)) | (1 << (CommonRegexParser.IUC - 70)) | (1 << (CommonRegexParser.JUC - 70)) | (1 << (CommonRegexParser.KUC - 70)) | (1 << (CommonRegexParser.LUC - 70)) | (1 << (CommonRegexParser.MUC - 70)) | (1 << (CommonRegexParser.NUC - 70)) | (1 << (CommonRegexParser.OUC - 70)) | (1 << (CommonRegexParser.PUC - 70)) | (1 << (CommonRegexParser.QUC - 70)) | (1 << (CommonRegexParser.RUC - 70)) | (1 << (CommonRegexParser.SUC - 70)) | (1 << (CommonRegexParser.TUC - 70)) | (1 << (CommonRegexParser.UUC - 70)) | (1 << (CommonRegexParser.VUC - 70)) | (1 << (CommonRegexParser.WUC - 70)) | (1 << (CommonRegexParser.XUC - 70)) | (1 << (CommonRegexParser.YUC - 70)) | (1 << (CommonRegexParser.ZUC - 70)) | (1 << (CommonRegexParser.D1 - 70)) | (1 << (CommonRegexParser.D2 - 70)) | (1 << (CommonRegexParser.D3 - 70)) | (1 << (CommonRegexParser.D4 - 70)) | (1 << (CommonRegexParser.D5 - 70)) | (1 << (CommonRegexParser.D6 - 70)))) !== 0) || ((((_la - 102)) & ~0x1F) === 0 && ((1 << (_la - 102)) & ((1 << (CommonRegexParser.D7 - 102)) | (1 << (CommonRegexParser.D8 - 102)) | (1 << (CommonRegexParser.D9 - 102)) | (1 << (CommonRegexParser.D0 - 102)))) !== 0)) { { - this.state = 251; + this.state = 253; this._errHandler.sync(this); switch (this._input.LA(1)) { case CommonRegexParser.ALC: @@ -1962,13 +1985,13 @@ export class CommonRegexParser extends Parser { case CommonRegexParser.YUC: case CommonRegexParser.ZUC: { - this.state = 248; + this.state = 250; this.letter(); } break; case CommonRegexParser.Underscore: { - this.state = 249; + this.state = 251; this.match(CommonRegexParser.Underscore); } break; @@ -1983,7 +2006,7 @@ export class CommonRegexParser extends Parser { case CommonRegexParser.D9: case CommonRegexParser.D0: { - this.state = 250; + this.state = 252; this.digit(); } break; @@ -1991,7 +2014,7 @@ export class CommonRegexParser extends Parser { throw new NoViableAltException(this); } } - this.state = 255; + this.state = 257; this._errHandler.sync(this); _la = this._input.LA(1); } @@ -2019,20 +2042,20 @@ export class CommonRegexParser extends Parser { try { this.enterOuterAlt(_localctx, 1); { - this.state = 257; + this.state = 259; this._errHandler.sync(this); _la = this._input.LA(1); do { { { - this.state = 256; + this.state = 258; this.non_close_paren(); } } - this.state = 259; + this.state = 261; this._errHandler.sync(this); _la = this._input.LA(1); - } while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << CommonRegexParser.BellChar) | (1 << CommonRegexParser.ControlChar) | (1 << CommonRegexParser.EscapeChar) | (1 << CommonRegexParser.FormFeed) | (1 << CommonRegexParser.NewLine) | (1 << CommonRegexParser.CarriageReturn) | (1 << CommonRegexParser.Tab) | (1 << CommonRegexParser.Backslash) | (1 << CommonRegexParser.HexChar) | (1 << CommonRegexParser.Dot) | (1 << CommonRegexParser.DecimalDigit) | (1 << CommonRegexParser.NotDecimalDigit) | (1 << CommonRegexParser.CharWithProperty) | (1 << CommonRegexParser.CharWithoutProperty) | (1 << CommonRegexParser.WhiteSpace) | (1 << CommonRegexParser.NotWhiteSpace) | (1 << CommonRegexParser.WordChar) | (1 << CommonRegexParser.NotWordChar) | (1 << CommonRegexParser.CharacterClassStart) | (1 << CommonRegexParser.CharacterClassEnd) | (1 << CommonRegexParser.Caret) | (1 << CommonRegexParser.Hyphen) | (1 << CommonRegexParser.QuestionMark) | (1 << CommonRegexParser.Plus) | (1 << CommonRegexParser.Star) | (1 << CommonRegexParser.OpenBrace) | (1 << CommonRegexParser.CloseBrace) | (1 << CommonRegexParser.Comma) | (1 << CommonRegexParser.EndOfSubject) | (1 << CommonRegexParser.Pipe) | (1 << CommonRegexParser.OpenParen))) !== 0) || ((((_la - 33)) & ~0x1F) === 0 && ((1 << (_la - 33)) & ((1 << (CommonRegexParser.LessThan - 33)) | (1 << (CommonRegexParser.GreaterThan - 33)) | (1 << (CommonRegexParser.SingleQuote - 33)) | (1 << (CommonRegexParser.Underscore - 33)) | (1 << (CommonRegexParser.Colon - 33)) | (1 << (CommonRegexParser.Hash - 33)) | (1 << (CommonRegexParser.Equals - 33)) | (1 << (CommonRegexParser.Exclamation - 33)) | (1 << (CommonRegexParser.Ampersand - 33)) | (1 << (CommonRegexParser.ALC - 33)) | (1 << (CommonRegexParser.BLC - 33)) | (1 << (CommonRegexParser.CLC - 33)) | (1 << (CommonRegexParser.DLC - 33)) | (1 << (CommonRegexParser.ELC - 33)) | (1 << (CommonRegexParser.FLC - 33)) | (1 << (CommonRegexParser.GLC - 33)) | (1 << (CommonRegexParser.HLC - 33)) | (1 << (CommonRegexParser.ILC - 33)) | (1 << (CommonRegexParser.JLC - 33)) | (1 << (CommonRegexParser.KLC - 33)) | (1 << (CommonRegexParser.LLC - 33)) | (1 << (CommonRegexParser.MLC - 33)) | (1 << (CommonRegexParser.NLC - 33)) | (1 << (CommonRegexParser.OLC - 33)) | (1 << (CommonRegexParser.PLC - 33)) | (1 << (CommonRegexParser.QLC - 33)) | (1 << (CommonRegexParser.RLC - 33)) | (1 << (CommonRegexParser.SLC - 33)) | (1 << (CommonRegexParser.TLC - 33)) | (1 << (CommonRegexParser.ULC - 33)) | (1 << (CommonRegexParser.VLC - 33)) | (1 << (CommonRegexParser.WLC - 33)))) !== 0) || ((((_la - 65)) & ~0x1F) === 0 && ((1 << (_la - 65)) & ((1 << (CommonRegexParser.XLC - 65)) | (1 << (CommonRegexParser.YLC - 65)) | (1 << (CommonRegexParser.ZLC - 65)) | (1 << (CommonRegexParser.AUC - 65)) | (1 << (CommonRegexParser.BUC - 65)) | (1 << (CommonRegexParser.CUC - 65)) | (1 << (CommonRegexParser.DUC - 65)) | (1 << (CommonRegexParser.EUC - 65)) | (1 << (CommonRegexParser.FUC - 65)) | (1 << (CommonRegexParser.GUC - 65)) | (1 << (CommonRegexParser.HUC - 65)) | (1 << (CommonRegexParser.IUC - 65)) | (1 << (CommonRegexParser.JUC - 65)) | (1 << (CommonRegexParser.KUC - 65)) | (1 << (CommonRegexParser.LUC - 65)) | (1 << (CommonRegexParser.MUC - 65)) | (1 << (CommonRegexParser.NUC - 65)) | (1 << (CommonRegexParser.OUC - 65)) | (1 << (CommonRegexParser.PUC - 65)) | (1 << (CommonRegexParser.QUC - 65)) | (1 << (CommonRegexParser.RUC - 65)) | (1 << (CommonRegexParser.SUC - 65)) | (1 << (CommonRegexParser.TUC - 65)) | (1 << (CommonRegexParser.UUC - 65)) | (1 << (CommonRegexParser.VUC - 65)) | (1 << (CommonRegexParser.WUC - 65)) | (1 << (CommonRegexParser.XUC - 65)) | (1 << (CommonRegexParser.YUC - 65)) | (1 << (CommonRegexParser.ZUC - 65)) | (1 << (CommonRegexParser.D1 - 65)) | (1 << (CommonRegexParser.D2 - 65)) | (1 << (CommonRegexParser.D3 - 65)))) !== 0) || ((((_la - 97)) & ~0x1F) === 0 && ((1 << (_la - 97)) & ((1 << (CommonRegexParser.D4 - 97)) | (1 << (CommonRegexParser.D5 - 97)) | (1 << (CommonRegexParser.D6 - 97)) | (1 << (CommonRegexParser.D7 - 97)) | (1 << (CommonRegexParser.D8 - 97)) | (1 << (CommonRegexParser.D9 - 97)) | (1 << (CommonRegexParser.D0 - 97)) | (1 << (CommonRegexParser.OtherChar - 97)))) !== 0)); + } while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << CommonRegexParser.Quoted) | (1 << CommonRegexParser.BlockQuoted) | (1 << CommonRegexParser.BellChar) | (1 << CommonRegexParser.ControlChar) | (1 << CommonRegexParser.EscapeChar) | (1 << CommonRegexParser.FormFeed) | (1 << CommonRegexParser.NewLine) | (1 << CommonRegexParser.CarriageReturn) | (1 << CommonRegexParser.Tab) | (1 << CommonRegexParser.Backslash) | (1 << CommonRegexParser.HexChar) | (1 << CommonRegexParser.Dot) | (1 << CommonRegexParser.DecimalDigit) | (1 << CommonRegexParser.NotDecimalDigit) | (1 << CommonRegexParser.CharWithProperty) | (1 << CommonRegexParser.CharWithoutProperty) | (1 << CommonRegexParser.WhiteSpace) | (1 << CommonRegexParser.NotWhiteSpace) | (1 << CommonRegexParser.WordChar) | (1 << CommonRegexParser.NotWordChar) | (1 << CommonRegexParser.CharacterClassStart) | (1 << CommonRegexParser.CharacterClassEnd) | (1 << CommonRegexParser.Caret) | (1 << CommonRegexParser.Hyphen) | (1 << CommonRegexParser.QuestionMark) | (1 << CommonRegexParser.Plus) | (1 << CommonRegexParser.Star) | (1 << CommonRegexParser.OpenBrace) | (1 << CommonRegexParser.CloseBrace) | (1 << CommonRegexParser.Comma) | (1 << CommonRegexParser.EndOfSubject))) !== 0) || ((((_la - 32)) & ~0x1F) === 0 && ((1 << (_la - 32)) & ((1 << (CommonRegexParser.Pipe - 32)) | (1 << (CommonRegexParser.OpenParen - 32)) | (1 << (CommonRegexParser.LessThan - 32)) | (1 << (CommonRegexParser.GreaterThan - 32)) | (1 << (CommonRegexParser.SingleQuote - 32)) | (1 << (CommonRegexParser.Underscore - 32)) | (1 << (CommonRegexParser.Colon - 32)) | (1 << (CommonRegexParser.Hash - 32)) | (1 << (CommonRegexParser.Equals - 32)) | (1 << (CommonRegexParser.Exclamation - 32)) | (1 << (CommonRegexParser.Ampersand - 32)) | (1 << (CommonRegexParser.ALC - 32)) | (1 << (CommonRegexParser.BLC - 32)) | (1 << (CommonRegexParser.CLC - 32)) | (1 << (CommonRegexParser.DLC - 32)) | (1 << (CommonRegexParser.ELC - 32)) | (1 << (CommonRegexParser.FLC - 32)) | (1 << (CommonRegexParser.GLC - 32)) | (1 << (CommonRegexParser.HLC - 32)) | (1 << (CommonRegexParser.ILC - 32)) | (1 << (CommonRegexParser.JLC - 32)) | (1 << (CommonRegexParser.KLC - 32)) | (1 << (CommonRegexParser.LLC - 32)) | (1 << (CommonRegexParser.MLC - 32)) | (1 << (CommonRegexParser.NLC - 32)) | (1 << (CommonRegexParser.OLC - 32)) | (1 << (CommonRegexParser.PLC - 32)) | (1 << (CommonRegexParser.QLC - 32)) | (1 << (CommonRegexParser.RLC - 32)) | (1 << (CommonRegexParser.SLC - 32)) | (1 << (CommonRegexParser.TLC - 32)))) !== 0) || ((((_la - 64)) & ~0x1F) === 0 && ((1 << (_la - 64)) & ((1 << (CommonRegexParser.ULC - 64)) | (1 << (CommonRegexParser.VLC - 64)) | (1 << (CommonRegexParser.WLC - 64)) | (1 << (CommonRegexParser.XLC - 64)) | (1 << (CommonRegexParser.YLC - 64)) | (1 << (CommonRegexParser.ZLC - 64)) | (1 << (CommonRegexParser.AUC - 64)) | (1 << (CommonRegexParser.BUC - 64)) | (1 << (CommonRegexParser.CUC - 64)) | (1 << (CommonRegexParser.DUC - 64)) | (1 << (CommonRegexParser.EUC - 64)) | (1 << (CommonRegexParser.FUC - 64)) | (1 << (CommonRegexParser.GUC - 64)) | (1 << (CommonRegexParser.HUC - 64)) | (1 << (CommonRegexParser.IUC - 64)) | (1 << (CommonRegexParser.JUC - 64)) | (1 << (CommonRegexParser.KUC - 64)) | (1 << (CommonRegexParser.LUC - 64)) | (1 << (CommonRegexParser.MUC - 64)) | (1 << (CommonRegexParser.NUC - 64)) | (1 << (CommonRegexParser.OUC - 64)) | (1 << (CommonRegexParser.PUC - 64)) | (1 << (CommonRegexParser.QUC - 64)) | (1 << (CommonRegexParser.RUC - 64)) | (1 << (CommonRegexParser.SUC - 64)) | (1 << (CommonRegexParser.TUC - 64)) | (1 << (CommonRegexParser.UUC - 64)) | (1 << (CommonRegexParser.VUC - 64)) | (1 << (CommonRegexParser.WUC - 64)) | (1 << (CommonRegexParser.XUC - 64)) | (1 << (CommonRegexParser.YUC - 64)) | (1 << (CommonRegexParser.ZUC - 64)))) !== 0) || ((((_la - 96)) & ~0x1F) === 0 && ((1 << (_la - 96)) & ((1 << (CommonRegexParser.D1 - 96)) | (1 << (CommonRegexParser.D2 - 96)) | (1 << (CommonRegexParser.D3 - 96)) | (1 << (CommonRegexParser.D4 - 96)) | (1 << (CommonRegexParser.D5 - 96)) | (1 << (CommonRegexParser.D6 - 96)) | (1 << (CommonRegexParser.D7 - 96)) | (1 << (CommonRegexParser.D8 - 96)) | (1 << (CommonRegexParser.D9 - 96)) | (1 << (CommonRegexParser.D0 - 96)) | (1 << (CommonRegexParser.OtherChar - 96)))) !== 0)); } } catch (re) { @@ -2057,7 +2080,7 @@ export class CommonRegexParser extends Parser { try { this.enterOuterAlt(_localctx, 1); { - this.state = 261; + this.state = 263; _la = this._input.LA(1); if (_la <= 0 || (_la === CommonRegexParser.CloseParen)) { this._errHandler.recoverInline(this); @@ -2093,9 +2116,9 @@ export class CommonRegexParser extends Parser { try { this.enterOuterAlt(_localctx, 1); { - this.state = 263; + this.state = 265; _la = this._input.LA(1); - if (!(((((_la - 42)) & ~0x1F) === 0 && ((1 << (_la - 42)) & ((1 << (CommonRegexParser.ALC - 42)) | (1 << (CommonRegexParser.BLC - 42)) | (1 << (CommonRegexParser.CLC - 42)) | (1 << (CommonRegexParser.DLC - 42)) | (1 << (CommonRegexParser.ELC - 42)) | (1 << (CommonRegexParser.FLC - 42)) | (1 << (CommonRegexParser.GLC - 42)) | (1 << (CommonRegexParser.HLC - 42)) | (1 << (CommonRegexParser.ILC - 42)) | (1 << (CommonRegexParser.JLC - 42)) | (1 << (CommonRegexParser.KLC - 42)) | (1 << (CommonRegexParser.LLC - 42)) | (1 << (CommonRegexParser.MLC - 42)) | (1 << (CommonRegexParser.NLC - 42)) | (1 << (CommonRegexParser.OLC - 42)) | (1 << (CommonRegexParser.PLC - 42)) | (1 << (CommonRegexParser.QLC - 42)) | (1 << (CommonRegexParser.RLC - 42)) | (1 << (CommonRegexParser.SLC - 42)) | (1 << (CommonRegexParser.TLC - 42)) | (1 << (CommonRegexParser.ULC - 42)) | (1 << (CommonRegexParser.VLC - 42)) | (1 << (CommonRegexParser.WLC - 42)) | (1 << (CommonRegexParser.XLC - 42)) | (1 << (CommonRegexParser.YLC - 42)) | (1 << (CommonRegexParser.ZLC - 42)) | (1 << (CommonRegexParser.AUC - 42)) | (1 << (CommonRegexParser.BUC - 42)) | (1 << (CommonRegexParser.CUC - 42)) | (1 << (CommonRegexParser.DUC - 42)) | (1 << (CommonRegexParser.EUC - 42)) | (1 << (CommonRegexParser.FUC - 42)))) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & ((1 << (CommonRegexParser.GUC - 74)) | (1 << (CommonRegexParser.HUC - 74)) | (1 << (CommonRegexParser.IUC - 74)) | (1 << (CommonRegexParser.JUC - 74)) | (1 << (CommonRegexParser.KUC - 74)) | (1 << (CommonRegexParser.LUC - 74)) | (1 << (CommonRegexParser.MUC - 74)) | (1 << (CommonRegexParser.NUC - 74)) | (1 << (CommonRegexParser.OUC - 74)) | (1 << (CommonRegexParser.PUC - 74)) | (1 << (CommonRegexParser.QUC - 74)) | (1 << (CommonRegexParser.RUC - 74)) | (1 << (CommonRegexParser.SUC - 74)) | (1 << (CommonRegexParser.TUC - 74)) | (1 << (CommonRegexParser.UUC - 74)) | (1 << (CommonRegexParser.VUC - 74)) | (1 << (CommonRegexParser.WUC - 74)) | (1 << (CommonRegexParser.XUC - 74)) | (1 << (CommonRegexParser.YUC - 74)) | (1 << (CommonRegexParser.ZUC - 74)))) !== 0))) { + if (!(((((_la - 44)) & ~0x1F) === 0 && ((1 << (_la - 44)) & ((1 << (CommonRegexParser.ALC - 44)) | (1 << (CommonRegexParser.BLC - 44)) | (1 << (CommonRegexParser.CLC - 44)) | (1 << (CommonRegexParser.DLC - 44)) | (1 << (CommonRegexParser.ELC - 44)) | (1 << (CommonRegexParser.FLC - 44)) | (1 << (CommonRegexParser.GLC - 44)) | (1 << (CommonRegexParser.HLC - 44)) | (1 << (CommonRegexParser.ILC - 44)) | (1 << (CommonRegexParser.JLC - 44)) | (1 << (CommonRegexParser.KLC - 44)) | (1 << (CommonRegexParser.LLC - 44)) | (1 << (CommonRegexParser.MLC - 44)) | (1 << (CommonRegexParser.NLC - 44)) | (1 << (CommonRegexParser.OLC - 44)) | (1 << (CommonRegexParser.PLC - 44)) | (1 << (CommonRegexParser.QLC - 44)) | (1 << (CommonRegexParser.RLC - 44)) | (1 << (CommonRegexParser.SLC - 44)) | (1 << (CommonRegexParser.TLC - 44)) | (1 << (CommonRegexParser.ULC - 44)) | (1 << (CommonRegexParser.VLC - 44)) | (1 << (CommonRegexParser.WLC - 44)) | (1 << (CommonRegexParser.XLC - 44)) | (1 << (CommonRegexParser.YLC - 44)) | (1 << (CommonRegexParser.ZLC - 44)) | (1 << (CommonRegexParser.AUC - 44)) | (1 << (CommonRegexParser.BUC - 44)) | (1 << (CommonRegexParser.CUC - 44)) | (1 << (CommonRegexParser.DUC - 44)) | (1 << (CommonRegexParser.EUC - 44)) | (1 << (CommonRegexParser.FUC - 44)))) !== 0) || ((((_la - 76)) & ~0x1F) === 0 && ((1 << (_la - 76)) & ((1 << (CommonRegexParser.GUC - 76)) | (1 << (CommonRegexParser.HUC - 76)) | (1 << (CommonRegexParser.IUC - 76)) | (1 << (CommonRegexParser.JUC - 76)) | (1 << (CommonRegexParser.KUC - 76)) | (1 << (CommonRegexParser.LUC - 76)) | (1 << (CommonRegexParser.MUC - 76)) | (1 << (CommonRegexParser.NUC - 76)) | (1 << (CommonRegexParser.OUC - 76)) | (1 << (CommonRegexParser.PUC - 76)) | (1 << (CommonRegexParser.QUC - 76)) | (1 << (CommonRegexParser.RUC - 76)) | (1 << (CommonRegexParser.SUC - 76)) | (1 << (CommonRegexParser.TUC - 76)) | (1 << (CommonRegexParser.UUC - 76)) | (1 << (CommonRegexParser.VUC - 76)) | (1 << (CommonRegexParser.WUC - 76)) | (1 << (CommonRegexParser.XUC - 76)) | (1 << (CommonRegexParser.YUC - 76)) | (1 << (CommonRegexParser.ZUC - 76)))) !== 0))) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token.EOF) { @@ -2123,7 +2146,7 @@ export class CommonRegexParser extends Parser { } public static readonly _serializedATN: string = - "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x03j\u010C\x04\x02" + + "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x03l\u010E\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" + @@ -2145,111 +2168,112 @@ export class CommonRegexParser extends Parser { "\x03\x11\x03\x11\x03\x11\x03\x11\x03\x11\x03\x11\x03\x11\x05\x11\xC3\n" + "\x11\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03" + "\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03" + - "\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x05\x12\xDD\n\x12" + - "\x03\x13\x03\x13\x03\x14\x03\x14\x03\x14\x03\x14\x03\x14\x03\x14\x03\x14" + - "\x03\x14\x03\x14\x05\x14\xEA\n\x14\x03\x15\x03\x15\x03\x16\x06\x16\xEF" + - "\n\x16\r\x16\x0E\x16\xF0\x03\x17\x03\x17\x03\x18\x03\x18\x03\x19\x03\x19" + - "\x05\x19\xF9\n\x19\x03\x19\x03\x19\x03\x19\x07\x19\xFE\n\x19\f\x19\x0E" + - "\x19\u0101\v\x19\x03\x1A\x06\x1A\u0104\n\x1A\r\x1A\x0E\x1A\u0105\x03\x1B" + - "\x03\x1B\x03\x1C\x03\x1C\x03\x1C\x02\x02\x02\x1D\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\x02" + - "4\x026\x02\x02\t\x05\x024488>>\x04\x02\x04\x04\r\x14\x04\x02`bii\x04\x02" + - "`fii\x03\x02`i\x03\x02\"\"\x03\x02,_\u0132\x028\x03\x02\x02\x02\x04;\x03" + - "\x02\x02\x02\x06F\x03\x02\x02\x02\bI\x03\x02\x02\x02\ne\x03\x02\x02\x02" + - "\fj\x03\x02\x02\x02\x0E}\x03\x02\x02\x02\x10\x8B\x03\x02\x02\x02\x12\x8D" + - "\x03\x02\x02\x02\x14\x93\x03\x02\x02\x02\x16\x9C\x03\x02\x02\x02\x18\xA7" + - "\x03\x02\x02\x02\x1A\xAF\x03\x02\x02\x02\x1C\xB1\x03\x02\x02\x02\x1E\xB5" + - "\x03\x02\x02\x02 \xC2\x03\x02\x02\x02\"\xDC\x03\x02\x02\x02$\xDE\x03\x02" + - "\x02\x02&\xE9\x03\x02\x02\x02(\xEB\x03\x02\x02\x02*\xEE\x03\x02\x02\x02" + - ",\xF2\x03\x02\x02\x02.\xF4\x03\x02\x02\x020\xF8\x03\x02\x02\x022\u0103" + - "\x03\x02\x02\x024\u0107\x03\x02\x02\x026\u0109\x03\x02\x02\x0289\x05\x04" + - "\x03\x029:\x07\x02\x02\x03:\x03\x03\x02\x02\x02;@\x05\x06\x04\x02<=\x07" + - " \x02\x02=?\x05\x06\x04\x02><\x03\x02\x02\x02?B\x03\x02\x02\x02@>\x03" + - "\x02\x02\x02@A\x03\x02\x02\x02A\x05\x03\x02\x02\x02B@\x03\x02\x02\x02" + - "CE\x05\b\x05\x02DC\x03\x02\x02\x02EH\x03\x02\x02\x02FD\x03\x02\x02\x02" + - "FG\x03\x02\x02\x02G\x07\x03\x02\x02\x02HF\x03\x02\x02\x02IK\x05\x18\r" + - "\x02JL\x05\n\x06\x02KJ\x03\x02\x02\x02KL\x03\x02\x02\x02L\t\x03\x02\x02" + - "\x02MN\x07\x19\x02\x02Nf\x05\f\x07\x02OP\x07\x1A\x02\x02Pf\x05\f\x07\x02" + - "QR\x07\x1B\x02\x02Rf\x05\f\x07\x02ST\x07\x1C\x02\x02TU\x05$\x13\x02UV" + - "\x07\x1D\x02\x02VW\x05\f\x07\x02Wf\x03\x02\x02\x02XY\x07\x1C\x02\x02Y" + - "Z\x05$\x13\x02Z[\x07\x1E\x02\x02[\\\x07\x1D\x02\x02\\]\x05\f\x07\x02]" + - "f\x03\x02\x02\x02^_\x07\x1C\x02\x02_`\x05$\x13\x02`a\x07\x1E\x02\x02a" + - "b\x05$\x13\x02bc\x07\x1D\x02\x02cd\x05\f\x07\x02df\x03\x02\x02\x02eM\x03" + - "\x02\x02\x02eO\x03\x02\x02\x02eQ\x03\x02\x02\x02eS\x03\x02\x02\x02eX\x03" + - "\x02\x02\x02e^\x03\x02\x02\x02f\v\x03\x02\x02\x02gk\x07\x1A\x02\x02hk" + - "\x07\x19\x02\x02ik\x03\x02\x02\x02jg\x03\x02\x02\x02jh\x03\x02\x02\x02" + - "ji\x03\x02\x02\x02k\r\x03\x02\x02\x02lm\x07\x15\x02\x02mo\x07\x17\x02" + - "\x02np\x05\x1A\x0E\x02on\x03\x02\x02\x02pq\x03\x02\x02\x02qo\x03\x02\x02" + - "\x02qr\x03\x02\x02\x02rs\x03\x02\x02\x02st\x07\x16\x02\x02t~\x03\x02\x02" + - "\x02uw\x07\x15\x02\x02vx\x05\x1A\x0E\x02wv\x03\x02\x02\x02xy\x03\x02\x02" + - "\x02yw\x03\x02\x02\x02yz\x03\x02\x02\x02z{\x03\x02\x02\x02{|\x07\x16\x02" + - "\x02|~\x03\x02\x02\x02}l\x03\x02\x02\x02}u\x03\x02\x02\x02~\x0F\x03\x02" + - "\x02\x02\x7F\x80\x07!\x02\x02\x80\x81\x07\x19\x02\x02\x81\x82\x07#\x02" + - "\x02\x82\x83\x05.\x18\x02\x83\x84\x07$\x02\x02\x84\x85\x05\x04\x03\x02" + - "\x85\x86\x07\"\x02\x02\x86\x8C\x03\x02\x02\x02\x87\x88\x07!\x02\x02\x88" + - "\x89\x05\x04\x03\x02\x89\x8A\x07\"\x02\x02\x8A\x8C\x03\x02\x02\x02\x8B" + - "\x7F\x03\x02\x02\x02\x8B\x87\x03\x02\x02\x02\x8C\x11\x03\x02\x02\x02\x8D" + - "\x8E\x07!\x02\x02\x8E\x8F\x07\x19\x02\x02\x8F\x90\x07\'\x02\x02\x90\x91" + - "\x05\x04\x03\x02\x91\x92\x07\"\x02\x02\x92\x13\x03\x02\x02\x02\x93\x94" + - "\x07!\x02\x02\x94\x96\x07\x19\x02\x02\x95\x97\x05\x16\f\x02\x96\x95\x03" + - "\x02\x02\x02\x97\x98\x03\x02\x02\x02\x98\x96\x03\x02\x02\x02\x98\x99\x03" + - "\x02\x02\x02\x99\x9A\x03\x02\x02\x02\x9A\x9B\x07\"\x02\x02\x9B\x15\x03" + - "\x02\x02\x02\x9C\x9D\t\x02\x02\x02\x9D\x17\x03\x02\x02\x02\x9E\xA8\x05" + - "\x1C\x0F\x02\x9F\xA8\x05\x1E\x10\x02\xA0\xA8\x05\x0E\b\x02\xA1\xA8\x05" + - "\x10\t\x02\xA2\xA8\x05\x12\n\x02\xA3\xA8\x05\x14\v\x02\xA4\xA8\x07\f\x02" + - "\x02\xA5\xA8\x07\x17\x02\x02\xA6\xA8\x07\x1F\x02\x02\xA7\x9E\x03\x02\x02" + - "\x02\xA7\x9F\x03\x02\x02\x02\xA7\xA0\x03\x02\x02\x02\xA7\xA1\x03\x02\x02" + - "\x02\xA7\xA2\x03\x02\x02\x02\xA7\xA3\x03\x02\x02\x02\xA7\xA4\x03\x02\x02" + - "\x02\xA7\xA5\x03\x02\x02\x02\xA7\xA6\x03\x02\x02\x02\xA8\x19\x03\x02\x02" + - "\x02\xA9\xAA\x05 \x11\x02\xAA\xAB\x07\x18\x02\x02\xAB\xAC\x05 \x11\x02" + - "\xAC\xB0\x03\x02\x02\x02\xAD\xB0\x05\x1C\x0F\x02\xAE\xB0\x05 \x11\x02" + - "\xAF\xA9\x03\x02\x02\x02\xAF\xAD\x03\x02\x02\x02\xAF\xAE\x03\x02\x02\x02" + - "\xB0\x1B\x03\x02\x02\x02\xB1\xB2\t\x03\x02\x02\xB2\x1D\x03\x02\x02\x02" + - "\xB3\xB6\x05\"\x12\x02\xB4\xB6\x07\x16\x02\x02\xB5\xB3\x03\x02\x02\x02" + - "\xB5\xB4\x03\x02\x02\x02\xB6\x1F\x03\x02\x02\x02\xB7\xC3\x05\"\x12\x02" + - "\xB8\xC3\x07\f\x02\x02\xB9\xC3\x07\x15\x02\x02\xBA\xC3\x07\x17\x02\x02" + - "\xBB\xC3\x07\x19\x02\x02\xBC\xC3\x07\x1A\x02\x02\xBD\xC3\x07\x1B\x02\x02" + - "\xBE\xC3\x07\x1F\x02\x02\xBF\xC3\x07 \x02\x02\xC0\xC3\x07!\x02\x02\xC1" + - "\xC3\x07\"\x02\x02\xC2\xB7\x03\x02\x02\x02\xC2\xB8\x03\x02\x02\x02\xC2" + - "\xB9\x03\x02\x02\x02\xC2\xBA\x03\x02\x02\x02\xC2\xBB\x03\x02\x02\x02\xC2" + - "\xBC\x03\x02\x02\x02\xC2\xBD\x03\x02\x02\x02\xC2\xBE\x03\x02\x02\x02\xC2" + - "\xBF\x03\x02\x02\x02\xC2\xC0\x03\x02\x02\x02\xC2\xC1\x03\x02\x02\x02\xC3" + - "!\x03\x02\x02\x02\xC4\xDD\x05&\x14\x02\xC5\xDD\x056\x1C\x02\xC6\xDD\x05" + - ",\x17\x02\xC7\xDD\x07\x03\x02\x02\xC8\xDD\x07\x05\x02\x02\xC9\xDD\x07" + - "\x06\x02\x02\xCA\xDD\x07\x07\x02\x02\xCB\xDD\x07\b\x02\x02\xCC\xDD\x07" + - "\t\x02\x02\xCD\xDD\x07\v\x02\x02\xCE\xDD\x07\x1C\x02\x02\xCF\xDD\x07\x1D" + - "\x02\x02\xD0\xDD\x07\x1E\x02\x02\xD1\xDD\x07\x18\x02\x02\xD2\xDD\x07#" + - "\x02\x02\xD3\xDD\x07$\x02\x02\xD4\xDD\x07%\x02\x02\xD5\xDD\x07&\x02\x02" + - "\xD6\xDD\x07\'\x02\x02\xD7\xDD\x07(\x02\x02\xD8\xDD\x07)\x02\x02\xD9\xDD" + - "\x07*\x02\x02\xDA\xDD\x07+\x02\x02\xDB\xDD\x07j\x02\x02\xDC\xC4\x03\x02" + - "\x02\x02\xDC\xC5\x03\x02\x02\x02\xDC\xC6\x03\x02\x02\x02\xDC\xC7\x03\x02" + - "\x02\x02\xDC\xC8\x03\x02\x02\x02\xDC\xC9\x03\x02\x02\x02\xDC\xCA\x03\x02" + - "\x02\x02\xDC\xCB\x03\x02\x02\x02\xDC\xCC\x03\x02\x02\x02\xDC\xCD\x03\x02" + - "\x02\x02\xDC\xCE\x03\x02\x02\x02\xDC\xCF\x03\x02\x02\x02\xDC\xD0\x03\x02" + - "\x02\x02\xDC\xD1\x03\x02\x02\x02\xDC\xD2\x03\x02\x02\x02\xDC\xD3\x03\x02" + - "\x02\x02\xDC\xD4\x03\x02\x02\x02\xDC\xD5\x03\x02\x02\x02\xDC\xD6\x03\x02" + - "\x02\x02\xDC\xD7\x03\x02\x02\x02\xDC\xD8\x03\x02\x02\x02\xDC\xD9\x03\x02" + - "\x02\x02\xDC\xDA\x03\x02\x02\x02\xDC\xDB\x03\x02\x02\x02\xDD#\x03\x02" + - "\x02\x02\xDE\xDF\x05*\x16\x02\xDF%\x03\x02\x02\x02\xE0\xE1\x07\n\x02\x02" + - "\xE1\xE2\t\x04\x02\x02\xE2\xE3\x05(\x15\x02\xE3\xE4\x05(\x15\x02\xE4\xEA" + - "\x03\x02\x02\x02\xE5\xE6\x07\n\x02\x02\xE6\xE7\x05(\x15\x02\xE7\xE8\x05" + - "(\x15\x02\xE8\xEA\x03\x02\x02\x02\xE9\xE0\x03\x02\x02\x02\xE9\xE5\x03" + - "\x02\x02\x02\xEA\'\x03\x02\x02\x02\xEB\xEC\t\x05\x02\x02\xEC)\x03\x02" + - "\x02\x02\xED\xEF\x05,\x17\x02\xEE\xED\x03\x02\x02\x02\xEF\xF0\x03\x02" + - "\x02\x02\xF0\xEE\x03\x02\x02\x02\xF0\xF1\x03\x02\x02\x02\xF1+\x03\x02" + - "\x02\x02\xF2\xF3\t\x06\x02\x02\xF3-\x03\x02\x02\x02\xF4\xF5\x050\x19\x02" + - "\xF5/\x03\x02\x02\x02\xF6\xF9\x056\x1C\x02\xF7\xF9\x07&\x02\x02\xF8\xF6" + - "\x03\x02\x02\x02\xF8\xF7\x03\x02\x02\x02\xF9\xFF\x03\x02\x02\x02\xFA\xFE" + - "\x056\x1C\x02\xFB\xFE\x07&\x02\x02\xFC\xFE\x05,\x17\x02\xFD\xFA\x03\x02" + - "\x02\x02\xFD\xFB\x03\x02\x02\x02\xFD\xFC\x03\x02\x02\x02\xFE\u0101\x03" + - "\x02\x02\x02\xFF\xFD\x03\x02\x02\x02\xFF\u0100\x03\x02\x02\x02\u01001" + - "\x03\x02\x02\x02\u0101\xFF\x03\x02\x02\x02\u0102\u0104\x054\x1B\x02\u0103" + - "\u0102\x03\x02\x02\x02\u0104\u0105\x03\x02\x02\x02\u0105\u0103\x03\x02" + - "\x02\x02\u0105\u0106\x03\x02\x02\x02\u01063\x03\x02\x02\x02\u0107\u0108" + - "\n\x07\x02\x02\u01085\x03\x02\x02\x02\u0109\u010A\t\b\x02\x02\u010A7\x03" + - "\x02\x02\x02\x17@FKejqy}\x8B\x98\xA7\xAF\xB5\xC2\xDC\xE9\xF0\xF8\xFD\xFF" + - "\u0105"; + "\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x05" + + "\x12\xDF\n\x12\x03\x13\x03\x13\x03\x14\x03\x14\x03\x14\x03\x14\x03\x14" + + "\x03\x14\x03\x14\x03\x14\x03\x14\x05\x14\xEC\n\x14\x03\x15\x03\x15\x03" + + "\x16\x06\x16\xF1\n\x16\r\x16\x0E\x16\xF2\x03\x17\x03\x17\x03\x18\x03\x18" + + "\x03\x19\x03\x19\x05\x19\xFB\n\x19\x03\x19\x03\x19\x03\x19\x07\x19\u0100" + + "\n\x19\f\x19\x0E\x19\u0103\v\x19\x03\x1A\x06\x1A\u0106\n\x1A\r\x1A\x0E" + + "\x1A\u0107\x03\x1B\x03\x1B\x03\x1C\x03\x1C\x03\x1C\x02\x02\x02\x1D\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\x02\x02\t\x05\x0266::@@\x04\x02\x06\x06\x0F" + + "\x16\x04\x02bdkk\x04\x02bhkk\x03\x02bk\x03\x02$$\x03\x02.a\u0136\x028" + + "\x03\x02\x02\x02\x04;\x03\x02\x02\x02\x06F\x03\x02\x02\x02\bI\x03\x02" + + "\x02\x02\ne\x03\x02\x02\x02\fj\x03\x02\x02\x02\x0E}\x03\x02\x02\x02\x10" + + "\x8B\x03\x02\x02\x02\x12\x8D\x03\x02\x02\x02\x14\x93\x03\x02\x02\x02\x16" + + "\x9C\x03\x02\x02\x02\x18\xA7\x03\x02\x02\x02\x1A\xAF\x03\x02\x02\x02\x1C" + + "\xB1\x03\x02\x02\x02\x1E\xB5\x03\x02\x02\x02 \xC2\x03\x02\x02\x02\"\xDE" + + "\x03\x02\x02\x02$\xE0\x03\x02\x02\x02&\xEB\x03\x02\x02\x02(\xED\x03\x02" + + "\x02\x02*\xF0\x03\x02\x02\x02,\xF4\x03\x02\x02\x02.\xF6\x03\x02\x02\x02" + + "0\xFA\x03\x02\x02\x022\u0105\x03\x02\x02\x024\u0109\x03\x02\x02\x026\u010B" + + "\x03\x02\x02\x0289\x05\x04\x03\x029:\x07\x02\x02\x03:\x03\x03\x02\x02" + + "\x02;@\x05\x06\x04\x02<=\x07\"\x02\x02=?\x05\x06\x04\x02><\x03\x02\x02" + + "\x02?B\x03\x02\x02\x02@>\x03\x02\x02\x02@A\x03\x02\x02\x02A\x05\x03\x02" + + "\x02\x02B@\x03\x02\x02\x02CE\x05\b\x05\x02DC\x03\x02\x02\x02EH\x03\x02" + + "\x02\x02FD\x03\x02\x02\x02FG\x03\x02\x02\x02G\x07\x03\x02\x02\x02HF\x03" + + "\x02\x02\x02IK\x05\x18\r\x02JL\x05\n\x06\x02KJ\x03\x02\x02\x02KL\x03\x02" + + "\x02\x02L\t\x03\x02\x02\x02MN\x07\x1B\x02\x02Nf\x05\f\x07\x02OP\x07\x1C" + + "\x02\x02Pf\x05\f\x07\x02QR\x07\x1D\x02\x02Rf\x05\f\x07\x02ST\x07\x1E\x02" + + "\x02TU\x05$\x13\x02UV\x07\x1F\x02\x02VW\x05\f\x07\x02Wf\x03\x02\x02\x02" + + "XY\x07\x1E\x02\x02YZ\x05$\x13\x02Z[\x07 \x02\x02[\\\x07\x1F\x02\x02\\" + + "]\x05\f\x07\x02]f\x03\x02\x02\x02^_\x07\x1E\x02\x02_`\x05$\x13\x02`a\x07" + + " \x02\x02ab\x05$\x13\x02bc\x07\x1F\x02\x02cd\x05\f\x07\x02df\x03\x02\x02" + + "\x02eM\x03\x02\x02\x02eO\x03\x02\x02\x02eQ\x03\x02\x02\x02eS\x03\x02\x02" + + "\x02eX\x03\x02\x02\x02e^\x03\x02\x02\x02f\v\x03\x02\x02\x02gk\x07\x1C" + + "\x02\x02hk\x07\x1B\x02\x02ik\x03\x02\x02\x02jg\x03\x02\x02\x02jh\x03\x02" + + "\x02\x02ji\x03\x02\x02\x02k\r\x03\x02\x02\x02lm\x07\x17\x02\x02mo\x07" + + "\x19\x02\x02np\x05\x1A\x0E\x02on\x03\x02\x02\x02pq\x03\x02\x02\x02qo\x03" + + "\x02\x02\x02qr\x03\x02\x02\x02rs\x03\x02\x02\x02st\x07\x18\x02\x02t~\x03" + + "\x02\x02\x02uw\x07\x17\x02\x02vx\x05\x1A\x0E\x02wv\x03\x02\x02\x02xy\x03" + + "\x02\x02\x02yw\x03\x02\x02\x02yz\x03\x02\x02\x02z{\x03\x02\x02\x02{|\x07" + + "\x18\x02\x02|~\x03\x02\x02\x02}l\x03\x02\x02\x02}u\x03\x02\x02\x02~\x0F" + + "\x03\x02\x02\x02\x7F\x80\x07#\x02\x02\x80\x81\x07\x1B\x02\x02\x81\x82" + + "\x07%\x02\x02\x82\x83\x05.\x18\x02\x83\x84\x07&\x02\x02\x84\x85\x05\x04" + + "\x03\x02\x85\x86\x07$\x02\x02\x86\x8C\x03\x02\x02\x02\x87\x88\x07#\x02" + + "\x02\x88\x89\x05\x04\x03\x02\x89\x8A\x07$\x02\x02\x8A\x8C\x03\x02\x02" + + "\x02\x8B\x7F\x03\x02\x02\x02\x8B\x87\x03\x02\x02\x02\x8C\x11\x03\x02\x02" + + "\x02\x8D\x8E\x07#\x02\x02\x8E\x8F\x07\x1B\x02\x02\x8F\x90\x07)\x02\x02" + + "\x90\x91\x05\x04\x03\x02\x91\x92\x07$\x02\x02\x92\x13\x03\x02\x02\x02" + + "\x93\x94\x07#\x02\x02\x94\x96\x07\x1B\x02\x02\x95\x97\x05\x16\f\x02\x96" + + "\x95\x03\x02\x02\x02\x97\x98\x03\x02\x02\x02\x98\x96\x03\x02\x02\x02\x98" + + "\x99\x03\x02\x02\x02\x99\x9A\x03\x02\x02\x02\x9A\x9B\x07$\x02\x02\x9B" + + "\x15\x03\x02\x02\x02\x9C\x9D\t\x02\x02\x02\x9D\x17\x03\x02\x02\x02\x9E" + + "\xA8\x05\x1C\x0F\x02\x9F\xA8\x05\x1E\x10\x02\xA0\xA8\x05\x0E\b\x02\xA1" + + "\xA8\x05\x10\t\x02\xA2\xA8\x05\x12\n\x02\xA3\xA8\x05\x14\v\x02\xA4\xA8" + + "\x07\x0E\x02\x02\xA5\xA8\x07\x19\x02\x02\xA6\xA8\x07!\x02\x02\xA7\x9E" + + "\x03\x02\x02\x02\xA7\x9F\x03\x02\x02\x02\xA7\xA0\x03\x02\x02\x02\xA7\xA1" + + "\x03\x02\x02\x02\xA7\xA2\x03\x02\x02\x02\xA7\xA3\x03\x02\x02\x02\xA7\xA4" + + "\x03\x02\x02\x02\xA7\xA5\x03\x02\x02\x02\xA7\xA6\x03\x02\x02\x02\xA8\x19" + + "\x03\x02\x02\x02\xA9\xAA\x05 \x11\x02\xAA\xAB\x07\x1A\x02\x02\xAB\xAC" + + "\x05 \x11\x02\xAC\xB0\x03\x02\x02\x02\xAD\xB0\x05\x1C\x0F\x02\xAE\xB0" + + "\x05 \x11\x02\xAF\xA9\x03\x02\x02\x02\xAF\xAD\x03\x02\x02\x02\xAF\xAE" + + "\x03\x02\x02\x02\xB0\x1B\x03\x02\x02\x02\xB1\xB2\t\x03\x02\x02\xB2\x1D" + + "\x03\x02\x02\x02\xB3\xB6\x05\"\x12\x02\xB4\xB6\x07\x18\x02\x02\xB5\xB3" + + "\x03\x02\x02\x02\xB5\xB4\x03\x02\x02\x02\xB6\x1F\x03\x02\x02\x02\xB7\xC3" + + "\x05\"\x12\x02\xB8\xC3\x07\x0E\x02\x02\xB9\xC3\x07\x17\x02\x02\xBA\xC3" + + "\x07\x19\x02\x02\xBB\xC3\x07\x1B\x02\x02\xBC\xC3\x07\x1C\x02\x02\xBD\xC3" + + "\x07\x1D\x02\x02\xBE\xC3\x07!\x02\x02\xBF\xC3\x07\"\x02\x02\xC0\xC3\x07" + + "#\x02\x02\xC1\xC3\x07$\x02\x02\xC2\xB7\x03\x02\x02\x02\xC2\xB8\x03\x02" + + "\x02\x02\xC2\xB9\x03\x02\x02\x02\xC2\xBA\x03\x02\x02\x02\xC2\xBB\x03\x02" + + "\x02\x02\xC2\xBC\x03\x02\x02\x02\xC2\xBD\x03\x02\x02\x02\xC2\xBE\x03\x02" + + "\x02\x02\xC2\xBF\x03\x02\x02\x02\xC2\xC0\x03\x02\x02\x02\xC2\xC1\x03\x02" + + "\x02\x02\xC3!\x03\x02\x02\x02\xC4\xDF\x05&\x14\x02\xC5\xDF\x056\x1C\x02" + + "\xC6\xDF\x05,\x17\x02\xC7\xDF\x07\x05\x02\x02\xC8\xDF\x07\x07\x02\x02" + + "\xC9\xDF\x07\b\x02\x02\xCA\xDF\x07\t\x02\x02\xCB\xDF\x07\n\x02\x02\xCC" + + "\xDF\x07\v\x02\x02\xCD\xDF\x07\r\x02\x02\xCE\xDF\x07\x03\x02\x02\xCF\xDF" + + "\x07\x04\x02\x02\xD0\xDF\x07\x1E\x02\x02\xD1\xDF\x07\x1F\x02\x02\xD2\xDF" + + "\x07 \x02\x02\xD3\xDF\x07\x1A\x02\x02\xD4\xDF\x07%\x02\x02\xD5\xDF\x07" + + "&\x02\x02\xD6\xDF\x07\'\x02\x02\xD7\xDF\x07(\x02\x02\xD8\xDF\x07)\x02" + + "\x02\xD9\xDF\x07*\x02\x02\xDA\xDF\x07+\x02\x02\xDB\xDF\x07,\x02\x02\xDC" + + "\xDF\x07-\x02\x02\xDD\xDF\x07l\x02\x02\xDE\xC4\x03\x02\x02\x02\xDE\xC5" + + "\x03\x02\x02\x02\xDE\xC6\x03\x02\x02\x02\xDE\xC7\x03\x02\x02\x02\xDE\xC8" + + "\x03\x02\x02\x02\xDE\xC9\x03\x02\x02\x02\xDE\xCA\x03\x02\x02\x02\xDE\xCB" + + "\x03\x02\x02\x02\xDE\xCC\x03\x02\x02\x02\xDE\xCD\x03\x02\x02\x02\xDE\xCE" + + "\x03\x02\x02\x02\xDE\xCF\x03\x02\x02\x02\xDE\xD0\x03\x02\x02\x02\xDE\xD1" + + "\x03\x02\x02\x02\xDE\xD2\x03\x02\x02\x02\xDE\xD3\x03\x02\x02\x02\xDE\xD4" + + "\x03\x02\x02\x02\xDE\xD5\x03\x02\x02\x02\xDE\xD6\x03\x02\x02\x02\xDE\xD7" + + "\x03\x02\x02\x02\xDE\xD8\x03\x02\x02\x02\xDE\xD9\x03\x02\x02\x02\xDE\xDA" + + "\x03\x02\x02\x02\xDE\xDB\x03\x02\x02\x02\xDE\xDC\x03\x02\x02\x02\xDE\xDD" + + "\x03\x02\x02\x02\xDF#\x03\x02\x02\x02\xE0\xE1\x05*\x16\x02\xE1%\x03\x02" + + "\x02\x02\xE2\xE3\x07\f\x02\x02\xE3\xE4\t\x04\x02\x02\xE4\xE5\x05(\x15" + + "\x02\xE5\xE6\x05(\x15\x02\xE6\xEC\x03\x02\x02\x02\xE7\xE8\x07\f\x02\x02" + + "\xE8\xE9\x05(\x15\x02\xE9\xEA\x05(\x15\x02\xEA\xEC\x03\x02\x02\x02\xEB" + + "\xE2\x03\x02\x02\x02\xEB\xE7\x03\x02\x02\x02\xEC\'\x03\x02\x02\x02\xED" + + "\xEE\t\x05\x02\x02\xEE)\x03\x02\x02\x02\xEF\xF1\x05,\x17\x02\xF0\xEF\x03" + + "\x02\x02\x02\xF1\xF2\x03\x02\x02\x02\xF2\xF0\x03\x02\x02\x02\xF2\xF3\x03" + + "\x02\x02\x02\xF3+\x03\x02\x02\x02\xF4\xF5\t\x06\x02\x02\xF5-\x03\x02\x02" + + "\x02\xF6\xF7\x050\x19\x02\xF7/\x03\x02\x02\x02\xF8\xFB\x056\x1C\x02\xF9" + + "\xFB\x07(\x02\x02\xFA\xF8\x03\x02\x02\x02\xFA\xF9\x03\x02\x02\x02\xFB" + + "\u0101\x03\x02\x02\x02\xFC\u0100\x056\x1C\x02\xFD\u0100\x07(\x02\x02\xFE" + + "\u0100\x05,\x17\x02\xFF\xFC\x03\x02\x02\x02\xFF\xFD\x03\x02\x02\x02\xFF" + + "\xFE\x03\x02\x02\x02\u0100\u0103\x03\x02\x02\x02\u0101\xFF\x03\x02\x02" + + "\x02\u0101\u0102\x03\x02\x02\x02\u01021\x03\x02\x02\x02\u0103\u0101\x03" + + "\x02\x02\x02\u0104\u0106\x054\x1B\x02\u0105\u0104\x03\x02\x02\x02\u0106" + + "\u0107\x03\x02\x02\x02\u0107\u0105\x03\x02\x02\x02\u0107\u0108\x03\x02" + + "\x02\x02\u01083\x03\x02\x02\x02\u0109\u010A\n\x07\x02\x02\u010A5\x03\x02" + + "\x02\x02\u010B\u010C\t\b\x02\x02\u010C7\x03\x02\x02\x02\x17@FKejqy}\x8B" + + "\x98\xA7\xAF\xB5\xC2\xDE\xEB\xF2\xFA\xFF\u0101\u0107"; public static __ATN: ATN; public static get _ATN(): ATN { if (!CommonRegexParser.__ATN) { @@ -2869,6 +2893,8 @@ export class Shared_literalContext extends ParserRuleContext { public CarriageReturn(): TerminalNode | undefined { return this.tryGetToken(CommonRegexParser.CarriageReturn, 0); } public Tab(): TerminalNode | undefined { return this.tryGetToken(CommonRegexParser.Tab, 0); } public HexChar(): TerminalNode | undefined { return this.tryGetToken(CommonRegexParser.HexChar, 0); } + public Quoted(): TerminalNode | undefined { return this.tryGetToken(CommonRegexParser.Quoted, 0); } + public BlockQuoted(): TerminalNode | undefined { return this.tryGetToken(CommonRegexParser.BlockQuoted, 0); } public OpenBrace(): TerminalNode | undefined { return this.tryGetToken(CommonRegexParser.OpenBrace, 0); } public CloseBrace(): TerminalNode | undefined { return this.tryGetToken(CommonRegexParser.CloseBrace, 0); } public Comma(): TerminalNode | undefined { return this.tryGetToken(CommonRegexParser.Comma, 0); } diff --git a/libraries/adaptive-expressions/src/index.ts b/libraries/adaptive-expressions/src/index.ts index e1569d4c98..6b24b4066e 100644 --- a/libraries/adaptive-expressions/src/index.ts +++ b/libraries/adaptive-expressions/src/index.ts @@ -9,7 +9,7 @@ export * from './expressionFunctions'; export * from './constant'; export * from './expression'; export * from './expressionEvaluator'; -export * from './expressionParser'; +export * from './expressionParserInterface'; export * from './expressionType'; export * from './extensions'; export * from './timeZoneConverter'; @@ -19,4 +19,4 @@ export * from './parser'; export * from './memory'; export * from './regexErrorListener'; export * from './componentExpressionFunctions'; -export * from './formatConverter'; +export * from './datetimeFormatConverter'; diff --git a/libraries/adaptive-expressions/src/memory/simpleObjectMemory.ts b/libraries/adaptive-expressions/src/memory/simpleObjectMemory.ts index 8251e703f3..b7d3709867 100644 --- a/libraries/adaptive-expressions/src/memory/simpleObjectMemory.ts +++ b/libraries/adaptive-expressions/src/memory/simpleObjectMemory.ts @@ -1,6 +1,6 @@ import { MemoryInterface } from './memoryInterface'; import { Extensions } from '../extensions'; -import { Util } from '../parser/util'; +import { ExpressionFunctions } from '../expressionFunctions'; /** * @module adaptive-expressions @@ -36,7 +36,7 @@ export class SimpleObjectMemory implements MemoryInterface { } public getValue(path: string): any { - if (this.memory === undefined || path.length === 0 || (path[0] !== '[' && !path[0].match(/[a-z]/i))) { + if (this.memory === undefined || path.length === 0) { return undefined; } @@ -56,9 +56,9 @@ export class SimpleObjectMemory implements MemoryInterface { let error: string; const idx = parseInt(part); if(!isNaN(idx) && Array.isArray(curScope)) { - ({value, error} = Extensions.accessIndex(curScope, idx)); + ({value, error} = ExpressionFunctions.accessIndex(curScope, idx)); } else { - ({value, error} = Extensions.accessProperty(curScope, part)); + ({value, error} = ExpressionFunctions.accessProperty(curScope, part)); } if (error) { @@ -101,10 +101,10 @@ export class SimpleObjectMemory implements MemoryInterface { const idx = parseInt(parts[i]); if(!isNaN(idx) && Array.isArray(curScope)) { curPath = `[${ parts[i] }]`; - ({value: curScope, error} = Extensions.accessIndex(curScope, idx)); + ({value: curScope, error} = ExpressionFunctions.accessIndex(curScope, idx)); } else { curPath = `.${ parts[i] }`; - ({value: curScope, error} = Extensions.accessProperty(curScope, parts[i])); + ({value: curScope, error} = ExpressionFunctions.accessProperty(curScope, parts[i])); } if (error) { @@ -136,7 +136,7 @@ export class SimpleObjectMemory implements MemoryInterface { return; } } else { - error = Extensions.setProperty(curScope,parts[parts.length - 1], input).error; + error = ExpressionFunctions.setProperty(curScope,parts[parts.length - 1], input).error; if (error) { return; } diff --git a/libraries/adaptive-expressions/src/parser/ExpressionLexer.g4 b/libraries/adaptive-expressions/src/parser/ExpressionAntlrLexer.g4 similarity index 84% rename from libraries/adaptive-expressions/src/parser/ExpressionLexer.g4 rename to libraries/adaptive-expressions/src/parser/ExpressionAntlrLexer.g4 index 7ab80b8c8a..5e62ba181b 100644 --- a/libraries/adaptive-expressions/src/parser/ExpressionLexer.g4 +++ b/libraries/adaptive-expressions/src/parser/ExpressionAntlrLexer.g4 @@ -1,4 +1,4 @@ -lexer grammar ExpressionLexer; +lexer grammar ExpressionAntlrLexer; @lexer::members { ignoreWS = true; // usually we ignore whitespace, but inside stringInterpolation, whitespace is significant @@ -59,13 +59,13 @@ NUMBER : DIGIT + ( '.' DIGIT +)? ; WHITESPACE : (' '|'\t'|'\ufeff'|'\u00a0') {this.ignoreWS}? -> skip; -IDENTIFIER : (LETTER | '_' | '#' | '@' | '@@' | '$' | '%') (LETTER | DIGIT | '-' | '_')* '!'?; +IDENTIFIER : (LETTER | '_' | '#' | '@' | '@@' | '$' | '%') (LETTER | DIGIT | '-' | '_')*; NEWLINE : '\r'? '\n' -> skip; -STRING : ('\'' (~'\'')* '\'') | ('"' (~'"')* '"'); +STRING : ('\'' (('\\'('\''|'\\'))|(~'\''))*? '\'') | ('"' (('\\'('"'|'\\'))|(~'"'))*? '"'); -CONSTANT : ('[' WHITESPACE* ']') | ('{' WHITESPACE* '}'); +CONSTANT : ('{' WHITESPACE* '}'); INVALID_TOKEN_DEFAULT_MODE : . ; @@ -77,6 +77,6 @@ TEMPLATE : '$' '{' (STRING | ~[\r\n{}'"])*? '}'; ESCAPE_CHARACTER : '\\' ~[\r\n]?; -TEXT_CONTENT : '\\`' | ~[\r\n]; +TEXT_CONTENT : ~[\r\n]; diff --git a/libraries/adaptive-expressions/src/parser/ExpressionParser.g4 b/libraries/adaptive-expressions/src/parser/ExpressionAntlrParser.g4 similarity index 87% rename from libraries/adaptive-expressions/src/parser/ExpressionParser.g4 rename to libraries/adaptive-expressions/src/parser/ExpressionAntlrParser.g4 index 847ddf8cda..3772df0202 100644 --- a/libraries/adaptive-expressions/src/parser/ExpressionParser.g4 +++ b/libraries/adaptive-expressions/src/parser/ExpressionAntlrParser.g4 @@ -1,6 +1,6 @@ -parser grammar ExpressionParser; +parser grammar ExpressionAntlrParser; -options { tokenVocab=ExpressionLexer; } +options { tokenVocab=ExpressionAntlrLexer; } file: expression EOF; @@ -19,13 +19,14 @@ expression primaryExpression : OPEN_BRACKET expression CLOSE_BRACKET #parenthesisExp + | OPEN_SQUARE_BRACKET argsList? CLOSE_SQUARE_BRACKET #arrayCreationExp | CONSTANT #constantAtom | NUMBER #numericAtom | STRING #stringAtom | IDENTIFIER #idAtom | stringInterpolation #stringInterpolationAtom | primaryExpression DOT IDENTIFIER #memberAccessExp - | primaryExpression OPEN_BRACKET argsList? CLOSE_BRACKET #funcInvokeExp + | primaryExpression NON? OPEN_BRACKET argsList? CLOSE_BRACKET #funcInvokeExp | primaryExpression OPEN_SQUARE_BRACKET expression CLOSE_SQUARE_BRACKET #indexAccessExp ; diff --git a/libraries/adaptive-expressions/src/parser/expressionEngine.ts b/libraries/adaptive-expressions/src/parser/expressionParser.ts similarity index 65% rename from libraries/adaptive-expressions/src/parser/expressionEngine.ts rename to libraries/adaptive-expressions/src/parser/expressionParser.ts index 08a385e5fd..77f772e6d9 100644 --- a/libraries/adaptive-expressions/src/parser/expressionEngine.ts +++ b/libraries/adaptive-expressions/src/parser/expressionParser.ts @@ -1,4 +1,3 @@ - /** * @module adaptive-expressions */ @@ -7,35 +6,33 @@ * Licensed under the MIT License. */ import { ANTLRInputStream, CommonTokenStream } from 'antlr4ts'; -// tslint:disable-next-line: no-submodule-imports import { AbstractParseTreeVisitor, ParseTree, TerminalNode } from 'antlr4ts/tree'; -import { ExpressionFunctions } from '../expressionFunctions'; import { Constant } from '../constant'; import { Expression } from '../expression'; import { EvaluatorLookup } from '../expressionEvaluator'; -import { ExpressionParserInterface } from '../expressionParser'; +import { ExpressionParserInterface } from '../expressionParserInterface'; import { ExpressionType } from '../expressionType'; -import { ExpressionLexer, ExpressionParser, ExpressionParserVisitor } from './generated'; -import * as ep from './generated/ExpressionParser'; +import { ExpressionAntlrLexer, ExpressionAntlrParser, ExpressionAntlrParserVisitor } from './generated'; +import * as ep from './generated/ExpressionAntlrParser'; import { ParseErrorListener } from './parseErrorListener'; import { Util } from './util'; /** * Parser to turn strings into Expression */ -export class ExpressionEngine implements ExpressionParserInterface { +export class ExpressionParser implements ExpressionParserInterface { /** * The delegate to lookup function information from the type. */ public readonly EvaluatorLookup: EvaluatorLookup; - // tslint:disable-next-line: typedef - private readonly ExpressionTransformer = class extends AbstractParseTreeVisitor implements ExpressionParserVisitor { + private readonly ExpressionTransformer = class extends AbstractParseTreeVisitor implements ExpressionAntlrParserVisitor { - private readonly _lookup: EvaluatorLookup = undefined; + private readonly escapeRegex: RegExp = new RegExp(/\\[^\r\n]?/g); + private readonly _lookupFunction: EvaluatorLookup = undefined; public constructor(lookup: EvaluatorLookup) { super(); - this._lookup = lookup; + this._lookupFunction = lookup; } public transform = (context: ParseTree): Expression => this.visit(context); @@ -44,10 +41,10 @@ export class ExpressionEngine implements ExpressionParserInterface { const unaryOperationName: string = context.getChild(0).text; const operand: Expression = this.visit(context.expression()); if (unaryOperationName === ExpressionType.Subtract || unaryOperationName === ExpressionType.Add) { - return this.MakeExpression(unaryOperationName, new Constant(0), operand); + return this.makeExpression(unaryOperationName, new Constant(0), operand); } - return this.MakeExpression(unaryOperationName, operand); + return this.makeExpression(unaryOperationName, operand); } public visitBinaryOpExp(context: ep.BinaryOpExpContext): Expression { @@ -55,16 +52,20 @@ export class ExpressionEngine implements ExpressionParserInterface { const left: Expression = this.visit(context.expression(0)); const right: Expression = this.visit(context.expression(1)); - return this.MakeExpression(binaryOperationName, left, right); + return this.makeExpression(binaryOperationName, left, right); } public visitFuncInvokeExp(context: ep.FuncInvokeExpContext): Expression { const parameters: Expression[] = this.processArgsList(context.argsList()); // Remove the check to check primaryExpression is just an IDENTIFIER to support "." in template name - const functionName: string = context.primaryExpression().text; + let functionName: string = context.primaryExpression().text; + + if (context.NON() !== undefined) { + functionName += context.NON().text; + } - return this.MakeExpression(functionName, ...parameters); + return this.makeExpression(functionName, ...parameters); } public visitIdAtom(context: ep.IdAtomContext): Expression { @@ -78,7 +79,7 @@ export class ExpressionEngine implements ExpressionParserInterface { } else if (symbol === 'null' || symbol === 'undefined') { result = new Constant(undefined); } else { - result = this.MakeExpression(ExpressionType.Accessor, new Constant(symbol)); + result = this.makeExpression(ExpressionType.Accessor, new Constant(symbol)); } return result; @@ -90,14 +91,14 @@ export class ExpressionEngine implements ExpressionParserInterface { instance = this.visit(context.primaryExpression()); - return this.MakeExpression(ExpressionType.Element, instance, property); + return this.makeExpression(ExpressionType.Element, instance, property); } public visitMemberAccessExp(context: ep.MemberAccessExpContext): Expression { const property: string = context.IDENTIFIER().text; const instance: Expression = this.visit(context.primaryExpression()); - return this.MakeExpression(ExpressionType.Accessor, new Constant(property), instance); + return this.makeExpression(ExpressionType.Accessor, new Constant(property), instance); } public visitNumericAtom(context: ep.NumericAtomContext): Expression { @@ -111,13 +112,22 @@ export class ExpressionEngine implements ExpressionParserInterface { public visitParenthesisExp = (context: ep.ParenthesisExpContext): Expression => this.visit(context.expression()); + public visitArrayCreationExp(context: ep.ArrayCreationExpContext): Expression { + const parameters: Expression[] = this.processArgsList(context.argsList()); + return this.makeExpression(ExpressionType.CreateArray, ...parameters); + } + public visitStringAtom(context: ep.StringAtomContext): Expression { - const text: string = context.text; - if (text.startsWith('\'')) { - return new Constant(Util.unescape(Util.trim(context.text, '\''))); - } else { // start with "" - return new Constant(Util.unescape(Util.trim(context.text, '"'))); + let text: string = context.text; + if (text.startsWith('\'') && text.endsWith('\'')) { + text = text.substr(1, text.length - 2).replace(/\\'/g, '\''); + } else if (text.startsWith('"') && text.endsWith('"')) { // start with "" + text = text.substr(1, text.length - 2).replace(/\\"/g, '"'); + } else { + throw new Error(`Invalid string ${ text }`); } + + return new Constant(this.evalEscape(text)); } public visitStringInterpolationAtom(context: ep.StringInterpolationAtomContext): Expression { @@ -126,26 +136,27 @@ export class ExpressionEngine implements ExpressionParserInterface { for (const node of context.stringInterpolation().children) { if (node instanceof TerminalNode){ switch((node as TerminalNode).symbol.type) { - case ep.ExpressionParser.TEMPLATE: + case ep.ExpressionAntlrParser.TEMPLATE: const expressionString = this.trimExpression(node.text); - children.push(new ExpressionEngine(this._lookup).parse(expressionString)); + children.push(Expression.parse(expressionString, this._lookupFunction)); break; - case ep.ExpressionParser.TEXT_CONTENT: + case ep.ExpressionAntlrParser.TEXT_CONTENT: children.push(new Constant(node.text)); break; - case ep.ExpressionParser.ESCAPE_CHARACTER: - children.push(new Constant(Util.unescape(node.text))); + case ep.ExpressionAntlrParser.ESCAPE_CHARACTER: + children.push(new Constant(this.evalEscape(node.text).replace(/\\`/g, '`').replace(/\\\$/g, '$'))); break; default: break; } } else { - children.push(new Constant(node.text)); + const text = this.evalEscape(node.text); + children.push(new Constant(text)); } } - return this.MakeExpression(ExpressionType.Concat, ...children); + return this.makeExpression(ExpressionType.Concat, ...children); } @@ -170,8 +181,14 @@ export class ExpressionEngine implements ExpressionParserInterface { protected defaultResult = (): Expression => new Constant(''); - private readonly MakeExpression = (type: string, ...children: Expression[]): Expression => - Expression.makeExpression(type, this._lookup(type), ...children) + private readonly makeExpression = (functionType: string, ...children: Expression[]): Expression => { + if (!this._lookupFunction(functionType)) { + throw Error(`${ functionType } does not have an evaluator, it's not a built-in function or a custom function.`); + } + + return Expression.makeExpression(functionType, this._lookupFunction(functionType), ...children); + } + private processArgsList(context: ep.ArgsListContext): Expression[] { const result: Expression[] = []; @@ -199,19 +216,34 @@ export class ExpressionEngine implements ExpressionParserInterface { return result.trim(); } - + private evalEscape(text: string): string { + const validCharactersDict: any = { + '\\r': '\r', + '\\n': '\n', + '\\t': '\t', + '\\\\': '\\' + }; + + return text.replace(this.escapeRegex, (sub: string): string => { + if (sub in validCharactersDict) { + return validCharactersDict[sub]; + } else { + return sub; + } + }); + } }; public constructor(lookup?: EvaluatorLookup) { - this.EvaluatorLookup = lookup === undefined ? ExpressionFunctions.lookup : lookup; + this.EvaluatorLookup = lookup || Expression.lookup; } protected static antlrParse(expression: string): ParseTree { const inputStream: ANTLRInputStream = new ANTLRInputStream(expression); - const lexer: ExpressionLexer = new ExpressionLexer(inputStream); + const lexer: ExpressionAntlrLexer = new ExpressionAntlrLexer(inputStream); lexer.removeErrorListeners(); const tokenStream: CommonTokenStream = new CommonTokenStream(lexer); - const parser: ExpressionParser = new ExpressionParser(tokenStream); + const parser: ExpressionAntlrParser = new ExpressionAntlrParser(tokenStream); parser.removeErrorListeners(); parser.addErrorListener(ParseErrorListener.Instance); parser.buildParseTree = true; @@ -230,11 +262,10 @@ export class ExpressionEngine implements ExpressionParserInterface { * @returns Expression tree. */ public parse(expression: string): Expression { - if (expression === undefined || expression === null || expression === '') { return new Constant(''); } else { - return new this.ExpressionTransformer(this.EvaluatorLookup).transform(ExpressionEngine.antlrParse(expression)); + return new this.ExpressionTransformer(this.EvaluatorLookup).transform(ExpressionParser.antlrParse(expression)); } } } diff --git a/libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrLexer.ts b/libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrLexer.ts new file mode 100644 index 0000000000..4b79bf04d3 --- /dev/null +++ b/libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrLexer.ts @@ -0,0 +1,273 @@ +// Generated from ../ExpressionAntlrLexer.g4 by ANTLR 4.6-SNAPSHOT + + +import { ATN } from "antlr4ts/atn/ATN"; +import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer"; +import { CharStream } from "antlr4ts/CharStream"; +import { Lexer } from "antlr4ts/Lexer"; +import { LexerATNSimulator } from "antlr4ts/atn/LexerATNSimulator"; +import { NotNull } from "antlr4ts/Decorators"; +import { Override } from "antlr4ts/Decorators"; +import { RuleContext } from "antlr4ts/RuleContext"; +import { Vocabulary } from "antlr4ts/Vocabulary"; +import { VocabularyImpl } from "antlr4ts/VocabularyImpl"; + +import * as Utils from "antlr4ts/misc/Utils"; + + +export class ExpressionAntlrLexer extends Lexer { + public static readonly STRING_INTERPOLATION_START = 1; + public static readonly PLUS = 2; + public static readonly SUBSTRACT = 3; + public static readonly NON = 4; + public static readonly XOR = 5; + public static readonly ASTERISK = 6; + public static readonly SLASH = 7; + public static readonly PERCENT = 8; + public static readonly DOUBLE_EQUAL = 9; + public static readonly NOT_EQUAL = 10; + public static readonly SINGLE_AND = 11; + public static readonly DOUBLE_AND = 12; + public static readonly DOUBLE_VERTICAL_CYLINDER = 13; + public static readonly LESS_THAN = 14; + public static readonly MORE_THAN = 15; + public static readonly LESS_OR_EQUAl = 16; + public static readonly MORE_OR_EQUAL = 17; + public static readonly OPEN_BRACKET = 18; + public static readonly CLOSE_BRACKET = 19; + public static readonly DOT = 20; + public static readonly OPEN_SQUARE_BRACKET = 21; + public static readonly CLOSE_SQUARE_BRACKET = 22; + public static readonly COMMA = 23; + public static readonly NUMBER = 24; + public static readonly WHITESPACE = 25; + public static readonly IDENTIFIER = 26; + public static readonly NEWLINE = 27; + public static readonly STRING = 28; + public static readonly CONSTANT = 29; + public static readonly INVALID_TOKEN_DEFAULT_MODE = 30; + public static readonly TEMPLATE = 31; + public static readonly ESCAPE_CHARACTER = 32; + public static readonly TEXT_CONTENT = 33; + public static readonly STRING_INTERPOLATION_MODE = 1; + // tslint:disable:no-trailing-whitespace + public static readonly modeNames: string[] = [ + "DEFAULT_MODE", "STRING_INTERPOLATION_MODE", + ]; + + public static readonly ruleNames: string[] = [ + "LETTER", "DIGIT", "STRING_INTERPOLATION_START", "PLUS", "SUBSTRACT", + "NON", "XOR", "ASTERISK", "SLASH", "PERCENT", "DOUBLE_EQUAL", "NOT_EQUAL", + "SINGLE_AND", "DOUBLE_AND", "DOUBLE_VERTICAL_CYLINDER", "LESS_THAN", "MORE_THAN", + "LESS_OR_EQUAl", "MORE_OR_EQUAL", "OPEN_BRACKET", "CLOSE_BRACKET", "DOT", + "OPEN_SQUARE_BRACKET", "CLOSE_SQUARE_BRACKET", "COMMA", "NUMBER", "WHITESPACE", + "IDENTIFIER", "NEWLINE", "STRING", "CONSTANT", "INVALID_TOKEN_DEFAULT_MODE", + "STRING_INTERPOLATION_END", "TEMPLATE", "ESCAPE_CHARACTER", "TEXT_CONTENT", + ]; + + private static readonly _LITERAL_NAMES: Array = [ + undefined, undefined, "'+'", "'-'", "'!'", "'^'", "'*'", "'/'", "'%'", + "'=='", undefined, "'&'", "'&&'", "'||'", "'<'", "'>'", "'<='", "'>='", + "'('", "')'", "'.'", "'['", "']'", "','", + ]; + private static readonly _SYMBOLIC_NAMES: Array = [ + undefined, "STRING_INTERPOLATION_START", "PLUS", "SUBSTRACT", "NON", "XOR", + "ASTERISK", "SLASH", "PERCENT", "DOUBLE_EQUAL", "NOT_EQUAL", "SINGLE_AND", + "DOUBLE_AND", "DOUBLE_VERTICAL_CYLINDER", "LESS_THAN", "MORE_THAN", "LESS_OR_EQUAl", + "MORE_OR_EQUAL", "OPEN_BRACKET", "CLOSE_BRACKET", "DOT", "OPEN_SQUARE_BRACKET", + "CLOSE_SQUARE_BRACKET", "COMMA", "NUMBER", "WHITESPACE", "IDENTIFIER", + "NEWLINE", "STRING", "CONSTANT", "INVALID_TOKEN_DEFAULT_MODE", "TEMPLATE", + "ESCAPE_CHARACTER", "TEXT_CONTENT", + ]; + public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(ExpressionAntlrLexer._LITERAL_NAMES, ExpressionAntlrLexer._SYMBOLIC_NAMES, []); + + // @Override + // @NotNull + public get vocabulary(): Vocabulary { + return ExpressionAntlrLexer.VOCABULARY; + } + // tslint:enable:no-trailing-whitespace + + + ignoreWS = true; // usually we ignore whitespace, but inside stringInterpolation, whitespace is significant + + + constructor(input: CharStream) { + super(input); + this._interp = new LexerATNSimulator(ExpressionAntlrLexer._ATN, this); + } + + // @Override + public get grammarFileName(): string { return "ExpressionAntlrLexer.g4"; } + + // @Override + public get ruleNames(): string[] { return ExpressionAntlrLexer.ruleNames; } + + // @Override + public get serializedATN(): string { return ExpressionAntlrLexer._serializedATN; } + + // @Override + public get modeNames(): string[] { return ExpressionAntlrLexer.modeNames; } + + // @Override + public action(_localctx: RuleContext, ruleIndex: number, actionIndex: number): void { + switch (ruleIndex) { + case 2: + this.STRING_INTERPOLATION_START_action(_localctx, actionIndex); + break; + + case 32: + this.STRING_INTERPOLATION_END_action(_localctx, actionIndex); + break; + } + } + private STRING_INTERPOLATION_START_action(_localctx: RuleContext, actionIndex: number): void { + switch (actionIndex) { + case 0: + this.ignoreWS = false; + break; + } + } + private STRING_INTERPOLATION_END_action(_localctx: RuleContext, actionIndex: number): void { + switch (actionIndex) { + case 1: + this.ignoreWS = true; + break; + } + } + // @Override + public sempred(_localctx: RuleContext, ruleIndex: number, predIndex: number): boolean { + switch (ruleIndex) { + case 26: + return this.WHITESPACE_sempred(_localctx, predIndex); + } + return true; + } + private WHITESPACE_sempred(_localctx: RuleContext, predIndex: number): boolean { + switch (predIndex) { + case 0: + return this.ignoreWS; + } + return true; + } + + public static readonly _serializedATN: string = + "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x02#\xEA\b\x01\b" + + "\x01\x04\x02\t\x02\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06\t" + + "\x06\x04\x07\t\x07\x04\b\t\b\x04\t\t\t\x04\n\t\n\x04\v\t\v\x04\f\t\f\x04" + + "\r\t\r\x04\x0E\t\x0E\x04\x0F\t\x0F\x04\x10\t\x10\x04\x11\t\x11\x04\x12" + + "\t\x12\x04\x13\t\x13\x04\x14\t\x14\x04\x15\t\x15\x04\x16\t\x16\x04\x17" + + "\t\x17\x04\x18\t\x18\x04\x19\t\x19\x04\x1A\t\x1A\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%\x03\x02\x03\x02\x03\x03\x03\x03\x03\x04\x03" + + "\x04\x03\x04\x03\x04\x03\x04\x03\x05\x03\x05\x03\x06\x03\x06\x03\x07\x03" + + "\x07\x03\b\x03\b\x03\t\x03\t\x03\n\x03\n\x03\v\x03\v\x03\f\x03\f\x03\f" + + "\x03\r\x03\r\x03\r\x03\r\x05\rk\n\r\x03\x0E\x03\x0E\x03\x0F\x03\x0F\x03" + + "\x0F\x03\x10\x03\x10\x03\x10\x03\x11\x03\x11\x03\x12\x03\x12\x03\x13\x03" + + "\x13\x03\x13\x03\x14\x03\x14\x03\x14\x03\x15\x03\x15\x03\x16\x03\x16\x03" + + "\x17\x03\x17\x03\x18\x03\x18\x03\x19\x03\x19\x03\x1A\x03\x1A\x03\x1B\x06" + + "\x1B\x8C\n\x1B\r\x1B\x0E\x1B\x8D\x03\x1B\x03\x1B\x06\x1B\x92\n\x1B\r\x1B" + + "\x0E\x1B\x93\x05\x1B\x96\n\x1B\x03\x1C\x03\x1C\x03\x1C\x03\x1C\x03\x1C" + + "\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x05\x1D\xA2\n\x1D\x03\x1D\x03" + + "\x1D\x03\x1D\x07\x1D\xA7\n\x1D\f\x1D\x0E\x1D\xAA\v\x1D\x03\x1E\x05\x1E" + + "\xAD\n\x1E\x03\x1E\x03\x1E\x03\x1E\x03\x1E\x03\x1F\x03\x1F\x03\x1F\x03" + + "\x1F\x07\x1F\xB7\n\x1F\f\x1F\x0E\x1F\xBA\v\x1F\x03\x1F\x03\x1F\x03\x1F" + + "\x03\x1F\x03\x1F\x07\x1F\xC1\n\x1F\f\x1F\x0E\x1F\xC4\v\x1F\x03\x1F\x05" + + "\x1F\xC7\n\x1F\x03 \x03 \x07 \xCB\n \f \x0E \xCE\v \x03 \x03 \x03!\x03" + + "!\x03\"\x03\"\x03\"\x03\"\x03\"\x03\"\x03#\x03#\x03#\x03#\x07#\xDE\n#" + + "\f#\x0E#\xE1\v#\x03#\x03#\x03$\x03$\x05$\xE7\n$\x03%\x03%\x05\xB8\xC2" + + "\xDF\x02\x02&\x04\x02\x02\x06\x02\x02\b\x02\x03\n\x02\x04\f\x02\x05\x0E" + + "\x02\x06\x10\x02\x07\x12\x02\b\x14\x02\t\x16\x02\n\x18\x02\v\x1A\x02\f" + + "\x1C\x02\r\x1E\x02\x0E \x02\x0F\"\x02\x10$\x02\x11&\x02\x12(\x02\x13*" + + "\x02\x14,\x02\x15.\x02\x160\x02\x172\x02\x184\x02\x196\x02\x1A8\x02\x1B" + + ":\x02\x1C<\x02\x1D>\x02\x1E@\x02\x1FB\x02 D\x02\x02F\x02!H\x02\"J\x02" + + "#\x04\x02\x03\r\x04\x02C\\c|\x03\x022;\x06\x02\v\v\"\"\xA2\xA2\uFF01\uFF01" + + "\x05\x02%%BBaa\x04\x02//aa\x04\x02))^^\x03\x02))\x04\x02$$^^\x03\x02$" + + "$\b\x02\f\f\x0F\x0F$$))}}\x7F\x7F\x04\x02\f\f\x0F\x0F\xFA\x02\b\x03\x02" + + "\x02\x02\x02\n\x03\x02\x02\x02\x02\f\x03\x02\x02\x02\x02\x0E\x03\x02\x02" + + "\x02\x02\x10\x03\x02\x02\x02\x02\x12\x03\x02\x02\x02\x02\x14\x03\x02\x02" + + "\x02\x02\x16\x03\x02\x02\x02\x02\x18\x03\x02\x02\x02\x02\x1A\x03\x02\x02" + + "\x02\x02\x1C\x03\x02\x02\x02\x02\x1E\x03\x02\x02\x02\x02 \x03\x02\x02" + + "\x02\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\x020\x03\x02\x02\x02\x022\x03\x02\x02\x02\x024\x03\x02\x02\x02" + + "\x026\x03\x02\x02\x02\x028\x03\x02\x02\x02\x02:\x03\x02\x02\x02\x02<\x03" + + "\x02\x02\x02\x02>\x03\x02\x02\x02\x02@\x03\x02\x02\x02\x02B\x03\x02\x02" + + "\x02\x03D\x03\x02\x02\x02\x03F\x03\x02\x02\x02\x03H\x03\x02\x02\x02\x03" + + "J\x03\x02\x02\x02\x04L\x03\x02\x02\x02\x06N\x03\x02\x02\x02\bP\x03\x02" + + "\x02\x02\nU\x03\x02\x02\x02\fW\x03\x02\x02\x02\x0EY\x03\x02\x02\x02\x10" + + "[\x03\x02\x02\x02\x12]\x03\x02\x02\x02\x14_\x03\x02\x02\x02\x16a\x03\x02" + + "\x02\x02\x18c\x03\x02\x02\x02\x1Aj\x03\x02\x02\x02\x1Cl\x03\x02\x02\x02" + + "\x1En\x03\x02\x02\x02 q\x03\x02\x02\x02\"t\x03\x02\x02\x02$v\x03\x02\x02" + + "\x02&x\x03\x02\x02\x02({\x03\x02\x02\x02*~\x03\x02\x02\x02,\x80\x03\x02" + + "\x02\x02.\x82\x03\x02\x02\x020\x84\x03\x02\x02\x022\x86\x03\x02\x02\x02" + + "4\x88\x03\x02\x02\x026\x8B\x03\x02\x02\x028\x97\x03\x02\x02\x02:\xA1\x03" + + "\x02\x02\x02<\xAC\x03\x02\x02\x02>\xC6\x03\x02\x02\x02@\xC8\x03\x02\x02" + + "\x02B\xD1\x03\x02\x02\x02D\xD3\x03\x02\x02\x02F\xD9\x03\x02\x02\x02H\xE4" + + "\x03\x02\x02\x02J\xE8\x03\x02\x02\x02LM\t\x02\x02\x02M\x05\x03\x02\x02" + + "\x02NO\t\x03\x02\x02O\x07\x03\x02\x02\x02PQ\x07b\x02\x02QR\b\x04\x02\x02" + + "RS\x03\x02\x02\x02ST\b\x04\x03\x02T\t\x03\x02\x02\x02UV\x07-\x02\x02V" + + "\v\x03\x02\x02\x02WX\x07/\x02\x02X\r\x03\x02\x02\x02YZ\x07#\x02\x02Z\x0F" + + "\x03\x02\x02\x02[\\\x07`\x02\x02\\\x11\x03\x02\x02\x02]^\x07,\x02\x02" + + "^\x13\x03\x02\x02\x02_`\x071\x02\x02`\x15\x03\x02\x02\x02ab\x07\'\x02" + + "\x02b\x17\x03\x02\x02\x02cd\x07?\x02\x02de\x07?\x02\x02e\x19\x03\x02\x02" + + "\x02fg\x07#\x02\x02gk\x07?\x02\x02hi\x07>\x02\x02ik\x07@\x02\x02jf\x03" + + "\x02\x02\x02jh\x03\x02\x02\x02k\x1B\x03\x02\x02\x02lm\x07(\x02\x02m\x1D" + + "\x03\x02\x02\x02no\x07(\x02\x02op\x07(\x02\x02p\x1F\x03\x02\x02\x02qr" + + "\x07~\x02\x02rs\x07~\x02\x02s!\x03\x02\x02\x02tu\x07>\x02\x02u#\x03\x02" + + "\x02\x02vw\x07@\x02\x02w%\x03\x02\x02\x02xy\x07>\x02\x02yz\x07?\x02\x02" + + "z\'\x03\x02\x02\x02{|\x07@\x02\x02|}\x07?\x02\x02})\x03\x02\x02\x02~\x7F" + + "\x07*\x02\x02\x7F+\x03\x02\x02\x02\x80\x81\x07+\x02\x02\x81-\x03\x02\x02" + + "\x02\x82\x83\x070\x02\x02\x83/\x03\x02\x02\x02\x84\x85\x07]\x02\x02\x85" + + "1\x03\x02\x02\x02\x86\x87\x07_\x02\x02\x873\x03\x02\x02\x02\x88\x89\x07" + + ".\x02\x02\x895\x03\x02\x02\x02\x8A\x8C\x05\x06\x03\x02\x8B\x8A\x03\x02" + + "\x02\x02\x8C\x8D\x03\x02\x02\x02\x8D\x8B\x03\x02\x02\x02\x8D\x8E\x03\x02" + + "\x02\x02\x8E\x95\x03\x02\x02\x02\x8F\x91\x070\x02\x02\x90\x92\x05\x06" + + "\x03\x02\x91\x90\x03\x02\x02\x02\x92\x93\x03\x02\x02\x02\x93\x91\x03\x02" + + "\x02\x02\x93\x94\x03\x02\x02\x02\x94\x96\x03\x02\x02\x02\x95\x8F\x03\x02" + + "\x02\x02\x95\x96\x03\x02\x02\x02\x967\x03\x02\x02\x02\x97\x98\t\x04\x02" + + "\x02\x98\x99\x06\x1C\x02\x02\x99\x9A\x03\x02\x02\x02\x9A\x9B\b\x1C\x04" + + "\x02\x9B9\x03\x02\x02\x02\x9C\xA2\x05\x04\x02\x02\x9D\xA2\t\x05\x02\x02" + + "\x9E\x9F\x07B\x02\x02\x9F\xA2\x07B\x02\x02\xA0\xA2\x04&\'\x02\xA1\x9C" + + "\x03\x02\x02\x02\xA1\x9D\x03\x02\x02\x02\xA1\x9E\x03\x02\x02\x02\xA1\xA0" + + "\x03\x02\x02\x02\xA2\xA8\x03\x02\x02\x02\xA3\xA7\x05\x04\x02\x02\xA4\xA7" + + "\x05\x06\x03\x02\xA5\xA7\t\x06\x02\x02\xA6\xA3\x03\x02\x02\x02\xA6\xA4" + + "\x03\x02\x02\x02\xA6\xA5\x03\x02\x02\x02\xA7\xAA\x03\x02\x02\x02\xA8\xA6" + + "\x03\x02\x02\x02\xA8\xA9\x03\x02\x02\x02\xA9;\x03\x02\x02\x02\xAA\xA8" + + "\x03\x02\x02\x02\xAB\xAD\x07\x0F\x02\x02\xAC\xAB\x03\x02\x02\x02\xAC\xAD" + + "\x03\x02\x02\x02\xAD\xAE\x03\x02\x02\x02\xAE\xAF\x07\f\x02\x02\xAF\xB0" + + "\x03\x02\x02\x02\xB0\xB1\b\x1E\x04\x02\xB1=\x03\x02\x02\x02\xB2\xB8\x07" + + ")\x02\x02\xB3\xB4\x07^\x02\x02\xB4\xB7\t\x07\x02\x02\xB5\xB7\n\b\x02\x02" + + "\xB6\xB3\x03\x02\x02\x02\xB6\xB5\x03\x02\x02\x02\xB7\xBA\x03\x02\x02\x02" + + "\xB8\xB9\x03\x02\x02\x02\xB8\xB6\x03\x02\x02\x02\xB9\xBB\x03\x02\x02\x02" + + "\xBA\xB8\x03\x02\x02\x02\xBB\xC7\x07)\x02\x02\xBC\xC2\x07$\x02\x02\xBD" + + "\xBE\x07^\x02\x02\xBE\xC1\t\t\x02\x02\xBF\xC1\n\n\x02\x02\xC0\xBD\x03" + + "\x02\x02\x02\xC0\xBF\x03\x02\x02\x02\xC1\xC4\x03\x02\x02\x02\xC2\xC3\x03" + + "\x02\x02\x02\xC2\xC0\x03\x02\x02\x02\xC3\xC5\x03\x02\x02\x02\xC4\xC2\x03" + + "\x02\x02\x02\xC5\xC7\x07$\x02\x02\xC6\xB2\x03\x02\x02\x02\xC6\xBC\x03" + + "\x02\x02\x02\xC7?\x03\x02\x02\x02\xC8\xCC\x07}\x02\x02\xC9\xCB\x058\x1C" + + "\x02\xCA\xC9\x03\x02\x02\x02\xCB\xCE\x03\x02\x02\x02\xCC\xCA\x03\x02\x02" + + "\x02\xCC\xCD\x03\x02\x02\x02\xCD\xCF\x03\x02\x02\x02\xCE\xCC\x03\x02\x02" + + "\x02\xCF\xD0\x07\x7F\x02\x02\xD0A\x03\x02\x02\x02\xD1\xD2\v\x02\x02\x02" + + "\xD2C\x03\x02\x02\x02\xD3\xD4\x07b\x02\x02\xD4\xD5\b\"\x05\x02\xD5\xD6" + + "\x03\x02\x02\x02\xD6\xD7\b\"\x06\x02\xD7\xD8\b\"\x07\x02\xD8E\x03\x02" + + "\x02\x02\xD9\xDA\x07&\x02\x02\xDA\xDF\x07}\x02\x02\xDB\xDE\x05>\x1F\x02" + + "\xDC\xDE\n\v\x02\x02\xDD\xDB\x03\x02\x02\x02\xDD\xDC\x03\x02\x02\x02\xDE" + + "\xE1\x03\x02\x02\x02\xDF\xE0\x03\x02\x02\x02\xDF\xDD\x03\x02\x02\x02\xE0" + + "\xE2\x03\x02\x02\x02\xE1\xDF\x03\x02\x02\x02\xE2\xE3\x07\x7F\x02\x02\xE3" + + "G\x03\x02\x02\x02\xE4\xE6\x07^\x02\x02\xE5\xE7\n\f\x02\x02\xE6\xE5\x03" + + "\x02\x02\x02\xE6\xE7\x03\x02\x02\x02\xE7I\x03\x02\x02\x02\xE8\xE9\n\f" + + "\x02\x02\xE9K\x03\x02\x02\x02\x15\x02\x03j\x8D\x93\x95\xA1\xA6\xA8\xAC" + + "\xB6\xB8\xC0\xC2\xC6\xCC\xDD\xDF\xE6\b\x03\x04\x02\x07\x03\x02\b\x02\x02" + + "\x03\"\x03\t\x03\x02\x06\x02\x02"; + public static __ATN: ATN; + public static get _ATN(): ATN { + if (!ExpressionAntlrLexer.__ATN) { + ExpressionAntlrLexer.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(ExpressionAntlrLexer._serializedATN)); + } + + return ExpressionAntlrLexer.__ATN; + } + +} + diff --git a/libraries/adaptive-expressions/src/parser/generated/ExpressionParser.ts b/libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrParser.ts similarity index 65% rename from libraries/adaptive-expressions/src/parser/generated/ExpressionParser.ts rename to libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrParser.ts index a6ac84a456..20356e2df6 100644 --- a/libraries/adaptive-expressions/src/parser/generated/ExpressionParser.ts +++ b/libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrParser.ts @@ -1,1423 +1,1491 @@ -// Generated from ../ExpressionParser.g4 by ANTLR 4.6-SNAPSHOT - - -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"; -import { TerminalNode } from "antlr4ts/tree/TerminalNode"; -import { Token } from "antlr4ts/Token"; -import { TokenStream } from "antlr4ts/TokenStream"; -import { Vocabulary } from "antlr4ts/Vocabulary"; -import { VocabularyImpl } from "antlr4ts/VocabularyImpl"; - -import * as Utils from "antlr4ts/misc/Utils"; - -import { ExpressionParserListener } from "./ExpressionParserListener"; -import { ExpressionParserVisitor } from "./ExpressionParserVisitor"; - - -export class ExpressionParser extends Parser { - public static readonly STRING_INTERPOLATION_START = 1; - public static readonly PLUS = 2; - public static readonly SUBSTRACT = 3; - public static readonly NON = 4; - public static readonly XOR = 5; - public static readonly ASTERISK = 6; - public static readonly SLASH = 7; - public static readonly PERCENT = 8; - public static readonly DOUBLE_EQUAL = 9; - public static readonly NOT_EQUAL = 10; - public static readonly SINGLE_AND = 11; - public static readonly DOUBLE_AND = 12; - public static readonly DOUBLE_VERTICAL_CYLINDER = 13; - public static readonly LESS_THAN = 14; - public static readonly MORE_THAN = 15; - public static readonly LESS_OR_EQUAl = 16; - public static readonly MORE_OR_EQUAL = 17; - public static readonly OPEN_BRACKET = 18; - public static readonly CLOSE_BRACKET = 19; - public static readonly DOT = 20; - public static readonly OPEN_SQUARE_BRACKET = 21; - public static readonly CLOSE_SQUARE_BRACKET = 22; - public static readonly COMMA = 23; - public static readonly NUMBER = 24; - public static readonly WHITESPACE = 25; - public static readonly IDENTIFIER = 26; - public static readonly NEWLINE = 27; - public static readonly STRING = 28; - public static readonly CONSTANT = 29; - public static readonly INVALID_TOKEN_DEFAULT_MODE = 30; - public static readonly TEMPLATE = 31; - public static readonly ESCAPE_CHARACTER = 32; - public static readonly TEXT_CONTENT = 33; - public static readonly RULE_file = 0; - public static readonly RULE_expression = 1; - public static readonly RULE_primaryExpression = 2; - public static readonly RULE_stringInterpolation = 3; - public static readonly RULE_textContent = 4; - public static readonly RULE_argsList = 5; - // tslint:disable:no-trailing-whitespace - public static readonly ruleNames: string[] = [ - "file", "expression", "primaryExpression", "stringInterpolation", "textContent", - "argsList", - ]; - - private static readonly _LITERAL_NAMES: Array = [ - undefined, undefined, "'+'", "'-'", "'!'", "'^'", "'*'", "'/'", "'%'", - "'=='", undefined, "'&'", "'&&'", "'||'", "'<'", "'>'", "'<='", "'>='", - "'('", "')'", "'.'", "'['", "']'", "','", - ]; - private static readonly _SYMBOLIC_NAMES: Array = [ - undefined, "STRING_INTERPOLATION_START", "PLUS", "SUBSTRACT", "NON", "XOR", - "ASTERISK", "SLASH", "PERCENT", "DOUBLE_EQUAL", "NOT_EQUAL", "SINGLE_AND", - "DOUBLE_AND", "DOUBLE_VERTICAL_CYLINDER", "LESS_THAN", "MORE_THAN", "LESS_OR_EQUAl", - "MORE_OR_EQUAL", "OPEN_BRACKET", "CLOSE_BRACKET", "DOT", "OPEN_SQUARE_BRACKET", - "CLOSE_SQUARE_BRACKET", "COMMA", "NUMBER", "WHITESPACE", "IDENTIFIER", - "NEWLINE", "STRING", "CONSTANT", "INVALID_TOKEN_DEFAULT_MODE", "TEMPLATE", - "ESCAPE_CHARACTER", "TEXT_CONTENT", - ]; - public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(ExpressionParser._LITERAL_NAMES, ExpressionParser._SYMBOLIC_NAMES, []); - - // @Override - // @NotNull - public get vocabulary(): Vocabulary { - return ExpressionParser.VOCABULARY; - } - // tslint:enable:no-trailing-whitespace - - // @Override - public get grammarFileName(): string { return "ExpressionParser.g4"; } - - // @Override - public get ruleNames(): string[] { return ExpressionParser.ruleNames; } - - // @Override - public get serializedATN(): string { return ExpressionParser._serializedATN; } - - constructor(input: TokenStream) { - super(input); - this._interp = new ParserATNSimulator(ExpressionParser._ATN, this); - } - // @RuleVersion(0) - public file(): FileContext { - let _localctx: FileContext = new FileContext(this._ctx, this.state); - this.enterRule(_localctx, 0, ExpressionParser.RULE_file); - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 12; - this.expression(0); - this.state = 13; - this.match(ExpressionParser.EOF); - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - - public expression(): ExpressionContext; - public expression(_p: number): ExpressionContext; - // @RuleVersion(0) - public expression(_p?: number): ExpressionContext { - if (_p === undefined) { - _p = 0; - } - - let _parentctx: ParserRuleContext = this._ctx; - let _parentState: number = this.state; - let _localctx: ExpressionContext = new ExpressionContext(this._ctx, _parentState); - let _prevctx: ExpressionContext = _localctx; - let _startState: number = 2; - this.enterRecursionRule(_localctx, 2, ExpressionParser.RULE_expression, _p); - let _la: number; - try { - let _alt: number; - this.enterOuterAlt(_localctx, 1); - { - this.state = 19; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case ExpressionParser.PLUS: - case ExpressionParser.SUBSTRACT: - case ExpressionParser.NON: - { - _localctx = new UnaryOpExpContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; - - this.state = 16; - _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << ExpressionParser.PLUS) | (1 << ExpressionParser.SUBSTRACT) | (1 << ExpressionParser.NON))) !== 0))) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 17; - this.expression(10); - } - break; - case ExpressionParser.STRING_INTERPOLATION_START: - case ExpressionParser.OPEN_BRACKET: - case ExpressionParser.NUMBER: - case ExpressionParser.IDENTIFIER: - case ExpressionParser.STRING: - case ExpressionParser.CONSTANT: - { - _localctx = new PrimaryExpContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; - this.state = 18; - this.primaryExpression(0); - } - break; - default: - throw new NoViableAltException(this); - } - this._ctx._stop = this._input.tryLT(-1); - this.state = 47; - this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 2, this._ctx); - while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { - if (_alt === 1) { - if (this._parseListeners != null) { - this.triggerExitRuleEvent(); - } - _prevctx = _localctx; - { - this.state = 45; - this._errHandler.sync(this); - switch ( this.interpreter.adaptivePredict(this._input, 1, this._ctx) ) { - case 1: - { - _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, ExpressionParser.RULE_expression); - this.state = 21; - if (!(this.precpred(this._ctx, 9))) { - throw new FailedPredicateException(this, "this.precpred(this._ctx, 9)"); - } - this.state = 22; - this.match(ExpressionParser.XOR); - this.state = 23; - this.expression(9); - } - break; - - case 2: - { - _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, ExpressionParser.RULE_expression); - this.state = 24; - if (!(this.precpred(this._ctx, 8))) { - throw new FailedPredicateException(this, "this.precpred(this._ctx, 8)"); - } - this.state = 25; - _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << ExpressionParser.ASTERISK) | (1 << ExpressionParser.SLASH) | (1 << ExpressionParser.PERCENT))) !== 0))) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 26; - this.expression(9); - } - break; - - case 3: - { - _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, ExpressionParser.RULE_expression); - this.state = 27; - if (!(this.precpred(this._ctx, 7))) { - throw new FailedPredicateException(this, "this.precpred(this._ctx, 7)"); - } - this.state = 28; - _la = this._input.LA(1); - if (!(_la === ExpressionParser.PLUS || _la === ExpressionParser.SUBSTRACT)) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 29; - this.expression(8); - } - break; - - case 4: - { - _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, ExpressionParser.RULE_expression); - this.state = 30; - if (!(this.precpred(this._ctx, 6))) { - throw new FailedPredicateException(this, "this.precpred(this._ctx, 6)"); - } - this.state = 31; - _la = this._input.LA(1); - if (!(_la === ExpressionParser.DOUBLE_EQUAL || _la === ExpressionParser.NOT_EQUAL)) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 32; - this.expression(7); - } - break; - - case 5: - { - _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, ExpressionParser.RULE_expression); - this.state = 33; - if (!(this.precpred(this._ctx, 5))) { - throw new FailedPredicateException(this, "this.precpred(this._ctx, 5)"); - } - { - this.state = 34; - this.match(ExpressionParser.SINGLE_AND); - } - this.state = 35; - this.expression(6); - } - break; - - case 6: - { - _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, ExpressionParser.RULE_expression); - this.state = 36; - if (!(this.precpred(this._ctx, 4))) { - throw new FailedPredicateException(this, "this.precpred(this._ctx, 4)"); - } - this.state = 37; - _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << ExpressionParser.LESS_THAN) | (1 << ExpressionParser.MORE_THAN) | (1 << ExpressionParser.LESS_OR_EQUAl) | (1 << ExpressionParser.MORE_OR_EQUAL))) !== 0))) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 38; - this.expression(5); - } - break; - - case 7: - { - _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, ExpressionParser.RULE_expression); - this.state = 39; - if (!(this.precpred(this._ctx, 3))) { - throw new FailedPredicateException(this, "this.precpred(this._ctx, 3)"); - } - this.state = 40; - this.match(ExpressionParser.DOUBLE_AND); - this.state = 41; - this.expression(4); - } - break; - - case 8: - { - _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, ExpressionParser.RULE_expression); - this.state = 42; - if (!(this.precpred(this._ctx, 2))) { - throw new FailedPredicateException(this, "this.precpred(this._ctx, 2)"); - } - this.state = 43; - this.match(ExpressionParser.DOUBLE_VERTICAL_CYLINDER); - this.state = 44; - this.expression(3); - } - break; - } - } - } - this.state = 49; - this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 2, this._ctx); - } - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.unrollRecursionContexts(_parentctx); - } - return _localctx; - } - - public primaryExpression(): PrimaryExpressionContext; - public primaryExpression(_p: number): PrimaryExpressionContext; - // @RuleVersion(0) - public primaryExpression(_p?: number): PrimaryExpressionContext { - if (_p === undefined) { - _p = 0; - } - - let _parentctx: ParserRuleContext = this._ctx; - let _parentState: number = this.state; - let _localctx: PrimaryExpressionContext = new PrimaryExpressionContext(this._ctx, _parentState); - let _prevctx: PrimaryExpressionContext = _localctx; - let _startState: number = 4; - this.enterRecursionRule(_localctx, 4, ExpressionParser.RULE_primaryExpression, _p); - let _la: number; - try { - let _alt: number; - this.enterOuterAlt(_localctx, 1); - { - this.state = 60; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case ExpressionParser.OPEN_BRACKET: - { - _localctx = new ParenthesisExpContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; - - this.state = 51; - this.match(ExpressionParser.OPEN_BRACKET); - this.state = 52; - this.expression(0); - this.state = 53; - this.match(ExpressionParser.CLOSE_BRACKET); - } - break; - case ExpressionParser.CONSTANT: - { - _localctx = new ConstantAtomContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; - this.state = 55; - this.match(ExpressionParser.CONSTANT); - } - break; - case ExpressionParser.NUMBER: - { - _localctx = new NumericAtomContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; - this.state = 56; - this.match(ExpressionParser.NUMBER); - } - break; - case ExpressionParser.STRING: - { - _localctx = new StringAtomContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; - this.state = 57; - this.match(ExpressionParser.STRING); - } - break; - case ExpressionParser.IDENTIFIER: - { - _localctx = new IdAtomContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; - this.state = 58; - this.match(ExpressionParser.IDENTIFIER); - } - break; - case ExpressionParser.STRING_INTERPOLATION_START: - { - _localctx = new StringInterpolationAtomContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; - this.state = 59; - this.stringInterpolation(); - } - break; - default: - throw new NoViableAltException(this); - } - this._ctx._stop = this._input.tryLT(-1); - this.state = 78; - this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 6, this._ctx); - while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { - if (_alt === 1) { - if (this._parseListeners != null) { - this.triggerExitRuleEvent(); - } - _prevctx = _localctx; - { - this.state = 76; - this._errHandler.sync(this); - switch ( this.interpreter.adaptivePredict(this._input, 5, this._ctx) ) { - case 1: - { - _localctx = new MemberAccessExpContext(new PrimaryExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, ExpressionParser.RULE_primaryExpression); - this.state = 62; - if (!(this.precpred(this._ctx, 3))) { - throw new FailedPredicateException(this, "this.precpred(this._ctx, 3)"); - } - this.state = 63; - this.match(ExpressionParser.DOT); - this.state = 64; - this.match(ExpressionParser.IDENTIFIER); - } - break; - - case 2: - { - _localctx = new FuncInvokeExpContext(new PrimaryExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, ExpressionParser.RULE_primaryExpression); - this.state = 65; - if (!(this.precpred(this._ctx, 2))) { - throw new FailedPredicateException(this, "this.precpred(this._ctx, 2)"); - } - this.state = 66; - this.match(ExpressionParser.OPEN_BRACKET); - this.state = 68; - this._errHandler.sync(this); - _la = this._input.LA(1); - if ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << ExpressionParser.STRING_INTERPOLATION_START) | (1 << ExpressionParser.PLUS) | (1 << ExpressionParser.SUBSTRACT) | (1 << ExpressionParser.NON) | (1 << ExpressionParser.OPEN_BRACKET) | (1 << ExpressionParser.NUMBER) | (1 << ExpressionParser.IDENTIFIER) | (1 << ExpressionParser.STRING) | (1 << ExpressionParser.CONSTANT))) !== 0)) { - { - this.state = 67; - this.argsList(); - } - } - - this.state = 70; - this.match(ExpressionParser.CLOSE_BRACKET); - } - break; - - case 3: - { - _localctx = new IndexAccessExpContext(new PrimaryExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, ExpressionParser.RULE_primaryExpression); - this.state = 71; - if (!(this.precpred(this._ctx, 1))) { - throw new FailedPredicateException(this, "this.precpred(this._ctx, 1)"); - } - this.state = 72; - this.match(ExpressionParser.OPEN_SQUARE_BRACKET); - this.state = 73; - this.expression(0); - this.state = 74; - this.match(ExpressionParser.CLOSE_SQUARE_BRACKET); - } - break; - } - } - } - this.state = 80; - this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 6, this._ctx); - } - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.unrollRecursionContexts(_parentctx); - } - return _localctx; - } - // @RuleVersion(0) - public stringInterpolation(): StringInterpolationContext { - let _localctx: StringInterpolationContext = new StringInterpolationContext(this._ctx, this.state); - this.enterRule(_localctx, 6, ExpressionParser.RULE_stringInterpolation); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 81; - this.match(ExpressionParser.STRING_INTERPOLATION_START); - this.state = 85; - this._errHandler.sync(this); - _la = this._input.LA(1); - do { - { - this.state = 85; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case ExpressionParser.ESCAPE_CHARACTER: - { - this.state = 82; - this.match(ExpressionParser.ESCAPE_CHARACTER); - } - break; - case ExpressionParser.TEMPLATE: - { - this.state = 83; - this.match(ExpressionParser.TEMPLATE); - } - break; - case ExpressionParser.TEXT_CONTENT: - { - this.state = 84; - this.textContent(); - } - break; - default: - throw new NoViableAltException(this); - } - } - this.state = 87; - this._errHandler.sync(this); - _la = this._input.LA(1); - } while (((((_la - 31)) & ~0x1F) === 0 && ((1 << (_la - 31)) & ((1 << (ExpressionParser.TEMPLATE - 31)) | (1 << (ExpressionParser.ESCAPE_CHARACTER - 31)) | (1 << (ExpressionParser.TEXT_CONTENT - 31)))) !== 0)); - this.state = 89; - this.match(ExpressionParser.STRING_INTERPOLATION_START); - } - } - 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 textContent(): TextContentContext { - let _localctx: TextContentContext = new TextContentContext(this._ctx, this.state); - this.enterRule(_localctx, 8, ExpressionParser.RULE_textContent); - try { - let _alt: number; - this.enterOuterAlt(_localctx, 1); - { - this.state = 92; - this._errHandler.sync(this); - _alt = 1; - do { - switch (_alt) { - case 1: - { - { - this.state = 91; - this.match(ExpressionParser.TEXT_CONTENT); - } - } - break; - default: - throw new NoViableAltException(this); - } - this.state = 94; - this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 9, this._ctx); - } while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER); - } - } - 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 argsList(): ArgsListContext { - let _localctx: ArgsListContext = new ArgsListContext(this._ctx, this.state); - this.enterRule(_localctx, 10, ExpressionParser.RULE_argsList); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 96; - this.expression(0); - this.state = 101; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === ExpressionParser.COMMA) { - { - { - this.state = 97; - this.match(ExpressionParser.COMMA); - this.state = 98; - this.expression(0); - } - } - this.state = 103; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - - public sempred(_localctx: RuleContext, ruleIndex: number, predIndex: number): boolean { - switch (ruleIndex) { - case 1: - return this.expression_sempred(_localctx as ExpressionContext, predIndex); - - case 2: - return this.primaryExpression_sempred(_localctx as PrimaryExpressionContext, predIndex); - } - return true; - } - private expression_sempred(_localctx: ExpressionContext, predIndex: number): boolean { - switch (predIndex) { - case 0: - return this.precpred(this._ctx, 9); - - case 1: - return this.precpred(this._ctx, 8); - - case 2: - return this.precpred(this._ctx, 7); - - case 3: - return this.precpred(this._ctx, 6); - - case 4: - return this.precpred(this._ctx, 5); - - case 5: - return this.precpred(this._ctx, 4); - - case 6: - return this.precpred(this._ctx, 3); - - case 7: - return this.precpred(this._ctx, 2); - } - return true; - } - private primaryExpression_sempred(_localctx: PrimaryExpressionContext, predIndex: number): boolean { - switch (predIndex) { - case 8: - return this.precpred(this._ctx, 3); - - case 9: - return this.precpred(this._ctx, 2); - - case 10: - return this.precpred(this._ctx, 1); - } - return true; - } - - public static readonly _serializedATN: string = - "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x03#k\x04\x02\t\x02" + - "\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06\t\x06\x04\x07\t\x07" + - "\x03\x02\x03\x02\x03\x02\x03\x03\x03\x03\x03\x03\x03\x03\x05\x03\x16\n" + - "\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\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x07\x030\n\x03\f" + - "\x03\x0E\x033\v\x03\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03" + - "\x04\x03\x04\x03\x04\x03\x04\x05\x04?\n\x04\x03\x04\x03\x04\x03\x04\x03" + - "\x04\x03\x04\x03\x04\x05\x04G\n\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03" + - "\x04\x03\x04\x07\x04O\n\x04\f\x04\x0E\x04R\v\x04\x03\x05\x03\x05\x03\x05" + - "\x03\x05\x06\x05X\n\x05\r\x05\x0E\x05Y\x03\x05\x03\x05\x03\x06\x06\x06" + - "_\n\x06\r\x06\x0E\x06`\x03\x07\x03\x07\x03\x07\x07\x07f\n\x07\f\x07\x0E" + - "\x07i\v\x07\x03\x07\x02\x02\x04\x04\x06\b\x02\x02\x04\x02\x06\x02\b\x02" + - "\n\x02\f\x02\x02\x07\x03\x02\x04\x06\x03\x02\b\n\x03\x02\x04\x05\x03\x02" + - "\v\f\x03\x02\x10\x13{\x02\x0E\x03\x02\x02\x02\x04\x15\x03\x02\x02\x02" + - "\x06>\x03\x02\x02\x02\bS\x03\x02\x02\x02\n^\x03\x02\x02\x02\fb\x03\x02" + - "\x02\x02\x0E\x0F\x05\x04\x03\x02\x0F\x10\x07\x02\x02\x03\x10\x03\x03\x02" + - "\x02\x02\x11\x12\b\x03\x01\x02\x12\x13\t\x02\x02\x02\x13\x16\x05\x04\x03" + - "\f\x14\x16\x05\x06\x04\x02\x15\x11\x03\x02\x02\x02\x15\x14\x03\x02\x02" + - "\x02\x161\x03\x02\x02\x02\x17\x18\f\v\x02\x02\x18\x19\x07\x07\x02\x02" + - "\x190\x05\x04\x03\v\x1A\x1B\f\n\x02\x02\x1B\x1C\t\x03\x02\x02\x1C0\x05" + - "\x04\x03\v\x1D\x1E\f\t\x02\x02\x1E\x1F\t\x04\x02\x02\x1F0\x05\x04\x03" + - "\n !\f\b\x02\x02!\"\t\x05\x02\x02\"0\x05\x04\x03\t#$\f\x07\x02\x02$%\x07" + - "\r\x02\x02%0\x05\x04\x03\b&\'\f\x06\x02\x02\'(\t\x06\x02\x02(0\x05\x04" + - "\x03\x07)*\f\x05\x02\x02*+\x07\x0E\x02\x02+0\x05\x04\x03\x06,-\f\x04\x02" + - "\x02-.\x07\x0F\x02\x02.0\x05\x04\x03\x05/\x17\x03\x02\x02\x02/\x1A\x03" + - "\x02\x02\x02/\x1D\x03\x02\x02\x02/ \x03\x02\x02\x02/#\x03\x02\x02\x02" + - "/&\x03\x02\x02\x02/)\x03\x02\x02\x02/,\x03\x02\x02\x0203\x03\x02\x02\x02" + - "1/\x03\x02\x02\x0212\x03\x02\x02\x022\x05\x03\x02\x02\x0231\x03\x02\x02" + - "\x0245\b\x04\x01\x0256\x07\x14\x02\x0267\x05\x04\x03\x0278\x07\x15\x02" + - "\x028?\x03\x02\x02\x029?\x07\x1F\x02\x02:?\x07\x1A\x02\x02;?\x07\x1E\x02" + - "\x024\x03\x02\x02\x02>9\x03\x02\x02" + - "\x02>:\x03\x02\x02\x02>;\x03\x02\x02\x02><\x03\x02\x02\x02>=\x03\x02\x02" + - "\x02?P\x03\x02\x02\x02@A\f\x05\x02\x02AB\x07\x16\x02\x02BO\x07\x1C\x02" + - "\x02CD\f\x04\x02\x02DF\x07\x14\x02\x02EG\x05\f\x07\x02FE\x03\x02\x02\x02" + - "FG\x03\x02\x02\x02GH\x03\x02\x02\x02HO\x07\x15\x02\x02IJ\f\x03\x02\x02" + - "JK\x07\x17\x02\x02KL\x05\x04\x03\x02LM\x07\x18\x02\x02MO\x03\x02\x02\x02" + - "N@\x03\x02\x02\x02NC\x03\x02\x02\x02NI\x03\x02\x02\x02OR\x03\x02\x02\x02" + - "PN\x03\x02\x02\x02PQ\x03\x02\x02\x02Q\x07\x03\x02\x02\x02RP\x03\x02\x02" + - "\x02SW\x07\x03\x02\x02TX\x07\"\x02\x02UX\x07!\x02\x02VX\x05\n\x06\x02" + - "WT\x03\x02\x02\x02WU\x03\x02\x02\x02WV\x03\x02\x02\x02XY\x03\x02\x02\x02" + - "YW\x03\x02\x02\x02YZ\x03\x02\x02\x02Z[\x03\x02\x02\x02[\\\x07\x03\x02" + - "\x02\\\t\x03\x02\x02\x02]_\x07#\x02\x02^]\x03\x02\x02\x02_`\x03\x02\x02" + - "\x02`^\x03\x02\x02\x02`a\x03\x02\x02\x02a\v\x03\x02\x02\x02bg\x05\x04" + - "\x03\x02cd\x07\x19\x02\x02df\x05\x04\x03\x02ec\x03\x02\x02\x02fi\x03\x02" + - "\x02\x02ge\x03\x02\x02\x02gh\x03\x02\x02\x02h\r\x03\x02\x02\x02ig\x03" + - "\x02\x02\x02\r\x15/1>FNPWY`g"; - public static __ATN: ATN; - public static get _ATN(): ATN { - if (!ExpressionParser.__ATN) { - ExpressionParser.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(ExpressionParser._serializedATN)); - } - - return ExpressionParser.__ATN; - } - -} - -export class FileContext extends ParserRuleContext { - public expression(): ExpressionContext { - return this.getRuleContext(0, ExpressionContext); - } - public EOF(): TerminalNode { return this.getToken(ExpressionParser.EOF, 0); } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return ExpressionParser.RULE_file; } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterFile) { - listener.enterFile(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitFile) { - listener.exitFile(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitFile) { - return visitor.visitFile(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class ExpressionContext extends ParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return ExpressionParser.RULE_expression; } - public copyFrom(ctx: ExpressionContext): void { - super.copyFrom(ctx); - } -} -export class UnaryOpExpContext extends ExpressionContext { - public expression(): ExpressionContext { - return this.getRuleContext(0, ExpressionContext); - } - public NON(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.NON, 0); } - public SUBSTRACT(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.SUBSTRACT, 0); } - public PLUS(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.PLUS, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterUnaryOpExp) { - listener.enterUnaryOpExp(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitUnaryOpExp) { - listener.exitUnaryOpExp(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitUnaryOpExp) { - return visitor.visitUnaryOpExp(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class BinaryOpExpContext extends ExpressionContext { - public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { - if (i === undefined) { - return this.getRuleContexts(ExpressionContext); - } else { - return this.getRuleContext(i, ExpressionContext); - } - } - public XOR(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.XOR, 0); } - public ASTERISK(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.ASTERISK, 0); } - public SLASH(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.SLASH, 0); } - public PERCENT(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.PERCENT, 0); } - public PLUS(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.PLUS, 0); } - public SUBSTRACT(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.SUBSTRACT, 0); } - public DOUBLE_EQUAL(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.DOUBLE_EQUAL, 0); } - public NOT_EQUAL(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.NOT_EQUAL, 0); } - public SINGLE_AND(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.SINGLE_AND, 0); } - public LESS_THAN(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.LESS_THAN, 0); } - public LESS_OR_EQUAl(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.LESS_OR_EQUAl, 0); } - public MORE_THAN(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.MORE_THAN, 0); } - public MORE_OR_EQUAL(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.MORE_OR_EQUAL, 0); } - public DOUBLE_AND(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.DOUBLE_AND, 0); } - public DOUBLE_VERTICAL_CYLINDER(): TerminalNode | undefined { return this.tryGetToken(ExpressionParser.DOUBLE_VERTICAL_CYLINDER, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterBinaryOpExp) { - listener.enterBinaryOpExp(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitBinaryOpExp) { - listener.exitBinaryOpExp(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitBinaryOpExp) { - return visitor.visitBinaryOpExp(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class PrimaryExpContext extends ExpressionContext { - public primaryExpression(): PrimaryExpressionContext { - return this.getRuleContext(0, PrimaryExpressionContext); - } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterPrimaryExp) { - listener.enterPrimaryExp(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitPrimaryExp) { - listener.exitPrimaryExp(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitPrimaryExp) { - return visitor.visitPrimaryExp(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class PrimaryExpressionContext extends ParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return ExpressionParser.RULE_primaryExpression; } - public copyFrom(ctx: PrimaryExpressionContext): void { - super.copyFrom(ctx); - } -} -export class FuncInvokeExpContext extends PrimaryExpressionContext { - public primaryExpression(): PrimaryExpressionContext { - return this.getRuleContext(0, PrimaryExpressionContext); - } - public OPEN_BRACKET(): TerminalNode { return this.getToken(ExpressionParser.OPEN_BRACKET, 0); } - public CLOSE_BRACKET(): TerminalNode { return this.getToken(ExpressionParser.CLOSE_BRACKET, 0); } - public argsList(): ArgsListContext | undefined { - return this.tryGetRuleContext(0, ArgsListContext); - } - constructor(ctx: PrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterFuncInvokeExp) { - listener.enterFuncInvokeExp(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitFuncInvokeExp) { - listener.exitFuncInvokeExp(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitFuncInvokeExp) { - return visitor.visitFuncInvokeExp(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class ConstantAtomContext extends PrimaryExpressionContext { - public CONSTANT(): TerminalNode { return this.getToken(ExpressionParser.CONSTANT, 0); } - constructor(ctx: PrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterConstantAtom) { - listener.enterConstantAtom(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitConstantAtom) { - listener.exitConstantAtom(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitConstantAtom) { - return visitor.visitConstantAtom(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class IdAtomContext extends PrimaryExpressionContext { - public IDENTIFIER(): TerminalNode { return this.getToken(ExpressionParser.IDENTIFIER, 0); } - constructor(ctx: PrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterIdAtom) { - listener.enterIdAtom(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitIdAtom) { - listener.exitIdAtom(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitIdAtom) { - return visitor.visitIdAtom(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class StringAtomContext extends PrimaryExpressionContext { - public STRING(): TerminalNode { return this.getToken(ExpressionParser.STRING, 0); } - constructor(ctx: PrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterStringAtom) { - listener.enterStringAtom(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitStringAtom) { - listener.exitStringAtom(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitStringAtom) { - return visitor.visitStringAtom(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class IndexAccessExpContext extends PrimaryExpressionContext { - public primaryExpression(): PrimaryExpressionContext { - return this.getRuleContext(0, PrimaryExpressionContext); - } - public OPEN_SQUARE_BRACKET(): TerminalNode { return this.getToken(ExpressionParser.OPEN_SQUARE_BRACKET, 0); } - public expression(): ExpressionContext { - return this.getRuleContext(0, ExpressionContext); - } - public CLOSE_SQUARE_BRACKET(): TerminalNode { return this.getToken(ExpressionParser.CLOSE_SQUARE_BRACKET, 0); } - constructor(ctx: PrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterIndexAccessExp) { - listener.enterIndexAccessExp(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitIndexAccessExp) { - listener.exitIndexAccessExp(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitIndexAccessExp) { - return visitor.visitIndexAccessExp(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class StringInterpolationAtomContext extends PrimaryExpressionContext { - public stringInterpolation(): StringInterpolationContext { - return this.getRuleContext(0, StringInterpolationContext); - } - constructor(ctx: PrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterStringInterpolationAtom) { - listener.enterStringInterpolationAtom(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitStringInterpolationAtom) { - listener.exitStringInterpolationAtom(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitStringInterpolationAtom) { - return visitor.visitStringInterpolationAtom(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class MemberAccessExpContext extends PrimaryExpressionContext { - public primaryExpression(): PrimaryExpressionContext { - return this.getRuleContext(0, PrimaryExpressionContext); - } - public DOT(): TerminalNode { return this.getToken(ExpressionParser.DOT, 0); } - public IDENTIFIER(): TerminalNode { return this.getToken(ExpressionParser.IDENTIFIER, 0); } - constructor(ctx: PrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterMemberAccessExp) { - listener.enterMemberAccessExp(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitMemberAccessExp) { - listener.exitMemberAccessExp(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitMemberAccessExp) { - return visitor.visitMemberAccessExp(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class ParenthesisExpContext extends PrimaryExpressionContext { - public OPEN_BRACKET(): TerminalNode { return this.getToken(ExpressionParser.OPEN_BRACKET, 0); } - public expression(): ExpressionContext { - return this.getRuleContext(0, ExpressionContext); - } - public CLOSE_BRACKET(): TerminalNode { return this.getToken(ExpressionParser.CLOSE_BRACKET, 0); } - constructor(ctx: PrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterParenthesisExp) { - listener.enterParenthesisExp(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitParenthesisExp) { - listener.exitParenthesisExp(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitParenthesisExp) { - return visitor.visitParenthesisExp(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class NumericAtomContext extends PrimaryExpressionContext { - public NUMBER(): TerminalNode { return this.getToken(ExpressionParser.NUMBER, 0); } - constructor(ctx: PrimaryExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterNumericAtom) { - listener.enterNumericAtom(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitNumericAtom) { - listener.exitNumericAtom(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitNumericAtom) { - return visitor.visitNumericAtom(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class StringInterpolationContext extends ParserRuleContext { - public STRING_INTERPOLATION_START(): TerminalNode[]; - public STRING_INTERPOLATION_START(i: number): TerminalNode; - public STRING_INTERPOLATION_START(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(ExpressionParser.STRING_INTERPOLATION_START); - } else { - return this.getToken(ExpressionParser.STRING_INTERPOLATION_START, i); - } - } - public ESCAPE_CHARACTER(): TerminalNode[]; - public ESCAPE_CHARACTER(i: number): TerminalNode; - public ESCAPE_CHARACTER(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(ExpressionParser.ESCAPE_CHARACTER); - } else { - return this.getToken(ExpressionParser.ESCAPE_CHARACTER, i); - } - } - public TEMPLATE(): TerminalNode[]; - public TEMPLATE(i: number): TerminalNode; - public TEMPLATE(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(ExpressionParser.TEMPLATE); - } else { - return this.getToken(ExpressionParser.TEMPLATE, i); - } - } - public textContent(): TextContentContext[]; - public textContent(i: number): TextContentContext; - public textContent(i?: number): TextContentContext | TextContentContext[] { - if (i === undefined) { - return this.getRuleContexts(TextContentContext); - } else { - return this.getRuleContext(i, TextContentContext); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return ExpressionParser.RULE_stringInterpolation; } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterStringInterpolation) { - listener.enterStringInterpolation(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitStringInterpolation) { - listener.exitStringInterpolation(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitStringInterpolation) { - return visitor.visitStringInterpolation(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class TextContentContext extends ParserRuleContext { - public TEXT_CONTENT(): TerminalNode[]; - public TEXT_CONTENT(i: number): TerminalNode; - public TEXT_CONTENT(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(ExpressionParser.TEXT_CONTENT); - } else { - return this.getToken(ExpressionParser.TEXT_CONTENT, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return ExpressionParser.RULE_textContent; } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterTextContent) { - listener.enterTextContent(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitTextContent) { - listener.exitTextContent(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitTextContent) { - return visitor.visitTextContent(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class ArgsListContext extends ParserRuleContext { - public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { - if (i === undefined) { - return this.getRuleContexts(ExpressionContext); - } else { - return this.getRuleContext(i, ExpressionContext); - } - } - public COMMA(): TerminalNode[]; - public COMMA(i: number): TerminalNode; - public COMMA(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(ExpressionParser.COMMA); - } else { - return this.getToken(ExpressionParser.COMMA, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return ExpressionParser.RULE_argsList; } - // @Override - public enterRule(listener: ExpressionParserListener): void { - if (listener.enterArgsList) { - listener.enterArgsList(this); - } - } - // @Override - public exitRule(listener: ExpressionParserListener): void { - if (listener.exitArgsList) { - listener.exitArgsList(this); - } - } - // @Override - public accept(visitor: ExpressionParserVisitor): Result { - if (visitor.visitArgsList) { - return visitor.visitArgsList(this); - } else { - return visitor.visitChildren(this); - } - } -} - - +// Generated from ../ExpressionAntlrParser.g4 by ANTLR 4.6-SNAPSHOT + + +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"; +import { TerminalNode } from "antlr4ts/tree/TerminalNode"; +import { Token } from "antlr4ts/Token"; +import { TokenStream } from "antlr4ts/TokenStream"; +import { Vocabulary } from "antlr4ts/Vocabulary"; +import { VocabularyImpl } from "antlr4ts/VocabularyImpl"; + +import * as Utils from "antlr4ts/misc/Utils"; + +import { ExpressionAntlrParserListener } from "./ExpressionAntlrParserListener"; +import { ExpressionAntlrParserVisitor } from "./ExpressionAntlrParserVisitor"; + + +export class ExpressionAntlrParser extends Parser { + public static readonly STRING_INTERPOLATION_START = 1; + public static readonly PLUS = 2; + public static readonly SUBSTRACT = 3; + public static readonly NON = 4; + public static readonly XOR = 5; + public static readonly ASTERISK = 6; + public static readonly SLASH = 7; + public static readonly PERCENT = 8; + public static readonly DOUBLE_EQUAL = 9; + public static readonly NOT_EQUAL = 10; + public static readonly SINGLE_AND = 11; + public static readonly DOUBLE_AND = 12; + public static readonly DOUBLE_VERTICAL_CYLINDER = 13; + public static readonly LESS_THAN = 14; + public static readonly MORE_THAN = 15; + public static readonly LESS_OR_EQUAl = 16; + public static readonly MORE_OR_EQUAL = 17; + public static readonly OPEN_BRACKET = 18; + public static readonly CLOSE_BRACKET = 19; + public static readonly DOT = 20; + public static readonly OPEN_SQUARE_BRACKET = 21; + public static readonly CLOSE_SQUARE_BRACKET = 22; + public static readonly COMMA = 23; + public static readonly NUMBER = 24; + public static readonly WHITESPACE = 25; + public static readonly IDENTIFIER = 26; + public static readonly NEWLINE = 27; + public static readonly STRING = 28; + public static readonly CONSTANT = 29; + public static readonly INVALID_TOKEN_DEFAULT_MODE = 30; + public static readonly TEMPLATE = 31; + public static readonly ESCAPE_CHARACTER = 32; + public static readonly TEXT_CONTENT = 33; + public static readonly RULE_file = 0; + public static readonly RULE_expression = 1; + public static readonly RULE_primaryExpression = 2; + public static readonly RULE_stringInterpolation = 3; + public static readonly RULE_textContent = 4; + public static readonly RULE_argsList = 5; + // tslint:disable:no-trailing-whitespace + public static readonly ruleNames: string[] = [ + "file", "expression", "primaryExpression", "stringInterpolation", "textContent", + "argsList", + ]; + + private static readonly _LITERAL_NAMES: Array = [ + undefined, undefined, "'+'", "'-'", "'!'", "'^'", "'*'", "'/'", "'%'", + "'=='", undefined, "'&'", "'&&'", "'||'", "'<'", "'>'", "'<='", "'>='", + "'('", "')'", "'.'", "'['", "']'", "','", + ]; + private static readonly _SYMBOLIC_NAMES: Array = [ + undefined, "STRING_INTERPOLATION_START", "PLUS", "SUBSTRACT", "NON", "XOR", + "ASTERISK", "SLASH", "PERCENT", "DOUBLE_EQUAL", "NOT_EQUAL", "SINGLE_AND", + "DOUBLE_AND", "DOUBLE_VERTICAL_CYLINDER", "LESS_THAN", "MORE_THAN", "LESS_OR_EQUAl", + "MORE_OR_EQUAL", "OPEN_BRACKET", "CLOSE_BRACKET", "DOT", "OPEN_SQUARE_BRACKET", + "CLOSE_SQUARE_BRACKET", "COMMA", "NUMBER", "WHITESPACE", "IDENTIFIER", + "NEWLINE", "STRING", "CONSTANT", "INVALID_TOKEN_DEFAULT_MODE", "TEMPLATE", + "ESCAPE_CHARACTER", "TEXT_CONTENT", + ]; + public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(ExpressionAntlrParser._LITERAL_NAMES, ExpressionAntlrParser._SYMBOLIC_NAMES, []); + + // @Override + // @NotNull + public get vocabulary(): Vocabulary { + return ExpressionAntlrParser.VOCABULARY; + } + // tslint:enable:no-trailing-whitespace + + // @Override + public get grammarFileName(): string { return "ExpressionAntlrParser.g4"; } + + // @Override + public get ruleNames(): string[] { return ExpressionAntlrParser.ruleNames; } + + // @Override + public get serializedATN(): string { return ExpressionAntlrParser._serializedATN; } + + constructor(input: TokenStream) { + super(input); + this._interp = new ParserATNSimulator(ExpressionAntlrParser._ATN, this); + } + // @RuleVersion(0) + public file(): FileContext { + let _localctx: FileContext = new FileContext(this._ctx, this.state); + this.enterRule(_localctx, 0, ExpressionAntlrParser.RULE_file); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 12; + this.expression(0); + this.state = 13; + this.match(ExpressionAntlrParser.EOF); + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + + public expression(): ExpressionContext; + public expression(_p: number): ExpressionContext; + // @RuleVersion(0) + public expression(_p?: number): ExpressionContext { + if (_p === undefined) { + _p = 0; + } + + let _parentctx: ParserRuleContext = this._ctx; + let _parentState: number = this.state; + let _localctx: ExpressionContext = new ExpressionContext(this._ctx, _parentState); + let _prevctx: ExpressionContext = _localctx; + let _startState: number = 2; + this.enterRecursionRule(_localctx, 2, ExpressionAntlrParser.RULE_expression, _p); + let _la: number; + try { + let _alt: number; + this.enterOuterAlt(_localctx, 1); + { + this.state = 19; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case ExpressionAntlrParser.PLUS: + case ExpressionAntlrParser.SUBSTRACT: + case ExpressionAntlrParser.NON: + { + _localctx = new UnaryOpExpContext(_localctx); + this._ctx = _localctx; + _prevctx = _localctx; + + this.state = 16; + _la = this._input.LA(1); + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << ExpressionAntlrParser.PLUS) | (1 << ExpressionAntlrParser.SUBSTRACT) | (1 << ExpressionAntlrParser.NON))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 17; + this.expression(10); + } + break; + case ExpressionAntlrParser.STRING_INTERPOLATION_START: + case ExpressionAntlrParser.OPEN_BRACKET: + case ExpressionAntlrParser.OPEN_SQUARE_BRACKET: + case ExpressionAntlrParser.NUMBER: + case ExpressionAntlrParser.IDENTIFIER: + case ExpressionAntlrParser.STRING: + case ExpressionAntlrParser.CONSTANT: + { + _localctx = new PrimaryExpContext(_localctx); + this._ctx = _localctx; + _prevctx = _localctx; + this.state = 18; + this.primaryExpression(0); + } + break; + default: + throw new NoViableAltException(this); + } + this._ctx._stop = this._input.tryLT(-1); + this.state = 47; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 2, this._ctx); + while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { + if (_alt === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + _prevctx = _localctx; + { + this.state = 45; + this._errHandler.sync(this); + switch ( this.interpreter.adaptivePredict(this._input, 1, this._ctx) ) { + case 1: + { + _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); + this.pushNewRecursionContext(_localctx, _startState, ExpressionAntlrParser.RULE_expression); + this.state = 21; + if (!(this.precpred(this._ctx, 9))) { + throw new FailedPredicateException(this, "this.precpred(this._ctx, 9)"); + } + this.state = 22; + this.match(ExpressionAntlrParser.XOR); + this.state = 23; + this.expression(9); + } + break; + + case 2: + { + _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); + this.pushNewRecursionContext(_localctx, _startState, ExpressionAntlrParser.RULE_expression); + this.state = 24; + if (!(this.precpred(this._ctx, 8))) { + throw new FailedPredicateException(this, "this.precpred(this._ctx, 8)"); + } + this.state = 25; + _la = this._input.LA(1); + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << ExpressionAntlrParser.ASTERISK) | (1 << ExpressionAntlrParser.SLASH) | (1 << ExpressionAntlrParser.PERCENT))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 26; + this.expression(9); + } + break; + + case 3: + { + _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); + this.pushNewRecursionContext(_localctx, _startState, ExpressionAntlrParser.RULE_expression); + this.state = 27; + if (!(this.precpred(this._ctx, 7))) { + throw new FailedPredicateException(this, "this.precpred(this._ctx, 7)"); + } + this.state = 28; + _la = this._input.LA(1); + if (!(_la === ExpressionAntlrParser.PLUS || _la === ExpressionAntlrParser.SUBSTRACT)) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 29; + this.expression(8); + } + break; + + case 4: + { + _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); + this.pushNewRecursionContext(_localctx, _startState, ExpressionAntlrParser.RULE_expression); + this.state = 30; + if (!(this.precpred(this._ctx, 6))) { + throw new FailedPredicateException(this, "this.precpred(this._ctx, 6)"); + } + this.state = 31; + _la = this._input.LA(1); + if (!(_la === ExpressionAntlrParser.DOUBLE_EQUAL || _la === ExpressionAntlrParser.NOT_EQUAL)) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 32; + this.expression(7); + } + break; + + case 5: + { + _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); + this.pushNewRecursionContext(_localctx, _startState, ExpressionAntlrParser.RULE_expression); + this.state = 33; + if (!(this.precpred(this._ctx, 5))) { + throw new FailedPredicateException(this, "this.precpred(this._ctx, 5)"); + } + { + this.state = 34; + this.match(ExpressionAntlrParser.SINGLE_AND); + } + this.state = 35; + this.expression(6); + } + break; + + case 6: + { + _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); + this.pushNewRecursionContext(_localctx, _startState, ExpressionAntlrParser.RULE_expression); + this.state = 36; + if (!(this.precpred(this._ctx, 4))) { + throw new FailedPredicateException(this, "this.precpred(this._ctx, 4)"); + } + this.state = 37; + _la = this._input.LA(1); + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << ExpressionAntlrParser.LESS_THAN) | (1 << ExpressionAntlrParser.MORE_THAN) | (1 << ExpressionAntlrParser.LESS_OR_EQUAl) | (1 << ExpressionAntlrParser.MORE_OR_EQUAL))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 38; + this.expression(5); + } + break; + + case 7: + { + _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); + this.pushNewRecursionContext(_localctx, _startState, ExpressionAntlrParser.RULE_expression); + this.state = 39; + if (!(this.precpred(this._ctx, 3))) { + throw new FailedPredicateException(this, "this.precpred(this._ctx, 3)"); + } + this.state = 40; + this.match(ExpressionAntlrParser.DOUBLE_AND); + this.state = 41; + this.expression(4); + } + break; + + case 8: + { + _localctx = new BinaryOpExpContext(new ExpressionContext(_parentctx, _parentState)); + this.pushNewRecursionContext(_localctx, _startState, ExpressionAntlrParser.RULE_expression); + this.state = 42; + if (!(this.precpred(this._ctx, 2))) { + throw new FailedPredicateException(this, "this.precpred(this._ctx, 2)"); + } + this.state = 43; + this.match(ExpressionAntlrParser.DOUBLE_VERTICAL_CYLINDER); + this.state = 44; + this.expression(3); + } + break; + } + } + } + this.state = 49; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 2, this._ctx); + } + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + public primaryExpression(): PrimaryExpressionContext; + public primaryExpression(_p: number): PrimaryExpressionContext; + // @RuleVersion(0) + public primaryExpression(_p?: number): PrimaryExpressionContext { + if (_p === undefined) { + _p = 0; + } + + let _parentctx: ParserRuleContext = this._ctx; + let _parentState: number = this.state; + let _localctx: PrimaryExpressionContext = new PrimaryExpressionContext(this._ctx, _parentState); + let _prevctx: PrimaryExpressionContext = _localctx; + let _startState: number = 4; + this.enterRecursionRule(_localctx, 4, ExpressionAntlrParser.RULE_primaryExpression, _p); + let _la: number; + try { + let _alt: number; + this.enterOuterAlt(_localctx, 1); + { + this.state = 65; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case ExpressionAntlrParser.OPEN_BRACKET: + { + _localctx = new ParenthesisExpContext(_localctx); + this._ctx = _localctx; + _prevctx = _localctx; + + this.state = 51; + this.match(ExpressionAntlrParser.OPEN_BRACKET); + this.state = 52; + this.expression(0); + this.state = 53; + this.match(ExpressionAntlrParser.CLOSE_BRACKET); + } + break; + case ExpressionAntlrParser.OPEN_SQUARE_BRACKET: + { + _localctx = new ArrayCreationExpContext(_localctx); + this._ctx = _localctx; + _prevctx = _localctx; + this.state = 55; + this.match(ExpressionAntlrParser.OPEN_SQUARE_BRACKET); + this.state = 57; + this._errHandler.sync(this); + _la = this._input.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << ExpressionAntlrParser.STRING_INTERPOLATION_START) | (1 << ExpressionAntlrParser.PLUS) | (1 << ExpressionAntlrParser.SUBSTRACT) | (1 << ExpressionAntlrParser.NON) | (1 << ExpressionAntlrParser.OPEN_BRACKET) | (1 << ExpressionAntlrParser.OPEN_SQUARE_BRACKET) | (1 << ExpressionAntlrParser.NUMBER) | (1 << ExpressionAntlrParser.IDENTIFIER) | (1 << ExpressionAntlrParser.STRING) | (1 << ExpressionAntlrParser.CONSTANT))) !== 0)) { + { + this.state = 56; + this.argsList(); + } + } + + this.state = 59; + this.match(ExpressionAntlrParser.CLOSE_SQUARE_BRACKET); + } + break; + case ExpressionAntlrParser.CONSTANT: + { + _localctx = new ConstantAtomContext(_localctx); + this._ctx = _localctx; + _prevctx = _localctx; + this.state = 60; + this.match(ExpressionAntlrParser.CONSTANT); + } + break; + case ExpressionAntlrParser.NUMBER: + { + _localctx = new NumericAtomContext(_localctx); + this._ctx = _localctx; + _prevctx = _localctx; + this.state = 61; + this.match(ExpressionAntlrParser.NUMBER); + } + break; + case ExpressionAntlrParser.STRING: + { + _localctx = new StringAtomContext(_localctx); + this._ctx = _localctx; + _prevctx = _localctx; + this.state = 62; + this.match(ExpressionAntlrParser.STRING); + } + break; + case ExpressionAntlrParser.IDENTIFIER: + { + _localctx = new IdAtomContext(_localctx); + this._ctx = _localctx; + _prevctx = _localctx; + this.state = 63; + this.match(ExpressionAntlrParser.IDENTIFIER); + } + break; + case ExpressionAntlrParser.STRING_INTERPOLATION_START: + { + _localctx = new StringInterpolationAtomContext(_localctx); + this._ctx = _localctx; + _prevctx = _localctx; + this.state = 64; + this.stringInterpolation(); + } + break; + default: + throw new NoViableAltException(this); + } + this._ctx._stop = this._input.tryLT(-1); + this.state = 86; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 8, this._ctx); + while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { + if (_alt === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + _prevctx = _localctx; + { + this.state = 84; + this._errHandler.sync(this); + switch ( this.interpreter.adaptivePredict(this._input, 7, this._ctx) ) { + case 1: + { + _localctx = new MemberAccessExpContext(new PrimaryExpressionContext(_parentctx, _parentState)); + this.pushNewRecursionContext(_localctx, _startState, ExpressionAntlrParser.RULE_primaryExpression); + this.state = 67; + if (!(this.precpred(this._ctx, 3))) { + throw new FailedPredicateException(this, "this.precpred(this._ctx, 3)"); + } + this.state = 68; + this.match(ExpressionAntlrParser.DOT); + this.state = 69; + this.match(ExpressionAntlrParser.IDENTIFIER); + } + break; + + case 2: + { + _localctx = new FuncInvokeExpContext(new PrimaryExpressionContext(_parentctx, _parentState)); + this.pushNewRecursionContext(_localctx, _startState, ExpressionAntlrParser.RULE_primaryExpression); + this.state = 70; + if (!(this.precpred(this._ctx, 2))) { + throw new FailedPredicateException(this, "this.precpred(this._ctx, 2)"); + } + this.state = 72; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === ExpressionAntlrParser.NON) { + { + this.state = 71; + this.match(ExpressionAntlrParser.NON); + } + } + + this.state = 74; + this.match(ExpressionAntlrParser.OPEN_BRACKET); + this.state = 76; + this._errHandler.sync(this); + _la = this._input.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << ExpressionAntlrParser.STRING_INTERPOLATION_START) | (1 << ExpressionAntlrParser.PLUS) | (1 << ExpressionAntlrParser.SUBSTRACT) | (1 << ExpressionAntlrParser.NON) | (1 << ExpressionAntlrParser.OPEN_BRACKET) | (1 << ExpressionAntlrParser.OPEN_SQUARE_BRACKET) | (1 << ExpressionAntlrParser.NUMBER) | (1 << ExpressionAntlrParser.IDENTIFIER) | (1 << ExpressionAntlrParser.STRING) | (1 << ExpressionAntlrParser.CONSTANT))) !== 0)) { + { + this.state = 75; + this.argsList(); + } + } + + this.state = 78; + this.match(ExpressionAntlrParser.CLOSE_BRACKET); + } + break; + + case 3: + { + _localctx = new IndexAccessExpContext(new PrimaryExpressionContext(_parentctx, _parentState)); + this.pushNewRecursionContext(_localctx, _startState, ExpressionAntlrParser.RULE_primaryExpression); + this.state = 79; + if (!(this.precpred(this._ctx, 1))) { + throw new FailedPredicateException(this, "this.precpred(this._ctx, 1)"); + } + this.state = 80; + this.match(ExpressionAntlrParser.OPEN_SQUARE_BRACKET); + this.state = 81; + this.expression(0); + this.state = 82; + this.match(ExpressionAntlrParser.CLOSE_SQUARE_BRACKET); + } + break; + } + } + } + this.state = 88; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 8, this._ctx); + } + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.unrollRecursionContexts(_parentctx); + } + return _localctx; + } + // @RuleVersion(0) + public stringInterpolation(): StringInterpolationContext { + let _localctx: StringInterpolationContext = new StringInterpolationContext(this._ctx, this.state); + this.enterRule(_localctx, 6, ExpressionAntlrParser.RULE_stringInterpolation); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 89; + this.match(ExpressionAntlrParser.STRING_INTERPOLATION_START); + this.state = 93; + this._errHandler.sync(this); + _la = this._input.LA(1); + do { + { + this.state = 93; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case ExpressionAntlrParser.ESCAPE_CHARACTER: + { + this.state = 90; + this.match(ExpressionAntlrParser.ESCAPE_CHARACTER); + } + break; + case ExpressionAntlrParser.TEMPLATE: + { + this.state = 91; + this.match(ExpressionAntlrParser.TEMPLATE); + } + break; + case ExpressionAntlrParser.TEXT_CONTENT: + { + this.state = 92; + this.textContent(); + } + break; + default: + throw new NoViableAltException(this); + } + } + this.state = 95; + this._errHandler.sync(this); + _la = this._input.LA(1); + } while (((((_la - 31)) & ~0x1F) === 0 && ((1 << (_la - 31)) & ((1 << (ExpressionAntlrParser.TEMPLATE - 31)) | (1 << (ExpressionAntlrParser.ESCAPE_CHARACTER - 31)) | (1 << (ExpressionAntlrParser.TEXT_CONTENT - 31)))) !== 0)); + this.state = 97; + this.match(ExpressionAntlrParser.STRING_INTERPOLATION_START); + } + } + 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 textContent(): TextContentContext { + let _localctx: TextContentContext = new TextContentContext(this._ctx, this.state); + this.enterRule(_localctx, 8, ExpressionAntlrParser.RULE_textContent); + try { + let _alt: number; + this.enterOuterAlt(_localctx, 1); + { + this.state = 100; + this._errHandler.sync(this); + _alt = 1; + do { + switch (_alt) { + case 1: + { + { + this.state = 99; + this.match(ExpressionAntlrParser.TEXT_CONTENT); + } + } + break; + default: + throw new NoViableAltException(this); + } + this.state = 102; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 11, this._ctx); + } while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER); + } + } + 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 argsList(): ArgsListContext { + let _localctx: ArgsListContext = new ArgsListContext(this._ctx, this.state); + this.enterRule(_localctx, 10, ExpressionAntlrParser.RULE_argsList); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 104; + this.expression(0); + this.state = 109; + this._errHandler.sync(this); + _la = this._input.LA(1); + while (_la === ExpressionAntlrParser.COMMA) { + { + { + this.state = 105; + this.match(ExpressionAntlrParser.COMMA); + this.state = 106; + this.expression(0); + } + } + this.state = 111; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + + public sempred(_localctx: RuleContext, ruleIndex: number, predIndex: number): boolean { + switch (ruleIndex) { + case 1: + return this.expression_sempred(_localctx as ExpressionContext, predIndex); + + case 2: + return this.primaryExpression_sempred(_localctx as PrimaryExpressionContext, predIndex); + } + return true; + } + private expression_sempred(_localctx: ExpressionContext, predIndex: number): boolean { + switch (predIndex) { + case 0: + return this.precpred(this._ctx, 9); + + case 1: + return this.precpred(this._ctx, 8); + + case 2: + return this.precpred(this._ctx, 7); + + case 3: + return this.precpred(this._ctx, 6); + + case 4: + return this.precpred(this._ctx, 5); + + case 5: + return this.precpred(this._ctx, 4); + + case 6: + return this.precpred(this._ctx, 3); + + case 7: + return this.precpred(this._ctx, 2); + } + return true; + } + private primaryExpression_sempred(_localctx: PrimaryExpressionContext, predIndex: number): boolean { + switch (predIndex) { + case 8: + return this.precpred(this._ctx, 3); + + case 9: + return this.precpred(this._ctx, 2); + + case 10: + return this.precpred(this._ctx, 1); + } + return true; + } + + public static readonly _serializedATN: string = + "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x03#s\x04\x02\t\x02" + + "\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06\t\x06\x04\x07\t\x07" + + "\x03\x02\x03\x02\x03\x02\x03\x03\x03\x03\x03\x03\x03\x03\x05\x03\x16\n" + + "\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\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x07\x030\n\x03\f" + + "\x03\x0E\x033\v\x03\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03" + + "\x04\x05\x04<\n\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x05" + + "\x04D\n\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x05\x04K\n\x04\x03" + + "\x04\x03\x04\x05\x04O\n\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03" + + "\x04\x07\x04W\n\x04\f\x04\x0E\x04Z\v\x04\x03\x05\x03\x05\x03\x05\x03\x05" + + "\x06\x05`\n\x05\r\x05\x0E\x05a\x03\x05\x03\x05\x03\x06\x06\x06g\n\x06" + + "\r\x06\x0E\x06h\x03\x07\x03\x07\x03\x07\x07\x07n\n\x07\f\x07\x0E\x07q" + + "\v\x07\x03\x07\x02\x02\x04\x04\x06\b\x02\x02\x04\x02\x06\x02\b\x02\n\x02" + + "\f\x02\x02\x07\x03\x02\x04\x06\x03\x02\b\n\x03\x02\x04\x05\x03\x02\v\f" + + "\x03\x02\x10\x13\x86\x02\x0E\x03\x02\x02\x02\x04\x15\x03\x02\x02\x02\x06" + + "C\x03\x02\x02\x02\b[\x03\x02\x02\x02\nf\x03\x02\x02\x02\fj\x03\x02\x02" + + "\x02\x0E\x0F\x05\x04\x03\x02\x0F\x10\x07\x02\x02\x03\x10\x03\x03\x02\x02" + + "\x02\x11\x12\b\x03\x01\x02\x12\x13\t\x02\x02\x02\x13\x16\x05\x04\x03\f" + + "\x14\x16\x05\x06\x04\x02\x15\x11\x03\x02\x02\x02\x15\x14\x03\x02\x02\x02" + + "\x161\x03\x02\x02\x02\x17\x18\f\v\x02\x02\x18\x19\x07\x07\x02\x02\x19" + + "0\x05\x04\x03\v\x1A\x1B\f\n\x02\x02\x1B\x1C\t\x03\x02\x02\x1C0\x05\x04" + + "\x03\v\x1D\x1E\f\t\x02\x02\x1E\x1F\t\x04\x02\x02\x1F0\x05\x04\x03\n !" + + "\f\b\x02\x02!\"\t\x05\x02\x02\"0\x05\x04\x03\t#$\f\x07\x02\x02$%\x07\r" + + "\x02\x02%0\x05\x04\x03\b&\'\f\x06\x02\x02\'(\t\x06\x02\x02(0\x05\x04\x03" + + "\x07)*\f\x05\x02\x02*+\x07\x0E\x02\x02+0\x05\x04\x03\x06,-\f\x04\x02\x02" + + "-.\x07\x0F\x02\x02.0\x05\x04\x03\x05/\x17\x03\x02\x02\x02/\x1A\x03\x02" + + "\x02\x02/\x1D\x03\x02\x02\x02/ \x03\x02\x02\x02/#\x03\x02\x02\x02/&\x03" + + "\x02\x02\x02/)\x03\x02\x02\x02/,\x03\x02\x02\x0203\x03\x02\x02\x021/\x03" + + "\x02\x02\x0212\x03\x02\x02\x022\x05\x03\x02\x02\x0231\x03\x02\x02\x02" + + "45\b\x04\x01\x0256\x07\x14\x02\x0267\x05\x04\x03\x0278\x07\x15\x02\x02" + + "8D\x03\x02\x02\x029;\x07\x17\x02\x02:<\x05\f\x07\x02;:\x03\x02\x02\x02" + + ";<\x03\x02\x02\x02<=\x03\x02\x02\x02=D\x07\x18\x02\x02>D\x07\x1F\x02\x02" + + "?D\x07\x1A\x02\x02@D\x07\x1E\x02\x02AD\x07\x1C\x02\x02BD\x05\b\x05\x02" + + "C4\x03\x02\x02\x02C9\x03\x02\x02\x02C>\x03\x02\x02\x02C?\x03\x02\x02\x02" + + "C@\x03\x02\x02\x02CA\x03\x02\x02\x02CB\x03\x02\x02\x02DX\x03\x02\x02\x02" + + "EF\f\x05\x02\x02FG\x07\x16\x02\x02GW\x07\x1C\x02\x02HJ\f\x04\x02\x02I" + + "K\x07\x06\x02\x02JI\x03\x02\x02\x02JK\x03\x02\x02\x02KL\x03\x02\x02\x02" + + "LN\x07\x14\x02\x02MO\x05\f\x07\x02NM\x03\x02\x02\x02NO\x03\x02\x02\x02" + + "OP\x03\x02\x02\x02PW\x07\x15\x02\x02QR\f\x03\x02\x02RS\x07\x17\x02\x02" + + "ST\x05\x04\x03\x02TU\x07\x18\x02\x02UW\x03\x02\x02\x02VE\x03\x02\x02\x02" + + "VH\x03\x02\x02\x02VQ\x03\x02\x02\x02WZ\x03\x02\x02\x02XV\x03\x02\x02\x02" + + "XY\x03\x02\x02\x02Y\x07\x03\x02\x02\x02ZX\x03\x02\x02\x02[_\x07\x03\x02" + + "\x02\\`\x07\"\x02\x02]`\x07!\x02\x02^`\x05\n\x06\x02_\\\x03\x02\x02\x02" + + "_]\x03\x02\x02\x02_^\x03\x02\x02\x02`a\x03\x02\x02\x02a_\x03\x02\x02\x02" + + "ab\x03\x02\x02\x02bc\x03\x02\x02\x02cd\x07\x03\x02\x02d\t\x03\x02\x02" + + "\x02eg\x07#\x02\x02fe\x03\x02\x02\x02gh\x03\x02\x02\x02hf\x03\x02\x02" + + "\x02hi\x03\x02\x02\x02i\v\x03\x02\x02\x02jo\x05\x04\x03\x02kl\x07\x19" + + "\x02\x02ln\x05\x04\x03\x02mk\x03\x02\x02\x02nq\x03\x02\x02\x02om\x03\x02" + + "\x02\x02op\x03\x02\x02\x02p\r\x03\x02\x02\x02qo\x03\x02\x02\x02\x0F\x15" + + "/1;CJNVX_aho"; + public static __ATN: ATN; + public static get _ATN(): ATN { + if (!ExpressionAntlrParser.__ATN) { + ExpressionAntlrParser.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(ExpressionAntlrParser._serializedATN)); + } + + return ExpressionAntlrParser.__ATN; + } + +} + +export class FileContext extends ParserRuleContext { + public expression(): ExpressionContext { + return this.getRuleContext(0, ExpressionContext); + } + public EOF(): TerminalNode { return this.getToken(ExpressionAntlrParser.EOF, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return ExpressionAntlrParser.RULE_file; } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterFile) { + listener.enterFile(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitFile) { + listener.exitFile(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitFile) { + return visitor.visitFile(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ExpressionContext extends ParserRuleContext { + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return ExpressionAntlrParser.RULE_expression; } + public copyFrom(ctx: ExpressionContext): void { + super.copyFrom(ctx); + } +} +export class UnaryOpExpContext extends ExpressionContext { + public expression(): ExpressionContext { + return this.getRuleContext(0, ExpressionContext); + } + public NON(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.NON, 0); } + public SUBSTRACT(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.SUBSTRACT, 0); } + public PLUS(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.PLUS, 0); } + constructor(ctx: ExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterUnaryOpExp) { + listener.enterUnaryOpExp(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitUnaryOpExp) { + listener.exitUnaryOpExp(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitUnaryOpExp) { + return visitor.visitUnaryOpExp(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class BinaryOpExpContext extends ExpressionContext { + public expression(): ExpressionContext[]; + public expression(i: number): ExpressionContext; + public expression(i?: number): ExpressionContext | ExpressionContext[] { + if (i === undefined) { + return this.getRuleContexts(ExpressionContext); + } else { + return this.getRuleContext(i, ExpressionContext); + } + } + public XOR(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.XOR, 0); } + public ASTERISK(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.ASTERISK, 0); } + public SLASH(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.SLASH, 0); } + public PERCENT(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.PERCENT, 0); } + public PLUS(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.PLUS, 0); } + public SUBSTRACT(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.SUBSTRACT, 0); } + public DOUBLE_EQUAL(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.DOUBLE_EQUAL, 0); } + public NOT_EQUAL(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.NOT_EQUAL, 0); } + public SINGLE_AND(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.SINGLE_AND, 0); } + public LESS_THAN(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.LESS_THAN, 0); } + public LESS_OR_EQUAl(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.LESS_OR_EQUAl, 0); } + public MORE_THAN(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.MORE_THAN, 0); } + public MORE_OR_EQUAL(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.MORE_OR_EQUAL, 0); } + public DOUBLE_AND(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.DOUBLE_AND, 0); } + public DOUBLE_VERTICAL_CYLINDER(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.DOUBLE_VERTICAL_CYLINDER, 0); } + constructor(ctx: ExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterBinaryOpExp) { + listener.enterBinaryOpExp(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitBinaryOpExp) { + listener.exitBinaryOpExp(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitBinaryOpExp) { + return visitor.visitBinaryOpExp(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class PrimaryExpContext extends ExpressionContext { + public primaryExpression(): PrimaryExpressionContext { + return this.getRuleContext(0, PrimaryExpressionContext); + } + constructor(ctx: ExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterPrimaryExp) { + listener.enterPrimaryExp(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitPrimaryExp) { + listener.exitPrimaryExp(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitPrimaryExp) { + return visitor.visitPrimaryExp(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class PrimaryExpressionContext extends ParserRuleContext { + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return ExpressionAntlrParser.RULE_primaryExpression; } + public copyFrom(ctx: PrimaryExpressionContext): void { + super.copyFrom(ctx); + } +} +export class FuncInvokeExpContext extends PrimaryExpressionContext { + public primaryExpression(): PrimaryExpressionContext { + return this.getRuleContext(0, PrimaryExpressionContext); + } + public OPEN_BRACKET(): TerminalNode { return this.getToken(ExpressionAntlrParser.OPEN_BRACKET, 0); } + public CLOSE_BRACKET(): TerminalNode { return this.getToken(ExpressionAntlrParser.CLOSE_BRACKET, 0); } + public NON(): TerminalNode | undefined { return this.tryGetToken(ExpressionAntlrParser.NON, 0); } + public argsList(): ArgsListContext | undefined { + return this.tryGetRuleContext(0, ArgsListContext); + } + constructor(ctx: PrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterFuncInvokeExp) { + listener.enterFuncInvokeExp(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitFuncInvokeExp) { + listener.exitFuncInvokeExp(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitFuncInvokeExp) { + return visitor.visitFuncInvokeExp(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class ConstantAtomContext extends PrimaryExpressionContext { + public CONSTANT(): TerminalNode { return this.getToken(ExpressionAntlrParser.CONSTANT, 0); } + constructor(ctx: PrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterConstantAtom) { + listener.enterConstantAtom(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitConstantAtom) { + listener.exitConstantAtom(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitConstantAtom) { + return visitor.visitConstantAtom(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class IdAtomContext extends PrimaryExpressionContext { + public IDENTIFIER(): TerminalNode { return this.getToken(ExpressionAntlrParser.IDENTIFIER, 0); } + constructor(ctx: PrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterIdAtom) { + listener.enterIdAtom(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitIdAtom) { + listener.exitIdAtom(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitIdAtom) { + return visitor.visitIdAtom(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class StringAtomContext extends PrimaryExpressionContext { + public STRING(): TerminalNode { return this.getToken(ExpressionAntlrParser.STRING, 0); } + constructor(ctx: PrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterStringAtom) { + listener.enterStringAtom(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitStringAtom) { + listener.exitStringAtom(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitStringAtom) { + return visitor.visitStringAtom(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class IndexAccessExpContext extends PrimaryExpressionContext { + public primaryExpression(): PrimaryExpressionContext { + return this.getRuleContext(0, PrimaryExpressionContext); + } + public OPEN_SQUARE_BRACKET(): TerminalNode { return this.getToken(ExpressionAntlrParser.OPEN_SQUARE_BRACKET, 0); } + public expression(): ExpressionContext { + return this.getRuleContext(0, ExpressionContext); + } + public CLOSE_SQUARE_BRACKET(): TerminalNode { return this.getToken(ExpressionAntlrParser.CLOSE_SQUARE_BRACKET, 0); } + constructor(ctx: PrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterIndexAccessExp) { + listener.enterIndexAccessExp(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitIndexAccessExp) { + listener.exitIndexAccessExp(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitIndexAccessExp) { + return visitor.visitIndexAccessExp(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class StringInterpolationAtomContext extends PrimaryExpressionContext { + public stringInterpolation(): StringInterpolationContext { + return this.getRuleContext(0, StringInterpolationContext); + } + constructor(ctx: PrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterStringInterpolationAtom) { + listener.enterStringInterpolationAtom(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitStringInterpolationAtom) { + listener.exitStringInterpolationAtom(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitStringInterpolationAtom) { + return visitor.visitStringInterpolationAtom(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class MemberAccessExpContext extends PrimaryExpressionContext { + public primaryExpression(): PrimaryExpressionContext { + return this.getRuleContext(0, PrimaryExpressionContext); + } + public DOT(): TerminalNode { return this.getToken(ExpressionAntlrParser.DOT, 0); } + public IDENTIFIER(): TerminalNode { return this.getToken(ExpressionAntlrParser.IDENTIFIER, 0); } + constructor(ctx: PrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterMemberAccessExp) { + listener.enterMemberAccessExp(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitMemberAccessExp) { + listener.exitMemberAccessExp(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitMemberAccessExp) { + return visitor.visitMemberAccessExp(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class ParenthesisExpContext extends PrimaryExpressionContext { + public OPEN_BRACKET(): TerminalNode { return this.getToken(ExpressionAntlrParser.OPEN_BRACKET, 0); } + public expression(): ExpressionContext { + return this.getRuleContext(0, ExpressionContext); + } + public CLOSE_BRACKET(): TerminalNode { return this.getToken(ExpressionAntlrParser.CLOSE_BRACKET, 0); } + constructor(ctx: PrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterParenthesisExp) { + listener.enterParenthesisExp(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitParenthesisExp) { + listener.exitParenthesisExp(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitParenthesisExp) { + return visitor.visitParenthesisExp(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class NumericAtomContext extends PrimaryExpressionContext { + public NUMBER(): TerminalNode { return this.getToken(ExpressionAntlrParser.NUMBER, 0); } + constructor(ctx: PrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterNumericAtom) { + listener.enterNumericAtom(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitNumericAtom) { + listener.exitNumericAtom(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitNumericAtom) { + return visitor.visitNumericAtom(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class ArrayCreationExpContext extends PrimaryExpressionContext { + public OPEN_SQUARE_BRACKET(): TerminalNode { return this.getToken(ExpressionAntlrParser.OPEN_SQUARE_BRACKET, 0); } + public CLOSE_SQUARE_BRACKET(): TerminalNode { return this.getToken(ExpressionAntlrParser.CLOSE_SQUARE_BRACKET, 0); } + public argsList(): ArgsListContext | undefined { + return this.tryGetRuleContext(0, ArgsListContext); + } + constructor(ctx: PrimaryExpressionContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterArrayCreationExp) { + listener.enterArrayCreationExp(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitArrayCreationExp) { + listener.exitArrayCreationExp(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitArrayCreationExp) { + return visitor.visitArrayCreationExp(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class StringInterpolationContext extends ParserRuleContext { + public STRING_INTERPOLATION_START(): TerminalNode[]; + public STRING_INTERPOLATION_START(i: number): TerminalNode; + public STRING_INTERPOLATION_START(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(ExpressionAntlrParser.STRING_INTERPOLATION_START); + } else { + return this.getToken(ExpressionAntlrParser.STRING_INTERPOLATION_START, i); + } + } + public ESCAPE_CHARACTER(): TerminalNode[]; + public ESCAPE_CHARACTER(i: number): TerminalNode; + public ESCAPE_CHARACTER(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(ExpressionAntlrParser.ESCAPE_CHARACTER); + } else { + return this.getToken(ExpressionAntlrParser.ESCAPE_CHARACTER, i); + } + } + public TEMPLATE(): TerminalNode[]; + public TEMPLATE(i: number): TerminalNode; + public TEMPLATE(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(ExpressionAntlrParser.TEMPLATE); + } else { + return this.getToken(ExpressionAntlrParser.TEMPLATE, i); + } + } + public textContent(): TextContentContext[]; + public textContent(i: number): TextContentContext; + public textContent(i?: number): TextContentContext | TextContentContext[] { + if (i === undefined) { + return this.getRuleContexts(TextContentContext); + } else { + return this.getRuleContext(i, TextContentContext); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return ExpressionAntlrParser.RULE_stringInterpolation; } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterStringInterpolation) { + listener.enterStringInterpolation(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitStringInterpolation) { + listener.exitStringInterpolation(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitStringInterpolation) { + return visitor.visitStringInterpolation(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class TextContentContext extends ParserRuleContext { + public TEXT_CONTENT(): TerminalNode[]; + public TEXT_CONTENT(i: number): TerminalNode; + public TEXT_CONTENT(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(ExpressionAntlrParser.TEXT_CONTENT); + } else { + return this.getToken(ExpressionAntlrParser.TEXT_CONTENT, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return ExpressionAntlrParser.RULE_textContent; } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterTextContent) { + listener.enterTextContent(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitTextContent) { + listener.exitTextContent(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitTextContent) { + return visitor.visitTextContent(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ArgsListContext extends ParserRuleContext { + public expression(): ExpressionContext[]; + public expression(i: number): ExpressionContext; + public expression(i?: number): ExpressionContext | ExpressionContext[] { + if (i === undefined) { + return this.getRuleContexts(ExpressionContext); + } else { + return this.getRuleContext(i, ExpressionContext); + } + } + public COMMA(): TerminalNode[]; + public COMMA(i: number): TerminalNode; + public COMMA(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(ExpressionAntlrParser.COMMA); + } else { + return this.getToken(ExpressionAntlrParser.COMMA, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return ExpressionAntlrParser.RULE_argsList; } + // @Override + public enterRule(listener: ExpressionAntlrParserListener): void { + if (listener.enterArgsList) { + listener.enterArgsList(this); + } + } + // @Override + public exitRule(listener: ExpressionAntlrParserListener): void { + if (listener.exitArgsList) { + listener.exitArgsList(this); + } + } + // @Override + public accept(visitor: ExpressionAntlrParserVisitor): Result { + if (visitor.visitArgsList) { + return visitor.visitArgsList(this); + } else { + return visitor.visitChildren(this); + } + } +} + + diff --git a/libraries/adaptive-expressions/src/parser/generated/ExpressionParserListener.ts b/libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrParserListener.ts similarity index 53% rename from libraries/adaptive-expressions/src/parser/generated/ExpressionParserListener.ts rename to libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrParserListener.ts index f975e67640..24465318ae 100644 --- a/libraries/adaptive-expressions/src/parser/generated/ExpressionParserListener.ts +++ b/libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrParserListener.ts @@ -1,253 +1,267 @@ -// Generated from ../ExpressionParser.g4 by ANTLR 4.6-SNAPSHOT - - -import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener"; - -import { FuncInvokeExpContext } from "./ExpressionParser"; -import { ConstantAtomContext } from "./ExpressionParser"; -import { IdAtomContext } from "./ExpressionParser"; -import { StringAtomContext } from "./ExpressionParser"; -import { IndexAccessExpContext } from "./ExpressionParser"; -import { StringInterpolationAtomContext } from "./ExpressionParser"; -import { MemberAccessExpContext } from "./ExpressionParser"; -import { ParenthesisExpContext } from "./ExpressionParser"; -import { NumericAtomContext } from "./ExpressionParser"; -import { UnaryOpExpContext } from "./ExpressionParser"; -import { BinaryOpExpContext } from "./ExpressionParser"; -import { PrimaryExpContext } from "./ExpressionParser"; -import { FileContext } from "./ExpressionParser"; -import { ExpressionContext } from "./ExpressionParser"; -import { PrimaryExpressionContext } from "./ExpressionParser"; -import { StringInterpolationContext } from "./ExpressionParser"; -import { TextContentContext } from "./ExpressionParser"; -import { ArgsListContext } from "./ExpressionParser"; - - -/** - * This interface defines a complete listener for a parse tree produced by - * `ExpressionParser`. - */ -export interface ExpressionParserListener extends ParseTreeListener { - /** - * Enter a parse tree produced by the `funcInvokeExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - enterFuncInvokeExp?: (ctx: FuncInvokeExpContext) => void; - /** - * Exit a parse tree produced by the `funcInvokeExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - exitFuncInvokeExp?: (ctx: FuncInvokeExpContext) => void; - - /** - * Enter a parse tree produced by the `constantAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - enterConstantAtom?: (ctx: ConstantAtomContext) => void; - /** - * Exit a parse tree produced by the `constantAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - exitConstantAtom?: (ctx: ConstantAtomContext) => void; - - /** - * Enter a parse tree produced by the `idAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - enterIdAtom?: (ctx: IdAtomContext) => void; - /** - * Exit a parse tree produced by the `idAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - exitIdAtom?: (ctx: IdAtomContext) => void; - - /** - * Enter a parse tree produced by the `stringAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - enterStringAtom?: (ctx: StringAtomContext) => void; - /** - * Exit a parse tree produced by the `stringAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - exitStringAtom?: (ctx: StringAtomContext) => void; - - /** - * Enter a parse tree produced by the `indexAccessExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - enterIndexAccessExp?: (ctx: IndexAccessExpContext) => void; - /** - * Exit a parse tree produced by the `indexAccessExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - exitIndexAccessExp?: (ctx: IndexAccessExpContext) => void; - - /** - * Enter a parse tree produced by the `stringInterpolationAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - enterStringInterpolationAtom?: (ctx: StringInterpolationAtomContext) => void; - /** - * Exit a parse tree produced by the `stringInterpolationAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - exitStringInterpolationAtom?: (ctx: StringInterpolationAtomContext) => void; - - /** - * Enter a parse tree produced by the `memberAccessExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - enterMemberAccessExp?: (ctx: MemberAccessExpContext) => void; - /** - * Exit a parse tree produced by the `memberAccessExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - exitMemberAccessExp?: (ctx: MemberAccessExpContext) => void; - - /** - * Enter a parse tree produced by the `parenthesisExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - enterParenthesisExp?: (ctx: ParenthesisExpContext) => void; - /** - * Exit a parse tree produced by the `parenthesisExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - exitParenthesisExp?: (ctx: ParenthesisExpContext) => void; - - /** - * Enter a parse tree produced by the `numericAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - enterNumericAtom?: (ctx: NumericAtomContext) => void; - /** - * Exit a parse tree produced by the `numericAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - exitNumericAtom?: (ctx: NumericAtomContext) => void; - - /** - * Enter a parse tree produced by the `unaryOpExp` - * labeled alternative in `ExpressionParser.expression`. - * @param ctx the parse tree - */ - enterUnaryOpExp?: (ctx: UnaryOpExpContext) => void; - /** - * Exit a parse tree produced by the `unaryOpExp` - * labeled alternative in `ExpressionParser.expression`. - * @param ctx the parse tree - */ - exitUnaryOpExp?: (ctx: UnaryOpExpContext) => void; - - /** - * Enter a parse tree produced by the `binaryOpExp` - * labeled alternative in `ExpressionParser.expression`. - * @param ctx the parse tree - */ - enterBinaryOpExp?: (ctx: BinaryOpExpContext) => void; - /** - * Exit a parse tree produced by the `binaryOpExp` - * labeled alternative in `ExpressionParser.expression`. - * @param ctx the parse tree - */ - exitBinaryOpExp?: (ctx: BinaryOpExpContext) => void; - - /** - * Enter a parse tree produced by the `primaryExp` - * labeled alternative in `ExpressionParser.expression`. - * @param ctx the parse tree - */ - enterPrimaryExp?: (ctx: PrimaryExpContext) => void; - /** - * Exit a parse tree produced by the `primaryExp` - * labeled alternative in `ExpressionParser.expression`. - * @param ctx the parse tree - */ - exitPrimaryExp?: (ctx: PrimaryExpContext) => void; - - /** - * Enter a parse tree produced by `ExpressionParser.file`. - * @param ctx the parse tree - */ - enterFile?: (ctx: FileContext) => void; - /** - * Exit a parse tree produced by `ExpressionParser.file`. - * @param ctx the parse tree - */ - exitFile?: (ctx: FileContext) => void; - - /** - * Enter a parse tree produced by `ExpressionParser.expression`. - * @param ctx the parse tree - */ - enterExpression?: (ctx: ExpressionContext) => void; - /** - * Exit a parse tree produced by `ExpressionParser.expression`. - * @param ctx the parse tree - */ - exitExpression?: (ctx: ExpressionContext) => void; - - /** - * Enter a parse tree produced by `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - enterPrimaryExpression?: (ctx: PrimaryExpressionContext) => void; - /** - * Exit a parse tree produced by `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - */ - exitPrimaryExpression?: (ctx: PrimaryExpressionContext) => void; - - /** - * Enter a parse tree produced by `ExpressionParser.stringInterpolation`. - * @param ctx the parse tree - */ - enterStringInterpolation?: (ctx: StringInterpolationContext) => void; - /** - * Exit a parse tree produced by `ExpressionParser.stringInterpolation`. - * @param ctx the parse tree - */ - exitStringInterpolation?: (ctx: StringInterpolationContext) => void; - - /** - * Enter a parse tree produced by `ExpressionParser.textContent`. - * @param ctx the parse tree - */ - enterTextContent?: (ctx: TextContentContext) => void; - /** - * Exit a parse tree produced by `ExpressionParser.textContent`. - * @param ctx the parse tree - */ - exitTextContent?: (ctx: TextContentContext) => void; - - /** - * Enter a parse tree produced by `ExpressionParser.argsList`. - * @param ctx the parse tree - */ - enterArgsList?: (ctx: ArgsListContext) => void; - /** - * Exit a parse tree produced by `ExpressionParser.argsList`. - * @param ctx the parse tree - */ - exitArgsList?: (ctx: ArgsListContext) => void; -} - +// Generated from ../ExpressionAntlrParser.g4 by ANTLR 4.6-SNAPSHOT + + +import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener"; + +import { FuncInvokeExpContext } from "./ExpressionAntlrParser"; +import { ConstantAtomContext } from "./ExpressionAntlrParser"; +import { IdAtomContext } from "./ExpressionAntlrParser"; +import { StringAtomContext } from "./ExpressionAntlrParser"; +import { IndexAccessExpContext } from "./ExpressionAntlrParser"; +import { StringInterpolationAtomContext } from "./ExpressionAntlrParser"; +import { MemberAccessExpContext } from "./ExpressionAntlrParser"; +import { ParenthesisExpContext } from "./ExpressionAntlrParser"; +import { NumericAtomContext } from "./ExpressionAntlrParser"; +import { ArrayCreationExpContext } from "./ExpressionAntlrParser"; +import { UnaryOpExpContext } from "./ExpressionAntlrParser"; +import { BinaryOpExpContext } from "./ExpressionAntlrParser"; +import { PrimaryExpContext } from "./ExpressionAntlrParser"; +import { FileContext } from "./ExpressionAntlrParser"; +import { ExpressionContext } from "./ExpressionAntlrParser"; +import { PrimaryExpressionContext } from "./ExpressionAntlrParser"; +import { StringInterpolationContext } from "./ExpressionAntlrParser"; +import { TextContentContext } from "./ExpressionAntlrParser"; +import { ArgsListContext } from "./ExpressionAntlrParser"; + + +/** + * This interface defines a complete listener for a parse tree produced by + * `ExpressionAntlrParser`. + */ +export interface ExpressionAntlrParserListener extends ParseTreeListener { + /** + * Enter a parse tree produced by the `funcInvokeExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + enterFuncInvokeExp?: (ctx: FuncInvokeExpContext) => void; + /** + * Exit a parse tree produced by the `funcInvokeExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + exitFuncInvokeExp?: (ctx: FuncInvokeExpContext) => void; + + /** + * Enter a parse tree produced by the `constantAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + enterConstantAtom?: (ctx: ConstantAtomContext) => void; + /** + * Exit a parse tree produced by the `constantAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + exitConstantAtom?: (ctx: ConstantAtomContext) => void; + + /** + * Enter a parse tree produced by the `idAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + enterIdAtom?: (ctx: IdAtomContext) => void; + /** + * Exit a parse tree produced by the `idAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + exitIdAtom?: (ctx: IdAtomContext) => void; + + /** + * Enter a parse tree produced by the `stringAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + enterStringAtom?: (ctx: StringAtomContext) => void; + /** + * Exit a parse tree produced by the `stringAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + exitStringAtom?: (ctx: StringAtomContext) => void; + + /** + * Enter a parse tree produced by the `indexAccessExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + enterIndexAccessExp?: (ctx: IndexAccessExpContext) => void; + /** + * Exit a parse tree produced by the `indexAccessExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + exitIndexAccessExp?: (ctx: IndexAccessExpContext) => void; + + /** + * Enter a parse tree produced by the `stringInterpolationAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + enterStringInterpolationAtom?: (ctx: StringInterpolationAtomContext) => void; + /** + * Exit a parse tree produced by the `stringInterpolationAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + exitStringInterpolationAtom?: (ctx: StringInterpolationAtomContext) => void; + + /** + * Enter a parse tree produced by the `memberAccessExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + enterMemberAccessExp?: (ctx: MemberAccessExpContext) => void; + /** + * Exit a parse tree produced by the `memberAccessExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + exitMemberAccessExp?: (ctx: MemberAccessExpContext) => void; + + /** + * Enter a parse tree produced by the `parenthesisExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + enterParenthesisExp?: (ctx: ParenthesisExpContext) => void; + /** + * Exit a parse tree produced by the `parenthesisExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + exitParenthesisExp?: (ctx: ParenthesisExpContext) => void; + + /** + * Enter a parse tree produced by the `numericAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + enterNumericAtom?: (ctx: NumericAtomContext) => void; + /** + * Exit a parse tree produced by the `numericAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + exitNumericAtom?: (ctx: NumericAtomContext) => void; + + /** + * Enter a parse tree produced by the `arrayCreationExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + enterArrayCreationExp?: (ctx: ArrayCreationExpContext) => void; + /** + * Exit a parse tree produced by the `arrayCreationExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + exitArrayCreationExp?: (ctx: ArrayCreationExpContext) => void; + + /** + * Enter a parse tree produced by the `unaryOpExp` + * labeled alternative in `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + */ + enterUnaryOpExp?: (ctx: UnaryOpExpContext) => void; + /** + * Exit a parse tree produced by the `unaryOpExp` + * labeled alternative in `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + */ + exitUnaryOpExp?: (ctx: UnaryOpExpContext) => void; + + /** + * Enter a parse tree produced by the `binaryOpExp` + * labeled alternative in `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + */ + enterBinaryOpExp?: (ctx: BinaryOpExpContext) => void; + /** + * Exit a parse tree produced by the `binaryOpExp` + * labeled alternative in `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + */ + exitBinaryOpExp?: (ctx: BinaryOpExpContext) => void; + + /** + * Enter a parse tree produced by the `primaryExp` + * labeled alternative in `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + */ + enterPrimaryExp?: (ctx: PrimaryExpContext) => void; + /** + * Exit a parse tree produced by the `primaryExp` + * labeled alternative in `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + */ + exitPrimaryExp?: (ctx: PrimaryExpContext) => void; + + /** + * Enter a parse tree produced by `ExpressionAntlrParser.file`. + * @param ctx the parse tree + */ + enterFile?: (ctx: FileContext) => void; + /** + * Exit a parse tree produced by `ExpressionAntlrParser.file`. + * @param ctx the parse tree + */ + exitFile?: (ctx: FileContext) => void; + + /** + * Enter a parse tree produced by `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + */ + enterExpression?: (ctx: ExpressionContext) => void; + /** + * Exit a parse tree produced by `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + */ + exitExpression?: (ctx: ExpressionContext) => void; + + /** + * Enter a parse tree produced by `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + enterPrimaryExpression?: (ctx: PrimaryExpressionContext) => void; + /** + * Exit a parse tree produced by `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + */ + exitPrimaryExpression?: (ctx: PrimaryExpressionContext) => void; + + /** + * Enter a parse tree produced by `ExpressionAntlrParser.stringInterpolation`. + * @param ctx the parse tree + */ + enterStringInterpolation?: (ctx: StringInterpolationContext) => void; + /** + * Exit a parse tree produced by `ExpressionAntlrParser.stringInterpolation`. + * @param ctx the parse tree + */ + exitStringInterpolation?: (ctx: StringInterpolationContext) => void; + + /** + * Enter a parse tree produced by `ExpressionAntlrParser.textContent`. + * @param ctx the parse tree + */ + enterTextContent?: (ctx: TextContentContext) => void; + /** + * Exit a parse tree produced by `ExpressionAntlrParser.textContent`. + * @param ctx the parse tree + */ + exitTextContent?: (ctx: TextContentContext) => void; + + /** + * Enter a parse tree produced by `ExpressionAntlrParser.argsList`. + * @param ctx the parse tree + */ + enterArgsList?: (ctx: ArgsListContext) => void; + /** + * Exit a parse tree produced by `ExpressionAntlrParser.argsList`. + * @param ctx the parse tree + */ + exitArgsList?: (ctx: ArgsListContext) => void; +} + diff --git a/libraries/adaptive-expressions/src/parser/generated/ExpressionParserVisitor.ts b/libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrParserVisitor.ts similarity index 53% rename from libraries/adaptive-expressions/src/parser/generated/ExpressionParserVisitor.ts rename to libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrParserVisitor.ts index c49b1a283c..e88b8a3b4c 100644 --- a/libraries/adaptive-expressions/src/parser/generated/ExpressionParserVisitor.ts +++ b/libraries/adaptive-expressions/src/parser/generated/ExpressionAntlrParserVisitor.ts @@ -1,172 +1,181 @@ -// Generated from ../ExpressionParser.g4 by ANTLR 4.6-SNAPSHOT - - -import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor"; - -import { FuncInvokeExpContext } from "./ExpressionParser"; -import { ConstantAtomContext } from "./ExpressionParser"; -import { IdAtomContext } from "./ExpressionParser"; -import { StringAtomContext } from "./ExpressionParser"; -import { IndexAccessExpContext } from "./ExpressionParser"; -import { StringInterpolationAtomContext } from "./ExpressionParser"; -import { MemberAccessExpContext } from "./ExpressionParser"; -import { ParenthesisExpContext } from "./ExpressionParser"; -import { NumericAtomContext } from "./ExpressionParser"; -import { UnaryOpExpContext } from "./ExpressionParser"; -import { BinaryOpExpContext } from "./ExpressionParser"; -import { PrimaryExpContext } from "./ExpressionParser"; -import { FileContext } from "./ExpressionParser"; -import { ExpressionContext } from "./ExpressionParser"; -import { PrimaryExpressionContext } from "./ExpressionParser"; -import { StringInterpolationContext } from "./ExpressionParser"; -import { TextContentContext } from "./ExpressionParser"; -import { ArgsListContext } from "./ExpressionParser"; - - -/** - * This interface defines a complete generic visitor for a parse tree produced - * by `ExpressionParser`. - * - * @param The return type of the visit operation. Use `void` for - * operations with no return type. - */ -export interface ExpressionParserVisitor extends ParseTreeVisitor { - /** - * Visit a parse tree produced by the `funcInvokeExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitFuncInvokeExp?: (ctx: FuncInvokeExpContext) => Result; - - /** - * Visit a parse tree produced by the `constantAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitConstantAtom?: (ctx: ConstantAtomContext) => Result; - - /** - * Visit a parse tree produced by the `idAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitIdAtom?: (ctx: IdAtomContext) => Result; - - /** - * Visit a parse tree produced by the `stringAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitStringAtom?: (ctx: StringAtomContext) => Result; - - /** - * Visit a parse tree produced by the `indexAccessExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitIndexAccessExp?: (ctx: IndexAccessExpContext) => Result; - - /** - * Visit a parse tree produced by the `stringInterpolationAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitStringInterpolationAtom?: (ctx: StringInterpolationAtomContext) => Result; - - /** - * Visit a parse tree produced by the `memberAccessExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitMemberAccessExp?: (ctx: MemberAccessExpContext) => Result; - - /** - * Visit a parse tree produced by the `parenthesisExp` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitParenthesisExp?: (ctx: ParenthesisExpContext) => Result; - - /** - * Visit a parse tree produced by the `numericAtom` - * labeled alternative in `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitNumericAtom?: (ctx: NumericAtomContext) => Result; - - /** - * Visit a parse tree produced by the `unaryOpExp` - * labeled alternative in `ExpressionParser.expression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitUnaryOpExp?: (ctx: UnaryOpExpContext) => Result; - - /** - * Visit a parse tree produced by the `binaryOpExp` - * labeled alternative in `ExpressionParser.expression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitBinaryOpExp?: (ctx: BinaryOpExpContext) => Result; - - /** - * Visit a parse tree produced by the `primaryExp` - * labeled alternative in `ExpressionParser.expression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitPrimaryExp?: (ctx: PrimaryExpContext) => Result; - - /** - * Visit a parse tree produced by `ExpressionParser.file`. - * @param ctx the parse tree - * @return the visitor result - */ - visitFile?: (ctx: FileContext) => Result; - - /** - * Visit a parse tree produced by `ExpressionParser.expression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitExpression?: (ctx: ExpressionContext) => Result; - - /** - * Visit a parse tree produced by `ExpressionParser.primaryExpression`. - * @param ctx the parse tree - * @return the visitor result - */ - visitPrimaryExpression?: (ctx: PrimaryExpressionContext) => Result; - - /** - * Visit a parse tree produced by `ExpressionParser.stringInterpolation`. - * @param ctx the parse tree - * @return the visitor result - */ - visitStringInterpolation?: (ctx: StringInterpolationContext) => Result; - - /** - * Visit a parse tree produced by `ExpressionParser.textContent`. - * @param ctx the parse tree - * @return the visitor result - */ - visitTextContent?: (ctx: TextContentContext) => Result; - - /** - * Visit a parse tree produced by `ExpressionParser.argsList`. - * @param ctx the parse tree - * @return the visitor result - */ - visitArgsList?: (ctx: ArgsListContext) => Result; -} - +// Generated from ../ExpressionAntlrParser.g4 by ANTLR 4.6-SNAPSHOT + + +import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor"; + +import { FuncInvokeExpContext } from "./ExpressionAntlrParser"; +import { ConstantAtomContext } from "./ExpressionAntlrParser"; +import { IdAtomContext } from "./ExpressionAntlrParser"; +import { StringAtomContext } from "./ExpressionAntlrParser"; +import { IndexAccessExpContext } from "./ExpressionAntlrParser"; +import { StringInterpolationAtomContext } from "./ExpressionAntlrParser"; +import { MemberAccessExpContext } from "./ExpressionAntlrParser"; +import { ParenthesisExpContext } from "./ExpressionAntlrParser"; +import { NumericAtomContext } from "./ExpressionAntlrParser"; +import { ArrayCreationExpContext } from "./ExpressionAntlrParser"; +import { UnaryOpExpContext } from "./ExpressionAntlrParser"; +import { BinaryOpExpContext } from "./ExpressionAntlrParser"; +import { PrimaryExpContext } from "./ExpressionAntlrParser"; +import { FileContext } from "./ExpressionAntlrParser"; +import { ExpressionContext } from "./ExpressionAntlrParser"; +import { PrimaryExpressionContext } from "./ExpressionAntlrParser"; +import { StringInterpolationContext } from "./ExpressionAntlrParser"; +import { TextContentContext } from "./ExpressionAntlrParser"; +import { ArgsListContext } from "./ExpressionAntlrParser"; + + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by `ExpressionAntlrParser`. + * + * @param The return type of the visit operation. Use `void` for + * operations with no return type. + */ +export interface ExpressionAntlrParserVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by the `funcInvokeExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitFuncInvokeExp?: (ctx: FuncInvokeExpContext) => Result; + + /** + * Visit a parse tree produced by the `constantAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitConstantAtom?: (ctx: ConstantAtomContext) => Result; + + /** + * Visit a parse tree produced by the `idAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitIdAtom?: (ctx: IdAtomContext) => Result; + + /** + * Visit a parse tree produced by the `stringAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitStringAtom?: (ctx: StringAtomContext) => Result; + + /** + * Visit a parse tree produced by the `indexAccessExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitIndexAccessExp?: (ctx: IndexAccessExpContext) => Result; + + /** + * Visit a parse tree produced by the `stringInterpolationAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitStringInterpolationAtom?: (ctx: StringInterpolationAtomContext) => Result; + + /** + * Visit a parse tree produced by the `memberAccessExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitMemberAccessExp?: (ctx: MemberAccessExpContext) => Result; + + /** + * Visit a parse tree produced by the `parenthesisExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitParenthesisExp?: (ctx: ParenthesisExpContext) => Result; + + /** + * Visit a parse tree produced by the `numericAtom` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitNumericAtom?: (ctx: NumericAtomContext) => Result; + + /** + * Visit a parse tree produced by the `arrayCreationExp` + * labeled alternative in `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitArrayCreationExp?: (ctx: ArrayCreationExpContext) => Result; + + /** + * Visit a parse tree produced by the `unaryOpExp` + * labeled alternative in `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitUnaryOpExp?: (ctx: UnaryOpExpContext) => Result; + + /** + * Visit a parse tree produced by the `binaryOpExp` + * labeled alternative in `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitBinaryOpExp?: (ctx: BinaryOpExpContext) => Result; + + /** + * Visit a parse tree produced by the `primaryExp` + * labeled alternative in `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitPrimaryExp?: (ctx: PrimaryExpContext) => Result; + + /** + * Visit a parse tree produced by `ExpressionAntlrParser.file`. + * @param ctx the parse tree + * @return the visitor result + */ + visitFile?: (ctx: FileContext) => Result; + + /** + * Visit a parse tree produced by `ExpressionAntlrParser.expression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitExpression?: (ctx: ExpressionContext) => Result; + + /** + * Visit a parse tree produced by `ExpressionAntlrParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitPrimaryExpression?: (ctx: PrimaryExpressionContext) => Result; + + /** + * Visit a parse tree produced by `ExpressionAntlrParser.stringInterpolation`. + * @param ctx the parse tree + * @return the visitor result + */ + visitStringInterpolation?: (ctx: StringInterpolationContext) => Result; + + /** + * Visit a parse tree produced by `ExpressionAntlrParser.textContent`. + * @param ctx the parse tree + * @return the visitor result + */ + visitTextContent?: (ctx: TextContentContext) => Result; + + /** + * Visit a parse tree produced by `ExpressionAntlrParser.argsList`. + * @param ctx the parse tree + * @return the visitor result + */ + visitArgsList?: (ctx: ArgsListContext) => Result; +} + diff --git a/libraries/adaptive-expressions/src/parser/generated/ExpressionLexer.ts b/libraries/adaptive-expressions/src/parser/generated/ExpressionLexer.ts deleted file mode 100644 index c2dbed2ec5..0000000000 --- a/libraries/adaptive-expressions/src/parser/generated/ExpressionLexer.ts +++ /dev/null @@ -1,278 +0,0 @@ -// Generated from ../ExpressionLexer.g4 by ANTLR 4.6-SNAPSHOT - - -import { ATN } from "antlr4ts/atn/ATN"; -import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer"; -import { CharStream } from "antlr4ts/CharStream"; -import { Lexer } from "antlr4ts/Lexer"; -import { LexerATNSimulator } from "antlr4ts/atn/LexerATNSimulator"; -import { NotNull } from "antlr4ts/Decorators"; -import { Override } from "antlr4ts/Decorators"; -import { RuleContext } from "antlr4ts/RuleContext"; -import { Vocabulary } from "antlr4ts/Vocabulary"; -import { VocabularyImpl } from "antlr4ts/VocabularyImpl"; - -import * as Utils from "antlr4ts/misc/Utils"; - - -export class ExpressionLexer extends Lexer { - public static readonly STRING_INTERPOLATION_START = 1; - public static readonly PLUS = 2; - public static readonly SUBSTRACT = 3; - public static readonly NON = 4; - public static readonly XOR = 5; - public static readonly ASTERISK = 6; - public static readonly SLASH = 7; - public static readonly PERCENT = 8; - public static readonly DOUBLE_EQUAL = 9; - public static readonly NOT_EQUAL = 10; - public static readonly SINGLE_AND = 11; - public static readonly DOUBLE_AND = 12; - public static readonly DOUBLE_VERTICAL_CYLINDER = 13; - public static readonly LESS_THAN = 14; - public static readonly MORE_THAN = 15; - public static readonly LESS_OR_EQUAl = 16; - public static readonly MORE_OR_EQUAL = 17; - public static readonly OPEN_BRACKET = 18; - public static readonly CLOSE_BRACKET = 19; - public static readonly DOT = 20; - public static readonly OPEN_SQUARE_BRACKET = 21; - public static readonly CLOSE_SQUARE_BRACKET = 22; - public static readonly COMMA = 23; - public static readonly NUMBER = 24; - public static readonly WHITESPACE = 25; - public static readonly IDENTIFIER = 26; - public static readonly NEWLINE = 27; - public static readonly STRING = 28; - public static readonly CONSTANT = 29; - public static readonly INVALID_TOKEN_DEFAULT_MODE = 30; - public static readonly TEMPLATE = 31; - public static readonly ESCAPE_CHARACTER = 32; - public static readonly TEXT_CONTENT = 33; - public static readonly STRING_INTERPOLATION_MODE = 1; - // tslint:disable:no-trailing-whitespace - public static readonly modeNames: string[] = [ - "DEFAULT_MODE", "STRING_INTERPOLATION_MODE", - ]; - - public static readonly ruleNames: string[] = [ - "LETTER", "DIGIT", "STRING_INTERPOLATION_START", "PLUS", "SUBSTRACT", - "NON", "XOR", "ASTERISK", "SLASH", "PERCENT", "DOUBLE_EQUAL", "NOT_EQUAL", - "SINGLE_AND", "DOUBLE_AND", "DOUBLE_VERTICAL_CYLINDER", "LESS_THAN", "MORE_THAN", - "LESS_OR_EQUAl", "MORE_OR_EQUAL", "OPEN_BRACKET", "CLOSE_BRACKET", "DOT", - "OPEN_SQUARE_BRACKET", "CLOSE_SQUARE_BRACKET", "COMMA", "NUMBER", "WHITESPACE", - "IDENTIFIER", "NEWLINE", "STRING", "CONSTANT", "INVALID_TOKEN_DEFAULT_MODE", - "STRING_INTERPOLATION_END", "TEMPLATE", "ESCAPE_CHARACTER", "TEXT_CONTENT", - ]; - - private static readonly _LITERAL_NAMES: Array = [ - undefined, undefined, "'+'", "'-'", "'!'", "'^'", "'*'", "'/'", "'%'", - "'=='", undefined, "'&'", "'&&'", "'||'", "'<'", "'>'", "'<='", "'>='", - "'('", "')'", "'.'", "'['", "']'", "','", - ]; - private static readonly _SYMBOLIC_NAMES: Array = [ - undefined, "STRING_INTERPOLATION_START", "PLUS", "SUBSTRACT", "NON", "XOR", - "ASTERISK", "SLASH", "PERCENT", "DOUBLE_EQUAL", "NOT_EQUAL", "SINGLE_AND", - "DOUBLE_AND", "DOUBLE_VERTICAL_CYLINDER", "LESS_THAN", "MORE_THAN", "LESS_OR_EQUAl", - "MORE_OR_EQUAL", "OPEN_BRACKET", "CLOSE_BRACKET", "DOT", "OPEN_SQUARE_BRACKET", - "CLOSE_SQUARE_BRACKET", "COMMA", "NUMBER", "WHITESPACE", "IDENTIFIER", - "NEWLINE", "STRING", "CONSTANT", "INVALID_TOKEN_DEFAULT_MODE", "TEMPLATE", - "ESCAPE_CHARACTER", "TEXT_CONTENT", - ]; - public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(ExpressionLexer._LITERAL_NAMES, ExpressionLexer._SYMBOLIC_NAMES, []); - - // @Override - // @NotNull - public get vocabulary(): Vocabulary { - return ExpressionLexer.VOCABULARY; - } - // tslint:enable:no-trailing-whitespace - - - ignoreWS = true; // usually we ignore whitespace, but inside stringInterpolation, whitespace is significant - - - constructor(input: CharStream) { - super(input); - this._interp = new LexerATNSimulator(ExpressionLexer._ATN, this); - } - - // @Override - public get grammarFileName(): string { return "ExpressionLexer.g4"; } - - // @Override - public get ruleNames(): string[] { return ExpressionLexer.ruleNames; } - - // @Override - public get serializedATN(): string { return ExpressionLexer._serializedATN; } - - // @Override - public get modeNames(): string[] { return ExpressionLexer.modeNames; } - - // @Override - public action(_localctx: RuleContext, ruleIndex: number, actionIndex: number): void { - switch (ruleIndex) { - case 2: - this.STRING_INTERPOLATION_START_action(_localctx, actionIndex); - break; - - case 32: - this.STRING_INTERPOLATION_END_action(_localctx, actionIndex); - break; - } - } - private STRING_INTERPOLATION_START_action(_localctx: RuleContext, actionIndex: number): void { - switch (actionIndex) { - case 0: - this.ignoreWS = false; - break; - } - } - private STRING_INTERPOLATION_END_action(_localctx: RuleContext, actionIndex: number): void { - switch (actionIndex) { - case 1: - this.ignoreWS = true; - break; - } - } - // @Override - public sempred(_localctx: RuleContext, ruleIndex: number, predIndex: number): boolean { - switch (ruleIndex) { - case 26: - return this.WHITESPACE_sempred(_localctx, predIndex); - } - return true; - } - private WHITESPACE_sempred(_localctx: RuleContext, predIndex: number): boolean { - switch (predIndex) { - case 0: - return this.ignoreWS; - } - return true; - } - - public static readonly _serializedATN: string = - "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x02#\xF5\b\x01\b" + - "\x01\x04\x02\t\x02\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06\t" + - "\x06\x04\x07\t\x07\x04\b\t\b\x04\t\t\t\x04\n\t\n\x04\v\t\v\x04\f\t\f\x04" + - "\r\t\r\x04\x0E\t\x0E\x04\x0F\t\x0F\x04\x10\t\x10\x04\x11\t\x11\x04\x12" + - "\t\x12\x04\x13\t\x13\x04\x14\t\x14\x04\x15\t\x15\x04\x16\t\x16\x04\x17" + - "\t\x17\x04\x18\t\x18\x04\x19\t\x19\x04\x1A\t\x1A\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%\x03\x02\x03\x02\x03\x03\x03\x03\x03\x04\x03" + - "\x04\x03\x04\x03\x04\x03\x04\x03\x05\x03\x05\x03\x06\x03\x06\x03\x07\x03" + - "\x07\x03\b\x03\b\x03\t\x03\t\x03\n\x03\n\x03\v\x03\v\x03\f\x03\f\x03\f" + - "\x03\r\x03\r\x03\r\x03\r\x05\rk\n\r\x03\x0E\x03\x0E\x03\x0F\x03\x0F\x03" + - "\x0F\x03\x10\x03\x10\x03\x10\x03\x11\x03\x11\x03\x12\x03\x12\x03\x13\x03" + - "\x13\x03\x13\x03\x14\x03\x14\x03\x14\x03\x15\x03\x15\x03\x16\x03\x16\x03" + - "\x17\x03\x17\x03\x18\x03\x18\x03\x19\x03\x19\x03\x1A\x03\x1A\x03\x1B\x06" + - "\x1B\x8C\n\x1B\r\x1B\x0E\x1B\x8D\x03\x1B\x03\x1B\x06\x1B\x92\n\x1B\r\x1B" + - "\x0E\x1B\x93\x05\x1B\x96\n\x1B\x03\x1C\x03\x1C\x03\x1C\x03\x1C\x03\x1C" + - "\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x05\x1D\xA2\n\x1D\x03\x1D\x03" + - "\x1D\x03\x1D\x07\x1D\xA7\n\x1D\f\x1D\x0E\x1D\xAA\v\x1D\x03\x1D\x05\x1D" + - "\xAD\n\x1D\x03\x1E\x05\x1E\xB0\n\x1E\x03\x1E\x03\x1E\x03\x1E\x03\x1E\x03" + - "\x1F\x03\x1F\x07\x1F\xB8\n\x1F\f\x1F\x0E\x1F\xBB\v\x1F\x03\x1F\x03\x1F" + - "\x03\x1F\x07\x1F\xC0\n\x1F\f\x1F\x0E\x1F\xC3\v\x1F\x03\x1F\x05\x1F\xC6" + - "\n\x1F\x03 \x03 \x07 \xCA\n \f \x0E \xCD\v \x03 \x03 \x03 \x07 \xD2\n" + - " \f \x0E \xD5\v \x03 \x05 \xD8\n \x03!\x03!\x03\"\x03\"\x03\"\x03\"\x03" + - "\"\x03\"\x03#\x03#\x03#\x03#\x07#\xE6\n#\f#\x0E#\xE9\v#\x03#\x03#\x03" + - "$\x03$\x05$\xEF\n$\x03%\x03%\x03%\x05%\xF4\n%\x03\xE7\x02\x02&\x04\x02" + - "\x02\x06\x02\x02\b\x02\x03\n\x02\x04\f\x02\x05\x0E\x02\x06\x10\x02\x07" + - "\x12\x02\b\x14\x02\t\x16\x02\n\x18\x02\v\x1A\x02\f\x1C\x02\r\x1E\x02\x0E" + - " \x02\x0F\"\x02\x10$\x02\x11&\x02\x12(\x02\x13*\x02\x14,\x02\x15.\x02" + - "\x160\x02\x172\x02\x184\x02\x196\x02\x1A8\x02\x1B:\x02\x1C<\x02\x1D>\x02" + - "\x1E@\x02\x1FB\x02 D\x02\x02F\x02!H\x02\"J\x02#\x04\x02\x03\v\x04\x02" + - "C\\c|\x03\x022;\x06\x02\v\v\"\"\xA2\xA2\uFF01\uFF01\x05\x02%%BBaa\x04" + - "\x02//aa\x03\x02))\x03\x02$$\b\x02\f\f\x0F\x0F$$))}}\x7F\x7F\x04\x02\f" + - "\f\x0F\x0F\u0107\x02\b\x03\x02\x02\x02\x02\n\x03\x02\x02\x02\x02\f\x03" + - "\x02\x02\x02\x02\x0E\x03\x02\x02\x02\x02\x10\x03\x02\x02\x02\x02\x12\x03" + - "\x02\x02\x02\x02\x14\x03\x02\x02\x02\x02\x16\x03\x02\x02\x02\x02\x18\x03" + - "\x02\x02\x02\x02\x1A\x03\x02\x02\x02\x02\x1C\x03\x02\x02\x02\x02\x1E\x03" + - "\x02\x02\x02\x02 \x03\x02\x02\x02\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\x020\x03\x02\x02\x02\x022\x03\x02" + - "\x02\x02\x024\x03\x02\x02\x02\x026\x03\x02\x02\x02\x028\x03\x02\x02\x02" + - "\x02:\x03\x02\x02\x02\x02<\x03\x02\x02\x02\x02>\x03\x02\x02\x02\x02@\x03" + - "\x02\x02\x02\x02B\x03\x02\x02\x02\x03D\x03\x02\x02\x02\x03F\x03\x02\x02" + - "\x02\x03H\x03\x02\x02\x02\x03J\x03\x02\x02\x02\x04L\x03\x02\x02\x02\x06" + - "N\x03\x02\x02\x02\bP\x03\x02\x02\x02\nU\x03\x02\x02\x02\fW\x03\x02\x02" + - "\x02\x0EY\x03\x02\x02\x02\x10[\x03\x02\x02\x02\x12]\x03\x02\x02\x02\x14" + - "_\x03\x02\x02\x02\x16a\x03\x02\x02\x02\x18c\x03\x02\x02\x02\x1Aj\x03\x02" + - "\x02\x02\x1Cl\x03\x02\x02\x02\x1En\x03\x02\x02\x02 q\x03\x02\x02\x02\"" + - "t\x03\x02\x02\x02$v\x03\x02\x02\x02&x\x03\x02\x02\x02({\x03\x02\x02\x02" + - "*~\x03\x02\x02\x02,\x80\x03\x02\x02\x02.\x82\x03\x02\x02\x020\x84\x03" + - "\x02\x02\x022\x86\x03\x02\x02\x024\x88\x03\x02\x02\x026\x8B\x03\x02\x02" + - "\x028\x97\x03\x02\x02\x02:\xA1\x03\x02\x02\x02<\xAF\x03\x02\x02\x02>\xC5" + - "\x03\x02\x02\x02@\xD7\x03\x02\x02\x02B\xD9\x03\x02\x02\x02D\xDB\x03\x02" + - "\x02\x02F\xE1\x03\x02\x02\x02H\xEC\x03\x02\x02\x02J\xF3\x03\x02\x02\x02" + - "LM\t\x02\x02\x02M\x05\x03\x02\x02\x02NO\t\x03\x02\x02O\x07\x03\x02\x02" + - "\x02PQ\x07b\x02\x02QR\b\x04\x02\x02RS\x03\x02\x02\x02ST\b\x04\x03\x02" + - "T\t\x03\x02\x02\x02UV\x07-\x02\x02V\v\x03\x02\x02\x02WX\x07/\x02\x02X" + - "\r\x03\x02\x02\x02YZ\x07#\x02\x02Z\x0F\x03\x02\x02\x02[\\\x07`\x02\x02" + - "\\\x11\x03\x02\x02\x02]^\x07,\x02\x02^\x13\x03\x02\x02\x02_`\x071\x02" + - "\x02`\x15\x03\x02\x02\x02ab\x07\'\x02\x02b\x17\x03\x02\x02\x02cd\x07?" + - "\x02\x02de\x07?\x02\x02e\x19\x03\x02\x02\x02fg\x07#\x02\x02gk\x07?\x02" + - "\x02hi\x07>\x02\x02ik\x07@\x02\x02jf\x03\x02\x02\x02jh\x03\x02\x02\x02" + - "k\x1B\x03\x02\x02\x02lm\x07(\x02\x02m\x1D\x03\x02\x02\x02no\x07(\x02\x02" + - "op\x07(\x02\x02p\x1F\x03\x02\x02\x02qr\x07~\x02\x02rs\x07~\x02\x02s!\x03" + - "\x02\x02\x02tu\x07>\x02\x02u#\x03\x02\x02\x02vw\x07@\x02\x02w%\x03\x02" + - "\x02\x02xy\x07>\x02\x02yz\x07?\x02\x02z\'\x03\x02\x02\x02{|\x07@\x02\x02" + - "|}\x07?\x02\x02})\x03\x02\x02\x02~\x7F\x07*\x02\x02\x7F+\x03\x02\x02\x02" + - "\x80\x81\x07+\x02\x02\x81-\x03\x02\x02\x02\x82\x83\x070\x02\x02\x83/\x03" + - "\x02\x02\x02\x84\x85\x07]\x02\x02\x851\x03\x02\x02\x02\x86\x87\x07_\x02" + - "\x02\x873\x03\x02\x02\x02\x88\x89\x07.\x02\x02\x895\x03\x02\x02\x02\x8A" + - "\x8C\x05\x06\x03\x02\x8B\x8A\x03\x02\x02\x02\x8C\x8D\x03\x02\x02\x02\x8D" + - "\x8B\x03\x02\x02\x02\x8D\x8E\x03\x02\x02\x02\x8E\x95\x03\x02\x02\x02\x8F" + - "\x91\x070\x02\x02\x90\x92\x05\x06\x03\x02\x91\x90\x03\x02\x02\x02\x92" + - "\x93\x03\x02\x02\x02\x93\x91\x03\x02\x02\x02\x93\x94\x03\x02\x02\x02\x94" + - "\x96\x03\x02\x02\x02\x95\x8F\x03\x02\x02\x02\x95\x96\x03\x02\x02\x02\x96" + - "7\x03\x02\x02\x02\x97\x98\t\x04\x02\x02\x98\x99\x06\x1C\x02\x02\x99\x9A" + - "\x03\x02\x02\x02\x9A\x9B\b\x1C\x04\x02\x9B9\x03\x02\x02\x02\x9C\xA2\x05" + - "\x04\x02\x02\x9D\xA2\t\x05\x02\x02\x9E\x9F\x07B\x02\x02\x9F\xA2\x07B\x02" + - "\x02\xA0\xA2\x04&\'\x02\xA1\x9C\x03\x02\x02\x02\xA1\x9D\x03\x02\x02\x02" + - "\xA1\x9E\x03\x02\x02\x02\xA1\xA0\x03\x02\x02\x02\xA2\xA8\x03\x02\x02\x02" + - "\xA3\xA7\x05\x04\x02\x02\xA4\xA7\x05\x06\x03\x02\xA5\xA7\t\x06\x02\x02" + - "\xA6\xA3\x03\x02\x02\x02\xA6\xA4\x03\x02\x02\x02\xA6\xA5\x03\x02\x02\x02" + - "\xA7\xAA\x03\x02\x02\x02\xA8\xA6\x03\x02\x02\x02\xA8\xA9\x03\x02\x02\x02" + - "\xA9\xAC\x03\x02\x02\x02\xAA\xA8\x03\x02\x02\x02\xAB\xAD\x07#\x02\x02" + - "\xAC\xAB\x03\x02\x02\x02\xAC\xAD\x03\x02\x02\x02\xAD;\x03\x02\x02\x02" + - "\xAE\xB0\x07\x0F\x02\x02\xAF\xAE\x03\x02\x02\x02\xAF\xB0\x03\x02\x02\x02" + - "\xB0\xB1\x03\x02\x02\x02\xB1\xB2\x07\f\x02\x02\xB2\xB3\x03\x02\x02\x02" + - "\xB3\xB4\b\x1E\x04\x02\xB4=\x03\x02\x02\x02\xB5\xB9\x07)\x02\x02\xB6\xB8" + - "\n\x07\x02\x02\xB7\xB6\x03\x02\x02\x02\xB8\xBB\x03\x02\x02\x02\xB9\xB7" + - "\x03\x02\x02\x02\xB9\xBA\x03\x02\x02\x02\xBA\xBC\x03\x02\x02\x02\xBB\xB9" + - "\x03\x02\x02\x02\xBC\xC6\x07)\x02\x02\xBD\xC1\x07$\x02\x02\xBE\xC0\n\b" + - "\x02\x02\xBF\xBE\x03\x02\x02\x02\xC0\xC3\x03\x02\x02\x02\xC1\xBF\x03\x02" + - "\x02\x02\xC1\xC2\x03\x02\x02\x02\xC2\xC4\x03\x02\x02\x02\xC3\xC1\x03\x02" + - "\x02\x02\xC4\xC6\x07$\x02\x02\xC5\xB5\x03\x02\x02\x02\xC5\xBD\x03\x02" + - "\x02\x02\xC6?\x03\x02\x02\x02\xC7\xCB\x07]\x02\x02\xC8\xCA\x058\x1C\x02" + - "\xC9\xC8\x03\x02\x02\x02\xCA\xCD\x03\x02\x02\x02\xCB\xC9\x03\x02\x02\x02" + - "\xCB\xCC\x03\x02\x02\x02\xCC\xCE\x03\x02\x02\x02\xCD\xCB\x03\x02\x02\x02" + - "\xCE\xD8\x07_\x02\x02\xCF\xD3\x07}\x02\x02\xD0\xD2\x058\x1C\x02\xD1\xD0" + - "\x03\x02\x02\x02\xD2\xD5\x03\x02\x02\x02\xD3\xD1\x03\x02\x02\x02\xD3\xD4" + - "\x03\x02\x02\x02\xD4\xD6\x03\x02\x02\x02\xD5\xD3\x03\x02\x02\x02\xD6\xD8" + - "\x07\x7F\x02\x02\xD7\xC7\x03\x02\x02\x02\xD7\xCF\x03\x02\x02\x02\xD8A" + - "\x03\x02\x02\x02\xD9\xDA\v\x02\x02\x02\xDAC\x03\x02\x02\x02\xDB\xDC\x07" + - "b\x02\x02\xDC\xDD\b\"\x05\x02\xDD\xDE\x03\x02\x02\x02\xDE\xDF\b\"\x06" + - "\x02\xDF\xE0\b\"\x07\x02\xE0E\x03\x02\x02\x02\xE1\xE2\x07&\x02\x02\xE2" + - "\xE7\x07}\x02\x02\xE3\xE6\x05>\x1F\x02\xE4\xE6\n\t\x02\x02\xE5\xE3\x03" + - "\x02\x02\x02\xE5\xE4\x03\x02\x02\x02\xE6\xE9\x03\x02\x02\x02\xE7\xE8\x03" + - "\x02\x02\x02\xE7\xE5\x03\x02\x02\x02\xE8\xEA\x03\x02\x02\x02\xE9\xE7\x03" + - "\x02\x02\x02\xEA\xEB\x07\x7F\x02\x02\xEBG\x03\x02\x02\x02\xEC\xEE\x07" + - "^\x02\x02\xED\xEF\n\n\x02\x02\xEE\xED\x03\x02\x02\x02\xEE\xEF\x03\x02" + - "\x02\x02\xEFI\x03\x02\x02\x02\xF0\xF1\x07^\x02\x02\xF1\xF4\x07b\x02\x02" + - "\xF2\xF4\n\n\x02\x02\xF3\xF0\x03\x02\x02\x02\xF3\xF2\x03\x02\x02\x02\xF4" + - "K\x03\x02\x02\x02\x17\x02\x03j\x8D\x93\x95\xA1\xA6\xA8\xAC\xAF\xB9\xC1" + - "\xC5\xCB\xD3\xD7\xE5\xE7\xEE\xF3\b\x03\x04\x02\x07\x03\x02\b\x02\x02\x03" + - "\"\x03\t\x03\x02\x06\x02\x02"; - public static __ATN: ATN; - public static get _ATN(): ATN { - if (!ExpressionLexer.__ATN) { - ExpressionLexer.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(ExpressionLexer._serializedATN)); - } - - return ExpressionLexer.__ATN; - } - -} - diff --git a/libraries/adaptive-expressions/src/parser/generated/index.ts b/libraries/adaptive-expressions/src/parser/generated/index.ts index cf90ec968f..b37bc6d9a1 100644 --- a/libraries/adaptive-expressions/src/parser/generated/index.ts +++ b/libraries/adaptive-expressions/src/parser/generated/index.ts @@ -6,7 +6,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -export * from './ExpressionLexer'; -export * from './ExpressionParserListener'; -export * from './ExpressionParser'; -export * from './ExpressionParserVisitor'; +export * from './ExpressionAntlrLexer'; +export * from './ExpressionAntlrParserListener'; +export * from './ExpressionAntlrParser'; +export * from './ExpressionAntlrParserVisitor'; diff --git a/libraries/adaptive-expressions/src/parser/index.ts b/libraries/adaptive-expressions/src/parser/index.ts index 0768cd05a5..0ddcdc8d72 100644 --- a/libraries/adaptive-expressions/src/parser/index.ts +++ b/libraries/adaptive-expressions/src/parser/index.ts @@ -7,6 +7,6 @@ * Licensed under the MIT License. */ export * from './parseErrorListener'; -export * from './expressionEngine'; +export * from './expressionParser'; export * from './util'; export * from './generated'; diff --git a/libraries/adaptive-expressions/src/parser/util.ts b/libraries/adaptive-expressions/src/parser/util.ts index 7383c51795..2b0595bf8e 100644 --- a/libraries/adaptive-expressions/src/parser/util.ts +++ b/libraries/adaptive-expressions/src/parser/util.ts @@ -10,6 +10,11 @@ * util class */ export class Util { + /** + * trim char + * @param str input string + * @param char trim character + */ public static trim(str: string, char: string): string { if (char !== undefined) { return str.replace(new RegExp(''.concat('^\\', char, '+|\\', char, '+$'), 'g'), ''); @@ -17,20 +22,4 @@ export class Util { return str.trim(); } - - public static unescape(exp: string): string { - const validCharactersDict: any = { - '\\r': '\r', - '\\n': '\n', - '\\t': '\t' - }; - - return exp.replace(/\\[^\r\n]?/g, (sub: string): string => { - if (sub in validCharactersDict) { - return validCharactersDict[sub]; - } else { - return sub.substr(1); - } - }); - } } diff --git a/libraries/adaptive-expressions/tests/badExpression.test.js b/libraries/adaptive-expressions/tests/badExpression.test.js index d92b5ef02e..590ecd1450 100644 --- a/libraries/adaptive-expressions/tests/badExpression.test.js +++ b/libraries/adaptive-expressions/tests/badExpression.test.js @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -const { ExpressionEngine } = require('../'); +const { ExpressionParser } = require('../'); const assert = require('assert'); const invalidExpressions = [ @@ -343,7 +343,16 @@ const badExpressions = // SetPathToValue tests 'setPathToValue(2+3, 4)', // Not a real path - 'setPathToValue(a)' // Missing value + 'setPathToValue(a)', // Missing value + + //Type Checking + 'isString(hello, hello)', // should have one parameter + 'isInteger(one, hello)', // should have one parameter + 'isFloat(1.324, hello)', // should have one parameter + 'isArray(createArray(1,2,3), hello)', // should have one parameter + 'isBoolean(true, false)', // should have one parameter + 'isDateTime("2018-03-15T13:00:00.111Z", hello)', // should have one parameter + 'isObject({}, false)', // should have one parameter ]; const scope = { @@ -407,7 +416,7 @@ describe('expression functional test', () => { const input = expression; try { // eslint-disable-next-line @typescript-eslint/no-unused-vars - var { value: actual, error } = new ExpressionEngine().parse(input).tryEvaluate(scope); + var { value: actual, error } = new ExpressionParser().parse(input).tryEvaluate(scope); if (error === undefined) { isFail = true; } else { @@ -427,7 +436,7 @@ describe('expression functional test', () => { for (const expression of invalidExpressions) { const input = expression; try { - new ExpressionEngine().parse(input); + new ExpressionParser().parse(input); assert.fail(`Test expression ${ input } did not throw expected exception`); } catch (e) { console.log(e.message); diff --git a/libraries/adaptive-expressions/tests/expression.test.js b/libraries/adaptive-expressions/tests/expressionParser.test.js similarity index 86% rename from libraries/adaptive-expressions/tests/expression.test.js rename to libraries/adaptive-expressions/tests/expressionParser.test.js index f48012cb88..a731d0ecd5 100644 --- a/libraries/adaptive-expressions/tests/expression.test.js +++ b/libraries/adaptive-expressions/tests/expressionParser.test.js @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-use-before-define */ /* eslint-disable @typescript-eslint/no-var-requires */ -const { Expression, Extensions, SimpleObjectMemory, ExpressionFunctions } = require('../'); +const { Expression, SimpleObjectMemory, ExpressionFunctions } = require('../lib'); const assert = require('assert'); const moment = require('moment'); @@ -8,11 +8,23 @@ const one = ['one']; const oneTwo = ['one', 'two']; const dataSource = [ + // accessProperty and accessIndex + ['$index', 'index'], + ['`hi\\``', 'hi`'], // `hi\`` -> hi` + ['`hi\\y`', 'hi\\y'], // `hi\y` -> hi\y + ['`\\${a}`', '${a}'], // `\${a}` -> ${a} + ['"ab\\"cd"', 'ab"cd'], // "ab\"cd" -> ab"cd + ['"ab`cd"', 'ab`cd'], // "ab`cd" -> ab`cd + ['"ab\\ncd"', 'ab\ncd'], // "ab\ncd" -> ab [newline] cd + ['"ab\\ycd"', 'ab\\ycd'], //"ab\ycd" -> ab\ycd + ['\'ab\\\'cd\'', 'ab\'cd'], // 'ab\'cd' -> ab'cd + ['alist[0].Name', 'item1'], + // string interpolation test ['`hi`', 'hi'], ['`hi\\``', 'hi`'], ['`${world}`', 'world'], - ['`hi ${string(\'jack\\`\')}`', 'hi jack`'], + ['`hi ${string(\'jack`\')}`', 'hi jack`'], ['`\\${world}`', '${world}'], ['length(`hello ${world}`)', 'hello world'.length], ['json(`{"foo": "${hello}","item": "${world}"}`).foo', 'hello'], @@ -20,20 +32,36 @@ const dataSource = [ ['`hello ${world}` != \'hello hello\'', true], ['`hello ${user.nickname}` == \'hello John\'', true], ['`hello ${user.nickname}` != \'hello Dong\'', true], + ['`hi\\`[1,2,3]`', 'hi`[1,2,3]'], + ['`hi ${[\'jack`\', \'queen\', \'king\']}`', 'hi jack`,queen,king'], + ['`abc ${concat("[", "]")}`', 'abc []'], + ['`[] ${concat("[]")}`', '[] []'], + ['`hi ${count(["a", "b", "c"])}`', `hi 3`], // Operators tests + ['1 + 2', 3], + ['1 +\n 2', 3], + ['1 \n+ 2', 3], + ['1 +\r\n 2', 3], ['- 1 + 2', 1], + ['-\r\n 1 + 2', 1], ['+ 1 + 2', 3], + ['+\r\n 1 + 2', 3], ['1 - 2', -1], + ['1 -\r\n 2', -1], ['1 - (-2)', 3], + ['1 - (\r\n-2)', 3], ['1.0 + 2.0', 3.0], ['1 * 2 + 3', 5], + ['1 *\r\n 2 + 3', 5], ['1 + 2 * 3', 7], ['4 / 2', 2], + ['4 /\r\n 2', 2], ['1 + 3 / 2', 2], ['(1 + 3) / 2', 2], + ['(1 +\r\n 3) / 2', 2], ['1 * (2 + 3)', 5], ['(1 + 2) * 3', 9], ['(one + two) * bag.three', 9.0, ['one', 'two', 'bag.three']], @@ -43,14 +71,20 @@ const dataSource = [ ['one + two + hello + one + two', '3hello12'], ['2^2', 4.0], + ['2^\r\n2', 4.0], + ['3^2^2', 81.0], + ['one >\r\n 0.5', true], ['one > 0.5 && two < 2.5', true], ['one > 0.5 || two < 1.5', true], ['5 % 2', 1], + ['5 %\r\n 2', 1], ['!(one == 1.0)', false], + ['!\r\n(one == 1.0)', false], ['!!(one == 1.0)', true], ['!exists(xione) || !!exists(two)', true], ['(1 + 2) == (4 - 1)', true], + ['(1 + 2) ==\r\n (4 - 1)', true], ['!!exists(one) == !!exists(one)', true], ['!(one == 1.0)', false, ['one']], ['!!(one == 1.0)', true, ['one']], @@ -61,25 +95,35 @@ const dataSource = [ ['hello == \'hello\'', true], ['hello == \'world\'', false], ['(1 + 2) != (4 - 1)', false], + ['(1 + 2) !=\r\n (4 - 1)', false], ['!!exists(one) != !!exists(one)', false], ['hello != \'hello\'', false], ['hello != \'world\'', true], - ['hello != "hello"', false], - ['hello != "world"', true], + ['hello!= "hello"', false], + ['hello!= "world"', true], ['(1 + 2) >= (4 - 1)', true], ['(2 + 2) >= (4 - 1)', true], + ['(2 + 2) >=\r\n (4 - 1)', true], ['float(5.5) >= float(4 - 1)', true], ['(1 + 2) <= (4 - 1)', true], ['(2 + 2) <= (4 - 1)', false], + ['(2 + 2) <=\r\n (4 - 1)', false], ['float(5.5) <= float(4 - 1)', false], ['\'string\'&\'builder\'', 'stringbuilder'], ['"string"&"builder"', 'stringbuilder'], + ['"string"&\n"builder"', 'stringbuilder'], + ['"string"&\r\n"builder"', 'stringbuilder'], ['one > 0.5 && two < 2.5', true, oneTwo], ['notThere > 4', false], ['float(5.5) && float(0.0)', true], ['hello && "hello"', true], + ['hello &&\n "hello"', true], + ['hello &&\r\n "hello"', true], ['items || ((2 + 2) <= (4 - 1))', true], // true || false ['0 || false', true], // true || false + ['0 ||\n false', true], // true || false + ['0 ||\r\n false', true], // true || false + ['false ||\r\n false || \r\n true', true], // true || false ['!(hello)', false], // false ['!(10)', false], ['!(0)', false], @@ -91,9 +135,11 @@ const dataSource = [ ['concat(hello,world)', 'helloworld'], ['concat(hello,nullObj)', 'hello'], ['concat(\'hello\',\'world\')', 'helloworld'], + ['concat(\'hello\'\r\n,\'world\')', 'helloworld'], ['concat("hello","world")', 'helloworld'], ['add(hello,world)', 'helloworld'], ['add(\'hello\',\'world\')', 'helloworld'], + ['add(\'hello\',\r\n\'world\')', 'helloworld'], ['add(nullObj,\'world\')', 'world'], ['add(\'hello\',nullObj)', 'hello'], ['add("hello","world")', 'helloworld'], @@ -101,10 +147,11 @@ const dataSource = [ ['length(nullObj)', 0], ['length("hello")', 5], ['length(concat(hello,world))', 10], + ['length(concat("[]", "abc"))', 5], ['length(hello + world)', 10], ['count(\'hello\')', 5], ['count("hello")', 5], - ['count(concat(hello,world))', 10], + ['count(concat(hello,\r\nworld))', 10], ['replace(\'hello\', \'l\', \'k\')', 'hekko'], ['replace(\'hello\', \'L\', \'k\')', 'hello'], ['replace(nullObj, \'L\', \'k\')', ''], @@ -168,6 +215,7 @@ const dataSource = [ ['indexOf(json(\'["a", "b"]\'), "a")', 0], ['indexOf(json(\'["a", "b"]\'), \'c\')', -1], ['indexOf(createArray(\'abc\', \'def\', \'ghi\'), \'def\')', 1], + ['indexOf([\'abc\', \'def\', \'ghi\'], \'def\')', 1], ['indexOf(createArray(\'abc\', \'def\', \'ghi\'), \'klm\')', -1], ['lastIndexOf(nullObj, \'-\')', -1], ['lastIndexOf(hello, nullObj)', 4], @@ -274,9 +322,18 @@ const dataSource = [ ['bool(hello * 5)', false], ['bool(\'false\')', true], // we make it true, because it is not empty ['bool(\'hi\')', true], + ['[1,2,3]', [1,2,3]], + ['[1,2,3, [4,5]]', [1,2,3, [4,5]]], + ['\"[1,2,3]\"', '[1,2,3]'], + ['[1, bool(0), string(bool(1)), float(\'10\')]', [1, true, 'true', 10.0]], + ['[\'a\', \'b[]\', \'c[][][]\'][1]', 'b[]'], + ['[\'a\', [\'b\', \'c\']][1][0]', 'b'], + ['union(["a", "b", "c"], ["d", ["e", "f"], "g"][1])', ['a', 'b', 'c', 'e', 'f']], + ['union(["a", "b", "c"], ["d", ["e", "f"], "g"][1])[1]', ['b']], ['createArray(\'h\', \'e\', \'l\', \'l\', \'o\')', ['h', 'e', 'l', 'l', 'o']], + ['createArray()', []], + ['[]', []], ['createArray(1, bool(0), string(bool(1)), float(\'10\'))', [1, true, 'true', 10.0]], - ['array(hello)', ['hello']], ['binary(hello)', '0110100001100101011011000110110001101111'], ['dataUri(hello)', 'data:text/plain;charset=utf-8;base64,aGVsbG8='], ['dataUriToBinary(dataUri(hello))', '011001000110000101110100011000010011101001110100011001010111100001110100001011110111000001101100011000010110100101101110001110110110001101101000011000010111001001110011011001010111010000111101011101010111010001100110001011010011100000111011011000100110000101110011011001010011011000110100001011000110000101000111010101100111001101100010010001110011100000111101'], @@ -342,8 +399,8 @@ const dataSource = [ ['formatDateTime(notISOTimestamp, \'ddd\')', 'Thu'], ['formatDateTime(notISOTimestamp, \'dddd\')', 'Thursday'], ['formatDateTime(\'2018-03-15T00:00:00.000Z\', \'yyyy\')', '2018'], -// ['formatDateTime(\'2018-03-15T00:00:00.000Z\', \'yyyy-MM-dd-\\\\d\')', '2018-03-15-4'], -// - Fails in the US + // ['formatDateTime(\'2018-03-15T00:00:00.000Z\', \'yyyy-MM-dd-\\\\d\')', '2018-03-15-4'], + // - Fails in the US ['formatDateTime(\'2018-03-15T00:00:00.010Z\', \'FFFF\')', '0100'], ['formatDateTime(\'2018-03-15T00:00:00.010Z\', \'FFFFFF\')', '010000'], ['formatDateTime(\'2018-03-15T00:00:00.010Z\', \'FFF\')', '010'], @@ -366,9 +423,9 @@ const dataSource = [ ['subtractFromTime(timestamp, 1, \'Hour\')', '2018-03-15T12:00:00.111Z'], ['subtractFromTime(timestamp, 1, \'Minute\')', '2018-03-15T12:59:00.111Z'], ['subtractFromTime(timestamp, 1, \'Second\')', '2018-03-15T12:59:59.111Z'], -// ['dateReadBack(timestamp, addDays(timestamp, 1))', 'tomorrow'], -// ['dateReadBack(addDays(timestamp, 1),timestamp)', 'yesterday'], -// - Fails in the US + // ['dateReadBack(timestamp, addDays(timestamp, 1))', 'tomorrow'], + // ['dateReadBack(addDays(timestamp, 1),timestamp)', 'yesterday'], + // - Fails in the US ['getTimeOfDay(\'2018-03-15T00:00:00.000Z\')', 'midnight'], ['getTimeOfDay(\'2018-03-15T08:00:00.000Z\')', 'morning'], ['getTimeOfDay(\'2018-03-15T12:00:00.000Z\')', 'noon'], @@ -405,6 +462,7 @@ const dataSource = [ ['uriScheme(\'http://www.contoso.com/catalog/shownew.htm?date=today\')', 'http'], // Collection functions tests + ['createArray(hello)', ['hello']], ['sum(createArray(1, 2))', 3], ['sum(createArray(one, two, 3))', 6.0], ['average(createArray(1, 2))', 1.5], @@ -513,7 +571,27 @@ const dataSource = [ ['isMatch(\'12abc\', \'([0-9]+)([a-z]+)([0-9]+)\')', false], // "(...)" (simple group) ['isMatch("a", "\\\\w{1}")', true], // "\w" (match [a-zA-Z0-9_]) ['isMatch("1", "\\\\d{1}")', true], // "\d" (match [0-9]) + ['isMatch("12.5", "[0-9]+(\\\\.5)")', true], // "\." (match .) + ['isMatch("12x5", "[0-9]+(\\\\.5)")', false], // "\." (match .) + //Type Checking Tests + ['isString(hello)', true], + ['isString("Monday")', true], + ['isString(one)', false], + ['isInteger(one)', true], + ['isInteger(1)', true], + ['isInteger(1.23)', false], + ['isFloat(one)', false], + ['isFloat(1)', false], + ['isFloat(1.23)', true], + ['isArray(hello)', false], + ['isArray(createArray(1,2,3))', true], + ['isObject(hello)', false], + ['isObject(dialog)', true], + ['isBoolean(hello)', false], + ['isBoolean(1 == one)', true], + ['isDateTime(hello)', false], + ['isDateTime(timestamp)', true], // Empty expression ['', ''], @@ -522,18 +600,19 @@ const dataSource = [ ['setPathToValue(path.simple, 5) + path.simple', 10], ['setPathToValue(path.array[0], 7) + path.array[0]', 14], ['setPathToValue(path.array[1], 9) + path.array[1]', 18], - /* - ['setPathToValue(path.darray[2][0], 11) + path.darray[2][0]', 22], - ['setPathToValue(path.darray[2][3].foo, 13) + path.darray[2][3].foo', 26], - ['setPathToValue(path.overwrite, 3) + setPathToValue(path.overwrite[0], 4) + path.overwrite[0]', 11], - ['setPathToValue(path.overwrite[0], 3) + setPathToValue(path.overwrite, 4) + path.overwrite', 11], - ['setPathToValue(path.overwrite.prop, 3) + setPathToValue(path.overwrite, 4) + path.overwrite', 11], - ['setPathToValue(path.overwrite.prop, 3) + setPathToValue(path.overwrite[0], 4) + path.overwrite[0]', 11], - */ ['setPathToValue(path.x, null)', undefined], ]; const scope = { + "$index": "index", + alist: [ + { + Name: 'item1' + }, + { + Name: 'item2' + } + ], emptyList:[], emptyObject: new Map(), emptyJObject: {}, @@ -624,7 +703,7 @@ const scope = { ], }; -describe('expression functional test', () => { +describe('expression parser functional test', () => { it('should get right evaluate result', () => { for (const data of dataSource) { const input = data[0].toString(); @@ -636,29 +715,20 @@ describe('expression functional test', () => { const expected = data[1]; - //Assert Object Equals - if (Array.isArray(actual) && Array.isArray(expected)) { - const [isSuccess, errorMessage] = isArraySame(actual, expected); - if (!isSuccess) { - assert.fail(errorMessage); - } - } else if (typeof expected === 'number') { - assert(parseFloat(actual) === expected, `actual is: ${ actual } for case ${ input }`); - } - else { - assert(actual === expected, `actual is: ${ actual } for case ${ input }`); - } + assertObjectEquals(actual, expected); //Assert ExpectedRefs if (data.length === 3) { - const actualRefs = Extensions.references(parsed); - const [isSuccess, errorMessage] = isArraySame(actualRefs.sort(), data[2].sort()); - if (!isSuccess) { - assert.fail(errorMessage); - } + const actualRefs = parsed.references(); + assertObjectEquals(actualRefs.sort(), data[2].sort()); } + + //ToString re-parse + const newExpr = Expression.parse(parsed.toString()); + const newActual = newExpr.tryEvaluate(scope).value; + assertObjectEquals(newActual, actual); } - }); + }).timeout(5000); it('Test AccumulatePath', () => { const scope = { @@ -674,8 +744,6 @@ describe('expression functional test', () => { // normal case, note, we doesn't append a " yet let exp = Expression.parse('a[f].b[n].z'); let path = undefined; - let left = undefined; - let error = undefined; ({path, left, error} = ExpressionFunctions.tryAccumulatePath(exp, memory)); assert.strictEqual(path, 'a[\'foo\'].b[2].z'); @@ -697,20 +765,17 @@ describe('expression functional test', () => { }); }); -var isArraySame = (actual, expected) => { //return [isSuccess, errorMessage] - if (actual.length !== expected.length) return [false, `expected length: ${ expected.length }, actual length: ${ actual.length }`]; - - for (let i = 0; i < actual.length; i++) { - if (Array.isArray(actual[i]) && Array.isArray(expected[i])) { - if (!isArraySame(actual[i], expected[i])) { - return [false, `actual is: ${ actual[i] }, expected is: ${ expected[i] }`] - } - } else if (Array.isArray(actual[i]) || Array.isArray(expected[i])){ - return [false, `actual is: ${ actual[i] }, expected is: ${ expected[i] }`] - } else if (actual[i] !== expected[i]) { - return [false, `actual is: ${ actual[i] }, expected is: ${ expected[i] }`]; +var assertObjectEquals = (actual, expected) => { + if (actual === undefined || expected === undefined) { + return; + } else if (typeof actual === 'number' && typeof expected === 'number') { + assert.equal(parseFloat(actual), parseFloat(expected), `actual is: ${ actual }, expected is ${ expected }`); + } else if (Array.isArray(actual) && Array.isArray(expected)) { + assert.equal(actual.length, expected.length); + for(let i = 0; i< actual.length; i++) { + assertObjectEquals(actual[i], expected[i], `actual is: ${ actual[i] }, expected is ${ expected[i] }`); } + } else { + assert.equal(actual, expected, `actual is: ${ actual }, expected is ${ expected }`); } - - return [true, '']; -}; \ No newline at end of file +}; diff --git a/libraries/botbuilder-ai/src/luisRecognizer.ts b/libraries/botbuilder-ai/src/luisRecognizer.ts index 1943877a0a..9fee62714d 100644 --- a/libraries/botbuilder-ai/src/luisRecognizer.ts +++ b/libraries/botbuilder-ai/src/luisRecognizer.ts @@ -170,12 +170,12 @@ export interface LuisRecognizerOptionsV3 extends LuisRecognizerOptions { /** * (Optional) Dynamic lists of things like contact names to recognize at query time.. */ - dynamicLists?: any[]; + dynamicLists?: Array; /** * (Optional) External entities recognized in query. */ - externalEntities?: any[]; + externalEntities?: Array; /** * (Optional) Boolean for if external entities should be preferred to the results from LUIS models. diff --git a/libraries/botbuilder-ai/src/luisRecognizerOptionsV3.ts b/libraries/botbuilder-ai/src/luisRecognizerOptionsV3.ts index 4cd6440b2b..b8032f04bb 100644 --- a/libraries/botbuilder-ai/src/luisRecognizerOptionsV3.ts +++ b/libraries/botbuilder-ai/src/luisRecognizerOptionsV3.ts @@ -57,8 +57,13 @@ export class LuisRecognizerV3 extends LuisRecognizerInternal { const uri = this.buildUrl(); const httpOptions = this.buildRequestBody(utterance); - const data = await fetch(uri, httpOptions) + const data = await fetch(uri, httpOptions); const response = await data.json(); + if (response.error) { + const errObj = response.error; + const errMessage = errObj.code ? `${ errObj.code }: ${ errObj.message }` : errObj.message; + throw new Error(`[LUIS Recognition Error]: ${ errMessage }`); + } const result: RecognizerResult = { text: utterance, intents : getIntents(response.prediction), diff --git a/libraries/botbuilder-core/src/activityFactory.ts b/libraries/botbuilder-core/src/activityFactory.ts new file mode 100644 index 0000000000..ccad1b4555 --- /dev/null +++ b/libraries/botbuilder-core/src/activityFactory.ts @@ -0,0 +1,627 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + +import { Activity, SuggestedActions, Attachment, ActivityTypes, ActionTypes, CardAction } from 'botframework-schema'; +import { MessageFactory } from './messageFactory'; +import { CardFactory } from './cardFactory'; + +/** + * The ActivityFactory + * to generate text and then uses simple markdown semantics like chatdown to create Activity. + */ +export class ActivityFactory { + + private static readonly lgType = 'lgType'; + private static readonly errorPrefix = '[ERROR]'; + private static readonly warningPrefix = '[WARNING]'; + private static adaptiveCardType: string = CardFactory.contentTypes.adaptiveCard; + + private static readonly genericCardTypeMapping: Map = new Map + ([ + [ 'herocard', CardFactory.contentTypes.heroCard ], + [ 'thumbnailcard', CardFactory.contentTypes.thumbnailCard ], + [ 'audiocard', CardFactory.contentTypes.audioCard ], + [ 'videocard', CardFactory.contentTypes.videoCard ], + [ 'animationcard', CardFactory.contentTypes.animationCard ], + [ 'signincard', CardFactory.contentTypes.signinCard ], + [ 'oauthcard', CardFactory.contentTypes.oauthCard ], + [ 'receiptcard', CardFactory.contentTypes.receiptCard ], + ]); + + private static readonly activityProperties: string[] = ['type','id','timestamp','localTimestamp','localTimezone','callerId', + 'serviceUrl','channelId','from','conversation','recipient','textFormat','attachmentLayout','membersAdded', + 'membersRemoved','reactionsAdded','reactionsRemoved','topicName','historyDisclosed','locale','text','speak', + 'inputHint','summary','suggestedActions','attachments','entities','channelData','action','replyToId','label', + 'valueType','value','name','typrelatesToe','code','expiration','importance','deliveryMode','listenFor', + 'textHighlights','semanticAction']; + + private static readonly cardActionProperties: string[] = ['type','title','image','text','displayText','value','channelData']; + + /** + * Generate the activity. + * @param lgResult string result from languageGenerator. + */ + public static fromObject(lgResult: any): Partial { + const diagnostics: string[] = this.checkLGResult(lgResult); + const errors: string[] = diagnostics.filter((u: string): boolean => u.startsWith(this.errorPrefix)); + if (errors !== undefined && errors.length > 0) { + throw new Error(`${ errors.join('\n') }`); + } + + if (typeof lgResult === 'string') { + const structuredLGResult: any = this.parseStructuredLGResult(lgResult.trim()); + return structuredLGResult === undefined ? + this.buildActivityFromText(lgResult.trim()) + :this.buildActivityFromLGStructuredResult(lgResult); + } + + return this.buildActivityFromLGStructuredResult(lgResult); + } + + /** + * check the LG result before generate an Activity. + * @param lgResult lg output. + * @returns Diagnostic list. + */ + public static checkLGResult(lgResult: any): string[] { + if (lgResult === undefined) { + return [this.buildDiagnostic('LG output is empty', false)]; + } + + if (typeof lgResult === 'string') { + if (!lgResult.startsWith('{') || !lgResult.endsWith('}')) { + return [this.buildDiagnostic('LG output is not a json object, and will fallback to string format.', false)]; + } + + let lgStructuredResult: any = undefined; + + try { + lgStructuredResult = JSON.parse(lgResult); + } catch (error) { + return [this.buildDiagnostic('LG output is not a json object, and will fallback to string format.', false)]; + } + + return this.checkStructuredResult(lgStructuredResult); + } else { + return this.checkStructuredResult(lgResult); + } + } + + /** + * Given a lg result, create a text activity. This method will create a MessageActivity from text. + * @param text lg text output. + */ + private static buildActivityFromText(text: string): Partial { + const msg: Partial = { + type: ActivityTypes.Message, + text: text, + speak: text + }; + + return msg; + } + + /** + * Given a structured lg result, create an activity. This method will create an MessageActivity from object + * @param lgValue lg output. + */ + private static buildActivityFromLGStructuredResult(lgValue: any): Partial { + let activity: Partial = {}; + + const type: string = this.getStructureType(lgValue); + if (this.genericCardTypeMapping.has(type) || type === 'attachment') { + activity = MessageFactory.attachment(this.getAttachment(lgValue)); + } else if (type === 'activity') { + activity = this.buildActivity(lgValue); + } else if (lgValue){ + activity = this.buildActivityFromText(JSON.stringify(lgValue).trim()); + } + + return activity; + } + + private static buildActivity(messageValue: any): Partial { + let activity: Partial = { type: ActivityTypes.Message }; + for (const key of Object.keys(messageValue)) { + const property: string = key.trim(); + if (property === this.lgType) { + continue; + } + + const value: any = messageValue[key]; + + switch (property.toLowerCase()) { + case 'attachments': + activity.attachments = this.getAttachments(value); + break; + case 'suggestedactions': + activity.suggestedActions = this.getSuggestions(value); + break; + default: + var properties = this.activityProperties.map((u: string): string => u.toLowerCase()); + if (properties.includes(property.toLowerCase())) + { + var realPropertyName = this.activityProperties[properties.indexOf(property.toLowerCase())]; + activity[realPropertyName] = value; + } else { + activity[property.toLowerCase()] = value; + } + break; + } + } + + return activity; + } + + private static getSuggestions(suggestionsValue: any): SuggestedActions { + const actions: any[] = this.normalizedToList(suggestionsValue); + + const suggestedActions: SuggestedActions = { + actions : this.getCardActions(actions), + to: [] + }; + + return suggestedActions; + } + + private static getButtons(buttonsValue: any): CardAction[] { + const actions: any[] = this.normalizedToList(buttonsValue); + return this.getCardActions(actions); + } + + private static getCardActions(actions: any[]): CardAction[] { + return actions.map((u: any): CardAction => this.getCardAction(u)); + } + + private static getCardAction(action: any): CardAction + { + let cardAction: CardAction; + if (typeof action === 'string') { + cardAction = { type: ActionTypes.ImBack, value: action, title: action, channelData: undefined }; + } else { + const type: string = this.getStructureType(action); + cardAction = { + type: ActionTypes.ImBack, + title: '', + value: '' + }; + + if (type === 'cardaction') { + for (const key of Object.keys(action)) { + const property: string = key.trim(); + if (property === this.lgType) { + continue; + } + + const value: any = action[key]; + + switch (property.toLowerCase()) { + case 'displaytext': + cardAction.displayText = value; + break; + case 'channeldata': + cardAction.channelData = value; + break; + default: + cardAction[property.toLowerCase()] = value; + break; + } + } + } + } + + return cardAction; + } + + + + + private static getAttachments(input: any): Attachment[] { + const attachments: Attachment[] = []; + const attachmentsJsonList: any[] = this.normalizedToList(input); + + for (const attachmentsJson of attachmentsJsonList) { + if (typeof attachmentsJson === 'object') { + attachments.push(this.getAttachment(attachmentsJson)); + } + } + + return attachments; + } + + private static getAttachment(input: any): Attachment { + let attachment: Attachment = { + contentType: '' + }; + const type: string = this.getStructureType(input); + if (this.genericCardTypeMapping.has(type)) { + attachment = this.getCardAttachment(this.genericCardTypeMapping.get(type), input); + } else if (type === 'adaptivecard') { + attachment = CardFactory.adaptiveCard(input); + } else if (type === 'attachment') { + attachment = this.getNormalAttachment(input); + } else { + attachment = {contentType: type, content: input}; + } + + return attachment; + } + + private static getNormalAttachment(input: any): Attachment { + const attachment: Attachment = {contentType:''}; + + for (const key of Object.keys(input)) { + const property: string = key.trim(); + const value: any = input[key]; + + switch (property.toLowerCase()) { + case 'contenttype': + const type: string = value.toString().toLowerCase(); + if (this.genericCardTypeMapping.has(type)) { + attachment.contentType = this.genericCardTypeMapping.get(type); + } else if (type === 'adaptivecard') { + attachment.contentType = this.adaptiveCardType; + } else { + attachment.contentType = type; + } + break; + case 'contenturl': + attachment.contentUrl = value; + break; + case 'thumbnailurl': + attachment.thumbnailUrl = value; + break; + default: + attachment[property.toLowerCase()] = value; + break; + } + } + + return attachment; + } + + private static getCardAttachment(type: string, input: any): Attachment { + const card: any = {}; + + for (const key of Object.keys(input)) { + const property: string = key.trim().toLowerCase(); + const value: any = input[key]; + + switch (property) { + case 'tap': + card[property] = this.getCardAction(value); + break; + case 'image': + case 'images': + if (type === CardFactory.contentTypes.heroCard || type === CardFactory.contentTypes.thumbnailCard) { + if (!('images' in card)) { + card['images'] = []; + } + + const imageList: string[] = this.normalizedToList(value).map((u): string => u.toString()); + imageList.forEach( (u): any => card['images'].push({url : u})); + } else { + card['image'] = {url: value.toString()}; + } + break; + case 'media': + if (!('media' in card)) { + card['media'] = []; + } + + const mediaList: string[] = this.normalizedToList(value).map((u): string => u.toString()); + mediaList.forEach( (u): any => card['media'].push({url : u})); + break; + case 'buttons': + if (!('buttons' in card)) { + card['buttons'] = []; + } + + const buttons: any[] = this.getButtons(value); + buttons.forEach( (u): any => card[property].push(u)); + break; + case 'autostart': + case 'shareable': + case 'autoloop': + const boolValue: boolean = this.getValidBooleanValue(value.toString()); + if (boolValue !== undefined) { + card[property] = boolValue; + } + break; + case 'connectionname': + card['connectionName'] = value; + break; + default: + card[property.toLowerCase()] = value; + break; + } + } + + const attachment: Attachment = { + contentType: type, + content: card + }; + + return attachment; + } + + private static normalizedToList(item: any): any[] { + if (item === undefined) { + return []; + } else if (Array.isArray(item)) { + return item; + } else { + return [item]; + } + } + + private static parseStructuredLGResult(lgStringResult: string): any + { + let lgStructuredResult: any = undefined; + if (lgStringResult === undefined || lgStringResult === '') { + return undefined; + } + + lgStringResult = lgStringResult.trim(); + + if (lgStringResult === '' || !lgStringResult.startsWith('{') || !lgStringResult.endsWith('}')) { + return undefined; + } + + try { + lgStructuredResult = JSON.parse(lgStringResult); + const type = this.getStructureType(lgStringResult); + if (!type || type.trim() === '') { + return undefined; + } + } catch (error) { + return undefined; + } + + return lgStructuredResult; + } + + private static checkStructuredResult(input: any): string[] { + const result: string[] = []; + const type: string = this.getStructureType(input); + + if (!type || type.trim() === '') { + return result; + } + + if (this.genericCardTypeMapping.has(type) || type === 'attachment') { + result.push(...this.checkAttachment(input)); + } else if (type === 'activity') { + result.push(...this.checkActivity(input)); + } else { + const diagnosticMessage = `Type '${ type }' is not supported currently.`; + result.push(this.buildDiagnostic(diagnosticMessage, false)); + } + + return result; + } + + private static checkActivity(input: any): string[] { + const result: string[] = []; + let activityType: string = undefined; + if ('type' in input) { + activityType = input['type'].toString().trim(); + } + + result.push(...this.checkActivityType(activityType)); + result.push(...this.checkActivityPropertyName(input)); + result.push(...this.checkActivityProperties(input)); + + return result; + } + + private static checkActivityType(activityType: string): string[] { + if (activityType !== undefined) { + if (!Object.values(ActivityTypes).map((u: string): string => u.toLowerCase()).includes(activityType.toLowerCase())) { + return [this.buildDiagnostic(`'${ activityType }' is not a valid activity type.`)]; + } + } + return []; + } + + private static checkActivityPropertyName(input: any): string[] { + const invalidProperties: string[] = []; + for (const property of Object.keys(input)) { + if (property === this.lgType) { + continue; + } + if (!this.activityProperties.map((u: string): string => u.toLowerCase()).includes(property.toLowerCase())) { + invalidProperties.push(property); + } + } + if (invalidProperties.length > 0) { + return [this.buildDiagnostic(`'${ invalidProperties.join(',') }' not support in Activity.`, false)]; + } + + return []; + } + + private static checkActivityProperties(input: any): string[] { + const result: string[] = []; + for (const key of Object.keys(input)) { + const property: string = key.trim(); + const value: any = input[key]; + + switch (property.toLowerCase()) { + case 'attachments': + result.push(...this.checkAttachments(value)); + break; + case 'suggestedactions': + result.push(...this.checkSuggestions(value)); + break; + default: + break; + } + } + + return result; + } + + private static checkSuggestions(value: any): string[] { + const actions: any[] = this.normalizedToList(value); + return this.checkCardActions(actions); + } + + private static checkButtons(value: any): string[] { + const actions: any[] = this.normalizedToList(value); + return this.checkCardActions(actions); + } + + private static checkCardActions(actions: any[]): string[] { + const result: string[] = []; + actions.forEach((u: any): void => { result.push(...this.checkCardAction(u)); }); + return result; + } + + private static checkCardAction(value: any): string[] { + const result: string[] = []; + if (typeof value === 'string') { + return result; + } + + if (typeof value === 'object') { + const type: string = this.getStructureType(value); + if (type !== 'cardaction') { + result.push(this.buildDiagnostic(`'${ type }' is not card action type.`, false)); + } else { + result.push(...this.checkCardActionPropertyName(value)); + if ('type' in value) { + result.push(...this.checkCardActionType(value['type'])); + } + } + } else { + result.push(this.buildDiagnostic(`'${ value }' is not a valid card action format.`, false)); + } + + return result; + } + + + private static checkCardActionPropertyName(input: any): string[] { + const invalidProperties: string[] = []; + for (const property of Object.keys(input)) { + if (property === this.lgType) { + continue; + } + if (!this.cardActionProperties.map((u: string): string => u.toLowerCase()).includes(property.toLowerCase())) { + invalidProperties.push(property); + } + } + if (invalidProperties.length > 0) { + return [this.buildDiagnostic(`'${ invalidProperties.join(',') }' not support in card action.`, false)]; + } + + return []; + } + + private static checkCardActionType(cardActionType: string): string[] { + const result: string[] = []; + if (!cardActionType) { + return result; + } + + if (!Object.values(ActionTypes).map((u: string): string => u.toLowerCase()).includes(cardActionType.toLowerCase())) { + return [this.buildDiagnostic(`'${ cardActionType }' is not a valid card action type.`)]; + } + + return result; + } + + private static checkAttachments(value: any): string[] { + const result: string[] = []; + const attachmentsJsonList: any[] = this.normalizedToList(value); + + for (const attachmentsJson of attachmentsJsonList) { + if (typeof attachmentsJson === 'object') { + result.push(...this.checkAttachment(attachmentsJson)); + } + } + + return result; + } + + private static checkAttachment(value: any): string[] { + const result: string[] = []; + const type: string = this.getStructureType(value); + if (this.genericCardTypeMapping.has(type)) { + result.push(...this.checkCardAttachment(value)); + } else if (type === 'adaptivecard') { + // TODO + // check adaptivecard format + } else if (type === 'attachment') { + // TODO + // Check attachment format + } else { + result.push(this.buildDiagnostic(`'${ type }' is not an attachment type.`, false)); + } + + return result; + } + + private static checkCardAttachment(input: any): string[] { + const result: string[] = []; + for (const key of Object.keys(input)) { + const property: string = key.trim().toLowerCase(); + const value: any = input[key]; + + switch (property) { + case 'buttons': + result.push(...this.checkButtons(value)); + break; + case 'autostart': + case 'shareable': + case 'autoloop': + const boolValue: boolean = this.getValidBooleanValue(value.toString()); + if (boolValue === undefined) { + result.push(this.buildDiagnostic(`'${ value.toString() }' is not a boolean value.`)); + } + break; + default: + break; + } + } + + return result; + } + + private static getStructureType(input: any): string { + let result = ''; + + if (input && typeof input === 'object') { + if (this.lgType in input) { + result = input[this.lgType].toString(); + } else if ('type' in input) { + // Adaptive card type + result = input['type'].toString(); + } + } + + return result.trim().toLowerCase(); + } + + + private static getValidBooleanValue(boolValue: string): boolean{ + if (boolValue.toLowerCase() === 'true') + { + return true; + } + else if (boolValue.toLowerCase() === 'false') + { + return false; + } + + return undefined; + } + + private static buildDiagnostic(message: string, isError: boolean = true): string { + message = message === undefined ? '' : message; + return isError ? this.errorPrefix + message : this.warningPrefix + message; + } +} \ No newline at end of file diff --git a/libraries/botbuilder-core/src/activityHandler.ts b/libraries/botbuilder-core/src/activityHandler.ts index 7fc244fe20..7dc0445558 100644 --- a/libraries/botbuilder-core/src/activityHandler.ts +++ b/libraries/botbuilder-core/src/activityHandler.ts @@ -2,8 +2,13 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { MessageReaction, TurnContext } from '.'; + +import { MessageReaction } from 'botframework-schema'; import { ActivityHandlerBase } from './activityHandlerBase'; +import { InvokeResponse } from './invokeResponse'; +import { verifyStateOperationName, tokenExchangeOperationName, tokenResponseEventName } from './signInConstants'; +import { StatusCodes } from './statusCodes'; +import { TurnContext } from './turnContext'; /** * Describes a bot activity event handler, for use with an [ActivityHandler](xref:botbuilder-core.ActivityHandler) object. @@ -397,6 +402,47 @@ export class ActivityHandler extends ActivityHandlerBase { await this.handle(context, 'Message', this.defaultNextEvent(context)); } + /* + * Provides default behavior for invoke activities. + * + * @param context The context object for the current turn. + * + * @remarks + * Overwrite this method to support channel-specific behavior across multiple channels. + * The default logic is to check for a signIn invoke and handle that + * and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent). + */ + protected async onInvokeActivity(context: TurnContext): Promise { + try { + if (context.activity.name && (context.activity.name === verifyStateOperationName || context.activity.name === tokenExchangeOperationName)) { + await this.onSignInInvoke(context); + return { status: StatusCodes.OK }; + } + throw new Error('NotImplemented'); + } + catch (err) { + if (err.message === 'NotImplemented') { + return { status: StatusCodes.NOT_IMPLEMENTED }; + } + throw err; + } + finally { + this.defaultNextEvent(context)(); + } + } + + /* + * Handle _signin invoke activity type_. + * + * @param context The context object for the current turn. + * + * @remarks + * Overwrite this method to support channel-specific behavior across multiple channels. + */ + protected async onSignInInvoke(context: TurnContext): Promise { + throw new Error('NotImplemented'); + } + /** * Runs all registered _endOfConversation_ handlers and then continues the event emission process. * @@ -597,7 +643,7 @@ export class ActivityHandler extends ActivityHandlerBase { * - Continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent). */ protected async dispatchEventActivity(context: TurnContext): Promise { - if (context.activity.name === 'tokens/response') { + if (context.activity.name === tokenResponseEventName) { await this.handle(context, 'TokenResponseEvent', this.defaultNextEvent(context)); } else { await this.defaultNextEvent(context)(); diff --git a/libraries/botbuilder-core/src/activityHandlerBase.ts b/libraries/botbuilder-core/src/activityHandlerBase.ts index d49faa3343..10f4a19c5d 100644 --- a/libraries/botbuilder-core/src/activityHandlerBase.ts +++ b/libraries/botbuilder-core/src/activityHandlerBase.ts @@ -7,6 +7,11 @@ import { ChannelAccount, MessageReaction, TurnContext } from '.'; +import { InvokeResponse } from './invokeResponse'; +import { StatusCodes } from './statusCodes'; + +// This key is exported internally so that subclassed ActivityHandlers and BotAdapters will not overwrite any already set InvokeResponses. +export const INVOKE_RESPONSE_KEY: symbol = Symbol('invokeResponse'); /** * Defines the core behavior for event-emitting activity handlers for bots. @@ -44,6 +49,7 @@ export class ActivityHandlerBase { * - Conversation update activities * - Message reaction activities * - Event activities + * - Invoke activities * - _Unrecognized_ activities, ones that this class has not otherwise defined an _on event_ method for. */ protected async onTurnActivity(context: TurnContext): Promise { @@ -60,6 +66,13 @@ export class ActivityHandlerBase { case ActivityTypes.Event: await this.onEventActivity(context); break; + case ActivityTypes.Invoke: + const invokeResponse = await this.onInvokeActivity(context); + // If onInvokeActivity has already sent an InvokeResponse, do not send another one. + if (invokeResponse && !context.turnState.get(INVOKE_RESPONSE_KEY)) { + await context.sendActivity({ value: invokeResponse, type: 'invokeResponse' }); + } + break; case ActivityTypes.EndOfConversation: await this.onEndOfConversationActivity(context); break; @@ -149,6 +162,18 @@ export class ActivityHandlerBase { return; } + /** + * Provides a hook for invoke calls. + * + * @param context The context object for the current turn. + * + * @remarks + * Overwrite this method to handle particular invoke calls. + */ + protected async onInvokeActivity(context: TurnContext): Promise { + return { status: StatusCodes.NOT_IMPLEMENTED }; + } + /** * Provides a hook for emitting the _end of conversation_ event. * diff --git a/libraries/botbuilder-core/src/botAdapter.ts b/libraries/botbuilder-core/src/botAdapter.ts index ec3eae7959..55723e28dd 100644 --- a/libraries/botbuilder-core/src/botAdapter.ts +++ b/libraries/botbuilder-core/src/botAdapter.ts @@ -30,6 +30,7 @@ export abstract class BotAdapter { protected middleware: MiddlewareSet = new MiddlewareSet(); private turnError: (context: TurnContext, error: Error) => Promise; public readonly BotIdentityKey: Symbol = Symbol('BotIdentity'); + public readonly OAuthScopeKey: Symbol = Symbol('OAuthScope'); /** * Asynchronously sends a set of outgoing activities to a channel server. diff --git a/libraries/botbuilder-core/src/botAdapterSet.ts b/libraries/botbuilder-core/src/botAdapterSet.ts deleted file mode 100644 index 959324e0f9..0000000000 --- a/libraries/botbuilder-core/src/botAdapterSet.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @module botbuilder - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ -import { BotAdapter } from './botAdapter'; -import { TurnContext } from './turnContext'; - -export class BotAdapterSet { - private adapters: { [channel:string]: BotAdapter; } = {}; - - constructor (defaultAdapter?: BotAdapter) { - if (defaultAdapter) { - this.addAdapter('*', defaultAdapter); - } - } - - public addAdapter(channels: string|string[], adapter: BotAdapter): this { - // Add callback hook to adapters middleware chain - adapter.use((context, next) => this.onTurn(context, next)); - - // Save to map - (Array.isArray(channels) ? channels : [channels]).forEach((channel) => { - this.adapters[channel] = adapter; - }); - return this; - } - - public findAdapter(channel: string): BotAdapter|undefined { - if (this.adapters.hasOwnProperty(channel)) { - return this.adapters[channel]; - } else if (this.adapters.hasOwnProperty('*')) { - return this.adapters['*']; - } else { - return undefined; - } - } - - protected onTurn(context: TurnContext, next: () => Promise): Promise { - return next(); - } -} \ No newline at end of file diff --git a/libraries/botbuilder-core/src/cardFactory.ts b/libraries/botbuilder-core/src/cardFactory.ts index bdef2cdef9..df0bbfeb25 100644 --- a/libraries/botbuilder-core/src/cardFactory.ts +++ b/libraries/botbuilder-core/src/cardFactory.ts @@ -2,7 +2,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { ActionTypes, AnimationCard, Attachment, AudioCard, CardAction, CardImage, HeroCard, MediaUrl, OAuthCard, O365ConnectorCard, ReceiptCard, SigninCard, ThumbnailCard, VideoCard } from 'botframework-schema'; +import { ActionTypes, AnimationCard, Attachment, AudioCard, CardAction, CardImage, HeroCard, MediaUrl, OAuthCard, O365ConnectorCard, ReceiptCard, SigninCard, ThumbnailCard, TokenExchangeResource, VideoCard } from 'botframework-schema'; /** * Provides methods for formatting the various card types a bot can return. @@ -179,12 +179,13 @@ export class CardFactory { * @remarks * OAuth cards support the Bot Framework's single sign on (SSO) service. */ - public static oauthCard(connectionName: string, title: string, text?: string, link?: string): Attachment { + public static oauthCard(connectionName: string, title: string, text?: string, link?: string, tokenExchangeResource?: TokenExchangeResource): Attachment { const card: Partial = { buttons: [ { type: ActionTypes.Signin, title: title, value: link, channelData: undefined } ], - connectionName: connectionName + connectionName, + tokenExchangeResource }; if (text) { card.text = text; } diff --git a/libraries/botbuilder-core/src/appCredentials.ts b/libraries/botbuilder-core/src/coreAppCredentials.ts similarity index 59% rename from libraries/botbuilder-core/src/appCredentials.ts rename to libraries/botbuilder-core/src/coreAppCredentials.ts index 77f26b85fd..25699b8fe8 100644 --- a/libraries/botbuilder-core/src/appCredentials.ts +++ b/libraries/botbuilder-core/src/coreAppCredentials.ts @@ -6,22 +6,28 @@ * Licensed under the MIT License. */ - /** - * Internal interface representing the "WebResource" from @azure/ms-rest-js@1.2.6 - */ -interface WebResource {} +/** + * Internal interface representing the "WebResource" from @azure/ms-rest-js@1.2.6 + */ +interface CoreWebResource { + url?: string; + method?: any; + body?: any; + headers?: any; +} + /** - * AppCredentials + * CoreAppCredentials * @remarks * Runtime-agnostic interface representing "ServiceClientCredentials" from @azure/ms-rest-js@1.2.6 */ -export interface AppCredentials { +export interface CoreAppCredentials { /** * Signs a request with the Authentication header. * * @param {WebResource} webResource The WebResource/request to be signed. * @returns {Promise} The signed request object; */ - signRequest(webResource: WebResource): Promise; + signRequest(webResource: CoreWebResource): Promise; } diff --git a/libraries/botbuilder-core/src/credentialTokenProvider.ts b/libraries/botbuilder-core/src/credentialTokenProvider.ts deleted file mode 100644 index 8e918748f9..0000000000 --- a/libraries/botbuilder-core/src/credentialTokenProvider.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @module botbuilder-core - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ - -import { AppCredentials } from './appCredentials'; -import { IUserTokenProvider } from './userTokenProvider'; -import { TurnContext } from './turnContext'; -import { TokenResponse } from 'botframework-schema'; - -export interface CredentialTokenProvider extends IUserTokenProvider { - /** - * Retrieves the OAuth token for a user that is in a sign-in flow. - * @param context Context for the current turn of conversation with the user. - * @param connectionName Name of the auth connection to use. - * @param magicCode (Optional) Optional user entered code to validate. - */ - getUserToken(context: TurnContext, connectionName: string, magicCode?: string, appCredentials?: AppCredentials): Promise; - - /** - * Signs the user out with the token server. - * @param context Context for the current turn of conversation with the user. - * @param connectionName Name of the auth connection to use. - * @param userId User id of user to sign out. - * @param oAuthAppCredentials AppCredentials for OAuth. - */ - signOutUser(context: TurnContext, connectionName: string, userId?: string, appCredentials?: AppCredentials): Promise; - - /** - * Gets a signin link from the token server that can be sent as part of a SigninCard. - * @param context Context for the current turn of conversation with the user. - * @param connectionName Name of the auth connection to use. - * @param oAuthAppCredentials AppCredentials for OAuth. - */ - getSignInLink(context: TurnContext, connectionName: string, appCredentials?: AppCredentials): Promise; - - /** - * Signs the user out with the token server. - * @param context Context for the current turn of conversation with the user. - * @param connectionName Name of the auth connection to use. - * @param oAuthAppCredentials AppCredentials for OAuth. - */ - getAadTokens(context: TurnContext, connectionName: string, resourceUrls: string[], appCredentials?: AppCredentials): Promise<{ - [propertyName: string]: TokenResponse; - }>; -} diff --git a/libraries/botbuilder-core/src/extendedUserTokenProvider.ts b/libraries/botbuilder-core/src/extendedUserTokenProvider.ts new file mode 100644 index 0000000000..2f81aeaf2c --- /dev/null +++ b/libraries/botbuilder-core/src/extendedUserTokenProvider.ts @@ -0,0 +1,95 @@ +/** + * @module botbuilder + */ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + +import { CoreAppCredentials } from './coreAppCredentials'; +import { IUserTokenProvider } from './userTokenProvider'; +import { TurnContext } from './turnContext'; +import { SignInUrlResponse ,TokenResponse, TokenExchangeRequest } from 'botframework-schema'; + +/** + * Interface for User Token OAuth Single Sign On and Token Exchange APIs for BotAdapters + */ +export interface ExtendedUserTokenProvider extends IUserTokenProvider { + /** + * Retrieves the OAuth token for a user that is in a sign-in flow. + * @param context Context for the current turn of conversation with the user. + * @param connectionName Name of the auth connection to use. + * @param magicCode (Optional) Optional user entered code to validate. + */ + getUserToken(context: TurnContext, connectionName: string, magicCode?: string, appCredentials?: CoreAppCredentials): Promise; + + /** + * Signs the user out with the token server. + * @param context Context for the current turn of conversation with the user. + * @param connectionName Name of the auth connection to use. + * @param userId User id of user to sign out. + * @param oAuthAppCredentials AppCredentials for OAuth. + */ + signOutUser(context: TurnContext, connectionName: string, userId?: string, appCredentials?: CoreAppCredentials): Promise; + + /** + * Gets a signin link from the token server that can be sent as part of a SigninCard. + * @param context Context for the current turn of conversation with the user. + * @param connectionName Name of the auth connection to use. + * @param oAuthAppCredentials AppCredentials for OAuth. + */ + getSignInLink(context: TurnContext, connectionName: string, appCredentials?: CoreAppCredentials): Promise; + + /** + * Signs the user out with the token server. + * @param context Context for the current turn of conversation with the user. + * @param connectionName Name of the auth connection to use. + * @param oAuthAppCredentials AppCredentials for OAuth. + */ + getAadTokens(context: TurnContext, connectionName: string, resourceUrls: string[], appCredentials?: CoreAppCredentials): Promise<{ + [propertyName: string]: TokenResponse; + }>; + + /** + * Get the raw signin resource to be sent to the user for signin for a connection name. + * @param context Context for the current turn of conversation with the user. + * @param connectionName Name of the auth connection to use. + */ + getSignInResource(context: TurnContext, connectionName: string): Promise; + + /** + * Get the raw signin resource to be sent to the user for signin for a connection name. + * @param context Context for the current turn of conversation with the user. + * @param connectionName Name of the auth connection to use. + * @param userId The user id that will be associated with the token. + * @param finalRedirect The final URL that the OAuth flow will redirect to. + */ + getSignInResource(context: TurnContext, connectionName: string, userId: string, finalRedirect?: string): Promise; + + /** + * Get the raw signin resource to be sent to the user for signin for a connection name. + * @param context Context for the current turn of conversation with the user. + * @param connectionName Name of the auth connection to use. + * @param userId The user id that will be associated with the token. + * @param finalRedirect The final URL that the OAuth flow will redirect to. + */ + getSignInResource(context: TurnContext, connectionName: string, userId: string, finalRedirect?: string, appCredentials?: CoreAppCredentials): Promise; + + /** + * Performs a token exchange operation such as for single sign-on. + * @param context Context for the current turn of conversation with the user. + * @param connectionName Name of the auth connection to use. + * @param userId The user id that will be associated with the token. + * @param tokenExchangeRequest The exchange request details, either a token to exchange or a uri to exchange. + */ + exchangeToken(context: TurnContext, connectionName: string, userId: string, tokenExchangeRequest: TokenExchangeRequest): Promise; + + /** + * Performs a token exchange operation such as for single sign-on. + * @param context Context for the current turn of conversation with the user. + * @param connectionName Name of the auth connection to use. + * @param userId The user id that will be associated with the token. + * @param tokenExchangeRequest The exchange request details, either a token to exchange or a uri to exchange. + */ + exchangeToken(context: TurnContext, connectionName: string, userId: string, tokenExchangeRequest: TokenExchangeRequest, appCredentials: CoreAppCredentials): Promise; +} \ No newline at end of file diff --git a/libraries/botbuilder-core/src/index.ts b/libraries/botbuilder-core/src/index.ts index 1056d8379e..8e592abad2 100644 --- a/libraries/botbuilder-core/src/index.ts +++ b/libraries/botbuilder-core/src/index.ts @@ -7,11 +7,12 @@ */ export * from 'botframework-schema'; +export * from './activityFactory'; +export * from './coreAppCredentials'; export * from './activityHandler'; export * from './activityHandlerBase'; export * from './autoSaveStateMiddleware'; export * from './botAdapter'; -export * from './botAdapterSet'; export * from './botState'; export * from './botStatePropertyAccessor'; export * from './botStateSet'; @@ -20,6 +21,7 @@ export * from './browserStorage'; export * from './cardFactory'; export * from './conversationState'; export * from './invokeResponse'; +export * from './extendedUserTokenProvider'; export * from './memoryStorage'; export * from './memoryTranscriptStore'; export * from './messageFactory'; @@ -28,8 +30,15 @@ export * from './privateConversationState'; export * from './propertyManager'; export * from './recognizerResult'; export * from './showTypingMiddleware'; -export { BotFrameworkSkill, BotFrameworkClient, SkillConversationIdFactoryBase } from './skills'; +export * from './signInConstants'; +export { + BotFrameworkSkill, + BotFrameworkClient, + SkillConversationIdFactoryBase, + SkillConversationReference, + SkillConversationIdFactoryOptions } from './skills'; export * from './skypeMentionNormalizeMiddleware'; +export * from './statusCodes'; export * from './storage'; export * from './telemetryLoggerMiddleware'; export * from './testAdapter'; @@ -38,5 +47,3 @@ export * from './turnContext'; export * from './userState'; export * from './userTokenProvider'; export * from './userTokenSettings'; -export * from './appCredentials'; -export * from './credentialTokenProvider'; diff --git a/libraries/botbuilder-core/src/invokeResponse.ts b/libraries/botbuilder-core/src/invokeResponse.ts index 02887f6481..d2d03372fb 100644 --- a/libraries/botbuilder-core/src/invokeResponse.ts +++ b/libraries/botbuilder-core/src/invokeResponse.ts @@ -11,7 +11,7 @@ * * This interface supports the framework and is not intended to be called directly for your code. */ -export interface InvokeResponse { +export interface InvokeResponse { /** * The HTTP status code of the response. */ @@ -20,5 +20,5 @@ export interface InvokeResponse { /** * Optional. The body of the response. */ - body?: any; + body?: T; } diff --git a/libraries/botbuilder-core/src/signInConstants.ts b/libraries/botbuilder-core/src/signInConstants.ts new file mode 100644 index 0000000000..f5b784bcaf --- /dev/null +++ b/libraries/botbuilder-core/src/signInConstants.ts @@ -0,0 +1,11 @@ +/** + * @module botbuilder + */ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + + export const verifyStateOperationName: string = 'signin/verifyState'; + export const tokenExchangeOperationName: string = 'signin/tokenExchange'; + export const tokenResponseEventName: string = 'tokens/response'; diff --git a/libraries/botbuilder-core/src/skills/botFrameworkClient.ts b/libraries/botbuilder-core/src/skills/botFrameworkClient.ts index 40507a7880..8d67c85308 100644 --- a/libraries/botbuilder-core/src/skills/botFrameworkClient.ts +++ b/libraries/botbuilder-core/src/skills/botFrameworkClient.ts @@ -9,7 +9,7 @@ import { Activity } from 'botframework-schema'; import { InvokeResponse } from '../invokeResponse'; -export abstract class BotFrameworkClient { +export interface BotFrameworkClient { /** * Forwards an activity to a another bot. * @remarks @@ -21,5 +21,5 @@ export abstract class BotFrameworkClient { * @param conversationId A conversation ID to use for the conversation with the skill. * @param activity Activity to forward. */ - public abstract postActivity(fromBotId: string, toBotId: string, toUrl: string, serviceUrl: string, conversationId: string, activity: Activity): Promise + postActivity: ((fromBotId: string, toBotId: string, toUrl: string, serviceUrl: string, conversationId: string, activity: Activity) => Promise>) | ((fromBotId: string, toBotId: string, toUrl: string, serviceUrl: string, conversationId: string, activity: Activity) => Promise); } diff --git a/libraries/botbuilder-core/src/skills/index.ts b/libraries/botbuilder-core/src/skills/index.ts index 4dbd753ea5..ef64ac868e 100644 --- a/libraries/botbuilder-core/src/skills/index.ts +++ b/libraries/botbuilder-core/src/skills/index.ts @@ -9,3 +9,5 @@ export { BotFrameworkClient } from './botFrameworkClient'; export { BotFrameworkSkill } from './botFrameworkSkill'; export { SkillConversationIdFactoryBase } from './skillConversationIdFactoryBase'; +export { SkillConversationReference } from './skillConversationReference'; +export { SkillConversationIdFactoryOptions } from './skillConversationIdFactoryOptions'; diff --git a/libraries/botbuilder-core/src/skills/skillConversationIdFactoryBase.ts b/libraries/botbuilder-core/src/skills/skillConversationIdFactoryBase.ts index fdf124c8f9..3f8d74833a 100644 --- a/libraries/botbuilder-core/src/skills/skillConversationIdFactoryBase.ts +++ b/libraries/botbuilder-core/src/skills/skillConversationIdFactoryBase.ts @@ -7,11 +7,13 @@ */ import { ConversationReference } from 'botframework-schema'; +import { SkillConversationIdFactoryOptions } from './skillConversationIdFactoryOptions'; +import { SkillConversationReference } from './skillConversationReference'; /** * Defines the methods of a factory that is used to create unique conversation IDs for skill conversations. */ -export abstract class SkillConversationIdFactoryBase { +export abstract class SkillConversationIdFactoryBase { /** * Creates a conversation ID for a skill conversation based on the caller's ConversationReference. * @remarks @@ -19,14 +21,40 @@ export abstract class SkillConversationIdFactoryBase { * @param conversationReference The skill's caller ConversationReference. * @returns A unique conversation ID used to communicate with the skill. */ - public abstract createSkillConversationId(conversationReference: ConversationReference): Promise; + public createSkillConversationIdWithOptions(options: SkillConversationIdFactoryOptions): Promise { + throw new Error('Not Implemented'); + } + + + /** + * Creates a conversation ID for a skill conversation based on the caller's ConversationReference. + * @deprecated Method is deprecated, please use createSkillConversationIdWithOptions() with SkillConversationIdFactoryOptions instead. + * @remarks + * It should be possible to use the returned string on a request URL and it should not contain special characters. + * @param conversationReference The skill's caller ConversationReference. + * @returns A unique conversation ID used to communicate with the skill. + */ + public createSkillConversationId(conversationReference: ConversationReference): Promise { + throw new Error('Not Implemented'); + } /** * Gets the ConversationReference created using createSkillConversationId() for a skillConversationId. + * @deprecated Method is deprecated, please use getSkillConversationReference() instead. * @param skillConversationId >A skill conversationId created using createSkillConversationId(). * @returns The caller's ConversationReference for a skillConversationId. null if not found. */ - public abstract getConversationReference(skillConversationId: string): Promise; + public getConversationReference(skillConversationId: string): Promise { + throw new Error('Not Implemented'); + } + + /** + * Gets the SkillConversationReference created using createSkillConversationId() for a skillConversationId. + * @param skillConversationId Gets the SkillConversationReference used during CreateSkillConversationIdAsync for a skillConversationId. + */ + public getSkillConversationReference(skillConversationId: string): Promise { + throw new Error('Not Implemented'); + } /** * Deletes a ConversationReference. diff --git a/libraries/botbuilder-core/src/skills/skillConversationIdFactoryOptions.ts b/libraries/botbuilder-core/src/skills/skillConversationIdFactoryOptions.ts new file mode 100644 index 0000000000..25ef21ecb8 --- /dev/null +++ b/libraries/botbuilder-core/src/skills/skillConversationIdFactoryOptions.ts @@ -0,0 +1,32 @@ +/** + * @module botbuilder-core + */ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + +import { Activity } from 'botframework-schema'; +import { BotFrameworkSkill } from './botFrameworkSkill'; + +export interface SkillConversationIdFactoryOptions { + /** + * The oauth audience scope, used during token retrieval (either https://api.botframework.com or bot app id if this is a skill calling another skill). + */ + fromBotOAuthScope: string; + + /** + * The id of the parent bot that is messaging the skill. + */ + fromBotId: string; + + /** + * The activity which will be sent to the skill. + */ + activity: Activity; + + /** + * The skill to create the conversation Id for. + */ + botFrameworkSkill: BotFrameworkSkill; +} diff --git a/libraries/botbuilder-core/src/skills/skillConversationReference.ts b/libraries/botbuilder-core/src/skills/skillConversationReference.ts new file mode 100644 index 0000000000..386d112346 --- /dev/null +++ b/libraries/botbuilder-core/src/skills/skillConversationReference.ts @@ -0,0 +1,14 @@ +/** + * @module botbuilder-core + */ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + +import { ConversationReference } from 'botframework-schema'; + +export interface SkillConversationReference { + conversationReference: ConversationReference; + oAuthScope: string; +} diff --git a/libraries/botbuilder-core/src/statusCodes.ts b/libraries/botbuilder-core/src/statusCodes.ts new file mode 100644 index 0000000000..dff31a3256 --- /dev/null +++ b/libraries/botbuilder-core/src/statusCodes.ts @@ -0,0 +1,20 @@ +/** + * @module botbuilder + */ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + +export enum StatusCodes { + OK = 200, + BAD_REQUEST = 400, + UNAUTHORIZED = 401, + NOT_FOUND = 404, + METHOD_NOT_ALLOWED = 405, + CONFLICT = 409, + UPGRADE_REQUIRED = 426, + INTERNAL_SERVER_ERROR = 500, + NOT_IMPLEMENTED = 501, + BAD_GATEWAY = 502 +} \ No newline at end of file diff --git a/libraries/botbuilder-core/src/testAdapter.ts b/libraries/botbuilder-core/src/testAdapter.ts index 010144b36e..55c5dfba94 100644 --- a/libraries/botbuilder-core/src/testAdapter.ts +++ b/libraries/botbuilder-core/src/testAdapter.ts @@ -7,10 +7,10 @@ */ // tslint:disable-next-line:no-require-imports import assert from 'assert'; -import { Activity, ActivityTypes, ConversationReference, ResourceResponse, TokenResponse } from 'botframework-schema'; +import { Activity, ActivityTypes, ConversationReference, ResourceResponse, TokenResponse, TokenExchangeRequest, SignInUrlResponse } from 'botframework-schema'; import { BotAdapter } from './botAdapter'; +import {ExtendedUserTokenProvider} from './extendedUserTokenProvider'; import { TurnContext } from './turnContext'; -import { IUserTokenProvider } from './userTokenProvider'; /** * Signature for a function that can be used to inspect individual activities returned by a bot @@ -42,7 +42,7 @@ export type TestActivityInspector = (activity: Partial, description: s * .then(() => done()); * ``` */ -export class TestAdapter extends BotAdapter implements IUserTokenProvider { +export class TestAdapter extends BotAdapter implements ExtendedUserTokenProvider { /** * @private * INTERNAL: used to drive the promise chain forward when running tests. @@ -391,6 +391,51 @@ export class TestAdapter extends BotAdapter implements IUserTokenProvider { return undefined; } + + private exchangeableTokens : {[key: string]: ExchangeableToken} = {}; + + public addExchangeableToken(connectionName: string, channelId: string, userId: string, exchangeableItem: string, token: string) { + const key: ExchangeableToken = new ExchangeableToken(); + key.ChannelId = channelId; + key.ConnectionName = connectionName; + key.UserId = userId; + key.exchangeableItem = exchangeableItem; + key.Token = token; + this.exchangeableTokens[key.toKey()] = key; + } + + public async getSignInResource(context: TurnContext, connectionName: string, userId?: string, finalRedirect?: string): Promise { + return { + signInLink: `https://botframeworktestadapter.com/oauthsignin/${connectionName}/${context.activity.channelId}/${userId}`, + tokenExchangeResource: { + id: String(Math.random()), + providerId: null, + uri: `api://${connectionName}/resource` + + } + } + } + + + public async exchangeToken(context: TurnContext, connectionName: string, userId: string, tokenExchangeRequest: TokenExchangeRequest): Promise { + const exchangeableValue: string = tokenExchangeRequest.token ? tokenExchangeRequest.token : tokenExchangeRequest.uri; + const key = new ExchangeableToken(); + key.ChannelId = context.activity.channelId; + key.ConnectionName = connectionName; + key.exchangeableItem = exchangeableValue; + key.UserId = userId; + + const tokenExchangeResponse = this.exchangeableTokens[key.toKey()]; + return tokenExchangeResponse ? + { + channelId: key.ChannelId, + connectionName: key.ConnectionName, + token: tokenExchangeResponse.Token, + expiration: null + } : + null; + } + /** * Indicates if the activity is a reply from the bot (role == 'bot') * @@ -427,6 +472,20 @@ class TokenMagicCode { public MagicCode: string; } +class ExchangeableToken extends UserToken { + public exchangeableItem: string; + + public EqualsKey(rhs: ExchangeableToken): boolean { + return rhs != null && + this.exchangeableItem === rhs.exchangeableItem && + super.EqualsKey(rhs); + } + + public toKey(): string { + return this.exchangeableItem; + } +} + /** * Support class for `TestAdapter` that allows for the simple construction of a sequence of tests. * diff --git a/libraries/botbuilder-core/src/turnContext.ts b/libraries/botbuilder-core/src/turnContext.ts index d18858a6ee..663b554776 100644 --- a/libraries/botbuilder-core/src/turnContext.ts +++ b/libraries/botbuilder-core/src/turnContext.ts @@ -344,9 +344,9 @@ export class TurnContext { } /** - * List of activities to send when `context.activity.deliveryMode == 'buffered'`. + * List of activities to send when `context.activity.deliveryMode == 'expectReplies'`. */ - public readonly bufferedReplies: Partial[] = []; + public readonly bufferedReplyActivities: Partial[] = []; /** * Asynchronously sends an activity to the sender of the incoming activity. @@ -464,11 +464,11 @@ export class TurnContext { }); return this.emit(this._onSendActivities, output, () => { - if (this.activity.deliveryMode === DeliveryModes.BufferedReplies) { + if (this.activity.deliveryMode === DeliveryModes.ExpectReplies) { // Append activities to buffer const responses: ResourceResponse[] = []; output.forEach((a) => { - this.bufferedReplies.push(a); + this.bufferedReplyActivities.push(a); responses.push({ id: undefined }); }); diff --git a/libraries/botbuilder-dialogs-adaptive-tests/resources/ActionTests/InputDialog_ActivityProcessed.test.dialog b/libraries/botbuilder-dialogs-adaptive-tests/resources/ActionTests/InputDialog_ActivityProcessed.test.dialog index 5f350699d6..8dc06e99a4 100644 --- a/libraries/botbuilder-dialogs-adaptive-tests/resources/ActionTests/InputDialog_ActivityProcessed.test.dialog +++ b/libraries/botbuilder-dialogs-adaptive-tests/resources/ActionTests/InputDialog_ActivityProcessed.test.dialog @@ -30,11 +30,11 @@ "$kind": "Microsoft.TextInput", "alwaysPrompt": true, "property": "$userName", - "prompt": "\\[set name]::What is your name?" + "prompt": "[set name]::What is your name?" }, { "$kind": "Microsoft.SendActivity", - "activity": "\\[set name]::I have ${$userName} as your name" + "activity": "[set name]::I have ${$userName} as your name" } ] }, @@ -46,11 +46,11 @@ "$kind": "Microsoft.TextInput", "allowInterruptions": "false", "property": "$userName", - "prompt": "\\[start]::What is your name?" + "prompt": "[start]::What is your name?" }, { "$kind": "Microsoft.SendActivity", - "activity": "\\[start]::I have ${$userName} as your name" + "activity": "[start]::I have ${$userName} as your name" }, { "$kind": "Microsoft.DateTimeInput", @@ -61,7 +61,7 @@ }, { "$kind": "Microsoft.SendActivity", - "activity": "\\[start]:: I have ${$fromDate} as date 1" + "activity": "[start]:: I have ${$fromDate} as date 1" }, { "$kind": "Microsoft.DateTimeInput", @@ -71,7 +71,7 @@ }, { "$kind": "Microsoft.SendActivity", - "activity": "\\[start]:: I have ${$toDate} as date 2" + "activity": "[start]:: I have ${$toDate} as date 2" } ] }, diff --git a/libraries/botbuilder-dialogs-adaptive-tests/src/testing/testActions/assertReplyActivity.ts b/libraries/botbuilder-dialogs-adaptive-tests/src/testing/testActions/assertReplyActivity.ts index ed02c37234..2d3bd7dea5 100644 --- a/libraries/botbuilder-dialogs-adaptive-tests/src/testing/testActions/assertReplyActivity.ts +++ b/libraries/botbuilder-dialogs-adaptive-tests/src/testing/testActions/assertReplyActivity.ts @@ -6,7 +6,7 @@ * Licensed under the MIT License. */ import { Activity, TurnContext } from 'botbuilder-core'; -import { ExpressionEngine } from 'adaptive-expressions'; +import { ExpressionParser } from 'adaptive-expressions'; import { TestAction } from '../testAction'; import { AdaptiveTestAdapter } from '../adaptiveTestAdapter'; @@ -32,7 +32,7 @@ export class AssertReplyActivity implements TestAction { public validateReply(activity: Activity): void { if (this.assertions) { - const engine = new ExpressionEngine(); + const engine = new ExpressionParser(); for (let i = 0; i < this.assertions.length; i++) { const assertion = this.assertions[i]; const { value, error } = engine.parse(assertion).tryEvaluate(activity); diff --git a/libraries/botbuilder-dialogs-adaptive/src/actions/httpRequest.ts b/libraries/botbuilder-dialogs-adaptive/src/actions/httpRequest.ts index 5182c3a799..f9f8658955 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/actions/httpRequest.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/actions/httpRequest.ts @@ -8,7 +8,7 @@ import fetch from 'node-fetch'; import { DialogTurnResult, DialogConfiguration, DialogContext, Dialog, Configurable } from 'botbuilder-dialogs'; import { Activity } from 'botbuilder-core'; -import { ExpressionEngine } from 'adaptive-expressions'; +import { ExpressionParser } from 'adaptive-expressions'; import { TextTemplate } from '../templates'; import { ValueExpression, StringExpression, BoolExpression, EnumExpression } from '../expressions'; @@ -256,7 +256,7 @@ export class HttpRequest extends Dialog implements Con let text: string = unit as string; if (text.startsWith('{') && text.endsWith('}')) { text = text.slice(1, text.length - 1); - const { value } = new ExpressionEngine().parse(text).tryEvaluate(dc.state); + const { value } = new ExpressionParser().parse(text).tryEvaluate(dc.state); return value; } else { diff --git a/libraries/botbuilder-dialogs-adaptive/src/actions/switchCondition.ts b/libraries/botbuilder-dialogs-adaptive/src/actions/switchCondition.ts index 4186f3366d..94d2b24782 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/actions/switchCondition.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/actions/switchCondition.ts @@ -6,7 +6,7 @@ * Licensed under the MIT License. */ import { DialogTurnResult, DialogDependencies, Dialog, DialogContext } from 'botbuilder-dialogs'; -import { Expression, ExpressionEngine } from 'adaptive-expressions'; +import { Expression, ExpressionParser } from 'adaptive-expressions'; import { ActionScope } from './actionScope'; import { Case } from './case'; import { BoolExpression } from '../expressions'; @@ -16,7 +16,7 @@ export class SwitchCondition extends Dialog implements public constructor(condition: string, defaultDialogs: Dialog[], cases: Case[]); public constructor(condition?: string, defaultDialogs?: Dialog[], cases?: Case[]) { super(); - if (condition) { this.condition = new ExpressionEngine().parse(condition); } + if (condition) { this.condition = new ExpressionParser().parse(condition); } if (defaultDialogs) { this.default = defaultDialogs; } if (cases) { this.cases = cases; } } diff --git a/libraries/botbuilder-dialogs-adaptive/src/adaptiveDialog.ts b/libraries/botbuilder-dialogs-adaptive/src/adaptiveDialog.ts index 0da3f72157..75c2da370a 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/adaptiveDialog.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/adaptiveDialog.ts @@ -162,7 +162,7 @@ export class AdaptiveDialog extends DialogContainer { if (this.needsTracker && dcState.getValue(AdaptiveDialog.conditionTracker) == undefined) { this.triggers.forEach((trigger) => { if (trigger.runOnce && trigger.condition) { - const references = Extensions.references(trigger.condition.toExpression()); + const references = trigger.condition.toExpression().references(); var paths = dcState.trackPaths(references); var triggerPath = `${ AdaptiveDialog.conditionTracker }.${ trigger.id }.`; dcState.setValue(triggerPath + 'paths', paths); diff --git a/libraries/botbuilder-dialogs-adaptive/src/conditions/onCondition.ts b/libraries/botbuilder-dialogs-adaptive/src/conditions/onCondition.ts index 9ce73fba7b..dde4469694 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/conditions/onCondition.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/conditions/onCondition.ts @@ -6,7 +6,7 @@ * Licensed under the MIT License. */ import { Dialog, DialogDependencies, DialogStateManager } from 'botbuilder-dialogs'; -import { Expression, ExpressionParserInterface, Constant, ExpressionEngine, ExpressionEvaluator, ReturnType, ExpressionFunctions } from 'adaptive-expressions'; +import { Expression, ExpressionParserInterface, Constant, ExpressionParser, ExpressionEvaluator, ReturnType, ExpressionFunctions } from 'adaptive-expressions'; import { ActionScope } from '../actions/actionScope'; import { BoolExpression } from '../expressions'; import { AdaptiveDialog } from '../adaptiveDialog'; @@ -149,7 +149,7 @@ export class OnCondition implements DialogDependencies { public addExternalCondition(condition: string): void { if (condition) { try { - const parser = new ExpressionEngine(); + const parser = new ExpressionParser(); this._extraConstraints.push(parser.parse(condition)); this._fullConstraint = undefined; } catch (err) { diff --git a/libraries/botbuilder-dialogs-adaptive/src/converters/expressionConverter.ts b/libraries/botbuilder-dialogs-adaptive/src/converters/expressionConverter.ts index 7baf1eed53..afb5042484 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/converters/expressionConverter.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/converters/expressionConverter.ts @@ -6,11 +6,11 @@ * Licensed under the MIT License. */ -import { Expression, ExpressionEngine } from 'adaptive-expressions'; +import { Expression, ExpressionParser } from 'adaptive-expressions'; import { Converter } from 'botbuilder-dialogs-declarative'; export class ExpressionConverter implements Converter { public convert(value: string): Expression { - return new ExpressionEngine().parse(value); + return new ExpressionParser().parse(value); } } \ No newline at end of file diff --git a/libraries/botbuilder-dialogs-adaptive/src/expressions/expressionProperty.ts b/libraries/botbuilder-dialogs-adaptive/src/expressions/expressionProperty.ts index 1058810e62..afdcab8fac 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/expressions/expressionProperty.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/expressions/expressionProperty.ts @@ -5,9 +5,9 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { Expression, ExpressionEngine } from 'adaptive-expressions'; +import { Expression, ExpressionParser } from 'adaptive-expressions'; -let engine: ExpressionEngine = undefined; +let engine: ExpressionParser = undefined; /** * Base class which defines a Expression or value for a property. @@ -90,15 +90,15 @@ export class ExpressionProperty { } } - public static get engine(): ExpressionEngine { + public static get engine(): ExpressionParser { if (engine == undefined) { - engine = new ExpressionEngine(); + engine = new ExpressionParser(); } return engine; } - public static set engine(value: ExpressionEngine) { + public static set engine(value: ExpressionParser) { engine = value; } } diff --git a/libraries/botbuilder-dialogs-adaptive/src/expressions/stringExpression.ts b/libraries/botbuilder-dialogs-adaptive/src/expressions/stringExpression.ts index bf61097073..eea6fd1353 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/expressions/stringExpression.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/expressions/stringExpression.ts @@ -7,7 +7,7 @@ */ import { ExpressionProperty } from './expressionProperty'; import { Expression } from 'adaptive-expressions'; -import { LGFile } from 'botbuilder-lg'; +import { Templates } from 'botbuilder-lg'; /** * Represents a property which is either a string value or a string expression. @@ -23,7 +23,7 @@ import { LGFile } from 'botbuilder-lg'; * prop = "\=user" => "=user". */ export class StringExpression extends ExpressionProperty { - private readonly engine = new LGFile(); + private readonly engine = new Templates(); public constructor(value?: string | Expression) { super(value); @@ -33,7 +33,7 @@ export class StringExpression extends ExpressionProperty { if (typeof this.value == 'string') { let v: string, e: Error; try { - v = this.engine.evaluate(this.value, data); + v = this.engine.evaluateText(this.value, data); } catch (err) { e = err; } diff --git a/libraries/botbuilder-dialogs-adaptive/src/expressions/valueExpression.ts b/libraries/botbuilder-dialogs-adaptive/src/expressions/valueExpression.ts index e216a4eab9..3badfb10e6 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/expressions/valueExpression.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/expressions/valueExpression.ts @@ -7,7 +7,7 @@ */ import { ExpressionProperty } from './expressionProperty'; import { Expression } from 'adaptive-expressions'; -import { LGFile } from 'botbuilder-lg'; +import { Templates } from 'botbuilder-lg'; /** * Represents a property which is an object of any kind or a string expression. @@ -23,7 +23,7 @@ import { LGFile } from 'botbuilder-lg'; * prop = "\=user" => "=user". */ export class ValueExpression extends ExpressionProperty { - private readonly engine = new LGFile(); + private readonly engine = new Templates(); public constructor(value?: any | string | Expression) { super(value); @@ -33,7 +33,7 @@ export class ValueExpression extends ExpressionProperty { if (typeof this.value == 'string') { let v: string, e: Error; try { - v = this.engine.evaluate(this.value, data); + v = this.engine.evaluateText(this.value, data); } catch (err) { e = err; } diff --git a/libraries/botbuilder-dialogs-adaptive/src/generators/templateEngineLanguageGenerator.ts b/libraries/botbuilder-dialogs-adaptive/src/generators/templateEngineLanguageGenerator.ts index 3b73c97ff8..915d7691c8 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/generators/templateEngineLanguageGenerator.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/generators/templateEngineLanguageGenerator.ts @@ -8,7 +8,7 @@ import { LanguageGenerator } from '../languageGenerator'; import { TurnContext } from 'botbuilder-core'; -import{ LGFile, LGParser } from 'botbuilder-lg'; +import { Templates } from 'botbuilder-lg'; import { IResource } from 'botbuilder-dialogs-declarative'; import { LanguageResourceLoader } from '../languageResourceLoader'; import { LanguageGeneratorManager } from './languageGeneratorManager'; @@ -22,24 +22,22 @@ export class TemplateEngineLanguageGenerator implements LanguageGenerator{ private readonly DEFAULTLABEL: string = 'Unknown'; - private readonly multiLangEngines: Map = new Map(); - - private lgFile: LGFile; + private lg: Templates; public id: string = ''; - public constructor(arg1?: LGFile | string, arg2?: string | Map, arg3?: Map) { + public constructor(arg1?: Templates | string, arg2?: string | Map, arg3?: Map) { if (arguments.length === 0) { - this.lgFile = new LGFile(); - } else if(arguments.length === 1 && arg1 instanceof LGFile) { - this.lgFile = arg1; + this.lg = new Templates(); + } else if(arguments.length === 1 && arg1 instanceof Templates) { + this.lg = arg1; } else if (arguments.length === 2 && typeof arg1 === 'string' && arg2 instanceof Map) { const filePath = normalize(arg1 as string); const resourceMapping = arg2 as Map; this.id = basename(filePath); const {prefix: _, language: locale} = LanguageResourceLoader.parseLGFileName(this.id); const importResolver = LanguageGeneratorManager.resourceExplorerResolver(locale, resourceMapping); - this.lgFile = LGParser.parseFile(filePath, importResolver); + this.lg = Templates.parseFile(filePath, importResolver); } else if (arguments.length === 3 && typeof arg1 === 'string' && typeof arg2 === 'string' && arg3 instanceof Map) { const id = arg2 as string; this.id = id !== undefined? id : this.DEFAULTLABEL; @@ -47,13 +45,13 @@ export class TemplateEngineLanguageGenerator implements LanguageGenerator{ const resourceMapping = arg3 as Map; const importResolver = LanguageGeneratorManager.resourceExplorerResolver(locale, resourceMapping); const lgText = arg1? arg1 : ''; - this.lgFile = LGParser.parseText(lgText, id, importResolver); + this.lg = Templates.parseText(lgText, id, importResolver); } } public generate(turnContext: TurnContext, template: string, data: object): Promise { try { - return Promise.resolve(this.lgFile.evaluate(template, data).toString()); + return Promise.resolve(this.lg.evaluateText(template, data).toString()); } catch(e) { if (this.id !== undefined && this.id === '') { throw Error(`${ this.id }:${ e }`); diff --git a/libraries/botbuilder-dialogs-adaptive/src/input/inputDialog.ts b/libraries/botbuilder-dialogs-adaptive/src/input/inputDialog.ts index 8a216e91a1..d40187224e 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/input/inputDialog.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/input/inputDialog.ts @@ -7,7 +7,7 @@ */ import { Dialog, DialogContext, DialogTurnResult, DialogEvent, DialogReason, Choice, ListStyle, ChoiceFactoryOptions, ChoiceFactory, DialogEvents, TurnPath } from 'botbuilder-dialogs'; import { ActivityTypes, Activity, InputHints, MessageFactory } from 'botbuilder-core'; -import { ExpressionEngine } from 'adaptive-expressions'; +import { ExpressionParser } from 'adaptive-expressions'; import { TemplateInterface } from '../template'; import { ValueExpression, StringExpression, BoolExpression, NumberExpression } from '../expressions'; import { AdaptiveEvents } from '../adaptiveEvents'; @@ -299,7 +299,7 @@ export abstract class InputDialog extends Dialog { if (state == InputState.valid) { for (let i = 0; i < this.validations.length; i++) { const validation = this.validations[i]; - const exp = new ExpressionEngine().parse(validation); + const exp = new ExpressionParser().parse(validation); const { value } = exp.tryEvaluate(dc.state); if (!value) { return InputState.invalid; diff --git a/libraries/botbuilder-dialogs-adaptive/src/selectors/conditionalSelector.ts b/libraries/botbuilder-dialogs-adaptive/src/selectors/conditionalSelector.ts index b608d6aa3e..8f0eef1d7d 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/selectors/conditionalSelector.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/selectors/conditionalSelector.ts @@ -5,7 +5,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { ExpressionEngine, ExpressionParserInterface } from 'adaptive-expressions'; +import { ExpressionParser, ExpressionParserInterface } from 'adaptive-expressions'; import { OnCondition } from '../conditions/onCondition'; import { TriggerSelector } from '../triggerSelector'; import { BoolExpression } from '../expressions'; @@ -36,7 +36,7 @@ export class ConditionalSelector implements TriggerSelector { /** * Gets or sets the expression parser to use. */ - public parser: ExpressionParserInterface = new ExpressionEngine() + public parser: ExpressionParserInterface = new ExpressionParser() public initialize(conditionals: OnCondition[], evaluate: boolean): void { this._conditionals = conditionals; diff --git a/libraries/botbuilder-dialogs-adaptive/src/selectors/firstSelector.ts b/libraries/botbuilder-dialogs-adaptive/src/selectors/firstSelector.ts index 8d79d6ffc5..3608a8fff9 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/selectors/firstSelector.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/selectors/firstSelector.ts @@ -5,7 +5,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { ExpressionEngine, ExpressionParserInterface } from 'adaptive-expressions'; +import { ExpressionParser, ExpressionParserInterface } from 'adaptive-expressions'; import { OnCondition } from '../conditions/onCondition'; import { TriggerSelector } from '../triggerSelector'; import { ActionContext } from '../actionContext'; @@ -20,7 +20,7 @@ export class FirstSelector implements TriggerSelector { /** * Gets or sets the expression parser to use. */ - public parser: ExpressionParserInterface = new ExpressionEngine() + public parser: ExpressionParserInterface = new ExpressionParser() public initialize(conditionals: OnCondition[], evaluate: boolean) { this._conditionals = conditionals; diff --git a/libraries/botbuilder-dialogs-adaptive/src/selectors/randomSelector.ts b/libraries/botbuilder-dialogs-adaptive/src/selectors/randomSelector.ts index cf36112b7d..62b5288db0 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/selectors/randomSelector.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/selectors/randomSelector.ts @@ -5,7 +5,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { ExpressionParserInterface, ExpressionEngine } from 'adaptive-expressions'; +import { ExpressionParserInterface, ExpressionParser } from 'adaptive-expressions'; import { TriggerSelector } from '../triggerSelector'; import { OnCondition } from '../conditions'; import { ActionContext } from '../actionContext'; @@ -20,7 +20,7 @@ export class RandomSelector implements TriggerSelector { /** * Gets or sets the expression parser to use. */ - public parser: ExpressionParserInterface = new ExpressionEngine() + public parser: ExpressionParserInterface = new ExpressionParser() public initialize(conditionals: OnCondition[], evaluate: boolean): void { this._conditionals = conditionals; diff --git a/libraries/botbuilder-dialogs-adaptive/src/selectors/trueSelector.ts b/libraries/botbuilder-dialogs-adaptive/src/selectors/trueSelector.ts index 44434affa3..d86bf8e1e7 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/selectors/trueSelector.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/selectors/trueSelector.ts @@ -5,7 +5,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { ExpressionParserInterface, ExpressionEngine } from 'adaptive-expressions'; +import { ExpressionParserInterface, ExpressionParser } from 'adaptive-expressions'; import { TriggerSelector } from '../triggerSelector'; import { OnCondition } from '../conditions'; import { ActionContext } from '../actionContext'; @@ -20,7 +20,7 @@ export class TrueSelector implements TriggerSelector { /** * Gets or sets the expression parser to use. */ - public parser: ExpressionParserInterface = new ExpressionEngine() + public parser: ExpressionParserInterface = new ExpressionParser() public initialize(conditionals: OnCondition[], evaluate: boolean): void { this._conditionals = conditionals; diff --git a/libraries/botbuilder-dialogs-adaptive/src/templates/activityTemplate.ts b/libraries/botbuilder-dialogs-adaptive/src/templates/activityTemplate.ts index 71546f4bad..ac747c2d3d 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/templates/activityTemplate.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/templates/activityTemplate.ts @@ -1,7 +1,6 @@ +import { TurnContext, Activity, ActivityFactory, MessageFactory } from 'botbuilder-core'; import { TemplateInterface } from '../template'; -import { TurnContext, Activity } from 'botbuilder-core'; import { LanguageGenerator } from '../languageGenerator'; -import { ActivityFactory } from 'botbuilder-lg'; export class ActivityTemplate implements TemplateInterface> { public template: string; @@ -15,12 +14,10 @@ export class ActivityTemplate implements TemplateInterface> { const languageGenerator: LanguageGenerator = context.turnState.get('LanguageGenerator'); if (languageGenerator) { const lgStringResult = await languageGenerator.generate(context, this.template, data); - const result = ActivityFactory.createActivity(lgStringResult); + const result = ActivityFactory.fromObject(lgStringResult); return Promise.resolve(result); } else { - let message = ActivityFactory.createActivity(''); - message.text = this.template; - message.speak = this.template; + const message = MessageFactory.text(this.template, this.template); return Promise.resolve(message); } } diff --git a/libraries/botbuilder-dialogs-adaptive/tests/LGGenerator.test.js b/libraries/botbuilder-dialogs-adaptive/tests/LGGenerator.test.js index 60fdeabb00..c9149d565b 100644 --- a/libraries/botbuilder-dialogs-adaptive/tests/LGGenerator.test.js +++ b/libraries/botbuilder-dialogs-adaptive/tests/LGGenerator.test.js @@ -125,10 +125,10 @@ describe('LGLanguageGenerator', function() { const result5 = await lg.generate(await getTurnContext('foo'), '${test()}', undefined); assert.equal(result5, 'default'); - const result6 = await lg.generate(await getTurnContext('en-us'), '${test2()}', undefined); - assert.equal(result6, 'default2'); + const result6 = await lg.generate(await getTurnContext('en-US'), '${test2()}', {country: 'US'}); + assert.equal(result6, 'english-US'); - const result7 = await lg.generate(await getTurnContext('en-gb'), '${test2()}', undefined); + const result7 = await lg.generate(await getTurnContext('en-GB'), '${test2()}', undefined); assert.equal(result7, 'default2'); const result8 = await lg.generate(await getTurnContext('en'), '${test2()}', undefined); @@ -174,8 +174,8 @@ describe('LGLanguageGenerator', function() { const result10 = await lg.generate(await getTurnContext('foo', lg), '${test2()}', undefined); assert.equal(result10, 'default2'); - const result11 = await lg.generate(await getTurnContext('en-us', lg), '${test2()}', undefined); - assert.equal(result11, 'default2'); + const result11 = await lg.generate(await getTurnContext('en-us', lg), '${test2()}', {country: 'US'}); + assert.equal(result11, 'english-US'); }); }); \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/src/componentDialog.ts b/libraries/botbuilder-dialogs/src/componentDialog.ts index b58613869b..e146348bbf 100644 --- a/libraries/botbuilder-dialogs/src/componentDialog.ts +++ b/libraries/botbuilder-dialogs/src/componentDialog.ts @@ -93,7 +93,6 @@ export class ComponentDialog extends DialogContainer { // Return result to calling dialog return await this.endComponent(outerDC, turnResult.result); } - // Just signal end of turn return Dialog.EndOfTurn; } diff --git a/libraries/botbuilder-dialogs/src/dialog.ts b/libraries/botbuilder-dialogs/src/dialog.ts index 6366fd45a5..8fef7124e1 100644 --- a/libraries/botbuilder-dialogs/src/dialog.ts +++ b/libraries/botbuilder-dialogs/src/dialog.ts @@ -167,6 +167,35 @@ export interface DialogConfiguration { telemetryClient?: BotTelemetryClient; } +export interface DialogEvent { + /** + * Flag indicating whether the event will be bubbled to the parent `DialogContext`. + */ + bubble: boolean; + + /** + * Name of the event being raised. + */ + name: string; + + /** + * Optional. Value associated with the event. + */ + value?: any; +} + +export interface DialogConfiguration { + /** + * Static id of the dialog. + */ + id?: string; + + /** + * Telemetry client the dialog should use. + */ + telemetryClient?: BotTelemetryClient; +} + /** * Represents the result of a dialog context's attempt to begin, continue, * or otherwise manipulate one or more dialogs. @@ -219,24 +248,6 @@ export interface DialogTurnResult { parentEnded?: boolean; } -export interface DialogEvent { - /** - * If `true` the event will be bubbled to the parent `DialogContext` if not handled by the - * current dialog. - */ - bubble: boolean; - - /** - * Name of the event being raised. - */ - name: string; - - /** - * (Optional) value associated with the event. - */ - value?: any; -} - /** * Defines the core behavior for all dialogs. */ @@ -263,7 +274,7 @@ export abstract class Dialog extends Configurable { * * @param dialogId Optional. unique ID of the dialog. */ - constructor(dialogId?: string) { + public constructor(dialogId?: string) { super(); this.id = dialogId; } @@ -274,16 +285,16 @@ export abstract class Dialog extends Configurable { * @remarks * This will be automatically generated if not specified. */ - public get id(): string { - if (this._id === undefined) { - this._id = this.onComputeId(); - } - return this._id; - } + public get id(): string { + if (this._id === undefined) { + this._id = this.onComputeId(); + } + return this._id; + } - public set id(value: string) { - this._id = value; - } + public set id(value: string) { + this._id = value; + } /** * Gets the telemetry client for this dialog. @@ -444,7 +455,7 @@ export abstract class Dialog extends Configurable { /** * Called before an event is bubbled to its parent. - * + * * @remarks * This is a good place to perform interception of an event as returning `true` will prevent * any further bubbling of the event to the dialogs parents and will also prevent any child @@ -459,7 +470,7 @@ export abstract class Dialog extends Configurable { /** * Called after an event was bubbled to all parents and wasn't handled. - * + * * @remarks * This is a good place to perform default processing logic for an event. Returning `true` will * prevent any processing of the event by child dialogs. diff --git a/libraries/botbuilder-dialogs/src/dialogContext.ts b/libraries/botbuilder-dialogs/src/dialogContext.ts index fa57ec79d1..162e68a432 100644 --- a/libraries/botbuilder-dialogs/src/dialogContext.ts +++ b/libraries/botbuilder-dialogs/src/dialogContext.ts @@ -143,9 +143,6 @@ export class DialogContext { * * @param dialogId ID of the dialog to start. * @param options Optional. Arguments to pass into the dialog when it starts. - * - * @param dialogId ID of the dialog to start. - * @param options Optional. Arguments to pass into the dialog when it starts. * * @remarks * If there's already an active dialog on the stack, that dialog will be paused until @@ -161,7 +158,7 @@ export class DialogContext { * ```JavaScript * const result = await dc.beginDialog('greeting', { name: user.name }); * ``` - * + * * **See also** * - [endDialog](xref:botbuilder-dialogs.DialogContext.endDialog) * - [prompt](xref:botbuilder-dialogs.DialogContext.prompt) @@ -186,15 +183,15 @@ export class DialogContext { /** * Cancels all dialogs on the dialog stack, and clears stack. - * + * * @param cancelParents Optional. If `true` all parent dialogs will be cancelled as well. - * @param eventName Optional. Name of a custom event to raise as dialogs are cancelled. This defaults to [cancelDialog](xref:botbuilder-dialogs.DialogEvents.cancelDialog). + * @param eventName Optional. Name of a custom event to raise as dialogs are cancelled. This defaults to [cancelDialog](xref:botbuilder-dialogs.DialogEvents.cancelDialog). * @param eventValue Optional. Value to pass along with custom cancellation event. * * @remarks * This calls each dialog's [Dialog.endDialog](xref:botbuilder-dialogs.Dialog.endDialog) method before * removing the dialog from the stack. - * + * * If there were any dialogs on the stack initially, the [status](xref:botbuilder-dialogs.DialogTurnResult.status) * of the return value is [cancelled](xref:botbuilder-dialogs.DialogTurnStatus.cancelled); otherwise, it's * [empty](xref:botbuilder-dialogs.DialogTurnStatus.empty). @@ -217,7 +214,7 @@ export class DialogContext { while (dc != undefined) { if (dc.stack.length > 0) { // Check to see if the dialog wants to handle the event - // - We skip notifying the first dialog which actually called cancelAllDialogs() + // - We skip notifying the first dialog which actually called cancelAllDialogs() if (notify) { const handled = await dc.emitEvent(eventName, eventValue, false, false); if (handled) { @@ -242,13 +239,13 @@ export class DialogContext { /** * Searches for a dialog with a given ID. - * + * * @param dialogId ID of the dialog to search for. - * + * * @remarks * If the dialog to start is not found in the [DialogSet](xref:botbuilder-dialogs.DialogSet) associated * with this dialog context, it attempts to find the dialog in its parent dialog context. - * + * * **See also** * - [dialogs](xref:botbuilder-dialogs.DialogContext.dialogs) * - [parent](xref:botbuilder-dialogs.DialogContext.parent) @@ -263,14 +260,14 @@ export class DialogContext { /** * Helper function to simplify formatting the options for calling a prompt dialog. - * + * * @param dialogId ID of the prompt dialog to start. * @param promptOrOptions The text of the initial prompt to send the user, * the activity to send as the initial prompt, or * the object with which to format the prompt dialog. * @param choices Optional. Array of choices for the user to choose from, * for use with a [ChoicePrompt](xref:botbuilder-dialogs.ChoicePrompt). - * + * * @remarks * This helper method formats the object to use as the `options` parameter, and then calls * [beginDialog](xref:botbuilder-dialogs.DialogContext.beginDialog) to start the specified prompt dialog. @@ -316,7 +313,7 @@ export class DialogContext { * the status of the dialog stack after this method completes. * * Typically, you would call this from within your bot's turn handler. - * + * * For example: * ```JavaScript * const result = await dc.continueDialog(); @@ -369,16 +366,16 @@ export class DialogContext { * * The [status](xref:botbuilder-dialogs.DialogTurnResult.status) of returned object describes * the status of the dialog stack after this method completes. - * + * * Typically, you would call this from within the logic for a specific dialog to signal back to * the dialog context that the dialog has completed, the dialog should be removed from the stack, * and the parent dialog should resume. - * + * * For example: * ```JavaScript * return await dc.endDialog(returnValue); * ``` - * + * * **See also** * - [beginDialog](xref:botbuilder-dialogs.DialogContext.beginDialog) * - [replaceDialog](xref:botbuilder-dialogs.DialogContext.replaceDialog) @@ -410,13 +407,13 @@ export class DialogContext { * * @param dialogId ID of the dialog to start. * @param options Optional. Arguments to pass into the new dialog when it starts. - * + * * @remarks * This is particularly useful for creating a loop or redirecting to another dialog. * * The [status](xref:botbuilder-dialogs.DialogTurnResult.status) of returned object describes * the status of the dialog stack after this method completes. - * + * * This method is similar to ending the current dialog and immediately beginning the new one. * However, the parent dialog is neither resumed nor otherwise notified. * diff --git a/libraries/botbuilder-dialogs/src/dialogHelper.ts b/libraries/botbuilder-dialogs/src/dialogHelper.ts new file mode 100644 index 0000000000..3d4c440140 --- /dev/null +++ b/libraries/botbuilder-dialogs/src/dialogHelper.ts @@ -0,0 +1,95 @@ +import { Activity, ActivityTypes, TurnContext, StatePropertyAccessor } from 'botbuilder-core'; +import { DialogContext, DialogState } from './dialogContext'; +import { Dialog, DialogTurnStatus } from './dialog'; +import { DialogEvents } from './dialogEvents'; +import { DialogSet } from './dialogSet'; +import { isSkillClaim } from './prompts/skillsHelpers'; + +export async function runDialog(dialog: Dialog, context: TurnContext, accessor: StatePropertyAccessor): Promise { + if (!dialog) { + throw new Error('runDialog(): missing dialog'); + } + + if (!context) { + throw new Error('runDialog(): missing context'); + } + + if (!context.activity) { + throw new Error('runDialog(): missing context.activity'); + } + + if (!accessor) { + throw new Error('runDialog(): missing accessor'); + } + + const dialogSet = new DialogSet(accessor); + dialogSet.telemetryClient = dialog.telemetryClient; + dialogSet.add(dialog); + + const dialogContext = await dialogSet.createContext(context); + const telemetryEventName = `runDialog(${ dialog.constructor.name })`; + + const identity = context.turnState.get(context.adapter.BotIdentityKey); + if (identity && isSkillClaim(identity.claims)) { + // The bot is running as a skill. + if (context.activity.type === ActivityTypes.EndOfConversation && dialogContext.stack.length > 0 && isEocComingFromParent(context)) { + // Handle remote cancellation request if we have something in the stack. + const activeDialogContext = getActiveDialogContext(dialogContext); + + const remoteCancelText = 'Skill was canceled through an EndOfConversation activity from the parent.'; + await context.sendTraceActivity(telemetryEventName, undefined, undefined, `${ remoteCancelText }`); + + // Send cancellation message to the top dialog in the stack to ensure all the parents are canceled in the right order. + await activeDialogContext.cancelAllDialogs(true); + } else { + // Process a reprompt event sent from the parent. + if (context.activity.type === ActivityTypes.Event && context.activity.name === DialogEvents.repromptDialog && dialogContext.stack.length > 0) { + await dialogContext.repromptDialog(); + return; + } + + // Run the Dialog with the new message Activity and capture the results so we can send end of conversation if needed. + let result = await dialogContext.continueDialog(); + if (result.status === DialogTurnStatus.empty) { + const startMessageText = `Starting ${ dialog.id }.`; + await context.sendTraceActivity(telemetryEventName, undefined, undefined, `${ startMessageText }`); + result = await dialogContext.beginDialog(dialog.id, null); + } + + // Send end of conversation if it is completed or cancelled. + if (result.status === DialogTurnStatus.complete || result.status === DialogTurnStatus.cancelled) { + const endMessageText = `Dialog ${ dialog.id } has **completed**. Sending EndOfConversation.`; + await context.sendTraceActivity(telemetryEventName, result.result, undefined, `${ endMessageText }`); + + // Send End of conversation at the end. + const activity: Partial = { type: ActivityTypes.EndOfConversation, value: result.result }; + await context.sendActivity(activity); + } + } + } else { + // The bot is running as a standard bot. + const results = await dialogContext.continueDialog(); + if (results.status === DialogTurnStatus.empty) { + await dialogContext.beginDialog(dialog.id); + } + } +} + +// Recursively walk up the DC stack to find the active DC. +function getActiveDialogContext(dialogContext: DialogContext): DialogContext { + const child = dialogContext.child; + if (!child) { + return dialogContext; + } + + return getActiveDialogContext(child); +} + +// We should only cancel the current dialog stack if the EoC activity is coming from a parent (a root bot or another skill). +// When the EoC is coming back from a child, we should just process that EoC normally through the +// dialog stack and let the child dialogs handle that. +function isEocComingFromParent(context: TurnContext): boolean { + // To determine the direction we check callerId property which is set to the parent bot + // by the BotFrameworkHttpClient on outgoing requests. + return !!context.activity.callerId; +} diff --git a/libraries/botbuilder-dialogs/src/index.ts b/libraries/botbuilder-dialogs/src/index.ts index 97980927c8..6f58078f19 100644 --- a/libraries/botbuilder-dialogs/src/index.ts +++ b/libraries/botbuilder-dialogs/src/index.ts @@ -5,19 +5,21 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ + +export * from './beginSkillDialogOptions'; export * from './choices'; -export * from './memory'; -export * from './prompts'; export * from './componentDialog'; export * from './configurable'; export * from './dialog'; export * from './dialogContainer'; export * from './dialogContext'; export * from './dialogEvents'; +export { runDialog } from './dialogHelper'; export * from './dialogManager'; export * from './dialogSet'; +export * from './memory'; +export * from './prompts'; export * from './skillDialog'; export * from './skillDialogOptions'; -export * from './beginSkillDialogOptions'; export * from './waterfallDialog'; export * from './waterfallStepContext'; diff --git a/libraries/botbuilder-dialogs/src/memory/index.ts b/libraries/botbuilder-dialogs/src/memory/index.ts index efcd979a1d..ac5f5e865e 100644 --- a/libraries/botbuilder-dialogs/src/memory/index.ts +++ b/libraries/botbuilder-dialogs/src/memory/index.ts @@ -9,4 +9,4 @@ export * from './pathResolvers'; export * from './scopes'; export * from './dialogStateManager'; export * from './turnPath'; -export * from './dialogPath'; \ No newline at end of file +export * from './dialogPath'; diff --git a/libraries/botbuilder-dialogs/src/memory/scopes/turnMemoryScope.ts b/libraries/botbuilder-dialogs/src/memory/scopes/turnMemoryScope.ts index eec0d8e94c..657d48f853 100644 --- a/libraries/botbuilder-dialogs/src/memory/scopes/turnMemoryScope.ts +++ b/libraries/botbuilder-dialogs/src/memory/scopes/turnMemoryScope.ts @@ -39,4 +39,4 @@ export class TurnMemoryScope extends MemoryScope { dc.context.turnState.set(TURN_STATE, memory); } -} \ No newline at end of file +} diff --git a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts index e236043f44..f79d347c7a 100644 --- a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts @@ -5,12 +5,36 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { Activity, ActivityTypes, AppCredentials, Attachment, CardFactory, Channels, InputHints, MessageFactory, OAuthLoginTimeoutKey, TokenResponse, TurnContext, CredentialTokenProvider, OAuthCard, ActionTypes, } from 'botbuilder-core'; +import { Activity, ActivityTypes, Attachment, CoreAppCredentials, BotAdapter, CardFactory, Channels, InputHints, MessageFactory, OAuthLoginTimeoutKey, TokenResponse, TurnContext, OAuthCard, ActionTypes, ExtendedUserTokenProvider, verifyStateOperationName, StatusCodes, tokenExchangeOperationName, tokenResponseEventName } from 'botbuilder-core'; import { Dialog, DialogTurnResult } from '../dialog'; import { DialogContext } from '../dialogContext'; import { PromptOptions, PromptRecognizerResult, PromptValidator } from './prompt'; import { isSkillClaim } from './skillsHelpers'; +/** + * Request body accepted for a token exchange invoke activity. + */ +interface TokenExchangeInvokeRequest { + id: string; + connectionName: string; + token: string; +} + +/** + * Response body returned for a token exchange invoke activity. + */ +class TokenExchangeInvokeResponse { + id: string; + connectionName: string; + failureDetail: string; + + constructor(id:string, connectionName:string, failureDetail:string) { + this.id = id; + this.connectionName = connectionName; + this.failureDetail = failureDetail; + } +} + /** * Settings used to configure an `OAuthPrompt` instance. */ @@ -18,7 +42,7 @@ export interface OAuthPromptSettings { /** * AppCredentials for OAuth. */ - oAuthAppCredentials: AppCredentials; + oAuthAppCredentials?: CoreAppCredentials; /** * Name of the OAuth connection being used. @@ -205,7 +229,7 @@ export class OAuthPrompt extends Dialog { } // Get the token and call validator - const adapter: CredentialTokenProvider = context.adapter as CredentialTokenProvider; + const adapter: ExtendedUserTokenProvider = context.adapter as ExtendedUserTokenProvider; return await adapter.getUserToken(context, this.settings.connectionName, code, this.settings.oAuthAppCredentials); } @@ -232,7 +256,7 @@ export class OAuthPrompt extends Dialog { } // Sign out user - const adapter: CredentialTokenProvider = context.adapter as CredentialTokenProvider; + const adapter: ExtendedUserTokenProvider = context.adapter as ExtendedUserTokenProvider; return adapter.signOutUser(context, this.settings.connectionName, null, this.settings.oAuthAppCredentials); } @@ -253,25 +277,30 @@ export class OAuthPrompt extends Dialog { const cards: Attachment[] = msg.attachments.filter((a: Attachment) => a.contentType === CardFactory.contentTypes.oauthCard); if (cards.length === 0) { let cardActionType = ActionTypes.Signin; - let link: string; - if (OAuthPrompt.isFromStreamingConnection(context.activity)) { - link = await (context.adapter as CredentialTokenProvider).getSignInLink(context, this.settings.connectionName, this.settings.oAuthAppCredentials); - } else { - // Retrieve the ClaimsIdentity from a BotFrameworkAdapter. For more information see - // https://github.com/microsoft/botbuilder-js/commit/b7932e37bb6e421985d5ce53edd9e82af6240a63#diff-3e3af334c0c6adf4906ee5e2a23beaebR250 - const identity = context.turnState.get((context.adapter as any).BotIdentityKey); - if (identity && isSkillClaim(identity.claims)) { - // Force magic code for Skills (to be addressed in R8) - link = await (context.adapter as CredentialTokenProvider).getSignInLink(context, this.settings.connectionName, this.settings.oAuthAppCredentials); + const signInResource = await (context.adapter as ExtendedUserTokenProvider).getSignInResource(context, this.settings.connectionName, context.activity.from.id, null, this.settings.oAuthAppCredentials); + let link = signInResource.signInLink; + const identity = context.turnState.get((context.adapter as BotAdapter).BotIdentityKey); + + // use the SignInLink when + // in speech channel or + // bot is a skill or + // an extra OAuthAppCredentials is being passed in + if((identity && isSkillClaim(identity.claims)) || OAuthPrompt.isFromStreamingConnection(context.activity) || this.settings.oAuthAppCredentials) { + if(context.activity.channelId === Channels.Emulator) { cardActionType = ActionTypes.OpenUrl; } } + else { + link = undefined; + } + // Append oauth card const card = CardFactory.oauthCard( this.settings.connectionName, this.settings.title, this.settings.text, - link + link, + signInResource.tokenExchangeResource ); // Set the appropriate ActionType for the button. @@ -282,10 +311,10 @@ export class OAuthPrompt extends Dialog { const cards: Attachment[] = msg.attachments.filter((a: Attachment) => a.contentType === CardFactory.contentTypes.signinCard); if (cards.length === 0) { // Append signin card - const link: any = await (context.adapter as CredentialTokenProvider).getSignInLink(context, this.settings.connectionName, this.settings.oAuthAppCredentials); + const signInResource = await (context.adapter as ExtendedUserTokenProvider).getSignInResource(context, this.settings.connectionName, context.activity.from.id, null, this.settings.oAuthAppCredentials); msg.attachments.push(CardFactory.signinCard( this.settings.title, - link, + signInResource.signInLink, this.settings.text )); } @@ -309,7 +338,7 @@ export class OAuthPrompt extends Dialog { try { token = await this.getUserToken(context, code); if (token !== undefined) { - await context.sendActivity({ type: 'invokeResponse', value: { status: 200 }}); + await context.sendActivity({ type: 'invokeResponse', value: { status: StatusCodes.OK }}); } else { await context.sendActivity({ type: 'invokeResponse', value: { status: 404 }}); } @@ -318,6 +347,44 @@ export class OAuthPrompt extends Dialog { { await context.sendActivity({ type: 'invokeResponse', value: { status: 500 }}); } + } else if (this.isTokenExchangeRequestInvoke(context)) { + // Received activity is not a token exchange request + if(!(context.activity.value && this.isTokenExchangeRequest(context.activity.value))) { + await context.sendActivity(this.getTokenExchangeInvokeResponse( + StatusCodes.BAD_REQUEST, + 'The bot received an InvokeActivity that is missing a TokenExchangeInvokeRequest value. This is required to be sent with the InvokeActivity.')); + } else if (context.activity.value.connectionName != this.settings.connectionName) { + // Connection name on activity does not match that of setting + await context.sendActivity(this.getTokenExchangeInvokeResponse( + StatusCodes.BAD_REQUEST, + 'The bot received an InvokeActivity with a TokenExchangeInvokeRequest containing a ConnectionName that does not match the ConnectionName' + + 'expected by the bots active OAuthPrompt. Ensure these names match when sending the InvokeActivityInvalid ConnectionName in the TokenExchangeInvokeRequest')); + } + else if (!('exchangeToken' in context.adapter)) { + // Token Exchange not supported in the adapter + await context.sendActivity(this.getTokenExchangeInvokeResponse( + StatusCodes.BAD_GATEWAY, + 'The bot\'s BotAdapter does not support token exchange operations. Ensure the bot\'s Adapter supports the ITokenExchangeProvider interface.')); + throw new Error('OAuthPrompt.recognize(): not supported by the current adapter'); + } else { + // No errors. Proceed with token exchange + const extendedUserTokenProvider : ExtendedUserTokenProvider = context.adapter as ExtendedUserTokenProvider; + const tokenExchangeResponse = await extendedUserTokenProvider.exchangeToken(context, this.settings.connectionName, context.activity.from.id, {token: context.activity.value.token}); + + if(!tokenExchangeResponse || !tokenExchangeResponse.token) { + await context.sendActivity(this.getTokenExchangeInvokeResponse( + StatusCodes.CONFLICT, + 'The bot is unable to exchange token. Proceed with regular login.')); + } else { + await context.sendActivity(this.getTokenExchangeInvokeResponse(StatusCodes.OK, null, context.activity.value.id)); + token = { + channelId: tokenExchangeResponse.channelId, + connectionName: tokenExchangeResponse.connectionName, + token : tokenExchangeResponse.token, + expiration: null + }; + } + } } else if (context.activity.type === ActivityTypes.Message) { const matched: RegExpExecArray = /(\d{6})/.exec(context.activity.text); if (matched && matched.length > 1) { @@ -328,6 +395,14 @@ export class OAuthPrompt extends Dialog { return token !== undefined ? { succeeded: true, value: token } : { succeeded: false }; } + private getTokenExchangeInvokeResponse(status: number, failureDetail: string, id?: string): Activity { + const invokeResponse: Partial = { + type: 'invokeResponse', + value: { status, body: new TokenExchangeInvokeResponse(id, this.settings.connectionName, failureDetail)} + }; + return invokeResponse as Activity; + } + private static isFromStreamingConnection(activity: Activity): boolean { return activity && activity.serviceUrl && !activity.serviceUrl.toLowerCase().startsWith('http'); } @@ -335,7 +410,7 @@ export class OAuthPrompt extends Dialog { private isTokenResponseEvent(context: TurnContext): boolean { const activity: Activity = context.activity; - return activity.type === ActivityTypes.Event && activity.name === 'tokens/response'; + return activity.type === ActivityTypes.Event && activity.name === tokenResponseEventName; } @@ -343,13 +418,13 @@ export class OAuthPrompt extends Dialog { private isTeamsVerificationInvoke(context: TurnContext): boolean { const activity: Activity = context.activity; - return activity.type === ActivityTypes.Invoke && activity.name === 'signin/verifyState'; + return activity.type === ActivityTypes.Invoke && activity.name === verifyStateOperationName; } - private isOAuthCardSupported(context: TurnContext) { + private isOAuthCardSupported(context: TurnContext): boolean { // Azure Bot Service OAuth cards are not supported in the community adapters. Since community adapters // have a 'name' in them, we cast the adapter to 'any' to check for the name. - const adapter:any = context.adapter; + const adapter: any = context.adapter; if (adapter.name) { switch(adapter.name) { case 'Facebook Adapter': @@ -365,6 +440,19 @@ export class OAuthPrompt extends Dialog { } return this.channelSupportsOAuthCard(context.activity.channelId); } + + private isTokenExchangeRequestInvoke(context: TurnContext): boolean { + const activity: Activity = context.activity; + + return activity.type === ActivityTypes.Invoke && activity.name === tokenExchangeOperationName; + } + + private isTokenExchangeRequest(obj: unknown): obj is TokenExchangeInvokeRequest { + if(obj.hasOwnProperty('token')) { + return true; + } + return false; + } private channelSupportsOAuthCard(channelId: string): boolean { switch (channelId) { diff --git a/libraries/botbuilder-dialogs/src/prompts/skillsHelpers.ts b/libraries/botbuilder-dialogs/src/prompts/skillsHelpers.ts index 34939ae9d2..2f0b3f3ae5 100644 --- a/libraries/botbuilder-dialogs/src/prompts/skillsHelpers.ts +++ b/libraries/botbuilder-dialogs/src/prompts/skillsHelpers.ts @@ -22,7 +22,7 @@ export const AuthConstants = { export const GovConstants = { ToBotFromChannelTokenIssuer: 'https://api.botframework.us' -} +}; /** * @ignore @@ -82,20 +82,20 @@ export function getAppIdFromClaims(claims: { [key: string]: any }[]): string { } let appId: string; - // Depending on Version, the AppId is either in the - // appid claim (Version 1) or the 'azp' claim (Version 2). - const versionClaim = claims.find(c => c.type === AuthConstants.VersionClaim); - const versionValue = versionClaim && versionClaim.value; - if (!versionValue || versionValue === '1.0') { - // No version or a version of '1.0' means we should look for - // the claim in the 'appid' claim. - const appIdClaim = claims.find(c => c.type === AuthConstants.AppIdClaim); - appId = appIdClaim && appIdClaim.value; - } else if (versionValue === '2.0') { - // Version '2.0' puts the AppId in the 'azp' claim. - const azpClaim = claims.find(c => c.type === AuthConstants.AuthorizedParty); - appId = azpClaim && azpClaim.value; - } + // Depending on Version, the AppId is either in the + // appid claim (Version 1) or the 'azp' claim (Version 2). + const versionClaim = claims.find(c => c.type === AuthConstants.VersionClaim); + const versionValue = versionClaim && versionClaim.value; + if (!versionValue || versionValue === '1.0') { + // No version or a version of '1.0' means we should look for + // the claim in the 'appid' claim. + const appIdClaim = claims.find(c => c.type === AuthConstants.AppIdClaim); + appId = appIdClaim && appIdClaim.value; + } else if (versionValue === '2.0') { + // Version '2.0' puts the AppId in the 'azp' claim. + const azpClaim = claims.find(c => c.type === AuthConstants.AuthorizedParty); + appId = azpClaim && azpClaim.value; + } - return appId; + return appId; } diff --git a/libraries/botbuilder-dialogs/src/skillDialog.ts b/libraries/botbuilder-dialogs/src/skillDialog.ts index ae14ffb924..3ee369bcf9 100644 --- a/libraries/botbuilder-dialogs/src/skillDialog.ts +++ b/libraries/botbuilder-dialogs/src/skillDialog.ts @@ -10,8 +10,12 @@ import { Activity, ActivityTypes, ConversationReference, + DeliveryModes, + ExpectedReplies, + SkillConversationIdFactoryOptions, TurnContext } from 'botbuilder-core'; +import { BeginSkillDialogOptions } from './beginSkillDialogOptions'; import { Dialog, DialogInstance, @@ -19,12 +23,15 @@ import { DialogTurnResult } from './dialog'; import { DialogContext } from './dialogContext'; -import { BeginSkillDialogOptions } from './beginSkillDialogOptions'; +import { DialogEvents } from './dialogEvents'; import { SkillDialogOptions } from './skillDialogOptions'; export class SkillDialog extends Dialog { protected dialogOptions: SkillDialogOptions; + // This key uses a simple namespace as Symbols are not serializable. + private readonly DeliveryModeStateKey: string = 'SkillDialog.deliveryMode'; + /** * A sample dialog that can wrap remote calls to a skill. * @@ -43,7 +50,7 @@ export class SkillDialog extends Dialog { this.dialogOptions = dialogOptions; } - public async beginDialog(dc: DialogContext, options?: {}): Promise { + public async beginDialog(dc: DialogContext, options?: any): Promise { const dialogArgs = SkillDialog.validateBeginDialogArgs(options); await dc.context.sendTraceActivity(`${ this.id }.beginDialog()`, undefined, undefined, `Using activity of type: ${ dialogArgs.activity.type }`); @@ -54,8 +61,14 @@ export class SkillDialog extends Dialog { // Apply conversation reference and common properties from incoming activity before sending. const skillActivity = TurnContext.applyConversationReference(clonedActivity, TurnContext.getConversationReference(dc.context.activity), true) as Activity; + // Store the deliveryMode of the first forwarded activity + dc.activeDialog.state[this.DeliveryModeStateKey] = dialogArgs.activity.deliveryMode; + // Send the activity to the skill. - await this.sendToSkill(dc.context, skillActivity); + const eocActivity = await this.sendToSkill(dc.context, skillActivity); + if (eocActivity) { + return await dc.endDialog(eocActivity.value); + } return Dialog.EndOfTurn; } @@ -71,8 +84,15 @@ export class SkillDialog extends Dialog { // Forward only Message and Event activities to the skill if (dc.context.activity.type === ActivityTypes.Message || dc.context.activity.type === ActivityTypes.Event) { + // Create deep clone of the original activity to avoid altering it before forwarding it. + const skillActivity = this.cloneActivity(dc.context.activity); + skillActivity.deliveryMode = dc.activeDialog.state[this.DeliveryModeStateKey] as string; + // Just forward to the remote skill - await this.sendToSkill(dc.context, dc.context.activity); + const eocActivity = await this.sendToSkill(dc.context, skillActivity); + if (eocActivity) { + return await dc.endDialog(eocActivity.value); + } } return Dialog.EndOfTurn; @@ -94,6 +114,22 @@ export class SkillDialog extends Dialog { await super.endDialog(context, instance, reason); } + public async repromptDialog(context: TurnContext, instance: DialogInstance): Promise { + // Create and send an envent to the skill so it can resume the dialog. + const repromptEvent = { type: ActivityTypes.Event, name: DialogEvents.repromptDialog }; + + const reference = TurnContext.getConversationReference(context.activity); + // Apply conversation reference and common properties from incoming activity before sending. + const activity: Activity = TurnContext.applyConversationReference(repromptEvent, reference, true) as Activity; + + await this.sendToSkill(context, activity); + } + + public async resumeDialog(dc: DialogContext, reason: DialogReason, result?: any): Promise { + await this.repromptDialog(dc.context, dc.activeDialog); + return Dialog.EndOfTurn; + } + /** * Clones the Activity entity. * @param activity Activity to clone. @@ -116,25 +152,59 @@ export class SkillDialog extends Dialog { // Only accept Message or Event activities if (dialogArgs.activity.type !== ActivityTypes.Message && dialogArgs.activity.type !== ActivityTypes.Event) { // Just forward to the remote skill - throw new TypeError(`Only ${ ActivityTypes.Message } and ${ ActivityTypes.Event } activities are supported. Received activity of type ${ dialogArgs.activity.type } in options.`); + throw new TypeError(`Only "${ ActivityTypes.Message }" and "${ ActivityTypes.Event }" activities are supported. Received activity of type "${ dialogArgs.activity.type }" in options.`); } return dialogArgs; } - private async sendToSkill(context: TurnContext, activity: Activity): Promise { + private async sendToSkill(context: TurnContext, activity: Activity): Promise { + // Create a conversationId to interact with the skill and send the activity + const conversationIdFactoryOptions: SkillConversationIdFactoryOptions = { + fromBotOAuthScope: context.turnState.get(context.adapter.OAuthScopeKey), + fromBotId: this.dialogOptions.botId, + activity: activity, + botFrameworkSkill: this.dialogOptions.skill + }; + // Create a conversationId to interact with the skill and send the activity - const skillConversationId = await this.dialogOptions.conversationIdFactory.createSkillConversationId(TurnContext.getConversationReference(activity) as ConversationReference); + let skillConversationId: string; + try { + skillConversationId = await this.dialogOptions.conversationIdFactory.createSkillConversationIdWithOptions(conversationIdFactoryOptions); + } catch (err) { + if (err.message !== 'Not Implemented') throw err; + // If the SkillConversationIdFactoryBase implementation doesn't support createSkillConversationIdWithOptions(), + // use createSkillConversationId() instead. + skillConversationId = await this.dialogOptions.conversationIdFactory.createSkillConversationId(TurnContext.getConversationReference(activity) as ConversationReference); + } // Always save state before forwarding // (the dialog stack won't get updated with the skillDialog and things won't work if you don't) - await this.dialogOptions.conversationState.saveChanges(context, true); const skillInfo = this.dialogOptions.skill; - const response = await this.dialogOptions.skillClient.postActivity(this.dialogOptions.botId, skillInfo.appId, skillInfo.skillEndpoint, skillInfo.skillEndpoint, skillConversationId, activity); + await this.dialogOptions.conversationState.saveChanges(context, true); + + const response = await this.dialogOptions.skillClient.postActivity(this.dialogOptions.botId, skillInfo.appId, skillInfo.skillEndpoint, this.dialogOptions.skillHostEndpoint, skillConversationId, activity); // Inspect the skill response status if (!(response.status >= 200 && response.status <= 299)) { throw new Error(`Error invoking the skill id: "${ skillInfo.id }" at "${ skillInfo.skillEndpoint }" (status is ${ response.status }). \r\n ${ response.body }`); } + + let eocActivity: Activity; + if (activity.deliveryMode == DeliveryModes.ExpectReplies && response.body && response.body.activities) { + // Process replies in the response.Body. + if (Array.isArray(response.body.activities)) { + response.body.activities.forEach(async (fromSkillActivity: Activity): Promise => { + if (fromSkillActivity.type === ActivityTypes.EndOfConversation) { + // Capture the EndOfConversation activity if it was sent from skill + eocActivity = fromSkillActivity; + } else { + await context.sendActivity(fromSkillActivity); + } + }); + } + } + + return eocActivity; } } diff --git a/libraries/botbuilder-dialogs/src/skillDialogOptions.ts b/libraries/botbuilder-dialogs/src/skillDialogOptions.ts index 02b8737de6..31fec502eb 100644 --- a/libraries/botbuilder-dialogs/src/skillDialogOptions.ts +++ b/libraries/botbuilder-dialogs/src/skillDialogOptions.ts @@ -15,7 +15,7 @@ import { export interface SkillDialogOptions { /** - * The the Microsoft app ID of the bot calling the skill. + * The Microsoft app ID of the bot calling the skill. */ botId: string; diff --git a/libraries/botbuilder-dialogs/tests/dialogHelper.test.js b/libraries/botbuilder-dialogs/tests/dialogHelper.test.js new file mode 100644 index 0000000000..05531b60f5 --- /dev/null +++ b/libraries/botbuilder-dialogs/tests/dialogHelper.test.js @@ -0,0 +1,40 @@ +const { strictEqual } = require('assert'); +const { runDialog } = require('../'); + +describe('runDialog()', function() { + this.timeout(300); + + describe('parameter validation', () => { + it('should throw if missing dialog parameter', (done) => { + runDialog().then( + () => done(new Error('should have throw error')), + (err) => { + done(strictEqual(err.message, 'runDialog(): missing dialog')); + }); + }); + + it('should throw if missing context parameter', (done) => { + runDialog({}).then( + () => done(new Error('should have throw error')), + (err) => { + done(strictEqual(err.message, 'runDialog(): missing context')); + }); + }); + + it('should throw if missing context.activity', (done) => { + runDialog({}, {}).then( + () => done(new Error('should have throw error')), + (err) => { + done(strictEqual(err.message, 'runDialog(): missing context.activity')); + }); + }); + + it('should throw if missing accessor parameter', (done) => { + runDialog({}, { activity: {} }).then( + () => done(new Error('should have throw error')), + (err) => { + done(strictEqual(err.message, 'runDialog(): missing accessor')); + }); + }); + }); +}); diff --git a/libraries/botbuilder-dialogs/tests/oauthPrompt.test.js b/libraries/botbuilder-dialogs/tests/oauthPrompt.test.js index abac7ded9a..8dc0141425 100644 --- a/libraries/botbuilder-dialogs/tests/oauthPrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/oauthPrompt.test.js @@ -7,12 +7,12 @@ const beginMessage = { text: `begin`, type: 'message' }; const answerMessage = { text: `yes`, type: 'message' }; const invalidMessage = { text: `what?`, type: 'message' }; -describe('OAuthPrompt', function () { +describe('OAuthPrompt', function() { this.timeout(5000); - it('should call OAuthPrompt', async function () { - var connectionName = "myConnection"; - var token = "abc123"; + it('should call OAuthPrompt', async function() { + var connectionName = 'myConnection'; + var token = 'abc123'; // Initialize TestAdapter. const adapter = new TestAdapter(async (turnContext) => { @@ -39,10 +39,10 @@ describe('OAuthPrompt', function () { const dialogState = convoState.createProperty('dialogState'); const dialogs = new DialogSet(dialogState); dialogs.add(new OAuthPrompt('prompt', { - connectionName, - title: 'Login', - timeout: 300000 - })); + connectionName, + title: 'Login', + timeout: 300000 + })); await adapter.send('Hello') .assertReply(activity => { @@ -59,7 +59,7 @@ describe('OAuthPrompt', function () { var from = eventActivity.from; eventActivity.from = eventActivity.recipient; eventActivity.recipient = from; - eventActivity.name = "tokens/response"; + eventActivity.name = 'tokens/response'; eventActivity.value = { connectionName, token @@ -70,10 +70,10 @@ describe('OAuthPrompt', function () { .assertReply('Logged in.'); }); - it('should call OAuthPrompt with code', async function () { - var connectionName = "myConnection"; - var token = "abc123"; - var magicCode = "888999"; + it('should call OAuthPrompt with code', async function() { + var connectionName = 'myConnection'; + var token = 'abc123'; + var magicCode = '888999'; // Initialize TestAdapter. const adapter = new TestAdapter(async (turnContext) => { @@ -100,10 +100,10 @@ describe('OAuthPrompt', function () { const dialogState = convoState.createProperty('dialogState'); const dialogs = new DialogSet(dialogState); dialogs.add(new OAuthPrompt('prompt', { - connectionName, - title: 'Login', - timeout: 300000 - })); + connectionName, + title: 'Login', + timeout: 300000 + })); await adapter.send('Hello') .assertReply(activity => { @@ -194,9 +194,9 @@ describe('OAuthPrompt', function () { .assertReply('Logged in'); }); - it('should call OAuthPrompt for streaming connection', async function () { - var connectionName = "myConnection"; - var token = "abc123"; + it('should call OAuthPrompt for streaming connection', async function() { + var connectionName = 'myConnection'; + var token = 'abc123'; // Initialize TestAdapter. const adapter = new TestAdapter(async (turnContext) => { @@ -223,10 +223,10 @@ describe('OAuthPrompt', function () { const dialogState = convoState.createProperty('dialogState'); const dialogs = new DialogSet(dialogState); dialogs.add(new OAuthPrompt('prompt', { - connectionName, - title: 'Login', - timeout: 300000 - })); + connectionName, + title: 'Login', + timeout: 300000 + })); const streamingActivity = { activityId: '1234', @@ -260,7 +260,7 @@ describe('OAuthPrompt', function () { var from = eventActivity.from; eventActivity.from = eventActivity.recipient; eventActivity.recipient = from; - eventActivity.name = "tokens/response"; + eventActivity.name = 'tokens/response'; eventActivity.value = { connectionName, token @@ -290,10 +290,20 @@ describe('OAuthPrompt', function () { } async getUserToken(context, magicCode) { - assert(context, 'context not passed in to getSignInLink call.'); + assert(context, 'context not passed in to getUserToken call.'); assert(magicCode, 'magicCode not passed in to getUserToken call'); return 'token'; } + + async getSignInResource(context, connectionName, userId) { + assert(context, 'context not passed in to getSignInResource call.'); + assert(connectionName, 'connectionName not passed in to getSignInResource call'); + assert(userId, 'userId not passed in to getSignInResource call'); + return { + signInLink: this.signInLink, + tokenExchangeResource: this.tokenExchangeResource + }; + } } it(`should fail if adapter does not have 'getUserToken'`, async () => { @@ -318,14 +328,19 @@ describe('OAuthPrompt', function () { const title = 'myTitle'; const text = 'Sign in here'; const signInLink = 'https://dev.botframework.com'; + const tokenExchangeResource = { + id: 'id', + uri: 'some uri' + }; const adapter = new SendActivityAdapter({ connectionName, signInLink, - text, title, + text, title, tokenExchangeResource }); const context = new TurnContext(adapter, { - activity: { - channelId: Channels.Webchat, - serviceUrl: 'https://bing.com', + channelId: Channels.Webchat, + serviceUrl: 'https://bing.com', + from: { + id: 'someId' } }); // Override sendActivity @@ -354,14 +369,19 @@ describe('OAuthPrompt', function () { const title = 'myTitle'; const text = 'Sign in here'; const signInLink = 'https://dev.botframework.com'; + const tokenExchangeResource = { + id: 'id', + uri: 'some uri' + }; const adapter = new SendActivityAdapter({ connectionName, signInLink, - text, title, + text, title, tokenExchangeResource }); const context = new TurnContext(adapter, { - activity: { - channelId: Channels.Webchat, - serviceUrl: 'https://bing.com', + channelId: Channels.Emulator, + serviceUrl: 'https://bing.com', + from: { + id: 'someId' } }); context.turnState.set(adapter.BotIdentityKey, new ClaimsIdentity([ @@ -400,6 +420,9 @@ describe('OAuthPrompt', function () { const context = new TurnContext(adapter, { channelId: Channels.Webchat, serviceUrl: 'wss://bing.com', + from: { + id: 'someId' + } }); // Override sendActivity context.sendActivity = async function(activity) { @@ -432,9 +455,10 @@ describe('OAuthPrompt', function () { text, title, }); const context = new TurnContext(adapter, { - activity: { - channelId: Channels.Webchat, - serviceUrl: 'https://bing.com', + channelId: Channels.Webchat, + serviceUrl: 'https://bing.com', + from: { + id: 'someId' } }); context.turnState.set(adapter.BotIdentityKey, new ClaimsIdentity([ @@ -465,6 +489,190 @@ describe('OAuthPrompt', function () { }); }); }); + + describe('Test Adapter should be able to exchange tokens for uri and token', async function() { + let adapter; + const connectionName = 'myConnection'; + const exchangeToken = 'exch123'; + const token = 'abc123'; + this.beforeEach(function() { + adapter = new TestAdapter(async (turnContext) => { + const userId = 'blah'; + adapter.addExchangeableToken(connectionName, turnContext.activity.channelId, userId, exchangeToken, token); + + // Positive case: Token + let result = await adapter.exchangeToken(turnContext, connectionName, userId, {token: exchangeToken}); + assert(result); + assert.strictEqual(result.token, token); + assert.strictEqual(result.connectionName, connectionName); + // Positive case: URI + result = await adapter.exchangeToken(turnContext, connectionName, userId, {uri: exchangeToken}); + assert(result); + assert.strictEqual(result.token, token); + assert.strictEqual(result.connectionName, connectionName); + // Negative case: Token + result = await adapter.exchangeToken(turnContext, connectionName, userId, {token: 'beepboop'}); + assert(result === null); + // Negative case: URI + result = await adapter.exchangeToken(turnContext, connectionName, userId, {uri: 'beepboop'}); + assert(result === null); + }); + }); + + it('Test adapter should be able to perform token exchanges for token', async function() { + await adapter + .send('hello'); + }); + }); + + describe('OAuthPrompt should be able to exchange tokens', async function() { + let adapter; + const connectionName = 'myConnection'; + const exchangeToken = 'exch123'; + const token = 'abc123'; + this.beforeEach(function() { + // Initialize TestAdapter + adapter = new TestAdapter(async (turnContext) => { + const dc = await dialogs.createContext(turnContext); + const results = await dc.continueDialog(); + if(results.status === DialogTurnStatus.empty) { + await dc.prompt('OAuthPrompt', {}); + } + else if(results.status === DialogTurnStatus.complete) { + if (results.result.token) { + await turnContext.sendActivity(`Logged in.`); + } + else { + await turnContext.sendActivity('Failed'); + } + } + await convoState.saveChanges(turnContext); + }); + + + //Create new ConversationState with MemoryStorage + const convoState = new ConversationState(new MemoryStorage()); + + //Create a DialogState property, DialogSet and OAuthPrompt + const dialogState = convoState.createProperty('dialogState'); + const dialogs = new DialogSet(dialogState); + + dialogs.add(new OAuthPrompt('OAuthPrompt', { + connectionName, + title: 'Sign in', + timeout: 30000, + text: 'Please sign in' + })); + }); + + it('Should handle token exchange invoke requests via OAuthPrompt', async function() { + await adapter + .send('hello') + .assertReply(activity => { + assert.strictEqual(activity.attachments.length, 1); + assert.strictEqual(activity.attachments[0].contentType, CardFactory.contentTypes.oauthCard); + assert(activity.inputHint === InputHints.AcceptingInput); + + // Add an exchangeable token to the adapter + adapter.addExchangeableToken(connectionName, activity.channelId, activity.recipient.id, exchangeToken, token); + }) + .send({ + type: ActivityTypes.Invoke, + name: 'signin/tokenExchange', + value: { + id: null, + connectionName: connectionName, + token: exchangeToken + } + }) + .assertReply(a => { + assert.strictEqual('invokeResponse', a.type); + assert(a.value); + assert.strictEqual(a.value.status, 200); + assert.strictEqual(a.value.body.connectionName, connectionName); + assert(a.value.body.failureDetail === null); + }) + .assertReply('Logged in.'); + }); + + it('Should reject token exchange requests if token cannot be exchanged', async function() { + await adapter + .send('hello') + .assertReply(activity => { + assert.strictEqual(activity.attachments.length, 1); + assert.strictEqual(activity.attachments[0].contentType, CardFactory.contentTypes.oauthCard); + assert(activity.inputHint === InputHints.AcceptingInput); + + // No exchangeable token is added to the adapter + }) + .send({ + type: ActivityTypes.Invoke, + name: 'signin/tokenExchange', + value: { + id: null, + connectionName: connectionName, + token: exchangeToken + } + }) + .assertReply(a => { + assert.strictEqual('invokeResponse', a.type); + assert(a.value); + assert.strictEqual(a.value.status, 409); + assert(a.value.body.failureDetail); + }); + }); + + it('Should reject token exhchange requests with no body', async function() { + await adapter + .send('hello') + .assertReply(activity => { + assert.strictEqual(activity.attachments.length, 1); + assert.strictEqual(activity.attachments[0].contentType, CardFactory.contentTypes.oauthCard); + assert(activity.inputHint === InputHints.AcceptingInput); + + // No exchangeable token is added to the adapter + }) + .send({ + type: ActivityTypes.Invoke, + name: 'signin/tokenExchange' + //no body is sent + }) + .assertReply(a => { + assert.strictEqual('invokeResponse', a.type); + assert(a.value); + assert.strictEqual(a.value.status, 400); + assert(a.value.body.failureDetail); + }); + }); + + it('Should reject token exhchange requests with wrong connection name', async function() { + await adapter + .send('hello') + .assertReply(activity => { + assert.strictEqual(activity.attachments.length, 1); + assert.strictEqual(activity.attachments[0].contentType, CardFactory.contentTypes.oauthCard); + assert(activity.inputHint === InputHints.AcceptingInput); + + // No exchangeable token is added to the adapter + }) + .send({ + type: ActivityTypes.Invoke, + name: 'signin/tokenExchange', + value: { + id: null, + connectionName: 'foobar', + token: exchangeToken + } + }) + .assertReply(a => { + assert.strictEqual('invokeResponse', a.type); + assert(a.value); + assert.strictEqual(a.value.status, 400); + assert.strictEqual(a.value.body.connectionName, connectionName); + assert(a.value.body.failureDetail); + }); + }); + }); }); function createReply(activity) { diff --git a/libraries/botbuilder-dialogs/tests/skillDialog.test.js b/libraries/botbuilder-dialogs/tests/skillDialog.test.js new file mode 100644 index 0000000000..74a212899c --- /dev/null +++ b/libraries/botbuilder-dialogs/tests/skillDialog.test.js @@ -0,0 +1,180 @@ +const { equal, ok: assert, strictEqual } = require('assert'); +const { ActivityTypes, TestAdapter, SkillConversationIdFactoryBase, TurnContext } = require('botbuilder-core'); +const { Dialog, DialogContext, SkillDialog } = require('../'); + +const DEFAULT_OAUTHSCOPE = 'https://api.botframework.com'; +const DEFAULT_GOV_OAUTHSCOPE = 'https://api.botframework.us'; + +const defaultSkillDialogOptions = { + botId: 'botId', + conversationIdFactory: {}, + conversationState: {}, + skill: {}, + skillHostEndpoint: {} +}; + +function typeErrorValidator(e, expectedMessage) { + assert(e instanceof TypeError); + strictEqual(e.message, expectedMessage); +} + +describe('SkillDialog', function() { + this.timeout(3000); + + it('repromptDialog() should call sendToSkill()', async () => { + const adapter = new TestAdapter(/* logic param not required */); + const context = new TurnContext(adapter, { type: ActivityTypes.Message, id: 'activity-id' }); + context.turnState.set(adapter.OAuthScopeKey, DEFAULT_OAUTHSCOPE); + const dialog = new SkillDialog({} , 'SkillDialog'); + + let sendToSkillCalled = false; + dialog.sendToSkill = () => { + sendToSkillCalled = true; + }; + + await dialog.repromptDialog(context, {}); + assert(sendToSkillCalled, 'sendToSkill not called'); + }); + + it('resumeDialog() should call repromptDialog()', async () => { + const adapter = new TestAdapter(/* logic param not required */); + const context = new TurnContext(adapter, { type: ActivityTypes.Message, id: 'activity-id' }); + context.turnState.set(adapter.OAuthScopeKey, DEFAULT_OAUTHSCOPE); + const dialog = new SkillDialog({} , 'SkillDialog'); + + let repromptDialogCalled = false; + dialog.repromptDialog = () => { + repromptDialogCalled = true; + }; + + const result = await dialog.resumeDialog(context, {}); + assert(repromptDialogCalled, 'sendToSkill not called'); + strictEqual(result, Dialog.EndOfTurn); + }); + + describe('(private) validateBeginDialogArgs()', () => { + it('should fail if options is falsy', () => { + const activity = { + type: ActivityTypes.Message, + text: 'Hello SkillDialog!' + }; + const validatedArgs = SkillDialog.validateBeginDialogArgs({ activity }); + const validatedActivity = validatedArgs.activity; + strictEqual(validatedActivity.type, ActivityTypes.Message); + strictEqual(validatedActivity.text, 'Hello SkillDialog!'); + }); + + it('should fail if options is falsy', () => { + try { + SkillDialog.validateBeginDialogArgs(); + } catch (e) { + typeErrorValidator(e, 'Missing options parameter'); + } + }); + + it('should fail if dialogArgs.activity is falsy', () => { + try { + SkillDialog.validateBeginDialogArgs({}); + } catch (e) { + typeErrorValidator(e, '"activity" is undefined or null in options.'); + } + }); + + it('should fail if dialogArgs.activity.type is not "message" or "event"', () => { + const type = ActivityTypes.EndOfConversation; + try { + SkillDialog.validateBeginDialogArgs({ activity: { type } }); + } catch (e) { + typeErrorValidator(e, `Only "${ ActivityTypes.Message }" and "${ ActivityTypes.Event }" activities are supported. Received activity of type "${ type }" in options.`); + } + }); + }); + + describe('(private) sendToSkill()', () => { + it(`should rethrow the error if its message is not "Not Implemented" error`, async () => { + const adapter = new TestAdapter(/* logic param not required */); + const context = new TurnContext(adapter, { type: ActivityTypes.Message }); + context.turnState.set(adapter.OAuthScopeKey, DEFAULT_OAUTHSCOPE); + const dialog = new SkillDialog({ + botId: 'botId', + conversationIdFactory: { createSkillConversationIdWithOptions: async () => { throw new Error('Whoops'); } + }, + conversationState: {}, + skill: {}, + skillHostEndpoint: 'http://localhost:3980/api/messages' + } , 'SkillDialog'); + + try { + await dialog.sendToSkill(context, {}); + } catch (e) { + strictEqual(e.message, 'Whoops'); + } + }); + + it('should not rethrow if Error.message is "Not Implemented"', (done) => { + const adapter = new TestAdapter(/* logic param not required */); + const context = new TurnContext(adapter, { activity: {} }); + context.turnState.set(adapter.OAuthScopeKey, DEFAULT_OAUTHSCOPE); + const dialog = new SkillDialog({ + botId: 'botId', + conversationIdFactory: { + createSkillConversationIdWithOptions: async () => { throw new Error('Not Implemented'); }, + createSkillConversationId: async () => done() + }, + conversationState: { + saveChanges: () => null + }, + skill: {}, + skillHostEndpoint: 'http://localhost:3980/api/messages', + skillClient: { + postActivity: async () => { return { status: 200 }; } + } + } , 'SkillDialog'); + + dialog.sendToSkill(context, {}).then((a) => assert(typeof a === 'undefined'), (e) => done(e)); + }); + }); +}); + +/** + * @param {string} fromBotOAuthScope + * @param {string} fromBotId + * @param {object} activity + * @param {object} botFrameworkSkill { id, appId, skillEndpoint } + */ +function createFactoryOptions(fromBotOAuthScope, fromBotId, activity, botFrameworkSkill) { + return { fromBotOAuthScope, fromBotId, activity, botFrameworkSkill }; +} + +class SkillConversationIdFactory extends SkillConversationIdFactoryBase { + constructor(config = { disableCreateWithOpts: false, disableGetSkillRef: false }) { + super(); + this.disableCreateWithOpts = config.disableCreateWithOpts; + this.disableGetSkillRef = config.disableGetSkillRef; + } + + async createSkillConversationIdWithOptions(opts) { + if (this.disableCreateWithOpts) { + return super.createSkillConversationIdWithOptions(); + } + } + + async createSkillConversationId() { + + } + + async getConversationReference() { + + } + + async getSkillConversationReference() { + if (this.disableGetSkillRef) { + return super.getSkillConversationReference(); + } + } + + deleteConversationReference() { + + } + +} diff --git a/libraries/botbuilder-lg/README.MD b/libraries/botbuilder-lg/README.MD index 205a918f0b..84d03d0197 100644 --- a/libraries/botbuilder-lg/README.MD +++ b/libraries/botbuilder-lg/README.MD @@ -78,7 +78,7 @@ the result could be: the structured name would be placed into property 'lgType'. See more tests here : [structured LG test][4] -By this, You can use the `ActivityFactory.createActivity(lgResult)` method to transform the lg output into a Bot Framework activity to post back to the user. +By this, You can use the `ActivityFactory.fromObject(lgResult)` method to transform the lg output into a Bot Framework activity to post back to the user. see more samples here: [Structured LG to Activity][5] @@ -91,26 +91,22 @@ Then make sure you include the platform specific language generation library. For C#, add Microsoft.Bot.Builder.LanguageGeneration. For NodeJS, add botbuilder-lg -Load the template manager with your .lg file(s) +Load the template manager with your .lg file ```typescript - // multi lg files - let lgEngine = new TemplateEngine.addFiles(filePaths, importResolver?); - - // single lg file - let lgEngine = new TemplateEngine.addFile(filePath, importResolver?); + let templates = new Templates.parseFile(filePath, importResolver?, expressionParser?); ``` -When you need template expansion, call the templateEngine and pass in the relevant template name +When you need template expansion, call the templates and pass in the relevant template name ```typescript - await turnContext.sendActivity(lgEngine.evaluateTemplate("", entitiesCollection)); + await turnContext.sendActivity(templates.evaluate("", entitiesCollection)); ``` If your template needs specific entity values to be passed for resolution/ expansion, you can pass them in on the call to `evaluateTemplate` ```typescript - await turnContext.sendActivity(lgEngine.evaluateTemplate("WordGameReply", { GameName = "MarcoPolo" } )); + await turnContext.sendActivity(templates.evaluate("WordGameReply", { GameName = "MarcoPolo" } )); ``` [1]:https://github.com/Microsoft/BotBuilder/blob/master/specs/botframework-activity/botframework-activity.md diff --git a/libraries/botbuilder-lg/src/LGFileLexer.g4 b/libraries/botbuilder-lg/src/LGFileLexer.g4 index 0e9608f22f..5ec3f08bd9 100644 --- a/libraries/botbuilder-lg/src/LGFileLexer.g4 +++ b/libraries/botbuilder-lg/src/LGFileLexer.g4 @@ -42,11 +42,11 @@ fragment WHITESPACE : ' '|'\t'|'\ufeff'|'\u00a0'; fragment EMPTY_OBJECT: '{' WHITESPACE* '}'; -fragment STRING_LITERAL : ('\'' (~['\r\n])* '\'') | ('"' (~["\r\n])* '"'); +fragment STRING_LITERAL : ('\'' (('\\'('\''|'\\'))|(~'\''))*? '\'') | ('"' (('\\'('"'|'\\'))|(~'"'))*? '"'); -fragment STRING_INTERPOLATION : '`' ('\\`' | ~'`')* '`'; +fragment STRING_INTERPOLATION : '`' (('\\'('`'|'\\'))|(~'`'))*? '`'; -fragment EXPRESSION_FRAGMENT : '$' '{' (STRING_LITERAL | STRING_INTERPOLATION | EMPTY_OBJECT | ~[\r\n{}'"`] )+ '}'?; +fragment EXPRESSION_FRAGMENT : '$' '{' (STRING_LITERAL | STRING_INTERPOLATION | EMPTY_OBJECT | ~[}'"`] )+ '}'?; fragment ESCAPE_CHARACTER_FRAGMENT : '\\' ~[\r\n]?; diff --git a/libraries/botbuilder-lg/src/README.md b/libraries/botbuilder-lg/src/README.md deleted file mode 100644 index 66425dbd30..0000000000 --- a/libraries/botbuilder-lg/src/README.md +++ /dev/null @@ -1,28 +0,0 @@ -### Introduction -Language Generation tool - -### How to use -cd to microsoft-expression directory, then -``` -npm i -tsc -``` - -Then back to botbuilder-ai directory -``` - yarn install -``` - -Then -``` - import {TemplateEngine} from 'botbuilder-ai'; - let engine = TemplateEngine.fromFiles("lgfilePath"); - let evaled = engine.evaluateTemplate("templateId", {name:"your options"}); -``` - -to get result - -### How to test -``` - npm test -``` diff --git a/libraries/botbuilder-lg/src/activityChecker.ts b/libraries/botbuilder-lg/src/activityChecker.ts deleted file mode 100644 index 1fed950a41..0000000000 --- a/libraries/botbuilder-lg/src/activityChecker.ts +++ /dev/null @@ -1,320 +0,0 @@ -/** - * @module botbuilder-lg - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ - -import { ActivityTypes, ActionTypes } from 'botbuilder-core'; -import { CardFactory } from 'botbuilder-core'; -import { Diagnostic, DiagnosticSeverity } from './diagnostic'; -import { Range } from './range'; -import { Position } from './position'; -import { Evaluator } from './evaluator'; - -/** - * Structure LG result checker. - */ -export class ActivityChecker { - public static readonly genericCardTypeMapping: Map = new Map - ([ - [ 'herocard', CardFactory.contentTypes.heroCard ], - [ 'thumbnailcard', CardFactory.contentTypes.thumbnailCard ], - [ 'audiocard', CardFactory.contentTypes.audioCard ], - [ 'videocard', CardFactory.contentTypes.videoCard ], - [ 'animationcard', CardFactory.contentTypes.animationCard ], - [ 'signincard', CardFactory.contentTypes.signinCard ], - [ 'oauthcard', CardFactory.contentTypes.oauthCard ], - [ 'receiptcard', CardFactory.contentTypes.receiptCard ], - ]); - - public static readonly activityProperties: string[] = ['type','id','timestamp','localTimestamp','localTimezone','callerId', - 'serviceUrl','channelId','from','conversation','recipient','textFormat','attachmentLayout','membersAdded', - 'membersRemoved','reactionsAdded','reactionsRemoved','topicName','historyDisclosed','locale','text','speak', - 'inputHint','summary','suggestedActions','attachments','entities','channelData','action','replyToId','label', - 'valueType','value','name','typrelatesToe','code','expiration','importance','deliveryMode','listenFor', - 'textHighlights','semanticAction']; - - public static readonly cardActionProperties: string[] = ['type','title','image','text','displayText','value','channelData']; - - /** - * check the LG result before generate an Activity. - * @param lgResult lg output. - * @returns Diagnostic list. - */ - public static check(lgResult: any): Diagnostic[] { - if (lgResult === undefined) { - return [this.buildDiagnostic('LG output is empty', false)]; - } - - if (typeof lgResult === 'string') { - if (!lgResult.startsWith('{') || !lgResult.endsWith('}')) { - return [this.buildDiagnostic('LG output is not a json object, and will fallback to string format.', false)]; - } - - let lgStructuredResult: any = undefined; - - try { - lgStructuredResult = JSON.parse(lgResult); - } catch (error) { - return [this.buildDiagnostic('LG output is not a json object, and will fallback to string format.', false)]; - } - - return this.checkStructuredResult(lgStructuredResult); - } else { - return this.checkStructuredResult(lgResult); - } - } - - public static checkStructuredResult(input: any): Diagnostic[] { - const result: Diagnostic[] = []; - const type: string = this.getStructureType(input); - if (ActivityChecker.genericCardTypeMapping.has(type) || type === 'attachment') { - result.push(...this.checkAttachment(input)); - } else if (type === 'activity') { - result.push(...this.checkActivity(input)); - } else { - const diagnosticMessage: string = (type === undefined || type === '') ? - `'${ Evaluator.LGType }' does not exist in lg output json object.` - : `Type '${ type }' is not supported currently.`; - result.push(this.buildDiagnostic(diagnosticMessage)); - } - - return result; - } - - private static checkActivity(input: any): Diagnostic[] { - const result: Diagnostic[] = []; - let activityType: string = undefined; - if ('type' in input) { - activityType = input['type'].toString().trim(); - } - - result.push(...this.checkActivityType(activityType)); - result.push(...this.checkActivityPropertyName(input)); - result.push(...this.checkActivityProperties(input)); - - return result; - } - - private static checkActivityType(activityType: string): Diagnostic[] { - if (activityType !== undefined) { - if (!Object.values(ActivityTypes).map((u: string): string => u.toLowerCase()).includes(activityType.toLowerCase())) { - return [this.buildDiagnostic(`'${ activityType }' is not a valid activity type.`)]; - } - } - return []; - } - - private static checkActivityPropertyName(input: any): Diagnostic[] { - const invalidProperties: string[] = []; - for (const property of Object.keys(input)) { - if (property === Evaluator.LGType) { - continue; - } - if (!ActivityChecker.activityProperties.map((u: string): string => u.toLowerCase()).includes(property.toLowerCase())) { - invalidProperties.push(property); - } - } - if (invalidProperties.length > 0) { - return [this.buildDiagnostic(`'${ invalidProperties.join(',') }' not support in Activity.`, false)]; - } - - return []; - } - - private static checkActivityProperties(input: any): Diagnostic[] { - const result: Diagnostic[] = []; - for (const key of Object.keys(input)) { - const property: string = key.trim(); - const value: any = input[key]; - - switch (property.toLowerCase()) { - case 'attachments': - result.push(...this.checkAttachments(value)); - break; - case 'suggestedactions': - result.push(...this.checkSuggestions(value)); - break; - default: - break; - } - } - - return result; - } - - private static checkSuggestions(value: any): Diagnostic[] { - const actions: any[] = this.normalizedToList(value); - return this.checkCardActions(actions); - } - - private static checkButtons(value: any): Diagnostic[] { - const actions: any[] = this.normalizedToList(value); - return this.checkCardActions(actions); - } - - private static checkCardActions(actions: any[]): Diagnostic[] { - const result: Diagnostic[] = []; - actions.forEach((u: any): void => { result.push(...this.checkCardAction(u)); }); - return result; - } - - private static checkCardAction(value: any): Diagnostic[] { - const result: Diagnostic[] = []; - if (typeof value === 'string') { - return result; - } - - if (typeof value === 'object') { - const type: string = this.getStructureType(value); - if (type !== 'cardaction') { - result.push(this.buildDiagnostic(`'${ type }' is not card action type.`, false)); - } else { - result.push(...this.checkCardActionPropertyName(value)); - if ('type' in value) { - result.push(...this.checkCardActionType(value['type'])); - } - } - } else { - result.push(this.buildDiagnostic(`'${ value }' is not a valid card action format.`, false)); - } - - return result; - } - - - private static checkCardActionPropertyName(input: any): Diagnostic[] { - const invalidProperties: string[] = []; - for (const property of Object.keys(input)) { - if (property === Evaluator.LGType) { - continue; - } - if (!ActivityChecker.cardActionProperties.map((u: string): string => u.toLowerCase()).includes(property.toLowerCase())) { - invalidProperties.push(property); - } - } - if (invalidProperties.length > 0) { - return [this.buildDiagnostic(`'${ invalidProperties.join(',') }' not support in card action.`, false)]; - } - - return []; - } - - private static checkCardActionType(cardActionType: string): Diagnostic[] { - const result: Diagnostic[] = []; - if (!cardActionType) { - return result; - } - - if (!Object.values(ActionTypes).map((u: string): string => u.toLowerCase()).includes(cardActionType.toLowerCase())) { - return [this.buildDiagnostic(`'${ cardActionType }' is not a valid card action type.`)]; - } - - return result; - } - - private static checkAttachments(value: any): Diagnostic[] { - const result: Diagnostic[] = []; - const attachmentsJsonList: any[] = this.normalizedToList(value); - - for (const attachmentsJson of attachmentsJsonList) { - if (typeof attachmentsJson === 'object') { - result.push(...this.checkAttachment(attachmentsJson)); - } - } - - return result; - } - - private static checkAttachment(value: any): Diagnostic[] { - const result: Diagnostic[] = []; - const type: string = this.getStructureType(value); - if (ActivityChecker.genericCardTypeMapping.has(type)) { - result.push(...this.checkCardAttachment(value)); - } else if (type === 'adaptivecard') { - // TODO - // check adaptivecard format - } else if (type === 'attachment') { - // TODO - // Check attachment format - } else { - result.push(this.buildDiagnostic(`'${ type }' is not an attachment type.`, false)); - } - - return result; - } - - private static checkCardAttachment(input: any): Diagnostic[] { - const result: Diagnostic[] = []; - for (const key of Object.keys(input)) { - const property: string = key.trim().toLowerCase(); - const value: any = input[key]; - - switch (property) { - case 'buttons': - result.push(...this.checkButtons(value)); - break; - case 'autostart': - case 'shareable': - case 'autoloop': - const boolValue: boolean = this.getValidBooleanValue(value.toString()); - if (boolValue === undefined) { - result.push(this.buildDiagnostic(`'${ value.toString() }' is not a boolean value.`)); - } - break; - default: - break; - } - } - - return result; - } - - private static getStructureType(input: any): string { - let result = ''; - - if (input !== undefined) { - if (Evaluator.LGType in input) { - result = input[Evaluator.LGType].toString(); - } else if ('type' in input) { - // Adaptive card type - result = input['type'].toString(); - } - } - - return result.trim().toLowerCase(); - } - - - private static getValidBooleanValue(boolValue: string): boolean{ - if (boolValue.toLowerCase() === 'true') - { - return true; - } - else if (boolValue.toLowerCase() === 'false') - { - return false; - } - - return undefined; - } - - private static buildDiagnostic(message: string, isError: boolean = true): Diagnostic { - message = message === undefined ? '' : message; - const emptyRange: Range = new Range(new Position(0, 0), new Position(0, 0)); - return isError ? new Diagnostic(emptyRange, message, DiagnosticSeverity.Error) - : new Diagnostic(emptyRange, message, DiagnosticSeverity.Warning); - } - - private static normalizedToList(item: any): any[] { - if (item === undefined) { - return []; - } else if (Array.isArray(item)) { - return item; - } else { - return [item]; - } - } -} \ No newline at end of file diff --git a/libraries/botbuilder-lg/src/activityFactory.ts b/libraries/botbuilder-lg/src/activityFactory.ts deleted file mode 100644 index 4b90c5bc02..0000000000 --- a/libraries/botbuilder-lg/src/activityFactory.ts +++ /dev/null @@ -1,350 +0,0 @@ -/** - * @module botbuilder-lg - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ - -import { Activity, SuggestedActions, Attachment, ActivityTypes, ActionTypes, CardAction } from 'botframework-schema'; -import { MessageFactory, CardFactory } from 'botbuilder-core'; -import { Diagnostic, DiagnosticSeverity } from './diagnostic'; -import { ActivityChecker } from './activityChecker'; -import { Evaluator } from './evaluator'; - -/** - * The ActivityFactory - * to generate text and then uses simple markdown semantics like chatdown to create Activity. - */ -export class ActivityFactory { - private static adaptiveCardType: string = CardFactory.contentTypes.adaptiveCard; - - /** - * Generate the activity. - * @param lgResult string result from languageGenerator. - */ - public static createActivity(lgResult: any): Partial { - const diagnostics: Diagnostic[] = ActivityChecker.check(lgResult); - const errors: Diagnostic[] = diagnostics.filter((u: Diagnostic): boolean => u.severity === DiagnosticSeverity.Error); - if (errors !== undefined && errors.length > 0) { - throw new Error(`${ errors.join('\n') }`); - } - - if (typeof lgResult === 'string') { - const structuredLGResult: any = this.parseStructuredLGResult(lgResult.trim()); - return structuredLGResult === undefined ? - this.buildActivityFromText(lgResult.trim()) - :this.buildActivityFromLGStructuredResult(lgResult); - } - - return this.buildActivityFromLGStructuredResult(lgResult); - } - - /** - * Given a lg result, create a text activity. This method will create a MessageActivity from text. - * @param text lg text output. - */ - private static buildActivityFromText(text: string): Partial { - return MessageFactory.text(text, text); - } - - /** - * Given a structured lg result, create an activity. This method will create an MessageActivity from object - * @param lgValue lg output. - */ - private static buildActivityFromLGStructuredResult(lgValue: any): Partial { - let activity: Partial = {}; - - const type: string = this.getStructureType(lgValue); - if (ActivityChecker.genericCardTypeMapping.has(type) || type === 'attachment') { - activity = MessageFactory.attachment(this.getAttachment(lgValue)); - } else if (type === 'activity') { - activity = this.buildActivity(lgValue); - } - - return activity; - } - - private static buildActivity(messageValue: any): Partial { - let activity: Partial = { type: ActivityTypes.Message }; - for (const key of Object.keys(messageValue)) { - const property: string = key.trim(); - if (property === Evaluator.LGType) { - continue; - } - - const value: any = messageValue[key]; - - switch (property.toLowerCase()) { - case 'attachments': - activity.attachments = this.getAttachments(value); - break; - case 'suggestedactions': - activity.suggestedActions = this.getSuggestions(value); - break; - default: - var properties = ActivityChecker.activityProperties.map((u: string): string => u.toLowerCase()); - if (properties.includes(property.toLowerCase())) - { - var realPropertyName = ActivityChecker.activityProperties[properties.indexOf(property.toLowerCase())]; - activity[realPropertyName] = value; - } else { - activity[property.toLowerCase()] = value; - } - break; - } - } - - return activity; - } - - private static getSuggestions(suggestionsValue: any): SuggestedActions { - const actions: any[] = this.normalizedToList(suggestionsValue); - - const suggestedActions: SuggestedActions = { - actions : this.getCardActions(actions), - to: [] - }; - - return suggestedActions; - } - - private static getButtons(buttonsValue: any): CardAction[] { - const actions: any[] = this.normalizedToList(buttonsValue); - return this.getCardActions(actions); - } - - private static getCardActions(actions: any[]): CardAction[] { - return actions.map((u: any): CardAction => this.getCardAction(u)); - } - - private static getCardAction(action: any): CardAction - { - let cardAction: CardAction; - if (typeof action === 'string') { - cardAction = { type: ActionTypes.ImBack, value: action, title: action, channelData: undefined }; - } else { - const type: string = this.getStructureType(action); - cardAction = { - type: ActionTypes.ImBack, - title: '', - value: '' - }; - - if (type === 'cardaction') { - for (const key of Object.keys(action)) { - const property: string = key.trim(); - if (property === Evaluator.LGType) { - continue; - } - - const value: any = action[key]; - - switch (property.toLowerCase()) { - case 'displaytext': - cardAction.displayText = value; - break; - case 'channeldata': - cardAction.channelData = value; - break; - default: - cardAction[property.toLowerCase()] = value; - break; - } - } - } - } - - return cardAction; - } - - - private static getStructureType(input: any): string { - let result = ''; - - if (input && typeof input === 'object') { - if (Evaluator.LGType in input) { - result = input[Evaluator.LGType].toString(); - } else if ('type' in input) { - // Adaptive card type - result = input['type'].toString(); - } - } - - return result.trim().toLowerCase(); - } - - private static getAttachments(input: any): Attachment[] { - const attachments: Attachment[] = []; - const attachmentsJsonList: any[] = this.normalizedToList(input); - - for (const attachmentsJson of attachmentsJsonList) { - if (typeof attachmentsJson === 'object') { - attachments.push(this.getAttachment(attachmentsJson)); - } - } - - return attachments; - } - - private static getAttachment(input: any): Attachment { - let attachment: Attachment = { - contentType: '' - }; - const type: string = this.getStructureType(input); - if (ActivityChecker.genericCardTypeMapping.has(type)) { - attachment = this.getCardAttachment(ActivityChecker.genericCardTypeMapping.get(type), input); - } else if (type === 'adaptivecard') { - attachment = CardFactory.adaptiveCard(input); - } else if (type === 'attachment') { - attachment = this.getNormalAttachment(input); - } else { - attachment = {contentType: type, content: input}; - } - - return attachment; - } - - private static getNormalAttachment(input: any): Attachment { - const attachment: Attachment = {contentType:''}; - - for (const key of Object.keys(input)) { - const property: string = key.trim(); - const value: any = input[key]; - - switch (property.toLowerCase()) { - case 'contenttype': - const type: string = value.toString().toLowerCase(); - if (ActivityChecker.genericCardTypeMapping.has(type)) { - attachment.contentType = ActivityChecker.genericCardTypeMapping.get(type); - } else if (type === 'adaptivecard') { - attachment.contentType = this.adaptiveCardType; - } else { - attachment.contentType = type; - } - break; - case 'contenturl': - attachment.contentUrl = value; - break; - case 'thumbnailurl': - attachment.thumbnailUrl = value; - break; - default: - attachment[property.toLowerCase()] = value; - break; - } - } - - return attachment; - } - - private static getCardAttachment(type: string, input: any): Attachment { - const card: any = {}; - - for (const key of Object.keys(input)) { - const property: string = key.trim().toLowerCase(); - const value: any = input[key]; - - switch (property) { - case 'tap': - card[property] = this.getCardAction(value); - break; - case 'image': - case 'images': - if (type === CardFactory.contentTypes.heroCard || type === CardFactory.contentTypes.thumbnailCard) { - if (!('images' in card)) { - card['images'] = []; - } - - const imageList: string[] = this.normalizedToList(value).map((u): string => u.toString()); - imageList.forEach( (u): any => card['images'].push({url : u})); - } else { - card['image'] = {url: value.toString()}; - } - break; - case 'media': - if (!('media' in card)) { - card['media'] = []; - } - - const mediaList: string[] = this.normalizedToList(value).map((u): string => u.toString()); - mediaList.forEach( (u): any => card['media'].push({url : u})); - break; - case 'buttons': - if (!('buttons' in card)) { - card['buttons'] = []; - } - - const buttons: any[] = this.getButtons(value); - buttons.forEach( (u): any => card[property].push(u)); - break; - case 'autostart': - case 'shareable': - case 'autoloop': - const boolValue: boolean = this.getValidBooleanValue(value.toString()); - if (boolValue !== undefined) { - card[property] = boolValue; - } - break; - case 'connectionname': - card['connectionName'] = value; - break; - default: - card[property.toLowerCase()] = value; - break; - } - } - - const attachment: Attachment = { - contentType: type, - content: card - }; - - return attachment; - } - - private static getValidBooleanValue(boolValue: string): boolean{ - if (boolValue.toLowerCase() === 'true') - { - return true; - } - else if (boolValue.toLowerCase() === 'false') - { - return false; - } - - return undefined; - } - - private static normalizedToList(item: any): any[] { - if (item === undefined) { - return []; - } else if (Array.isArray(item)) { - return item; - } else { - return [item]; - } - } - - private static parseStructuredLGResult(lgStringResult: string): any - { - let lgStructuredResult: any = undefined; - if (lgStringResult === undefined || lgStringResult === '') { - return undefined; - } - - lgStringResult = lgStringResult.trim(); - - if (lgStringResult === '' || !lgStringResult.startsWith('{') || !lgStringResult.endsWith('}')) { - return undefined; - } - - try { - lgStructuredResult = JSON.parse(lgStringResult); - } catch (error) { - return undefined; - } - - return lgStructuredResult; - } -} \ No newline at end of file diff --git a/libraries/botbuilder-lg/src/analyzer.ts b/libraries/botbuilder-lg/src/analyzer.ts index 139ff77e0d..6ddc158d48 100644 --- a/libraries/botbuilder-lg/src/analyzer.ts +++ b/libraries/botbuilder-lg/src/analyzer.ts @@ -1,4 +1,3 @@ - /** * @module botbuilder-lg */ @@ -6,41 +5,39 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -// tslint:disable-next-line: no-submodule-imports import { AbstractParseTreeVisitor, TerminalNode } from 'antlr4ts/tree'; -import { Expression, ExpressionEngine, ExpressionParserInterface, Extensions } from 'adaptive-expressions'; +import { Expression, ExpressionParserInterface, ExpressionParser } from 'adaptive-expressions'; import { keyBy } from 'lodash'; import { EvaluationTarget } from './evaluationTarget'; import { Evaluator } from './evaluator'; import * as lp from './generated/LGFileParser'; import { LGFileParserVisitor } from './generated/LGFileParserVisitor'; -import { LGTemplate } from './lgTemplate'; -import { LGExtensions } from './lgExtensions'; +import { Template } from './template'; +import { TemplateExtensions } from './templateExtensions'; import { AnalyzerResult } from './analyzerResult'; -import {LGErrors} from './lgErrors'; +import {TemplateErrors} from './templateErrors'; -// tslint:disable-next-line: max-classes-per-file /** - * Analyzer engine. To analyse which variable may be used + * Analyzer engine. To to get the static analyzer results. */ export class Analyzer extends AbstractParseTreeVisitor implements LGFileParserVisitor { /** * Templates. */ - public readonly templates: LGTemplate[]; + public readonly templates: Template[]; - private readonly templateMap: {[name: string]: LGTemplate}; + private readonly templateMap: {[name: string]: Template}; private readonly evalutationTargetStack: EvaluationTarget[] = []; private readonly _expressionParser: ExpressionParserInterface; - public constructor(templates: LGTemplate[], expressionEngine: ExpressionEngine) { + public constructor(templates: Template[], expressionParser: ExpressionParser) { super(); this.templates = templates; - this.templateMap = keyBy(templates, (t: LGTemplate): string => t.name); + this.templateMap = keyBy(templates, (t: Template): string => t.name); - // create an evaluator to leverage it's customized function look up for checking - const evaluator: Evaluator = new Evaluator(this.templates, expressionEngine); - this._expressionParser = evaluator.expressionEngine; + // create an evaluator to leverage its customized function look up for checking + const evaluator: Evaluator = new Evaluator(this.templates, expressionParser); + this._expressionParser = evaluator.expressionParser; } /** @@ -50,11 +47,11 @@ export class Analyzer extends AbstractParseTreeVisitor implement */ public analyzeTemplate(templateName: string): AnalyzerResult { if (!(templateName in this.templateMap)) { - throw new Error(LGErrors.templateNotExist(templateName)); + throw new Error(TemplateErrors.templateNotExist(templateName)); } if (this.evalutationTargetStack.find((u: EvaluationTarget): boolean => u.templateName === templateName) !== undefined) { - throw new Error(`${ LGErrors.loopDetected } ${ this.evalutationTargetStack.reverse() + throw new Error(`${ TemplateErrors.loopDetected } ${ this.evalutationTargetStack.reverse() .map((u: EvaluationTarget): string => u.templateName) .join(' => ') }`); } @@ -117,8 +114,8 @@ export class Analyzer extends AbstractParseTreeVisitor implement const values = ctx.keyValueStructureValue(); for (const value of values) { - if (this.isPureExpression(value).hasExpr) { - result.union(this.analyzeExpression(this.isPureExpression(value).expression)); + if (TemplateExtensions.isPureExpression(value).hasExpr) { + result.union(this.analyzeExpression(TemplateExtensions.isPureExpression(value).expression)); } else { const exprs = value.EXPRESSION_IN_STRUCTURE_BODY(); for (const expr of exprs) { @@ -201,10 +198,10 @@ export class Analyzer extends AbstractParseTreeVisitor implement private analyzeExpression(exp: string): AnalyzerResult { const result: AnalyzerResult = new AnalyzerResult(); - exp = LGExtensions.trimExpression(exp); + exp = TemplateExtensions.trimExpression(exp); const parsed: Expression = this._expressionParser.parse(exp); - const references: readonly string[] = Extensions.references(parsed); + const references: readonly string[] = parsed.references(); result.union(new AnalyzerResult(references.slice(), [])); result.union(this.analyzeExpressionDirectly(parsed)); @@ -214,31 +211,4 @@ export class Analyzer extends AbstractParseTreeVisitor implement private currentTarget(): EvaluationTarget { return this.evalutationTargetStack[this.evalutationTargetStack.length - 1]; } - - public isPureExpression(ctx: lp.KeyValueStructureValueContext): {hasExpr: boolean; expression: string | undefined} { - let expression = ctx.text; - let hasExpr = false; - for (const node of ctx.children) { - switch ((node as TerminalNode).symbol.type) { - case (lp.LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY): - return {hasExpr, expression}; - case (lp.LGFileParser.EXPRESSION_IN_STRUCTURE_BODY): - if (hasExpr) { - return {hasExpr: false, expression: expression}; - } - - hasExpr = true; - expression = node.text; - break; - default: - if (node !== undefined && node.text !== '' && node.text !== ' ') { - return {hasExpr: false, expression: expression}; - } - - break; - } - } - - return {hasExpr: hasExpr, expression: expression}; - } } \ No newline at end of file diff --git a/libraries/botbuilder-lg/src/customizedMemory.ts b/libraries/botbuilder-lg/src/customizedMemory.ts index b638ccb1d1..e4693e7e7e 100644 --- a/libraries/botbuilder-lg/src/customizedMemory.ts +++ b/libraries/botbuilder-lg/src/customizedMemory.ts @@ -25,7 +25,7 @@ export class CustomizedMemory implements MemoryInterface { */ public localMemory: MemoryInterface; - public constructor(scope?: any, localMemory: MemoryInterface = undefined) { + public constructor(scope?: any, localMemory?: MemoryInterface) { this.globalMemory = !scope ? undefined : SimpleObjectMemory.wrap(scope); this.localMemory = localMemory; } diff --git a/libraries/botbuilder-lg/src/diagnostic.ts b/libraries/botbuilder-lg/src/diagnostic.ts index f01bbcf259..c7cfda2386 100644 --- a/libraries/botbuilder-lg/src/diagnostic.ts +++ b/libraries/botbuilder-lg/src/diagnostic.ts @@ -32,8 +32,8 @@ export class Diagnostic { range: Range, message: string, severity: DiagnosticSeverity = DiagnosticSeverity.Error, - source: string = undefined, - code: string = undefined) { + source?: string , + code?: string) { this.message = message; this.range = range; this.severity = severity; diff --git a/libraries/botbuilder-lg/src/errorListener.ts b/libraries/botbuilder-lg/src/errorListener.ts index a801fcab54..8e64765ab7 100644 --- a/libraries/botbuilder-lg/src/errorListener.ts +++ b/libraries/botbuilder-lg/src/errorListener.ts @@ -7,12 +7,11 @@ */ import { ANTLRErrorListener, RecognitionException, Recognizer } from 'antlr4ts'; import { Diagnostic, DiagnosticSeverity } from './diagnostic'; -import { LGException } from './lgException'; +import { TemplateException } from './templateException'; import { Position } from './position'; import { Range } from './range'; -import { LGErrors } from './lgErrors'; +import { TemplateErrors } from './templateErrors'; -// tslint:disable-next-line: completed-docs /** * LG parser error listener. */ @@ -27,16 +26,15 @@ export class ErrorListener implements ANTLRErrorListener { offendingSymbol: any, line: number, charPositionInLine: number, + // eslint-disable-next-line @typescript-eslint/no-unused-vars msg: string, // eslint-disable-next-line @typescript-eslint/no-unused-vars e: RecognitionException | undefined): void { const startPosition: Position = new Position(line, charPositionInLine); - // tslint:disable-next-line: max-line-length - // tslint:disable-next-line: restrict-plus-operands const stopPosition: Position = new Position(line, charPositionInLine + offendingSymbol.stopIndex - offendingSymbol.startIndex + 1); const range: Range = new Range(startPosition, stopPosition); - const diagnostic: Diagnostic = new Diagnostic(range, LGErrors.syntaxError, DiagnosticSeverity.Error, this.source); + const diagnostic: Diagnostic = new Diagnostic(range, TemplateErrors.syntaxError, DiagnosticSeverity.Error, this.source); - throw new LGException(diagnostic.toString(), [diagnostic]); + throw new TemplateException(diagnostic.toString(), [diagnostic]); } } diff --git a/libraries/botbuilder-lg/src/evaluationTarget.ts b/libraries/botbuilder-lg/src/evaluationTarget.ts index 43775683df..00c8d54b2f 100644 --- a/libraries/botbuilder-lg/src/evaluationTarget.ts +++ b/libraries/botbuilder-lg/src/evaluationTarget.ts @@ -27,7 +27,7 @@ export class EvaluationTarget { public scope: any; /** - * The children template that this template has evaluated currently. + * The children templates that this template has evaluated currently. */ public evaluatedChildren: Map; public constructor(templateName: string, scope: any) { @@ -38,7 +38,7 @@ export class EvaluationTarget { /** * Get current instance id. If two target has the same Id, - * we can say they have the same template evaluation. + * we can say they have the same template evaluation result. * @returns id. */ public getId(): string { diff --git a/libraries/botbuilder-lg/src/evaluator.ts b/libraries/botbuilder-lg/src/evaluator.ts index a8022a2ac8..7ac0212d6a 100644 --- a/libraries/botbuilder-lg/src/evaluator.ts +++ b/libraries/botbuilder-lg/src/evaluator.ts @@ -5,62 +5,60 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -// tslint:disable-next-line: no-submodule-imports import { AbstractParseTreeVisitor, TerminalNode } from 'antlr4ts/tree'; import { ParserRuleContext } from 'antlr4ts/ParserRuleContext'; -import { ExpressionFunctions, Constant, EvaluatorLookup, Expression, ExpressionEngine, ExpressionEvaluator, ExpressionType, ReturnType, SimpleObjectMemory } from 'adaptive-expressions'; +import { ExpressionFunctions, Constant, EvaluatorLookup, Expression, ExpressionParser, ExpressionEvaluator, ExpressionType, ReturnType, SimpleObjectMemory} from 'adaptive-expressions'; import { keyBy } from 'lodash'; import { CustomizedMemory } from './customizedMemory'; import { EvaluationTarget } from './evaluationTarget'; import * as lp from './generated/LGFileParser'; import { LGFileParserVisitor } from './generated/LGFileParserVisitor'; -import { LGTemplate } from './lgTemplate'; +import { Template } from './template'; import * as path from 'path'; import * as fs from 'fs'; -import { LGExtensions } from './lgExtensions'; -import { LGErrors } from './lgErrors'; +import { TemplateExtensions } from './templateExtensions'; +import { TemplateErrors } from './templateErrors'; /** - * Evaluation tuntime engine + * Evaluation runtime engine */ -// tslint:disable-next-line: max-classes-per-file export class Evaluator extends AbstractParseTreeVisitor implements LGFileParserVisitor { /** * Templates. */ - public readonly templates: LGTemplate[]; + public readonly templates: Template[]; /** - * Expression engine. + * Expression parser. */ - public readonly expressionEngine: ExpressionEngine; + public readonly expressionParser: ExpressionParser; /** * TemplateMap. */ - public readonly templateMap: { [name: string]: LGTemplate }; + public readonly templateMap: { [name: string]: Template }; private readonly evaluationTargetStack: EvaluationTarget[] = []; private readonly strictMode: boolean; // to support broswer, use look-ahead replace look-behind - // original:/(? t.name); + this.templateMap = keyBy(templates, (t: Template): string => t.name); this.strictMode = strictMode; - // generate a new customzied expression engine by injecting the template as functions - this.expressionEngine = new ExpressionEngine(this.customizedEvaluatorLookup(expressionEngine.EvaluatorLookup)); + // generate a new customzied expression parser by injecting the templates as functions + this.expressionParser = new ExpressionParser(this.customizedEvaluatorLookup(expressionParser.EvaluatorLookup)); } public static wrappedRegExSplit(inputString: string, regex: RegExp): string[] { @@ -79,11 +77,11 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa ({reExecute, pureTemplateName: templateName} = this.parseTemplateName(inputTemplateName)); if (!(templateName in this.templateMap)) { - throw new Error(LGErrors.templateNotExist(templateName)); + throw new Error(TemplateErrors.templateNotExist(templateName)); } - if (this.evaluationTargetStack.find((u: EvaluationTarget): boolean => u.templateName === templateName) !== undefined) { - throw new Error(`${ LGErrors.loopDetected } ${ this.evaluationTargetStack.reverse() + if (this.evaluationTargetStack.some((u: EvaluationTarget): boolean => u.templateName === templateName)) { + throw new Error(`${ TemplateErrors.loopDetected } ${ this.evaluationTargetStack.reverse() .map((u: EvaluationTarget): string => u.templateName) .join(' => ') }`); } @@ -150,14 +148,14 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa const result = []; for(const item of values) { - if (Evaluator.isPureExpression(item).hasExpr) { - result.push(this.evalExpression(Evaluator.isPureExpression(item).expression, ctx)); + if (TemplateExtensions.isPureExpression(item).hasExpr) { + result.push(this.evalExpression(TemplateExtensions.isPureExpression(item).expression, ctx)); } else { let itemStringResult = ''; for(const node of item.children) { switch ((node as TerminalNode).symbol.type) { case (lp.LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY): - itemStringResult += this.evalEscape(node.text); + itemStringResult += TemplateExtensions.evalEscape(node.text.replace(/\\\|/g, '|')); break; case (lp.LGFileParser.EXPRESSION_IN_STRUCTURE_BODY): @@ -193,7 +191,6 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa public visitNormalTemplateBody(ctx: lp.NormalTemplateBodyContext): any { const normalTemplateStrs: lp.TemplateStringContext[] = ctx.templateString(); - // tslint:disable-next-line: insecure-random const randomNumber: number = Math.floor(Math.random() * normalTemplateStrs.length); return this.visit(normalTemplateStrs[randomNumber].normalTemplateString()); @@ -211,7 +208,7 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa } public visitNormalTemplateString(ctx: lp.NormalTemplateStringContext): string { - const prefixErrorMsg = LGExtensions.getPrefixErrorMessage(ctx); + const prefixErrorMsg = TemplateExtensions.getPrefixErrorMessage(ctx); const result: any[] = []; for (const node of ctx.children) { const innerNode: TerminalNode = node as TerminalNode; @@ -221,7 +218,7 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa case lp.LGFileParser.DASH: break; case lp.LGFileParser.ESCAPE_CHARACTER: - result.push(this.evalEscape(innerNode.text)); + result.push(TemplateExtensions.evalEscape(innerNode.text)); break; case lp.LGFileParser.EXPRESSION: result.push(this.evalExpression(innerNode.text, ctx, prefixErrorMsg)); @@ -249,8 +246,8 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa public constructScope(inputTemplateName: string, args: any[]): any { var templateName = this.parseTemplateName(inputTemplateName).pureTemplateName; - if (!this.templateMap[templateName]) { - throw new Error(LGErrors.templateNotExist(templateName)); + if (!(templateName in this.templateMap)) { + throw new Error(TemplateErrors.templateNotExist(templateName)); } const parameters: string[] = this.templateMap[templateName].parameters; @@ -265,7 +262,7 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa parameters.map((e: string, i: number): void => newScope[e] = args[i]); const memory = currentScope as CustomizedMemory; if (!memory) { - throw new Error(LGErrors.invalidMemory); + throw new Error(TemplateErrors.invalidMemory); } return new CustomizedMemory(memory.globalMemory, SimpleObjectMemory.wrap(newScope)); @@ -335,11 +332,11 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa return false; } - private evalExpressionInCondition(exp: string, context: ParserRuleContext = undefined, errorPrefix: string = ''): boolean { - exp = LGExtensions.trimExpression(exp); + private evalExpressionInCondition(exp: string, context?: ParserRuleContext, errorPrefix: string = ''): boolean { + exp = TemplateExtensions.trimExpression(exp); let result: any; let error: string; - ({value: result, error: error} = this.evalByExpressionEngine(exp, this.currentTarget().scope)); + ({value: result, error: error} = this.evalByAdaptiveExpression(exp, this.currentTarget().scope)); if (this.strictMode && (error || !result)) { @@ -352,12 +349,12 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa } else if (!result) { - childErrorMsg += LGErrors.nullExpression(exp); + childErrorMsg += TemplateErrors.nullExpression(exp); } if (context) { - errorMsg += LGErrors.errorExpression(context.text, this.currentTarget().templateName, errorPrefix); + errorMsg += TemplateErrors.errorExpression(context.text, this.currentTarget().templateName, errorPrefix); } if (this.evaluationTargetStack.length > 0) @@ -374,12 +371,12 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa return true; } - private evalExpression(exp: string, context: ParserRuleContext = undefined, errorPrefix: string = ''): any + private evalExpression(exp: string, context?: ParserRuleContext, errorPrefix: string = ''): any { - exp = LGExtensions.trimExpression(exp); + exp = TemplateExtensions.trimExpression(exp); let result: any; let error: string; - ({value: result, error: error} = this.evalByExpressionEngine(exp, this.currentTarget().scope)); + ({value: result, error: error} = this.evalByAdaptiveExpression(exp, this.currentTarget().scope)); if (error || (result === undefined && this.strictMode)) { @@ -392,12 +389,12 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa } else if (result === undefined) { - childErrorMsg += LGErrors.nullExpression(exp); + childErrorMsg += TemplateErrors.nullExpression(exp); } if (context) { - errorMsg += LGErrors.errorExpression(context.text, this.currentTarget().templateName, errorPrefix); + errorMsg += TemplateErrors.errorExpression(context.text, this.currentTarget().templateName, errorPrefix); } if (this.evaluationTargetStack.length > 0) @@ -415,50 +412,26 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa return result; } - public static isPureExpression(ctx: lp.KeyValueStructureValueContext): {hasExpr: boolean; expression: string | undefined} { - let expression = ctx.text; - let hasExpr = false; - for (const node of ctx.children) { - switch ((node as TerminalNode).symbol.type) { - case (lp.LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY): - return {hasExpr, expression}; - case (lp.LGFileParser.EXPRESSION_IN_STRUCTURE_BODY): - if (hasExpr) { - return {hasExpr: false, expression: expression}; - } - - hasExpr = true; - expression = node.text; - break; - default: - if (node !== undefined && node.text !== '' && node.text !== ' ') { - return {hasExpr: false, expression: expression}; - } - - break; - } - } - - return {hasExpr: hasExpr, expression: expression}; - } - - private evalByExpressionEngine(exp: string, scope: any): { value: any; error: string } { - const parse: Expression = this.expressionEngine.parse(exp); + private evalByAdaptiveExpression(exp: string, scope: any): { value: any; error: string } { + const parse: Expression = this.expressionParser.parse(exp); return parse.tryEvaluate(scope); } // Genearte a new lookup function based on one lookup function private readonly customizedEvaluatorLookup = (baseLookup: EvaluatorLookup): any => (name: string): any => { - const prebuiltPrefix = 'prebuilt.'; + const standardFunction = baseLookup(name); - if (name.startsWith(prebuiltPrefix)) { - return baseLookup(name.substring(prebuiltPrefix.length)); + if (standardFunction !== undefined) { + return standardFunction; + } + + if (name.startsWith('lg.')) { + name = name.substring(3); } var templateName = this.parseTemplateName(name).pureTemplateName; if (templateName in this.templateMap) { - // tslint:disable-next-line: max-line-length return new ExpressionEvaluator(templateName, ExpressionFunctions.apply(this.templateEvaluator(name)), ReturnType.Object, this.validTemplateReference); } @@ -482,23 +455,7 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa return new ExpressionEvaluator(Evaluator.isTemplateFunctionName, ExpressionFunctions.apply(this.isTemplate()), ReturnType.Boolean, ExpressionFunctions.validateUnaryString); } - return baseLookup(name); - } - - private evalEscape(exp: string): string { - const validCharactersDict: any = { - '\\r': '\r', - '\\n': '\n', - '\\t': '\t' - }; - - return exp.replace(/\\[^\r\n]?/g, (sub: string): string => { - if (sub in validCharactersDict) { - return validCharactersDict[sub]; - } else { - return sub.substr(1); - } - }); + return undefined; } private readonly isTemplate = (): any => (args: readonly any[]): boolean => { @@ -507,12 +464,12 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa } private readonly fromFile = (): any => (args: readonly any[]): any => { - const filePath: string = LGExtensions.normalizePath(args[0].toString()); + const filePath: string = TemplateExtensions.normalizePath(args[0].toString()); const resourcePath: string = this.getResourcePath(filePath); const stringContent = fs.readFileSync(resourcePath, 'utf-8'); const result = this.wrappedEvalTextContainsExpression(stringContent, Evaluator.expressionRecognizeReverseRegex); - return this.evalEscape(result); + return TemplateExtensions.evalEscape(result); } private getResourcePath(filePath: string): string { @@ -525,8 +482,8 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa if (inBrowser) { throw new Error('relative path is not support in browser.'); } - const template: LGTemplate = this.templateMap[this.currentTarget().templateName]; - const sourcePath: string = LGExtensions.normalizePath(template.source); + const template: Template = this.templateMap[this.currentTarget().templateName]; + const sourcePath: string = TemplateExtensions.normalizePath(template.source); let baseFolder: string = __dirname; if (path.isAbsolute(sourcePath)) { baseFolder = path.dirname(sourcePath); @@ -561,7 +518,7 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa // Validate return type if (children0.returnType !== ReturnType.Object && children0.returnType !== ReturnType.String) { - throw new Error(LGErrors.errorTemplateNameformat(children0.toString())); + throw new Error(TemplateErrors.errorTemplateNameformat(children0.toString())); } // Validate more if the name is string constant @@ -574,7 +531,7 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa private checkTemplateReference(templateName: string, children: Expression[]): void{ if (!(templateName in this.templateMap)) { - throw new Error(LGErrors.templateNotExist(templateName)); + throw new Error(TemplateErrors.templateNotExist(templateName)); } var expectedArgsCount = this.templateMap[templateName].parameters.length; @@ -582,7 +539,7 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa if (actualArgsCount !== 0 && expectedArgsCount !== actualArgsCount) { - throw new Error(LGErrors.argumentMismatch(templateName, expectedArgsCount, actualArgsCount)); + throw new Error(TemplateErrors.argumentMismatch(templateName, expectedArgsCount, actualArgsCount)); } } @@ -593,18 +550,7 @@ export class Evaluator extends AbstractParseTreeVisitor implements LGFilePa } private readonly validTemplateReference = (expression: Expression): void => { - const templateName: string = expression.type; - - if (!this.templateMap[templateName]) { - throw new Error(`no such template '${ templateName }' to call in ${ expression }`); - } - - const expectedArgsCount: number = this.templateMap[templateName].parameters.length; - const actualArgsCount: number = expression.children.length; - - if (expectedArgsCount !== actualArgsCount) { - throw new Error(LGErrors.argumentMismatch(templateName, expectedArgsCount, actualArgsCount)); - } + return this.checkTemplateReference(expression.type, expression.children); } private parseTemplateName(templateName: string): { reExecute: boolean; pureTemplateName: string } { diff --git a/libraries/botbuilder-lg/src/expander.ts b/libraries/botbuilder-lg/src/expander.ts index 7a4b7a0695..af48044854 100644 --- a/libraries/botbuilder-lg/src/expander.ts +++ b/libraries/botbuilder-lg/src/expander.ts @@ -1,4 +1,3 @@ - /** * @module botbuilder-lg */ @@ -6,22 +5,21 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -// tslint:disable-next-line: no-submodule-imports import { AbstractParseTreeVisitor, TerminalNode } from 'antlr4ts/tree'; import { ParserRuleContext } from 'antlr4ts/ParserRuleContext'; -import { ExpressionFunctions, EvaluatorLookup, Expression, ExpressionEngine, ExpressionEvaluator, ReturnType, SimpleObjectMemory } from 'adaptive-expressions'; +import { ExpressionFunctions, EvaluatorLookup, Expression, ExpressionParser, ExpressionEvaluator, ReturnType, SimpleObjectMemory, ExpressionType, Constant } from 'adaptive-expressions'; import { keyBy } from 'lodash'; import { EvaluationTarget } from './evaluationTarget'; import { Evaluator } from './evaluator'; +import * as path from 'path'; +import * as fs from 'fs'; import * as lp from './generated/LGFileParser'; import { LGFileParserVisitor } from './generated/LGFileParserVisitor'; -import { LGTemplate } from './lgTemplate'; -import { LGExtensions } from './lgExtensions'; +import { Template } from './template'; +import { TemplateExtensions } from './templateExtensions'; import { CustomizedMemory } from './customizedMemory'; -import { LGErrors } from './lgErrors'; +import { TemplateErrors } from './templateErrors'; -// tslint:disable-next-line: max-classes-per-file -// tslint:disable-next-line: completed-docs /** * LG template expander. */ @@ -29,26 +27,26 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi /** * Templates. */ - public readonly templates: LGTemplate[]; + public readonly templates: Template[]; /** * TemplateMap. */ - public readonly templateMap: {[name: string]: LGTemplate}; + public readonly templateMap: {[name: string]: Template}; private readonly evaluationTargetStack: EvaluationTarget[] = []; - private readonly expanderExpressionEngine: ExpressionEngine; - private readonly evaluatorExpressionEngine: ExpressionEngine; + private readonly expanderExpressionParser: ExpressionParser; + private readonly evaluatorExpressionParser: ExpressionParser; private readonly strictMode: boolean; - public constructor(templates: LGTemplate[], expressionEngine: ExpressionEngine, strictMode: boolean = false) { + public constructor(templates: Template[], expressionParser: ExpressionParser, strictMode: boolean = false) { super(); this.templates = templates; - this.templateMap = keyBy(templates, (t: LGTemplate): string => t.name); + this.templateMap = keyBy(templates, (t: Template): string => t.name); this.strictMode = strictMode; - // generate a new customzied expression engine by injecting the template as functions - this.expanderExpressionEngine = new ExpressionEngine(this.customizedEvaluatorLookup(expressionEngine.EvaluatorLookup, true)); - this.evaluatorExpressionEngine = new ExpressionEngine(this.customizedEvaluatorLookup(expressionEngine.EvaluatorLookup, false)); + // generate a new customzied expression parser by injecting the template as functions + this.expanderExpressionParser = new ExpressionParser(this.customizedEvaluatorLookup(expressionParser.EvaluatorLookup, true)); + this.evaluatorExpressionParser = new ExpressionParser(this.customizedEvaluatorLookup(expressionParser.EvaluatorLookup, false)); } /** @@ -59,11 +57,11 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi */ public expandTemplate(templateName: string, scope: any): string[] { if (!(templateName in this.templateMap)) { - throw new Error(LGErrors.templateNotExist(templateName)); + throw new Error(TemplateErrors.templateNotExist(templateName)); } if (this.evaluationTargetStack.find((u: EvaluationTarget): boolean => u.templateName === templateName)) { - throw new Error(`${ LGErrors.loopDetected } ${ this.evaluationTargetStack.reverse() + throw new Error(`${ TemplateErrors.loopDetected } ${ this.evaluationTargetStack.reverse() .map((u: EvaluationTarget): string => u.templateName) .join(' => ') }`); } @@ -114,7 +112,6 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi return undefined; } - // tslint:disable-next-line: cyclomatic-complexity public visitStructuredBody(ctx: lp.StructuredBodyContext): string[] { const templateRefValues: Map = new Map(); const stb: lp.StructuredTemplateBodyContext = ctx.structuredTemplateBody(); @@ -131,20 +128,20 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi if (value.length > 1) { const valueList = []; for (const item of value) { - const id = this.newGuid(); + const id = TemplateExtensions.newGuid(); valueList.push(id); templateRefValues.set(id, item); } - expandedResult.forEach(x => x[property] = valueList); + expandedResult.forEach((x): any[] => x[property] = valueList); } else { - const id = this.newGuid(); - expandedResult.forEach(x => x[property] = id); + const id = TemplateExtensions.newGuid(); + expandedResult.forEach((x): string => x[property] = id); templateRefValues.set(id, value[0]); } } else { const propertyObjects: object[] = []; - this.evalExpression(body.objectStructureLine().text, body.objectStructureLine()).forEach(x => propertyObjects.push(JSON.parse(x))); + this.evalExpression(body.objectStructureLine().text, body.objectStructureLine()).forEach((x): number => propertyObjects.push(JSON.parse(x))); const tempResult = []; for (const res of expandedResult) { for (const propertyObject of propertyObjects) { @@ -189,17 +186,17 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi let result: any[] = []; for (const item of values) { - if (Evaluator.isPureExpression(item).hasExpr) { - result.push(this.evalExpression(Evaluator.isPureExpression(item).expression, ctx)); + if (TemplateExtensions.isPureExpression(item).hasExpr) { + result.push(this.evalExpression(TemplateExtensions.isPureExpression(item).expression, ctx)); } else { let itemStringResult = ['']; for (const node of item.children) { switch ((node as TerminalNode).symbol.type) { case (lp.LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY): - itemStringResult = this.stringArrayConcat(itemStringResult, [this.evalEscape(node.text)]); + itemStringResult = this.stringArrayConcat(itemStringResult, [TemplateExtensions.evalEscape(node.text.replace(/\\\|/g, '|'))]); break; case (lp.LGFileParser.EXPRESSION_IN_STRUCTURE_BODY): - const errorPrefix = `Property '` + ctx.STRUCTURE_IDENTIFIER().text + `':`; + const errorPrefix = `Property '${ ctx.STRUCTURE_IDENTIFIER().text }':`; itemStringResult =this.stringArrayConcat(itemStringResult, this.evalExpression(node.text, ctx, errorPrefix)); break; default: @@ -220,7 +217,7 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi const length: number = switchcaseNodes.length; const switchNode: lp.SwitchCaseRuleContext = switchcaseNodes[0]; const switchExprs: TerminalNode[] = switchNode.switchCaseStat().EXPRESSION(); - const switchErrorPrefix = `Switch '` + switchExprs[0].text + `': `; + const switchErrorPrefix = `Switch '${ switchExprs[0].text }': `; const switchExprResult = this.evalExpression(switchExprs[0].text, switchcaseNodes[0].switchCaseStat(), switchErrorPrefix); let idx = 0; for (const caseNode of switchcaseNodes) { @@ -239,7 +236,7 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi } const caseExprs: TerminalNode[] = caseNode.switchCaseStat().EXPRESSION(); - const caseErrorPrefix = `Case '` + caseExprs[0].text + `': `; + const caseErrorPrefix = `Case '${ caseExprs[0].text }': `; var caseExprResult = this.evalExpression(caseExprs[0].text, caseNode.switchCaseStat(), caseErrorPrefix); //condition: check whether two string array have same elements if (switchExprResult.sort().toString() === caseExprResult.sort().toString()) { @@ -253,7 +250,7 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi } public visitNormalTemplateString(ctx: lp.NormalTemplateStringContext): string[] { - var prefixErrorMsg = LGExtensions.getPrefixErrorMessage(ctx); + var prefixErrorMsg = TemplateExtensions.getPrefixErrorMessage(ctx); let result: string[] = ['']; for (const node of ctx.children) { const innerNode: TerminalNode = node as TerminalNode; @@ -263,7 +260,7 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi case lp.LGFileParser.DASH: break; case lp.LGFileParser.ESCAPE_CHARACTER: - result = this.stringArrayConcat(result, [this.evalEscape(innerNode.text)]); + result = this.stringArrayConcat(result, [TemplateExtensions.evalEscape(innerNode.text)]); break; case lp.LGFileParser.EXPRESSION: { result = this.stringArrayConcat(result, this.evalExpression(innerNode.text, ctx, prefixErrorMsg)); @@ -301,23 +298,6 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi return this.evaluationTargetStack[this.evaluationTargetStack.length - 1]; } - private evalEscape(exp: string): string { - const validCharactersDict: any = { - '\\r': '\r', - '\\n': '\n', - '\\t': '\t', - '\\\\': '\\', - }; - - return exp.replace(/\\[^\r\n]?/g, (sub: string): string => { - if (sub in validCharactersDict) { - return validCharactersDict[sub]; - } else { - return sub.substr(1); - } - }); - } - private evalCondition(condition: lp.IfConditionContext): boolean { const expression: TerminalNode = condition.EXPRESSION()[0]; if (!expression) { @@ -331,11 +311,11 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi return false; } - private evalExpressionInCondition(exp: string, context: ParserRuleContext = undefined, errorPrefix: string = ''): boolean { - exp = LGExtensions.trimExpression(exp); + private evalExpressionInCondition(exp: string, context?: ParserRuleContext, errorPrefix: string = ''): boolean { + exp = TemplateExtensions.trimExpression(exp); let result: any; let error: string; - ({value: result, error: error} = this.evalByExpressionEngine(exp, this.currentTarget().scope)); + ({value: result, error: error} = this.evalByAdaptiveExpression(exp, this.currentTarget().scope)); if (this.strictMode && (error || !result)) { @@ -348,12 +328,12 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi } else if (!result) { - childErrorMsg += LGErrors.nullExpression(exp); + childErrorMsg += TemplateErrors.nullExpression(exp); } if (context) { - errorMsg += LGErrors.errorExpression(context.text, this.currentTarget().templateName, errorPrefix); + errorMsg += TemplateErrors.errorExpression(context.text, this.currentTarget().templateName, errorPrefix); } if (this.evaluationTargetStack.length > 0) @@ -371,10 +351,10 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi } private evalExpression(exp: string, context: ParserRuleContext, errorPrefix: string = ''): string[] { - exp = LGExtensions.trimExpression(exp); + exp = TemplateExtensions.trimExpression(exp); let result: any; let error: string; - ({value: result, error: error} = this.evalByExpressionEngine(exp, this.currentTarget().scope)); + ({value: result, error: error} = this.evalByAdaptiveExpression(exp, this.currentTarget().scope)); if (error || (result === undefined && this.strictMode)) { @@ -387,12 +367,12 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi } else if (result === undefined) { - childErrorMsg += LGErrors.nullExpression(exp); + childErrorMsg += TemplateErrors.nullExpression(exp); } if (context !== undefined) { - errorMsg += LGErrors.errorExpression(context.text, this.currentTarget().templateName, errorPrefix); + errorMsg += TemplateErrors.errorExpression(context.text, this.currentTarget().templateName, errorPrefix); } if (this.evaluationTargetStack.length > 0) @@ -408,15 +388,15 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi if (Array.isArray(result)) { - return result.map(u => u.toString()); + return result.map((u): string => u.toString()); } return [ result.toString() ]; } - private evalByExpressionEngine(exp: string, scope: any): any { - const expanderExpression: Expression = this.expanderExpressionEngine.parse(exp); - const evaluatorExpression: Expression = this.evaluatorExpressionEngine.parse(exp); + private evalByAdaptiveExpression(exp: string, scope: any): any { + const expanderExpression: Expression = this.expanderExpressionParser.parse(exp); + const evaluatorExpression: Expression = this.evaluatorExpressionParser.parse(exp); const parse: Expression = this.reconstructExpression(expanderExpression, evaluatorExpression, false); return parse.tryEvaluate(scope); @@ -433,30 +413,53 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi return result; } - // Genearte a new lookup function based on one lookup function private readonly customizedEvaluatorLookup = (baseLookup: EvaluatorLookup, isExpander: boolean): any => (name: string): ExpressionEvaluator => { - const prebuiltPrefix = 'prebuilt.'; + const standardFunction = baseLookup(name); - if (name.startsWith(prebuiltPrefix)) { - return baseLookup(name.substring(prebuiltPrefix.length)); + if (standardFunction !== undefined) { + return standardFunction; + } + + if (name.startsWith('lg.')) { + name = name.substring(3); } - if (this.templateMap[name]) { + var templateName = this.parseTemplateName(name).pureTemplateName; + if (templateName in this.templateMap) { if (isExpander) { - return new ExpressionEvaluator(name, ExpressionFunctions.apply(this.templateExpander(name)), ReturnType.String, this.validTemplateReference); + return new ExpressionEvaluator(templateName, ExpressionFunctions.apply(this.templateExpander(name)), ReturnType.Object, this.validTemplateReference); } else { - return new ExpressionEvaluator(name, ExpressionFunctions.apply(this.templateEvaluator(name)), ReturnType.String, this.validTemplateReference); + return new ExpressionEvaluator(templateName, ExpressionFunctions.apply(this.templateEvaluator(name)), ReturnType.Object, this.validTemplateReference); } } - return baseLookup(name); + if (name === Evaluator.templateFunctionName) { + return new ExpressionEvaluator(Evaluator.templateFunctionName, ExpressionFunctions.apply(this.templateFunction()), ReturnType.Object, this.validateTemplateFunction); + } + + if (name === Evaluator.fromFileFunctionName) { + return new ExpressionEvaluator(Evaluator.fromFileFunctionName, ExpressionFunctions.apply(this.fromFile()), ReturnType.Object, ExpressionFunctions.validateUnaryString); + } + + if (name === Evaluator.activityAttachmentFunctionName) { + return new ExpressionEvaluator( + Evaluator.activityAttachmentFunctionName, + ExpressionFunctions.apply(this.activityAttachment()), + ReturnType.Object, + (expr): void => ExpressionFunctions.validateOrder(expr, undefined, ReturnType.Object, ReturnType.String)); + } + + if (name === Evaluator.isTemplateFunctionName) { + return new ExpressionEvaluator(Evaluator.isTemplateFunctionName, ExpressionFunctions.apply(this.isTemplate()), ReturnType.Boolean, ExpressionFunctions.validateUnaryString); + } + + return undefined; } private readonly templateEvaluator = (templateName: string): any => (args: readonly any[]): string => { const newScope: any = this.constructScope(templateName, Array.from(args)); const value: string[] = this.expandTemplate(templateName, newScope); - // tslint:disable-next-line: insecure-random const randomNumber: number = Math.floor(Math.random() * value.length); return value[randomNumber]; @@ -468,21 +471,6 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi return this.expandTemplate(templateName, newScope); } - private readonly validTemplateReference = (expression: Expression): void => { - const templateName: string = expression.type; - - if (!this.templateMap[templateName]) { - throw new Error(LGErrors.templateNotExist(templateName)); - } - - const expectedArgsCount: number = this.templateMap[templateName].parameters.length; - const actualArgsCount: number = expression.children.length; - - if (expectedArgsCount !== actualArgsCount) { - throw new Error(LGErrors.argumentMismatch(templateName, expectedArgsCount, actualArgsCount)); - } - } - private reconstructExpression(expanderExpression: Expression, evaluatorExpression: Expression, foundPrebuiltFunction: boolean): Expression { if (this.templateMap[expanderExpression.type]) { if (foundPrebuiltFunction) { @@ -499,13 +487,109 @@ export class Expander extends AbstractParseTreeVisitor implements LGFi return expanderExpression; } - private newGuid(): string { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c: any): string => { - const r: number = Math.random() * 16 | 0; - // tslint:disable-next-line: no-bitwise - const v: number = c === 'x' ? r : (r & 0x3 | 0x8); + private readonly isTemplate = (): any => (args: readonly any[]): boolean => { + const templateName = args[0].toString(); + return templateName in this.templateMap; + } + + private readonly fromFile = (): any => (args: readonly any[]): any => { + const filePath: string = TemplateExtensions.normalizePath(args[0].toString()); + const resourcePath: string = this.getResourcePath(filePath); + const stringContent = fs.readFileSync(resourcePath, 'utf-8'); + + // TODO + return stringContent; + //const result = this.wrappedEvalTextContainsExpression(stringContent, Evaluator.expressionRecognizeReverseRegex); + //return TemplateExtensions.evalEscape(result); + } + + private getResourcePath(filePath: string): string { + let resourcePath: string; + if (path.isAbsolute(filePath)) { + resourcePath = filePath; + } else { + // relative path is not support in broswer environment + const inBrowser: boolean = typeof window !== 'undefined'; + if (inBrowser) { + throw new Error('relative path is not support in browser.'); + } + const template: Template = this.templateMap[this.currentTarget().templateName]; + const sourcePath: string = TemplateExtensions.normalizePath(template.source); + let baseFolder: string = __dirname; + if (path.isAbsolute(sourcePath)) { + baseFolder = path.dirname(sourcePath); + } + + resourcePath = path.join(baseFolder, filePath); + } - return v.toString(16); - }); + return resourcePath; + } + + private readonly activityAttachment = (): any => (args: readonly any[]): any => { + return { + [Evaluator.LGType]: 'attachment', + contenttype: args[1].toString(), + content: args[0] + }; + } + + private readonly templateFunction = (): any => (args: readonly any[]): any => { + const templateName: string = args[0]; + const newScope: any = this.constructScope(templateName, args.slice(1)); + + const value: string[] = this.expandTemplate(templateName, newScope); + const randomNumber: number = Math.floor(Math.random() * value.length); + + return value[randomNumber]; + } + + private readonly validateTemplateFunction = (expression: Expression): void => { + + ExpressionFunctions.validateAtLeastOne(expression); + + const children0: Expression = expression.children[0]; + + // Validate return type + if (children0.returnType !== ReturnType.Object && children0.returnType !== ReturnType.String) { + throw new Error(TemplateErrors.errorTemplateNameformat(children0.toString())); + } + + // Validate more if the name is string constant + if (children0.type === ExpressionType.Constant) { + const templateName: string = (children0 as Constant).value; + this.checkTemplateReference(templateName, expression.children.slice(1)); + } + } + + private checkTemplateReference(templateName: string, children: Expression[]): void{ + if (!(templateName in this.templateMap)) + { + throw new Error(TemplateErrors.templateNotExist(templateName)); + } + + var expectedArgsCount = this.templateMap[templateName].parameters.length; + var actualArgsCount = children.length; + + if (actualArgsCount !== 0 && expectedArgsCount !== actualArgsCount) + { + throw new Error(TemplateErrors.argumentMismatch(templateName, expectedArgsCount, actualArgsCount)); + } + } + + private readonly validTemplateReference = (expression: Expression): void => { + return this.checkTemplateReference(expression.type, expression.children); + } + + private parseTemplateName(templateName: string): { reExecute: boolean; pureTemplateName: string } { + if (!templateName) { + throw new Error('template name is empty.'); + } + + if (templateName.endsWith(Evaluator.ReExecuteSuffix)) { + return {reExecute:true, pureTemplateName: templateName.substr(0, templateName.length - Evaluator.ReExecuteSuffix.length)}; + } else { + return {reExecute:false, pureTemplateName: templateName}; + } } } diff --git a/libraries/botbuilder-lg/src/extractor.ts b/libraries/botbuilder-lg/src/extractor.ts index b6fe47b2ad..c759d1190e 100644 --- a/libraries/botbuilder-lg/src/extractor.ts +++ b/libraries/botbuilder-lg/src/extractor.ts @@ -6,29 +6,27 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -// tslint:disable-next-line: no-submodule-imports import { AbstractParseTreeVisitor, TerminalNode } from 'antlr4ts/tree'; import { keyBy } from 'lodash'; import * as lp from './generated/LGFileParser'; import { LGFileParserVisitor } from './generated/LGFileParserVisitor'; -import { LGTemplate } from './lgTemplate'; +import { Template } from './template'; -// tslint:disable-next-line: completed-docs /** * Lg template extracter. */ export class Extractor extends AbstractParseTreeVisitor> implements LGFileParserVisitor> { - public readonly templates: LGTemplate[]; - public readonly templateMap: {[name: string]: LGTemplate}; - public constructor(templates: LGTemplate[]) { + public readonly templates: Template[]; + public readonly templateMap: {[name: string]: Template}; + public constructor(templates: Template[]) { super(); this.templates = templates; - this.templateMap = keyBy(templates, (t: LGTemplate): string => t.name); + this.templateMap = keyBy(templates, (t: Template): string => t.name); } public extract(): Map[] { const result: Map[] = []; - this.templates.forEach((template: LGTemplate): any => { + this.templates.forEach((template: Template): any => { result.push(this.visit(template.parseTree)); }); @@ -69,7 +67,7 @@ export class Extractor extends AbstractParseTreeVisitor> implem const lineStart = ' '; const structName = context.structuredTemplateBody().structuredBodyNameLine().text; let fullStr = structName + '\n'; - context.structuredTemplateBody().structuredBodyContentLine().forEach(line => fullStr += lineStart + line.text + '\n'); + context.structuredTemplateBody().structuredBodyContentLine().forEach((line): string => fullStr += lineStart + line.text + '\n'); fullStr += context.structuredTemplateBody().structuredBodyEndLine().text; result.set(fullStr, undefined); @@ -100,7 +98,6 @@ export class Extractor extends AbstractParseTreeVisitor> implem result.set(conditionLabel.toUpperCase().concat(' ') + expressions[0].text, childTemplateBodyResult); } } else { - // tslint:disable-next-line: no-backbone-get-set-outside-model result.set('ELSE:', childTemplateBodyResult); } } @@ -133,7 +130,6 @@ export class Extractor extends AbstractParseTreeVisitor> implem if (caseExpr) { result.set(conditionLabel.toUpperCase().concat(' ') + expressions[0].text, childTemplateBodyResult); } else { - // tslint:disable-next-line: no-backbone-get-set-outside-model result.set('DEFALUT:', childTemplateBodyResult); } } diff --git a/libraries/botbuilder-lg/src/generated/LGFileLexer.ts b/libraries/botbuilder-lg/src/generated/LGFileLexer.ts index eedb60a114..4b9e112b8b 100644 --- a/libraries/botbuilder-lg/src/generated/LGFileLexer.ts +++ b/libraries/botbuilder-lg/src/generated/LGFileLexer.ts @@ -595,7 +595,7 @@ export class LGFileLexer extends Lexer { private static readonly _serializedATNSegments: number = 2; private static readonly _serializedATNSegment0: string = - "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x02.\u0266\b\x01" + + "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x02.\u026A\b\x01" + "\b\x01\b\x01\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" + @@ -610,296 +610,300 @@ export class LGFileLexer extends Lexer { "\x05\x03\x05\x03\x06\x03\x06\x03\x07\x03\x07\x03\b\x03\b\x03\t\x03\t\x03" + "\n\x03\n\x03\v\x03\v\x03\f\x03\f\x03\r\x03\r\x03\x0E\x03\x0E\x03\x0F\x03" + "\x0F\x03\x10\x03\x10\x03\x11\x03\x11\x07\x11\xAF\n\x11\f\x11\x0E\x11\xB2" + - "\v\x11\x03\x11\x03\x11\x03\x12\x03\x12\x07\x12\xB8\n\x12\f\x12\x0E\x12" + - "\xBB\v\x12\x03\x12\x03\x12\x03\x12\x07\x12\xC0\n\x12\f\x12\x0E\x12\xC3" + - "\v\x12\x03\x12\x05\x12\xC6\n\x12\x03\x13\x03\x13\x03\x13\x03\x13\x07\x13" + - "\xCC\n\x13\f\x13\x0E\x13\xCF\v\x13\x03\x13\x03\x13\x03\x14\x03\x14\x03" + - "\x14\x03\x14\x03\x14\x03\x14\x06\x14\xD9\n\x14\r\x14\x0E\x14\xDA\x03\x14" + - "\x05\x14\xDE\n\x14\x03\x15\x03\x15\x05\x15\xE2\n\x15\x03\x16\x03\x16\x07" + - "\x16\xE6\n\x16\f\x16\x0E\x16\xE9\v\x16\x03\x16\x03\x16\x03\x16\x03\x16" + - "\x06\x16\xEF\n\x16\r\x16\x0E\x16\xF0\x03\x17\x03\x17\x07\x17\xF5\n\x17" + - "\f\x17\x0E\x17\xF8\v\x17\x03\x17\x03\x17\x03\x18\x06\x18\xFD\n\x18\r\x18" + - "\x0E\x18\xFE\x03\x18\x03\x18\x03\x19\x05\x19\u0104\n\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\x1D\x03\x1D\x07\x1D\u011C\n\x1D\f\x1D\x0E\x1D\u011F\v\x1D\x03\x1D" + - "\x03\x1D\x03\x1D\x07\x1D\u0124\n\x1D\f\x1D\x0E\x1D\u0127\v\x1D\x03\x1D" + - "\x03\x1D\x03\x1D\x03\x1E\x03\x1E\x03\x1E\x03\x1F\x06\x1F\u0130\n\x1F\r" + - "\x1F\x0E\x1F\u0131\x03\x1F\x03\x1F\x03 \x05 \u0137\n \x03 \x03 \x03 \x03" + - " \x03 \x03 \x03!\x03!\x03!\x05!\u0142\n!\x03!\x03!\x03!\x07!\u0147\n!" + - "\f!\x0E!\u014A\v!\x03\"\x03\"\x03#\x03#\x03$\x03$\x03%\x03%\x03&\x06&" + - "\u0155\n&\r&\x0E&\u0156\x03\'\x06\'\u015A\n\'\r\'\x0E\'\u015B\x03\'\x03" + - "\'\x03\'\x03\'\x03(\x03(\x03(\x03(\x03(\x03(\x03(\x03(\x03(\x03)\x05)" + - "\u016C\n)\x03)\x03)\x03)\x03)\x03)\x03)\x03*\x03*\x03*\x07*\u0177\n*\f" + - "*\x0E*\u017A\v*\x03*\x03*\x03*\x03*\x03+\x03+\x03+\x03+\x03+\x07+\u0185" + - "\n+\f+\x0E+\u0188\v+\x03+\x03+\x03+\x07+\u018D\n+\f+\x0E+\u0190\v+\x03" + - "+\x03+\x03+\x03+\x03,\x03,\x03,\x03,\x03,\x07,\u019B\n,\f,\x0E,\u019E" + - "\v,\x03,\x03,\x03,\x03,\x03-\x03-\x03-\x03-\x03-\x03-\x03-\x07-\u01AB" + - "\n-\f-\x0E-\u01AE\v-\x03-\x03-\x03-\x03-\x03.\x03.\x03.\x03.\x03.\x07" + - ".\u01B9\n.\f.\x0E.\u01BC\v.\x03.\x03.\x03.\x03.\x03/\x03/\x03/\x03/\x03" + - "/\x03/\x03/\x03/\x07/\u01CA\n/\f/\x0E/\u01CD\v/\x03/\x03/\x03/\x03/\x03" + - "0\x030\x030\x031\x031\x031\x032\x062\u01DA\n2\r2\x0E2\u01DB\x032\x032" + - "\x033\x033\x033\x033\x033\x033\x033\x033\x034\x034\x034\x034\x035\x03" + - "5\x035\x035\x036\x056\u01F1\n6\x036\x036\x066\u01F5\n6\r6\x0E6\u01F6\x03" + - "6\x036\x037\x067\u01FC\n7\r7\x0E7\u01FD\x037\x037\x038\x058\u0203\n8\x03" + - "8\x038\x038\x038\x038\x038\x038\x039\x039\x039\x059\u020F\n9\x039\x03" + - "9\x039\x079\u0214\n9\f9\x0E9\u0217\v9\x03:\x06:\u021A\n:\r:\x0E:\u021B" + - "\x03;\x03;\x07;\u0220\n;\f;\x0E;\u0223\v;\x03;\x05;\u0226\n;\x03;\x03" + - ";\x03;\x03;\x03;\x03<\x06<\u022E\n<\r<\x0E<\u022F\x03<\x03<\x03<\x03<" + - "\x03=\x05=\u0237\n=\x03=\x03=\x03=\x03>\x03>\x03>\x03>\x03>\x03>\x03>" + - "\x03?\x03?\x03?\x05?\u0246\n?\x03?\x03?\x03?\x07?\u024B\n?\f?\x0E?\u024E" + - "\v?\x03?\x03?\x03?\x03@\x03@\x03@\x03@\x03A\x03A\x03A\x03B\x03B\x03B\x03" + - "C\x03C\x03C\x03D\x06D\u0261\nD\rD\x0ED\u0262\x03D\x03D\t\u011D\u0125\u0156" + - "\u01DB\u01F6\u021B\u0262\x02\x02E\b\x02\x02\n\x02\x02\f\x02\x02\x0E\x02" + - "\x02\x10\x02\x02\x12\x02\x02\x14\x02\x02\x16\x02\x02\x18\x02\x02\x1A\x02" + - "\x02\x1C\x02\x02\x1E\x02\x02 \x02\x02\"\x02\x02$\x02\x02&\x02\x02(\x02" + - "\x02*\x02\x02,\x02\x02.\x02\x020\x02\x032\x02\x044\x02\x056\x02\x068\x02" + - "\x07:\x02\b<\x02\t>\x02\n@\x02\vB\x02\fD\x02\rF\x02\x0EH\x02\x0FJ\x02" + - "\x10L\x02\x11N\x02\x12P\x02\x13R\x02\x14T\x02\x15V\x02\x16X\x02\x17Z\x02" + - "\x18\\\x02\x19^\x02\x1A`\x02\x1Bb\x02\x1Cd\x02\x1Df\x02\x1Eh\x02\x1Fj" + - "\x02 l\x02\x02n\x02\x02p\x02\x02r\x02!t\x02\"v\x02#x\x02$z\x02%|\x02&" + - "~\x02\'\x80\x02(\x82\x02)\x84\x02*\x86\x02+\x88\x02,\x8A\x02-\x8C\x02" + - ".\b\x02\x03\x04\x05\x06\x07\x19\x04\x02CCcc\x04\x02EEee\x04\x02FFff\x04" + - "\x02GGgg\x04\x02HHhh\x04\x02JJjj\x04\x02KKkk\x04\x02NNnn\x04\x02UUuu\x04" + - "\x02VVvv\x04\x02WWww\x04\x02YYyy\x04\x02C\\c|\x06\x02\v\v\"\"\xA2\xA2" + - "\uFF01\uFF01\x05\x02\f\f\x0F\x0F))\x05\x02\f\f\x0F\x0F$$\x03\x02bb\t\x02" + - "\f\f\x0F\x0F$$))bb}}\x7F\x7F\x04\x02\f\f\x0F\x0F\x06\x02\f\f\x0F\x0F]" + - "]__\x05\x02\f\f\x0F\x0F*+\x04\x02//aa\x04\x02/0aa\u0286\x020\x03\x02\x02" + - "\x02\x022\x03\x02\x02\x02\x024\x03\x02\x02\x02\x026\x03\x02\x02\x02\x02" + - "8\x03\x02\x02\x02\x02:\x03\x02\x02\x02\x02<\x03\x02\x02\x02\x02>\x03\x02" + - "\x02\x02\x02@\x03\x02\x02\x02\x03B\x03\x02\x02\x02\x03D\x03\x02\x02\x02" + - "\x03F\x03\x02\x02\x02\x03H\x03\x02\x02\x02\x03J\x03\x02\x02\x02\x03L\x03" + - "\x02\x02\x02\x03N\x03\x02\x02\x02\x03P\x03\x02\x02\x02\x04R\x03\x02\x02" + - "\x02\x04T\x03\x02\x02\x02\x04V\x03\x02\x02\x02\x04X\x03\x02\x02\x02\x04" + - "Z\x03\x02\x02\x02\x04\\\x03\x02\x02\x02\x04^\x03\x02\x02\x02\x04`\x03" + - "\x02\x02\x02\x04b\x03\x02\x02\x02\x04d\x03\x02\x02\x02\x04f\x03\x02\x02" + - "\x02\x04h\x03\x02\x02\x02\x05j\x03\x02\x02\x02\x05l\x03\x02\x02\x02\x05" + - "n\x03\x02\x02\x02\x05p\x03\x02\x02\x02\x06r\x03\x02\x02\x02\x06t\x03\x02" + - "\x02\x02\x06v\x03\x02\x02\x02\x06x\x03\x02\x02\x02\x07z\x03\x02\x02\x02" + - "\x07|\x03\x02\x02\x02\x07~\x03\x02\x02\x02\x07\x80\x03\x02\x02\x02\x07" + - "\x82\x03\x02\x02\x02\x07\x84\x03\x02\x02\x02\x07\x86\x03\x02\x02\x02\x07" + - "\x88\x03\x02\x02\x02\x07\x8A\x03\x02\x02\x02\x07\x8C\x03\x02\x02\x02\b" + - "\x8E\x03\x02\x02\x02\n\x90\x03\x02\x02\x02\f\x92\x03\x02\x02\x02\x0E\x94" + - "\x03\x02\x02\x02\x10\x96\x03\x02\x02\x02\x12\x98\x03\x02\x02\x02\x14\x9A" + - "\x03\x02\x02\x02\x16\x9C\x03\x02\x02\x02\x18\x9E\x03\x02\x02\x02\x1A\xA0" + - "\x03\x02\x02\x02\x1C\xA2\x03\x02\x02\x02\x1E\xA4\x03\x02\x02\x02 \xA6" + - "\x03\x02\x02\x02\"\xA8\x03\x02\x02\x02$\xAA\x03\x02\x02\x02&\xAC\x03\x02" + - "\x02\x02(\xC5\x03\x02\x02\x02*\xC7\x03\x02\x02\x02,\xD2\x03\x02\x02\x02" + - ".\xDF\x03\x02\x02\x020\xE3\x03\x02\x02\x022\xF2\x03\x02\x02\x024\xFC\x03" + - "\x02\x02\x026\u0103\x03\x02\x02\x028\u0109\x03\x02\x02\x02:\u010E\x03" + - "\x02\x02\x02<\u0114\x03\x02\x02\x02>\u0119\x03\x02\x02\x02@\u012B\x03" + - "\x02\x02\x02B\u012F\x03\x02\x02\x02D\u0136\x03\x02\x02\x02F\u0141\x03" + - "\x02\x02\x02H\u014B\x03\x02\x02\x02J\u014D\x03\x02\x02\x02L\u014F\x03" + - "\x02\x02\x02N\u0151\x03\x02\x02\x02P\u0154\x03\x02\x02\x02R\u0159\x03" + - "\x02\x02\x02T\u0161\x03\x02\x02\x02V\u016B\x03\x02\x02\x02X\u0173\x03" + - "\x02\x02\x02Z\u017F\x03\x02\x02\x02\\\u0195\x03\x02\x02\x02^\u01A3\x03" + - "\x02\x02\x02`\u01B3\x03\x02\x02\x02b\u01C1\x03\x02\x02\x02d\u01D2\x03" + - "\x02\x02\x02f\u01D5\x03\x02\x02\x02h\u01D9\x03\x02\x02\x02j\u01DF\x03" + - "\x02\x02\x02l\u01E7\x03\x02\x02\x02n\u01EB\x03\x02\x02\x02p\u01F4\x03" + - "\x02\x02\x02r\u01FB\x03\x02\x02\x02t\u0202\x03\x02\x02\x02v\u020E\x03" + - "\x02\x02\x02x\u0219\x03\x02\x02\x02z\u021D\x03\x02\x02\x02|\u022D\x03" + - "\x02\x02\x02~\u0236\x03\x02\x02\x02\x80\u023B\x03\x02\x02\x02\x82\u0245" + - "\x03\x02\x02\x02\x84\u0252\x03\x02\x02\x02\x86\u0256\x03\x02\x02\x02\x88" + - "\u0259\x03\x02\x02\x02\x8A\u025C\x03\x02\x02\x02\x8C\u0260\x03\x02\x02" + - "\x02\x8E\x8F\t\x02\x02\x02\x8F\t\x03\x02\x02\x02\x90\x91\t\x03\x02\x02" + - "\x91\v\x03\x02\x02\x02\x92\x93\t\x04\x02\x02\x93\r\x03\x02\x02\x02\x94" + - "\x95\t\x05\x02\x02\x95\x0F\x03\x02\x02\x02\x96\x97\t\x06\x02\x02\x97\x11" + - "\x03\x02\x02\x02\x98\x99\t\x07\x02\x02\x99\x13\x03\x02\x02\x02\x9A\x9B" + - "\t\b\x02\x02\x9B\x15\x03\x02\x02\x02\x9C\x9D\t\t\x02\x02\x9D\x17\x03\x02" + - "\x02\x02\x9E\x9F\t\n\x02\x02\x9F\x19\x03\x02\x02\x02\xA0\xA1\t\v\x02\x02" + - "\xA1\x1B\x03\x02\x02\x02\xA2\xA3\t\f\x02\x02\xA3\x1D\x03\x02\x02\x02\xA4" + - "\xA5\t\r\x02\x02\xA5\x1F\x03\x02\x02\x02\xA6\xA7\t\x0E\x02\x02\xA7!\x03" + - "\x02\x02\x02\xA8\xA9\x042;\x02\xA9#\x03\x02\x02\x02\xAA\xAB\t\x0F\x02" + - "\x02\xAB%\x03\x02\x02\x02\xAC\xB0\x07}\x02\x02\xAD\xAF\x05$\x10\x02\xAE" + - "\xAD\x03\x02\x02\x02\xAF\xB2\x03\x02\x02\x02\xB0\xAE\x03\x02\x02\x02\xB0" + - "\xB1\x03\x02\x02\x02\xB1\xB3\x03\x02\x02\x02\xB2\xB0\x03\x02\x02\x02\xB3" + - "\xB4\x07\x7F\x02\x02\xB4\'\x03\x02\x02\x02\xB5\xB9\x07)\x02\x02\xB6\xB8" + - "\n\x10\x02\x02\xB7\xB6\x03\x02\x02\x02\xB8\xBB\x03\x02\x02\x02\xB9\xB7" + - "\x03\x02\x02\x02\xB9\xBA\x03\x02\x02\x02\xBA\xBC\x03\x02\x02\x02\xBB\xB9" + - "\x03\x02\x02\x02\xBC\xC6\x07)\x02\x02\xBD\xC1\x07$\x02\x02\xBE\xC0\n\x11" + - "\x02\x02\xBF\xBE\x03\x02\x02\x02\xC0\xC3\x03\x02\x02\x02\xC1\xBF\x03\x02" + - "\x02\x02\xC1\xC2\x03\x02\x02\x02\xC2\xC4\x03\x02\x02\x02\xC3\xC1\x03\x02" + - "\x02\x02\xC4\xC6\x07$\x02\x02\xC5\xB5\x03\x02\x02\x02\xC5\xBD\x03\x02" + - "\x02\x02\xC6)\x03\x02\x02\x02\xC7\xCD\x07b\x02\x02\xC8\xC9\x07^\x02\x02" + - "\xC9\xCC\x07b\x02\x02\xCA\xCC\n\x12\x02\x02\xCB\xC8\x03\x02\x02\x02\xCB" + - "\xCA\x03\x02\x02\x02\xCC\xCF\x03\x02\x02\x02\xCD\xCB\x03\x02\x02\x02\xCD" + - "\xCE\x03\x02\x02\x02\xCE\xD0\x03\x02\x02\x02\xCF\xCD\x03\x02\x02\x02\xD0" + - "\xD1\x07b\x02\x02\xD1+\x03\x02\x02\x02\xD2\xD3\x07&\x02\x02\xD3\xD8\x07" + - "}\x02\x02\xD4\xD9\x05(\x12\x02\xD5\xD9\x05*\x13\x02\xD6\xD9\x05&\x11\x02" + - "\xD7\xD9\n\x13\x02\x02\xD8\xD4\x03\x02\x02\x02\xD8\xD5\x03\x02\x02\x02" + - "\xD8\xD6\x03\x02\x02\x02\xD8\xD7\x03\x02\x02\x02\xD9\xDA\x03\x02\x02\x02" + - "\xDA\xD8\x03\x02\x02\x02\xDA\xDB\x03\x02\x02\x02\xDB\xDD\x03\x02\x02\x02" + - "\xDC\xDE\x07\x7F\x02\x02\xDD\xDC\x03\x02\x02\x02\xDD\xDE\x03\x02\x02\x02" + - "\xDE-\x03\x02\x02\x02\xDF\xE1\x07^\x02\x02\xE0\xE2\n\x14\x02\x02\xE1\xE0" + - "\x03\x02\x02\x02\xE1\xE2\x03\x02\x02\x02\xE2/\x03\x02\x02\x02\xE3\xE7" + - "\x07@\x02\x02\xE4\xE6\x05$\x10\x02\xE5\xE4\x03\x02\x02\x02\xE6\xE9\x03" + - "\x02\x02\x02\xE7\xE5\x03\x02\x02\x02\xE7\xE8\x03\x02\x02\x02\xE8\xEA\x03" + - "\x02\x02\x02\xE9\xE7\x03\x02\x02\x02\xEA\xEB\x07#\x02\x02\xEB\xEC\x07" + - "%\x02\x02\xEC\xEE\x03\x02\x02\x02\xED\xEF\n\x14\x02\x02\xEE\xED\x03\x02" + - "\x02\x02\xEF\xF0\x03\x02\x02\x02\xF0\xEE\x03\x02\x02\x02\xF0\xF1\x03\x02" + - "\x02\x02\xF11\x03\x02\x02\x02\xF2\xF6\x07@\x02\x02\xF3\xF5\n\x14\x02\x02" + - "\xF4\xF3\x03\x02\x02\x02\xF5\xF8\x03\x02\x02\x02\xF6\xF4\x03\x02\x02\x02" + - "\xF6\xF7\x03\x02\x02\x02\xF7\xF9\x03\x02\x02\x02\xF8\xF6\x03\x02\x02\x02" + - "\xF9\xFA\b\x17\x02\x02\xFA3\x03\x02\x02\x02\xFB\xFD\x05$\x10\x02\xFC\xFB" + - "\x03\x02\x02\x02\xFD\xFE\x03\x02\x02\x02\xFE\xFC\x03\x02\x02\x02\xFE\xFF" + - "\x03\x02\x02\x02\xFF\u0100\x03\x02\x02\x02\u0100\u0101\b\x18\x02\x02\u0101" + - "5\x03\x02\x02\x02\u0102\u0104\x07\x0F\x02\x02\u0103\u0102\x03\x02\x02" + - "\x02\u0103\u0104\x03\x02\x02\x02\u0104\u0105\x03\x02\x02\x02\u0105\u0106" + - "\x07\f\x02\x02\u0106\u0107\x03\x02\x02\x02\u0107\u0108\b\x19\x02\x02\u0108" + - "7\x03\x02\x02\x02\u0109\u010A\x07%\x02\x02\u010A\u010B\b\x1A\x03\x02\u010B" + - "\u010C\x03\x02\x02\x02\u010C\u010D\b\x1A\x04\x02\u010D9\x03\x02\x02\x02" + - "\u010E\u010F\x07/\x02\x02\u010F\u0110\x06\x1B\x02\x02\u0110\u0111\b\x1B" + - "\x05\x02\u0111\u0112\x03\x02\x02\x02\u0112\u0113\b\x1B\x06\x02\u0113;" + - "\x03\x02\x02\x02\u0114\u0115\x07]\x02\x02\u0115\u0116\x06\x1C\x03\x02" + - "\u0116\u0117\x03\x02\x02\x02\u0117\u0118\b\x1C\x07\x02\u0118=\x03\x02" + - "\x02\x02\u0119\u011D\x07]\x02\x02\u011A\u011C\n\x15\x02\x02\u011B\u011A" + - "\x03\x02\x02\x02\u011C\u011F\x03\x02\x02\x02\u011D\u011E\x03\x02\x02\x02" + - "\u011D\u011B\x03\x02\x02\x02\u011E\u0120\x03\x02\x02\x02\u011F\u011D\x03" + - "\x02\x02\x02\u0120\u0121\x07_\x02\x02\u0121\u0125\x07*\x02\x02\u0122\u0124" + - "\n\x16\x02\x02\u0123\u0122\x03\x02\x02\x02\u0124\u0127\x03\x02\x02\x02" + - "\u0125\u0126\x03\x02\x02\x02\u0125\u0123\x03\x02\x02\x02\u0126\u0128\x03" + - "\x02\x02\x02\u0127\u0125\x03\x02\x02\x02\u0128\u0129\x07+\x02\x02\u0129" + - "\u012A\b\x1D\b\x02\u012A?\x03\x02\x02\x02\u012B\u012C\v\x02\x02\x02\u012C" + - "\u012D\b\x1E\t\x02\u012DA\x03\x02\x02\x02\u012E\u0130\x05$\x10\x02\u012F" + - "\u012E\x03\x02\x02\x02\u0130\u0131\x03\x02\x02\x02\u0131\u012F\x03\x02" + - "\x02\x02\u0131\u0132\x03\x02\x02\x02\u0132\u0133\x03\x02\x02\x02\u0133" + - "\u0134\b\x1F\x02\x02\u0134C\x03\x02\x02\x02\u0135\u0137\x07\x0F\x02\x02" + - "\u0136\u0135\x03\x02\x02\x02\u0136\u0137\x03\x02\x02\x02\u0137\u0138\x03" + - "\x02\x02\x02\u0138\u0139\x07\f\x02\x02\u0139\u013A\b \n\x02\u013A\u013B" + - "\x03\x02\x02\x02\u013B\u013C\b \x02\x02\u013C\u013D\b \v\x02\u013DE\x03" + - "\x02\x02\x02\u013E\u0142\x05 \x0E\x02\u013F\u0142\x05\"\x0F\x02\u0140" + - "\u0142\x07a\x02\x02\u0141\u013E\x03\x02\x02\x02\u0141\u013F\x03\x02\x02" + - "\x02\u0141\u0140\x03\x02\x02\x02\u0142\u0148\x03\x02\x02\x02\u0143\u0147" + - "\x05 \x0E\x02\u0144\u0147\x05\"\x0F\x02\u0145\u0147\t\x17\x02\x02\u0146" + - "\u0143\x03\x02\x02\x02\u0146\u0144\x03\x02\x02\x02\u0146\u0145\x03\x02" + - "\x02\x02\u0147\u014A\x03\x02\x02\x02\u0148\u0146\x03\x02\x02\x02\u0148" + - "\u0149\x03\x02\x02\x02\u0149G\x03\x02\x02\x02\u014A\u0148\x03\x02\x02" + - "\x02\u014B\u014C\x070\x02\x02\u014CI\x03\x02\x02\x02\u014D\u014E\x07*" + - "\x02\x02\u014EK\x03\x02\x02\x02\u014F\u0150\x07+\x02\x02\u0150M\x03\x02" + - "\x02\x02\u0151\u0152\x07.\x02\x02\u0152O\x03\x02\x02\x02\u0153\u0155\n" + - "\x14\x02\x02\u0154\u0153\x03\x02\x02\x02\u0155\u0156\x03\x02\x02\x02\u0156" + - "\u0157\x03\x02\x02\x02\u0156\u0154\x03\x02\x02\x02\u0157Q\x03\x02\x02" + - "\x02\u0158\u015A\x05$\x10\x02\u0159\u0158\x03\x02\x02\x02\u015A\u015B" + - "\x03\x02\x02\x02\u015B\u0159\x03\x02\x02\x02\u015B\u015C\x03\x02\x02\x02" + - "\u015C\u015D\x03\x02\x02\x02\u015D\u015E\x06\'\x04\x02\u015E\u015F\x03" + - "\x02\x02\x02\u015F\u0160\b\'\x02\x02\u0160S\x03\x02\x02\x02\u0161\u0162" + - "\x07b\x02\x02\u0162\u0163\x07b\x02\x02\u0163\u0164\x07b\x02\x02\u0164" + - "\u0165\x03\x02\x02\x02\u0165\u0166\x06(\x05\x02\u0166\u0167\b(\f\x02\u0167" + - "\u0168\x03\x02\x02\x02\u0168\u0169\b(\r\x02\u0169U\x03\x02\x02\x02\u016A" + - "\u016C\x07\x0F\x02\x02\u016B\u016A\x03\x02\x02\x02\u016B\u016C\x03\x02" + - "\x02\x02\u016C\u016D\x03\x02\x02\x02\u016D\u016E\x07\f\x02\x02\u016E\u016F" + - "\b)\x0E\x02\u016F\u0170\x03\x02\x02\x02\u0170\u0171\b)\x02\x02\u0171\u0172" + - "\b)\v\x02\u0172W\x03\x02\x02\x02\u0173\u0174\x05\x14\b\x02\u0174\u0178" + - "\x05\x10\x06\x02\u0175\u0177\x05$\x10\x02\u0176\u0175\x03\x02\x02\x02" + - "\u0177\u017A\x03\x02\x02\x02\u0178\u0176\x03\x02\x02\x02\u0178\u0179\x03" + - "\x02\x02\x02\u0179\u017B\x03\x02\x02\x02\u017A\u0178\x03\x02\x02\x02\u017B" + - "\u017C\x07<\x02\x02\u017C\u017D\x06*\x06\x02\u017D\u017E\b*\x0F\x02\u017E" + - "Y\x03\x02\x02\x02\u017F\u0180\x05\x0E\x05\x02\u0180\u0181\x05\x16\t\x02" + - "\u0181\u0182\x05\x18\n\x02\u0182\u0186\x05\x0E\x05\x02\u0183\u0185\x05" + - "$\x10\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\u018A\x05\x14\b\x02\u018A\u018E" + - "\x05\x10\x06\x02\u018B\u018D\x05$\x10\x02\u018C\u018B\x03\x02\x02\x02" + - "\u018D\u0190\x03\x02\x02\x02\u018E\u018C\x03\x02\x02\x02\u018E\u018F\x03" + - "\x02\x02\x02\u018F\u0191\x03\x02\x02\x02\u0190\u018E\x03\x02\x02\x02\u0191" + - "\u0192\x07<\x02\x02\u0192\u0193\x06+\x07\x02\u0193\u0194\b+\x10\x02\u0194" + - "[\x03\x02\x02\x02\u0195\u0196\x05\x0E\x05\x02\u0196\u0197\x05\x16\t\x02" + - "\u0197\u0198\x05\x18\n\x02\u0198\u019C\x05\x0E\x05\x02\u0199\u019B\x05" + - "$\x10\x02\u019A\u0199\x03\x02\x02\x02\u019B\u019E\x03\x02\x02\x02\u019C" + - "\u019A\x03\x02\x02\x02\u019C\u019D\x03\x02\x02\x02\u019D\u019F\x03\x02" + - "\x02\x02\u019E\u019C\x03\x02\x02\x02\u019F\u01A0\x07<\x02\x02\u01A0\u01A1" + - "\x06,\b\x02\u01A1\u01A2\b,\x11\x02\u01A2]\x03\x02\x02\x02\u01A3\u01A4" + - "\x05\x18\n\x02\u01A4\u01A5\x05\x1E\r\x02\u01A5\u01A6\x05\x14\b\x02\u01A6" + - "\u01A7\x05\x1A\v\x02\u01A7\u01A8\x05\n\x03\x02\u01A8\u01AC\x05\x12\x07" + - "\x02\u01A9\u01AB\x05$\x10\x02\u01AA\u01A9\x03\x02\x02\x02\u01AB\u01AE" + - "\x03\x02\x02\x02\u01AC\u01AA\x03\x02\x02\x02\u01AC\u01AD\x03\x02\x02\x02" + - "\u01AD\u01AF\x03\x02\x02\x02\u01AE\u01AC\x03\x02\x02\x02\u01AF\u01B0\x07" + - "<\x02\x02\u01B0\u01B1\x06-\t\x02\u01B1\u01B2\b-\x12\x02\u01B2_\x03\x02" + - "\x02\x02\u01B3\u01B4\x05\n\x03\x02\u01B4\u01B5\x05\b\x02\x02\u01B5\u01B6" + - "\x05\x18\n\x02\u01B6\u01BA\x05\x0E\x05\x02\u01B7\u01B9\x05$\x10\x02\u01B8" + - "\u01B7\x03\x02\x02\x02\u01B9\u01BC\x03\x02\x02\x02\u01BA\u01B8\x03\x02" + - "\x02\x02\u01BA\u01BB\x03\x02\x02\x02\u01BB\u01BD\x03\x02\x02\x02\u01BC" + - "\u01BA\x03\x02\x02\x02\u01BD\u01BE\x07<\x02\x02\u01BE\u01BF\x06.\n\x02" + - "\u01BF\u01C0\b.\x13\x02\u01C0a\x03\x02\x02\x02\u01C1\u01C2\x05\f\x04\x02" + - "\u01C2\u01C3\x05\x0E\x05\x02\u01C3\u01C4\x05\x10\x06\x02\u01C4\u01C5\x05" + - "\b\x02\x02\u01C5\u01C6\x05\x1C\f\x02\u01C6\u01C7\x05\x16\t\x02\u01C7\u01CB" + - "\x05\x1A\v\x02\u01C8\u01CA\x05$\x10\x02\u01C9\u01C8\x03\x02\x02\x02\u01CA" + - "\u01CD\x03\x02\x02\x02\u01CB\u01C9\x03\x02\x02\x02\u01CB\u01CC\x03\x02" + - "\x02\x02\u01CC\u01CE\x03\x02\x02\x02\u01CD\u01CB\x03\x02\x02\x02\u01CE" + - "\u01CF\x07<\x02\x02\u01CF\u01D0\x06/\v\x02\u01D0\u01D1\b/\x14\x02\u01D1" + - "c\x03\x02\x02\x02\u01D2\u01D3\x05.\x15\x02\u01D3\u01D4\b0\x15\x02\u01D4" + - "e\x03\x02\x02\x02\u01D5\u01D6\x05,\x14\x02\u01D6\u01D7\b1\x16\x02\u01D7" + - "g\x03\x02\x02\x02\u01D8\u01DA\n\x14\x02\x02\u01D9\u01D8\x03\x02\x02\x02" + - "\u01DA\u01DB\x03\x02\x02\x02\u01DB\u01DC\x03\x02\x02\x02\u01DB\u01D9\x03" + - "\x02\x02\x02\u01DC\u01DD\x03\x02\x02\x02\u01DD\u01DE\b2\x17\x02\u01DE" + - "i\x03\x02\x02\x02\u01DF\u01E0\x07b\x02\x02\u01E0\u01E1\x07b\x02\x02\u01E1" + - "\u01E2\x07b\x02\x02\u01E2\u01E3\x03\x02\x02\x02\u01E3\u01E4\b3\x18\x02" + - "\u01E4\u01E5\x03\x02\x02\x02\u01E5\u01E6\b3\v\x02\u01E6k\x03\x02\x02\x02" + - "\u01E7\u01E8\x05.\x15\x02\u01E8\u01E9\x03\x02\x02\x02\u01E9\u01EA\b4\x19" + - "\x02\u01EAm\x03\x02\x02\x02\u01EB\u01EC\x05,\x14\x02\u01EC\u01ED\x03\x02" + - "\x02\x02\u01ED\u01EE\b5\x1A\x02\u01EEo\x03\x02\x02\x02\u01EF\u01F1\x07" + - "\x0F\x02\x02\u01F0\u01EF\x03\x02\x02\x02\u01F0\u01F1\x03\x02\x02\x02\u01F1" + - "\u01F2\x03\x02\x02\x02\u01F2\u01F5\x07\f\x02\x02\u01F3\u01F5\n\x14\x02" + - "\x02\u01F4\u01F0\x03\x02\x02\x02\u01F4\u01F3\x03\x02\x02\x02\u01F5\u01F6" + - "\x03\x02\x02\x02\u01F6\u01F7\x03\x02\x02\x02\u01F6\u01F4\x03\x02\x02\x02" + - "\u01F7\u01F8\x03\x02\x02\x02\u01F8\u01F9\b6\x1B\x02\u01F9q\x03\x02\x02" + - "\x02\u01FA\u01FC\x05$\x10\x02\u01FB\u01FA\x03\x02\x02\x02\u01FC\u01FD" + - "\x03\x02\x02\x02\u01FD\u01FB\x03\x02\x02\x02\u01FD\u01FE\x03\x02\x02\x02" + - "\u01FE\u01FF\x03\x02\x02\x02\u01FF\u0200\b7\x02\x02\u0200s\x03\x02\x02" + - "\x02\u0201\u0203\x07\x0F\x02\x02\u0202\u0201\x03\x02\x02\x02\u0202\u0203" + - "\x03\x02\x02\x02\u0203\u0204\x03\x02\x02\x02\u0204\u0205\x07\f\x02\x02" + - "\u0205\u0206\b8\x1C\x02\u0206\u0207\b8\x1D\x02\u0207\u0208\x03\x02\x02" + - "\x02\u0208\u0209\b8\x02\x02\u0209\u020A\b8\x1E\x02\u020Au\x03\x02\x02" + - "\x02\u020B\u020F\x05 \x0E\x02\u020C\u020F\x05\"\x0F\x02\u020D\u020F\x07" + - "a\x02\x02\u020E\u020B\x03\x02\x02\x02\u020E\u020C\x03\x02\x02\x02\u020E" + - "\u020D\x03\x02\x02\x02\u020F\u0215\x03\x02\x02\x02\u0210\u0214\x05 \x0E" + - "\x02\u0211\u0214\x05\"\x0F\x02\u0212\u0214\t\x18\x02\x02\u0213\u0210\x03" + - "\x02\x02\x02\u0213\u0211\x03\x02\x02\x02\u0213\u0212\x03\x02\x02\x02\u0214" + - "\u0217\x03\x02\x02\x02\u0215\u0213"; + "\v\x11\x03\x11\x03\x11\x03\x12\x03\x12\x03\x12\x03\x12\x07\x12\xBA\n\x12" + + "\f\x12\x0E\x12\xBD\v\x12\x03\x12\x03\x12\x03\x12\x03\x12\x03\x12\x07\x12" + + "\xC4\n\x12\f\x12\x0E\x12\xC7\v\x12\x03\x12\x05\x12\xCA\n\x12\x03\x13\x03" + + "\x13\x03\x13\x03\x13\x07\x13\xD0\n\x13\f\x13\x0E\x13\xD3\v\x13\x03\x13" + + "\x03\x13\x03\x14\x03\x14\x03\x14\x03\x14\x03\x14\x03\x14\x06\x14\xDD\n" + + "\x14\r\x14\x0E\x14\xDE\x03\x14\x05\x14\xE2\n\x14\x03\x15\x03\x15\x05\x15" + + "\xE6\n\x15\x03\x16\x03\x16\x07\x16\xEA\n\x16\f\x16\x0E\x16\xED\v\x16\x03" + + "\x16\x03\x16\x03\x16\x03\x16\x06\x16\xF3\n\x16\r\x16\x0E\x16\xF4\x03\x17" + + "\x03\x17\x07\x17\xF9\n\x17\f\x17\x0E\x17\xFC\v\x17\x03\x17\x03\x17\x03" + + "\x18\x06\x18\u0101\n\x18\r\x18\x0E\x18\u0102\x03\x18\x03\x18\x03\x19\x05" + + "\x19\u0108\n\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\x1D\x03\x1D\x07\x1D\u0120\n\x1D\f" + + "\x1D\x0E\x1D\u0123\v\x1D\x03\x1D\x03\x1D\x03\x1D\x07\x1D\u0128\n\x1D\f" + + "\x1D\x0E\x1D\u012B\v\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1E\x03\x1E\x03\x1E" + + "\x03\x1F\x06\x1F\u0134\n\x1F\r\x1F\x0E\x1F\u0135\x03\x1F\x03\x1F\x03 " + + "\x05 \u013B\n \x03 \x03 \x03 \x03 \x03 \x03 \x03!\x03!\x03!\x05!\u0146" + + "\n!\x03!\x03!\x03!\x07!\u014B\n!\f!\x0E!\u014E\v!\x03\"\x03\"\x03#\x03" + + "#\x03$\x03$\x03%\x03%\x03&\x06&\u0159\n&\r&\x0E&\u015A\x03\'\x06\'\u015E" + + "\n\'\r\'\x0E\'\u015F\x03\'\x03\'\x03\'\x03\'\x03(\x03(\x03(\x03(\x03(" + + "\x03(\x03(\x03(\x03(\x03)\x05)\u0170\n)\x03)\x03)\x03)\x03)\x03)\x03)" + + "\x03*\x03*\x03*\x07*\u017B\n*\f*\x0E*\u017E\v*\x03*\x03*\x03*\x03*\x03" + + "+\x03+\x03+\x03+\x03+\x07+\u0189\n+\f+\x0E+\u018C\v+\x03+\x03+\x03+\x07" + + "+\u0191\n+\f+\x0E+\u0194\v+\x03+\x03+\x03+\x03+\x03,\x03,\x03,\x03,\x03" + + ",\x07,\u019F\n,\f,\x0E,\u01A2\v,\x03,\x03,\x03,\x03,\x03-\x03-\x03-\x03" + + "-\x03-\x03-\x03-\x07-\u01AF\n-\f-\x0E-\u01B2\v-\x03-\x03-\x03-\x03-\x03" + + ".\x03.\x03.\x03.\x03.\x07.\u01BD\n.\f.\x0E.\u01C0\v.\x03.\x03.\x03.\x03" + + ".\x03/\x03/\x03/\x03/\x03/\x03/\x03/\x03/\x07/\u01CE\n/\f/\x0E/\u01D1" + + "\v/\x03/\x03/\x03/\x03/\x030\x030\x030\x031\x031\x031\x032\x062\u01DE" + + "\n2\r2\x0E2\u01DF\x032\x032\x033\x033\x033\x033\x033\x033\x033\x033\x03" + + "4\x034\x034\x034\x035\x035\x035\x035\x036\x056\u01F5\n6\x036\x036\x06" + + "6\u01F9\n6\r6\x0E6\u01FA\x036\x036\x037\x067\u0200\n7\r7\x0E7\u0201\x03" + + "7\x037\x038\x058\u0207\n8\x038\x038\x038\x038\x038\x038\x038\x039\x03" + + "9\x039\x059\u0213\n9\x039\x039\x039\x079\u0218\n9\f9\x0E9\u021B\v9\x03" + + ":\x06:\u021E\n:\r:\x0E:\u021F\x03;\x03;\x07;\u0224\n;\f;\x0E;\u0227\v" + + ";\x03;\x05;\u022A\n;\x03;\x03;\x03;\x03;\x03;\x03<\x06<\u0232\n<\r<\x0E" + + "<\u0233\x03<\x03<\x03<\x03<\x03=\x05=\u023B\n=\x03=\x03=\x03=\x03>\x03" + + ">\x03>\x03>\x03>\x03>\x03>\x03?\x03?\x03?\x05?\u024A\n?\x03?\x03?\x03" + + "?\x07?\u024F\n?\f?\x0E?\u0252\v?\x03?\x03?\x03?\x03@\x03@\x03@\x03@\x03" + + "A\x03A\x03A\x03B\x03B\x03B\x03C\x03C\x03C\x03D\x06D\u0265\nD\rD\x0ED\u0266" + + "\x03D\x03D\f\xBB\xC5\xD1\u0121\u0129\u015A\u01DF\u01FA\u021F\u0266\x02" + + "\x02E\b\x02\x02\n\x02\x02\f\x02\x02\x0E\x02\x02\x10\x02\x02\x12\x02\x02" + + "\x14\x02\x02\x16\x02\x02\x18\x02\x02\x1A\x02\x02\x1C\x02\x02\x1E\x02\x02" + + " \x02\x02\"\x02\x02$\x02\x02&\x02\x02(\x02\x02*\x02\x02,\x02\x02.\x02" + + "\x020\x02\x032\x02\x044\x02\x056\x02\x068\x02\x07:\x02\b<\x02\t>\x02\n" + + "@\x02\vB\x02\fD\x02\rF\x02\x0EH\x02\x0FJ\x02\x10L\x02\x11N\x02\x12P\x02" + + "\x13R\x02\x14T\x02\x15V\x02\x16X\x02\x17Z\x02\x18\\\x02\x19^\x02\x1A`" + + "\x02\x1Bb\x02\x1Cd\x02\x1Df\x02\x1Eh\x02\x1Fj\x02 l\x02\x02n\x02\x02p" + + "\x02\x02r\x02!t\x02\"v\x02#x\x02$z\x02%|\x02&~\x02\'\x80\x02(\x82\x02" + + ")\x84\x02*\x86\x02+\x88\x02,\x8A\x02-\x8C\x02.\b\x02\x03\x04\x05\x06\x07" + + "\x1C\x04\x02CCcc\x04\x02EEee\x04\x02FFff\x04\x02GGgg\x04\x02HHhh\x04\x02" + + "JJjj\x04\x02KKkk\x04\x02NNnn\x04\x02UUuu\x04\x02VVvv\x04\x02WWww\x04\x02" + + "YYyy\x04\x02C\\c|\x06\x02\v\v\"\"\xA2\xA2\uFF01\uFF01\x04\x02))^^\x03" + + "\x02))\x04\x02$$^^\x03\x02$$\x04\x02^^bb\x03\x02bb\x06\x02$$))bb\x7F\x7F" + + "\x04\x02\f\f\x0F\x0F\x06\x02\f\f\x0F\x0F]]__\x05\x02\f\f\x0F\x0F*+\x04" + + "\x02//aa\x04\x02/0aa\u028C\x020\x03\x02\x02\x02\x022\x03\x02\x02\x02\x02" + + "4\x03\x02\x02\x02\x026\x03\x02\x02\x02\x028\x03\x02\x02\x02\x02:\x03\x02" + + "\x02\x02\x02<\x03\x02\x02\x02\x02>\x03\x02\x02\x02\x02@\x03\x02\x02\x02" + + "\x03B\x03\x02\x02\x02\x03D\x03\x02\x02\x02\x03F\x03\x02\x02\x02\x03H\x03" + + "\x02\x02\x02\x03J\x03\x02\x02\x02\x03L\x03\x02\x02\x02\x03N\x03\x02\x02" + + "\x02\x03P\x03\x02\x02\x02\x04R\x03\x02\x02\x02\x04T\x03\x02\x02\x02\x04" + + "V\x03\x02\x02\x02\x04X\x03\x02\x02\x02\x04Z\x03\x02\x02\x02\x04\\\x03" + + "\x02\x02\x02\x04^\x03\x02\x02\x02\x04`\x03\x02\x02\x02\x04b\x03\x02\x02" + + "\x02\x04d\x03\x02\x02\x02\x04f\x03\x02\x02\x02\x04h\x03\x02\x02\x02\x05" + + "j\x03\x02\x02\x02\x05l\x03\x02\x02\x02\x05n\x03\x02\x02\x02\x05p\x03\x02" + + "\x02\x02\x06r\x03\x02\x02\x02\x06t\x03\x02\x02\x02\x06v\x03\x02\x02\x02" + + "\x06x\x03\x02\x02\x02\x07z\x03\x02\x02\x02\x07|\x03\x02\x02\x02\x07~\x03" + + "\x02\x02\x02\x07\x80\x03\x02\x02\x02\x07\x82\x03\x02\x02\x02\x07\x84\x03" + + "\x02\x02\x02\x07\x86\x03\x02\x02\x02\x07\x88\x03\x02\x02\x02\x07\x8A\x03" + + "\x02\x02\x02\x07\x8C\x03\x02\x02\x02\b\x8E\x03\x02\x02\x02\n\x90\x03\x02" + + "\x02\x02\f\x92\x03\x02\x02\x02\x0E\x94\x03\x02\x02\x02\x10\x96\x03\x02" + + "\x02\x02\x12\x98\x03\x02\x02\x02\x14\x9A\x03\x02\x02\x02\x16\x9C\x03\x02" + + "\x02\x02\x18\x9E\x03\x02\x02\x02\x1A\xA0\x03\x02\x02\x02\x1C\xA2\x03\x02" + + "\x02\x02\x1E\xA4\x03\x02\x02\x02 \xA6\x03\x02\x02\x02\"\xA8\x03\x02\x02" + + "\x02$\xAA\x03\x02\x02\x02&\xAC\x03\x02\x02\x02(\xC9\x03\x02\x02\x02*\xCB" + + "\x03\x02\x02\x02,\xD6\x03\x02\x02\x02.\xE3\x03\x02\x02\x020\xE7\x03\x02" + + "\x02\x022\xF6\x03\x02\x02\x024\u0100\x03\x02\x02\x026\u0107\x03\x02\x02" + + "\x028\u010D\x03\x02\x02\x02:\u0112\x03\x02\x02\x02<\u0118\x03\x02\x02" + + "\x02>\u011D\x03\x02\x02\x02@\u012F\x03\x02\x02\x02B\u0133\x03\x02\x02" + + "\x02D\u013A\x03\x02\x02\x02F\u0145\x03\x02\x02\x02H\u014F\x03\x02\x02" + + "\x02J\u0151\x03\x02\x02\x02L\u0153\x03\x02\x02\x02N\u0155\x03\x02\x02" + + "\x02P\u0158\x03\x02\x02\x02R\u015D\x03\x02\x02\x02T\u0165\x03\x02\x02" + + "\x02V\u016F\x03\x02\x02\x02X\u0177\x03\x02\x02\x02Z\u0183\x03\x02\x02" + + "\x02\\\u0199\x03\x02\x02\x02^\u01A7\x03\x02\x02\x02`\u01B7\x03\x02\x02" + + "\x02b\u01C5\x03\x02\x02\x02d\u01D6\x03\x02\x02\x02f\u01D9\x03\x02\x02" + + "\x02h\u01DD\x03\x02\x02\x02j\u01E3\x03\x02\x02\x02l\u01EB\x03\x02\x02" + + "\x02n\u01EF\x03\x02\x02\x02p\u01F8\x03\x02\x02\x02r\u01FF\x03\x02\x02" + + "\x02t\u0206\x03\x02\x02\x02v\u0212\x03\x02\x02\x02x\u021D\x03\x02\x02" + + "\x02z\u0221\x03\x02\x02\x02|\u0231\x03\x02\x02\x02~\u023A\x03\x02\x02" + + "\x02\x80\u023F\x03\x02\x02\x02\x82\u0249\x03\x02\x02\x02\x84\u0256\x03" + + "\x02\x02\x02\x86\u025A\x03\x02\x02\x02\x88\u025D\x03\x02\x02\x02\x8A\u0260" + + "\x03\x02\x02\x02\x8C\u0264\x03\x02\x02\x02\x8E\x8F\t\x02\x02\x02\x8F\t" + + "\x03\x02\x02\x02\x90\x91\t\x03\x02\x02\x91\v\x03\x02\x02\x02\x92\x93\t" + + "\x04\x02\x02\x93\r\x03\x02\x02\x02\x94\x95\t\x05\x02\x02\x95\x0F\x03\x02" + + "\x02\x02\x96\x97\t\x06\x02\x02\x97\x11\x03\x02\x02\x02\x98\x99\t\x07\x02" + + "\x02\x99\x13\x03\x02\x02\x02\x9A\x9B\t\b\x02\x02\x9B\x15\x03\x02\x02\x02" + + "\x9C\x9D\t\t\x02\x02\x9D\x17\x03\x02\x02\x02\x9E\x9F\t\n\x02\x02\x9F\x19" + + "\x03\x02\x02\x02\xA0\xA1\t\v\x02\x02\xA1\x1B\x03\x02\x02\x02\xA2\xA3\t" + + "\f\x02\x02\xA3\x1D\x03\x02\x02\x02\xA4\xA5\t\r\x02\x02\xA5\x1F\x03\x02" + + "\x02\x02\xA6\xA7\t\x0E\x02\x02\xA7!\x03\x02\x02\x02\xA8\xA9\x042;\x02" + + "\xA9#\x03\x02\x02\x02\xAA\xAB\t\x0F\x02\x02\xAB%\x03\x02\x02\x02\xAC\xB0" + + "\x07}\x02\x02\xAD\xAF\x05$\x10\x02\xAE\xAD\x03\x02\x02\x02\xAF\xB2\x03" + + "\x02\x02\x02\xB0\xAE\x03\x02\x02\x02\xB0\xB1\x03\x02\x02\x02\xB1\xB3\x03" + + "\x02\x02\x02\xB2\xB0\x03\x02\x02\x02\xB3\xB4\x07\x7F\x02\x02\xB4\'\x03" + + "\x02\x02\x02\xB5\xBB\x07)\x02\x02\xB6\xB7\x07^\x02\x02\xB7\xBA\t\x10\x02" + + "\x02\xB8\xBA\n\x11\x02\x02\xB9\xB6\x03\x02\x02\x02\xB9\xB8\x03\x02\x02" + + "\x02\xBA\xBD\x03\x02\x02\x02\xBB\xBC\x03\x02\x02\x02\xBB\xB9\x03\x02\x02" + + "\x02\xBC\xBE\x03\x02\x02\x02\xBD\xBB\x03\x02\x02\x02\xBE\xCA\x07)\x02" + + "\x02\xBF\xC5\x07$\x02\x02\xC0\xC1\x07^\x02\x02\xC1\xC4\t\x12\x02\x02\xC2" + + "\xC4\n\x13\x02\x02\xC3\xC0\x03\x02\x02\x02\xC3\xC2\x03\x02\x02\x02\xC4" + + "\xC7\x03\x02\x02\x02\xC5\xC6\x03\x02\x02\x02\xC5\xC3\x03\x02\x02\x02\xC6" + + "\xC8\x03\x02\x02\x02\xC7\xC5\x03\x02\x02\x02\xC8\xCA\x07$\x02\x02\xC9" + + "\xB5\x03\x02\x02\x02\xC9\xBF\x03\x02\x02\x02\xCA)\x03\x02\x02\x02\xCB" + + "\xD1\x07b\x02\x02\xCC\xCD\x07^\x02\x02\xCD\xD0\t\x14\x02\x02\xCE\xD0\n" + + "\x15\x02\x02\xCF\xCC\x03\x02\x02\x02\xCF\xCE\x03\x02\x02\x02\xD0\xD3\x03" + + "\x02\x02\x02\xD1\xD2\x03\x02\x02\x02\xD1\xCF\x03\x02\x02\x02\xD2\xD4\x03" + + "\x02\x02\x02\xD3\xD1\x03\x02\x02\x02\xD4\xD5\x07b\x02\x02\xD5+\x03\x02" + + "\x02\x02\xD6\xD7\x07&\x02\x02\xD7\xDC\x07}\x02\x02\xD8\xDD\x05(\x12\x02" + + "\xD9\xDD\x05*\x13\x02\xDA\xDD\x05&\x11\x02\xDB\xDD\n\x16\x02\x02\xDC\xD8" + + "\x03\x02\x02\x02\xDC\xD9\x03\x02\x02\x02\xDC\xDA\x03\x02\x02\x02\xDC\xDB" + + "\x03\x02\x02\x02\xDD\xDE\x03\x02\x02\x02\xDE\xDC\x03\x02\x02\x02\xDE\xDF" + + "\x03\x02\x02\x02\xDF\xE1\x03\x02\x02\x02\xE0\xE2\x07\x7F\x02\x02\xE1\xE0" + + "\x03\x02\x02\x02\xE1\xE2\x03\x02\x02\x02\xE2-\x03\x02\x02\x02\xE3\xE5" + + "\x07^\x02\x02\xE4\xE6\n\x17\x02\x02\xE5\xE4\x03\x02\x02\x02\xE5\xE6\x03" + + "\x02\x02\x02\xE6/\x03\x02\x02\x02\xE7\xEB\x07@\x02\x02\xE8\xEA\x05$\x10" + + "\x02\xE9\xE8\x03\x02\x02\x02\xEA\xED\x03\x02\x02\x02\xEB\xE9\x03\x02\x02" + + "\x02\xEB\xEC\x03\x02\x02\x02\xEC\xEE\x03\x02\x02\x02\xED\xEB\x03\x02\x02" + + "\x02\xEE\xEF\x07#\x02\x02\xEF\xF0\x07%\x02\x02\xF0\xF2\x03\x02\x02\x02" + + "\xF1\xF3\n\x17\x02\x02\xF2\xF1\x03\x02\x02\x02\xF3\xF4\x03\x02\x02\x02" + + "\xF4\xF2\x03\x02\x02\x02\xF4\xF5\x03\x02\x02\x02\xF51\x03\x02\x02\x02" + + "\xF6\xFA\x07@\x02\x02\xF7\xF9\n\x17\x02\x02\xF8\xF7\x03\x02\x02\x02\xF9" + + "\xFC\x03\x02\x02\x02\xFA\xF8\x03\x02\x02\x02\xFA\xFB\x03\x02\x02\x02\xFB" + + "\xFD\x03\x02\x02\x02\xFC\xFA\x03\x02\x02\x02\xFD\xFE\b\x17\x02\x02\xFE" + + "3\x03\x02\x02\x02\xFF\u0101\x05$\x10\x02\u0100\xFF\x03\x02\x02\x02\u0101" + + "\u0102\x03\x02\x02\x02\u0102\u0100\x03\x02\x02\x02\u0102\u0103\x03\x02" + + "\x02\x02\u0103\u0104\x03\x02\x02\x02\u0104\u0105\b\x18\x02\x02\u01055" + + "\x03\x02\x02\x02\u0106\u0108\x07\x0F\x02\x02\u0107\u0106\x03\x02\x02\x02" + + "\u0107\u0108\x03\x02\x02\x02\u0108\u0109\x03\x02\x02\x02\u0109\u010A\x07" + + "\f\x02\x02\u010A\u010B\x03\x02\x02\x02\u010B\u010C\b\x19\x02\x02\u010C" + + "7\x03\x02\x02\x02\u010D\u010E\x07%\x02\x02\u010E\u010F\b\x1A\x03\x02\u010F" + + "\u0110\x03\x02\x02\x02\u0110\u0111\b\x1A\x04\x02\u01119\x03\x02\x02\x02" + + "\u0112\u0113\x07/\x02\x02\u0113\u0114\x06\x1B\x02\x02\u0114\u0115\b\x1B" + + "\x05\x02\u0115\u0116\x03\x02\x02\x02\u0116\u0117\b\x1B\x06\x02\u0117;" + + "\x03\x02\x02\x02\u0118\u0119\x07]\x02\x02\u0119\u011A\x06\x1C\x03\x02" + + "\u011A\u011B\x03\x02\x02\x02\u011B\u011C\b\x1C\x07\x02\u011C=\x03\x02" + + "\x02\x02\u011D\u0121\x07]\x02\x02\u011E\u0120\n\x18\x02\x02\u011F\u011E" + + "\x03\x02\x02\x02\u0120\u0123\x03\x02\x02\x02\u0121\u0122\x03\x02\x02\x02" + + "\u0121\u011F\x03\x02\x02\x02\u0122\u0124\x03\x02\x02\x02\u0123\u0121\x03" + + "\x02\x02\x02\u0124\u0125\x07_\x02\x02\u0125\u0129\x07*\x02\x02\u0126\u0128" + + "\n\x19\x02\x02\u0127\u0126\x03\x02\x02\x02\u0128\u012B\x03\x02\x02\x02" + + "\u0129\u012A\x03\x02\x02\x02\u0129\u0127\x03\x02\x02\x02\u012A\u012C\x03" + + "\x02\x02\x02\u012B\u0129\x03\x02\x02\x02\u012C\u012D\x07+\x02\x02\u012D" + + "\u012E\b\x1D\b\x02\u012E?\x03\x02\x02\x02\u012F\u0130\v\x02\x02\x02\u0130" + + "\u0131\b\x1E\t\x02\u0131A\x03\x02\x02\x02\u0132\u0134\x05$\x10\x02\u0133" + + "\u0132\x03\x02\x02\x02\u0134\u0135\x03\x02\x02\x02\u0135\u0133\x03\x02" + + "\x02\x02\u0135\u0136\x03\x02\x02\x02\u0136\u0137\x03\x02\x02\x02\u0137" + + "\u0138\b\x1F\x02\x02\u0138C\x03\x02\x02\x02\u0139\u013B\x07\x0F\x02\x02" + + "\u013A\u0139\x03\x02\x02\x02\u013A\u013B\x03\x02\x02\x02\u013B\u013C\x03" + + "\x02\x02\x02\u013C\u013D\x07\f\x02\x02\u013D\u013E\b \n\x02\u013E\u013F" + + "\x03\x02\x02\x02\u013F\u0140\b \x02\x02\u0140\u0141\b \v\x02\u0141E\x03" + + "\x02\x02\x02\u0142\u0146\x05 \x0E\x02\u0143\u0146\x05\"\x0F\x02\u0144" + + "\u0146\x07a\x02\x02\u0145\u0142\x03\x02\x02\x02\u0145\u0143\x03\x02\x02" + + "\x02\u0145\u0144\x03\x02\x02\x02\u0146\u014C\x03\x02\x02\x02\u0147\u014B" + + "\x05 \x0E\x02\u0148\u014B\x05\"\x0F\x02\u0149\u014B\t\x1A\x02\x02\u014A" + + "\u0147\x03\x02\x02\x02\u014A\u0148\x03\x02\x02\x02\u014A\u0149\x03\x02" + + "\x02\x02\u014B\u014E\x03\x02\x02\x02\u014C\u014A\x03\x02\x02\x02\u014C" + + "\u014D\x03\x02\x02\x02\u014DG\x03\x02\x02\x02\u014E\u014C\x03\x02\x02" + + "\x02\u014F\u0150\x070\x02\x02\u0150I\x03\x02\x02\x02\u0151\u0152\x07*" + + "\x02\x02\u0152K\x03\x02\x02\x02\u0153\u0154\x07+\x02\x02\u0154M\x03\x02" + + "\x02\x02\u0155\u0156\x07.\x02\x02\u0156O\x03\x02\x02\x02\u0157\u0159\n" + + "\x17\x02\x02\u0158\u0157\x03\x02\x02\x02\u0159\u015A\x03\x02\x02\x02\u015A" + + "\u015B\x03\x02\x02\x02\u015A\u0158\x03\x02\x02\x02\u015BQ\x03\x02\x02" + + "\x02\u015C\u015E\x05$\x10\x02\u015D\u015C\x03\x02\x02\x02\u015E\u015F" + + "\x03\x02\x02\x02\u015F\u015D\x03\x02\x02\x02\u015F\u0160\x03\x02\x02\x02" + + "\u0160\u0161\x03\x02\x02\x02\u0161\u0162\x06\'\x04\x02\u0162\u0163\x03" + + "\x02\x02\x02\u0163\u0164\b\'\x02\x02\u0164S\x03\x02\x02\x02\u0165\u0166" + + "\x07b\x02\x02\u0166\u0167\x07b\x02\x02\u0167\u0168\x07b\x02\x02\u0168" + + "\u0169\x03\x02\x02\x02\u0169\u016A\x06(\x05\x02\u016A\u016B\b(\f\x02\u016B" + + "\u016C\x03\x02\x02\x02\u016C\u016D\b(\r\x02\u016DU\x03\x02\x02\x02\u016E" + + "\u0170\x07\x0F\x02\x02\u016F\u016E\x03\x02\x02\x02\u016F\u0170\x03\x02" + + "\x02\x02\u0170\u0171\x03\x02\x02\x02\u0171\u0172\x07\f\x02\x02\u0172\u0173" + + "\b)\x0E\x02\u0173\u0174\x03\x02\x02\x02\u0174\u0175\b)\x02\x02\u0175\u0176" + + "\b)\v\x02\u0176W\x03\x02\x02\x02\u0177\u0178\x05\x14\b\x02\u0178\u017C" + + "\x05\x10\x06\x02\u0179\u017B\x05$\x10\x02\u017A\u0179\x03\x02\x02\x02" + + "\u017B\u017E\x03\x02\x02\x02\u017C\u017A\x03\x02\x02\x02\u017C\u017D\x03" + + "\x02\x02\x02\u017D\u017F\x03\x02\x02\x02\u017E\u017C\x03\x02\x02\x02\u017F" + + "\u0180\x07<\x02\x02\u0180\u0181\x06*\x06\x02\u0181\u0182\b*\x0F\x02\u0182" + + "Y\x03\x02\x02\x02\u0183\u0184\x05\x0E\x05\x02\u0184\u0185\x05\x16\t\x02" + + "\u0185\u0186\x05\x18\n\x02\u0186\u018A\x05\x0E\x05\x02\u0187\u0189\x05" + + "$\x10\x02\u0188\u0187\x03\x02\x02\x02\u0189\u018C\x03\x02\x02\x02\u018A" + + "\u0188\x03\x02\x02\x02\u018A\u018B\x03\x02\x02\x02\u018B\u018D\x03\x02" + + "\x02\x02\u018C\u018A\x03\x02\x02\x02\u018D\u018E\x05\x14\b\x02\u018E\u0192" + + "\x05\x10\x06\x02\u018F\u0191\x05$\x10\x02\u0190\u018F\x03\x02\x02\x02" + + "\u0191\u0194\x03\x02\x02\x02\u0192\u0190\x03\x02\x02\x02\u0192\u0193\x03" + + "\x02\x02\x02\u0193\u0195\x03\x02\x02\x02\u0194\u0192\x03\x02\x02\x02\u0195" + + "\u0196\x07<\x02\x02\u0196\u0197\x06+\x07\x02\u0197\u0198\b+\x10\x02\u0198" + + "[\x03\x02\x02\x02\u0199\u019A\x05\x0E\x05\x02\u019A\u019B\x05\x16\t\x02" + + "\u019B\u019C\x05\x18\n\x02\u019C\u01A0\x05\x0E\x05\x02\u019D\u019F\x05" + + "$\x10\x02\u019E\u019D\x03\x02\x02\x02\u019F\u01A2\x03\x02\x02\x02\u01A0" + + "\u019E\x03\x02\x02\x02\u01A0\u01A1\x03\x02\x02\x02\u01A1\u01A3\x03\x02" + + "\x02\x02\u01A2\u01A0\x03\x02\x02\x02\u01A3\u01A4\x07<\x02\x02\u01A4\u01A5" + + "\x06,\b\x02\u01A5\u01A6\b,\x11\x02\u01A6]\x03\x02\x02\x02\u01A7\u01A8" + + "\x05\x18\n\x02\u01A8\u01A9\x05\x1E\r\x02\u01A9\u01AA\x05\x14\b\x02\u01AA" + + "\u01AB\x05\x1A\v\x02\u01AB\u01AC\x05\n\x03\x02\u01AC\u01B0\x05\x12\x07" + + "\x02\u01AD\u01AF\x05$\x10\x02\u01AE\u01AD\x03\x02\x02\x02\u01AF\u01B2" + + "\x03\x02\x02\x02\u01B0\u01AE\x03\x02\x02\x02\u01B0\u01B1\x03\x02\x02\x02" + + "\u01B1\u01B3\x03\x02\x02\x02\u01B2\u01B0\x03\x02\x02\x02\u01B3\u01B4\x07" + + "<\x02\x02\u01B4\u01B5\x06-\t\x02\u01B5\u01B6\b-\x12\x02\u01B6_\x03\x02" + + "\x02\x02\u01B7\u01B8\x05\n\x03\x02\u01B8\u01B9\x05\b\x02\x02\u01B9\u01BA" + + "\x05\x18\n\x02\u01BA\u01BE\x05\x0E\x05\x02\u01BB\u01BD\x05$\x10\x02\u01BC" + + "\u01BB\x03\x02\x02\x02\u01BD\u01C0\x03\x02\x02\x02\u01BE\u01BC\x03\x02" + + "\x02\x02\u01BE\u01BF\x03\x02\x02\x02\u01BF\u01C1\x03\x02\x02\x02\u01C0" + + "\u01BE\x03\x02\x02\x02\u01C1\u01C2\x07<\x02\x02\u01C2\u01C3\x06.\n\x02" + + "\u01C3\u01C4\b.\x13\x02\u01C4a\x03\x02\x02\x02\u01C5\u01C6\x05\f\x04\x02" + + "\u01C6\u01C7\x05\x0E\x05\x02\u01C7\u01C8\x05\x10\x06\x02\u01C8\u01C9\x05" + + "\b\x02\x02\u01C9\u01CA\x05\x1C\f\x02\u01CA\u01CB\x05\x16\t\x02\u01CB\u01CF" + + "\x05\x1A\v\x02\u01CC\u01CE\x05$\x10\x02\u01CD\u01CC\x03\x02\x02\x02\u01CE" + + "\u01D1\x03\x02\x02\x02\u01CF\u01CD\x03\x02\x02\x02\u01CF\u01D0\x03\x02" + + "\x02\x02\u01D0\u01D2\x03\x02\x02\x02\u01D1\u01CF\x03\x02\x02\x02\u01D2" + + "\u01D3\x07<\x02\x02\u01D3\u01D4\x06/\v\x02\u01D4\u01D5\b/\x14\x02\u01D5" + + "c\x03\x02\x02\x02\u01D6\u01D7\x05.\x15\x02\u01D7\u01D8\b0\x15\x02\u01D8" + + "e\x03\x02\x02\x02\u01D9\u01DA\x05,\x14\x02\u01DA\u01DB\b1\x16\x02\u01DB" + + "g\x03\x02\x02\x02\u01DC\u01DE\n\x17\x02\x02\u01DD\u01DC\x03\x02\x02\x02" + + "\u01DE\u01DF\x03\x02\x02\x02\u01DF\u01E0\x03\x02\x02\x02\u01DF\u01DD\x03" + + "\x02\x02\x02\u01E0\u01E1\x03\x02\x02\x02\u01E1\u01E2\b2\x17\x02\u01E2" + + "i\x03\x02\x02\x02\u01E3\u01E4\x07b\x02\x02\u01E4\u01E5\x07b\x02\x02\u01E5" + + "\u01E6\x07b\x02\x02\u01E6\u01E7\x03\x02\x02\x02\u01E7\u01E8\b3\x18\x02" + + "\u01E8\u01E9\x03\x02\x02\x02\u01E9\u01EA\b3\v\x02\u01EAk\x03\x02\x02\x02" + + "\u01EB\u01EC\x05.\x15\x02\u01EC\u01ED\x03\x02\x02\x02\u01ED\u01EE\b4\x19" + + "\x02\u01EEm\x03\x02\x02\x02\u01EF\u01F0\x05,\x14\x02\u01F0\u01F1\x03\x02" + + "\x02\x02\u01F1\u01F2\b5\x1A\x02\u01F2o\x03\x02\x02\x02\u01F3\u01F5\x07" + + "\x0F\x02\x02\u01F4\u01F3\x03\x02\x02\x02\u01F4\u01F5\x03\x02\x02\x02\u01F5" + + "\u01F6\x03\x02\x02\x02\u01F6\u01F9\x07\f\x02\x02\u01F7\u01F9\n\x17\x02" + + "\x02\u01F8\u01F4\x03\x02\x02\x02\u01F8\u01F7\x03\x02\x02\x02\u01F9\u01FA" + + "\x03\x02\x02\x02\u01FA\u01FB\x03\x02\x02\x02\u01FA\u01F8\x03\x02\x02\x02" + + "\u01FB\u01FC\x03\x02\x02\x02\u01FC\u01FD\b6\x1B\x02\u01FDq\x03\x02\x02" + + "\x02\u01FE\u0200\x05$\x10\x02\u01FF\u01FE\x03\x02\x02\x02\u0200\u0201" + + "\x03\x02\x02\x02\u0201\u01FF\x03\x02\x02\x02\u0201\u0202\x03\x02\x02\x02" + + "\u0202\u0203\x03\x02\x02\x02\u0203\u0204\b7\x02\x02\u0204s\x03\x02\x02" + + "\x02\u0205\u0207\x07\x0F\x02\x02\u0206\u0205\x03\x02\x02\x02\u0206\u0207" + + "\x03\x02\x02\x02\u0207\u0208\x03\x02\x02\x02\u0208\u0209\x07\f\x02\x02" + + "\u0209\u020A\b8\x1C\x02\u020A\u020B\b8\x1D\x02\u020B\u020C\x03\x02\x02" + + "\x02\u020C\u020D\b8\x02\x02\u020D\u020E\b8\x1E\x02\u020Eu\x03\x02\x02" + + "\x02\u020F\u0213\x05 \x0E\x02\u0210\u0213\x05\"\x0F\x02\u0211\u0213\x07" + + "a\x02\x02\u0212\u020F\x03\x02\x02\x02\u0212\u0210\x03\x02\x02\x02\u0212" + + "\u0211\x03\x02\x02"; private static readonly _serializedATNSegment1: string = - "\x03\x02\x02\x02\u0215\u0216\x03\x02\x02\x02\u0216w\x03\x02\x02\x02\u0217" + - "\u0215\x03\x02\x02\x02\u0218\u021A\n\x14\x02\x02\u0219\u0218\x03\x02\x02" + - "\x02\u021A\u021B\x03\x02\x02\x02\u021B\u021C\x03\x02\x02\x02\u021B\u0219" + - "\x03\x02\x02\x02\u021Cy\x03\x02\x02\x02\u021D\u0221\x07@\x02\x02\u021E" + - "\u0220\n\x14\x02\x02\u021F\u021E\x03\x02\x02\x02\u0220\u0223\x03\x02\x02" + - "\x02\u0221\u021F\x03\x02\x02\x02\u0221\u0222\x03\x02\x02\x02\u0222\u0225" + - "\x03\x02\x02\x02\u0223\u0221\x03\x02\x02\x02\u0224\u0226\x07\x0F\x02\x02" + - "\u0225\u0224\x03\x02\x02\x02\u0225\u0226\x03\x02\x02\x02\u0226\u0227\x03" + - "\x02\x02\x02\u0227\u0228\x07\f\x02\x02\u0228\u0229\x06;\f\x02\u0229\u022A" + - "\x03\x02\x02\x02\u022A\u022B\b;\x02\x02\u022B{\x03\x02\x02\x02\u022C\u022E" + - "\x05$\x10\x02\u022D\u022C\x03\x02\x02\x02\u022E\u022F\x03\x02\x02\x02" + - "\u022F\u022D\x03\x02\x02\x02\u022F\u0230\x03\x02\x02\x02\u0230\u0231\x03" + - "\x02\x02\x02\u0231\u0232\x06<\r\x02\u0232\u0233\x03\x02\x02\x02\u0233" + - "\u0234\b<\x02\x02\u0234}\x03\x02\x02\x02\u0235\u0237\x07\x0F\x02\x02\u0236" + - "\u0235\x03\x02\x02\x02\u0236\u0237\x03\x02\x02\x02\u0237\u0238\x03\x02" + - "\x02\x02\u0238\u0239\x07\f\x02\x02\u0239\u023A\b=\x1F\x02\u023A\x7F\x03" + - "\x02\x02\x02\u023B\u023C\x07_\x02\x02\u023C\u023D\x06>\x0E\x02\u023D\u023E" + - "\b> \x02\u023E\u023F\x03\x02\x02\x02\u023F\u0240\b>\v\x02\u0240\u0241" + - "\b>\v\x02\u0241\x81\x03\x02\x02\x02\u0242\u0246\x05 \x0E\x02\u0243\u0246" + - "\x05\"\x0F\x02\u0244\u0246\x07a\x02\x02\u0245\u0242\x03\x02\x02\x02\u0245" + - "\u0243\x03\x02\x02\x02\u0245\u0244\x03\x02\x02\x02\u0246\u024C\x03\x02" + - "\x02\x02\u0247\u024B\x05 \x0E\x02\u0248\u024B\x05\"\x0F\x02\u0249\u024B" + - "\t\x18\x02\x02\u024A\u0247\x03\x02\x02\x02\u024A\u0248\x03\x02\x02\x02" + - "\u024A\u0249\x03\x02\x02\x02\u024B\u024E\x03\x02\x02\x02\u024C\u024A\x03" + - "\x02\x02\x02\u024C\u024D\x03\x02\x02\x02\u024D\u024F\x03\x02\x02\x02\u024E" + - "\u024C\x03\x02\x02\x02\u024F\u0250\x06?\x0F\x02\u0250\u0251\b?!\x02\u0251" + - "\x83\x03\x02\x02\x02\u0252\u0253\x07?\x02\x02\u0253\u0254\x06@\x10\x02" + - "\u0254\u0255\b@\"\x02\u0255\x85\x03\x02\x02\x02\u0256\u0257\x07~\x02\x02" + - "\u0257\u0258\bA#\x02\u0258\x87\x03\x02\x02\x02\u0259\u025A\x05.\x15\x02" + - "\u025A\u025B\bB$\x02\u025B\x89\x03\x02\x02\x02\u025C\u025D\x05,\x14\x02" + - "\u025D\u025E\bC%\x02\u025E\x8B\x03\x02\x02\x02\u025F\u0261\n\x14\x02\x02" + - "\u0260\u025F\x03\x02\x02\x02\u0261\u0262\x03\x02\x02\x02\u0262\u0263\x03" + - "\x02\x02\x02\u0262\u0260\x03\x02\x02\x02\u0263\u0264\x03\x02\x02\x02\u0264" + - "\u0265\bD&\x02\u0265\x8D\x03\x02\x02\x02:\x02\x03\x04\x05\x06\x07\xB0" + - "\xB9\xC1\xC5\xCB\xCD\xD8\xDA\xDD\xE1\xE7\xF0\xF6\xFE\u0103\u011D\u0125" + - "\u0131\u0136\u0141\u0146\u0148\u0156\u015B\u016B\u0178\u0186\u018E\u019C" + - "\u01AC\u01BA\u01CB\u01DB\u01F0\u01F4\u01F6\u01FD\u0202\u020E\u0213\u0215" + - "\u021B\u0221\u0225\u022F\u0236\u0245\u024A\u024C\u0262\'\b\x02\x02\x03" + - "\x1A\x02\x07\x03\x02\x03\x1B\x03\x07\x04\x02\x07\x06\x02\x03\x1D\x04\x03" + - "\x1E\x05\x03 \x06\x06\x02\x02\x03(\x07\x07\x05\x02\x03)\b\x03*\t\x03+" + - "\n\x03,\v\x03-\f\x03.\r\x03/\x0E\x030\x0F\x031\x10\x032\x11\x033\x12\t" + - "\x1D\x02\t\x1E\x02\t\x1F\x02\x038\x13\x038\x14\x07\x07\x02\x03=\x15\x03" + - ">\x16\x03?\x17\x03@\x18\x03A\x19\x03B\x1A\x03C\x1B\x03D\x1C"; + "\x02\u0213\u0219\x03\x02\x02\x02\u0214\u0218\x05 \x0E\x02\u0215\u0218" + + "\x05\"\x0F\x02\u0216\u0218\t\x1B\x02\x02\u0217\u0214\x03\x02\x02\x02\u0217" + + "\u0215\x03\x02\x02\x02\u0217\u0216\x03\x02\x02\x02\u0218\u021B\x03\x02" + + "\x02\x02\u0219\u0217\x03\x02\x02\x02\u0219\u021A\x03\x02\x02\x02\u021A" + + "w\x03\x02\x02\x02\u021B\u0219\x03\x02\x02\x02\u021C\u021E\n\x17\x02\x02" + + "\u021D\u021C\x03\x02\x02\x02\u021E\u021F\x03\x02\x02\x02\u021F\u0220\x03" + + "\x02\x02\x02\u021F\u021D\x03\x02\x02\x02\u0220y\x03\x02\x02\x02\u0221" + + "\u0225\x07@\x02\x02\u0222\u0224\n\x17\x02\x02\u0223\u0222\x03\x02\x02" + + "\x02\u0224\u0227\x03\x02\x02\x02\u0225\u0223\x03\x02\x02\x02\u0225\u0226" + + "\x03\x02\x02\x02\u0226\u0229\x03\x02\x02\x02\u0227\u0225\x03\x02\x02\x02" + + "\u0228\u022A\x07\x0F\x02\x02\u0229\u0228\x03\x02\x02\x02\u0229\u022A\x03" + + "\x02\x02\x02\u022A\u022B\x03\x02\x02\x02\u022B\u022C\x07\f\x02\x02\u022C" + + "\u022D\x06;\f\x02\u022D\u022E\x03\x02\x02\x02\u022E\u022F\b;\x02\x02\u022F" + + "{\x03\x02\x02\x02\u0230\u0232\x05$\x10\x02\u0231\u0230\x03\x02\x02\x02" + + "\u0232\u0233\x03\x02\x02\x02\u0233\u0231\x03\x02\x02\x02\u0233\u0234\x03" + + "\x02\x02\x02\u0234\u0235\x03\x02\x02\x02\u0235\u0236\x06<\r\x02\u0236" + + "\u0237\x03\x02\x02\x02\u0237\u0238\b<\x02\x02\u0238}\x03\x02\x02\x02\u0239" + + "\u023B\x07\x0F\x02\x02\u023A\u0239\x03\x02\x02\x02\u023A\u023B\x03\x02" + + "\x02\x02\u023B\u023C\x03\x02\x02\x02\u023C\u023D\x07\f\x02\x02\u023D\u023E" + + "\b=\x1F\x02\u023E\x7F\x03\x02\x02\x02\u023F\u0240\x07_\x02\x02\u0240\u0241" + + "\x06>\x0E\x02\u0241\u0242\b> \x02\u0242\u0243\x03\x02\x02\x02\u0243\u0244" + + "\b>\v\x02\u0244\u0245\b>\v\x02\u0245\x81\x03\x02\x02\x02\u0246\u024A\x05" + + " \x0E\x02\u0247\u024A\x05\"\x0F\x02\u0248\u024A\x07a\x02\x02\u0249\u0246" + + "\x03\x02\x02\x02\u0249\u0247\x03\x02\x02\x02\u0249\u0248\x03\x02\x02\x02" + + "\u024A\u0250\x03\x02\x02\x02\u024B\u024F\x05 \x0E\x02\u024C\u024F\x05" + + "\"\x0F\x02\u024D\u024F\t\x1B\x02\x02\u024E\u024B\x03\x02\x02\x02\u024E" + + "\u024C\x03\x02\x02\x02\u024E\u024D\x03\x02\x02\x02\u024F\u0252\x03\x02" + + "\x02\x02\u0250\u024E\x03\x02\x02\x02\u0250\u0251\x03\x02\x02\x02\u0251" + + "\u0253\x03\x02\x02\x02\u0252\u0250\x03\x02\x02\x02\u0253\u0254\x06?\x0F" + + "\x02\u0254\u0255\b?!\x02\u0255\x83\x03\x02\x02\x02\u0256\u0257\x07?\x02" + + "\x02\u0257\u0258\x06@\x10\x02\u0258\u0259\b@\"\x02\u0259\x85\x03\x02\x02" + + "\x02\u025A\u025B\x07~\x02\x02\u025B\u025C\bA#\x02\u025C\x87\x03\x02\x02" + + "\x02\u025D\u025E\x05.\x15\x02\u025E\u025F\bB$\x02\u025F\x89\x03\x02\x02" + + "\x02\u0260\u0261\x05,\x14\x02\u0261\u0262\bC%\x02\u0262\x8B\x03\x02\x02" + + "\x02\u0263\u0265\n\x17\x02\x02\u0264\u0263\x03\x02\x02\x02\u0265\u0266" + + "\x03\x02\x02\x02\u0266\u0267\x03\x02\x02\x02\u0266\u0264\x03\x02\x02\x02" + + "\u0267\u0268\x03\x02\x02\x02\u0268\u0269\bD&\x02\u0269\x8D\x03\x02\x02" + + "\x02<\x02\x03\x04\x05\x06\x07\xB0\xB9\xBB\xC3\xC5\xC9\xCF\xD1\xDC\xDE" + + "\xE1\xE5\xEB\xF4\xFA\u0102\u0107\u0121\u0129\u0135\u013A\u0145\u014A\u014C" + + "\u015A\u015F\u016F\u017C\u018A\u0192\u01A0\u01B0\u01BE\u01CF\u01DF\u01F4" + + "\u01F8\u01FA\u0201\u0206\u0212\u0217\u0219\u021F\u0225\u0229\u0233\u023A" + + "\u0249\u024E\u0250\u0266\'\b\x02\x02\x03\x1A\x02\x07\x03\x02\x03\x1B\x03" + + "\x07\x04\x02\x07\x06\x02\x03\x1D\x04\x03\x1E\x05\x03 \x06\x06\x02\x02" + + "\x03(\x07\x07\x05\x02\x03)\b\x03*\t\x03+\n\x03,\v\x03-\f\x03.\r\x03/\x0E" + + "\x030\x0F\x031\x10\x032\x11\x033\x12\t\x1D\x02\t\x1E\x02\t\x1F\x02\x03" + + "8\x13\x038\x14\x07\x07\x02\x03=\x15\x03>\x16\x03?\x17\x03@\x18\x03A\x19" + + "\x03B\x1A\x03C\x1B\x03D\x1C"; public static readonly _serializedATN: string = Utils.join( [ LGFileLexer._serializedATNSegment0, diff --git a/libraries/botbuilder-lg/src/generated/LGFileParser.ts b/libraries/botbuilder-lg/src/generated/LGFileParser.ts index 69c7c391c3..c522c2823d 100644 --- a/libraries/botbuilder-lg/src/generated/LGFileParser.ts +++ b/libraries/botbuilder-lg/src/generated/LGFileParser.ts @@ -1,3038 +1,3046 @@ -// Generated from ../LGFileParser.g4 by ANTLR 4.6-SNAPSHOT - -import { ATN } from 'antlr4ts/atn/ATN'; -import { ATNDeserializer } from 'antlr4ts/atn/ATNDeserializer'; -import { NoViableAltException } from 'antlr4ts/NoViableAltException'; -import { Parser } from 'antlr4ts/Parser'; -import { ParserRuleContext } from 'antlr4ts/ParserRuleContext'; -import { ParserATNSimulator } from 'antlr4ts/atn/ParserATNSimulator'; -import { RecognitionException } from 'antlr4ts/RecognitionException'; -import { TerminalNode } from 'antlr4ts/tree/TerminalNode'; -import { Token } from 'antlr4ts/Token'; -import { TokenStream } from 'antlr4ts/TokenStream'; -import { Vocabulary } from 'antlr4ts/Vocabulary'; -import { VocabularyImpl } from 'antlr4ts/VocabularyImpl'; - -import * as Utils from 'antlr4ts/misc/Utils'; - -import { LGFileParserListener } from './LGFileParserListener'; -import { LGFileParserVisitor } from './LGFileParserVisitor'; - - -export class LGFileParser extends Parser { - public static readonly OPTIONS = 1; - public static readonly COMMENTS = 2; - public static readonly WS = 3; - public static readonly NEWLINE = 4; - public static readonly HASH = 5; - public static readonly DASH = 6; - public static readonly LEFT_SQUARE_BRACKET = 7; - public static readonly IMPORT = 8; - public static readonly INVALID_TOKEN = 9; - public static readonly WS_IN_NAME = 10; - public static readonly NEWLINE_IN_NAME = 11; - public static readonly IDENTIFIER = 12; - public static readonly DOT = 13; - public static readonly OPEN_PARENTHESIS = 14; - public static readonly CLOSE_PARENTHESIS = 15; - public static readonly COMMA = 16; - public static readonly TEXT_IN_NAME = 17; - public static readonly WS_IN_BODY = 18; - public static readonly MULTILINE_PREFIX = 19; - public static readonly NEWLINE_IN_BODY = 20; - public static readonly IF = 21; - public static readonly ELSEIF = 22; - public static readonly ELSE = 23; - public static readonly SWITCH = 24; - public static readonly CASE = 25; - public static readonly DEFAULT = 26; - public static readonly ESCAPE_CHARACTER = 27; - public static readonly EXPRESSION = 28; - public static readonly TEXT = 29; - public static readonly MULTILINE_SUFFIX = 30; - public static readonly WS_IN_STRUCTURE_NAME = 31; - public static readonly NEWLINE_IN_STRUCTURE_NAME = 32; - public static readonly STRUCTURE_NAME = 33; - public static readonly TEXT_IN_STRUCTURE_NAME = 34; - public static readonly STRUCTURED_COMMENTS = 35; - public static readonly WS_IN_STRUCTURE_BODY = 36; - public static readonly STRUCTURED_NEWLINE = 37; - public static readonly STRUCTURED_BODY_END = 38; - public static readonly STRUCTURE_IDENTIFIER = 39; - public static readonly STRUCTURE_EQUALS = 40; - public static readonly STRUCTURE_OR_MARK = 41; - public static readonly ESCAPE_CHARACTER_IN_STRUCTURE_BODY = 42; - public static readonly EXPRESSION_IN_STRUCTURE_BODY = 43; - public static readonly TEXT_IN_STRUCTURE_BODY = 44; - public static readonly RULE_file = 0; - public static readonly RULE_paragraph = 1; - public static readonly RULE_errorTemplate = 2; - public static readonly RULE_templateDefinition = 3; - public static readonly RULE_templateNameLine = 4; - public static readonly RULE_errorTemplateName = 5; - public static readonly RULE_templateName = 6; - public static readonly RULE_parameters = 7; - public static readonly RULE_templateBody = 8; - public static readonly RULE_structuredTemplateBody = 9; - public static readonly RULE_structuredBodyNameLine = 10; - public static readonly RULE_errorStructuredName = 11; - public static readonly RULE_structuredBodyContentLine = 12; - public static readonly RULE_errorStructureLine = 13; - public static readonly RULE_keyValueStructureLine = 14; - public static readonly RULE_keyValueStructureValue = 15; - public static readonly RULE_objectStructureLine = 16; - public static readonly RULE_structuredBodyEndLine = 17; - public static readonly RULE_normalTemplateBody = 18; - public static readonly RULE_templateString = 19; - public static readonly RULE_normalTemplateString = 20; - public static readonly RULE_errorTemplateString = 21; - public static readonly RULE_ifElseTemplateBody = 22; - public static readonly RULE_ifConditionRule = 23; - public static readonly RULE_ifCondition = 24; - public static readonly RULE_switchCaseTemplateBody = 25; - public static readonly RULE_switchCaseRule = 26; - public static readonly RULE_switchCaseStat = 27; - public static readonly RULE_importDefinition = 28; - public static readonly RULE_optionsDefinition = 29; - // tslint:disable:no-trailing-whitespace - public static readonly ruleNames: string[] = [ - 'file', 'paragraph', 'errorTemplate', 'templateDefinition', 'templateNameLine', - 'errorTemplateName', 'templateName', 'parameters', 'templateBody', 'structuredTemplateBody', - 'structuredBodyNameLine', 'errorStructuredName', 'structuredBodyContentLine', - 'errorStructureLine', 'keyValueStructureLine', 'keyValueStructureValue', - 'objectStructureLine', 'structuredBodyEndLine', 'normalTemplateBody', - 'templateString', 'normalTemplateString', 'errorTemplateString', 'ifElseTemplateBody', - 'ifConditionRule', 'ifCondition', 'switchCaseTemplateBody', 'switchCaseRule', - 'switchCaseStat', 'importDefinition', 'optionsDefinition', - ]; - - private static readonly _LITERAL_NAMES: Array = [ - undefined, undefined, undefined, undefined, undefined, undefined, undefined, - undefined, undefined, undefined, undefined, undefined, undefined, '\'.\'', - '\'(\'', '\')\'', '\',\'', undefined, undefined, undefined, undefined, undefined, - undefined, undefined, undefined, undefined, undefined, undefined, undefined, - undefined, undefined, undefined, undefined, undefined, undefined, undefined, - undefined, undefined, undefined, undefined, undefined, '\'|\'', - ]; - private static readonly _SYMBOLIC_NAMES: Array = [ - undefined, 'OPTIONS', 'COMMENTS', 'WS', 'NEWLINE', 'HASH', 'DASH', 'LEFT_SQUARE_BRACKET', - 'IMPORT', 'INVALID_TOKEN', 'WS_IN_NAME', 'NEWLINE_IN_NAME', 'IDENTIFIER', - 'DOT', 'OPEN_PARENTHESIS', 'CLOSE_PARENTHESIS', 'COMMA', 'TEXT_IN_NAME', - 'WS_IN_BODY', 'MULTILINE_PREFIX', 'NEWLINE_IN_BODY', 'IF', 'ELSEIF', 'ELSE', - 'SWITCH', 'CASE', 'DEFAULT', 'ESCAPE_CHARACTER', 'EXPRESSION', 'TEXT', - 'MULTILINE_SUFFIX', 'WS_IN_STRUCTURE_NAME', 'NEWLINE_IN_STRUCTURE_NAME', - 'STRUCTURE_NAME', 'TEXT_IN_STRUCTURE_NAME', 'STRUCTURED_COMMENTS', 'WS_IN_STRUCTURE_BODY', - 'STRUCTURED_NEWLINE', 'STRUCTURED_BODY_END', 'STRUCTURE_IDENTIFIER', 'STRUCTURE_EQUALS', - 'STRUCTURE_OR_MARK', 'ESCAPE_CHARACTER_IN_STRUCTURE_BODY', 'EXPRESSION_IN_STRUCTURE_BODY', - 'TEXT_IN_STRUCTURE_BODY', - ]; - public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(LGFileParser._LITERAL_NAMES, LGFileParser._SYMBOLIC_NAMES, []); - - // @Override - // @NotNull - public get vocabulary(): Vocabulary { - return LGFileParser.VOCABULARY; - } - // tslint:enable:no-trailing-whitespace - - // @Override - public get grammarFileName(): string { return 'LGFileParser.g4'; } - - // @Override - public get ruleNames(): string[] { return LGFileParser.ruleNames; } - - // @Override - public get serializedATN(): string { return LGFileParser._serializedATN; } - - constructor(input: TokenStream) { - super(input); - this._interp = new ParserATNSimulator(LGFileParser._ATN, this); - } - // @RuleVersion(0) - public file(): FileContext { - let _localctx: FileContext = new FileContext(this._ctx, this.state); - this.enterRule(_localctx, 0, LGFileParser.RULE_file); - try { - let _alt: number; - this.enterOuterAlt(_localctx, 1); - { - this.state = 61; - this._errHandler.sync(this); - _alt = 1 + 1; - do { - switch (_alt) { - case 1 + 1: - { - { - this.state = 60; - this.paragraph(); - } - } - break; - default: - throw new NoViableAltException(this); - } - this.state = 63; - this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 0, this._ctx); - } while (_alt !== 1 && _alt !== ATN.INVALID_ALT_NUMBER); - this.state = 65; - this.match(LGFileParser.EOF); - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - // @RuleVersion(0) - public paragraph(): ParagraphContext { - let _localctx: ParagraphContext = new ParagraphContext(this._ctx, this.state); - this.enterRule(_localctx, 2, LGFileParser.RULE_paragraph); - try { - this.state = 72; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case LGFileParser.HASH: - this.enterOuterAlt(_localctx, 1); - { - this.state = 67; - this.templateDefinition(); - } - break; - case LGFileParser.IMPORT: - this.enterOuterAlt(_localctx, 2); - { - this.state = 68; - this.importDefinition(); - } - break; - case LGFileParser.OPTIONS: - this.enterOuterAlt(_localctx, 3); - { - this.state = 69; - this.optionsDefinition(); - } - break; - case LGFileParser.EOF: - this.enterOuterAlt(_localctx, 4); - { - this.state = 70; - this.match(LGFileParser.EOF); - } - break; - case LGFileParser.INVALID_TOKEN: - this.enterOuterAlt(_localctx, 5); - { - this.state = 71; - this.errorTemplate(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - // @RuleVersion(0) - public errorTemplate(): ErrorTemplateContext { - let _localctx: ErrorTemplateContext = new ErrorTemplateContext(this._ctx, this.state); - this.enterRule(_localctx, 4, LGFileParser.RULE_errorTemplate); - try { - let _alt: number; - this.enterOuterAlt(_localctx, 1); - { - this.state = 75; - this._errHandler.sync(this); - _alt = 1; - do { - switch (_alt) { - case 1: - { - { - this.state = 74; - this.match(LGFileParser.INVALID_TOKEN); - } - } - break; - default: - throw new NoViableAltException(this); - } - this.state = 77; - this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 2, this._ctx); - } while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER); - } - } - 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 templateDefinition(): TemplateDefinitionContext { - let _localctx: TemplateDefinitionContext = new TemplateDefinitionContext(this._ctx, this.state); - this.enterRule(_localctx, 6, LGFileParser.RULE_templateDefinition); - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 79; - this.templateNameLine(); - this.state = 81; - this._errHandler.sync(this); - switch ( this.interpreter.adaptivePredict(this._input, 3, this._ctx) ) { - case 1: - { - this.state = 80; - this.templateBody(); - } - break; - } - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - // @RuleVersion(0) - public templateNameLine(): TemplateNameLineContext { - let _localctx: TemplateNameLineContext = new TemplateNameLineContext(this._ctx, this.state); - this.enterRule(_localctx, 8, LGFileParser.RULE_templateNameLine); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 83; - this.match(LGFileParser.HASH); - this.state = 89; - this._errHandler.sync(this); - switch ( this.interpreter.adaptivePredict(this._input, 5, this._ctx) ) { - case 1: - { - { - this.state = 84; - this.templateName(); - this.state = 86; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === LGFileParser.OPEN_PARENTHESIS) { - { - this.state = 85; - this.parameters(); - } - } - - } - } - break; - - case 2: - { - this.state = 88; - this.errorTemplateName(); - } - break; - } - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - // @RuleVersion(0) - public errorTemplateName(): ErrorTemplateNameContext { - let _localctx: ErrorTemplateNameContext = new ErrorTemplateNameContext(this._ctx, this.state); - this.enterRule(_localctx, 10, LGFileParser.RULE_errorTemplateName); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 94; - this._errHandler.sync(this); - _la = this._input.LA(1); - while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.IDENTIFIER) | (1 << LGFileParser.DOT) | (1 << LGFileParser.OPEN_PARENTHESIS) | (1 << LGFileParser.CLOSE_PARENTHESIS) | (1 << LGFileParser.COMMA) | (1 << LGFileParser.TEXT_IN_NAME))) !== 0)) { - { - { - this.state = 91; - _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.IDENTIFIER) | (1 << LGFileParser.DOT) | (1 << LGFileParser.OPEN_PARENTHESIS) | (1 << LGFileParser.CLOSE_PARENTHESIS) | (1 << LGFileParser.COMMA) | (1 << LGFileParser.TEXT_IN_NAME))) !== 0))) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - } - } - this.state = 96; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } - } - 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 templateName(): TemplateNameContext { - let _localctx: TemplateNameContext = new TemplateNameContext(this._ctx, this.state); - this.enterRule(_localctx, 12, LGFileParser.RULE_templateName); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 97; - this.match(LGFileParser.IDENTIFIER); - this.state = 102; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === LGFileParser.DOT) { - { - { - this.state = 98; - this.match(LGFileParser.DOT); - this.state = 99; - this.match(LGFileParser.IDENTIFIER); - } - } - this.state = 104; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } - } - 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 parameters(): ParametersContext { - let _localctx: ParametersContext = new ParametersContext(this._ctx, this.state); - this.enterRule(_localctx, 14, LGFileParser.RULE_parameters); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 105; - this.match(LGFileParser.OPEN_PARENTHESIS); - this.state = 114; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === LGFileParser.IDENTIFIER) { - { - this.state = 106; - this.match(LGFileParser.IDENTIFIER); - this.state = 111; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === LGFileParser.COMMA) { - { - { - this.state = 107; - this.match(LGFileParser.COMMA); - this.state = 108; - this.match(LGFileParser.IDENTIFIER); - } - } - this.state = 113; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } - } - - this.state = 116; - this.match(LGFileParser.CLOSE_PARENTHESIS); - } - } - 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 templateBody(): TemplateBodyContext { - let _localctx: TemplateBodyContext = new TemplateBodyContext(this._ctx, this.state); - this.enterRule(_localctx, 16, LGFileParser.RULE_templateBody); - try { - this.state = 122; - this._errHandler.sync(this); - switch ( this.interpreter.adaptivePredict(this._input, 10, this._ctx) ) { - case 1: - _localctx = new NormalBodyContext(_localctx); - this.enterOuterAlt(_localctx, 1); - { - this.state = 118; - this.normalTemplateBody(); - } - break; - - case 2: - _localctx = new IfElseBodyContext(_localctx); - this.enterOuterAlt(_localctx, 2); - { - this.state = 119; - this.ifElseTemplateBody(); - } - break; - - case 3: - _localctx = new SwitchCaseBodyContext(_localctx); - this.enterOuterAlt(_localctx, 3); - { - this.state = 120; - this.switchCaseTemplateBody(); - } - break; - - case 4: - _localctx = new StructuredBodyContext(_localctx); - this.enterOuterAlt(_localctx, 4); - { - this.state = 121; - this.structuredTemplateBody(); - } - break; - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - // @RuleVersion(0) - public structuredTemplateBody(): StructuredTemplateBodyContext { - let _localctx: StructuredTemplateBodyContext = new StructuredTemplateBodyContext(this._ctx, this.state); - this.enterRule(_localctx, 18, LGFileParser.RULE_structuredTemplateBody); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 124; - this.structuredBodyNameLine(); - this.state = 132; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (((((_la - 39)) & ~0x1F) === 0 && ((1 << (_la - 39)) & ((1 << (LGFileParser.STRUCTURE_IDENTIFIER - 39)) | (1 << (LGFileParser.STRUCTURE_EQUALS - 39)) | (1 << (LGFileParser.STRUCTURE_OR_MARK - 39)) | (1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 39)))) !== 0)) { - { - this.state = 128; - this._errHandler.sync(this); - _la = this._input.LA(1); - do { - { - { - this.state = 125; - this.structuredBodyContentLine(); - this.state = 126; - this.match(LGFileParser.STRUCTURED_NEWLINE); - } - } - this.state = 130; - this._errHandler.sync(this); - _la = this._input.LA(1); - } while (((((_la - 39)) & ~0x1F) === 0 && ((1 << (_la - 39)) & ((1 << (LGFileParser.STRUCTURE_IDENTIFIER - 39)) | (1 << (LGFileParser.STRUCTURE_EQUALS - 39)) | (1 << (LGFileParser.STRUCTURE_OR_MARK - 39)) | (1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 39)))) !== 0)); - } - } - - this.state = 135; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === LGFileParser.STRUCTURED_BODY_END) { - { - this.state = 134; - this.structuredBodyEndLine(); - } - } - - } - } - 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 structuredBodyNameLine(): StructuredBodyNameLineContext { - let _localctx: StructuredBodyNameLineContext = new StructuredBodyNameLineContext(this._ctx, this.state); - this.enterRule(_localctx, 20, LGFileParser.RULE_structuredBodyNameLine); - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 137; - this.match(LGFileParser.LEFT_SQUARE_BRACKET); - this.state = 140; - this._errHandler.sync(this); - switch ( this.interpreter.adaptivePredict(this._input, 14, this._ctx) ) { - case 1: - { - this.state = 138; - this.match(LGFileParser.STRUCTURE_NAME); - } - break; - - case 2: - { - this.state = 139; - this.errorStructuredName(); - } - break; - } - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - // @RuleVersion(0) - public errorStructuredName(): ErrorStructuredNameContext { - let _localctx: ErrorStructuredNameContext = new ErrorStructuredNameContext(this._ctx, this.state); - this.enterRule(_localctx, 22, LGFileParser.RULE_errorStructuredName); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 145; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === LGFileParser.STRUCTURE_NAME || _la === LGFileParser.TEXT_IN_STRUCTURE_NAME) { - { - { - this.state = 142; - _la = this._input.LA(1); - if (!(_la === LGFileParser.STRUCTURE_NAME || _la === LGFileParser.TEXT_IN_STRUCTURE_NAME)) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - } - } - this.state = 147; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } - } - 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 structuredBodyContentLine(): StructuredBodyContentLineContext { - let _localctx: StructuredBodyContentLineContext = new StructuredBodyContentLineContext(this._ctx, this.state); - this.enterRule(_localctx, 24, LGFileParser.RULE_structuredBodyContentLine); - try { - this.state = 151; - this._errHandler.sync(this); - switch ( this.interpreter.adaptivePredict(this._input, 16, this._ctx) ) { - case 1: - this.enterOuterAlt(_localctx, 1); - { - this.state = 148; - this.keyValueStructureLine(); - } - break; - - case 2: - this.enterOuterAlt(_localctx, 2); - { - this.state = 149; - this.objectStructureLine(); - } - break; - - case 3: - this.enterOuterAlt(_localctx, 3); - { - this.state = 150; - this.errorStructureLine(); - } - break; - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - // @RuleVersion(0) - public errorStructureLine(): ErrorStructureLineContext { - let _localctx: ErrorStructureLineContext = new ErrorStructureLineContext(this._ctx, this.state); - this.enterRule(_localctx, 26, LGFileParser.RULE_errorStructureLine); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 154; - this._errHandler.sync(this); - _la = this._input.LA(1); - do { - { - { - this.state = 153; - _la = this._input.LA(1); - if (!(((((_la - 39)) & ~0x1F) === 0 && ((1 << (_la - 39)) & ((1 << (LGFileParser.STRUCTURE_IDENTIFIER - 39)) | (1 << (LGFileParser.STRUCTURE_EQUALS - 39)) | (1 << (LGFileParser.STRUCTURE_OR_MARK - 39)) | (1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 39)))) !== 0))) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - } - } - this.state = 156; - this._errHandler.sync(this); - _la = this._input.LA(1); - } while (((((_la - 39)) & ~0x1F) === 0 && ((1 << (_la - 39)) & ((1 << (LGFileParser.STRUCTURE_IDENTIFIER - 39)) | (1 << (LGFileParser.STRUCTURE_EQUALS - 39)) | (1 << (LGFileParser.STRUCTURE_OR_MARK - 39)) | (1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 39)))) !== 0)); - } - } - 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 keyValueStructureLine(): KeyValueStructureLineContext { - let _localctx: KeyValueStructureLineContext = new KeyValueStructureLineContext(this._ctx, this.state); - this.enterRule(_localctx, 28, LGFileParser.RULE_keyValueStructureLine); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 158; - this.match(LGFileParser.STRUCTURE_IDENTIFIER); - this.state = 159; - this.match(LGFileParser.STRUCTURE_EQUALS); - this.state = 160; - this.keyValueStructureValue(); - this.state = 165; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === LGFileParser.STRUCTURE_OR_MARK) { - { - { - this.state = 161; - this.match(LGFileParser.STRUCTURE_OR_MARK); - this.state = 162; - this.keyValueStructureValue(); - } - } - this.state = 167; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } - } - 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 keyValueStructureValue(): KeyValueStructureValueContext { - let _localctx: KeyValueStructureValueContext = new KeyValueStructureValueContext(this._ctx, this.state); - this.enterRule(_localctx, 30, LGFileParser.RULE_keyValueStructureValue); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 169; - this._errHandler.sync(this); - _la = this._input.LA(1); - do { - { - { - this.state = 168; - _la = this._input.LA(1); - if (!(((((_la - 42)) & ~0x1F) === 0 && ((1 << (_la - 42)) & ((1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 42)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 42)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 42)))) !== 0))) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - } - } - this.state = 171; - this._errHandler.sync(this); - _la = this._input.LA(1); - } while (((((_la - 42)) & ~0x1F) === 0 && ((1 << (_la - 42)) & ((1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 42)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 42)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 42)))) !== 0)); - } - } - 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 objectStructureLine(): ObjectStructureLineContext { - let _localctx: ObjectStructureLineContext = new ObjectStructureLineContext(this._ctx, this.state); - this.enterRule(_localctx, 32, LGFileParser.RULE_objectStructureLine); - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 173; - this.match(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY); - } - } - 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 structuredBodyEndLine(): StructuredBodyEndLineContext { - let _localctx: StructuredBodyEndLineContext = new StructuredBodyEndLineContext(this._ctx, this.state); - this.enterRule(_localctx, 34, LGFileParser.RULE_structuredBodyEndLine); - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 175; - this.match(LGFileParser.STRUCTURED_BODY_END); - } - } - 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 normalTemplateBody(): NormalTemplateBodyContext { - let _localctx: NormalTemplateBodyContext = new NormalTemplateBodyContext(this._ctx, this.state); - this.enterRule(_localctx, 36, LGFileParser.RULE_normalTemplateBody); - try { - let _alt: number; - this.enterOuterAlt(_localctx, 1); - { - this.state = 178; - this._errHandler.sync(this); - _alt = 1; - do { - switch (_alt) { - case 1: - { - { - this.state = 177; - this.templateString(); - } - } - break; - default: - throw new NoViableAltException(this); - } - this.state = 180; - this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 20, this._ctx); - } while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER); - } - } - 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 templateString(): TemplateStringContext { - let _localctx: TemplateStringContext = new TemplateStringContext(this._ctx, this.state); - this.enterRule(_localctx, 38, LGFileParser.RULE_templateString); - try { - this.state = 184; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case LGFileParser.DASH: - this.enterOuterAlt(_localctx, 1); - { - this.state = 182; - this.normalTemplateString(); - } - break; - case LGFileParser.INVALID_TOKEN: - this.enterOuterAlt(_localctx, 2); - { - this.state = 183; - this.errorTemplateString(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - // @RuleVersion(0) - public normalTemplateString(): NormalTemplateStringContext { - let _localctx: NormalTemplateStringContext = new NormalTemplateStringContext(this._ctx, this.state); - this.enterRule(_localctx, 40, LGFileParser.RULE_normalTemplateString); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 186; - this.match(LGFileParser.DASH); - this.state = 188; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === LGFileParser.MULTILINE_PREFIX) { - { - this.state = 187; - this.match(LGFileParser.MULTILINE_PREFIX); - } - } - - this.state = 193; - this._errHandler.sync(this); - _la = this._input.LA(1); - while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.ESCAPE_CHARACTER) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0)) { - { - { - this.state = 190; - _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.ESCAPE_CHARACTER) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0))) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - } - } - this.state = 195; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 197; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === LGFileParser.MULTILINE_SUFFIX) { - { - this.state = 196; - this.match(LGFileParser.MULTILINE_SUFFIX); - } - } - - } - } - 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 errorTemplateString(): ErrorTemplateStringContext { - let _localctx: ErrorTemplateStringContext = new ErrorTemplateStringContext(this._ctx, this.state); - this.enterRule(_localctx, 42, LGFileParser.RULE_errorTemplateString); - try { - let _alt: number; - this.enterOuterAlt(_localctx, 1); - { - this.state = 200; - this._errHandler.sync(this); - _alt = 1; - do { - switch (_alt) { - case 1: - { - { - this.state = 199; - this.match(LGFileParser.INVALID_TOKEN); - } - } - break; - default: - throw new NoViableAltException(this); - } - this.state = 202; - this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 25, this._ctx); - } while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER); - } - } - 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 ifElseTemplateBody(): IfElseTemplateBodyContext { - let _localctx: IfElseTemplateBodyContext = new IfElseTemplateBodyContext(this._ctx, this.state); - this.enterRule(_localctx, 44, LGFileParser.RULE_ifElseTemplateBody); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 205; - this._errHandler.sync(this); - _la = this._input.LA(1); - do { - { - { - this.state = 204; - this.ifConditionRule(); - } - } - this.state = 207; - this._errHandler.sync(this); - _la = this._input.LA(1); - } while (_la === LGFileParser.DASH); - } - } - 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 ifConditionRule(): IfConditionRuleContext { - let _localctx: IfConditionRuleContext = new IfConditionRuleContext(this._ctx, this.state); - this.enterRule(_localctx, 46, LGFileParser.RULE_ifConditionRule); - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 209; - this.ifCondition(); - this.state = 211; - this._errHandler.sync(this); - switch ( this.interpreter.adaptivePredict(this._input, 27, this._ctx) ) { - case 1: - { - this.state = 210; - this.normalTemplateBody(); - } - break; - } - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - // @RuleVersion(0) - public ifCondition(): IfConditionContext { - let _localctx: IfConditionContext = new IfConditionContext(this._ctx, this.state); - this.enterRule(_localctx, 48, LGFileParser.RULE_ifCondition); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 213; - this.match(LGFileParser.DASH); - this.state = 214; - _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.IF) | (1 << LGFileParser.ELSEIF) | (1 << LGFileParser.ELSE))) !== 0))) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 218; - this._errHandler.sync(this); - _la = this._input.LA(1); - while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.WS) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0)) { - { - { - this.state = 215; - _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.WS) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0))) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - } - } - this.state = 220; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } - } - 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 switchCaseTemplateBody(): SwitchCaseTemplateBodyContext { - let _localctx: SwitchCaseTemplateBodyContext = new SwitchCaseTemplateBodyContext(this._ctx, this.state); - this.enterRule(_localctx, 50, LGFileParser.RULE_switchCaseTemplateBody); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 222; - this._errHandler.sync(this); - _la = this._input.LA(1); - do { - { - { - this.state = 221; - this.switchCaseRule(); - } - } - this.state = 224; - this._errHandler.sync(this); - _la = this._input.LA(1); - } while (_la === LGFileParser.DASH); - } - } - 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 switchCaseRule(): SwitchCaseRuleContext { - let _localctx: SwitchCaseRuleContext = new SwitchCaseRuleContext(this._ctx, this.state); - this.enterRule(_localctx, 52, LGFileParser.RULE_switchCaseRule); - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 226; - this.switchCaseStat(); - this.state = 228; - this._errHandler.sync(this); - switch ( this.interpreter.adaptivePredict(this._input, 30, this._ctx) ) { - case 1: - { - this.state = 227; - this.normalTemplateBody(); - } - break; - } - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - // @RuleVersion(0) - public switchCaseStat(): SwitchCaseStatContext { - let _localctx: SwitchCaseStatContext = new SwitchCaseStatContext(this._ctx, this.state); - this.enterRule(_localctx, 54, LGFileParser.RULE_switchCaseStat); - let _la: number; - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 230; - this.match(LGFileParser.DASH); - this.state = 231; - _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.SWITCH) | (1 << LGFileParser.CASE) | (1 << LGFileParser.DEFAULT))) !== 0))) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 235; - this._errHandler.sync(this); - _la = this._input.LA(1); - while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.WS) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0)) { - { - { - this.state = 232; - _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.WS) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0))) { - this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - - this._errHandler.reportMatch(this); - this.consume(); - } - } - } - this.state = 237; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - } - } - 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 importDefinition(): ImportDefinitionContext { - let _localctx: ImportDefinitionContext = new ImportDefinitionContext(this._ctx, this.state); - this.enterRule(_localctx, 56, LGFileParser.RULE_importDefinition); - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 238; - this.match(LGFileParser.IMPORT); - } - } - 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 optionsDefinition(): OptionsDefinitionContext { - let _localctx: OptionsDefinitionContext = new OptionsDefinitionContext(this._ctx, this.state); - this.enterRule(_localctx, 58, LGFileParser.RULE_optionsDefinition); - try { - this.enterOuterAlt(_localctx, 1); - { - this.state = 240; - this.match(LGFileParser.OPTIONS); - } - } - catch (re) { - if (re instanceof RecognitionException) { - _localctx.exception = re; - this._errHandler.reportError(this, re); - this._errHandler.recover(this, re); - } else { - throw re; - } - } - finally { - this.exitRule(); - } - return _localctx; - } - - public static readonly _serializedATN: string = - '\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x03.\xF5\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\x03\x02\x06\x02@\n\x02\r\x02\x0E' + - '\x02A\x03\x02\x03\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x05\x03' + - 'K\n\x03\x03\x04\x06\x04N\n\x04\r\x04\x0E\x04O\x03\x05\x03\x05\x05\x05' + - 'T\n\x05\x03\x06\x03\x06\x03\x06\x05\x06Y\n\x06\x03\x06\x05\x06\\\n\x06' + - '\x03\x07\x07\x07_\n\x07\f\x07\x0E\x07b\v\x07\x03\b\x03\b\x03\b\x07\bg' + - '\n\b\f\b\x0E\bj\v\b\x03\t\x03\t\x03\t\x03\t\x07\tp\n\t\f\t\x0E\ts\v\t' + - '\x05\tu\n\t\x03\t\x03\t\x03\n\x03\n\x03\n\x03\n\x05\n}\n\n\x03\v\x03\v' + - '\x03\v\x03\v\x06\v\x83\n\v\r\v\x0E\v\x84\x05\v\x87\n\v\x03\v\x05\v\x8A' + - '\n\v\x03\f\x03\f\x03\f\x05\f\x8F\n\f\x03\r\x07\r\x92\n\r\f\r\x0E\r\x95' + - '\v\r\x03\x0E\x03\x0E\x03\x0E\x05\x0E\x9A\n\x0E\x03\x0F\x06\x0F\x9D\n\x0F' + - '\r\x0F\x0E\x0F\x9E\x03\x10\x03\x10\x03\x10\x03\x10\x03\x10\x07\x10\xA6' + - '\n\x10\f\x10\x0E\x10\xA9\v\x10\x03\x11\x06\x11\xAC\n\x11\r\x11\x0E\x11' + - '\xAD\x03\x12\x03\x12\x03\x13\x03\x13\x03\x14\x06\x14\xB5\n\x14\r\x14\x0E' + - '\x14\xB6\x03\x15\x03\x15\x05\x15\xBB\n\x15\x03\x16\x03\x16\x05\x16\xBF' + - '\n\x16\x03\x16\x07\x16\xC2\n\x16\f\x16\x0E\x16\xC5\v\x16\x03\x16\x05\x16' + - '\xC8\n\x16\x03\x17\x06\x17\xCB\n\x17\r\x17\x0E\x17\xCC\x03\x18\x06\x18' + - '\xD0\n\x18\r\x18\x0E\x18\xD1\x03\x19\x03\x19\x05\x19\xD6\n\x19\x03\x1A' + - '\x03\x1A\x03\x1A\x07\x1A\xDB\n\x1A\f\x1A\x0E\x1A\xDE\v\x1A\x03\x1B\x06' + - '\x1B\xE1\n\x1B\r\x1B\x0E\x1B\xE2\x03\x1C\x03\x1C\x05\x1C\xE7\n\x1C\x03' + - '\x1D\x03\x1D\x03\x1D\x07\x1D\xEC\n\x1D\f\x1D\x0E\x1D\xEF\v\x1D\x03\x1E' + - '\x03\x1E\x03\x1F\x03\x1F\x03\x1F\x03A\x02\x02 \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\x02' + - '4\x026\x028\x02:\x02<\x02\x02\n\x03\x02\x0E\x13\x03\x02#$\x03\x02).\x03' + - '\x02,.\x03\x02\x1D\x1F\x03\x02\x17\x19\x04\x02\x05\x05\x1E\x1F\x03\x02' + - '\x1A\x1C\xFC\x02?\x03\x02\x02\x02\x04J\x03\x02\x02\x02\x06M\x03\x02\x02' + - '\x02\bQ\x03\x02\x02\x02\nU\x03\x02\x02\x02\f`\x03\x02\x02\x02\x0Ec\x03' + - '\x02\x02\x02\x10k\x03\x02\x02\x02\x12|\x03\x02\x02\x02\x14~\x03\x02\x02' + - '\x02\x16\x8B\x03\x02\x02\x02\x18\x93\x03\x02\x02\x02\x1A\x99\x03\x02\x02' + - '\x02\x1C\x9C\x03\x02\x02\x02\x1E\xA0\x03\x02\x02\x02 \xAB\x03\x02\x02' + - '\x02"\xAF\x03\x02\x02\x02$\xB1\x03\x02\x02\x02&\xB4\x03\x02\x02\x02(' + - '\xBA\x03\x02\x02\x02*\xBC\x03\x02\x02\x02,\xCA\x03\x02\x02\x02.\xCF\x03' + - '\x02\x02\x020\xD3\x03\x02\x02\x022\xD7\x03\x02\x02\x024\xE0\x03\x02\x02' + - '\x026\xE4\x03\x02\x02\x028\xE8\x03\x02\x02\x02:\xF0\x03\x02\x02\x02<\xF2' + - '\x03\x02\x02\x02>@\x05\x04\x03\x02?>\x03\x02\x02\x02@A\x03\x02\x02\x02' + - 'AB\x03\x02\x02\x02A?\x03\x02\x02\x02BC\x03\x02\x02\x02CD\x07\x02\x02\x03' + - 'D\x03\x03\x02\x02\x02EK\x05\b\x05\x02FK\x05:\x1E\x02GK\x05<\x1F\x02HK' + - '\x07\x02\x02\x03IK\x05\x06\x04\x02JE\x03\x02\x02\x02JF\x03\x02\x02\x02' + - 'JG\x03\x02\x02\x02JH\x03\x02\x02\x02JI\x03\x02\x02\x02K\x05\x03\x02\x02' + - '\x02LN\x07\v\x02\x02ML\x03\x02\x02\x02NO\x03\x02\x02\x02OM\x03\x02\x02' + - '\x02OP\x03\x02\x02\x02P\x07\x03\x02\x02\x02QS\x05\n\x06\x02RT\x05\x12' + - '\n\x02SR\x03\x02\x02\x02ST\x03\x02\x02\x02T\t\x03\x02\x02\x02U[\x07\x07' + - '\x02\x02VX\x05\x0E\b\x02WY\x05\x10\t\x02XW\x03\x02\x02\x02XY\x03\x02\x02' + - '\x02Y\\\x03\x02\x02\x02Z\\\x05\f\x07\x02[V\x03\x02\x02\x02[Z\x03\x02\x02' + - '\x02\\\v\x03\x02\x02\x02]_\t\x02\x02\x02^]\x03\x02\x02\x02_b\x03\x02\x02' + - '\x02`^\x03\x02\x02\x02`a\x03\x02\x02\x02a\r\x03\x02\x02\x02b`\x03\x02' + - '\x02\x02ch\x07\x0E\x02\x02de\x07\x0F\x02\x02eg\x07\x0E\x02\x02fd\x03\x02' + - '\x02\x02gj\x03\x02\x02\x02hf\x03\x02\x02\x02hi\x03\x02\x02\x02i\x0F\x03' + - '\x02\x02\x02jh\x03\x02\x02\x02kt\x07\x10\x02\x02lq\x07\x0E\x02\x02mn\x07' + - '\x12\x02\x02np\x07\x0E\x02\x02om\x03\x02\x02\x02ps\x03\x02\x02\x02qo\x03' + - '\x02\x02\x02qr\x03\x02\x02\x02ru\x03\x02\x02\x02sq\x03\x02\x02\x02tl\x03' + - '\x02\x02\x02tu\x03\x02\x02\x02uv\x03\x02\x02\x02vw\x07\x11\x02\x02w\x11' + - '\x03\x02\x02\x02x}\x05&\x14\x02y}\x05.\x18\x02z}\x054\x1B\x02{}\x05\x14' + - '\v\x02|x\x03\x02\x02\x02|y\x03\x02\x02\x02|z\x03\x02\x02\x02|{\x03\x02' + - '\x02\x02}\x13\x03\x02\x02\x02~\x86\x05\x16\f\x02\x7F\x80\x05\x1A\x0E\x02' + - '\x80\x81\x07\'\x02\x02\x81\x83\x03\x02\x02\x02\x82\x7F\x03\x02\x02\x02' + - '\x83\x84\x03\x02\x02\x02\x84\x82\x03\x02\x02\x02\x84\x85\x03\x02\x02\x02' + - '\x85\x87\x03\x02\x02\x02\x86\x82\x03\x02\x02\x02\x86\x87\x03\x02\x02\x02' + - '\x87\x89\x03\x02\x02\x02\x88\x8A\x05$\x13\x02\x89\x88\x03\x02\x02\x02' + - '\x89\x8A\x03\x02\x02\x02\x8A\x15\x03\x02\x02\x02\x8B\x8E\x07\t\x02\x02' + - '\x8C\x8F\x07#\x02\x02\x8D\x8F\x05\x18\r\x02\x8E\x8C\x03\x02\x02\x02\x8E' + - '\x8D\x03\x02\x02\x02\x8F\x17\x03\x02\x02\x02\x90\x92\t\x03\x02\x02\x91' + - '\x90\x03\x02\x02\x02\x92\x95\x03\x02\x02\x02\x93\x91\x03\x02\x02\x02\x93' + - '\x94\x03\x02\x02\x02\x94\x19\x03\x02\x02\x02\x95\x93\x03\x02\x02\x02\x96' + - '\x9A\x05\x1E\x10\x02\x97\x9A\x05"\x12\x02\x98\x9A\x05\x1C\x0F\x02\x99' + - '\x96\x03\x02\x02\x02\x99\x97\x03\x02\x02\x02\x99\x98\x03\x02\x02\x02\x9A' + - '\x1B\x03\x02\x02\x02\x9B\x9D\t\x04\x02\x02\x9C\x9B\x03\x02\x02\x02\x9D' + - '\x9E\x03\x02\x02\x02\x9E\x9C\x03\x02\x02\x02\x9E\x9F\x03\x02\x02\x02\x9F' + - '\x1D\x03\x02\x02\x02\xA0\xA1\x07)\x02\x02\xA1\xA2\x07*\x02\x02\xA2\xA7' + - '\x05 \x11\x02\xA3\xA4\x07+\x02\x02\xA4\xA6\x05 \x11\x02\xA5\xA3\x03\x02' + - '\x02\x02\xA6\xA9\x03\x02\x02\x02\xA7\xA5\x03\x02\x02\x02\xA7\xA8\x03\x02' + - '\x02\x02\xA8\x1F\x03\x02\x02\x02\xA9\xA7\x03\x02\x02\x02\xAA\xAC\t\x05' + - '\x02\x02\xAB\xAA\x03\x02\x02\x02\xAC\xAD\x03\x02\x02\x02\xAD\xAB\x03\x02' + - '\x02\x02\xAD\xAE\x03\x02\x02\x02\xAE!\x03\x02\x02\x02\xAF\xB0\x07-\x02' + - '\x02\xB0#\x03\x02\x02\x02\xB1\xB2\x07(\x02\x02\xB2%\x03\x02\x02\x02\xB3' + - '\xB5\x05(\x15\x02\xB4\xB3\x03\x02\x02\x02\xB5\xB6\x03\x02\x02\x02\xB6' + - '\xB4\x03\x02\x02\x02\xB6\xB7\x03\x02\x02\x02\xB7\'\x03\x02\x02\x02\xB8' + - '\xBB\x05*\x16\x02\xB9\xBB\x05,\x17\x02\xBA\xB8\x03\x02\x02\x02\xBA\xB9' + - '\x03\x02\x02\x02\xBB)\x03\x02\x02\x02\xBC\xBE\x07\b\x02\x02\xBD\xBF\x07' + - '\x15\x02\x02\xBE\xBD\x03\x02\x02\x02\xBE\xBF\x03\x02\x02\x02\xBF\xC3\x03' + - '\x02\x02\x02\xC0\xC2\t\x06\x02\x02\xC1\xC0\x03\x02\x02\x02\xC2\xC5\x03' + - '\x02\x02\x02\xC3\xC1\x03\x02\x02\x02\xC3\xC4\x03\x02\x02\x02\xC4\xC7\x03' + - '\x02\x02\x02\xC5\xC3\x03\x02\x02\x02\xC6\xC8\x07 \x02\x02\xC7\xC6\x03' + - '\x02\x02\x02\xC7\xC8\x03\x02\x02\x02\xC8+\x03\x02\x02\x02\xC9\xCB\x07' + - '\v\x02\x02\xCA\xC9\x03\x02\x02\x02\xCB\xCC\x03\x02\x02\x02\xCC\xCA\x03' + - '\x02\x02\x02\xCC\xCD\x03\x02\x02\x02\xCD-\x03\x02\x02\x02\xCE\xD0\x05' + - '0\x19\x02\xCF\xCE\x03\x02\x02\x02\xD0\xD1\x03\x02\x02\x02\xD1\xCF\x03' + - '\x02\x02\x02\xD1\xD2\x03\x02\x02\x02\xD2/\x03\x02\x02\x02\xD3\xD5\x05' + - '2\x1A\x02\xD4\xD6\x05&\x14\x02\xD5\xD4\x03\x02\x02\x02\xD5\xD6\x03\x02' + - '\x02\x02\xD61\x03\x02\x02\x02\xD7\xD8\x07\b\x02\x02\xD8\xDC\t\x07\x02' + - '\x02\xD9\xDB\t\b\x02\x02\xDA\xD9\x03\x02\x02\x02\xDB\xDE\x03\x02\x02\x02' + - '\xDC\xDA\x03\x02\x02\x02\xDC\xDD\x03\x02\x02\x02\xDD3\x03\x02\x02\x02' + - '\xDE\xDC\x03\x02\x02\x02\xDF\xE1\x056\x1C\x02\xE0\xDF\x03\x02\x02\x02' + - '\xE1\xE2\x03\x02\x02\x02\xE2\xE0\x03\x02\x02\x02\xE2\xE3\x03\x02\x02\x02' + - '\xE35\x03\x02\x02\x02\xE4\xE6\x058\x1D\x02\xE5\xE7\x05&\x14\x02\xE6\xE5' + - '\x03\x02\x02\x02\xE6\xE7\x03\x02\x02\x02\xE77\x03\x02\x02\x02\xE8\xE9' + - '\x07\b\x02\x02\xE9\xED\t\t\x02\x02\xEA\xEC\t\b\x02\x02\xEB\xEA\x03\x02' + - '\x02\x02\xEC\xEF\x03\x02\x02\x02\xED\xEB\x03\x02\x02\x02\xED\xEE\x03\x02' + - '\x02\x02\xEE9\x03\x02\x02\x02\xEF\xED\x03\x02\x02\x02\xF0\xF1\x07\n\x02' + - '\x02\xF1;\x03\x02\x02\x02\xF2\xF3\x07\x03\x02\x02\xF3=\x03\x02\x02\x02' + - '"AJOSX[`hqt|\x84\x86\x89\x8E\x93\x99\x9E\xA7\xAD\xB6\xBA\xBE\xC3\xC7' + - '\xCC\xD1\xD5\xDC\xE2\xE6\xED'; - public static __ATN: ATN; - public static get _ATN(): ATN { - if (!LGFileParser.__ATN) { - LGFileParser.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(LGFileParser._serializedATN)); - } - - return LGFileParser.__ATN; - } - -} - -export class FileContext extends ParserRuleContext { - public EOF(): TerminalNode { return this.getToken(LGFileParser.EOF, 0); } - public paragraph(): ParagraphContext[]; - public paragraph(i: number): ParagraphContext; - public paragraph(i?: number): ParagraphContext | ParagraphContext[] { - if (i === undefined) { - return this.getRuleContexts(ParagraphContext); - } else { - return this.getRuleContext(i, ParagraphContext); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_file; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterFile) { - listener.enterFile(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitFile) { - listener.exitFile(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitFile) { - return visitor.visitFile(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class ParagraphContext extends ParserRuleContext { - public templateDefinition(): TemplateDefinitionContext | undefined { - return this.tryGetRuleContext(0, TemplateDefinitionContext); - } - public importDefinition(): ImportDefinitionContext | undefined { - return this.tryGetRuleContext(0, ImportDefinitionContext); - } - public optionsDefinition(): OptionsDefinitionContext | undefined { - return this.tryGetRuleContext(0, OptionsDefinitionContext); - } - public EOF(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.EOF, 0); } - public errorTemplate(): ErrorTemplateContext | undefined { - return this.tryGetRuleContext(0, ErrorTemplateContext); - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_paragraph; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterParagraph) { - listener.enterParagraph(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitParagraph) { - listener.exitParagraph(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitParagraph) { - return visitor.visitParagraph(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class ErrorTemplateContext extends ParserRuleContext { - public INVALID_TOKEN(): TerminalNode[]; - public INVALID_TOKEN(i: number): TerminalNode; - public INVALID_TOKEN(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.INVALID_TOKEN); - } else { - return this.getToken(LGFileParser.INVALID_TOKEN, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_errorTemplate; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterErrorTemplate) { - listener.enterErrorTemplate(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitErrorTemplate) { - listener.exitErrorTemplate(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitErrorTemplate) { - return visitor.visitErrorTemplate(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class TemplateDefinitionContext extends ParserRuleContext { - public templateNameLine(): TemplateNameLineContext { - return this.getRuleContext(0, TemplateNameLineContext); - } - public templateBody(): TemplateBodyContext | undefined { - return this.tryGetRuleContext(0, TemplateBodyContext); - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_templateDefinition; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterTemplateDefinition) { - listener.enterTemplateDefinition(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitTemplateDefinition) { - listener.exitTemplateDefinition(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitTemplateDefinition) { - return visitor.visitTemplateDefinition(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class TemplateNameLineContext extends ParserRuleContext { - public HASH(): TerminalNode { return this.getToken(LGFileParser.HASH, 0); } - public errorTemplateName(): ErrorTemplateNameContext | undefined { - return this.tryGetRuleContext(0, ErrorTemplateNameContext); - } - public templateName(): TemplateNameContext | undefined { - return this.tryGetRuleContext(0, TemplateNameContext); - } - public parameters(): ParametersContext | undefined { - return this.tryGetRuleContext(0, ParametersContext); - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_templateNameLine; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterTemplateNameLine) { - listener.enterTemplateNameLine(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitTemplateNameLine) { - listener.exitTemplateNameLine(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitTemplateNameLine) { - return visitor.visitTemplateNameLine(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class ErrorTemplateNameContext extends ParserRuleContext { - public IDENTIFIER(): TerminalNode[]; - public IDENTIFIER(i: number): TerminalNode; - public IDENTIFIER(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.IDENTIFIER); - } else { - return this.getToken(LGFileParser.IDENTIFIER, i); - } - } - public TEXT_IN_NAME(): TerminalNode[]; - public TEXT_IN_NAME(i: number): TerminalNode; - public TEXT_IN_NAME(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.TEXT_IN_NAME); - } else { - return this.getToken(LGFileParser.TEXT_IN_NAME, i); - } - } - public OPEN_PARENTHESIS(): TerminalNode[]; - public OPEN_PARENTHESIS(i: number): TerminalNode; - public OPEN_PARENTHESIS(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.OPEN_PARENTHESIS); - } else { - return this.getToken(LGFileParser.OPEN_PARENTHESIS, i); - } - } - public COMMA(): TerminalNode[]; - public COMMA(i: number): TerminalNode; - public COMMA(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.COMMA); - } else { - return this.getToken(LGFileParser.COMMA, i); - } - } - public CLOSE_PARENTHESIS(): TerminalNode[]; - public CLOSE_PARENTHESIS(i: number): TerminalNode; - public CLOSE_PARENTHESIS(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.CLOSE_PARENTHESIS); - } else { - return this.getToken(LGFileParser.CLOSE_PARENTHESIS, i); - } - } - public DOT(): TerminalNode[]; - public DOT(i: number): TerminalNode; - public DOT(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.DOT); - } else { - return this.getToken(LGFileParser.DOT, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_errorTemplateName; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterErrorTemplateName) { - listener.enterErrorTemplateName(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitErrorTemplateName) { - listener.exitErrorTemplateName(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitErrorTemplateName) { - return visitor.visitErrorTemplateName(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class TemplateNameContext extends ParserRuleContext { - public IDENTIFIER(): TerminalNode[]; - public IDENTIFIER(i: number): TerminalNode; - public IDENTIFIER(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.IDENTIFIER); - } else { - return this.getToken(LGFileParser.IDENTIFIER, i); - } - } - public DOT(): TerminalNode[]; - public DOT(i: number): TerminalNode; - public DOT(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.DOT); - } else { - return this.getToken(LGFileParser.DOT, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_templateName; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterTemplateName) { - listener.enterTemplateName(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitTemplateName) { - listener.exitTemplateName(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitTemplateName) { - return visitor.visitTemplateName(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class ParametersContext extends ParserRuleContext { - public OPEN_PARENTHESIS(): TerminalNode { return this.getToken(LGFileParser.OPEN_PARENTHESIS, 0); } - public CLOSE_PARENTHESIS(): TerminalNode { return this.getToken(LGFileParser.CLOSE_PARENTHESIS, 0); } - public IDENTIFIER(): TerminalNode[]; - public IDENTIFIER(i: number): TerminalNode; - public IDENTIFIER(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.IDENTIFIER); - } else { - return this.getToken(LGFileParser.IDENTIFIER, i); - } - } - public COMMA(): TerminalNode[]; - public COMMA(i: number): TerminalNode; - public COMMA(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.COMMA); - } else { - return this.getToken(LGFileParser.COMMA, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_parameters; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterParameters) { - listener.enterParameters(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitParameters) { - listener.exitParameters(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitParameters) { - return visitor.visitParameters(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class TemplateBodyContext extends ParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_templateBody; } - public copyFrom(ctx: TemplateBodyContext): void { - super.copyFrom(ctx); - } -} -export class SwitchCaseBodyContext extends TemplateBodyContext { - public switchCaseTemplateBody(): SwitchCaseTemplateBodyContext { - return this.getRuleContext(0, SwitchCaseTemplateBodyContext); - } - constructor(ctx: TemplateBodyContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterSwitchCaseBody) { - listener.enterSwitchCaseBody(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitSwitchCaseBody) { - listener.exitSwitchCaseBody(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitSwitchCaseBody) { - return visitor.visitSwitchCaseBody(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class NormalBodyContext extends TemplateBodyContext { - public normalTemplateBody(): NormalTemplateBodyContext { - return this.getRuleContext(0, NormalTemplateBodyContext); - } - constructor(ctx: TemplateBodyContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterNormalBody) { - listener.enterNormalBody(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitNormalBody) { - listener.exitNormalBody(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitNormalBody) { - return visitor.visitNormalBody(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class StructuredBodyContext extends TemplateBodyContext { - public structuredTemplateBody(): StructuredTemplateBodyContext { - return this.getRuleContext(0, StructuredTemplateBodyContext); - } - constructor(ctx: TemplateBodyContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterStructuredBody) { - listener.enterStructuredBody(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitStructuredBody) { - listener.exitStructuredBody(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitStructuredBody) { - return visitor.visitStructuredBody(this); - } else { - return visitor.visitChildren(this); - } - } -} -export class IfElseBodyContext extends TemplateBodyContext { - public ifElseTemplateBody(): IfElseTemplateBodyContext { - return this.getRuleContext(0, IfElseTemplateBodyContext); - } - constructor(ctx: TemplateBodyContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); - } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterIfElseBody) { - listener.enterIfElseBody(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitIfElseBody) { - listener.exitIfElseBody(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitIfElseBody) { - return visitor.visitIfElseBody(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class StructuredTemplateBodyContext extends ParserRuleContext { - public structuredBodyNameLine(): StructuredBodyNameLineContext { - return this.getRuleContext(0, StructuredBodyNameLineContext); - } - public structuredBodyEndLine(): StructuredBodyEndLineContext | undefined { - return this.tryGetRuleContext(0, StructuredBodyEndLineContext); - } - public structuredBodyContentLine(): StructuredBodyContentLineContext[]; - public structuredBodyContentLine(i: number): StructuredBodyContentLineContext; - public structuredBodyContentLine(i?: number): StructuredBodyContentLineContext | StructuredBodyContentLineContext[] { - if (i === undefined) { - return this.getRuleContexts(StructuredBodyContentLineContext); - } else { - return this.getRuleContext(i, StructuredBodyContentLineContext); - } - } - public STRUCTURED_NEWLINE(): TerminalNode[]; - public STRUCTURED_NEWLINE(i: number): TerminalNode; - public STRUCTURED_NEWLINE(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.STRUCTURED_NEWLINE); - } else { - return this.getToken(LGFileParser.STRUCTURED_NEWLINE, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_structuredTemplateBody; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterStructuredTemplateBody) { - listener.enterStructuredTemplateBody(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitStructuredTemplateBody) { - listener.exitStructuredTemplateBody(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitStructuredTemplateBody) { - return visitor.visitStructuredTemplateBody(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class StructuredBodyNameLineContext extends ParserRuleContext { - public LEFT_SQUARE_BRACKET(): TerminalNode { return this.getToken(LGFileParser.LEFT_SQUARE_BRACKET, 0); } - public STRUCTURE_NAME(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.STRUCTURE_NAME, 0); } - public errorStructuredName(): ErrorStructuredNameContext | undefined { - return this.tryGetRuleContext(0, ErrorStructuredNameContext); - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_structuredBodyNameLine; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterStructuredBodyNameLine) { - listener.enterStructuredBodyNameLine(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitStructuredBodyNameLine) { - listener.exitStructuredBodyNameLine(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitStructuredBodyNameLine) { - return visitor.visitStructuredBodyNameLine(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class ErrorStructuredNameContext extends ParserRuleContext { - public STRUCTURE_NAME(): TerminalNode[]; - public STRUCTURE_NAME(i: number): TerminalNode; - public STRUCTURE_NAME(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.STRUCTURE_NAME); - } else { - return this.getToken(LGFileParser.STRUCTURE_NAME, i); - } - } - public TEXT_IN_STRUCTURE_NAME(): TerminalNode[]; - public TEXT_IN_STRUCTURE_NAME(i: number): TerminalNode; - public TEXT_IN_STRUCTURE_NAME(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.TEXT_IN_STRUCTURE_NAME); - } else { - return this.getToken(LGFileParser.TEXT_IN_STRUCTURE_NAME, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_errorStructuredName; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterErrorStructuredName) { - listener.enterErrorStructuredName(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitErrorStructuredName) { - listener.exitErrorStructuredName(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitErrorStructuredName) { - return visitor.visitErrorStructuredName(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class StructuredBodyContentLineContext extends ParserRuleContext { - public keyValueStructureLine(): KeyValueStructureLineContext | undefined { - return this.tryGetRuleContext(0, KeyValueStructureLineContext); - } - public objectStructureLine(): ObjectStructureLineContext | undefined { - return this.tryGetRuleContext(0, ObjectStructureLineContext); - } - public errorStructureLine(): ErrorStructureLineContext | undefined { - return this.tryGetRuleContext(0, ErrorStructureLineContext); - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_structuredBodyContentLine; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterStructuredBodyContentLine) { - listener.enterStructuredBodyContentLine(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitStructuredBodyContentLine) { - listener.exitStructuredBodyContentLine(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitStructuredBodyContentLine) { - return visitor.visitStructuredBodyContentLine(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class ErrorStructureLineContext extends ParserRuleContext { - public STRUCTURE_IDENTIFIER(): TerminalNode[]; - public STRUCTURE_IDENTIFIER(i: number): TerminalNode; - public STRUCTURE_IDENTIFIER(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.STRUCTURE_IDENTIFIER); - } else { - return this.getToken(LGFileParser.STRUCTURE_IDENTIFIER, i); - } - } - public STRUCTURE_EQUALS(): TerminalNode[]; - public STRUCTURE_EQUALS(i: number): TerminalNode; - public STRUCTURE_EQUALS(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.STRUCTURE_EQUALS); - } else { - return this.getToken(LGFileParser.STRUCTURE_EQUALS, i); - } - } - public STRUCTURE_OR_MARK(): TerminalNode[]; - public STRUCTURE_OR_MARK(i: number): TerminalNode; - public STRUCTURE_OR_MARK(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.STRUCTURE_OR_MARK); - } else { - return this.getToken(LGFileParser.STRUCTURE_OR_MARK, i); - } - } - public TEXT_IN_STRUCTURE_BODY(): TerminalNode[]; - public TEXT_IN_STRUCTURE_BODY(i: number): TerminalNode; - public TEXT_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.TEXT_IN_STRUCTURE_BODY); - } else { - return this.getToken(LGFileParser.TEXT_IN_STRUCTURE_BODY, i); - } - } - public EXPRESSION_IN_STRUCTURE_BODY(): TerminalNode[]; - public EXPRESSION_IN_STRUCTURE_BODY(i: number): TerminalNode; - public EXPRESSION_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY); - } else { - return this.getToken(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY, i); - } - } - public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(): TerminalNode[]; - public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(i: number): TerminalNode; - public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY); - } else { - return this.getToken(LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_errorStructureLine; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterErrorStructureLine) { - listener.enterErrorStructureLine(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitErrorStructureLine) { - listener.exitErrorStructureLine(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitErrorStructureLine) { - return visitor.visitErrorStructureLine(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class KeyValueStructureLineContext extends ParserRuleContext { - public STRUCTURE_IDENTIFIER(): TerminalNode { return this.getToken(LGFileParser.STRUCTURE_IDENTIFIER, 0); } - public STRUCTURE_EQUALS(): TerminalNode { return this.getToken(LGFileParser.STRUCTURE_EQUALS, 0); } - public keyValueStructureValue(): KeyValueStructureValueContext[]; - public keyValueStructureValue(i: number): KeyValueStructureValueContext; - public keyValueStructureValue(i?: number): KeyValueStructureValueContext | KeyValueStructureValueContext[] { - if (i === undefined) { - return this.getRuleContexts(KeyValueStructureValueContext); - } else { - return this.getRuleContext(i, KeyValueStructureValueContext); - } - } - public STRUCTURE_OR_MARK(): TerminalNode[]; - public STRUCTURE_OR_MARK(i: number): TerminalNode; - public STRUCTURE_OR_MARK(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.STRUCTURE_OR_MARK); - } else { - return this.getToken(LGFileParser.STRUCTURE_OR_MARK, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_keyValueStructureLine; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterKeyValueStructureLine) { - listener.enterKeyValueStructureLine(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitKeyValueStructureLine) { - listener.exitKeyValueStructureLine(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitKeyValueStructureLine) { - return visitor.visitKeyValueStructureLine(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class KeyValueStructureValueContext extends ParserRuleContext { - public TEXT_IN_STRUCTURE_BODY(): TerminalNode[]; - public TEXT_IN_STRUCTURE_BODY(i: number): TerminalNode; - public TEXT_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.TEXT_IN_STRUCTURE_BODY); - } else { - return this.getToken(LGFileParser.TEXT_IN_STRUCTURE_BODY, i); - } - } - public EXPRESSION_IN_STRUCTURE_BODY(): TerminalNode[]; - public EXPRESSION_IN_STRUCTURE_BODY(i: number): TerminalNode; - public EXPRESSION_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY); - } else { - return this.getToken(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY, i); - } - } - public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(): TerminalNode[]; - public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(i: number): TerminalNode; - public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY); - } else { - return this.getToken(LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_keyValueStructureValue; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterKeyValueStructureValue) { - listener.enterKeyValueStructureValue(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitKeyValueStructureValue) { - listener.exitKeyValueStructureValue(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitKeyValueStructureValue) { - return visitor.visitKeyValueStructureValue(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class ObjectStructureLineContext extends ParserRuleContext { - public EXPRESSION_IN_STRUCTURE_BODY(): TerminalNode { return this.getToken(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY, 0); } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_objectStructureLine; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterObjectStructureLine) { - listener.enterObjectStructureLine(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitObjectStructureLine) { - listener.exitObjectStructureLine(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitObjectStructureLine) { - return visitor.visitObjectStructureLine(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class StructuredBodyEndLineContext extends ParserRuleContext { - public STRUCTURED_BODY_END(): TerminalNode { return this.getToken(LGFileParser.STRUCTURED_BODY_END, 0); } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_structuredBodyEndLine; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterStructuredBodyEndLine) { - listener.enterStructuredBodyEndLine(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitStructuredBodyEndLine) { - listener.exitStructuredBodyEndLine(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitStructuredBodyEndLine) { - return visitor.visitStructuredBodyEndLine(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class NormalTemplateBodyContext extends ParserRuleContext { - public templateString(): TemplateStringContext[]; - public templateString(i: number): TemplateStringContext; - public templateString(i?: number): TemplateStringContext | TemplateStringContext[] { - if (i === undefined) { - return this.getRuleContexts(TemplateStringContext); - } else { - return this.getRuleContext(i, TemplateStringContext); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_normalTemplateBody; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterNormalTemplateBody) { - listener.enterNormalTemplateBody(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitNormalTemplateBody) { - listener.exitNormalTemplateBody(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitNormalTemplateBody) { - return visitor.visitNormalTemplateBody(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class TemplateStringContext extends ParserRuleContext { - public normalTemplateString(): NormalTemplateStringContext | undefined { - return this.tryGetRuleContext(0, NormalTemplateStringContext); - } - public errorTemplateString(): ErrorTemplateStringContext | undefined { - return this.tryGetRuleContext(0, ErrorTemplateStringContext); - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_templateString; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterTemplateString) { - listener.enterTemplateString(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitTemplateString) { - listener.exitTemplateString(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitTemplateString) { - return visitor.visitTemplateString(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class NormalTemplateStringContext extends ParserRuleContext { - public DASH(): TerminalNode { return this.getToken(LGFileParser.DASH, 0); } - public MULTILINE_PREFIX(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.MULTILINE_PREFIX, 0); } - public MULTILINE_SUFFIX(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.MULTILINE_SUFFIX, 0); } - public TEXT(): TerminalNode[]; - public TEXT(i: number): TerminalNode; - public TEXT(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.TEXT); - } else { - return this.getToken(LGFileParser.TEXT, i); - } - } - public EXPRESSION(): TerminalNode[]; - public EXPRESSION(i: number): TerminalNode; - public EXPRESSION(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.EXPRESSION); - } else { - return this.getToken(LGFileParser.EXPRESSION, i); - } - } - public ESCAPE_CHARACTER(): TerminalNode[]; - public ESCAPE_CHARACTER(i: number): TerminalNode; - public ESCAPE_CHARACTER(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.ESCAPE_CHARACTER); - } else { - return this.getToken(LGFileParser.ESCAPE_CHARACTER, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_normalTemplateString; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterNormalTemplateString) { - listener.enterNormalTemplateString(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitNormalTemplateString) { - listener.exitNormalTemplateString(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitNormalTemplateString) { - return visitor.visitNormalTemplateString(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class ErrorTemplateStringContext extends ParserRuleContext { - public INVALID_TOKEN(): TerminalNode[]; - public INVALID_TOKEN(i: number): TerminalNode; - public INVALID_TOKEN(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.INVALID_TOKEN); - } else { - return this.getToken(LGFileParser.INVALID_TOKEN, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_errorTemplateString; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterErrorTemplateString) { - listener.enterErrorTemplateString(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitErrorTemplateString) { - listener.exitErrorTemplateString(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitErrorTemplateString) { - return visitor.visitErrorTemplateString(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class IfElseTemplateBodyContext extends ParserRuleContext { - public ifConditionRule(): IfConditionRuleContext[]; - public ifConditionRule(i: number): IfConditionRuleContext; - public ifConditionRule(i?: number): IfConditionRuleContext | IfConditionRuleContext[] { - if (i === undefined) { - return this.getRuleContexts(IfConditionRuleContext); - } else { - return this.getRuleContext(i, IfConditionRuleContext); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_ifElseTemplateBody; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterIfElseTemplateBody) { - listener.enterIfElseTemplateBody(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitIfElseTemplateBody) { - listener.exitIfElseTemplateBody(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitIfElseTemplateBody) { - return visitor.visitIfElseTemplateBody(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class IfConditionRuleContext extends ParserRuleContext { - public ifCondition(): IfConditionContext { - return this.getRuleContext(0, IfConditionContext); - } - public normalTemplateBody(): NormalTemplateBodyContext | undefined { - return this.tryGetRuleContext(0, NormalTemplateBodyContext); - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_ifConditionRule; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterIfConditionRule) { - listener.enterIfConditionRule(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitIfConditionRule) { - listener.exitIfConditionRule(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitIfConditionRule) { - return visitor.visitIfConditionRule(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class IfConditionContext extends ParserRuleContext { - public DASH(): TerminalNode { return this.getToken(LGFileParser.DASH, 0); } - public IF(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.IF, 0); } - public ELSE(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.ELSE, 0); } - public ELSEIF(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.ELSEIF, 0); } - public WS(): TerminalNode[]; - public WS(i: number): TerminalNode; - public WS(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.WS); - } else { - return this.getToken(LGFileParser.WS, i); - } - } - public TEXT(): TerminalNode[]; - public TEXT(i: number): TerminalNode; - public TEXT(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.TEXT); - } else { - return this.getToken(LGFileParser.TEXT, i); - } - } - public EXPRESSION(): TerminalNode[]; - public EXPRESSION(i: number): TerminalNode; - public EXPRESSION(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.EXPRESSION); - } else { - return this.getToken(LGFileParser.EXPRESSION, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_ifCondition; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterIfCondition) { - listener.enterIfCondition(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitIfCondition) { - listener.exitIfCondition(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitIfCondition) { - return visitor.visitIfCondition(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class SwitchCaseTemplateBodyContext extends ParserRuleContext { - public switchCaseRule(): SwitchCaseRuleContext[]; - public switchCaseRule(i: number): SwitchCaseRuleContext; - public switchCaseRule(i?: number): SwitchCaseRuleContext | SwitchCaseRuleContext[] { - if (i === undefined) { - return this.getRuleContexts(SwitchCaseRuleContext); - } else { - return this.getRuleContext(i, SwitchCaseRuleContext); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_switchCaseTemplateBody; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterSwitchCaseTemplateBody) { - listener.enterSwitchCaseTemplateBody(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitSwitchCaseTemplateBody) { - listener.exitSwitchCaseTemplateBody(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitSwitchCaseTemplateBody) { - return visitor.visitSwitchCaseTemplateBody(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class SwitchCaseRuleContext extends ParserRuleContext { - public switchCaseStat(): SwitchCaseStatContext { - return this.getRuleContext(0, SwitchCaseStatContext); - } - public normalTemplateBody(): NormalTemplateBodyContext | undefined { - return this.tryGetRuleContext(0, NormalTemplateBodyContext); - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_switchCaseRule; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterSwitchCaseRule) { - listener.enterSwitchCaseRule(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitSwitchCaseRule) { - listener.exitSwitchCaseRule(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitSwitchCaseRule) { - return visitor.visitSwitchCaseRule(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class SwitchCaseStatContext extends ParserRuleContext { - public DASH(): TerminalNode { return this.getToken(LGFileParser.DASH, 0); } - public SWITCH(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.SWITCH, 0); } - public CASE(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.CASE, 0); } - public DEFAULT(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.DEFAULT, 0); } - public WS(): TerminalNode[]; - public WS(i: number): TerminalNode; - public WS(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.WS); - } else { - return this.getToken(LGFileParser.WS, i); - } - } - public TEXT(): TerminalNode[]; - public TEXT(i: number): TerminalNode; - public TEXT(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.TEXT); - } else { - return this.getToken(LGFileParser.TEXT, i); - } - } - public EXPRESSION(): TerminalNode[]; - public EXPRESSION(i: number): TerminalNode; - public EXPRESSION(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(LGFileParser.EXPRESSION); - } else { - return this.getToken(LGFileParser.EXPRESSION, i); - } - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_switchCaseStat; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterSwitchCaseStat) { - listener.enterSwitchCaseStat(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitSwitchCaseStat) { - listener.exitSwitchCaseStat(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitSwitchCaseStat) { - return visitor.visitSwitchCaseStat(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class ImportDefinitionContext extends ParserRuleContext { - public IMPORT(): TerminalNode { return this.getToken(LGFileParser.IMPORT, 0); } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_importDefinition; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterImportDefinition) { - listener.enterImportDefinition(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitImportDefinition) { - listener.exitImportDefinition(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitImportDefinition) { - return visitor.visitImportDefinition(this); - } else { - return visitor.visitChildren(this); - } - } -} - - -export class OptionsDefinitionContext extends ParserRuleContext { - public OPTIONS(): TerminalNode { return this.getToken(LGFileParser.OPTIONS, 0); } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); - } - // @Override - public get ruleIndex(): number { return LGFileParser.RULE_optionsDefinition; } - // @Override - public enterRule(listener: LGFileParserListener): void { - if (listener.enterOptionsDefinition) { - listener.enterOptionsDefinition(this); - } - } - // @Override - public exitRule(listener: LGFileParserListener): void { - if (listener.exitOptionsDefinition) { - listener.exitOptionsDefinition(this); - } - } - // @Override - public accept(visitor: LGFileParserVisitor): Result { - if (visitor.visitOptionsDefinition) { - return visitor.visitOptionsDefinition(this); - } else { - return visitor.visitChildren(this); - } - } -} - - +// Generated from ../LGFileParser.g4 by ANTLR 4.6-SNAPSHOT + + +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"; +import { TerminalNode } from "antlr4ts/tree/TerminalNode"; +import { Token } from "antlr4ts/Token"; +import { TokenStream } from "antlr4ts/TokenStream"; +import { Vocabulary } from "antlr4ts/Vocabulary"; +import { VocabularyImpl } from "antlr4ts/VocabularyImpl"; + +import * as Utils from "antlr4ts/misc/Utils"; + +import { LGFileParserListener } from "./LGFileParserListener"; +import { LGFileParserVisitor } from "./LGFileParserVisitor"; + + +export class LGFileParser extends Parser { + public static readonly OPTIONS = 1; + public static readonly COMMENTS = 2; + public static readonly WS = 3; + public static readonly NEWLINE = 4; + public static readonly HASH = 5; + public static readonly DASH = 6; + public static readonly LEFT_SQUARE_BRACKET = 7; + public static readonly IMPORT = 8; + public static readonly INVALID_TOKEN = 9; + public static readonly WS_IN_NAME = 10; + public static readonly NEWLINE_IN_NAME = 11; + public static readonly IDENTIFIER = 12; + public static readonly DOT = 13; + public static readonly OPEN_PARENTHESIS = 14; + public static readonly CLOSE_PARENTHESIS = 15; + public static readonly COMMA = 16; + public static readonly TEXT_IN_NAME = 17; + public static readonly WS_IN_BODY = 18; + public static readonly MULTILINE_PREFIX = 19; + public static readonly NEWLINE_IN_BODY = 20; + public static readonly IF = 21; + public static readonly ELSEIF = 22; + public static readonly ELSE = 23; + public static readonly SWITCH = 24; + public static readonly CASE = 25; + public static readonly DEFAULT = 26; + public static readonly ESCAPE_CHARACTER = 27; + public static readonly EXPRESSION = 28; + public static readonly TEXT = 29; + public static readonly MULTILINE_SUFFIX = 30; + public static readonly WS_IN_STRUCTURE_NAME = 31; + public static readonly NEWLINE_IN_STRUCTURE_NAME = 32; + public static readonly STRUCTURE_NAME = 33; + public static readonly TEXT_IN_STRUCTURE_NAME = 34; + public static readonly STRUCTURED_COMMENTS = 35; + public static readonly WS_IN_STRUCTURE_BODY = 36; + public static readonly STRUCTURED_NEWLINE = 37; + public static readonly STRUCTURED_BODY_END = 38; + public static readonly STRUCTURE_IDENTIFIER = 39; + public static readonly STRUCTURE_EQUALS = 40; + public static readonly STRUCTURE_OR_MARK = 41; + public static readonly ESCAPE_CHARACTER_IN_STRUCTURE_BODY = 42; + public static readonly EXPRESSION_IN_STRUCTURE_BODY = 43; + public static readonly TEXT_IN_STRUCTURE_BODY = 44; + public static readonly RULE_file = 0; + public static readonly RULE_paragraph = 1; + public static readonly RULE_errorTemplate = 2; + public static readonly RULE_templateDefinition = 3; + public static readonly RULE_templateNameLine = 4; + public static readonly RULE_errorTemplateName = 5; + public static readonly RULE_templateName = 6; + public static readonly RULE_parameters = 7; + public static readonly RULE_templateBody = 8; + public static readonly RULE_structuredTemplateBody = 9; + public static readonly RULE_structuredBodyNameLine = 10; + public static readonly RULE_errorStructuredName = 11; + public static readonly RULE_structuredBodyContentLine = 12; + public static readonly RULE_errorStructureLine = 13; + public static readonly RULE_keyValueStructureLine = 14; + public static readonly RULE_keyValueStructureValue = 15; + public static readonly RULE_objectStructureLine = 16; + public static readonly RULE_structuredBodyEndLine = 17; + public static readonly RULE_normalTemplateBody = 18; + public static readonly RULE_templateString = 19; + public static readonly RULE_normalTemplateString = 20; + public static readonly RULE_errorTemplateString = 21; + public static readonly RULE_ifElseTemplateBody = 22; + public static readonly RULE_ifConditionRule = 23; + public static readonly RULE_ifCondition = 24; + public static readonly RULE_switchCaseTemplateBody = 25; + public static readonly RULE_switchCaseRule = 26; + public static readonly RULE_switchCaseStat = 27; + public static readonly RULE_importDefinition = 28; + public static readonly RULE_optionsDefinition = 29; + // tslint:disable:no-trailing-whitespace + public static readonly ruleNames: string[] = [ + "file", "paragraph", "errorTemplate", "templateDefinition", "templateNameLine", + "errorTemplateName", "templateName", "parameters", "templateBody", "structuredTemplateBody", + "structuredBodyNameLine", "errorStructuredName", "structuredBodyContentLine", + "errorStructureLine", "keyValueStructureLine", "keyValueStructureValue", + "objectStructureLine", "structuredBodyEndLine", "normalTemplateBody", + "templateString", "normalTemplateString", "errorTemplateString", "ifElseTemplateBody", + "ifConditionRule", "ifCondition", "switchCaseTemplateBody", "switchCaseRule", + "switchCaseStat", "importDefinition", "optionsDefinition", + ]; + + private static readonly _LITERAL_NAMES: Array = [ + undefined, undefined, undefined, undefined, undefined, undefined, undefined, + undefined, undefined, undefined, undefined, undefined, undefined, "'.'", + "'('", "')'", "','", undefined, undefined, undefined, undefined, undefined, + undefined, undefined, undefined, undefined, undefined, undefined, undefined, + undefined, undefined, undefined, undefined, undefined, undefined, undefined, + undefined, undefined, undefined, undefined, undefined, "'|'", + ]; + private static readonly _SYMBOLIC_NAMES: Array = [ + undefined, "OPTIONS", "COMMENTS", "WS", "NEWLINE", "HASH", "DASH", "LEFT_SQUARE_BRACKET", + "IMPORT", "INVALID_TOKEN", "WS_IN_NAME", "NEWLINE_IN_NAME", "IDENTIFIER", + "DOT", "OPEN_PARENTHESIS", "CLOSE_PARENTHESIS", "COMMA", "TEXT_IN_NAME", + "WS_IN_BODY", "MULTILINE_PREFIX", "NEWLINE_IN_BODY", "IF", "ELSEIF", "ELSE", + "SWITCH", "CASE", "DEFAULT", "ESCAPE_CHARACTER", "EXPRESSION", "TEXT", + "MULTILINE_SUFFIX", "WS_IN_STRUCTURE_NAME", "NEWLINE_IN_STRUCTURE_NAME", + "STRUCTURE_NAME", "TEXT_IN_STRUCTURE_NAME", "STRUCTURED_COMMENTS", "WS_IN_STRUCTURE_BODY", + "STRUCTURED_NEWLINE", "STRUCTURED_BODY_END", "STRUCTURE_IDENTIFIER", "STRUCTURE_EQUALS", + "STRUCTURE_OR_MARK", "ESCAPE_CHARACTER_IN_STRUCTURE_BODY", "EXPRESSION_IN_STRUCTURE_BODY", + "TEXT_IN_STRUCTURE_BODY", + ]; + public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(LGFileParser._LITERAL_NAMES, LGFileParser._SYMBOLIC_NAMES, []); + + // @Override + // @NotNull + public get vocabulary(): Vocabulary { + return LGFileParser.VOCABULARY; + } + // tslint:enable:no-trailing-whitespace + + // @Override + public get grammarFileName(): string { return "LGFileParser.g4"; } + + // @Override + public get ruleNames(): string[] { return LGFileParser.ruleNames; } + + // @Override + public get serializedATN(): string { return LGFileParser._serializedATN; } + + constructor(input: TokenStream) { + super(input); + this._interp = new ParserATNSimulator(LGFileParser._ATN, this); + } + // @RuleVersion(0) + public file(): FileContext { + let _localctx: FileContext = new FileContext(this._ctx, this.state); + this.enterRule(_localctx, 0, LGFileParser.RULE_file); + try { + let _alt: number; + this.enterOuterAlt(_localctx, 1); + { + this.state = 61; + this._errHandler.sync(this); + _alt = 1 + 1; + do { + switch (_alt) { + case 1 + 1: + { + { + this.state = 60; + this.paragraph(); + } + } + break; + default: + throw new NoViableAltException(this); + } + this.state = 63; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 0, this._ctx); + } while (_alt !== 1 && _alt !== ATN.INVALID_ALT_NUMBER); + this.state = 65; + this.match(LGFileParser.EOF); + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + // @RuleVersion(0) + public paragraph(): ParagraphContext { + let _localctx: ParagraphContext = new ParagraphContext(this._ctx, this.state); + this.enterRule(_localctx, 2, LGFileParser.RULE_paragraph); + try { + this.state = 72; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case LGFileParser.HASH: + this.enterOuterAlt(_localctx, 1); + { + this.state = 67; + this.templateDefinition(); + } + break; + case LGFileParser.IMPORT: + this.enterOuterAlt(_localctx, 2); + { + this.state = 68; + this.importDefinition(); + } + break; + case LGFileParser.OPTIONS: + this.enterOuterAlt(_localctx, 3); + { + this.state = 69; + this.optionsDefinition(); + } + break; + case LGFileParser.EOF: + this.enterOuterAlt(_localctx, 4); + { + this.state = 70; + this.match(LGFileParser.EOF); + } + break; + case LGFileParser.INVALID_TOKEN: + this.enterOuterAlt(_localctx, 5); + { + this.state = 71; + this.errorTemplate(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + // @RuleVersion(0) + public errorTemplate(): ErrorTemplateContext { + let _localctx: ErrorTemplateContext = new ErrorTemplateContext(this._ctx, this.state); + this.enterRule(_localctx, 4, LGFileParser.RULE_errorTemplate); + try { + let _alt: number; + this.enterOuterAlt(_localctx, 1); + { + this.state = 75; + this._errHandler.sync(this); + _alt = 1; + do { + switch (_alt) { + case 1: + { + { + this.state = 74; + this.match(LGFileParser.INVALID_TOKEN); + } + } + break; + default: + throw new NoViableAltException(this); + } + this.state = 77; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 2, this._ctx); + } while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER); + } + } + 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 templateDefinition(): TemplateDefinitionContext { + let _localctx: TemplateDefinitionContext = new TemplateDefinitionContext(this._ctx, this.state); + this.enterRule(_localctx, 6, LGFileParser.RULE_templateDefinition); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 79; + this.templateNameLine(); + this.state = 81; + this._errHandler.sync(this); + switch ( this.interpreter.adaptivePredict(this._input, 3, this._ctx) ) { + case 1: + { + this.state = 80; + this.templateBody(); + } + break; + } + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + // @RuleVersion(0) + public templateNameLine(): TemplateNameLineContext { + let _localctx: TemplateNameLineContext = new TemplateNameLineContext(this._ctx, this.state); + this.enterRule(_localctx, 8, LGFileParser.RULE_templateNameLine); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 83; + this.match(LGFileParser.HASH); + this.state = 89; + this._errHandler.sync(this); + switch ( this.interpreter.adaptivePredict(this._input, 5, this._ctx) ) { + case 1: + { + { + this.state = 84; + this.templateName(); + this.state = 86; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === LGFileParser.OPEN_PARENTHESIS) { + { + this.state = 85; + this.parameters(); + } + } + + } + } + break; + + case 2: + { + this.state = 88; + this.errorTemplateName(); + } + break; + } + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + // @RuleVersion(0) + public errorTemplateName(): ErrorTemplateNameContext { + let _localctx: ErrorTemplateNameContext = new ErrorTemplateNameContext(this._ctx, this.state); + this.enterRule(_localctx, 10, LGFileParser.RULE_errorTemplateName); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 94; + this._errHandler.sync(this); + _la = this._input.LA(1); + while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.IDENTIFIER) | (1 << LGFileParser.DOT) | (1 << LGFileParser.OPEN_PARENTHESIS) | (1 << LGFileParser.CLOSE_PARENTHESIS) | (1 << LGFileParser.COMMA) | (1 << LGFileParser.TEXT_IN_NAME))) !== 0)) { + { + { + this.state = 91; + _la = this._input.LA(1); + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.IDENTIFIER) | (1 << LGFileParser.DOT) | (1 << LGFileParser.OPEN_PARENTHESIS) | (1 << LGFileParser.CLOSE_PARENTHESIS) | (1 << LGFileParser.COMMA) | (1 << LGFileParser.TEXT_IN_NAME))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 96; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } + } + 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 templateName(): TemplateNameContext { + let _localctx: TemplateNameContext = new TemplateNameContext(this._ctx, this.state); + this.enterRule(_localctx, 12, LGFileParser.RULE_templateName); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 97; + this.match(LGFileParser.IDENTIFIER); + this.state = 102; + this._errHandler.sync(this); + _la = this._input.LA(1); + while (_la === LGFileParser.DOT) { + { + { + this.state = 98; + this.match(LGFileParser.DOT); + this.state = 99; + this.match(LGFileParser.IDENTIFIER); + } + } + this.state = 104; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } + } + 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 parameters(): ParametersContext { + let _localctx: ParametersContext = new ParametersContext(this._ctx, this.state); + this.enterRule(_localctx, 14, LGFileParser.RULE_parameters); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 105; + this.match(LGFileParser.OPEN_PARENTHESIS); + this.state = 114; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === LGFileParser.IDENTIFIER) { + { + this.state = 106; + this.match(LGFileParser.IDENTIFIER); + this.state = 111; + this._errHandler.sync(this); + _la = this._input.LA(1); + while (_la === LGFileParser.COMMA) { + { + { + this.state = 107; + this.match(LGFileParser.COMMA); + this.state = 108; + this.match(LGFileParser.IDENTIFIER); + } + } + this.state = 113; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } + } + + this.state = 116; + this.match(LGFileParser.CLOSE_PARENTHESIS); + } + } + 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 templateBody(): TemplateBodyContext { + let _localctx: TemplateBodyContext = new TemplateBodyContext(this._ctx, this.state); + this.enterRule(_localctx, 16, LGFileParser.RULE_templateBody); + try { + this.state = 122; + this._errHandler.sync(this); + switch ( this.interpreter.adaptivePredict(this._input, 10, this._ctx) ) { + case 1: + _localctx = new NormalBodyContext(_localctx); + this.enterOuterAlt(_localctx, 1); + { + this.state = 118; + this.normalTemplateBody(); + } + break; + + case 2: + _localctx = new IfElseBodyContext(_localctx); + this.enterOuterAlt(_localctx, 2); + { + this.state = 119; + this.ifElseTemplateBody(); + } + break; + + case 3: + _localctx = new SwitchCaseBodyContext(_localctx); + this.enterOuterAlt(_localctx, 3); + { + this.state = 120; + this.switchCaseTemplateBody(); + } + break; + + case 4: + _localctx = new StructuredBodyContext(_localctx); + this.enterOuterAlt(_localctx, 4); + { + this.state = 121; + this.structuredTemplateBody(); + } + break; + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + // @RuleVersion(0) + public structuredTemplateBody(): StructuredTemplateBodyContext { + let _localctx: StructuredTemplateBodyContext = new StructuredTemplateBodyContext(this._ctx, this.state); + this.enterRule(_localctx, 18, LGFileParser.RULE_structuredTemplateBody); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 124; + this.structuredBodyNameLine(); + this.state = 132; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (((((_la - 39)) & ~0x1F) === 0 && ((1 << (_la - 39)) & ((1 << (LGFileParser.STRUCTURE_IDENTIFIER - 39)) | (1 << (LGFileParser.STRUCTURE_EQUALS - 39)) | (1 << (LGFileParser.STRUCTURE_OR_MARK - 39)) | (1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 39)))) !== 0)) { + { + this.state = 128; + this._errHandler.sync(this); + _la = this._input.LA(1); + do { + { + { + this.state = 125; + this.structuredBodyContentLine(); + this.state = 126; + this.match(LGFileParser.STRUCTURED_NEWLINE); + } + } + this.state = 130; + this._errHandler.sync(this); + _la = this._input.LA(1); + } while (((((_la - 39)) & ~0x1F) === 0 && ((1 << (_la - 39)) & ((1 << (LGFileParser.STRUCTURE_IDENTIFIER - 39)) | (1 << (LGFileParser.STRUCTURE_EQUALS - 39)) | (1 << (LGFileParser.STRUCTURE_OR_MARK - 39)) | (1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 39)))) !== 0)); + } + } + + this.state = 135; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === LGFileParser.STRUCTURED_BODY_END) { + { + this.state = 134; + this.structuredBodyEndLine(); + } + } + + } + } + 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 structuredBodyNameLine(): StructuredBodyNameLineContext { + let _localctx: StructuredBodyNameLineContext = new StructuredBodyNameLineContext(this._ctx, this.state); + this.enterRule(_localctx, 20, LGFileParser.RULE_structuredBodyNameLine); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 137; + this.match(LGFileParser.LEFT_SQUARE_BRACKET); + this.state = 140; + this._errHandler.sync(this); + switch ( this.interpreter.adaptivePredict(this._input, 14, this._ctx) ) { + case 1: + { + this.state = 138; + this.match(LGFileParser.STRUCTURE_NAME); + } + break; + + case 2: + { + this.state = 139; + this.errorStructuredName(); + } + break; + } + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + // @RuleVersion(0) + public errorStructuredName(): ErrorStructuredNameContext { + let _localctx: ErrorStructuredNameContext = new ErrorStructuredNameContext(this._ctx, this.state); + this.enterRule(_localctx, 22, LGFileParser.RULE_errorStructuredName); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 145; + this._errHandler.sync(this); + _la = this._input.LA(1); + while (_la === LGFileParser.STRUCTURE_NAME || _la === LGFileParser.TEXT_IN_STRUCTURE_NAME) { + { + { + this.state = 142; + _la = this._input.LA(1); + if (!(_la === LGFileParser.STRUCTURE_NAME || _la === LGFileParser.TEXT_IN_STRUCTURE_NAME)) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 147; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } + } + 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 structuredBodyContentLine(): StructuredBodyContentLineContext { + let _localctx: StructuredBodyContentLineContext = new StructuredBodyContentLineContext(this._ctx, this.state); + this.enterRule(_localctx, 24, LGFileParser.RULE_structuredBodyContentLine); + try { + this.state = 151; + this._errHandler.sync(this); + switch ( this.interpreter.adaptivePredict(this._input, 16, this._ctx) ) { + case 1: + this.enterOuterAlt(_localctx, 1); + { + this.state = 148; + this.keyValueStructureLine(); + } + break; + + case 2: + this.enterOuterAlt(_localctx, 2); + { + this.state = 149; + this.objectStructureLine(); + } + break; + + case 3: + this.enterOuterAlt(_localctx, 3); + { + this.state = 150; + this.errorStructureLine(); + } + break; + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + // @RuleVersion(0) + public errorStructureLine(): ErrorStructureLineContext { + let _localctx: ErrorStructureLineContext = new ErrorStructureLineContext(this._ctx, this.state); + this.enterRule(_localctx, 26, LGFileParser.RULE_errorStructureLine); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 154; + this._errHandler.sync(this); + _la = this._input.LA(1); + do { + { + { + this.state = 153; + _la = this._input.LA(1); + if (!(((((_la - 39)) & ~0x1F) === 0 && ((1 << (_la - 39)) & ((1 << (LGFileParser.STRUCTURE_IDENTIFIER - 39)) | (1 << (LGFileParser.STRUCTURE_EQUALS - 39)) | (1 << (LGFileParser.STRUCTURE_OR_MARK - 39)) | (1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 39)))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 156; + this._errHandler.sync(this); + _la = this._input.LA(1); + } while (((((_la - 39)) & ~0x1F) === 0 && ((1 << (_la - 39)) & ((1 << (LGFileParser.STRUCTURE_IDENTIFIER - 39)) | (1 << (LGFileParser.STRUCTURE_EQUALS - 39)) | (1 << (LGFileParser.STRUCTURE_OR_MARK - 39)) | (1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 39)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 39)))) !== 0)); + } + } + 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 keyValueStructureLine(): KeyValueStructureLineContext { + let _localctx: KeyValueStructureLineContext = new KeyValueStructureLineContext(this._ctx, this.state); + this.enterRule(_localctx, 28, LGFileParser.RULE_keyValueStructureLine); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 158; + this.match(LGFileParser.STRUCTURE_IDENTIFIER); + this.state = 159; + this.match(LGFileParser.STRUCTURE_EQUALS); + this.state = 160; + this.keyValueStructureValue(); + this.state = 165; + this._errHandler.sync(this); + _la = this._input.LA(1); + while (_la === LGFileParser.STRUCTURE_OR_MARK) { + { + { + this.state = 161; + this.match(LGFileParser.STRUCTURE_OR_MARK); + this.state = 162; + this.keyValueStructureValue(); + } + } + this.state = 167; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } + } + 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 keyValueStructureValue(): KeyValueStructureValueContext { + let _localctx: KeyValueStructureValueContext = new KeyValueStructureValueContext(this._ctx, this.state); + this.enterRule(_localctx, 30, LGFileParser.RULE_keyValueStructureValue); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 169; + this._errHandler.sync(this); + _la = this._input.LA(1); + do { + { + { + this.state = 168; + _la = this._input.LA(1); + if (!(((((_la - 42)) & ~0x1F) === 0 && ((1 << (_la - 42)) & ((1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 42)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 42)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 42)))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 171; + this._errHandler.sync(this); + _la = this._input.LA(1); + } while (((((_la - 42)) & ~0x1F) === 0 && ((1 << (_la - 42)) & ((1 << (LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY - 42)) | (1 << (LGFileParser.EXPRESSION_IN_STRUCTURE_BODY - 42)) | (1 << (LGFileParser.TEXT_IN_STRUCTURE_BODY - 42)))) !== 0)); + } + } + 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 objectStructureLine(): ObjectStructureLineContext { + let _localctx: ObjectStructureLineContext = new ObjectStructureLineContext(this._ctx, this.state); + this.enterRule(_localctx, 32, LGFileParser.RULE_objectStructureLine); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 173; + this.match(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY); + } + } + 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 structuredBodyEndLine(): StructuredBodyEndLineContext { + let _localctx: StructuredBodyEndLineContext = new StructuredBodyEndLineContext(this._ctx, this.state); + this.enterRule(_localctx, 34, LGFileParser.RULE_structuredBodyEndLine); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 175; + this.match(LGFileParser.STRUCTURED_BODY_END); + } + } + 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 normalTemplateBody(): NormalTemplateBodyContext { + let _localctx: NormalTemplateBodyContext = new NormalTemplateBodyContext(this._ctx, this.state); + this.enterRule(_localctx, 36, LGFileParser.RULE_normalTemplateBody); + try { + let _alt: number; + this.enterOuterAlt(_localctx, 1); + { + this.state = 178; + this._errHandler.sync(this); + _alt = 1; + do { + switch (_alt) { + case 1: + { + { + this.state = 177; + this.templateString(); + } + } + break; + default: + throw new NoViableAltException(this); + } + this.state = 180; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 20, this._ctx); + } while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER); + } + } + 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 templateString(): TemplateStringContext { + let _localctx: TemplateStringContext = new TemplateStringContext(this._ctx, this.state); + this.enterRule(_localctx, 38, LGFileParser.RULE_templateString); + try { + this.state = 184; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case LGFileParser.DASH: + this.enterOuterAlt(_localctx, 1); + { + this.state = 182; + this.normalTemplateString(); + } + break; + case LGFileParser.INVALID_TOKEN: + this.enterOuterAlt(_localctx, 2); + { + this.state = 183; + this.errorTemplateString(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + // @RuleVersion(0) + public normalTemplateString(): NormalTemplateStringContext { + let _localctx: NormalTemplateStringContext = new NormalTemplateStringContext(this._ctx, this.state); + this.enterRule(_localctx, 40, LGFileParser.RULE_normalTemplateString); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 186; + this.match(LGFileParser.DASH); + this.state = 188; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === LGFileParser.MULTILINE_PREFIX) { + { + this.state = 187; + this.match(LGFileParser.MULTILINE_PREFIX); + } + } + + this.state = 193; + this._errHandler.sync(this); + _la = this._input.LA(1); + while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.ESCAPE_CHARACTER) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0)) { + { + { + this.state = 190; + _la = this._input.LA(1); + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.ESCAPE_CHARACTER) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 195; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + this.state = 197; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === LGFileParser.MULTILINE_SUFFIX) { + { + this.state = 196; + this.match(LGFileParser.MULTILINE_SUFFIX); + } + } + + } + } + 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 errorTemplateString(): ErrorTemplateStringContext { + let _localctx: ErrorTemplateStringContext = new ErrorTemplateStringContext(this._ctx, this.state); + this.enterRule(_localctx, 42, LGFileParser.RULE_errorTemplateString); + try { + let _alt: number; + this.enterOuterAlt(_localctx, 1); + { + this.state = 200; + this._errHandler.sync(this); + _alt = 1; + do { + switch (_alt) { + case 1: + { + { + this.state = 199; + this.match(LGFileParser.INVALID_TOKEN); + } + } + break; + default: + throw new NoViableAltException(this); + } + this.state = 202; + this._errHandler.sync(this); + _alt = this.interpreter.adaptivePredict(this._input, 25, this._ctx); + } while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER); + } + } + 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 ifElseTemplateBody(): IfElseTemplateBodyContext { + let _localctx: IfElseTemplateBodyContext = new IfElseTemplateBodyContext(this._ctx, this.state); + this.enterRule(_localctx, 44, LGFileParser.RULE_ifElseTemplateBody); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 205; + this._errHandler.sync(this); + _la = this._input.LA(1); + do { + { + { + this.state = 204; + this.ifConditionRule(); + } + } + this.state = 207; + this._errHandler.sync(this); + _la = this._input.LA(1); + } while (_la === LGFileParser.DASH); + } + } + 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 ifConditionRule(): IfConditionRuleContext { + let _localctx: IfConditionRuleContext = new IfConditionRuleContext(this._ctx, this.state); + this.enterRule(_localctx, 46, LGFileParser.RULE_ifConditionRule); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 209; + this.ifCondition(); + this.state = 211; + this._errHandler.sync(this); + switch ( this.interpreter.adaptivePredict(this._input, 27, this._ctx) ) { + case 1: + { + this.state = 210; + this.normalTemplateBody(); + } + break; + } + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + // @RuleVersion(0) + public ifCondition(): IfConditionContext { + let _localctx: IfConditionContext = new IfConditionContext(this._ctx, this.state); + this.enterRule(_localctx, 48, LGFileParser.RULE_ifCondition); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 213; + this.match(LGFileParser.DASH); + this.state = 214; + _la = this._input.LA(1); + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.IF) | (1 << LGFileParser.ELSEIF) | (1 << LGFileParser.ELSE))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 218; + this._errHandler.sync(this); + _la = this._input.LA(1); + while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.WS) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0)) { + { + { + this.state = 215; + _la = this._input.LA(1); + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.WS) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 220; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } + } + 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 switchCaseTemplateBody(): SwitchCaseTemplateBodyContext { + let _localctx: SwitchCaseTemplateBodyContext = new SwitchCaseTemplateBodyContext(this._ctx, this.state); + this.enterRule(_localctx, 50, LGFileParser.RULE_switchCaseTemplateBody); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 222; + this._errHandler.sync(this); + _la = this._input.LA(1); + do { + { + { + this.state = 221; + this.switchCaseRule(); + } + } + this.state = 224; + this._errHandler.sync(this); + _la = this._input.LA(1); + } while (_la === LGFileParser.DASH); + } + } + 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 switchCaseRule(): SwitchCaseRuleContext { + let _localctx: SwitchCaseRuleContext = new SwitchCaseRuleContext(this._ctx, this.state); + this.enterRule(_localctx, 52, LGFileParser.RULE_switchCaseRule); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 226; + this.switchCaseStat(); + this.state = 228; + this._errHandler.sync(this); + switch ( this.interpreter.adaptivePredict(this._input, 30, this._ctx) ) { + case 1: + { + this.state = 227; + this.normalTemplateBody(); + } + break; + } + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + // @RuleVersion(0) + public switchCaseStat(): SwitchCaseStatContext { + let _localctx: SwitchCaseStatContext = new SwitchCaseStatContext(this._ctx, this.state); + this.enterRule(_localctx, 54, LGFileParser.RULE_switchCaseStat); + let _la: number; + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 230; + this.match(LGFileParser.DASH); + this.state = 231; + _la = this._input.LA(1); + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.SWITCH) | (1 << LGFileParser.CASE) | (1 << LGFileParser.DEFAULT))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 235; + this._errHandler.sync(this); + _la = this._input.LA(1); + while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.WS) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0)) { + { + { + this.state = 232; + _la = this._input.LA(1); + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << LGFileParser.WS) | (1 << LGFileParser.EXPRESSION) | (1 << LGFileParser.TEXT))) !== 0))) { + this._errHandler.recoverInline(this); + } else { + if (this._input.LA(1) === Token.EOF) { + this.matchedEOF = true; + } + + this._errHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 237; + this._errHandler.sync(this); + _la = this._input.LA(1); + } + } + } + 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 importDefinition(): ImportDefinitionContext { + let _localctx: ImportDefinitionContext = new ImportDefinitionContext(this._ctx, this.state); + this.enterRule(_localctx, 56, LGFileParser.RULE_importDefinition); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 238; + this.match(LGFileParser.IMPORT); + } + } + 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 optionsDefinition(): OptionsDefinitionContext { + let _localctx: OptionsDefinitionContext = new OptionsDefinitionContext(this._ctx, this.state); + this.enterRule(_localctx, 58, LGFileParser.RULE_optionsDefinition); + try { + this.enterOuterAlt(_localctx, 1); + { + this.state = 240; + this.match(LGFileParser.OPTIONS); + } + } + catch (re) { + if (re instanceof RecognitionException) { + _localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return _localctx; + } + + public static readonly _serializedATN: string = + "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x03.\xF5\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\x03\x02\x06\x02@\n\x02\r\x02\x0E" + + "\x02A\x03\x02\x03\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x05\x03" + + "K\n\x03\x03\x04\x06\x04N\n\x04\r\x04\x0E\x04O\x03\x05\x03\x05\x05\x05" + + "T\n\x05\x03\x06\x03\x06\x03\x06\x05\x06Y\n\x06\x03\x06\x05\x06\\\n\x06" + + "\x03\x07\x07\x07_\n\x07\f\x07\x0E\x07b\v\x07\x03\b\x03\b\x03\b\x07\bg" + + "\n\b\f\b\x0E\bj\v\b\x03\t\x03\t\x03\t\x03\t\x07\tp\n\t\f\t\x0E\ts\v\t" + + "\x05\tu\n\t\x03\t\x03\t\x03\n\x03\n\x03\n\x03\n\x05\n}\n\n\x03\v\x03\v" + + "\x03\v\x03\v\x06\v\x83\n\v\r\v\x0E\v\x84\x05\v\x87\n\v\x03\v\x05\v\x8A" + + "\n\v\x03\f\x03\f\x03\f\x05\f\x8F\n\f\x03\r\x07\r\x92\n\r\f\r\x0E\r\x95" + + "\v\r\x03\x0E\x03\x0E\x03\x0E\x05\x0E\x9A\n\x0E\x03\x0F\x06\x0F\x9D\n\x0F" + + "\r\x0F\x0E\x0F\x9E\x03\x10\x03\x10\x03\x10\x03\x10\x03\x10\x07\x10\xA6" + + "\n\x10\f\x10\x0E\x10\xA9\v\x10\x03\x11\x06\x11\xAC\n\x11\r\x11\x0E\x11" + + "\xAD\x03\x12\x03\x12\x03\x13\x03\x13\x03\x14\x06\x14\xB5\n\x14\r\x14\x0E" + + "\x14\xB6\x03\x15\x03\x15\x05\x15\xBB\n\x15\x03\x16\x03\x16\x05\x16\xBF" + + "\n\x16\x03\x16\x07\x16\xC2\n\x16\f\x16\x0E\x16\xC5\v\x16\x03\x16\x05\x16" + + "\xC8\n\x16\x03\x17\x06\x17\xCB\n\x17\r\x17\x0E\x17\xCC\x03\x18\x06\x18" + + "\xD0\n\x18\r\x18\x0E\x18\xD1\x03\x19\x03\x19\x05\x19\xD6\n\x19\x03\x1A" + + "\x03\x1A\x03\x1A\x07\x1A\xDB\n\x1A\f\x1A\x0E\x1A\xDE\v\x1A\x03\x1B\x06" + + "\x1B\xE1\n\x1B\r\x1B\x0E\x1B\xE2\x03\x1C\x03\x1C\x05\x1C\xE7\n\x1C\x03" + + "\x1D\x03\x1D\x03\x1D\x07\x1D\xEC\n\x1D\f\x1D\x0E\x1D\xEF\v\x1D\x03\x1E" + + "\x03\x1E\x03\x1F\x03\x1F\x03\x1F\x03A\x02\x02 \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\x02" + + "4\x026\x028\x02:\x02<\x02\x02\n\x03\x02\x0E\x13\x03\x02#$\x03\x02).\x03" + + "\x02,.\x03\x02\x1D\x1F\x03\x02\x17\x19\x04\x02\x05\x05\x1E\x1F\x03\x02" + + "\x1A\x1C\xFC\x02?\x03\x02\x02\x02\x04J\x03\x02\x02\x02\x06M\x03\x02\x02" + + "\x02\bQ\x03\x02\x02\x02\nU\x03\x02\x02\x02\f`\x03\x02\x02\x02\x0Ec\x03" + + "\x02\x02\x02\x10k\x03\x02\x02\x02\x12|\x03\x02\x02\x02\x14~\x03\x02\x02" + + "\x02\x16\x8B\x03\x02\x02\x02\x18\x93\x03\x02\x02\x02\x1A\x99\x03\x02\x02" + + "\x02\x1C\x9C\x03\x02\x02\x02\x1E\xA0\x03\x02\x02\x02 \xAB\x03\x02\x02" + + "\x02\"\xAF\x03\x02\x02\x02$\xB1\x03\x02\x02\x02&\xB4\x03\x02\x02\x02(" + + "\xBA\x03\x02\x02\x02*\xBC\x03\x02\x02\x02,\xCA\x03\x02\x02\x02.\xCF\x03" + + "\x02\x02\x020\xD3\x03\x02\x02\x022\xD7\x03\x02\x02\x024\xE0\x03\x02\x02" + + "\x026\xE4\x03\x02\x02\x028\xE8\x03\x02\x02\x02:\xF0\x03\x02\x02\x02<\xF2" + + "\x03\x02\x02\x02>@\x05\x04\x03\x02?>\x03\x02\x02\x02@A\x03\x02\x02\x02" + + "AB\x03\x02\x02\x02A?\x03\x02\x02\x02BC\x03\x02\x02\x02CD\x07\x02\x02\x03" + + "D\x03\x03\x02\x02\x02EK\x05\b\x05\x02FK\x05:\x1E\x02GK\x05<\x1F\x02HK" + + "\x07\x02\x02\x03IK\x05\x06\x04\x02JE\x03\x02\x02\x02JF\x03\x02\x02\x02" + + "JG\x03\x02\x02\x02JH\x03\x02\x02\x02JI\x03\x02\x02\x02K\x05\x03\x02\x02" + + "\x02LN\x07\v\x02\x02ML\x03\x02\x02\x02NO\x03\x02\x02\x02OM\x03\x02\x02" + + "\x02OP\x03\x02\x02\x02P\x07\x03\x02\x02\x02QS\x05\n\x06\x02RT\x05\x12" + + "\n\x02SR\x03\x02\x02\x02ST\x03\x02\x02\x02T\t\x03\x02\x02\x02U[\x07\x07" + + "\x02\x02VX\x05\x0E\b\x02WY\x05\x10\t\x02XW\x03\x02\x02\x02XY\x03\x02\x02" + + "\x02Y\\\x03\x02\x02\x02Z\\\x05\f\x07\x02[V\x03\x02\x02\x02[Z\x03\x02\x02" + + "\x02\\\v\x03\x02\x02\x02]_\t\x02\x02\x02^]\x03\x02\x02\x02_b\x03\x02\x02" + + "\x02`^\x03\x02\x02\x02`a\x03\x02\x02\x02a\r\x03\x02\x02\x02b`\x03\x02" + + "\x02\x02ch\x07\x0E\x02\x02de\x07\x0F\x02\x02eg\x07\x0E\x02\x02fd\x03\x02" + + "\x02\x02gj\x03\x02\x02\x02hf\x03\x02\x02\x02hi\x03\x02\x02\x02i\x0F\x03" + + "\x02\x02\x02jh\x03\x02\x02\x02kt\x07\x10\x02\x02lq\x07\x0E\x02\x02mn\x07" + + "\x12\x02\x02np\x07\x0E\x02\x02om\x03\x02\x02\x02ps\x03\x02\x02\x02qo\x03" + + "\x02\x02\x02qr\x03\x02\x02\x02ru\x03\x02\x02\x02sq\x03\x02\x02\x02tl\x03" + + "\x02\x02\x02tu\x03\x02\x02\x02uv\x03\x02\x02\x02vw\x07\x11\x02\x02w\x11" + + "\x03\x02\x02\x02x}\x05&\x14\x02y}\x05.\x18\x02z}\x054\x1B\x02{}\x05\x14" + + "\v\x02|x\x03\x02\x02\x02|y\x03\x02\x02\x02|z\x03\x02\x02\x02|{\x03\x02" + + "\x02\x02}\x13\x03\x02\x02\x02~\x86\x05\x16\f\x02\x7F\x80\x05\x1A\x0E\x02" + + "\x80\x81\x07\'\x02\x02\x81\x83\x03\x02\x02\x02\x82\x7F\x03\x02\x02\x02" + + "\x83\x84\x03\x02\x02\x02\x84\x82\x03\x02\x02\x02\x84\x85\x03\x02\x02\x02" + + "\x85\x87\x03\x02\x02\x02\x86\x82\x03\x02\x02\x02\x86\x87\x03\x02\x02\x02" + + "\x87\x89\x03\x02\x02\x02\x88\x8A\x05$\x13\x02\x89\x88\x03\x02\x02\x02" + + "\x89\x8A\x03\x02\x02\x02\x8A\x15\x03\x02\x02\x02\x8B\x8E\x07\t\x02\x02" + + "\x8C\x8F\x07#\x02\x02\x8D\x8F\x05\x18\r\x02\x8E\x8C\x03\x02\x02\x02\x8E" + + "\x8D\x03\x02\x02\x02\x8F\x17\x03\x02\x02\x02\x90\x92\t\x03\x02\x02\x91" + + "\x90\x03\x02\x02\x02\x92\x95\x03\x02\x02\x02\x93\x91\x03\x02\x02\x02\x93" + + "\x94\x03\x02\x02\x02\x94\x19\x03\x02\x02\x02\x95\x93\x03\x02\x02\x02\x96" + + "\x9A\x05\x1E\x10\x02\x97\x9A\x05\"\x12\x02\x98\x9A\x05\x1C\x0F\x02\x99" + + "\x96\x03\x02\x02\x02\x99\x97\x03\x02\x02\x02\x99\x98\x03\x02\x02\x02\x9A" + + "\x1B\x03\x02\x02\x02\x9B\x9D\t\x04\x02\x02\x9C\x9B\x03\x02\x02\x02\x9D" + + "\x9E\x03\x02\x02\x02\x9E\x9C\x03\x02\x02\x02\x9E\x9F\x03\x02\x02\x02\x9F" + + "\x1D\x03\x02\x02\x02\xA0\xA1\x07)\x02\x02\xA1\xA2\x07*\x02\x02\xA2\xA7" + + "\x05 \x11\x02\xA3\xA4\x07+\x02\x02\xA4\xA6\x05 \x11\x02\xA5\xA3\x03\x02" + + "\x02\x02\xA6\xA9\x03\x02\x02\x02\xA7\xA5\x03\x02\x02\x02\xA7\xA8\x03\x02" + + "\x02\x02\xA8\x1F\x03\x02\x02\x02\xA9\xA7\x03\x02\x02\x02\xAA\xAC\t\x05" + + "\x02\x02\xAB\xAA\x03\x02\x02\x02\xAC\xAD\x03\x02\x02\x02\xAD\xAB\x03\x02" + + "\x02\x02\xAD\xAE\x03\x02\x02\x02\xAE!\x03\x02\x02\x02\xAF\xB0\x07-\x02" + + "\x02\xB0#\x03\x02\x02\x02\xB1\xB2\x07(\x02\x02\xB2%\x03\x02\x02\x02\xB3" + + "\xB5\x05(\x15\x02\xB4\xB3\x03\x02\x02\x02\xB5\xB6\x03\x02\x02\x02\xB6" + + "\xB4\x03\x02\x02\x02\xB6\xB7\x03\x02\x02\x02\xB7\'\x03\x02\x02\x02\xB8" + + "\xBB\x05*\x16\x02\xB9\xBB\x05,\x17\x02\xBA\xB8\x03\x02\x02\x02\xBA\xB9" + + "\x03\x02\x02\x02\xBB)\x03\x02\x02\x02\xBC\xBE\x07\b\x02\x02\xBD\xBF\x07" + + "\x15\x02\x02\xBE\xBD\x03\x02\x02\x02\xBE\xBF\x03\x02\x02\x02\xBF\xC3\x03" + + "\x02\x02\x02\xC0\xC2\t\x06\x02\x02\xC1\xC0\x03\x02\x02\x02\xC2\xC5\x03" + + "\x02\x02\x02\xC3\xC1\x03\x02\x02\x02\xC3\xC4\x03\x02\x02\x02\xC4\xC7\x03" + + "\x02\x02\x02\xC5\xC3\x03\x02\x02\x02\xC6\xC8\x07 \x02\x02\xC7\xC6\x03" + + "\x02\x02\x02\xC7\xC8\x03\x02\x02\x02\xC8+\x03\x02\x02\x02\xC9\xCB\x07" + + "\v\x02\x02\xCA\xC9\x03\x02\x02\x02\xCB\xCC\x03\x02\x02\x02\xCC\xCA\x03" + + "\x02\x02\x02\xCC\xCD\x03\x02\x02\x02\xCD-\x03\x02\x02\x02\xCE\xD0\x05" + + "0\x19\x02\xCF\xCE\x03\x02\x02\x02\xD0\xD1\x03\x02\x02\x02\xD1\xCF\x03" + + "\x02\x02\x02\xD1\xD2\x03\x02\x02\x02\xD2/\x03\x02\x02\x02\xD3\xD5\x05" + + "2\x1A\x02\xD4\xD6\x05&\x14\x02\xD5\xD4\x03\x02\x02\x02\xD5\xD6\x03\x02" + + "\x02\x02\xD61\x03\x02\x02\x02\xD7\xD8\x07\b\x02\x02\xD8\xDC\t\x07\x02" + + "\x02\xD9\xDB\t\b\x02\x02\xDA\xD9\x03\x02\x02\x02\xDB\xDE\x03\x02\x02\x02" + + "\xDC\xDA\x03\x02\x02\x02\xDC\xDD\x03\x02\x02\x02\xDD3\x03\x02\x02\x02" + + "\xDE\xDC\x03\x02\x02\x02\xDF\xE1\x056\x1C\x02\xE0\xDF\x03\x02\x02\x02" + + "\xE1\xE2\x03\x02\x02\x02\xE2\xE0\x03\x02\x02\x02\xE2\xE3\x03\x02\x02\x02" + + "\xE35\x03\x02\x02\x02\xE4\xE6\x058\x1D\x02\xE5\xE7\x05&\x14\x02\xE6\xE5" + + "\x03\x02\x02\x02\xE6\xE7\x03\x02\x02\x02\xE77\x03\x02\x02\x02\xE8\xE9" + + "\x07\b\x02\x02\xE9\xED\t\t\x02\x02\xEA\xEC\t\b\x02\x02\xEB\xEA\x03\x02" + + "\x02\x02\xEC\xEF\x03\x02\x02\x02\xED\xEB\x03\x02\x02\x02\xED\xEE\x03\x02" + + "\x02\x02\xEE9\x03\x02\x02\x02\xEF\xED\x03\x02\x02\x02\xF0\xF1\x07\n\x02" + + "\x02\xF1;\x03\x02\x02\x02\xF2\xF3\x07\x03\x02\x02\xF3=\x03\x02\x02\x02" + + "\"AJOSX[`hqt|\x84\x86\x89\x8E\x93\x99\x9E\xA7\xAD\xB6\xBA\xBE\xC3\xC7" + + "\xCC\xD1\xD5\xDC\xE2\xE6\xED"; + public static __ATN: ATN; + public static get _ATN(): ATN { + if (!LGFileParser.__ATN) { + LGFileParser.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(LGFileParser._serializedATN)); + } + + return LGFileParser.__ATN; + } + +} + +export class FileContext extends ParserRuleContext { + public EOF(): TerminalNode { return this.getToken(LGFileParser.EOF, 0); } + public paragraph(): ParagraphContext[]; + public paragraph(i: number): ParagraphContext; + public paragraph(i?: number): ParagraphContext | ParagraphContext[] { + if (i === undefined) { + return this.getRuleContexts(ParagraphContext); + } else { + return this.getRuleContext(i, ParagraphContext); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_file; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterFile) { + listener.enterFile(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitFile) { + listener.exitFile(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitFile) { + return visitor.visitFile(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ParagraphContext extends ParserRuleContext { + public templateDefinition(): TemplateDefinitionContext | undefined { + return this.tryGetRuleContext(0, TemplateDefinitionContext); + } + public importDefinition(): ImportDefinitionContext | undefined { + return this.tryGetRuleContext(0, ImportDefinitionContext); + } + public optionsDefinition(): OptionsDefinitionContext | undefined { + return this.tryGetRuleContext(0, OptionsDefinitionContext); + } + public EOF(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.EOF, 0); } + public errorTemplate(): ErrorTemplateContext | undefined { + return this.tryGetRuleContext(0, ErrorTemplateContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_paragraph; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterParagraph) { + listener.enterParagraph(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitParagraph) { + listener.exitParagraph(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitParagraph) { + return visitor.visitParagraph(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ErrorTemplateContext extends ParserRuleContext { + public INVALID_TOKEN(): TerminalNode[]; + public INVALID_TOKEN(i: number): TerminalNode; + public INVALID_TOKEN(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.INVALID_TOKEN); + } else { + return this.getToken(LGFileParser.INVALID_TOKEN, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_errorTemplate; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterErrorTemplate) { + listener.enterErrorTemplate(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitErrorTemplate) { + listener.exitErrorTemplate(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitErrorTemplate) { + return visitor.visitErrorTemplate(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class TemplateDefinitionContext extends ParserRuleContext { + public templateNameLine(): TemplateNameLineContext { + return this.getRuleContext(0, TemplateNameLineContext); + } + public templateBody(): TemplateBodyContext | undefined { + return this.tryGetRuleContext(0, TemplateBodyContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_templateDefinition; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterTemplateDefinition) { + listener.enterTemplateDefinition(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitTemplateDefinition) { + listener.exitTemplateDefinition(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitTemplateDefinition) { + return visitor.visitTemplateDefinition(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class TemplateNameLineContext extends ParserRuleContext { + public HASH(): TerminalNode { return this.getToken(LGFileParser.HASH, 0); } + public errorTemplateName(): ErrorTemplateNameContext | undefined { + return this.tryGetRuleContext(0, ErrorTemplateNameContext); + } + public templateName(): TemplateNameContext | undefined { + return this.tryGetRuleContext(0, TemplateNameContext); + } + public parameters(): ParametersContext | undefined { + return this.tryGetRuleContext(0, ParametersContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_templateNameLine; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterTemplateNameLine) { + listener.enterTemplateNameLine(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitTemplateNameLine) { + listener.exitTemplateNameLine(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitTemplateNameLine) { + return visitor.visitTemplateNameLine(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ErrorTemplateNameContext extends ParserRuleContext { + public IDENTIFIER(): TerminalNode[]; + public IDENTIFIER(i: number): TerminalNode; + public IDENTIFIER(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.IDENTIFIER); + } else { + return this.getToken(LGFileParser.IDENTIFIER, i); + } + } + public TEXT_IN_NAME(): TerminalNode[]; + public TEXT_IN_NAME(i: number): TerminalNode; + public TEXT_IN_NAME(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.TEXT_IN_NAME); + } else { + return this.getToken(LGFileParser.TEXT_IN_NAME, i); + } + } + public OPEN_PARENTHESIS(): TerminalNode[]; + public OPEN_PARENTHESIS(i: number): TerminalNode; + public OPEN_PARENTHESIS(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.OPEN_PARENTHESIS); + } else { + return this.getToken(LGFileParser.OPEN_PARENTHESIS, i); + } + } + public COMMA(): TerminalNode[]; + public COMMA(i: number): TerminalNode; + public COMMA(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.COMMA); + } else { + return this.getToken(LGFileParser.COMMA, i); + } + } + public CLOSE_PARENTHESIS(): TerminalNode[]; + public CLOSE_PARENTHESIS(i: number): TerminalNode; + public CLOSE_PARENTHESIS(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.CLOSE_PARENTHESIS); + } else { + return this.getToken(LGFileParser.CLOSE_PARENTHESIS, i); + } + } + public DOT(): TerminalNode[]; + public DOT(i: number): TerminalNode; + public DOT(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.DOT); + } else { + return this.getToken(LGFileParser.DOT, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_errorTemplateName; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterErrorTemplateName) { + listener.enterErrorTemplateName(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitErrorTemplateName) { + listener.exitErrorTemplateName(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitErrorTemplateName) { + return visitor.visitErrorTemplateName(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class TemplateNameContext extends ParserRuleContext { + public IDENTIFIER(): TerminalNode[]; + public IDENTIFIER(i: number): TerminalNode; + public IDENTIFIER(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.IDENTIFIER); + } else { + return this.getToken(LGFileParser.IDENTIFIER, i); + } + } + public DOT(): TerminalNode[]; + public DOT(i: number): TerminalNode; + public DOT(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.DOT); + } else { + return this.getToken(LGFileParser.DOT, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_templateName; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterTemplateName) { + listener.enterTemplateName(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitTemplateName) { + listener.exitTemplateName(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitTemplateName) { + return visitor.visitTemplateName(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ParametersContext extends ParserRuleContext { + public OPEN_PARENTHESIS(): TerminalNode { return this.getToken(LGFileParser.OPEN_PARENTHESIS, 0); } + public CLOSE_PARENTHESIS(): TerminalNode { return this.getToken(LGFileParser.CLOSE_PARENTHESIS, 0); } + public IDENTIFIER(): TerminalNode[]; + public IDENTIFIER(i: number): TerminalNode; + public IDENTIFIER(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.IDENTIFIER); + } else { + return this.getToken(LGFileParser.IDENTIFIER, i); + } + } + public COMMA(): TerminalNode[]; + public COMMA(i: number): TerminalNode; + public COMMA(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.COMMA); + } else { + return this.getToken(LGFileParser.COMMA, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_parameters; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterParameters) { + listener.enterParameters(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitParameters) { + listener.exitParameters(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitParameters) { + return visitor.visitParameters(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class TemplateBodyContext extends ParserRuleContext { + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_templateBody; } + public copyFrom(ctx: TemplateBodyContext): void { + super.copyFrom(ctx); + } +} +export class SwitchCaseBodyContext extends TemplateBodyContext { + public switchCaseTemplateBody(): SwitchCaseTemplateBodyContext { + return this.getRuleContext(0, SwitchCaseTemplateBodyContext); + } + constructor(ctx: TemplateBodyContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterSwitchCaseBody) { + listener.enterSwitchCaseBody(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitSwitchCaseBody) { + listener.exitSwitchCaseBody(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitSwitchCaseBody) { + return visitor.visitSwitchCaseBody(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class NormalBodyContext extends TemplateBodyContext { + public normalTemplateBody(): NormalTemplateBodyContext { + return this.getRuleContext(0, NormalTemplateBodyContext); + } + constructor(ctx: TemplateBodyContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterNormalBody) { + listener.enterNormalBody(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitNormalBody) { + listener.exitNormalBody(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitNormalBody) { + return visitor.visitNormalBody(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class StructuredBodyContext extends TemplateBodyContext { + public structuredTemplateBody(): StructuredTemplateBodyContext { + return this.getRuleContext(0, StructuredTemplateBodyContext); + } + constructor(ctx: TemplateBodyContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterStructuredBody) { + listener.enterStructuredBody(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitStructuredBody) { + listener.exitStructuredBody(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitStructuredBody) { + return visitor.visitStructuredBody(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class IfElseBodyContext extends TemplateBodyContext { + public ifElseTemplateBody(): IfElseTemplateBodyContext { + return this.getRuleContext(0, IfElseTemplateBodyContext); + } + constructor(ctx: TemplateBodyContext) { + super(ctx.parent, ctx.invokingState); + this.copyFrom(ctx); + } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterIfElseBody) { + listener.enterIfElseBody(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitIfElseBody) { + listener.exitIfElseBody(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitIfElseBody) { + return visitor.visitIfElseBody(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class StructuredTemplateBodyContext extends ParserRuleContext { + public structuredBodyNameLine(): StructuredBodyNameLineContext { + return this.getRuleContext(0, StructuredBodyNameLineContext); + } + public structuredBodyEndLine(): StructuredBodyEndLineContext | undefined { + return this.tryGetRuleContext(0, StructuredBodyEndLineContext); + } + public structuredBodyContentLine(): StructuredBodyContentLineContext[]; + public structuredBodyContentLine(i: number): StructuredBodyContentLineContext; + public structuredBodyContentLine(i?: number): StructuredBodyContentLineContext | StructuredBodyContentLineContext[] { + if (i === undefined) { + return this.getRuleContexts(StructuredBodyContentLineContext); + } else { + return this.getRuleContext(i, StructuredBodyContentLineContext); + } + } + public STRUCTURED_NEWLINE(): TerminalNode[]; + public STRUCTURED_NEWLINE(i: number): TerminalNode; + public STRUCTURED_NEWLINE(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.STRUCTURED_NEWLINE); + } else { + return this.getToken(LGFileParser.STRUCTURED_NEWLINE, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_structuredTemplateBody; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterStructuredTemplateBody) { + listener.enterStructuredTemplateBody(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitStructuredTemplateBody) { + listener.exitStructuredTemplateBody(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitStructuredTemplateBody) { + return visitor.visitStructuredTemplateBody(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class StructuredBodyNameLineContext extends ParserRuleContext { + public LEFT_SQUARE_BRACKET(): TerminalNode { return this.getToken(LGFileParser.LEFT_SQUARE_BRACKET, 0); } + public STRUCTURE_NAME(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.STRUCTURE_NAME, 0); } + public errorStructuredName(): ErrorStructuredNameContext | undefined { + return this.tryGetRuleContext(0, ErrorStructuredNameContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_structuredBodyNameLine; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterStructuredBodyNameLine) { + listener.enterStructuredBodyNameLine(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitStructuredBodyNameLine) { + listener.exitStructuredBodyNameLine(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitStructuredBodyNameLine) { + return visitor.visitStructuredBodyNameLine(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ErrorStructuredNameContext extends ParserRuleContext { + public STRUCTURE_NAME(): TerminalNode[]; + public STRUCTURE_NAME(i: number): TerminalNode; + public STRUCTURE_NAME(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.STRUCTURE_NAME); + } else { + return this.getToken(LGFileParser.STRUCTURE_NAME, i); + } + } + public TEXT_IN_STRUCTURE_NAME(): TerminalNode[]; + public TEXT_IN_STRUCTURE_NAME(i: number): TerminalNode; + public TEXT_IN_STRUCTURE_NAME(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.TEXT_IN_STRUCTURE_NAME); + } else { + return this.getToken(LGFileParser.TEXT_IN_STRUCTURE_NAME, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_errorStructuredName; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterErrorStructuredName) { + listener.enterErrorStructuredName(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitErrorStructuredName) { + listener.exitErrorStructuredName(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitErrorStructuredName) { + return visitor.visitErrorStructuredName(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class StructuredBodyContentLineContext extends ParserRuleContext { + public keyValueStructureLine(): KeyValueStructureLineContext | undefined { + return this.tryGetRuleContext(0, KeyValueStructureLineContext); + } + public objectStructureLine(): ObjectStructureLineContext | undefined { + return this.tryGetRuleContext(0, ObjectStructureLineContext); + } + public errorStructureLine(): ErrorStructureLineContext | undefined { + return this.tryGetRuleContext(0, ErrorStructureLineContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_structuredBodyContentLine; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterStructuredBodyContentLine) { + listener.enterStructuredBodyContentLine(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitStructuredBodyContentLine) { + listener.exitStructuredBodyContentLine(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitStructuredBodyContentLine) { + return visitor.visitStructuredBodyContentLine(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ErrorStructureLineContext extends ParserRuleContext { + public STRUCTURE_IDENTIFIER(): TerminalNode[]; + public STRUCTURE_IDENTIFIER(i: number): TerminalNode; + public STRUCTURE_IDENTIFIER(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.STRUCTURE_IDENTIFIER); + } else { + return this.getToken(LGFileParser.STRUCTURE_IDENTIFIER, i); + } + } + public STRUCTURE_EQUALS(): TerminalNode[]; + public STRUCTURE_EQUALS(i: number): TerminalNode; + public STRUCTURE_EQUALS(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.STRUCTURE_EQUALS); + } else { + return this.getToken(LGFileParser.STRUCTURE_EQUALS, i); + } + } + public STRUCTURE_OR_MARK(): TerminalNode[]; + public STRUCTURE_OR_MARK(i: number): TerminalNode; + public STRUCTURE_OR_MARK(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.STRUCTURE_OR_MARK); + } else { + return this.getToken(LGFileParser.STRUCTURE_OR_MARK, i); + } + } + public TEXT_IN_STRUCTURE_BODY(): TerminalNode[]; + public TEXT_IN_STRUCTURE_BODY(i: number): TerminalNode; + public TEXT_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.TEXT_IN_STRUCTURE_BODY); + } else { + return this.getToken(LGFileParser.TEXT_IN_STRUCTURE_BODY, i); + } + } + public EXPRESSION_IN_STRUCTURE_BODY(): TerminalNode[]; + public EXPRESSION_IN_STRUCTURE_BODY(i: number): TerminalNode; + public EXPRESSION_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY); + } else { + return this.getToken(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY, i); + } + } + public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(): TerminalNode[]; + public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(i: number): TerminalNode; + public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY); + } else { + return this.getToken(LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_errorStructureLine; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterErrorStructureLine) { + listener.enterErrorStructureLine(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitErrorStructureLine) { + listener.exitErrorStructureLine(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitErrorStructureLine) { + return visitor.visitErrorStructureLine(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class KeyValueStructureLineContext extends ParserRuleContext { + public STRUCTURE_IDENTIFIER(): TerminalNode { return this.getToken(LGFileParser.STRUCTURE_IDENTIFIER, 0); } + public STRUCTURE_EQUALS(): TerminalNode { return this.getToken(LGFileParser.STRUCTURE_EQUALS, 0); } + public keyValueStructureValue(): KeyValueStructureValueContext[]; + public keyValueStructureValue(i: number): KeyValueStructureValueContext; + public keyValueStructureValue(i?: number): KeyValueStructureValueContext | KeyValueStructureValueContext[] { + if (i === undefined) { + return this.getRuleContexts(KeyValueStructureValueContext); + } else { + return this.getRuleContext(i, KeyValueStructureValueContext); + } + } + public STRUCTURE_OR_MARK(): TerminalNode[]; + public STRUCTURE_OR_MARK(i: number): TerminalNode; + public STRUCTURE_OR_MARK(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.STRUCTURE_OR_MARK); + } else { + return this.getToken(LGFileParser.STRUCTURE_OR_MARK, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_keyValueStructureLine; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterKeyValueStructureLine) { + listener.enterKeyValueStructureLine(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitKeyValueStructureLine) { + listener.exitKeyValueStructureLine(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitKeyValueStructureLine) { + return visitor.visitKeyValueStructureLine(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class KeyValueStructureValueContext extends ParserRuleContext { + public TEXT_IN_STRUCTURE_BODY(): TerminalNode[]; + public TEXT_IN_STRUCTURE_BODY(i: number): TerminalNode; + public TEXT_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.TEXT_IN_STRUCTURE_BODY); + } else { + return this.getToken(LGFileParser.TEXT_IN_STRUCTURE_BODY, i); + } + } + public EXPRESSION_IN_STRUCTURE_BODY(): TerminalNode[]; + public EXPRESSION_IN_STRUCTURE_BODY(i: number): TerminalNode; + public EXPRESSION_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY); + } else { + return this.getToken(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY, i); + } + } + public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(): TerminalNode[]; + public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(i: number): TerminalNode; + public ESCAPE_CHARACTER_IN_STRUCTURE_BODY(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY); + } else { + return this.getToken(LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_keyValueStructureValue; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterKeyValueStructureValue) { + listener.enterKeyValueStructureValue(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitKeyValueStructureValue) { + listener.exitKeyValueStructureValue(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitKeyValueStructureValue) { + return visitor.visitKeyValueStructureValue(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ObjectStructureLineContext extends ParserRuleContext { + public EXPRESSION_IN_STRUCTURE_BODY(): TerminalNode { return this.getToken(LGFileParser.EXPRESSION_IN_STRUCTURE_BODY, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_objectStructureLine; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterObjectStructureLine) { + listener.enterObjectStructureLine(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitObjectStructureLine) { + listener.exitObjectStructureLine(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitObjectStructureLine) { + return visitor.visitObjectStructureLine(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class StructuredBodyEndLineContext extends ParserRuleContext { + public STRUCTURED_BODY_END(): TerminalNode { return this.getToken(LGFileParser.STRUCTURED_BODY_END, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_structuredBodyEndLine; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterStructuredBodyEndLine) { + listener.enterStructuredBodyEndLine(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitStructuredBodyEndLine) { + listener.exitStructuredBodyEndLine(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitStructuredBodyEndLine) { + return visitor.visitStructuredBodyEndLine(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class NormalTemplateBodyContext extends ParserRuleContext { + public templateString(): TemplateStringContext[]; + public templateString(i: number): TemplateStringContext; + public templateString(i?: number): TemplateStringContext | TemplateStringContext[] { + if (i === undefined) { + return this.getRuleContexts(TemplateStringContext); + } else { + return this.getRuleContext(i, TemplateStringContext); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_normalTemplateBody; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterNormalTemplateBody) { + listener.enterNormalTemplateBody(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitNormalTemplateBody) { + listener.exitNormalTemplateBody(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitNormalTemplateBody) { + return visitor.visitNormalTemplateBody(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class TemplateStringContext extends ParserRuleContext { + public normalTemplateString(): NormalTemplateStringContext | undefined { + return this.tryGetRuleContext(0, NormalTemplateStringContext); + } + public errorTemplateString(): ErrorTemplateStringContext | undefined { + return this.tryGetRuleContext(0, ErrorTemplateStringContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_templateString; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterTemplateString) { + listener.enterTemplateString(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitTemplateString) { + listener.exitTemplateString(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitTemplateString) { + return visitor.visitTemplateString(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class NormalTemplateStringContext extends ParserRuleContext { + public DASH(): TerminalNode { return this.getToken(LGFileParser.DASH, 0); } + public MULTILINE_PREFIX(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.MULTILINE_PREFIX, 0); } + public MULTILINE_SUFFIX(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.MULTILINE_SUFFIX, 0); } + public TEXT(): TerminalNode[]; + public TEXT(i: number): TerminalNode; + public TEXT(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.TEXT); + } else { + return this.getToken(LGFileParser.TEXT, i); + } + } + public EXPRESSION(): TerminalNode[]; + public EXPRESSION(i: number): TerminalNode; + public EXPRESSION(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.EXPRESSION); + } else { + return this.getToken(LGFileParser.EXPRESSION, i); + } + } + public ESCAPE_CHARACTER(): TerminalNode[]; + public ESCAPE_CHARACTER(i: number): TerminalNode; + public ESCAPE_CHARACTER(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.ESCAPE_CHARACTER); + } else { + return this.getToken(LGFileParser.ESCAPE_CHARACTER, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_normalTemplateString; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterNormalTemplateString) { + listener.enterNormalTemplateString(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitNormalTemplateString) { + listener.exitNormalTemplateString(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitNormalTemplateString) { + return visitor.visitNormalTemplateString(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ErrorTemplateStringContext extends ParserRuleContext { + public INVALID_TOKEN(): TerminalNode[]; + public INVALID_TOKEN(i: number): TerminalNode; + public INVALID_TOKEN(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.INVALID_TOKEN); + } else { + return this.getToken(LGFileParser.INVALID_TOKEN, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_errorTemplateString; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterErrorTemplateString) { + listener.enterErrorTemplateString(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitErrorTemplateString) { + listener.exitErrorTemplateString(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitErrorTemplateString) { + return visitor.visitErrorTemplateString(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class IfElseTemplateBodyContext extends ParserRuleContext { + public ifConditionRule(): IfConditionRuleContext[]; + public ifConditionRule(i: number): IfConditionRuleContext; + public ifConditionRule(i?: number): IfConditionRuleContext | IfConditionRuleContext[] { + if (i === undefined) { + return this.getRuleContexts(IfConditionRuleContext); + } else { + return this.getRuleContext(i, IfConditionRuleContext); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_ifElseTemplateBody; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterIfElseTemplateBody) { + listener.enterIfElseTemplateBody(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitIfElseTemplateBody) { + listener.exitIfElseTemplateBody(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitIfElseTemplateBody) { + return visitor.visitIfElseTemplateBody(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class IfConditionRuleContext extends ParserRuleContext { + public ifCondition(): IfConditionContext { + return this.getRuleContext(0, IfConditionContext); + } + public normalTemplateBody(): NormalTemplateBodyContext | undefined { + return this.tryGetRuleContext(0, NormalTemplateBodyContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_ifConditionRule; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterIfConditionRule) { + listener.enterIfConditionRule(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitIfConditionRule) { + listener.exitIfConditionRule(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitIfConditionRule) { + return visitor.visitIfConditionRule(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class IfConditionContext extends ParserRuleContext { + public DASH(): TerminalNode { return this.getToken(LGFileParser.DASH, 0); } + public IF(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.IF, 0); } + public ELSE(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.ELSE, 0); } + public ELSEIF(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.ELSEIF, 0); } + public WS(): TerminalNode[]; + public WS(i: number): TerminalNode; + public WS(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.WS); + } else { + return this.getToken(LGFileParser.WS, i); + } + } + public TEXT(): TerminalNode[]; + public TEXT(i: number): TerminalNode; + public TEXT(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.TEXT); + } else { + return this.getToken(LGFileParser.TEXT, i); + } + } + public EXPRESSION(): TerminalNode[]; + public EXPRESSION(i: number): TerminalNode; + public EXPRESSION(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.EXPRESSION); + } else { + return this.getToken(LGFileParser.EXPRESSION, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_ifCondition; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterIfCondition) { + listener.enterIfCondition(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitIfCondition) { + listener.exitIfCondition(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitIfCondition) { + return visitor.visitIfCondition(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class SwitchCaseTemplateBodyContext extends ParserRuleContext { + public switchCaseRule(): SwitchCaseRuleContext[]; + public switchCaseRule(i: number): SwitchCaseRuleContext; + public switchCaseRule(i?: number): SwitchCaseRuleContext | SwitchCaseRuleContext[] { + if (i === undefined) { + return this.getRuleContexts(SwitchCaseRuleContext); + } else { + return this.getRuleContext(i, SwitchCaseRuleContext); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_switchCaseTemplateBody; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterSwitchCaseTemplateBody) { + listener.enterSwitchCaseTemplateBody(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitSwitchCaseTemplateBody) { + listener.exitSwitchCaseTemplateBody(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitSwitchCaseTemplateBody) { + return visitor.visitSwitchCaseTemplateBody(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class SwitchCaseRuleContext extends ParserRuleContext { + public switchCaseStat(): SwitchCaseStatContext { + return this.getRuleContext(0, SwitchCaseStatContext); + } + public normalTemplateBody(): NormalTemplateBodyContext | undefined { + return this.tryGetRuleContext(0, NormalTemplateBodyContext); + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_switchCaseRule; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterSwitchCaseRule) { + listener.enterSwitchCaseRule(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitSwitchCaseRule) { + listener.exitSwitchCaseRule(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitSwitchCaseRule) { + return visitor.visitSwitchCaseRule(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class SwitchCaseStatContext extends ParserRuleContext { + public DASH(): TerminalNode { return this.getToken(LGFileParser.DASH, 0); } + public SWITCH(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.SWITCH, 0); } + public CASE(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.CASE, 0); } + public DEFAULT(): TerminalNode | undefined { return this.tryGetToken(LGFileParser.DEFAULT, 0); } + public WS(): TerminalNode[]; + public WS(i: number): TerminalNode; + public WS(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.WS); + } else { + return this.getToken(LGFileParser.WS, i); + } + } + public TEXT(): TerminalNode[]; + public TEXT(i: number): TerminalNode; + public TEXT(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.TEXT); + } else { + return this.getToken(LGFileParser.TEXT, i); + } + } + public EXPRESSION(): TerminalNode[]; + public EXPRESSION(i: number): TerminalNode; + public EXPRESSION(i?: number): TerminalNode | TerminalNode[] { + if (i === undefined) { + return this.getTokens(LGFileParser.EXPRESSION); + } else { + return this.getToken(LGFileParser.EXPRESSION, i); + } + } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_switchCaseStat; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterSwitchCaseStat) { + listener.enterSwitchCaseStat(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitSwitchCaseStat) { + listener.exitSwitchCaseStat(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitSwitchCaseStat) { + return visitor.visitSwitchCaseStat(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ImportDefinitionContext extends ParserRuleContext { + public IMPORT(): TerminalNode { return this.getToken(LGFileParser.IMPORT, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_importDefinition; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterImportDefinition) { + listener.enterImportDefinition(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitImportDefinition) { + listener.exitImportDefinition(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitImportDefinition) { + return visitor.visitImportDefinition(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class OptionsDefinitionContext extends ParserRuleContext { + public OPTIONS(): TerminalNode { return this.getToken(LGFileParser.OPTIONS, 0); } + constructor(parent: ParserRuleContext | undefined, invokingState: number) { + super(parent, invokingState); + } + // @Override + public get ruleIndex(): number { return LGFileParser.RULE_optionsDefinition; } + // @Override + public enterRule(listener: LGFileParserListener): void { + if (listener.enterOptionsDefinition) { + listener.enterOptionsDefinition(this); + } + } + // @Override + public exitRule(listener: LGFileParserListener): void { + if (listener.exitOptionsDefinition) { + listener.exitOptionsDefinition(this); + } + } + // @Override + public accept(visitor: LGFileParserVisitor): Result { + if (visitor.visitOptionsDefinition) { + return visitor.visitOptionsDefinition(this); + } else { + return visitor.visitChildren(this); + } + } +} + + diff --git a/libraries/botbuilder-lg/src/generated/LGFileParserListener.ts b/libraries/botbuilder-lg/src/generated/LGFileParserListener.ts index 808a89a5c9..ee6dd168f8 100644 --- a/libraries/botbuilder-lg/src/generated/LGFileParserListener.ts +++ b/libraries/botbuilder-lg/src/generated/LGFileParserListener.ts @@ -1,41 +1,42 @@ // Generated from ../LGFileParser.g4 by ANTLR 4.6-SNAPSHOT -import { ParseTreeListener } from 'antlr4ts/tree/ParseTreeListener'; - -import { SwitchCaseBodyContext } from './LGFileParser'; -import { NormalBodyContext } from './LGFileParser'; -import { StructuredBodyContext } from './LGFileParser'; -import { IfElseBodyContext } from './LGFileParser'; -import { FileContext } from './LGFileParser'; -import { ParagraphContext } from './LGFileParser'; -import { ErrorTemplateContext } from './LGFileParser'; -import { TemplateDefinitionContext } from './LGFileParser'; -import { TemplateNameLineContext } from './LGFileParser'; -import { ErrorTemplateNameContext } from './LGFileParser'; -import { TemplateNameContext } from './LGFileParser'; -import { ParametersContext } from './LGFileParser'; -import { TemplateBodyContext } from './LGFileParser'; -import { StructuredTemplateBodyContext } from './LGFileParser'; -import { StructuredBodyNameLineContext } from './LGFileParser'; -import { ErrorStructuredNameContext } from './LGFileParser'; -import { StructuredBodyContentLineContext } from './LGFileParser'; -import { ErrorStructureLineContext } from './LGFileParser'; -import { KeyValueStructureLineContext } from './LGFileParser'; -import { KeyValueStructureValueContext } from './LGFileParser'; -import { ObjectStructureLineContext } from './LGFileParser'; -import { StructuredBodyEndLineContext } from './LGFileParser'; -import { NormalTemplateBodyContext } from './LGFileParser'; -import { TemplateStringContext } from './LGFileParser'; -import { NormalTemplateStringContext } from './LGFileParser'; -import { ErrorTemplateStringContext } from './LGFileParser'; -import { IfElseTemplateBodyContext } from './LGFileParser'; -import { IfConditionRuleContext } from './LGFileParser'; -import { IfConditionContext } from './LGFileParser'; -import { SwitchCaseTemplateBodyContext } from './LGFileParser'; -import { SwitchCaseRuleContext } from './LGFileParser'; -import { SwitchCaseStatContext } from './LGFileParser'; -import { ImportDefinitionContext } from './LGFileParser'; -import { OptionsDefinitionContext } from './LGFileParser'; + +import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener"; + +import { SwitchCaseBodyContext } from "./LGFileParser"; +import { NormalBodyContext } from "./LGFileParser"; +import { StructuredBodyContext } from "./LGFileParser"; +import { IfElseBodyContext } from "./LGFileParser"; +import { FileContext } from "./LGFileParser"; +import { ParagraphContext } from "./LGFileParser"; +import { ErrorTemplateContext } from "./LGFileParser"; +import { TemplateDefinitionContext } from "./LGFileParser"; +import { TemplateNameLineContext } from "./LGFileParser"; +import { ErrorTemplateNameContext } from "./LGFileParser"; +import { TemplateNameContext } from "./LGFileParser"; +import { ParametersContext } from "./LGFileParser"; +import { TemplateBodyContext } from "./LGFileParser"; +import { StructuredTemplateBodyContext } from "./LGFileParser"; +import { StructuredBodyNameLineContext } from "./LGFileParser"; +import { ErrorStructuredNameContext } from "./LGFileParser"; +import { StructuredBodyContentLineContext } from "./LGFileParser"; +import { ErrorStructureLineContext } from "./LGFileParser"; +import { KeyValueStructureLineContext } from "./LGFileParser"; +import { KeyValueStructureValueContext } from "./LGFileParser"; +import { ObjectStructureLineContext } from "./LGFileParser"; +import { StructuredBodyEndLineContext } from "./LGFileParser"; +import { NormalTemplateBodyContext } from "./LGFileParser"; +import { TemplateStringContext } from "./LGFileParser"; +import { NormalTemplateStringContext } from "./LGFileParser"; +import { ErrorTemplateStringContext } from "./LGFileParser"; +import { IfElseTemplateBodyContext } from "./LGFileParser"; +import { IfConditionRuleContext } from "./LGFileParser"; +import { IfConditionContext } from "./LGFileParser"; +import { SwitchCaseTemplateBodyContext } from "./LGFileParser"; +import { SwitchCaseRuleContext } from "./LGFileParser"; +import { SwitchCaseStatContext } from "./LGFileParser"; +import { ImportDefinitionContext } from "./LGFileParser"; +import { OptionsDefinitionContext } from "./LGFileParser"; /** @@ -43,386 +44,386 @@ import { OptionsDefinitionContext } from './LGFileParser'; * `LGFileParser`. */ export interface LGFileParserListener extends ParseTreeListener { - /** + /** * Enter a parse tree produced by the `switchCaseBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree */ - enterSwitchCaseBody?: (ctx: SwitchCaseBodyContext) => void; - /** + enterSwitchCaseBody?: (ctx: SwitchCaseBodyContext) => void; + /** * Exit a parse tree produced by the `switchCaseBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree */ - exitSwitchCaseBody?: (ctx: SwitchCaseBodyContext) => void; + exitSwitchCaseBody?: (ctx: SwitchCaseBodyContext) => void; - /** + /** * Enter a parse tree produced by the `normalBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree */ - enterNormalBody?: (ctx: NormalBodyContext) => void; - /** + enterNormalBody?: (ctx: NormalBodyContext) => void; + /** * Exit a parse tree produced by the `normalBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree */ - exitNormalBody?: (ctx: NormalBodyContext) => void; + exitNormalBody?: (ctx: NormalBodyContext) => void; - /** + /** * Enter a parse tree produced by the `structuredBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree */ - enterStructuredBody?: (ctx: StructuredBodyContext) => void; - /** + enterStructuredBody?: (ctx: StructuredBodyContext) => void; + /** * Exit a parse tree produced by the `structuredBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree */ - exitStructuredBody?: (ctx: StructuredBodyContext) => void; + exitStructuredBody?: (ctx: StructuredBodyContext) => void; - /** + /** * Enter a parse tree produced by the `ifElseBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree */ - enterIfElseBody?: (ctx: IfElseBodyContext) => void; - /** + enterIfElseBody?: (ctx: IfElseBodyContext) => void; + /** * Exit a parse tree produced by the `ifElseBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree */ - exitIfElseBody?: (ctx: IfElseBodyContext) => void; + exitIfElseBody?: (ctx: IfElseBodyContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.file`. * @param ctx the parse tree */ - enterFile?: (ctx: FileContext) => void; - /** + enterFile?: (ctx: FileContext) => void; + /** * Exit a parse tree produced by `LGFileParser.file`. * @param ctx the parse tree */ - exitFile?: (ctx: FileContext) => void; + exitFile?: (ctx: FileContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.paragraph`. * @param ctx the parse tree */ - enterParagraph?: (ctx: ParagraphContext) => void; - /** + enterParagraph?: (ctx: ParagraphContext) => void; + /** * Exit a parse tree produced by `LGFileParser.paragraph`. * @param ctx the parse tree */ - exitParagraph?: (ctx: ParagraphContext) => void; + exitParagraph?: (ctx: ParagraphContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.errorTemplate`. * @param ctx the parse tree */ - enterErrorTemplate?: (ctx: ErrorTemplateContext) => void; - /** + enterErrorTemplate?: (ctx: ErrorTemplateContext) => void; + /** * Exit a parse tree produced by `LGFileParser.errorTemplate`. * @param ctx the parse tree */ - exitErrorTemplate?: (ctx: ErrorTemplateContext) => void; + exitErrorTemplate?: (ctx: ErrorTemplateContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.templateDefinition`. * @param ctx the parse tree */ - enterTemplateDefinition?: (ctx: TemplateDefinitionContext) => void; - /** + enterTemplateDefinition?: (ctx: TemplateDefinitionContext) => void; + /** * Exit a parse tree produced by `LGFileParser.templateDefinition`. * @param ctx the parse tree */ - exitTemplateDefinition?: (ctx: TemplateDefinitionContext) => void; + exitTemplateDefinition?: (ctx: TemplateDefinitionContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.templateNameLine`. * @param ctx the parse tree */ - enterTemplateNameLine?: (ctx: TemplateNameLineContext) => void; - /** + enterTemplateNameLine?: (ctx: TemplateNameLineContext) => void; + /** * Exit a parse tree produced by `LGFileParser.templateNameLine`. * @param ctx the parse tree */ - exitTemplateNameLine?: (ctx: TemplateNameLineContext) => void; + exitTemplateNameLine?: (ctx: TemplateNameLineContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.errorTemplateName`. * @param ctx the parse tree */ - enterErrorTemplateName?: (ctx: ErrorTemplateNameContext) => void; - /** + enterErrorTemplateName?: (ctx: ErrorTemplateNameContext) => void; + /** * Exit a parse tree produced by `LGFileParser.errorTemplateName`. * @param ctx the parse tree */ - exitErrorTemplateName?: (ctx: ErrorTemplateNameContext) => void; + exitErrorTemplateName?: (ctx: ErrorTemplateNameContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.templateName`. * @param ctx the parse tree */ - enterTemplateName?: (ctx: TemplateNameContext) => void; - /** + enterTemplateName?: (ctx: TemplateNameContext) => void; + /** * Exit a parse tree produced by `LGFileParser.templateName`. * @param ctx the parse tree */ - exitTemplateName?: (ctx: TemplateNameContext) => void; + exitTemplateName?: (ctx: TemplateNameContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.parameters`. * @param ctx the parse tree */ - enterParameters?: (ctx: ParametersContext) => void; - /** + enterParameters?: (ctx: ParametersContext) => void; + /** * Exit a parse tree produced by `LGFileParser.parameters`. * @param ctx the parse tree */ - exitParameters?: (ctx: ParametersContext) => void; + exitParameters?: (ctx: ParametersContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.templateBody`. * @param ctx the parse tree */ - enterTemplateBody?: (ctx: TemplateBodyContext) => void; - /** + enterTemplateBody?: (ctx: TemplateBodyContext) => void; + /** * Exit a parse tree produced by `LGFileParser.templateBody`. * @param ctx the parse tree */ - exitTemplateBody?: (ctx: TemplateBodyContext) => void; + exitTemplateBody?: (ctx: TemplateBodyContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.structuredTemplateBody`. * @param ctx the parse tree */ - enterStructuredTemplateBody?: (ctx: StructuredTemplateBodyContext) => void; - /** + enterStructuredTemplateBody?: (ctx: StructuredTemplateBodyContext) => void; + /** * Exit a parse tree produced by `LGFileParser.structuredTemplateBody`. * @param ctx the parse tree */ - exitStructuredTemplateBody?: (ctx: StructuredTemplateBodyContext) => void; + exitStructuredTemplateBody?: (ctx: StructuredTemplateBodyContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.structuredBodyNameLine`. * @param ctx the parse tree */ - enterStructuredBodyNameLine?: (ctx: StructuredBodyNameLineContext) => void; - /** + enterStructuredBodyNameLine?: (ctx: StructuredBodyNameLineContext) => void; + /** * Exit a parse tree produced by `LGFileParser.structuredBodyNameLine`. * @param ctx the parse tree */ - exitStructuredBodyNameLine?: (ctx: StructuredBodyNameLineContext) => void; + exitStructuredBodyNameLine?: (ctx: StructuredBodyNameLineContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.errorStructuredName`. * @param ctx the parse tree */ - enterErrorStructuredName?: (ctx: ErrorStructuredNameContext) => void; - /** + enterErrorStructuredName?: (ctx: ErrorStructuredNameContext) => void; + /** * Exit a parse tree produced by `LGFileParser.errorStructuredName`. * @param ctx the parse tree */ - exitErrorStructuredName?: (ctx: ErrorStructuredNameContext) => void; + exitErrorStructuredName?: (ctx: ErrorStructuredNameContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.structuredBodyContentLine`. * @param ctx the parse tree */ - enterStructuredBodyContentLine?: (ctx: StructuredBodyContentLineContext) => void; - /** + enterStructuredBodyContentLine?: (ctx: StructuredBodyContentLineContext) => void; + /** * Exit a parse tree produced by `LGFileParser.structuredBodyContentLine`. * @param ctx the parse tree */ - exitStructuredBodyContentLine?: (ctx: StructuredBodyContentLineContext) => void; + exitStructuredBodyContentLine?: (ctx: StructuredBodyContentLineContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.errorStructureLine`. * @param ctx the parse tree */ - enterErrorStructureLine?: (ctx: ErrorStructureLineContext) => void; - /** + enterErrorStructureLine?: (ctx: ErrorStructureLineContext) => void; + /** * Exit a parse tree produced by `LGFileParser.errorStructureLine`. * @param ctx the parse tree */ - exitErrorStructureLine?: (ctx: ErrorStructureLineContext) => void; + exitErrorStructureLine?: (ctx: ErrorStructureLineContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.keyValueStructureLine`. * @param ctx the parse tree */ - enterKeyValueStructureLine?: (ctx: KeyValueStructureLineContext) => void; - /** + enterKeyValueStructureLine?: (ctx: KeyValueStructureLineContext) => void; + /** * Exit a parse tree produced by `LGFileParser.keyValueStructureLine`. * @param ctx the parse tree */ - exitKeyValueStructureLine?: (ctx: KeyValueStructureLineContext) => void; + exitKeyValueStructureLine?: (ctx: KeyValueStructureLineContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.keyValueStructureValue`. * @param ctx the parse tree */ - enterKeyValueStructureValue?: (ctx: KeyValueStructureValueContext) => void; - /** + enterKeyValueStructureValue?: (ctx: KeyValueStructureValueContext) => void; + /** * Exit a parse tree produced by `LGFileParser.keyValueStructureValue`. * @param ctx the parse tree */ - exitKeyValueStructureValue?: (ctx: KeyValueStructureValueContext) => void; + exitKeyValueStructureValue?: (ctx: KeyValueStructureValueContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.objectStructureLine`. * @param ctx the parse tree */ - enterObjectStructureLine?: (ctx: ObjectStructureLineContext) => void; - /** + enterObjectStructureLine?: (ctx: ObjectStructureLineContext) => void; + /** * Exit a parse tree produced by `LGFileParser.objectStructureLine`. * @param ctx the parse tree */ - exitObjectStructureLine?: (ctx: ObjectStructureLineContext) => void; + exitObjectStructureLine?: (ctx: ObjectStructureLineContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.structuredBodyEndLine`. * @param ctx the parse tree */ - enterStructuredBodyEndLine?: (ctx: StructuredBodyEndLineContext) => void; - /** + enterStructuredBodyEndLine?: (ctx: StructuredBodyEndLineContext) => void; + /** * Exit a parse tree produced by `LGFileParser.structuredBodyEndLine`. * @param ctx the parse tree */ - exitStructuredBodyEndLine?: (ctx: StructuredBodyEndLineContext) => void; + exitStructuredBodyEndLine?: (ctx: StructuredBodyEndLineContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.normalTemplateBody`. * @param ctx the parse tree */ - enterNormalTemplateBody?: (ctx: NormalTemplateBodyContext) => void; - /** + enterNormalTemplateBody?: (ctx: NormalTemplateBodyContext) => void; + /** * Exit a parse tree produced by `LGFileParser.normalTemplateBody`. * @param ctx the parse tree */ - exitNormalTemplateBody?: (ctx: NormalTemplateBodyContext) => void; + exitNormalTemplateBody?: (ctx: NormalTemplateBodyContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.templateString`. * @param ctx the parse tree */ - enterTemplateString?: (ctx: TemplateStringContext) => void; - /** + enterTemplateString?: (ctx: TemplateStringContext) => void; + /** * Exit a parse tree produced by `LGFileParser.templateString`. * @param ctx the parse tree */ - exitTemplateString?: (ctx: TemplateStringContext) => void; + exitTemplateString?: (ctx: TemplateStringContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.normalTemplateString`. * @param ctx the parse tree */ - enterNormalTemplateString?: (ctx: NormalTemplateStringContext) => void; - /** + enterNormalTemplateString?: (ctx: NormalTemplateStringContext) => void; + /** * Exit a parse tree produced by `LGFileParser.normalTemplateString`. * @param ctx the parse tree */ - exitNormalTemplateString?: (ctx: NormalTemplateStringContext) => void; + exitNormalTemplateString?: (ctx: NormalTemplateStringContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.errorTemplateString`. * @param ctx the parse tree */ - enterErrorTemplateString?: (ctx: ErrorTemplateStringContext) => void; - /** + enterErrorTemplateString?: (ctx: ErrorTemplateStringContext) => void; + /** * Exit a parse tree produced by `LGFileParser.errorTemplateString`. * @param ctx the parse tree */ - exitErrorTemplateString?: (ctx: ErrorTemplateStringContext) => void; + exitErrorTemplateString?: (ctx: ErrorTemplateStringContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.ifElseTemplateBody`. * @param ctx the parse tree */ - enterIfElseTemplateBody?: (ctx: IfElseTemplateBodyContext) => void; - /** + enterIfElseTemplateBody?: (ctx: IfElseTemplateBodyContext) => void; + /** * Exit a parse tree produced by `LGFileParser.ifElseTemplateBody`. * @param ctx the parse tree */ - exitIfElseTemplateBody?: (ctx: IfElseTemplateBodyContext) => void; + exitIfElseTemplateBody?: (ctx: IfElseTemplateBodyContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.ifConditionRule`. * @param ctx the parse tree */ - enterIfConditionRule?: (ctx: IfConditionRuleContext) => void; - /** + enterIfConditionRule?: (ctx: IfConditionRuleContext) => void; + /** * Exit a parse tree produced by `LGFileParser.ifConditionRule`. * @param ctx the parse tree */ - exitIfConditionRule?: (ctx: IfConditionRuleContext) => void; + exitIfConditionRule?: (ctx: IfConditionRuleContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.ifCondition`. * @param ctx the parse tree */ - enterIfCondition?: (ctx: IfConditionContext) => void; - /** + enterIfCondition?: (ctx: IfConditionContext) => void; + /** * Exit a parse tree produced by `LGFileParser.ifCondition`. * @param ctx the parse tree */ - exitIfCondition?: (ctx: IfConditionContext) => void; + exitIfCondition?: (ctx: IfConditionContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.switchCaseTemplateBody`. * @param ctx the parse tree */ - enterSwitchCaseTemplateBody?: (ctx: SwitchCaseTemplateBodyContext) => void; - /** + enterSwitchCaseTemplateBody?: (ctx: SwitchCaseTemplateBodyContext) => void; + /** * Exit a parse tree produced by `LGFileParser.switchCaseTemplateBody`. * @param ctx the parse tree */ - exitSwitchCaseTemplateBody?: (ctx: SwitchCaseTemplateBodyContext) => void; + exitSwitchCaseTemplateBody?: (ctx: SwitchCaseTemplateBodyContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.switchCaseRule`. * @param ctx the parse tree */ - enterSwitchCaseRule?: (ctx: SwitchCaseRuleContext) => void; - /** + enterSwitchCaseRule?: (ctx: SwitchCaseRuleContext) => void; + /** * Exit a parse tree produced by `LGFileParser.switchCaseRule`. * @param ctx the parse tree */ - exitSwitchCaseRule?: (ctx: SwitchCaseRuleContext) => void; + exitSwitchCaseRule?: (ctx: SwitchCaseRuleContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.switchCaseStat`. * @param ctx the parse tree */ - enterSwitchCaseStat?: (ctx: SwitchCaseStatContext) => void; - /** + enterSwitchCaseStat?: (ctx: SwitchCaseStatContext) => void; + /** * Exit a parse tree produced by `LGFileParser.switchCaseStat`. * @param ctx the parse tree */ - exitSwitchCaseStat?: (ctx: SwitchCaseStatContext) => void; + exitSwitchCaseStat?: (ctx: SwitchCaseStatContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.importDefinition`. * @param ctx the parse tree */ - enterImportDefinition?: (ctx: ImportDefinitionContext) => void; - /** + enterImportDefinition?: (ctx: ImportDefinitionContext) => void; + /** * Exit a parse tree produced by `LGFileParser.importDefinition`. * @param ctx the parse tree */ - exitImportDefinition?: (ctx: ImportDefinitionContext) => void; + exitImportDefinition?: (ctx: ImportDefinitionContext) => void; - /** + /** * Enter a parse tree produced by `LGFileParser.optionsDefinition`. * @param ctx the parse tree */ - enterOptionsDefinition?: (ctx: OptionsDefinitionContext) => void; - /** + enterOptionsDefinition?: (ctx: OptionsDefinitionContext) => void; + /** * Exit a parse tree produced by `LGFileParser.optionsDefinition`. * @param ctx the parse tree */ - exitOptionsDefinition?: (ctx: OptionsDefinitionContext) => void; + exitOptionsDefinition?: (ctx: OptionsDefinitionContext) => void; } diff --git a/libraries/botbuilder-lg/src/generated/LGFileParserVisitor.ts b/libraries/botbuilder-lg/src/generated/LGFileParserVisitor.ts index bbbedd9d14..a1601593e1 100644 --- a/libraries/botbuilder-lg/src/generated/LGFileParserVisitor.ts +++ b/libraries/botbuilder-lg/src/generated/LGFileParserVisitor.ts @@ -1,41 +1,42 @@ // Generated from ../LGFileParser.g4 by ANTLR 4.6-SNAPSHOT -import { ParseTreeVisitor } from 'antlr4ts/tree/ParseTreeVisitor'; - -import { SwitchCaseBodyContext } from './LGFileParser'; -import { NormalBodyContext } from './LGFileParser'; -import { StructuredBodyContext } from './LGFileParser'; -import { IfElseBodyContext } from './LGFileParser'; -import { FileContext } from './LGFileParser'; -import { ParagraphContext } from './LGFileParser'; -import { ErrorTemplateContext } from './LGFileParser'; -import { TemplateDefinitionContext } from './LGFileParser'; -import { TemplateNameLineContext } from './LGFileParser'; -import { ErrorTemplateNameContext } from './LGFileParser'; -import { TemplateNameContext } from './LGFileParser'; -import { ParametersContext } from './LGFileParser'; -import { TemplateBodyContext } from './LGFileParser'; -import { StructuredTemplateBodyContext } from './LGFileParser'; -import { StructuredBodyNameLineContext } from './LGFileParser'; -import { ErrorStructuredNameContext } from './LGFileParser'; -import { StructuredBodyContentLineContext } from './LGFileParser'; -import { ErrorStructureLineContext } from './LGFileParser'; -import { KeyValueStructureLineContext } from './LGFileParser'; -import { KeyValueStructureValueContext } from './LGFileParser'; -import { ObjectStructureLineContext } from './LGFileParser'; -import { StructuredBodyEndLineContext } from './LGFileParser'; -import { NormalTemplateBodyContext } from './LGFileParser'; -import { TemplateStringContext } from './LGFileParser'; -import { NormalTemplateStringContext } from './LGFileParser'; -import { ErrorTemplateStringContext } from './LGFileParser'; -import { IfElseTemplateBodyContext } from './LGFileParser'; -import { IfConditionRuleContext } from './LGFileParser'; -import { IfConditionContext } from './LGFileParser'; -import { SwitchCaseTemplateBodyContext } from './LGFileParser'; -import { SwitchCaseRuleContext } from './LGFileParser'; -import { SwitchCaseStatContext } from './LGFileParser'; -import { ImportDefinitionContext } from './LGFileParser'; -import { OptionsDefinitionContext } from './LGFileParser'; + +import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor"; + +import { SwitchCaseBodyContext } from "./LGFileParser"; +import { NormalBodyContext } from "./LGFileParser"; +import { StructuredBodyContext } from "./LGFileParser"; +import { IfElseBodyContext } from "./LGFileParser"; +import { FileContext } from "./LGFileParser"; +import { ParagraphContext } from "./LGFileParser"; +import { ErrorTemplateContext } from "./LGFileParser"; +import { TemplateDefinitionContext } from "./LGFileParser"; +import { TemplateNameLineContext } from "./LGFileParser"; +import { ErrorTemplateNameContext } from "./LGFileParser"; +import { TemplateNameContext } from "./LGFileParser"; +import { ParametersContext } from "./LGFileParser"; +import { TemplateBodyContext } from "./LGFileParser"; +import { StructuredTemplateBodyContext } from "./LGFileParser"; +import { StructuredBodyNameLineContext } from "./LGFileParser"; +import { ErrorStructuredNameContext } from "./LGFileParser"; +import { StructuredBodyContentLineContext } from "./LGFileParser"; +import { ErrorStructureLineContext } from "./LGFileParser"; +import { KeyValueStructureLineContext } from "./LGFileParser"; +import { KeyValueStructureValueContext } from "./LGFileParser"; +import { ObjectStructureLineContext } from "./LGFileParser"; +import { StructuredBodyEndLineContext } from "./LGFileParser"; +import { NormalTemplateBodyContext } from "./LGFileParser"; +import { TemplateStringContext } from "./LGFileParser"; +import { NormalTemplateStringContext } from "./LGFileParser"; +import { ErrorTemplateStringContext } from "./LGFileParser"; +import { IfElseTemplateBodyContext } from "./LGFileParser"; +import { IfConditionRuleContext } from "./LGFileParser"; +import { IfConditionContext } from "./LGFileParser"; +import { SwitchCaseTemplateBodyContext } from "./LGFileParser"; +import { SwitchCaseRuleContext } from "./LGFileParser"; +import { SwitchCaseStatContext } from "./LGFileParser"; +import { ImportDefinitionContext } from "./LGFileParser"; +import { OptionsDefinitionContext } from "./LGFileParser"; /** @@ -46,246 +47,245 @@ import { OptionsDefinitionContext } from './LGFileParser'; * operations with no return type. */ export interface LGFileParserVisitor extends ParseTreeVisitor { - /** + /** * Visit a parse tree produced by the `switchCaseBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree * @return the visitor result */ - visitSwitchCaseBody?: (ctx: SwitchCaseBodyContext) => Result; + visitSwitchCaseBody?: (ctx: SwitchCaseBodyContext) => Result; - /** + /** * Visit a parse tree produced by the `normalBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree * @return the visitor result */ - visitNormalBody?: (ctx: NormalBodyContext) => Result; + visitNormalBody?: (ctx: NormalBodyContext) => Result; - /** + /** * Visit a parse tree produced by the `structuredBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree * @return the visitor result */ - visitStructuredBody?: (ctx: StructuredBodyContext) => Result; + visitStructuredBody?: (ctx: StructuredBodyContext) => Result; - /** + /** * Visit a parse tree produced by the `ifElseBody` * labeled alternative in `LGFileParser.templateBody`. * @param ctx the parse tree * @return the visitor result */ - visitIfElseBody?: (ctx: IfElseBodyContext) => Result; + visitIfElseBody?: (ctx: IfElseBodyContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.file`. * @param ctx the parse tree * @return the visitor result */ - visitFile?: (ctx: FileContext) => Result; + visitFile?: (ctx: FileContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.paragraph`. * @param ctx the parse tree * @return the visitor result */ - visitParagraph?: (ctx: ParagraphContext) => Result; + visitParagraph?: (ctx: ParagraphContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.errorTemplate`. * @param ctx the parse tree * @return the visitor result */ - visitErrorTemplate?: (ctx: ErrorTemplateContext) => Result; + visitErrorTemplate?: (ctx: ErrorTemplateContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.templateDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitTemplateDefinition?: (ctx: TemplateDefinitionContext) => Result; + visitTemplateDefinition?: (ctx: TemplateDefinitionContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.templateNameLine`. * @param ctx the parse tree * @return the visitor result */ - visitTemplateNameLine?: (ctx: TemplateNameLineContext) => Result; + visitTemplateNameLine?: (ctx: TemplateNameLineContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.errorTemplateName`. * @param ctx the parse tree * @return the visitor result */ - visitErrorTemplateName?: (ctx: ErrorTemplateNameContext) => Result; + visitErrorTemplateName?: (ctx: ErrorTemplateNameContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.templateName`. * @param ctx the parse tree * @return the visitor result */ - visitTemplateName?: (ctx: TemplateNameContext) => Result; + visitTemplateName?: (ctx: TemplateNameContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.parameters`. * @param ctx the parse tree * @return the visitor result */ - visitParameters?: (ctx: ParametersContext) => Result; + visitParameters?: (ctx: ParametersContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.templateBody`. * @param ctx the parse tree * @return the visitor result */ - visitTemplateBody?: (ctx: TemplateBodyContext) => Result; + visitTemplateBody?: (ctx: TemplateBodyContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.structuredTemplateBody`. * @param ctx the parse tree * @return the visitor result */ - visitStructuredTemplateBody?: (ctx: StructuredTemplateBodyContext) => Result; + visitStructuredTemplateBody?: (ctx: StructuredTemplateBodyContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.structuredBodyNameLine`. * @param ctx the parse tree * @return the visitor result */ - visitStructuredBodyNameLine?: (ctx: StructuredBodyNameLineContext) => Result; + visitStructuredBodyNameLine?: (ctx: StructuredBodyNameLineContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.errorStructuredName`. * @param ctx the parse tree * @return the visitor result */ - visitErrorStructuredName?: (ctx: ErrorStructuredNameContext) => Result; + visitErrorStructuredName?: (ctx: ErrorStructuredNameContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.structuredBodyContentLine`. * @param ctx the parse tree * @return the visitor result */ - visitStructuredBodyContentLine?: (ctx: StructuredBodyContentLineContext) => Result; + visitStructuredBodyContentLine?: (ctx: StructuredBodyContentLineContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.errorStructureLine`. * @param ctx the parse tree * @return the visitor result */ - visitErrorStructureLine?: (ctx: ErrorStructureLineContext) => Result; + visitErrorStructureLine?: (ctx: ErrorStructureLineContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.keyValueStructureLine`. * @param ctx the parse tree * @return the visitor result */ - visitKeyValueStructureLine?: (ctx: KeyValueStructureLineContext) => Result; + visitKeyValueStructureLine?: (ctx: KeyValueStructureLineContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.keyValueStructureValue`. * @param ctx the parse tree * @return the visitor result */ - visitKeyValueStructureValue?: (ctx: KeyValueStructureValueContext) => Result; + visitKeyValueStructureValue?: (ctx: KeyValueStructureValueContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.objectStructureLine`. * @param ctx the parse tree * @return the visitor result */ - visitObjectStructureLine?: (ctx: ObjectStructureLineContext) => Result; + visitObjectStructureLine?: (ctx: ObjectStructureLineContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.structuredBodyEndLine`. * @param ctx the parse tree * @return the visitor result */ - visitStructuredBodyEndLine?: (ctx: StructuredBodyEndLineContext) => Result; + visitStructuredBodyEndLine?: (ctx: StructuredBodyEndLineContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.normalTemplateBody`. * @param ctx the parse tree * @return the visitor result */ - visitNormalTemplateBody?: (ctx: NormalTemplateBodyContext) => Result; + visitNormalTemplateBody?: (ctx: NormalTemplateBodyContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.templateString`. * @param ctx the parse tree * @return the visitor result */ - visitTemplateString?: (ctx: TemplateStringContext) => Result; + visitTemplateString?: (ctx: TemplateStringContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.normalTemplateString`. * @param ctx the parse tree * @return the visitor result */ - visitNormalTemplateString?: (ctx: NormalTemplateStringContext) => Result; + visitNormalTemplateString?: (ctx: NormalTemplateStringContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.errorTemplateString`. * @param ctx the parse tree * @return the visitor result */ - visitErrorTemplateString?: (ctx: ErrorTemplateStringContext) => Result; + visitErrorTemplateString?: (ctx: ErrorTemplateStringContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.ifElseTemplateBody`. * @param ctx the parse tree * @return the visitor result */ - visitIfElseTemplateBody?: (ctx: IfElseTemplateBodyContext) => Result; + visitIfElseTemplateBody?: (ctx: IfElseTemplateBodyContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.ifConditionRule`. * @param ctx the parse tree * @return the visitor result */ - visitIfConditionRule?: (ctx: IfConditionRuleContext) => Result; + visitIfConditionRule?: (ctx: IfConditionRuleContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.ifCondition`. * @param ctx the parse tree * @return the visitor result */ - visitIfCondition?: (ctx: IfConditionContext) => Result; + visitIfCondition?: (ctx: IfConditionContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.switchCaseTemplateBody`. * @param ctx the parse tree * @return the visitor result */ - visitSwitchCaseTemplateBody?: (ctx: SwitchCaseTemplateBodyContext) => Result; + visitSwitchCaseTemplateBody?: (ctx: SwitchCaseTemplateBodyContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.switchCaseRule`. * @param ctx the parse tree * @return the visitor result */ - visitSwitchCaseRule?: (ctx: SwitchCaseRuleContext) => Result; + visitSwitchCaseRule?: (ctx: SwitchCaseRuleContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.switchCaseStat`. * @param ctx the parse tree * @return the visitor result */ - visitSwitchCaseStat?: (ctx: SwitchCaseStatContext) => Result; + visitSwitchCaseStat?: (ctx: SwitchCaseStatContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.importDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitImportDefinition?: (ctx: ImportDefinitionContext) => Result; + visitImportDefinition?: (ctx: ImportDefinitionContext) => Result; - /** + /** * Visit a parse tree produced by `LGFileParser.optionsDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitOptionsDefinition?: (ctx: OptionsDefinitionContext) => Result; + visitOptionsDefinition?: (ctx: OptionsDefinitionContext) => Result; } - diff --git a/libraries/botbuilder-lg/src/importResolver.ts b/libraries/botbuilder-lg/src/importResolver.ts deleted file mode 100644 index 81760c73cc..0000000000 --- a/libraries/botbuilder-lg/src/importResolver.ts +++ /dev/null @@ -1,54 +0,0 @@ - -/** - * @module botbuilder-lg - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ - -import * as fs from 'fs'; -import * as path from 'path'; -/** - * Delegate for resolving resource id of imported lg file. - */ -export declare type ImportResolverDelegate = (source: string, resourceId: string) => { content: string; id: string }; - -/** - * import resolver util - */ -export class ImportResolver { - public static fileResolver: ImportResolverDelegate = (filePath: string, id: string): any => { - // import paths are in resource files which can be executed on multiple OS environments - // Call GetOsPath() to map / & \ in importPath -> OSPath - let importPath: string = ImportResolver.normalizePath(id); - if (!path.isAbsolute(importPath)) { - // get full path for importPath relative to path which is doing the import. - importPath = path.normalize(path.join(path.dirname(filePath), importPath)); - } - - const content: string = fs.readFileSync(importPath, 'utf-8'); - - return { content, id: importPath }; - } - - /// - /// Normalize authored path to os path. - /// - /// - /// path is from authored content which doesn't know what OS it is running on. - /// This method treats / and \ both as seperators regardless of OS, for windows that means / -> \ and for linux/mac \ -> /. - /// This allows author to use ../foo.lg or ..\foo.lg as equivelents for importing. - /// - /// authoredPath. - /// path expressed as OS path. - public static normalizePath(ambiguousPath: string): string { - if (process.platform === 'win32') { - // map linux/mac sep -> windows - return ambiguousPath.replace(/\//g, '\\'); - } else { - // map windows sep -> linux/mac - return ambiguousPath.replace(/\\/g, '/'); - } - } -} diff --git a/libraries/botbuilder-lg/src/index.ts b/libraries/botbuilder-lg/src/index.ts index 7fb2b13056..4a7b019965 100644 --- a/libraries/botbuilder-lg/src/index.ts +++ b/libraries/botbuilder-lg/src/index.ts @@ -5,27 +5,25 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -export * from './lgFile'; +export * from './templates'; export * from './evaluator'; -export * from './lgParser'; +export * from './templatesParser'; export * from './generated'; export * from './staticChecker'; export * from './analyzer'; -export * from './mslgTool'; -export * from './lgTemplate'; +export * from './template'; export * from './diagnostic'; -export * from './lgException'; +export * from './templateException'; export * from './extractor'; -export * from './lgImport'; +export * from './templateImport'; export * from './range'; export * from './position'; export * from './evaluationTarget'; -export * from './activityFactory'; -export * from './activityChecker'; -export * from './lgExtensions'; +export * from './templateExtensions'; export * from './analyzerResult'; -export * from './lgErrors'; +export * from './templateErrors'; export * from './evaluator'; export * from './errorListener'; export * from './customizedMemory'; export * from './expander'; +export * from './multiLanguageLG'; diff --git a/libraries/botbuilder-lg/src/lgExtensions.ts b/libraries/botbuilder-lg/src/lgExtensions.ts deleted file mode 100644 index a4e752f868..0000000000 --- a/libraries/botbuilder-lg/src/lgExtensions.ts +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @module botbuilder-lg - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ - -import * as path from 'path'; -import * as lp from './generated/LGFileParser'; -/** - * Extension methods for LG. - */ -export class LGExtensions { - - /** - * trim expression. ${abc} => abc, ${a == {}} => a == {}. - * @param expression input expression string. - * @returns pure expression string. - */ - public static trimExpression(expression: string): string { - let result = expression.trim(); - if (result.startsWith('$')) { - result = result.substr(1); - } - - result = result.trim(); - - if (result.startsWith('{') && result.endsWith('}')) { - result = result.substr(1, result.length - 2); - } - - return result.trim(); - } - - /// - /// Normalize authored path to os path. - /// - /// - /// path is from authored content which doesn't know what OS it is running on. - /// This method treats / and \ both as seperators regardless of OS, for windows that means / -> \ and for linux/mac \ -> /. - /// This allows author to use ../foo.lg or ..\foo.lg as equivelents for importing. - /// - /// authoredPath. - /// path expressed as OS path. - public static normalizePath(ambiguousPath: string): string { - if (process.platform === 'win32') { - // map linux/mac sep -> windows - return path.normalize(ambiguousPath.replace(/\//g, '\\')); - } else { - // map windows sep -> linux/mac - return path.normalize(ambiguousPath.replace(/\\/g, '/')); - } - } - - /// - /// Get prefix error message from normal template sting context. - /// - /// normal template sting context. - /// prefix error message. - public static getPrefixErrorMessage(context: lp.NormalTemplateStringContext): string - { - let errorPrefix = ''; - if (context.parent && context.parent.parent && context.parent.parent.parent) { - - if (context.parent.parent.parent instanceof lp.IfConditionRuleContext) { - const conditionContext = context.parent.parent.parent; - let tempMsg = ''; - if (conditionContext.ifCondition() && conditionContext.ifCondition().EXPRESSION().length > 0) { - tempMsg = conditionContext.ifCondition().EXPRESSION(0).text; - errorPrefix = `Condition '` + tempMsg + `': `; - } - } else { - if (context.parent.parent.parent instanceof lp.SwitchCaseRuleContext ) - { - const switchCaseContext = context.parent.parent.parent; - var state = switchCaseContext.switchCaseStat(); - if (state && state.DEFAULT()) - { - errorPrefix = `Case 'Default':`; - } - else if (state && state.SWITCH()) - { - let tempMsg = ''; - if (state.EXPRESSION(0)) { - tempMsg = state.EXPRESSION(0).text; - } - errorPrefix = `Switch '${ tempMsg } ':`; - } - else if (state && state.CASE()) - { - let tempMsg = ''; - if (state.EXPRESSION(0)) { - tempMsg = state.EXPRESSION(0).text; - } - errorPrefix = `Case '${ tempMsg }':`; - } - } - } - } - - - return errorPrefix; - } -} \ No newline at end of file diff --git a/libraries/botbuilder-lg/src/lgFile.ts b/libraries/botbuilder-lg/src/lgFile.ts deleted file mode 100644 index 9741e1093a..0000000000 --- a/libraries/botbuilder-lg/src/lgFile.ts +++ /dev/null @@ -1,459 +0,0 @@ -/** - * @module botbuilder-lg - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ - -import { LGTemplate } from './lgTemplate'; -import { LGImport } from './lgImport'; -import { Diagnostic, DiagnosticSeverity } from './diagnostic'; -import { ExpressionEngine } from 'adaptive-expressions'; -import { ImportResolverDelegate } from './lgParser'; -import { Evaluator } from './evaluator'; -import { Expander } from './expander'; -import { Analyzer } from './analyzer'; -import { LGParser } from './lgParser'; -import { AnalyzerResult } from './analyzerResult'; -import { LGErrors } from './lgErrors'; - -/// -/// LG entrance, including properties that LG file has, and evaluate functions. -/// -export class LGFile { - - /// - /// Gets or sets templates that this LG file contains directly. - /// - /// - /// templates that this LG file contains directly. - /// - public templates: LGTemplate[]; - - /// - /// Gets or sets import elements that this LG file contains directly. - /// - /// - /// import elements that this LG file contains directly. - /// - public imports: LGImport[]; - - /// - /// Gets or sets diagnostics. - /// - /// - /// diagnostics. - /// - public diagnostics: Diagnostic[]; - - /// - /// Gets or sets all references that this LG file has from . - /// Notice: reference includs all child imports from the lg file, - /// not only the children belong to this lgfile directly. - /// so, reference count may >= imports count. - /// - /// - /// all references that this LG file has from . - /// - public references: LGFile[]; - - /// - /// Gets or sets LG content. - /// - /// - /// LG content. - /// - public content: string; - - /// - /// Gets or sets id of this LG file. - /// - /// - /// id of this lg source. For file, is full path. - /// - public id: string; - - /// - /// Gets or sets expression parser. - /// - /// - /// expression parser. - /// - public expressionEngine: ExpressionEngine; - - /// - /// Gets or sets delegate for resolving resource id of imported lg file. - /// - /// - /// Delegate for resolving resource id of imported lg file. - /// - public importResolver: ImportResolverDelegate; - - /// - /// Gets or sets lG file options. - /// - /// - /// LG file options. - /// - public options: string[]; - - public constructor(templates: LGTemplate[] = undefined, imports: LGImport[] = undefined, diagnostics: Diagnostic[] = undefined, references: LGFile[] = undefined, - content: string = undefined, id: string = undefined, expressionEngine: ExpressionEngine = undefined, importResolverDelegate: ImportResolverDelegate = undefined, - options: string[] = undefined) { - this.templates = templates? templates : []; - this.imports = imports? imports : []; - this.diagnostics = diagnostics? diagnostics : []; - this.references = references? references : []; - this.content = content? content : ''; - this.id = id? id : ''; - this.expressionEngine = expressionEngine || new ExpressionEngine(); - this.importResolver = importResolverDelegate; - this.options = options? options : []; - } - - /// - /// Gets a value indicating whether lG parser/checker/evaluate strict mode. - /// If strict mode is on, expression would throw exception instead of return - /// null or make the condition failed. - /// - /// - /// A value indicating whether lG parser/checker/evaluate strict mode. - /// If strict mode is on, expression would throw exception instead of return - /// null or make the condition failed. - /// - public strictMode: boolean; - - public updateStrictMode = (): void => {this.strictMode = this.getStrictModeFromOptions(this.options);}; - - - /// - /// Gets get all templates from current lg file and reference lg files. - /// - /// - /// All templates from current lg file and reference lg files. - /// - public get allTemplates(): LGTemplate[] { - let result = this.templates; - this.references.forEach((ref): LGTemplate[] => result = result.concat(ref.templates)); - return result; - } - - /// - /// Gets get all diagnostics from current lg file and reference lg files. - /// - /// - /// All diagnostics from current lg file and reference lg files. - /// - public get allDiagnostics(): Diagnostic[] { - let result = this.diagnostics; - this.references.forEach((ref): Diagnostic[] => result = result.concat(ref.diagnostics)); - return result; - } - - /// - /// Evaluate a template with given name and scope. - /// - /// Template name to be evaluated. - /// The state visible in the evaluation. - /// Evaluate result. - public evaluateTemplate(templateName: string, scope: object = undefined): object { - this.checkErrors(); - - const evaluator = new Evaluator(this.allTemplates, this.expressionEngine, this.strictMode); - return evaluator.evaluateTemplate(templateName, scope); - } - - /// - /// Expand a template with given name and scope. - /// Return all possible responses instead of random one. - /// - /// Template name to be evaluated. - /// The state visible in the evaluation. - /// Expand result. - public expandTemplate(templateName: string, scope: object = undefined): string[] { - this.checkErrors(); - - const expander = new Expander(this.allTemplates, this.expressionEngine, this.strictMode); - return expander.expandTemplate(templateName, scope); - } - - /// - /// (experimental) - /// Analyzer a template to get the static analyzer results including variables and template references. - /// - /// Template name to be evaluated. - /// analyzer result. - public analyzeTemplate(templateName: string): AnalyzerResult { - this.checkErrors(); - - const analyzer = new Analyzer(this.allTemplates, this.expressionEngine); - return analyzer.analyzeTemplate(templateName); - } - - /// - /// Use to evaluate an inline template str. - /// - /// inline string which will be evaluated. - /// scope object or JToken. - /// Evaluate result. - public evaluate(inlineStr: string, scope: any = undefined): any - { - if (inlineStr === undefined) - { - throw Error(`inline string is null.`); - } - - this.checkErrors(); - - // wrap inline string with "# name and -" to align the evaluation process - const fakeTemplateId = this.newGuid(); - const multiLineMark = '```'; - - inlineStr = !(inlineStr.trim().startsWith(multiLineMark) && inlineStr.includes('\n')) - ? `${ multiLineMark }${ inlineStr }${ multiLineMark }` : inlineStr; - - const newContent = `#${ fakeTemplateId } \r\n - ${ inlineStr }`; - - const newLgFile = LGParser.parseTextWithRef(newContent, this); - return newLgFile.evaluateTemplate(fakeTemplateId, scope); - } - - /** - * Update a template and return LG file. - * @param templateName new template name. - * @param parameters new params. - * @param templateBody new template body. - * @returns new lg file. - */ - public updateTemplate(templateName: string, newTemplateName: string, parameters: string[], templateBody: string): LGFile { - const template: LGTemplate = this.templates.find((u: LGTemplate): boolean => u.name === templateName); - if (template === undefined) { - return this; - } - - const templateNameLine: string = this.buildTemplateNameLine(newTemplateName, parameters); - const newTemplateBody: string = this.convertTemplateBody(templateBody); - const content = `${ templateNameLine }\r\n${ newTemplateBody }\r\n`; - - let startLine: number; - let stopLine: number; - - ({startLine, stopLine} = template.getTemplateRange()); - const newContent: string = this.replaceRangeContent(this.content, startLine, stopLine, content); - this.initialize(LGParser.parseText(newContent, this.id, this.importResolver)); - - return this; - } - - /** - * Add a new template and return LG file. - * @param templateName new template name. - * @param parameters new params. - * @param templateBody new template body. - * @returns new lg file. - */ - public addTemplate(templateName: string, parameters: string[], templateBody: string): LGFile { - const template: LGTemplate = this.templates.find((u: LGTemplate): boolean => u.name === templateName); - if (template !== undefined) { - throw new Error(LGErrors.templateExist(templateName)); - } - - const templateNameLine: string = this.buildTemplateNameLine(templateName, parameters); - const newTemplateBody: string = this.convertTemplateBody(templateBody); - const newContent = `${ this.content.trimRight() }\r\n\r\n${ templateNameLine }\r\n${ newTemplateBody }\r\n`; - this.initialize(LGParser.parseText(newContent, this.id, this.importResolver)); - - return this; - } - - /** - * Delete an exist template. - * @param templateName which template should delete. - * @returns return the new lg file. - */ - public deleteTemplate(templateName: string): LGFile { - const template: LGTemplate = this.templates.find((u: LGTemplate): boolean => u.name === templateName); - if (template === undefined) { - return this; - } - - let startLine: number; - let stopLine: number; - - ({startLine, stopLine} = template.getTemplateRange()); - - const newContent: string = this.replaceRangeContent(this.content, startLine, stopLine, undefined); - this.initialize(LGParser.parseText(newContent, this.id, this.importResolver)); - - return this; - } - - public toString(): string { - return this.content; - } - - private replaceRangeContent(originString: string, startLine: number, stopLine: number, replaceString: string): string { - const originList: string[] = originString.split('\n'); - const destList: string[] = []; - - if (startLine < 0 || startLine > stopLine || stopLine >= originList.length) { - throw new Error(`index out of range.`); - } - - destList.push(...this.trimList(originList.slice(0, startLine))); - - if (stopLine < originList.length - 1) { - // insert at the middle of the content - destList.push('\r\n'); - if (replaceString) { - destList.push(replaceString); - destList.push('\r\n'); - } - - destList.push(...this.trimList(originList.slice(stopLine + 1))); - } else { - // insert at the tail of the content - if (replaceString) { - destList.push('\r\n'); - destList.push(replaceString); - } - } - - return this.buildNewLGContent(this.trimList(destList)); - } - - /** - * trim the newlines at the beginning or at the tail of the array - * @param input input array - */ - private trimList(input: string[]): string[] { - if (input === undefined) { - return undefined; - } - - let startIndex = 0; - let endIndex = input.length; - - for(let i = 0; i< input.length; i++) { - if (input[i].trim() !== '') { - startIndex = i; - break; - } - } - - for(let i = input.length - 1; i >= 0; i--) { - if (input[i].trim() !== '') { - endIndex = i + 1; - break; - } - } - - return input.slice(startIndex, endIndex); - } - - private buildNewLGContent(destList: string[]): string { - let result = ''; - for (let i = 0; i < destList.length; i++) { - const currentItem: string = destList[i]; - result = result.concat(currentItem); - if (currentItem.endsWith('\r')) { - result = result.concat('\n'); - } else if (i < destList.length - 1 && !currentItem.endsWith('\r\n')) { - result = result.concat('\r\n'); - } - } - - return result; - } - - private convertTemplateBody(templateBody: string): string { - if (!templateBody) { - return ''; - } - - const replaceList: string[] = templateBody.split('\n'); - const wrappedReplaceList: string[] = replaceList.map((u: string): string => this.wrapTemplateBodyString(u)); - - return wrappedReplaceList.join('\n'); - } - - private wrapTemplateBodyString(replaceItem: string): string { - // tslint:disable-next-line: newline-per-chained-call - const isStartWithHash: boolean = replaceItem.trimLeft().startsWith('#'); - if (isStartWithHash) { - return `- ${ replaceItem.trimLeft() }`; - } else { - return replaceItem; - } - } - - private buildTemplateNameLine(templateName: string, parameters: string[]): string { - if (parameters === undefined || parameters === undefined) { - return `# ${ templateName }`; - } else { - return `# ${ templateName }(${ parameters.join(', ') })`; - } - } - - private initialize(lgfile: LGFile): void { - this.templates = lgfile.templates; - this.imports = lgfile.imports; - this.diagnostics = lgfile.diagnostics; - this.references = lgfile.references; - this.content = lgfile.content; - this.importResolver = lgfile.importResolver; - this.id = lgfile.id; - this.expressionEngine = lgfile.expressionEngine; - } - - private checkErrors(): void { - if (this.allDiagnostics) { - const errors = this.allDiagnostics.filter(u => u.severity === DiagnosticSeverity.Error); - if (errors.length !== 0) { - throw Error(errors.join('\n')); - } - } - } - - private getStrictModeFromOptions(options: string[]): boolean { - let result = false; - if (!options) - { - return result; - } - - const strictModeKey = '@strict'; - for (const option of options) - { - if (option && option.includes('=')) { - const index = option.indexOf('='); - const key = option.substring(0, index).trim(); - const value = option.substring(index + 1).trim().toLowerCase(); - if (key === strictModeKey) - { - if (value === 'true') - { - result = true; - } - else if (value == 'false') - { - result = false; - } - } - } - } - - return result; - } - - private newGuid(): string { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c: any): string => { - const r: number = Math.random() * 16 | 0; - // tslint:disable-next-line: no-bitwise - const v: number = c === 'x' ? r : (r & 0x3 | 0x8); - - return v.toString(16); - }); - } -} \ No newline at end of file diff --git a/libraries/botbuilder-lg/src/mslgTool.ts b/libraries/botbuilder-lg/src/mslgTool.ts deleted file mode 100644 index b5b180c3b6..0000000000 --- a/libraries/botbuilder-lg/src/mslgTool.ts +++ /dev/null @@ -1,142 +0,0 @@ -/** - * @module botbuilder-lg - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ -import { ExpressionEngine } from 'adaptive-expressions'; -import { Analyzer } from './analyzer'; -import { Diagnostic } from './diagnostic'; -import { Expander } from './expander'; -import { Extractor } from './extractor'; -import { LGParser } from './lgParser'; -import { LGTemplate } from './lgTemplate'; -import { Position } from './position'; -import { Range } from './range'; - -// tslint:disable-next-line: completed-docs -/** - * mslg tool, that make some api for mslg cli tool and other debug tools. - */ -export class MSLGTool { - public collationMessages: string[] = []; - public collatedTemplates: Map = new Map(); - public nameCollisions: string[] = []; - - private templates: LGTemplate[]; - private readonly expressionEngine: ExpressionEngine; - - public constructor(expressionEngine?: ExpressionEngine) { - this.expressionEngine = expressionEngine !== undefined ? expressionEngine : new ExpressionEngine(); - } - - /** - * validate a lg file. - * @param lgFileContent lg file content. - * @param id id. - * @returns diagnostics. - */ - public validateFile(lgFileContent: string, id?: string): string[] { - const lgFile = LGParser.parseText(lgFileContent, id); - const diagnostic: Diagnostic[] = lgFile.diagnostics; - if (diagnostic.length !== 0) { - return diagnostic.map((error: Diagnostic): string => error.toString()); - } - - // extract templates - this.templates = lgFile.templates; - if (this.templates && this.templates.length > 0) { - this.runTemplateExtractor(this.templates); - } - - return []; - } - - public getTemplateVariables(templateName: string): string[] { - const analyzer: Analyzer = new Analyzer(this.templates, this.expressionEngine); - - return analyzer.analyzeTemplate(templateName).Variables; - } - - /** - * expand a template. - * @param templateName template name. - * @param scope scope. - */ - public expandTemplate(templateName: string, scope?: any): string[] { - const expander: Expander = new Expander(this.templates, this.expressionEngine); - - return expander.expandTemplate(templateName, scope); - } - - /** - * collate templates. - */ - public collateTemplates(): string { - let result = ''; - if (!this.collationMessages || this.collationMessages.length === 0) { - for (const template of this.collatedTemplates) { - result += '# ' + template[0] + '\n'; - if (Array.isArray(template[1])) { - const templateStrs: string[] = template[1] as string[]; - for (const templateStr of templateStrs) { - if (templateStr.startsWith('-')) { - result += templateStr.slice(0, 1) + ' ' + templateStr.slice(1) + '\n'; - } else { - result += templateStr + '\n'; - break; - } - } - } else if (template[1] instanceof Map) { - for (const condition of (template[1] as Map)) { - const conditionStr: string = condition[0]; - result += '- ' + conditionStr + '\n'; - condition[1].forEach((templateStr: string): any => { - result += ' ' + templateStr.slice(0, 1) + ' ' + templateStr.slice(1) + '\n'; - }); - } - } else { - return undefined; - } - - result += '\n'; - } - } - - return result; - } - - private runTemplateExtractor(lgtemplates: LGTemplate[]): void { - const extractor: Extractor = new Extractor(lgtemplates); - const templates: Map[] = extractor.extract(); - for (const item of templates) { - const template: any = item.entries().next().value; - if (this.collatedTemplates.has(template[0])) { - this.nameCollisions.push(template[0]); - if (this.collatedTemplates.get(template[0]) instanceof Map && template[1] instanceof Map) { - for (const condition of (template[1] as Map)) { - const mergedCondtions: Map = this.collatedTemplates.get(template[0]) as Map; - if (mergedCondtions.has(condition[0])) { - // tslint:disable-next-line: max-line-length - this.collatedTemplates.set(template[0], this.collatedTemplates.get(template[0]).set(condition[0], Array.from(new Set(mergedCondtions.get(condition[0]).concat(condition[1]))))); - } else { - // tslint:disable-next-line: max-line-length - this.collatedTemplates.set(template[0], this.collatedTemplates.get(template[0]).set(condition[0], condition[1])); - } - } - } else if (Array.isArray(this.collatedTemplates.get(template[0])) && Array.isArray(template[1])) { - // tslint:disable-next-line: max-line-length - this.collatedTemplates.set(template[0], Array.from(new Set(this.collatedTemplates.get(template[0]).concat(template[1])))); - } else { - const range: Range = new Range(new Position(0, 0), new Position(0, 0)); - // tslint:disable-next-line: max-line-length - const mergeError: Diagnostic = new Diagnostic(range, `Template ${ template[0] } occurred in both normal and condition templates`); - this.collationMessages.push(mergeError.toString()); - } - } else { - this.collatedTemplates.set(template[0], template[1]); - } - } - } -} diff --git a/libraries/botbuilder-lg/src/multiLanguageLG.ts b/libraries/botbuilder-lg/src/multiLanguageLG.ts new file mode 100644 index 0000000000..51f3336069 --- /dev/null +++ b/libraries/botbuilder-lg/src/multiLanguageLG.ts @@ -0,0 +1,144 @@ +import { Templates } from './templates'; + +/** + * @module botbuilder-lg + */ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + +export class MultiLanguageLG { + public languageFallbackPolicy: {}; + public lgPerLocale: Map; + + private readonly locales = [ + '','aa','aa-dj','aa-er','aa-et','af','af-na','af-za','agq','agq-cm','ak','ak-gh','am','am-et','ar','ar-001', + 'ar-ae','ar-bh','ar-dj','ar-dz','ar-eg','ar-er','ar-il','ar-iq','ar-jo','ar-km','ar-kw','ar-lb','ar-ly','ar-ma', + 'ar-mr','ar-om','ar-ps','ar-qa','ar-sa','ar-sd','ar-so','ar-ss','ar-sy','ar-td','ar-tn','ar-ye','arn','arn-cl', + 'as','as-in','asa','asa-tz','ast','ast-es','az','az-cyrl','az-cyrl-az','az-latn','az-latn-az','ba','ba-ru','bas', + 'bas-cm','be','be-by','bem','bem-zm','bez','bez-tz','bg','bg-bg','bin','bin-ng','bm','bm-latn','bm-latn-ml','bn', + 'bn-bd','bn-in','bo','bo-cn','bo-in','br','br-fr','brx','brx-in','bs','bs-cyrl','bs-cyrl-ba','bs-latn', + 'bs-latn-ba','byn','byn-er','ca','ca-ad','ca-es','ca-es-valencia','ca-fr','ca-it','ce','ce-ru','cgg','cgg-ug', + 'chr','chr-cher','chr-cher-us','co','co-fr','cs','cs-cz','cu','cu-ru','cy','cy-gb','da','da-dk','da-gl','dav', + 'dav-ke','de','de-at','de-be','de-ch','de-de','de-it','de-li','de-lu','dje','dje-ne','dsb','dsb-de','dua', + 'dua-cm','dv','dv-mv','dyo','dyo-sn','dz','dz-bt','ebu','ebu-ke','ee','ee-gh','ee-tg','el','el-cy','el-gr','en', + 'en-001','en-029','en-150','en-ag','en-ai','en-as','en-at','en-au','en-bb','en-be','en-bi','en-bm','en-bs', + 'en-bw','en-bz','en-ca','en-cc','en-ch','en-ck','en-cm','en-cx','en-cy','en-de','en-dk','en-dm','en-er','en-fi', + 'en-fj','en-fk','en-fm','en-gb','en-gd','en-gg','en-gh','en-gi','en-gm','en-gu','en-gy','en-hk','en-id','en-ie', + 'en-il','en-im','en-in','en-io','en-je','en-jm','en-ke','en-ki','en-kn','en-ky','en-lc','en-lr','en-ls','en-mg', + 'en-mh','en-mo','en-mp','en-ms','en-mt','en-mu','en-mw','en-my','en-na','en-nf','en-ng','en-nl','en-nr','en-nu', + 'en-nz','en-pg','en-ph','en-pk','en-pn','en-pr','en-pw','en-rw','en-sb','en-sc','en-sd','en-se','en-sg','en-sh', + 'en-si','en-sl','en-ss','en-sx','en-sz','en-tc','en-tk','en-to','en-tt','en-tv','en-tz','en-ug','en-um','en-us', + 'en-vc','en-vg','en-vi','en-vu','en-ws','en-za','en-zm','en-zw','eo','eo-001','es','es-419','es-ar','es-bo', + 'es-br','es-bz','es-cl','es-co','es-cr','es-cu','es-do','es-ec','es-es','es-gq','es-gt','es-hn','es-mx','es-ni', + 'es-pa','es-pe','es-ph','es-pr','es-py','es-sv','es-us','es-uy','es-ve','et','et-ee','eu','eu-es','ewo','ewo-cm', + 'fa','fa-ir','ff','ff-latn','ff-latn-bf','ff-latn-cm','ff-latn-gh','ff-latn-gm','ff-latn-gn','ff-latn-gw', + 'ff-latn-lr','ff-latn-mr','ff-latn-ne','ff-latn-ng','ff-latn-sl','ff-latn-sn','fi','fi-fi','fil','fil-ph','fo', + 'fo-dk','fo-fo','fr','fr-029','fr-be','fr-bf','fr-bi','fr-bj','fr-bl','fr-ca','fr-cd','fr-cf','fr-cg','fr-ch', + 'fr-ci','fr-cm','fr-dj','fr-dz','fr-fr','fr-ga','fr-gf','fr-gn','fr-gp','fr-gq','fr-ht','fr-km','fr-lu','fr-ma', + 'fr-mc','fr-mf','fr-mg','fr-ml','fr-mq','fr-mr','fr-mu','fr-nc','fr-ne','fr-pf','fr-pm','fr-re','fr-rw','fr-sc', + 'fr-sn','fr-sy','fr-td','fr-tg','fr-tn','fr-vu','fr-wf','fr-yt','fur','fur-it','fy','fy-nl','ga','ga-ie','gd', + 'gd-gb','gl','gl-es','gn','gn-py','gsw','gsw-ch','gsw-fr','gsw-li','gu','gu-in','guz','guz-ke','gv','gv-im','ha', + 'ha-latn','ha-latn-gh','ha-latn-ne','ha-latn-ng','haw','haw-us','he','he-il','hi','hi-in','hr','hr-ba','hr-hr', + 'hsb','hsb-de','hu','hu-hu','hy','hy-am','ia','ia-001','ibb','ibb-ng','id','id-id','ig','ig-ng','ii','ii-cn', + 'is','is-is','it','it-ch','it-it','it-sm','it-va','iu','iu-cans','iu-cans-ca','iu-latn','iu-latn-ca','ja', + 'ja-jp','jgo','jgo-cm','jmc','jmc-tz','jv','jv-java','jv-java-id','jv-latn','jv-latn-id','ka','ka-ge','kab', + 'kab-dz','kam','kam-ke','kde','kde-tz','kea','kea-cv','khq','khq-ml','ki','ki-ke','kk','kk-kz','kkj','kkj-cm', + 'kl','kl-gl','kln','kln-ke','km','km-kh','kn','kn-in','ko','ko-kp','ko-kr','kok','kok-in','kr','kr-latn', + 'kr-latn-ng','ks','ks-arab','ks-arab-in','ks-deva','ks-deva-in','ksb','ksb-tz','ksf','ksf-cm','ksh','ksh-de', + 'ku','ku-arab','ku-arab-iq','ku-arab-ir','kw','kw-gb','ky','ky-kg','la','la-001','lag','lag-tz','lb','lb-lu', + 'lg','lg-ug','lkt','lkt-us','ln','ln-ao','ln-cd','ln-cf','ln-cg','lo','lo-la','lrc','lrc-iq','lrc-ir','lt', + 'lt-lt','lu','lu-cd','luo','luo-ke','luy','luy-ke','lv','lv-lv','mas','mas-ke','mas-tz','mer','mer-ke','mfe', + 'mfe-mu','mg','mg-mg','mgh','mgh-mz','mgo','mgo-cm','mi','mi-nz','mk','mk-mk','ml','ml-in','mn','mn-cyrl', + 'mn-mn','mn-mong','mn-mong-cn','mn-mong-mn','mni','mni-in','moh','moh-ca','mr','mr-in','ms','ms-bn','ms-my', + 'ms-sg','mt','mt-mt','mua','mua-cm','my','my-mm','mzn','mzn-ir','naq','naq-na','nb','nb-no','nb-sj','nd','nd-zw', + 'nds','nds-de','nds-nl','ne','ne-in','ne-np','nl','nl-aw','nl-be','nl-bq','nl-cw','nl-nl','nl-sr','nl-sx','nmg', + 'nmg-cm','nn','nn-no','nnh','nnh-cm','no','nqo','nqo-gn','nr','nr-za','nso','nso-za','nus','nus-ss','nyn', + 'nyn-ug','oc','oc-fr','om','om-et','om-ke','or','or-in','os','os-ge','os-ru','pa','pa-arab','pa-arab-pk', + 'pa-guru','pa-in','pap','pap-029','pl','pl-pl','prg','prg-001','prs','prs-af','ps','ps-af','pt','pt-ao','pt-br', + 'pt-ch','pt-cv','pt-gq','pt-gw','pt-lu','pt-mo','pt-mz','pt-pt','pt-st','pt-tl','quc','quc-latn','quc-latn-gt', + 'quz','quz-bo','quz-ec','quz-pe','rm','rm-ch','rn','rn-bi','ro','ro-md','ro-ro','rof','rof-tz','ru','ru-by', + 'ru-kg','ru-kz','ru-md','ru-ru','ru-ua','rw','rw-rw','rwk','rwk-tz','sa','sa-in','sah','sah-ru','saq','saq-ke', + 'sbp','sbp-tz','sd','sd-arab','sd-arab-pk','sd-deva','sd-deva-in','se','se-fi','se-no','se-se','seh','seh-mz', + 'ses','ses-ml','sg','sg-cf','shi','shi-latn','shi-latn-ma','shi-tfng','shi-tfng-ma','si','si-lk','sk','sk-sk', + 'sl','sl-si','sma','sma-no','sma-se','smj','smj-no','smj-se','smn','smn-fi','sms','sms-fi','sn','sn-latn', + 'sn-latn-zw','so','so-dj','so-et','so-ke','so-so','sq','sq-al','sq-mk','sq-xk','sr','sr-cyrl','sr-cyrl-ba', + 'sr-cyrl-me','sr-cyrl-rs','sr-cyrl-xk','sr-latn','sr-latn-ba','sr-latn-me','sr-latn-rs','sr-latn-xk','ss', + 'ss-sz','ss-za','ssy','ssy-er','st','st-ls','st-za','sv','sv-ax','sv-fi','sv-se','sw','sw-cd','sw-ke','sw-tz', + 'sw-ug','syr','syr-sy','ta','ta-in','ta-lk','ta-my','ta-sg','te','te-in','teo','teo-ke','teo-ug','tg','tg-cyrl', + 'tg-cyrl-tj','th','th-th','ti','ti-er','ti-et','tig','tig-er','tk','tk-tm','tn','tn-bw','tn-za','to','to-to', + 'tr','tr-cy','tr-tr','ts','ts-za','tt','tt-ru','twq','twq-ne','tzm','tzm-arab','tzm-arab-ma','tzm-latn', + 'tzm-latn-dz','tzm-latn-ma','tzm-tfng','tzm-tfng-ma','ug','ug-cn','uk','uk-ua','ur','ur-in','ur-pk','uz', + 'uz-arab','uz-arab-af','uz-cyrl','uz-cyrl-uz','uz-latn','uz-latn-uz','vai','vai-latn','vai-latn-lr','vai-vaii', + 'vai-vaii-lr','ve','ve-za','vi','vi-vn','vo','vo-001','vun','vun-tz','wae','wae-ch','wal','wal-et','wo','wo-sn', + 'xh','xh-za','xog','xog-ug','yav','yav-cm','yi','yi-001','yo','yo-bj','yo-ng','zgh','zgh-tfng','zgh-tfng-ma', + 'zh','zh-cn','zh-hans','zh-hans-hk','zh-hans-mo','zh-hant','zh-hk','zh-mo','zh-sg','zh-tw','zu','zu-za']; + + public constructor(localeLGFiles: Map) { + this.lgPerLocale = new Map(); + this.languageFallbackPolicy = this.getDefaultPolicy(); + + if (!localeLGFiles) { + throw new Error(`input is empty`); + } + + for (const filesPerLocale of localeLGFiles.entries()) { + this.lgPerLocale.set(filesPerLocale[0], Templates.parseFile(filesPerLocale[1])); + } + } + + public generate(template: string, data?: object, locale?: string): any { + if (!template) { + throw new Error('template is empty'); + } + + if (!locale) { + locale = ''; + } + + if (this.lgPerLocale.has(locale)) { + return this.lgPerLocale.get(locale).evaluateText(template, data); + } else { + let locales: string[] = ['']; + if (!(locale in this.languageFallbackPolicy)) { + if (!('' in this.languageFallbackPolicy)) { + throw Error(`No supported language found for ${ locale }`); + } + } else { + locales = this.languageFallbackPolicy[locale]; + } + + for (const fallBackLocale of locales) { + if (this.lgPerLocale.has(fallBackLocale)) { + return this.lgPerLocale.get(fallBackLocale).evaluateText(template, data); + } + } + } + + throw new Error(`No LG responses found for locale: ${ locale }`); + + } + + private getDefaultPolicy(): any { + var result = {}; + for (const locale of this.locales) { + let lang = locale.toLowerCase(); + const fallback: string[] = []; + while (lang) { + fallback.push(lang); + const i = lang.lastIndexOf('-'); + if (i > 0) { + lang = lang.substr(0, i); + } else { + break; + } + } + + fallback.push(''); + result[locale] = fallback; + } + + return result; + } +} diff --git a/libraries/botbuilder-lg/src/staticChecker.ts b/libraries/botbuilder-lg/src/staticChecker.ts index f84a4eb630..f3fad72e35 100644 --- a/libraries/botbuilder-lg/src/staticChecker.ts +++ b/libraries/botbuilder-lg/src/staticChecker.ts @@ -5,62 +5,61 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -// tslint:disable-next-line: no-submodule-imports import { ParserRuleContext } from 'antlr4ts'; import { AbstractParseTreeVisitor, TerminalNode } from 'antlr4ts/tree'; -import { ExpressionEngine, ExpressionParserInterface } from 'adaptive-expressions'; +import { ExpressionParser, ExpressionParserInterface } from 'adaptive-expressions'; import { Diagnostic, DiagnosticSeverity } from './diagnostic'; import { Evaluator } from './evaluator'; import * as lp from './generated/LGFileParser'; import { LGFileParserVisitor } from './generated/LGFileParserVisitor'; -import { LGFile } from './lgFile'; -import { LGErrors } from './lgErrors'; +import { Templates } from './templates'; +import { TemplateErrors } from './templateErrors'; import { Position } from './position'; import { Range } from './range'; -import { LGExtensions } from './lgExtensions'; +import { TemplateExtensions } from './templateExtensions'; -/// -/// LG managed code checker. -/// +/** + * LG managed code checker. + */ export class StaticChecker extends AbstractParseTreeVisitor implements LGFileParserVisitor { - private readonly baseExpressionEngine: ExpressionEngine; - private readonly lgFile: LGFile; + private readonly baseExpressionParser: ExpressionParser; + private readonly templates: Templates; private visitedTemplateNames: string[]; private _expressionParser: ExpressionParserInterface; - public constructor(lgFile: LGFile, expressionEngine: ExpressionEngine = undefined) { + public constructor(templates: Templates) { super(); - this.lgFile = lgFile; - this.baseExpressionEngine = expressionEngine || new ExpressionEngine(); + this.templates = templates; + this.baseExpressionParser = templates.expressionParser || new ExpressionParser(); } // Create a property because we want this to be lazy loaded private get expressionParser(): ExpressionParserInterface { if (this._expressionParser === undefined) { // create an evaluator to leverage it's customized function look up for checking - var evaluator = new Evaluator(this.lgFile.allTemplates, this.baseExpressionEngine); - this._expressionParser = evaluator.expressionEngine; + var evaluator = new Evaluator(this.templates.allTemplates, this.baseExpressionParser); + this._expressionParser = evaluator.expressionParser; } return this._expressionParser; } - /// - /// Return error messages list. - /// - /// report result. + /** + * Return error messages list. + * @returns report result. + */ public check(): Diagnostic[] { this.visitedTemplateNames = []; var result = []; - if (this.lgFile.allTemplates.length === 0) + if (this.templates.allTemplates.length === 0) { - result.push(this.buildLGDiagnostic(LGErrors.noTemplate, DiagnosticSeverity.Warning, undefined, false)); + result.push(this.buildLGDiagnostic(TemplateErrors.noTemplate, DiagnosticSeverity.Warning, undefined, false)); return result; } - this.lgFile.templates.forEach(t => result = result.concat(this.visit(t.parseTree))); + this.templates.toArray().forEach((t): Diagnostic[] => result = result.concat(this.visit(t.parseTree))); return result; } @@ -69,40 +68,28 @@ export class StaticChecker extends AbstractParseTreeVisitor implem var result = []; var templateNameLine = context.templateNameLine(); var errorTemplateName = templateNameLine.errorTemplateName(); - if (errorTemplateName) - { - result.push(this.buildLGDiagnostic(LGErrors.invalidTemplateName, undefined, errorTemplateName, false)); - } - else { + if (errorTemplateName) { + result.push(this.buildLGDiagnostic(TemplateErrors.invalidTemplateName, undefined, errorTemplateName, false)); + } else { var templateName = context.templateNameLine().templateName().text; - if (this.visitedTemplateNames.includes(templateName)) - { - result.push(this.buildLGDiagnostic(LGErrors.duplicatedTemplateInSameTemplate(templateName),undefined, templateNameLine)); - } - else { + if (this.visitedTemplateNames.includes(templateName)) { + result.push(this.buildLGDiagnostic(TemplateErrors.duplicatedTemplateInSameTemplate(templateName),undefined, templateNameLine)); + } else { this.visitedTemplateNames.push(templateName); - for (const reference of this.lgFile.references) - { - var sameTemplates = reference.templates.filter(u => u.name === templateName); - for(const sameTemplate of sameTemplates) - { - result.push(this.buildLGDiagnostic( LGErrors.duplicatedTemplateInDiffTemplate(sameTemplate.name, sameTemplate.source), undefined, templateNameLine)); + for (const reference of this.templates.references) { + var sameTemplates = reference.toArray().filter((u): boolean => u.name === templateName); + for(const sameTemplate of sameTemplates) { + result.push(this.buildLGDiagnostic( TemplateErrors.duplicatedTemplateInDiffTemplate(sameTemplate.name, sameTemplate.source), undefined, templateNameLine)); } } if (result.length > 0) { return result; - } - else - { - if (!context.templateBody()) - { - result.push(this.buildLGDiagnostic(LGErrors.noTemplateBody(templateName), DiagnosticSeverity.Warning, context.templateNameLine())); - } - else { - result = result.concat(this.visit(context.templateBody())); - } + } else if (!context.templateBody()) { + result.push(this.buildLGDiagnostic(TemplateErrors.noTemplateBody(templateName), DiagnosticSeverity.Warning, context.templateNameLine())); + } else { + result = result.concat(this.visit(context.templateBody())); } } } @@ -116,7 +103,7 @@ export class StaticChecker extends AbstractParseTreeVisitor implem const errorTemplateStr: lp.ErrorTemplateStringContext = templateStr.errorTemplateString(); if (errorTemplateStr) { - result.push(this.buildLGDiagnostic(LGErrors.invalidTemplateBody, undefined, errorTemplateStr)); + result.push(this.buildLGDiagnostic(TemplateErrors.invalidTemplateBody, undefined, errorTemplateStr)); } else { result = result.concat(this.visit(templateStr)); } @@ -129,20 +116,20 @@ export class StaticChecker extends AbstractParseTreeVisitor implem let result: Diagnostic[] = []; if (context.structuredBodyNameLine().errorStructuredName() !== undefined) { - result.push(this.buildLGDiagnostic(LGErrors.invalidStrucName, undefined, context.structuredBodyNameLine())); + result.push(this.buildLGDiagnostic(TemplateErrors.invalidStrucName, undefined, context.structuredBodyNameLine())); } if (context.structuredBodyEndLine() === undefined) { - result.push(this.buildLGDiagnostic(LGErrors.missingStrucEnd, undefined, context)); + result.push(this.buildLGDiagnostic(TemplateErrors.missingStrucEnd, undefined, context)); } const bodys = context.structuredBodyContentLine(); if (!bodys || bodys.length === 0) { - result.push(this.buildLGDiagnostic(LGErrors.emptyStrucContent, undefined, context)); + result.push(this.buildLGDiagnostic(TemplateErrors.emptyStrucContent, undefined, context)); } else { for (const body of bodys) { if (body.errorStructureLine() !== undefined) { - result.push(this.buildLGDiagnostic(LGErrors.invalidStrucBody, undefined, body.errorStructureLine())); + result.push(this.buildLGDiagnostic(TemplateErrors.invalidStrucBody, undefined, body.errorStructureLine())); } else if (body.objectStructureLine() !== undefined) { result = result.concat(this.checkExpression(body.objectStructureLine().text, body.objectStructureLine())); } else { @@ -176,41 +163,41 @@ export class StaticChecker extends AbstractParseTreeVisitor implem conditionNode.ELSE(); if (node.text.split(' ').length - 1 > 1) { - result.push(this.buildLGDiagnostic(LGErrors.invalidWhitespaceInCondition, undefined, conditionNode)); + result.push(this.buildLGDiagnostic(TemplateErrors.invalidWhitespaceInCondition, undefined, conditionNode)); } if (idx === 0 && !ifExpr) { - result.push(this.buildLGDiagnostic(LGErrors.notStartWithIfInCondition, DiagnosticSeverity.Warning, conditionNode)); + result.push(this.buildLGDiagnostic(TemplateErrors.notStartWithIfInCondition, DiagnosticSeverity.Warning, conditionNode)); } if (idx > 0 && ifExpr) { - result.push(this.buildLGDiagnostic(LGErrors.multipleIfInCondition, undefined, conditionNode)); + result.push(this.buildLGDiagnostic(TemplateErrors.multipleIfInCondition, undefined, conditionNode)); } if (idx === ifRules.length - 1 && !elseExpr) { - result.push(this.buildLGDiagnostic(LGErrors.notEndWithElseInCondition, DiagnosticSeverity.Warning, conditionNode)); + result.push(this.buildLGDiagnostic(TemplateErrors.notEndWithElseInCondition, DiagnosticSeverity.Warning, conditionNode)); } if (idx > 0 && idx < ifRules.length - 1 && !elseIfExpr) { - result.push(this.buildLGDiagnostic(LGErrors.invalidMiddleInCondition, undefined, conditionNode)); + result.push(this.buildLGDiagnostic(TemplateErrors.invalidMiddleInCondition, undefined, conditionNode)); } if (!elseExpr) { if (ifRule.ifCondition().EXPRESSION().length !== 1) { - result.push(this.buildLGDiagnostic(LGErrors.invalidExpressionInCondition,undefined, conditionNode)); + result.push(this.buildLGDiagnostic(TemplateErrors.invalidExpressionInCondition,undefined, conditionNode)); } else { const errorPrefix = `Condition '` + conditionNode.EXPRESSION(0).text + `': `; result = result.concat(this.checkExpression(ifRule.ifCondition().EXPRESSION(0).text, conditionNode, errorPrefix)); } } else { if (ifRule.ifCondition().EXPRESSION().length !== 0) { - result.push(this.buildLGDiagnostic(LGErrors.extraExpressionInCondition, undefined, conditionNode)); + result.push(this.buildLGDiagnostic(TemplateErrors.extraExpressionInCondition, undefined, conditionNode)); } } if (ifRule.normalTemplateBody() !== undefined) { result = result.concat(this.visit(ifRule.normalTemplateBody())); } else { - result.push(this.buildLGDiagnostic(LGErrors.missingTemplateBodyInCondition, undefined, conditionNode)); + result.push(this.buildLGDiagnostic(TemplateErrors.missingTemplateBodyInCondition, undefined, conditionNode)); } idx = idx + 1; @@ -219,7 +206,6 @@ export class StaticChecker extends AbstractParseTreeVisitor implem return result; } - // tslint:disable-next-line: cyclomatic-complexity public visitSwitchCaseBody(context: lp.SwitchCaseBodyContext): Diagnostic[] { let result: Diagnostic[] = []; const switchCaseNodes: lp.SwitchCaseRuleContext[] = context.switchCaseTemplateBody().switchCaseRule(); @@ -235,48 +221,48 @@ export class StaticChecker extends AbstractParseTreeVisitor implem caseExpr ? switchCaseStat.CASE() : switchCaseStat.DEFAULT(); if (node.text.split(' ').length - 1 > 1) { - result.push(this.buildLGDiagnostic(LGErrors.invalidWhitespaceInSwitchCase, undefined, switchCaseStat)); + result.push(this.buildLGDiagnostic(TemplateErrors.invalidWhitespaceInSwitchCase, undefined, switchCaseStat)); } if (idx === 0 && !switchExpr) { - result.push(this.buildLGDiagnostic(LGErrors.notStartWithSwitchInSwitchCase, undefined, switchCaseStat)); + result.push(this.buildLGDiagnostic(TemplateErrors.notStartWithSwitchInSwitchCase, undefined, switchCaseStat)); } if (idx > 0 && switchExpr) { - result.push(this.buildLGDiagnostic(LGErrors.multipleSwithStatementInSwitchCase, undefined, switchCaseStat)); + result.push(this.buildLGDiagnostic(TemplateErrors.multipleSwithStatementInSwitchCase, undefined, switchCaseStat)); } if (idx > 0 && idx < length - 1 && !caseExpr) { - result.push(this.buildLGDiagnostic(LGErrors.invalidStatementInMiddlerOfSwitchCase, undefined, switchCaseStat)); + result.push(this.buildLGDiagnostic(TemplateErrors.invalidStatementInMiddlerOfSwitchCase, undefined, switchCaseStat)); } if (idx === length - 1 && (caseExpr || defaultExpr)) { if (caseExpr) { - result.push(this.buildLGDiagnostic(LGErrors.notEndWithDefaultInSwitchCase, DiagnosticSeverity.Warning, switchCaseStat)); + result.push(this.buildLGDiagnostic(TemplateErrors.notEndWithDefaultInSwitchCase, DiagnosticSeverity.Warning, switchCaseStat)); } else { if (length === 2) { - result.push(this.buildLGDiagnostic(LGErrors.missingCaseInSwitchCase, DiagnosticSeverity.Warning, switchCaseStat)); + result.push(this.buildLGDiagnostic(TemplateErrors.missingCaseInSwitchCase, DiagnosticSeverity.Warning, switchCaseStat)); } } } if (switchExpr || caseExpr) { if (switchCaseStat.EXPRESSION().length !== 1) { - result.push(this.buildLGDiagnostic(LGErrors.invalidExpressionInSwiathCase, undefined, switchCaseStat)); + result.push(this.buildLGDiagnostic(TemplateErrors.invalidExpressionInSwiathCase, undefined, switchCaseStat)); } else { - let errorPrefix = switchExpr? `Switch` : `Case`; - errorPrefix += ` '` + switchCaseStat.EXPRESSION(0).text + `': `; + let errorPrefix = switchExpr ? 'Switch' : 'Case'; + errorPrefix += ` '${ switchCaseStat.EXPRESSION(0).text }': `; result = result.concat(this.checkExpression(switchCaseStat.EXPRESSION(0).text, switchCaseStat, errorPrefix)); } } else { if (switchCaseStat.EXPRESSION().length !== 0 || switchCaseStat.TEXT().length !== 0) { - result.push(this.buildLGDiagnostic(LGErrors.extraExpressionInSwitchCase, undefined, switchCaseStat)); + result.push(this.buildLGDiagnostic(TemplateErrors.extraExpressionInSwitchCase, undefined, switchCaseStat)); } } if (caseExpr || defaultExpr) { if (iterNode.normalTemplateBody()) { result = result.concat(this.visit(iterNode.normalTemplateBody())); } else { - result.push(this.buildLGDiagnostic(LGErrors.missingTemplateBodyInSwitchCase, undefined, switchCaseStat)); + result.push(this.buildLGDiagnostic(TemplateErrors.missingTemplateBodyInSwitchCase, undefined, switchCaseStat)); } } idx = idx + 1; @@ -286,7 +272,7 @@ export class StaticChecker extends AbstractParseTreeVisitor implem } public visitNormalTemplateString(context: lp.NormalTemplateStringContext): Diagnostic[] { - const prefixErrorMsg = LGExtensions.getPrefixErrorMessage(context); + const prefixErrorMsg = TemplateExtensions.getPrefixErrorMessage(context); let result: Diagnostic[] = []; for (const expression of context.EXPRESSION()) { @@ -297,7 +283,7 @@ export class StaticChecker extends AbstractParseTreeVisitor implem const multiLineSuffix = context.MULTILINE_SUFFIX(); if (multiLinePrefix !== undefined && multiLineSuffix === undefined) { - result.push(this.buildLGDiagnostic(LGErrors.noEndingInMultiline, undefined, context)); + result.push(this.buildLGDiagnostic(TemplateErrors.noEndingInMultiline, undefined, context)); } return result; } @@ -309,14 +295,14 @@ export class StaticChecker extends AbstractParseTreeVisitor implem private checkExpression(exp: string, context: ParserRuleContext, prefix: string = ''): Diagnostic[] { const result: Diagnostic[] = []; if(!exp.endsWith('}')) { - result.push(this.buildLGDiagnostic(LGErrors.noCloseBracket, undefined, context)); + result.push(this.buildLGDiagnostic(TemplateErrors.noCloseBracket, undefined, context)); } else { - exp = LGExtensions.trimExpression(exp); + exp = TemplateExtensions.trimExpression(exp); try { this.expressionParser.parse(exp); } catch (e) { - const errorMsg = prefix + LGErrors.expressionParseError(exp) + e.message; + const errorMsg = prefix + TemplateErrors.expressionParseError(exp) + e.message; result.push(this.buildLGDiagnostic(errorMsg, undefined, context)); return result; @@ -331,8 +317,8 @@ export class StaticChecker extends AbstractParseTreeVisitor implem const stopPosition = context === undefined ? new Position(0, 0) : new Position(context.stop.line, context.stop.charPositionInLine + context.stop.text.length); severity = severity? severity : DiagnosticSeverity.Error; const range = new Range(startPosition, stopPosition); - message = (this.visitedTemplateNames.length > 0 && includeTemplateNameInfo)? `[${ this.visitedTemplateNames.reverse().find(x => true) }]`+ message : message; + message = (this.visitedTemplateNames.length > 0 && includeTemplateNameInfo)? `[${ this.visitedTemplateNames[this.visitedTemplateNames.length - 1] }]`+ message : message; - return new Diagnostic(range, message, severity, this.lgFile.id); + return new Diagnostic(range, message, severity, this.templates.id); } } diff --git a/libraries/botbuilder-lg/src/lgTemplate.ts b/libraries/botbuilder-lg/src/template.ts similarity index 83% rename from libraries/botbuilder-lg/src/lgTemplate.ts rename to libraries/botbuilder-lg/src/template.ts index 3036d2b3c5..d5723050f3 100644 --- a/libraries/botbuilder-lg/src/lgTemplate.ts +++ b/libraries/botbuilder-lg/src/template.ts @@ -5,15 +5,15 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -// tslint:disable-next-line: no-submodule-imports import { TerminalNode } from 'antlr4ts/tree'; -import { ParametersContext, TemplateBodyContext, TemplateDefinitionContext, TemplateNameContext, FileContext} from './generated/LGFileParser'; +import { ParametersContext, TemplateDefinitionContext, TemplateNameContext, FileContext} from './generated/LGFileParser'; +import { TemplateExtensions } from './templateExtensions'; /** * Here is a data model that can easily understanded and used as the context or all kinds of visitors * wether it's evalator, static checker, anayler.. etc */ -export class LGTemplate { +export class Template { /** * Name of the template, what's followed by '#' in a LG file */ @@ -71,7 +71,6 @@ export class LGTemplate { return {startLine, stopLine}; } private readonly extractName = (): string => { - // tslint:disable-next-line: newline-per-chained-call const nameContext: TemplateNameContext = this.parseTree.templateNameLine().templateName(); if (!nameContext || !nameContext.text) { return ''; @@ -81,10 +80,8 @@ export class LGTemplate { } private readonly extractParameters = (): string[] => { - // tslint:disable-next-line: newline-per-chained-call const parameters: ParametersContext = this.parseTree.templateNameLine().parameters(); if (parameters !== undefined) { - // tslint:disable-next-line: newline-per-chained-call return parameters.IDENTIFIER().map((x: TerminalNode): string => x.text); } @@ -101,19 +98,15 @@ export class LGTemplate { } private getRangeContent(originString: string, startLine: number, stopLine: number): string { - const originList: string[] = originString.split('\n'); - if (startLine < 0 || startLine > stopLine || stopLine >= originList.length) { + if (startLine < 0 || startLine > stopLine) { throw new Error(`index out of range.`); } - const destList: string[] = originList.slice(startLine, stopLine + 1); + const originList: string[] = TemplateExtensions.readLine(originString); - let result: string = destList.join('\n'); - if (result.endsWith('\r')) { - result = result.substr(0, result.length - 1); - } + const destList: string[] = originList.slice(startLine, stopLine + 1); - return result; + return destList.join('\r\n'); } public toString(): string { diff --git a/libraries/botbuilder-lg/src/lgErrors.ts b/libraries/botbuilder-lg/src/templateErrors.ts similarity index 99% rename from libraries/botbuilder-lg/src/lgErrors.ts rename to libraries/botbuilder-lg/src/templateErrors.ts index 249dabb1f0..e43f2f587e 100644 --- a/libraries/botbuilder-lg/src/lgErrors.ts +++ b/libraries/botbuilder-lg/src/templateErrors.ts @@ -9,7 +9,7 @@ /** * Centralized LG errors. */ -export class LGErrors { +export class TemplateErrors { public static readonly noTemplate: string = `LG file must have at least one template definition. `; public static readonly invalidTemplateName: string = `Invalid template name. Template name should start with letter/number/_ and can only contains letter/number/_/./-. `; diff --git a/libraries/botbuilder-lg/src/lgException.ts b/libraries/botbuilder-lg/src/templateException.ts similarity index 81% rename from libraries/botbuilder-lg/src/lgException.ts rename to libraries/botbuilder-lg/src/templateException.ts index e4841a67c8..b2debd6e2e 100644 --- a/libraries/botbuilder-lg/src/lgException.ts +++ b/libraries/botbuilder-lg/src/templateException.ts @@ -10,13 +10,13 @@ import { Diagnostic } from './diagnostic'; /** * LG Exception that contains diagnostics. */ -export class LGException extends Error { +export class TemplateException extends Error { private diagnostics: Diagnostic[]; public constructor(m: string, diagnostics: Diagnostic[]) { super(m); this.diagnostics = diagnostics; - Object.setPrototypeOf(this, LGException .prototype); + Object.setPrototypeOf(this, TemplateException .prototype); } /** diff --git a/libraries/botbuilder-lg/src/templateExtensions.ts b/libraries/botbuilder-lg/src/templateExtensions.ts new file mode 100644 index 0000000000..422073d21b --- /dev/null +++ b/libraries/botbuilder-lg/src/templateExtensions.ts @@ -0,0 +1,178 @@ +/** + * @module botbuilder-lg + */ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + +import * as path from 'path'; +import * as lp from './generated/LGFileParser'; +import { TerminalNode } from 'antlr4ts/tree'; +/** + * Extension methods for LG. + */ +export class TemplateExtensions { + + /** + * trim expression. ${abc} => abc, ${a == {}} => a == {}. + * @param expression input expression string. + * @returns pure expression string. + */ + public static trimExpression(expression: string): string { + let result = expression.trim(); + if (result.startsWith('$')) { + result = result.substr(1); + } + + result = result.trim(); + + if (result.startsWith('{') && result.endsWith('}')) { + result = result.substr(1, result.length - 2); + } + + return result.trim(); + } + + /** + * Normalize authored path to os path. + * path is from authored content which doesn't know what OS it is running on. + * This method treats / and \ both as seperators regardless of OS, for windows that means / -> \ and for linux/mac \ -> /. + * This allows author to use ../foo.lg or ..\foo.lg as equivelents for importing. + * @param ambiguousPath authoredPath. + * @returns path expressed as OS path. + */ + public static normalizePath(ambiguousPath: string): string { + if (process.platform === 'win32') { + // map linux/mac sep -> windows + return path.normalize(ambiguousPath.replace(/\//g, '\\')); + } else { + // map windows sep -> linux/mac + return path.normalize(ambiguousPath.replace(/\\/g, '/')); + } + } + + /** + * Get prefix error message from normal template sting context. + * @param context normal template sting context. + * @returns prefix error message. + */ + public static getPrefixErrorMessage(context: lp.NormalTemplateStringContext): string + { + let errorPrefix = ''; + if (context.parent && context.parent.parent && context.parent.parent.parent) { + + if (context.parent.parent.parent instanceof lp.IfConditionRuleContext) { + const conditionContext = context.parent.parent.parent; + let tempMsg = ''; + if (conditionContext.ifCondition() && conditionContext.ifCondition().EXPRESSION().length > 0) { + tempMsg = conditionContext.ifCondition().EXPRESSION(0).text; + errorPrefix = `Condition '` + tempMsg + `': `; + } + } else { + if (context.parent.parent.parent instanceof lp.SwitchCaseRuleContext ) + { + const switchCaseContext = context.parent.parent.parent; + var state = switchCaseContext.switchCaseStat(); + if (state && state.DEFAULT()) + { + errorPrefix = `Case 'Default':`; + } + else if (state && state.SWITCH()) + { + let tempMsg = ''; + if (state.EXPRESSION(0)) { + tempMsg = state.EXPRESSION(0).text; + } + errorPrefix = `Switch '${ tempMsg } ':`; + } + else if (state && state.CASE()) + { + let tempMsg = ''; + if (state.EXPRESSION(0)) { + tempMsg = state.EXPRESSION(0).text; + } + errorPrefix = `Case '${ tempMsg }':`; + } + } + } + } + + + return errorPrefix; + } + + /** + * If a value is pure Expression. + * @param ctx Key value structure value context. + */ + public static isPureExpression(ctx: lp.KeyValueStructureValueContext): {hasExpr: boolean; expression: string | undefined} { + let expression = ctx.text; + let hasExpr = false; + for (const node of ctx.children) { + switch ((node as TerminalNode).symbol.type) { + case (lp.LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY): + return {hasExpr, expression}; + case (lp.LGFileParser.EXPRESSION_IN_STRUCTURE_BODY): + if (hasExpr) { + return {hasExpr: false, expression: expression}; + } + + hasExpr = true; + expression = node.text; + break; + default: + if (node !== undefined && node.text !== '' && node.text !== ' ') { + return {hasExpr: false, expression: expression}; + } + + break; + } + } + + return {hasExpr: hasExpr, expression: expression}; + } + + public static evalEscape(exp: string): string { + const validCharactersDict: any = { + '\\r': '\r', + '\\n': '\n', + '\\t': '\t', + '\\\\': '\\' + }; + + return exp.replace(/\\[^\r\n]?/g, (sub: string): string => { + if (sub in validCharactersDict) { + return validCharactersDict[sub]; + } else if (sub === '\\$') { + return sub.substr(1); + }else { + return sub; + } + }); + } + + /** + * Generate new guid string. + */ + public static newGuid(): string { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c: any): string => { + const r: number = Math.random() * 16 | 0; + const v: number = c === 'x' ? r : (r & 0x3 | 0x8); + + return v.toString(16); + }); + } + + /** + * read line from text. + * @param input text content. + */ + public static readLine(input: string): string[] { + if (!input) { + return []; + } + + return input.replace(/\r\n/g, '\n').split('\n'); + } +} \ No newline at end of file diff --git a/libraries/botbuilder-lg/src/lgImport.ts b/libraries/botbuilder-lg/src/templateImport.ts similarity index 97% rename from libraries/botbuilder-lg/src/lgImport.ts rename to libraries/botbuilder-lg/src/templateImport.ts index 60b1e332cb..fb7073db02 100644 --- a/libraries/botbuilder-lg/src/lgImport.ts +++ b/libraries/botbuilder-lg/src/templateImport.ts @@ -11,7 +11,7 @@ import { ImportDefinitionContext } from './generated/LGFileParser'; /** * Here is a data model that can help users understand and use the LG import definition in LG files easily. */ -export class LGImport { +export class TemplateImport { /** * Description of the import, what's included by '[]' in a lg file. diff --git a/libraries/botbuilder-lg/src/templates.ts b/libraries/botbuilder-lg/src/templates.ts new file mode 100644 index 0000000000..21fb436475 --- /dev/null +++ b/libraries/botbuilder-lg/src/templates.ts @@ -0,0 +1,410 @@ +/** + * @module botbuilder-lg + */ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + +import { Template } from './template'; +import { TemplateImport } from './templateImport'; +import { Diagnostic, DiagnosticSeverity } from './diagnostic'; +import { ExpressionParser } from 'adaptive-expressions'; +import { ImportResolverDelegate } from './templatesParser'; +import { Evaluator } from './evaluator'; +import { Expander } from './expander'; +import { Analyzer } from './analyzer'; +import { TemplatesParser } from './templatesParser'; +import { AnalyzerResult } from './analyzerResult'; +import { TemplateErrors } from './templateErrors'; +import { TemplateExtensions } from './templateExtensions'; + +/** + * LG entrance, including properties that LG file has, and evaluate functions. + */ +export class Templates implements Iterable