diff --git a/.gitmodules b/.gitmodules index d632d67..68aa1bd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,3 @@ [submodule "circom-g4-grammar"] path = circom-g4-grammar - branch = main url = https://github.com/distributed-lab/circom-g4-grammar.git diff --git a/.mocharc.json b/.mocharc.json index 5d915a7..cbde735 100644 --- a/.mocharc.json +++ b/.mocharc.json @@ -1,5 +1,6 @@ { "require": [ "ts-node/register" ], + "file": ["test/setup.ts"], "extensions": ["ts"], "spec": [ "test/**/*.ts" diff --git a/README.md b/README.md index 3702f48..950290b 100644 --- a/README.md +++ b/README.md @@ -45,16 +45,3 @@ if (errorListener.hasErrors()) { throw new ParserError(errorListener.getErrors()); } ``` - -## Reference: Built-in Visitors - -You can use the built-in visitors provided in this package as a reference or starting point for your own implementations: -- [CircomTemplateVisitor](./src/builtin/CircomTemplateVisitor.ts) -- [CircomIncludeVisitor](./src/builtin/CircomIncludeVisitor.ts) -- [CircomMainComponentVisitor](./src/builtin/CircomMainComponentVisitor.ts) -- [CircomExpressionVisitor](./src/builtin/CircomExpressionVisitor.ts) - -## Known limitations - -1. Function calls inside the main component declaration or expressions are not supported. -2. Currently, all 'simple' expressions are evaluated as-is, without accounting for the module. diff --git a/circom-g4-grammar b/circom-g4-grammar index 6440ff4..ca0f30f 160000 --- a/circom-g4-grammar +++ b/circom-g4-grammar @@ -1 +1 @@ -Subproject commit 6440ff47c5627c903e56ba5dcb7a55a73b9f4175 +Subproject commit ca0f30ff89694d7511e6a5cb00e3472fa2b1378f diff --git a/package-lock.json b/package-lock.json index f094192..fc0bef5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@distributedlab/circom-parser", - "version": "0.1.5", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@distributedlab/circom-parser", - "version": "0.1.5", + "version": "0.2.0", "license": "MIT", "dependencies": { "antlr4": "4.13.1-patch-1", diff --git a/package.json b/package.json index c26e9bb..50c2625 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@distributedlab/circom-parser", "description": "Circom circuit parser built with ANTLR4", - "version": "0.1.5", + "version": "0.2.0", "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ diff --git a/src/ExtendedCircomParser.ts b/src/ExtendedCircomParser.ts index fee9efa..ca47ab0 100644 --- a/src/ExtendedCircomParser.ts +++ b/src/ExtendedCircomParser.ts @@ -7,17 +7,21 @@ import { CircomLexer, CircomParser } from "./generated"; import ErrorListener from "./errors/ErrorListener"; export class ExtendedCircomParser extends CircomParser { - lexer: CircomLexer | null = null; + lexer: CircomLexer; parserErrorListener: ErrorListener; - lexerErrorListener: ErrorListener | null = null; + lexerErrorListener: ErrorListener; - constructor(tokens: antlr4.CommonTokenStream) { + constructor(tokens: antlr4.CommonTokenStream, lexer: CircomLexer) { super(tokens); - this.removeErrorListeners(); + this.lexer = lexer; + this.lexerErrorListener = new ErrorListener(); this.parserErrorListener = new ErrorListener(); - this.addErrorListener(this.parserErrorListener); + + this.initErrorListeners(); + + this.buildParseTrees = true; } circuit() { @@ -32,33 +36,25 @@ export class ExtendedCircomParser extends CircomParser { this._interp.predictionMode = antlr4.PredictionMode.LL; this.reset(); - this.parserErrorListener = new ErrorListener(); - this.removeErrorListeners(); - this.addErrorListener(this.parserErrorListener); + this.initErrorListeners(); return super.circuit(); } - setLexer(lexer: CircomLexer) { - this.lexer = lexer; - } - initErrorListeners() { this.parserErrorListener = new ErrorListener(); this.removeErrorListeners(); this.addErrorListener(this.parserErrorListener); - if (this.lexer) { - this.lexerErrorListener = new ErrorListener(); - this.lexer.removeErrorListeners(); - this.lexer.addErrorListener(this.lexerErrorListener); - } + this.lexerErrorListener = new ErrorListener(); + this.lexer.removeErrorListeners(); + this.lexer.addErrorListener(this.lexerErrorListener); } hasAnyErrors(): boolean { return ( this.parserErrorListener.hasErrors() || - (this.lexerErrorListener !== null && this.lexerErrorListener.hasErrors()) + this.lexerErrorListener.hasErrors() ); } @@ -69,11 +65,9 @@ export class ExtendedCircomParser extends CircomParser { errors.push(error); }); - if (this.lexerErrorListener) { - this.lexerErrorListener.getErrors().forEach((error) => { - errors.push(error); - }); - } + this.lexerErrorListener.getErrors().forEach((error) => { + errors.push(error); + }); return errors; } diff --git a/src/ExtendedCircomVisitor.ts b/src/ExtendedCircomVisitor.ts new file mode 100644 index 0000000..72c65b1 --- /dev/null +++ b/src/ExtendedCircomVisitor.ts @@ -0,0 +1,29 @@ +import { ParserRuleContext } from "antlr4"; + +import { CircomVisitor } from "./generated"; + +import { ParserErrorItem } from "./types"; + +export class ExtendedCircomVisitor extends CircomVisitor { + errors: ParserErrorItem[]; + + constructor(public templateIdentifier: string) { + super(); + + this.errors = []; + } + + protected addError(message: string, context: ParserRuleContext) { + this.errors.push({ + templateName: this.templateIdentifier, + message, + line: context.start.line, + column: context.start.column, + context, + }); + } + + public getErrors(): ParserErrorItem[] { + return this.errors; + } +} diff --git a/src/builtin/CircomExpressionVisitor.ts b/src/builtin/CircomExpressionVisitor.ts deleted file mode 100644 index 5528876..0000000 --- a/src/builtin/CircomExpressionVisitor.ts +++ /dev/null @@ -1,243 +0,0 @@ -import { resolveDimensions, validateBigInt } from "./utils"; - -import { - CircomVisitor, - CircomParser, - BinaryExpressionContext, - DotExpressionContext, - ExpressionContext, - PrimaryExpressionContext, - TernaryExpressionContext, - UnaryExpressionContext, -} from "../generated"; -import { BigIntOrNestedArray, Variables } from "../types"; - -import { ParserError } from "../errors/ParserError"; - -// TODO make operations modulo Q -export class CircomExpressionVisitor extends CircomVisitor { - allowId: boolean; - variablesContext: Variables; - - constructor(allowId: boolean, variablesContext: Variables = {}) { - super(); - - this.allowId = allowId; - this.variablesContext = variablesContext; - } - - visitExpression = (ctx: ExpressionContext): BigIntOrNestedArray => { - const expressionValue = this.visit(ctx); - - if (!validateBigInt(expressionValue)) { - throw new ParserError({ - message: "Expression value must be of type bigint or bigint array", - line: ctx.start.line, - column: ctx.start.column, - }); - } - - return expressionValue; - }; - - visitPrimaryExpression = ( - ctx: PrimaryExpressionContext, - ): BigIntOrNestedArray => { - const primary = ctx.primary(); - - if ((primary.identifier() && !this.allowId) || primary.args()) { - throw new ParserError({ - message: - "Identifier usage is not allowed within the main component's parameters", - line: primary.start.line, - column: primary.start.column, - }); - } else if (primary.identifier() && this.allowId) { - // FIXME: Handle nested components - const id = primary.identifier().ID(0).getText(); - - if (!(id in this.variablesContext)) { - throw new ParserError({ - message: `Unresolvable identifier ${id}`, - line: primary.start.line, - column: primary.start.column, - }); - } - - const dimensions = resolveDimensions( - primary.identifier().arrayDimension_list(), - this.variablesContext, - ); - - let identifierValue = this.variablesContext[id].value; - - for (let i = 0; i < dimensions.length; i++) { - if (Array.isArray(identifierValue)) { - identifierValue = identifierValue[Number(dimensions[i])]; - } - } - - if (!validateBigInt(identifierValue)) { - throw new ParserError({ - message: "Unexpected type for identifier value", - line: primary.start.line, - column: primary.start.column, - }); - } - - return identifierValue; - } else if (primary.NUMBER()) { - return BigInt(primary.NUMBER().getText()); - } else if (primary.numSequence()) { - const numSequence: bigint[] = []; - - primary - .numSequence() - .NUMBER_list() - .forEach((number) => { - numSequence.push(BigInt(number.getText())); - }); - - return numSequence; - } else if (primary.expression()) { - return this.visitExpression(primary.expression()); - } else if (primary.expressionList()) { - const expressionsResult: BigIntOrNestedArray = []; - - primary - .expressionList() - .expression_list() - .forEach((expression) => { - expressionsResult.push(this.visitExpression(expression)); - }); - - return expressionsResult; - } else { - throw new ParserError({ - message: "Unsupported expression", - line: primary.start.line, - column: primary.start.column, - }); - } - }; - - visitBinaryExpression = (ctx: BinaryExpressionContext): bigint => { - const left = this.visitExpression(ctx.expression(0)); - const right = this.visitExpression(ctx.expression(1)); - - if (typeof left !== "bigint" || typeof right !== "bigint") { - throw new ParserError({ - message: "Expected bigint operands in binary expression", - line: ctx.start.line, - column: ctx.start.column, - }); - } - - switch (ctx._op.type) { - case CircomParser.MUL: - return left * right; - case CircomParser.DIV: - if (right === BigInt(0)) { - throw new ParserError({ - message: "Division by zero is not allowed", - line: ctx.start.line, - column: ctx.start.column, - }); - } - return left / right; - case CircomParser.ADD: - return left + right; - case CircomParser.SUB: - return left - right; - case CircomParser.MOD: - return left % right; - case CircomParser.POW: - return left ** right; - case CircomParser.SHL: - return left << right; - case CircomParser.SHR: - return left >> right; - case CircomParser.BAND: - return left & right; - case CircomParser.BXOR: - return left ^ right; - case CircomParser.BOR: - return left | right; - case CircomParser.EQ: - return left === right ? 1n : 0n; - case CircomParser.NEQ: - return left !== right ? 1n : 0n; - case CircomParser.LT: - return left < right ? 1n : 0n; - case CircomParser.GT: - return left > right ? 1n : 0n; - case CircomParser.LE: - return left <= right ? 1n : 0n; - case CircomParser.GE: - return left >= right ? 1n : 0n; - case CircomParser.AND: - return left !== 0n && right !== 0n ? 1n : 0n; - case CircomParser.OR: - return left !== 0n || right !== 0n ? 1n : 0n; - default: - throw new ParserError({ - message: "Unsupported binary operator", - line: ctx.start.line, - column: ctx.start.column, - }); - } - }; - - visitUnaryExpression = (ctx: UnaryExpressionContext): bigint => { - const expressionValue = this.visitExpression(ctx.expression()); - - if (typeof expressionValue !== "bigint") { - throw new ParserError({ - message: "Expected bigint operand in unary expression", - line: ctx.start.line, - column: ctx.start.column, - }); - } - - if (ctx._op.type === CircomParser.NOT) { - return expressionValue === 0n ? 1n : 0n; - } else if (ctx._op.type === CircomParser.BNOT) { - return ~expressionValue; - } else { - throw new ParserError({ - message: "Unsupported unary operator", - line: ctx.start.line, - column: ctx.start.column, - }); - } - }; - - visitTernaryExpression = ( - ctx: TernaryExpressionContext, - ): BigIntOrNestedArray => { - const conditionValue = this.visitExpression(ctx.expression(0)); - - if (typeof conditionValue !== "bigint") { - throw new ParserError({ - message: "Expected bigint conditional value in ternary expression", - line: ctx.start.line, - column: ctx.start.column, - }); - } - - if (conditionValue) { - return this.visitExpression(ctx.expression(1)); - } else { - return this.visitExpression(ctx.expression(2)); - } - }; - - visitDotExpression = (ctx: DotExpressionContext) => { - throw new ParserError({ - message: - "Dot expressions are not allowed within the main component's parameters", - line: ctx.start.line, - column: ctx.start.column, - }); - }; -} diff --git a/src/builtin/CircomIncludeVisitor.ts b/src/builtin/CircomIncludeVisitor.ts deleted file mode 100644 index 56616d8..0000000 --- a/src/builtin/CircomIncludeVisitor.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { CircomVisitor, IncludeDeclarationContext } from "../generated"; - -export class CircomIncludeVisitor extends CircomVisitor { - packageNames: string[]; - - constructor() { - super(); - this.packageNames = []; - } - - visitIncludeDeclaration = (ctx: IncludeDeclarationContext) => { - this.packageNames.push(ctx.STRING().getText().slice(1, -1)); - }; -} diff --git a/src/builtin/CircomMainComponentVisitor.ts b/src/builtin/CircomMainComponentVisitor.ts deleted file mode 100644 index 85da3b4..0000000 --- a/src/builtin/CircomMainComponentVisitor.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { CircomExpressionVisitor } from "./CircomExpressionVisitor"; - -import { MainComponent } from "../types"; -import { CircomVisitor, ComponentMainDeclarationContext } from "../generated"; - -export class CircomMainComponentVisitor extends CircomVisitor { - mainComponentInfo: MainComponent; - - constructor() { - super(); - - this.mainComponentInfo = { - templateName: null, - publicInputs: [], - parameters: [], - }; - } - - visitComponentMainDeclaration = (ctx: ComponentMainDeclarationContext) => { - this.mainComponentInfo.templateName = ctx.ID().getText(); - - if ( - ctx.publicInputsList() && - ctx.publicInputsList().args() && - ctx.publicInputsList().args().ID_list() - ) { - ctx - .publicInputsList() - .args() - .ID_list() - .forEach((input) => { - this.mainComponentInfo.publicInputs.push(input.getText()); - }); - } - - if (ctx.expressionList() && ctx.expressionList().expression_list()) { - const expressionVisitor = new CircomExpressionVisitor(false); - - ctx - .expressionList() - .expression_list() - .forEach((expression) => { - this.mainComponentInfo.parameters.push( - expressionVisitor.visitExpression(expression), - ); - }); - } - }; -} diff --git a/src/builtin/CircomPragmaVisitor.ts b/src/builtin/CircomPragmaVisitor.ts deleted file mode 100644 index c89f9e6..0000000 --- a/src/builtin/CircomPragmaVisitor.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { CircomVisitor, PragmaDeclarationContext } from "../generated"; - -export class CircomPragmaVisitor extends CircomVisitor { - isCustom: boolean; - compilerVersion: string; - - constructor() { - super(); - this.isCustom = false; - this.compilerVersion = ""; - } - - visitPragmaDeclaration = (ctx: PragmaDeclarationContext) => { - ctx.CUSTOM_TEMPLATES() ? (this.isCustom = true) : (this.isCustom = false); - - if (ctx.VERSION()) { - this.compilerVersion = ctx.VERSION().getText(); - } - }; -} diff --git a/src/builtin/CircomTemplateVisitor.ts b/src/builtin/CircomTemplateVisitor.ts deleted file mode 100644 index 7285352..0000000 --- a/src/builtin/CircomTemplateVisitor.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { parseIdentifier } from "./utils"; - -import { - CircomVisitor, - SignalDeclarationContext, - TemplateDeclarationContext, -} from "../generated"; -import { Templates } from "../types"; - -import { ParserError } from "../errors/ParserError"; - -export class CircomTemplateVisitor extends CircomVisitor { - templates: Templates; - currentTemplate: string | null; - - constructor() { - super(); - this.templates = {}; - this.currentTemplate = null; - } - - visitTemplateDeclaration = (ctx: TemplateDeclarationContext) => { - if (ctx.ID().getText() in this.templates) { - throw new ParserError({ - message: `Template name ${ctx.ID().getText()} is already in use`, - line: ctx.start.line, - column: ctx.start.column, - }); - } - - this.currentTemplate = ctx.ID().getText(); - - const parameters: string[] = []; - - if (ctx.args() && ctx.args().ID_list()) { - ctx - .args() - .ID_list() - .forEach((arg) => { - parameters.push(arg.getText()); - }); - } - - this.templates[this.currentTemplate] = { - inputs: [], - parameters: parameters, - isCustom: !!ctx.CUSTOM(), - }; - - ctx - .templateBlock() - .templateStmt_list() - .forEach((stmt) => { - this.visitChildren(stmt); - }); - - this.currentTemplate = null; - }; - - visitSignalDeclaration = (ctx: SignalDeclarationContext) => { - if (this.currentTemplate) { - const signalDefinition = ctx.signalDefinition(); - - const identifier = signalDefinition.identifier(); - const signalType = signalDefinition.SIGNAL_TYPE().getText(); - - this.templates[this.currentTemplate].inputs.push({ - ...parseIdentifier(identifier), - type: signalType, - }); - - ctx.identifier_list().forEach((identifier) => { - this.templates[this.currentTemplate!].inputs.push({ - ...parseIdentifier(identifier), - type: signalType, - }); - }); - } - }; -} diff --git a/src/builtin/constants.ts b/src/builtin/constants.ts deleted file mode 100644 index df34c1b..0000000 --- a/src/builtin/constants.ts +++ /dev/null @@ -1,22 +0,0 @@ -export const Q = - 21888242871839275222246405745257275088548364400416034343698204186575808495617n; - -export const ASSIGNMENT_OPERATIONS = { - ADD: "+=", - SUB: "-=", - MUL: "*=", - EXP: "**=", - DIV: "/=", - INT_DIV: "\\=", - MOD: "%=", - LEFT_SHIFT: "<<=", - RIGHT_SHIFT: ">>=", - BIT_AND: "&=", - BIT_OR: "|=", - BIT_XOR: "^=", -}; - -export const POSTFIX_OPERATIONS = { - INCR: "++", - DECR: "--", -}; diff --git a/src/builtin/index.ts b/src/builtin/index.ts deleted file mode 100644 index b528ec2..0000000 --- a/src/builtin/index.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { CircomPragmaVisitor } from "./CircomPragmaVisitor"; -import { CircomIncludeVisitor } from "./CircomIncludeVisitor"; -import { CircomTemplateVisitor } from "./CircomTemplateVisitor"; -import { CircomMainComponentVisitor } from "./CircomMainComponentVisitor"; - -import { - getCircomParser, - MainComponent, - Templates, - ParserError, - PragmaComponent, -} from ".."; - -export function findTemplates(source: string): Templates { - const parser = getCircomParser(source); - - const templateVisitor = new CircomTemplateVisitor(); - - const context = parser.circuit(); - - if (parser.hasAnyErrors()) { - throw new ParserError(parser.getAllErrors()); - } - - templateVisitor.visit(context); - - return templateVisitor.templates; -} - -export function findIncludes(source: string): string[] { - const parser = getCircomParser(source); - - const includeDeclarationVisitor = new CircomIncludeVisitor(); - - const context = parser.circuit(); - - if (parser.hasAnyErrors()) { - throw new ParserError(parser.getAllErrors()); - } - - includeDeclarationVisitor.visit(context); - - return includeDeclarationVisitor.packageNames; -} - -export function findMainComponent(source: string): MainComponent { - const parser = getCircomParser(source); - - const mainComponentVisitor = new CircomMainComponentVisitor(); - - const context = parser.circuit(); - - if (parser.hasAnyErrors()) { - throw new ParserError(parser.getAllErrors()); - } - - mainComponentVisitor.visit(context); - - return mainComponentVisitor.mainComponentInfo; -} - -export function findPragma(source: string): PragmaComponent { - const parser = getCircomParser(source); - - const pragmaVisitor = new CircomPragmaVisitor(); - - const context = parser.circuit(); - - if (parser.hasAnyErrors()) { - throw new ParserError(parser.getAllErrors()); - } - - pragmaVisitor.visit(context); - - return { - isCustom: pragmaVisitor.isCustom, - compilerVersion: pragmaVisitor.compilerVersion, - }; -} - -export * from "./utils"; - -export { - CircomPragmaVisitor, - CircomIncludeVisitor, - CircomTemplateVisitor, - CircomMainComponentVisitor, -}; - -export { CircomExpressionVisitor } from "./CircomExpressionVisitor"; diff --git a/src/builtin/utils.ts b/src/builtin/utils.ts deleted file mode 100644 index 35bf22a..0000000 --- a/src/builtin/utils.ts +++ /dev/null @@ -1,231 +0,0 @@ -import { CircomExpressionVisitor } from "./CircomExpressionVisitor"; - -import { ASSIGNMENT_OPERATIONS, POSTFIX_OPERATIONS } from "./constants"; - -import { BigIntOrNestedArray, LocationCtx, Variables } from "../types"; -import { ArrayDimensionContext, IdentifierContext } from "../generated"; - -import { ParserError } from "../errors/ParserError"; - -export function parseIdentifier(identifier: IdentifierContext) { - const inputDimension: string[] = []; - - identifier.arrayDimension_list().forEach((dimension) => { - inputDimension.push(dimension.getText().slice(1, -1)); - }); - - return { - name: identifier.ID(0).getText(), - dimension: inputDimension, - }; -} - -export function validateBigInt(value: any): value is bigint | bigint[] { - if (typeof value === "bigint") { - return true; - } else if (Array.isArray(value)) { - return value.every((element) => validateBigInt(element)); - } - - return false; -} - -// returns array of resolved indexes as bigints -// e.g. variable[0][2][1] => [0, 2, 1] -export function resolveDimensions( - arrayDimentions: ArrayDimensionContext[], - variablesContext: Variables, -): number[] { - const dimensions: number[] = []; - - arrayDimentions.forEach((dimension: ArrayDimensionContext) => { - if (dimension.expression()) { - const expressionVisitor = new CircomExpressionVisitor( - true, - variablesContext, - ); - const expressionValue = expressionVisitor.visitExpression( - dimension.expression(), - ); - - if (typeof expressionValue !== "bigint") { - throw new ParserError({ - message: `Dimension value type is not allowed to be ${typeof expressionValue}`, - line: dimension.start.line, - column: dimension.start.column, - }); - } - - dimensions.push(Number(expressionValue)); - } - }); - - return dimensions; -} - -export function setValueToArrayElement( - array: BigIntOrNestedArray | null, - indices: number[], - value: BigIntOrNestedArray, -) { - let current: BigIntOrNestedArray = array ? array : []; - - if (Array.isArray(current)) { - for (let i = 0; i < indices.length; i++) { - const index = indices[i]; - - if (i === indices.length - 1) { - current[index] = value; - } else { - if (!Array.isArray(current[index])) { - current[index] = []; - } - current = current[index]; - } - } - } -} - -export function setZeroValueToArrayElements(dimensions: number[]) { - if (dimensions.length === 0) { - return 0n; - } - - const size = dimensions[0]; - - const remainingDimensions = dimensions.slice(1); - const array = new Array(size); - - for (let i = 0; i < size; i++) { - array[i] = setZeroValueToArrayElements(remainingDimensions); - } - - return array; -} - -// level is a current depth in the recursive check -export function validateArrayDimensions( - array: BigIntOrNestedArray, - dimensions: number[], - level = 0, -) { - if (typeof array === "bigint" && !dimensions.length) { - return true; - } - - if (!Array.isArray(array)) { - return false; - } - - if (array.length !== dimensions[level]) { - return false; - } - - if (level < dimensions.length - 1) { - for (let i = 0; i < array.length; i++) { - if (!validateArrayDimensions(array[i], dimensions, level + 1)) { - return false; - } - } - } - - return true; -} - -export function performAssignmentOperation( - assignmentOp: string, - variables: Variables, - variableId: string, - leftValue: bigint, - rightValue: bigint, - ctxLocation: LocationCtx, -) { - // TODO make operations modulo Q - switch (assignmentOp) { - case ASSIGNMENT_OPERATIONS.ADD: { - variables[variableId].value = leftValue + rightValue; - break; - } - case ASSIGNMENT_OPERATIONS.SUB: { - variables[variableId].value = leftValue - rightValue; - break; - } - case ASSIGNMENT_OPERATIONS.MUL: { - variables[variableId].value = leftValue * rightValue; - break; - } - case ASSIGNMENT_OPERATIONS.DIV: { - if (rightValue === 0n) { - throw new ParserError({ - message: "Division by zero is not allowed", - line: ctxLocation.line, - column: ctxLocation.column, - }); - } - variables[variableId].value = leftValue / rightValue; - break; - } - case ASSIGNMENT_OPERATIONS.MOD: { - variables[variableId].value = leftValue % rightValue; - break; - } - case ASSIGNMENT_OPERATIONS.EXP: { - variables[variableId].value = leftValue ** rightValue; - break; - } - case ASSIGNMENT_OPERATIONS.LEFT_SHIFT: { - variables[variableId].value = leftValue << rightValue; - break; - } - case ASSIGNMENT_OPERATIONS.RIGHT_SHIFT: { - variables[variableId].value = leftValue >> rightValue; - break; - } - case ASSIGNMENT_OPERATIONS.BIT_AND: { - variables[variableId].value = leftValue & rightValue; - break; - } - case ASSIGNMENT_OPERATIONS.BIT_OR: { - variables[variableId].value = leftValue | rightValue; - break; - } - case ASSIGNMENT_OPERATIONS.BIT_XOR: { - variables[variableId].value = leftValue ^ rightValue; - break; - } - default: { - throw new ParserError({ - message: "Unsupported assignment operation", - line: ctxLocation.line, - column: ctxLocation.column, - }); - } - } -} - -export function performPostfixOperation( - postfixOp: string, - variables: Variables, - variableId: string, - ctxLocation: LocationCtx, -) { - if (typeof variables[variableId].value !== "bigint") { - throw new ParserError({ - message: "Expected bigint operands in postfix operation", - line: ctxLocation.line, - column: ctxLocation.column, - }); - } - - if (postfixOp === POSTFIX_OPERATIONS.INCR) { - variables[variableId].value += 1n; - } else if (postfixOp === POSTFIX_OPERATIONS.DECR) { - variables[variableId].value -= 1n; - } else { - throw new ParserError({ - message: `Unsupported postfix operator ${postfixOp}`, - line: ctxLocation.line, - column: ctxLocation.column, - }); - } -} diff --git a/src/errors/ErrorListener.ts b/src/errors/ErrorListener.ts index 7de3136..de856ee 100644 --- a/src/errors/ErrorListener.ts +++ b/src/errors/ErrorListener.ts @@ -19,7 +19,13 @@ class ErrorListener extends AntlrErrorListener { column: number, message: string, ): void { - this._errors.push({ message, line, column }); + this._errors.push({ + message, + line, + column, + context: null as any, + templateName: null, + }); } getErrors(): ParserErrorItem[] { diff --git a/src/generated/CircomLexer.ts b/src/generated/CircomLexer.ts index 76fa7c4..7e10ab9 100644 --- a/src/generated/CircomLexer.ts +++ b/src/generated/CircomLexer.ts @@ -21,70 +21,73 @@ export default class CircomLexer extends Lexer { public static readonly INCLUDE = 6; public static readonly CUSTOM = 7; public static readonly PARALLEL = 8; - public static readonly TEMPLATE = 9; - public static readonly FUNCTION = 10; - public static readonly MAIN = 11; - public static readonly PUBLIC = 12; - public static readonly COMPONENT = 13; - public static readonly VAR = 14; - public static readonly SIGNAL = 15; - public static readonly INPUT = 16; - public static readonly OUTPUT = 17; - public static readonly IF = 18; - public static readonly ELSE = 19; - public static readonly FOR = 20; - public static readonly WHILE = 21; - public static readonly DO = 22; - public static readonly LOG = 23; - public static readonly ASSERT = 24; - public static readonly RETURN = 25; - public static readonly LP = 26; - public static readonly RP = 27; - public static readonly LB = 28; - public static readonly RB = 29; - public static readonly LC = 30; - public static readonly RC = 31; - public static readonly SEMICOLON = 32; - public static readonly DOT = 33; - public static readonly COMMA = 34; - public static readonly UNDERSCORE = 35; - public static readonly TERNARY_CONDITION = 36; - public static readonly TERNARY_ALTERNATIVE = 37; - public static readonly EQ_CONSTRAINT = 38; - public static readonly LEFT_CONSTRAINT = 39; - public static readonly RIGHT_CONSTRAINT = 40; - public static readonly SELF_OP = 41; - public static readonly NOT = 42; - public static readonly BNOT = 43; - public static readonly POW = 44; - public static readonly MUL = 45; - public static readonly DIV = 46; - public static readonly QUO = 47; - public static readonly MOD = 48; - public static readonly ADD = 49; - public static readonly SUB = 50; - public static readonly SHL = 51; - public static readonly SHR = 52; - public static readonly BAND = 53; - public static readonly BXOR = 54; - public static readonly BOR = 55; - public static readonly EQ = 56; - public static readonly NEQ = 57; - public static readonly GT = 58; - public static readonly LT = 59; - public static readonly LE = 60; - public static readonly GE = 61; - public static readonly AND = 62; - public static readonly OR = 63; - public static readonly ASSIGNMENT = 64; - public static readonly ASSIGNMENT_WITH_OP = 65; - public static readonly ID = 66; - public static readonly NUMBER = 67; - public static readonly HEX = 68; - public static readonly STRING = 69; - public static readonly COMMENT = 70; - public static readonly LINE_COMMENT = 71; - public static readonly WS = 72; + public static readonly BUS = 9; + public static readonly TEMPLATE = 10; + public static readonly FUNCTION = 11; + public static readonly MAIN = 12; + public static readonly PUBLIC = 13; + public static readonly COMPONENT = 14; + public static readonly VAR = 15; + public static readonly SIGNAL = 16; + public static readonly INPUT = 17; + public static readonly OUTPUT = 18; + public static readonly IF = 19; + public static readonly ELSE = 20; + public static readonly FOR = 21; + public static readonly WHILE = 22; + public static readonly DO = 23; + public static readonly LOG = 24; + public static readonly ASSERT = 25; + public static readonly RETURN = 26; + public static readonly LP = 27; + public static readonly RP = 28; + public static readonly LB = 29; + public static readonly RB = 30; + public static readonly LC = 31; + public static readonly RC = 32; + public static readonly SEMICOLON = 33; + public static readonly DOT = 34; + public static readonly COMMA = 35; + public static readonly UNDERSCORE = 36; + public static readonly TERNARY_CONDITION = 37; + public static readonly TERNARY_ALTERNATIVE = 38; + public static readonly EQ_CONSTRAINT = 39; + public static readonly LEFT_CONSTRAINT = 40; + public static readonly LEFT_ASSIGNMENT = 41; + public static readonly RIGHT_CONSTRAINT = 42; + public static readonly RIGHT_ASSIGNMENT = 43; + public static readonly SELF_OP = 44; + public static readonly NOT = 45; + public static readonly BNOT = 46; + public static readonly POW = 47; + public static readonly MUL = 48; + public static readonly DIV = 49; + public static readonly QUO = 50; + public static readonly MOD = 51; + public static readonly ADD = 52; + public static readonly SUB = 53; + public static readonly SHL = 54; + public static readonly SHR = 55; + public static readonly BAND = 56; + public static readonly BXOR = 57; + public static readonly BOR = 58; + public static readonly EQ = 59; + public static readonly NEQ = 60; + public static readonly GT = 61; + public static readonly LT = 62; + public static readonly LE = 63; + public static readonly GE = 64; + public static readonly AND = 65; + public static readonly OR = 66; + public static readonly ASSIGNMENT = 67; + public static readonly ASSIGNMENT_WITH_OP = 68; + public static readonly ID = 69; + public static readonly NUMBER = 70; + public static readonly HEX = 71; + public static readonly STRING = 72; + public static readonly COMMENT = 73; + public static readonly LINE_COMMENT = 74; + public static readonly WS = 75; public static readonly EOF = Token.EOF; public static readonly channelNames: string[] = [ @@ -101,6 +104,7 @@ export default class CircomLexer extends Lexer { "'include'", "'custom'", "'parallel'", + "'bus'", "'template'", "'function'", "'main'", @@ -131,8 +135,10 @@ export default class CircomLexer extends Lexer { "'?'", "':'", "'==='", - null, - null, + "'<=='", + "'<--'", + "'==>'", + "'-->'", null, "'!'", "'~'", @@ -168,6 +174,7 @@ export default class CircomLexer extends Lexer { "INCLUDE", "CUSTOM", "PARALLEL", + "BUS", "TEMPLATE", "FUNCTION", "MAIN", @@ -199,7 +206,9 @@ export default class CircomLexer extends Lexer { "TERNARY_ALTERNATIVE", "EQ_CONSTRAINT", "LEFT_CONSTRAINT", + "LEFT_ASSIGNMENT", "RIGHT_CONSTRAINT", + "RIGHT_ASSIGNMENT", "SELF_OP", "NOT", "BNOT", @@ -244,6 +253,7 @@ export default class CircomLexer extends Lexer { "INCLUDE", "CUSTOM", "PARALLEL", + "BUS", "TEMPLATE", "FUNCTION", "MAIN", @@ -275,7 +285,9 @@ export default class CircomLexer extends Lexer { "TERNARY_ALTERNATIVE", "EQ_CONSTRAINT", "LEFT_CONSTRAINT", + "LEFT_ASSIGNMENT", "RIGHT_CONSTRAINT", + "RIGHT_ASSIGNMENT", "SELF_OP", "NOT", "BNOT", @@ -352,7 +364,7 @@ export default class CircomLexer extends Lexer { } public static readonly _serializedATN: number[] = [ - 4, 0, 72, 540, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, + 4, 0, 75, 550, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, @@ -366,54 +378,55 @@ export default class CircomLexer extends Lexer { 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, - 76, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 3, 1, 164, 8, 1, 1, 2, - 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, - 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, - 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, - 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, - 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, - 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, - 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, - 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, - 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, - 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, - 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, - 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 22, 1, - 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 24, 1, - 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 26, 1, 26, 1, 27, 1, - 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 30, 1, 30, 1, 31, 1, 31, 1, 32, 1, 32, 1, - 33, 1, 33, 1, 34, 1, 34, 1, 35, 1, 35, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, - 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 358, 8, 38, 1, 39, 1, - 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 366, 8, 39, 1, 40, 1, 40, 1, 40, 1, - 40, 3, 40, 372, 8, 40, 1, 41, 1, 41, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, - 44, 1, 44, 1, 45, 1, 45, 1, 46, 1, 46, 1, 47, 1, 47, 1, 48, 1, 48, 1, 49, 1, - 49, 1, 50, 1, 50, 1, 50, 1, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 53, 1, 53, 1, - 54, 1, 54, 1, 55, 1, 55, 1, 55, 1, 56, 1, 56, 1, 56, 1, 57, 1, 57, 1, 58, 1, - 58, 1, 59, 1, 59, 1, 59, 1, 60, 1, 60, 1, 60, 1, 61, 1, 61, 1, 61, 1, 62, 1, - 62, 1, 62, 1, 63, 1, 63, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, - 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, - 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 3, 64, 456, 8, - 64, 1, 65, 5, 65, 459, 8, 65, 10, 65, 12, 65, 462, 9, 65, 1, 65, 1, 65, 1, - 65, 1, 65, 5, 65, 468, 8, 65, 10, 65, 12, 65, 471, 9, 65, 1, 66, 1, 66, 1, - 67, 1, 67, 1, 68, 4, 68, 478, 8, 68, 11, 68, 12, 68, 479, 1, 68, 3, 68, 483, - 8, 68, 1, 69, 1, 69, 1, 70, 1, 70, 1, 70, 4, 70, 490, 8, 70, 11, 70, 12, 70, - 491, 1, 71, 1, 71, 1, 72, 1, 72, 1, 72, 5, 72, 499, 8, 72, 10, 72, 12, 72, - 502, 9, 72, 1, 72, 1, 72, 1, 73, 1, 73, 1, 73, 1, 74, 1, 74, 1, 74, 1, 74, - 5, 74, 513, 8, 74, 10, 74, 12, 74, 516, 9, 74, 1, 74, 1, 74, 1, 74, 1, 74, - 1, 74, 1, 75, 1, 75, 1, 75, 1, 75, 5, 75, 527, 8, 75, 10, 75, 12, 75, 530, - 9, 75, 1, 75, 1, 75, 1, 76, 4, 76, 535, 8, 76, 11, 76, 12, 76, 536, 1, 76, - 1, 76, 2, 500, 514, 0, 77, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, - 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, - 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, - 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, - 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, 45, 91, - 46, 93, 47, 95, 48, 97, 49, 99, 50, 101, 51, 103, 52, 105, 53, 107, 54, 109, - 55, 111, 56, 113, 57, 115, 58, 117, 59, 119, 60, 121, 61, 123, 62, 125, 63, - 127, 64, 129, 65, 131, 66, 133, 0, 135, 0, 137, 67, 139, 0, 141, 68, 143, 0, - 145, 69, 147, 0, 149, 70, 151, 71, 153, 72, 1, 0, 7, 3, 0, 65, 90, 97, 122, - 128, 255, 2, 0, 36, 36, 95, 95, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, + 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 1, 1, 1, 3, 1, 170, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, + 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, + 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, + 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, + 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, + 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, + 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, + 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, + 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, + 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, + 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 1, + 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, + 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, + 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, + 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, + 29, 1, 29, 1, 30, 1, 30, 1, 31, 1, 31, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 1, + 34, 1, 35, 1, 35, 1, 36, 1, 36, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, + 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, + 41, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 43, 3, 43, 382, 8, + 43, 1, 44, 1, 44, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 48, 1, + 48, 1, 49, 1, 49, 1, 50, 1, 50, 1, 51, 1, 51, 1, 52, 1, 52, 1, 53, 1, 53, 1, + 53, 1, 54, 1, 54, 1, 54, 1, 55, 1, 55, 1, 56, 1, 56, 1, 57, 1, 57, 1, 58, 1, + 58, 1, 58, 1, 59, 1, 59, 1, 59, 1, 60, 1, 60, 1, 61, 1, 61, 1, 62, 1, 62, 1, + 62, 1, 63, 1, 63, 1, 63, 1, 64, 1, 64, 1, 64, 1, 65, 1, 65, 1, 65, 1, 66, 1, + 66, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, + 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, + 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 3, 67, 466, 8, 67, 1, 68, 5, 68, 469, + 8, 68, 10, 68, 12, 68, 472, 9, 68, 1, 68, 1, 68, 1, 68, 1, 68, 5, 68, 478, + 8, 68, 10, 68, 12, 68, 481, 9, 68, 1, 69, 1, 69, 1, 70, 1, 70, 1, 71, 4, 71, + 488, 8, 71, 11, 71, 12, 71, 489, 1, 71, 3, 71, 493, 8, 71, 1, 72, 1, 72, 1, + 73, 1, 73, 1, 73, 4, 73, 500, 8, 73, 11, 73, 12, 73, 501, 1, 74, 1, 74, 1, + 75, 1, 75, 1, 75, 5, 75, 509, 8, 75, 10, 75, 12, 75, 512, 9, 75, 1, 75, 1, + 75, 1, 76, 1, 76, 1, 76, 1, 77, 1, 77, 1, 77, 1, 77, 5, 77, 523, 8, 77, 10, + 77, 12, 77, 526, 9, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 78, 1, 78, 1, + 78, 1, 78, 5, 78, 537, 8, 78, 10, 78, 12, 78, 540, 9, 78, 1, 78, 1, 78, 1, + 79, 4, 79, 545, 8, 79, 11, 79, 12, 79, 546, 1, 79, 1, 79, 2, 510, 524, 0, + 80, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, + 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, + 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, + 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 39, + 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, 45, 91, 46, 93, 47, 95, 48, 97, + 49, 99, 50, 101, 51, 103, 52, 105, 53, 107, 54, 109, 55, 111, 56, 113, 57, + 115, 58, 117, 59, 119, 60, 121, 61, 123, 62, 125, 63, 127, 64, 129, 65, 131, + 66, 133, 67, 135, 68, 137, 69, 139, 0, 141, 0, 143, 70, 145, 0, 147, 71, + 149, 0, 151, 72, 153, 0, 155, 73, 157, 74, 159, 75, 1, 0, 7, 2, 0, 65, 90, + 97, 122, 2, 0, 36, 36, 95, 95, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 7, 0, 34, 34, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 2, 0, - 10, 10, 13, 13, 3, 0, 9, 10, 12, 13, 32, 32, 561, 0, 1, 1, 0, 0, 0, 0, 3, 1, + 10, 10, 13, 13, 3, 0, 9, 10, 12, 13, 32, 32, 569, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, @@ -430,155 +443,158 @@ export default class CircomLexer extends Lexer { 0, 0, 0, 0, 109, 1, 0, 0, 0, 0, 111, 1, 0, 0, 0, 0, 113, 1, 0, 0, 0, 0, 115, 1, 0, 0, 0, 0, 117, 1, 0, 0, 0, 0, 119, 1, 0, 0, 0, 0, 121, 1, 0, 0, 0, 0, 123, 1, 0, 0, 0, 0, 125, 1, 0, 0, 0, 0, 127, 1, 0, 0, 0, 0, 129, 1, 0, 0, 0, - 0, 131, 1, 0, 0, 0, 0, 137, 1, 0, 0, 0, 0, 141, 1, 0, 0, 0, 0, 145, 1, 0, 0, - 0, 0, 149, 1, 0, 0, 0, 0, 151, 1, 0, 0, 0, 0, 153, 1, 0, 0, 0, 1, 155, 1, 0, - 0, 0, 3, 163, 1, 0, 0, 0, 5, 165, 1, 0, 0, 0, 7, 172, 1, 0, 0, 0, 9, 179, 1, - 0, 0, 0, 11, 196, 1, 0, 0, 0, 13, 204, 1, 0, 0, 0, 15, 211, 1, 0, 0, 0, 17, - 220, 1, 0, 0, 0, 19, 229, 1, 0, 0, 0, 21, 238, 1, 0, 0, 0, 23, 243, 1, 0, 0, - 0, 25, 250, 1, 0, 0, 0, 27, 260, 1, 0, 0, 0, 29, 264, 1, 0, 0, 0, 31, 271, - 1, 0, 0, 0, 33, 277, 1, 0, 0, 0, 35, 284, 1, 0, 0, 0, 37, 287, 1, 0, 0, 0, - 39, 292, 1, 0, 0, 0, 41, 296, 1, 0, 0, 0, 43, 302, 1, 0, 0, 0, 45, 305, 1, - 0, 0, 0, 47, 309, 1, 0, 0, 0, 49, 316, 1, 0, 0, 0, 51, 323, 1, 0, 0, 0, 53, - 325, 1, 0, 0, 0, 55, 327, 1, 0, 0, 0, 57, 329, 1, 0, 0, 0, 59, 331, 1, 0, 0, - 0, 61, 333, 1, 0, 0, 0, 63, 335, 1, 0, 0, 0, 65, 337, 1, 0, 0, 0, 67, 339, - 1, 0, 0, 0, 69, 341, 1, 0, 0, 0, 71, 343, 1, 0, 0, 0, 73, 345, 1, 0, 0, 0, - 75, 347, 1, 0, 0, 0, 77, 357, 1, 0, 0, 0, 79, 365, 1, 0, 0, 0, 81, 371, 1, - 0, 0, 0, 83, 373, 1, 0, 0, 0, 85, 375, 1, 0, 0, 0, 87, 377, 1, 0, 0, 0, 89, - 380, 1, 0, 0, 0, 91, 382, 1, 0, 0, 0, 93, 384, 1, 0, 0, 0, 95, 386, 1, 0, 0, - 0, 97, 388, 1, 0, 0, 0, 99, 390, 1, 0, 0, 0, 101, 392, 1, 0, 0, 0, 103, 395, - 1, 0, 0, 0, 105, 398, 1, 0, 0, 0, 107, 400, 1, 0, 0, 0, 109, 402, 1, 0, 0, - 0, 111, 404, 1, 0, 0, 0, 113, 407, 1, 0, 0, 0, 115, 410, 1, 0, 0, 0, 117, - 412, 1, 0, 0, 0, 119, 414, 1, 0, 0, 0, 121, 417, 1, 0, 0, 0, 123, 420, 1, 0, - 0, 0, 125, 423, 1, 0, 0, 0, 127, 426, 1, 0, 0, 0, 129, 455, 1, 0, 0, 0, 131, - 460, 1, 0, 0, 0, 133, 472, 1, 0, 0, 0, 135, 474, 1, 0, 0, 0, 137, 482, 1, 0, - 0, 0, 139, 484, 1, 0, 0, 0, 141, 486, 1, 0, 0, 0, 143, 493, 1, 0, 0, 0, 145, - 495, 1, 0, 0, 0, 147, 505, 1, 0, 0, 0, 149, 508, 1, 0, 0, 0, 151, 522, 1, 0, - 0, 0, 153, 534, 1, 0, 0, 0, 155, 156, 3, 137, 68, 0, 156, 157, 5, 46, 0, 0, - 157, 158, 3, 137, 68, 0, 158, 159, 5, 46, 0, 0, 159, 160, 3, 137, 68, 0, - 160, 2, 1, 0, 0, 0, 161, 164, 3, 31, 15, 0, 162, 164, 3, 33, 16, 0, 163, - 161, 1, 0, 0, 0, 163, 162, 1, 0, 0, 0, 164, 4, 1, 0, 0, 0, 165, 166, 5, 112, - 0, 0, 166, 167, 5, 114, 0, 0, 167, 168, 5, 97, 0, 0, 168, 169, 5, 103, 0, 0, - 169, 170, 5, 109, 0, 0, 170, 171, 5, 97, 0, 0, 171, 6, 1, 0, 0, 0, 172, 173, - 5, 99, 0, 0, 173, 174, 5, 105, 0, 0, 174, 175, 5, 114, 0, 0, 175, 176, 5, - 99, 0, 0, 176, 177, 5, 111, 0, 0, 177, 178, 5, 109, 0, 0, 178, 8, 1, 0, 0, - 0, 179, 180, 5, 99, 0, 0, 180, 181, 5, 117, 0, 0, 181, 182, 5, 115, 0, 0, - 182, 183, 5, 116, 0, 0, 183, 184, 5, 111, 0, 0, 184, 185, 5, 109, 0, 0, 185, - 186, 5, 95, 0, 0, 186, 187, 5, 116, 0, 0, 187, 188, 5, 101, 0, 0, 188, 189, - 5, 109, 0, 0, 189, 190, 5, 112, 0, 0, 190, 191, 5, 108, 0, 0, 191, 192, 5, - 97, 0, 0, 192, 193, 5, 116, 0, 0, 193, 194, 5, 101, 0, 0, 194, 195, 5, 115, - 0, 0, 195, 10, 1, 0, 0, 0, 196, 197, 5, 105, 0, 0, 197, 198, 5, 110, 0, 0, - 198, 199, 5, 99, 0, 0, 199, 200, 5, 108, 0, 0, 200, 201, 5, 117, 0, 0, 201, - 202, 5, 100, 0, 0, 202, 203, 5, 101, 0, 0, 203, 12, 1, 0, 0, 0, 204, 205, 5, - 99, 0, 0, 205, 206, 5, 117, 0, 0, 206, 207, 5, 115, 0, 0, 207, 208, 5, 116, - 0, 0, 208, 209, 5, 111, 0, 0, 209, 210, 5, 109, 0, 0, 210, 14, 1, 0, 0, 0, - 211, 212, 5, 112, 0, 0, 212, 213, 5, 97, 0, 0, 213, 214, 5, 114, 0, 0, 214, - 215, 5, 97, 0, 0, 215, 216, 5, 108, 0, 0, 216, 217, 5, 108, 0, 0, 217, 218, - 5, 101, 0, 0, 218, 219, 5, 108, 0, 0, 219, 16, 1, 0, 0, 0, 220, 221, 5, 116, - 0, 0, 221, 222, 5, 101, 0, 0, 222, 223, 5, 109, 0, 0, 223, 224, 5, 112, 0, - 0, 224, 225, 5, 108, 0, 0, 225, 226, 5, 97, 0, 0, 226, 227, 5, 116, 0, 0, - 227, 228, 5, 101, 0, 0, 228, 18, 1, 0, 0, 0, 229, 230, 5, 102, 0, 0, 230, - 231, 5, 117, 0, 0, 231, 232, 5, 110, 0, 0, 232, 233, 5, 99, 0, 0, 233, 234, - 5, 116, 0, 0, 234, 235, 5, 105, 0, 0, 235, 236, 5, 111, 0, 0, 236, 237, 5, - 110, 0, 0, 237, 20, 1, 0, 0, 0, 238, 239, 5, 109, 0, 0, 239, 240, 5, 97, 0, - 0, 240, 241, 5, 105, 0, 0, 241, 242, 5, 110, 0, 0, 242, 22, 1, 0, 0, 0, 243, - 244, 5, 112, 0, 0, 244, 245, 5, 117, 0, 0, 245, 246, 5, 98, 0, 0, 246, 247, - 5, 108, 0, 0, 247, 248, 5, 105, 0, 0, 248, 249, 5, 99, 0, 0, 249, 24, 1, 0, - 0, 0, 250, 251, 5, 99, 0, 0, 251, 252, 5, 111, 0, 0, 252, 253, 5, 109, 0, 0, - 253, 254, 5, 112, 0, 0, 254, 255, 5, 111, 0, 0, 255, 256, 5, 110, 0, 0, 256, - 257, 5, 101, 0, 0, 257, 258, 5, 110, 0, 0, 258, 259, 5, 116, 0, 0, 259, 26, - 1, 0, 0, 0, 260, 261, 5, 118, 0, 0, 261, 262, 5, 97, 0, 0, 262, 263, 5, 114, - 0, 0, 263, 28, 1, 0, 0, 0, 264, 265, 5, 115, 0, 0, 265, 266, 5, 105, 0, 0, - 266, 267, 5, 103, 0, 0, 267, 268, 5, 110, 0, 0, 268, 269, 5, 97, 0, 0, 269, - 270, 5, 108, 0, 0, 270, 30, 1, 0, 0, 0, 271, 272, 5, 105, 0, 0, 272, 273, 5, - 110, 0, 0, 273, 274, 5, 112, 0, 0, 274, 275, 5, 117, 0, 0, 275, 276, 5, 116, - 0, 0, 276, 32, 1, 0, 0, 0, 277, 278, 5, 111, 0, 0, 278, 279, 5, 117, 0, 0, - 279, 280, 5, 116, 0, 0, 280, 281, 5, 112, 0, 0, 281, 282, 5, 117, 0, 0, 282, - 283, 5, 116, 0, 0, 283, 34, 1, 0, 0, 0, 284, 285, 5, 105, 0, 0, 285, 286, 5, - 102, 0, 0, 286, 36, 1, 0, 0, 0, 287, 288, 5, 101, 0, 0, 288, 289, 5, 108, 0, - 0, 289, 290, 5, 115, 0, 0, 290, 291, 5, 101, 0, 0, 291, 38, 1, 0, 0, 0, 292, - 293, 5, 102, 0, 0, 293, 294, 5, 111, 0, 0, 294, 295, 5, 114, 0, 0, 295, 40, - 1, 0, 0, 0, 296, 297, 5, 119, 0, 0, 297, 298, 5, 104, 0, 0, 298, 299, 5, - 105, 0, 0, 299, 300, 5, 108, 0, 0, 300, 301, 5, 101, 0, 0, 301, 42, 1, 0, 0, - 0, 302, 303, 5, 100, 0, 0, 303, 304, 5, 111, 0, 0, 304, 44, 1, 0, 0, 0, 305, - 306, 5, 108, 0, 0, 306, 307, 5, 111, 0, 0, 307, 308, 5, 103, 0, 0, 308, 46, - 1, 0, 0, 0, 309, 310, 5, 97, 0, 0, 310, 311, 5, 115, 0, 0, 311, 312, 5, 115, - 0, 0, 312, 313, 5, 101, 0, 0, 313, 314, 5, 114, 0, 0, 314, 315, 5, 116, 0, - 0, 315, 48, 1, 0, 0, 0, 316, 317, 5, 114, 0, 0, 317, 318, 5, 101, 0, 0, 318, - 319, 5, 116, 0, 0, 319, 320, 5, 117, 0, 0, 320, 321, 5, 114, 0, 0, 321, 322, - 5, 110, 0, 0, 322, 50, 1, 0, 0, 0, 323, 324, 5, 40, 0, 0, 324, 52, 1, 0, 0, - 0, 325, 326, 5, 41, 0, 0, 326, 54, 1, 0, 0, 0, 327, 328, 5, 91, 0, 0, 328, - 56, 1, 0, 0, 0, 329, 330, 5, 93, 0, 0, 330, 58, 1, 0, 0, 0, 331, 332, 5, - 123, 0, 0, 332, 60, 1, 0, 0, 0, 333, 334, 5, 125, 0, 0, 334, 62, 1, 0, 0, 0, - 335, 336, 5, 59, 0, 0, 336, 64, 1, 0, 0, 0, 337, 338, 5, 46, 0, 0, 338, 66, - 1, 0, 0, 0, 339, 340, 5, 44, 0, 0, 340, 68, 1, 0, 0, 0, 341, 342, 5, 95, 0, - 0, 342, 70, 1, 0, 0, 0, 343, 344, 5, 63, 0, 0, 344, 72, 1, 0, 0, 0, 345, - 346, 5, 58, 0, 0, 346, 74, 1, 0, 0, 0, 347, 348, 5, 61, 0, 0, 348, 349, 5, - 61, 0, 0, 349, 350, 5, 61, 0, 0, 350, 76, 1, 0, 0, 0, 351, 352, 5, 60, 0, 0, - 352, 353, 5, 45, 0, 0, 353, 358, 5, 45, 0, 0, 354, 355, 5, 60, 0, 0, 355, - 356, 5, 61, 0, 0, 356, 358, 5, 61, 0, 0, 357, 351, 1, 0, 0, 0, 357, 354, 1, - 0, 0, 0, 358, 78, 1, 0, 0, 0, 359, 360, 5, 45, 0, 0, 360, 361, 5, 45, 0, 0, - 361, 366, 5, 62, 0, 0, 362, 363, 5, 61, 0, 0, 363, 364, 5, 61, 0, 0, 364, - 366, 5, 62, 0, 0, 365, 359, 1, 0, 0, 0, 365, 362, 1, 0, 0, 0, 366, 80, 1, 0, - 0, 0, 367, 368, 5, 43, 0, 0, 368, 372, 5, 43, 0, 0, 369, 370, 5, 45, 0, 0, - 370, 372, 5, 45, 0, 0, 371, 367, 1, 0, 0, 0, 371, 369, 1, 0, 0, 0, 372, 82, - 1, 0, 0, 0, 373, 374, 5, 33, 0, 0, 374, 84, 1, 0, 0, 0, 375, 376, 5, 126, 0, - 0, 376, 86, 1, 0, 0, 0, 377, 378, 5, 42, 0, 0, 378, 379, 5, 42, 0, 0, 379, - 88, 1, 0, 0, 0, 380, 381, 5, 42, 0, 0, 381, 90, 1, 0, 0, 0, 382, 383, 5, 47, - 0, 0, 383, 92, 1, 0, 0, 0, 384, 385, 5, 92, 0, 0, 385, 94, 1, 0, 0, 0, 386, - 387, 5, 37, 0, 0, 387, 96, 1, 0, 0, 0, 388, 389, 5, 43, 0, 0, 389, 98, 1, 0, - 0, 0, 390, 391, 5, 45, 0, 0, 391, 100, 1, 0, 0, 0, 392, 393, 5, 60, 0, 0, - 393, 394, 5, 60, 0, 0, 394, 102, 1, 0, 0, 0, 395, 396, 5, 62, 0, 0, 396, - 397, 5, 62, 0, 0, 397, 104, 1, 0, 0, 0, 398, 399, 5, 38, 0, 0, 399, 106, 1, - 0, 0, 0, 400, 401, 5, 94, 0, 0, 401, 108, 1, 0, 0, 0, 402, 403, 5, 124, 0, - 0, 403, 110, 1, 0, 0, 0, 404, 405, 5, 61, 0, 0, 405, 406, 5, 61, 0, 0, 406, - 112, 1, 0, 0, 0, 407, 408, 5, 33, 0, 0, 408, 409, 5, 61, 0, 0, 409, 114, 1, - 0, 0, 0, 410, 411, 5, 62, 0, 0, 411, 116, 1, 0, 0, 0, 412, 413, 5, 60, 0, 0, - 413, 118, 1, 0, 0, 0, 414, 415, 5, 60, 0, 0, 415, 416, 5, 61, 0, 0, 416, - 120, 1, 0, 0, 0, 417, 418, 5, 62, 0, 0, 418, 419, 5, 61, 0, 0, 419, 122, 1, - 0, 0, 0, 420, 421, 5, 38, 0, 0, 421, 422, 5, 38, 0, 0, 422, 124, 1, 0, 0, 0, - 423, 424, 5, 124, 0, 0, 424, 425, 5, 124, 0, 0, 425, 126, 1, 0, 0, 0, 426, - 427, 5, 61, 0, 0, 427, 128, 1, 0, 0, 0, 428, 429, 5, 43, 0, 0, 429, 456, 5, - 61, 0, 0, 430, 431, 5, 45, 0, 0, 431, 456, 5, 61, 0, 0, 432, 433, 5, 42, 0, - 0, 433, 456, 5, 61, 0, 0, 434, 435, 5, 42, 0, 0, 435, 436, 5, 42, 0, 0, 436, - 456, 5, 61, 0, 0, 437, 438, 5, 47, 0, 0, 438, 456, 5, 61, 0, 0, 439, 440, 5, - 92, 0, 0, 440, 456, 5, 61, 0, 0, 441, 442, 5, 37, 0, 0, 442, 456, 5, 61, 0, - 0, 443, 444, 5, 60, 0, 0, 444, 445, 5, 60, 0, 0, 445, 456, 5, 61, 0, 0, 446, - 447, 5, 62, 0, 0, 447, 448, 5, 62, 0, 0, 448, 456, 5, 61, 0, 0, 449, 450, 5, - 38, 0, 0, 450, 456, 5, 61, 0, 0, 451, 452, 5, 94, 0, 0, 452, 456, 5, 61, 0, - 0, 453, 454, 5, 124, 0, 0, 454, 456, 5, 61, 0, 0, 455, 428, 1, 0, 0, 0, 455, - 430, 1, 0, 0, 0, 455, 432, 1, 0, 0, 0, 455, 434, 1, 0, 0, 0, 455, 437, 1, 0, - 0, 0, 455, 439, 1, 0, 0, 0, 455, 441, 1, 0, 0, 0, 455, 443, 1, 0, 0, 0, 455, - 446, 1, 0, 0, 0, 455, 449, 1, 0, 0, 0, 455, 451, 1, 0, 0, 0, 455, 453, 1, 0, - 0, 0, 456, 130, 1, 0, 0, 0, 457, 459, 3, 135, 67, 0, 458, 457, 1, 0, 0, 0, - 459, 462, 1, 0, 0, 0, 460, 458, 1, 0, 0, 0, 460, 461, 1, 0, 0, 0, 461, 463, - 1, 0, 0, 0, 462, 460, 1, 0, 0, 0, 463, 469, 3, 133, 66, 0, 464, 468, 3, 133, - 66, 0, 465, 468, 3, 139, 69, 0, 466, 468, 3, 135, 67, 0, 467, 464, 1, 0, 0, - 0, 467, 465, 1, 0, 0, 0, 467, 466, 1, 0, 0, 0, 468, 471, 1, 0, 0, 0, 469, - 467, 1, 0, 0, 0, 469, 470, 1, 0, 0, 0, 470, 132, 1, 0, 0, 0, 471, 469, 1, 0, - 0, 0, 472, 473, 7, 0, 0, 0, 473, 134, 1, 0, 0, 0, 474, 475, 7, 1, 0, 0, 475, - 136, 1, 0, 0, 0, 476, 478, 3, 139, 69, 0, 477, 476, 1, 0, 0, 0, 478, 479, 1, - 0, 0, 0, 479, 477, 1, 0, 0, 0, 479, 480, 1, 0, 0, 0, 480, 483, 1, 0, 0, 0, - 481, 483, 3, 141, 70, 0, 482, 477, 1, 0, 0, 0, 482, 481, 1, 0, 0, 0, 483, - 138, 1, 0, 0, 0, 484, 485, 7, 2, 0, 0, 485, 140, 1, 0, 0, 0, 486, 487, 5, - 48, 0, 0, 487, 489, 5, 120, 0, 0, 488, 490, 3, 143, 71, 0, 489, 488, 1, 0, - 0, 0, 490, 491, 1, 0, 0, 0, 491, 489, 1, 0, 0, 0, 491, 492, 1, 0, 0, 0, 492, - 142, 1, 0, 0, 0, 493, 494, 7, 3, 0, 0, 494, 144, 1, 0, 0, 0, 495, 500, 5, - 34, 0, 0, 496, 499, 3, 147, 73, 0, 497, 499, 9, 0, 0, 0, 498, 496, 1, 0, 0, - 0, 498, 497, 1, 0, 0, 0, 499, 502, 1, 0, 0, 0, 500, 501, 1, 0, 0, 0, 500, - 498, 1, 0, 0, 0, 501, 503, 1, 0, 0, 0, 502, 500, 1, 0, 0, 0, 503, 504, 5, - 34, 0, 0, 504, 146, 1, 0, 0, 0, 505, 506, 5, 92, 0, 0, 506, 507, 7, 4, 0, 0, - 507, 148, 1, 0, 0, 0, 508, 509, 5, 47, 0, 0, 509, 510, 5, 42, 0, 0, 510, - 514, 1, 0, 0, 0, 511, 513, 9, 0, 0, 0, 512, 511, 1, 0, 0, 0, 513, 516, 1, 0, - 0, 0, 514, 515, 1, 0, 0, 0, 514, 512, 1, 0, 0, 0, 515, 517, 1, 0, 0, 0, 516, - 514, 1, 0, 0, 0, 517, 518, 5, 42, 0, 0, 518, 519, 5, 47, 0, 0, 519, 520, 1, - 0, 0, 0, 520, 521, 6, 74, 0, 0, 521, 150, 1, 0, 0, 0, 522, 523, 5, 47, 0, 0, - 523, 524, 5, 47, 0, 0, 524, 528, 1, 0, 0, 0, 525, 527, 8, 5, 0, 0, 526, 525, - 1, 0, 0, 0, 527, 530, 1, 0, 0, 0, 528, 526, 1, 0, 0, 0, 528, 529, 1, 0, 0, - 0, 529, 531, 1, 0, 0, 0, 530, 528, 1, 0, 0, 0, 531, 532, 6, 75, 0, 0, 532, - 152, 1, 0, 0, 0, 533, 535, 7, 6, 0, 0, 534, 533, 1, 0, 0, 0, 535, 536, 1, 0, - 0, 0, 536, 534, 1, 0, 0, 0, 536, 537, 1, 0, 0, 0, 537, 538, 1, 0, 0, 0, 538, - 539, 6, 76, 0, 0, 539, 154, 1, 0, 0, 0, 17, 0, 163, 357, 365, 371, 455, 460, - 467, 469, 479, 482, 491, 498, 500, 514, 528, 536, 1, 0, 1, 0, + 0, 131, 1, 0, 0, 0, 0, 133, 1, 0, 0, 0, 0, 135, 1, 0, 0, 0, 0, 137, 1, 0, 0, + 0, 0, 143, 1, 0, 0, 0, 0, 147, 1, 0, 0, 0, 0, 151, 1, 0, 0, 0, 0, 155, 1, 0, + 0, 0, 0, 157, 1, 0, 0, 0, 0, 159, 1, 0, 0, 0, 1, 161, 1, 0, 0, 0, 3, 169, 1, + 0, 0, 0, 5, 171, 1, 0, 0, 0, 7, 178, 1, 0, 0, 0, 9, 185, 1, 0, 0, 0, 11, + 202, 1, 0, 0, 0, 13, 210, 1, 0, 0, 0, 15, 217, 1, 0, 0, 0, 17, 226, 1, 0, 0, + 0, 19, 230, 1, 0, 0, 0, 21, 239, 1, 0, 0, 0, 23, 248, 1, 0, 0, 0, 25, 253, + 1, 0, 0, 0, 27, 260, 1, 0, 0, 0, 29, 270, 1, 0, 0, 0, 31, 274, 1, 0, 0, 0, + 33, 281, 1, 0, 0, 0, 35, 287, 1, 0, 0, 0, 37, 294, 1, 0, 0, 0, 39, 297, 1, + 0, 0, 0, 41, 302, 1, 0, 0, 0, 43, 306, 1, 0, 0, 0, 45, 312, 1, 0, 0, 0, 47, + 315, 1, 0, 0, 0, 49, 319, 1, 0, 0, 0, 51, 326, 1, 0, 0, 0, 53, 333, 1, 0, 0, + 0, 55, 335, 1, 0, 0, 0, 57, 337, 1, 0, 0, 0, 59, 339, 1, 0, 0, 0, 61, 341, + 1, 0, 0, 0, 63, 343, 1, 0, 0, 0, 65, 345, 1, 0, 0, 0, 67, 347, 1, 0, 0, 0, + 69, 349, 1, 0, 0, 0, 71, 351, 1, 0, 0, 0, 73, 353, 1, 0, 0, 0, 75, 355, 1, + 0, 0, 0, 77, 357, 1, 0, 0, 0, 79, 361, 1, 0, 0, 0, 81, 365, 1, 0, 0, 0, 83, + 369, 1, 0, 0, 0, 85, 373, 1, 0, 0, 0, 87, 381, 1, 0, 0, 0, 89, 383, 1, 0, 0, + 0, 91, 385, 1, 0, 0, 0, 93, 387, 1, 0, 0, 0, 95, 390, 1, 0, 0, 0, 97, 392, + 1, 0, 0, 0, 99, 394, 1, 0, 0, 0, 101, 396, 1, 0, 0, 0, 103, 398, 1, 0, 0, 0, + 105, 400, 1, 0, 0, 0, 107, 402, 1, 0, 0, 0, 109, 405, 1, 0, 0, 0, 111, 408, + 1, 0, 0, 0, 113, 410, 1, 0, 0, 0, 115, 412, 1, 0, 0, 0, 117, 414, 1, 0, 0, + 0, 119, 417, 1, 0, 0, 0, 121, 420, 1, 0, 0, 0, 123, 422, 1, 0, 0, 0, 125, + 424, 1, 0, 0, 0, 127, 427, 1, 0, 0, 0, 129, 430, 1, 0, 0, 0, 131, 433, 1, 0, + 0, 0, 133, 436, 1, 0, 0, 0, 135, 465, 1, 0, 0, 0, 137, 470, 1, 0, 0, 0, 139, + 482, 1, 0, 0, 0, 141, 484, 1, 0, 0, 0, 143, 492, 1, 0, 0, 0, 145, 494, 1, 0, + 0, 0, 147, 496, 1, 0, 0, 0, 149, 503, 1, 0, 0, 0, 151, 505, 1, 0, 0, 0, 153, + 515, 1, 0, 0, 0, 155, 518, 1, 0, 0, 0, 157, 532, 1, 0, 0, 0, 159, 544, 1, 0, + 0, 0, 161, 162, 3, 143, 71, 0, 162, 163, 5, 46, 0, 0, 163, 164, 3, 143, 71, + 0, 164, 165, 5, 46, 0, 0, 165, 166, 3, 143, 71, 0, 166, 2, 1, 0, 0, 0, 167, + 170, 3, 33, 16, 0, 168, 170, 3, 35, 17, 0, 169, 167, 1, 0, 0, 0, 169, 168, + 1, 0, 0, 0, 170, 4, 1, 0, 0, 0, 171, 172, 5, 112, 0, 0, 172, 173, 5, 114, 0, + 0, 173, 174, 5, 97, 0, 0, 174, 175, 5, 103, 0, 0, 175, 176, 5, 109, 0, 0, + 176, 177, 5, 97, 0, 0, 177, 6, 1, 0, 0, 0, 178, 179, 5, 99, 0, 0, 179, 180, + 5, 105, 0, 0, 180, 181, 5, 114, 0, 0, 181, 182, 5, 99, 0, 0, 182, 183, 5, + 111, 0, 0, 183, 184, 5, 109, 0, 0, 184, 8, 1, 0, 0, 0, 185, 186, 5, 99, 0, + 0, 186, 187, 5, 117, 0, 0, 187, 188, 5, 115, 0, 0, 188, 189, 5, 116, 0, 0, + 189, 190, 5, 111, 0, 0, 190, 191, 5, 109, 0, 0, 191, 192, 5, 95, 0, 0, 192, + 193, 5, 116, 0, 0, 193, 194, 5, 101, 0, 0, 194, 195, 5, 109, 0, 0, 195, 196, + 5, 112, 0, 0, 196, 197, 5, 108, 0, 0, 197, 198, 5, 97, 0, 0, 198, 199, 5, + 116, 0, 0, 199, 200, 5, 101, 0, 0, 200, 201, 5, 115, 0, 0, 201, 10, 1, 0, 0, + 0, 202, 203, 5, 105, 0, 0, 203, 204, 5, 110, 0, 0, 204, 205, 5, 99, 0, 0, + 205, 206, 5, 108, 0, 0, 206, 207, 5, 117, 0, 0, 207, 208, 5, 100, 0, 0, 208, + 209, 5, 101, 0, 0, 209, 12, 1, 0, 0, 0, 210, 211, 5, 99, 0, 0, 211, 212, 5, + 117, 0, 0, 212, 213, 5, 115, 0, 0, 213, 214, 5, 116, 0, 0, 214, 215, 5, 111, + 0, 0, 215, 216, 5, 109, 0, 0, 216, 14, 1, 0, 0, 0, 217, 218, 5, 112, 0, 0, + 218, 219, 5, 97, 0, 0, 219, 220, 5, 114, 0, 0, 220, 221, 5, 97, 0, 0, 221, + 222, 5, 108, 0, 0, 222, 223, 5, 108, 0, 0, 223, 224, 5, 101, 0, 0, 224, 225, + 5, 108, 0, 0, 225, 16, 1, 0, 0, 0, 226, 227, 5, 98, 0, 0, 227, 228, 5, 117, + 0, 0, 228, 229, 5, 115, 0, 0, 229, 18, 1, 0, 0, 0, 230, 231, 5, 116, 0, 0, + 231, 232, 5, 101, 0, 0, 232, 233, 5, 109, 0, 0, 233, 234, 5, 112, 0, 0, 234, + 235, 5, 108, 0, 0, 235, 236, 5, 97, 0, 0, 236, 237, 5, 116, 0, 0, 237, 238, + 5, 101, 0, 0, 238, 20, 1, 0, 0, 0, 239, 240, 5, 102, 0, 0, 240, 241, 5, 117, + 0, 0, 241, 242, 5, 110, 0, 0, 242, 243, 5, 99, 0, 0, 243, 244, 5, 116, 0, 0, + 244, 245, 5, 105, 0, 0, 245, 246, 5, 111, 0, 0, 246, 247, 5, 110, 0, 0, 247, + 22, 1, 0, 0, 0, 248, 249, 5, 109, 0, 0, 249, 250, 5, 97, 0, 0, 250, 251, 5, + 105, 0, 0, 251, 252, 5, 110, 0, 0, 252, 24, 1, 0, 0, 0, 253, 254, 5, 112, 0, + 0, 254, 255, 5, 117, 0, 0, 255, 256, 5, 98, 0, 0, 256, 257, 5, 108, 0, 0, + 257, 258, 5, 105, 0, 0, 258, 259, 5, 99, 0, 0, 259, 26, 1, 0, 0, 0, 260, + 261, 5, 99, 0, 0, 261, 262, 5, 111, 0, 0, 262, 263, 5, 109, 0, 0, 263, 264, + 5, 112, 0, 0, 264, 265, 5, 111, 0, 0, 265, 266, 5, 110, 0, 0, 266, 267, 5, + 101, 0, 0, 267, 268, 5, 110, 0, 0, 268, 269, 5, 116, 0, 0, 269, 28, 1, 0, 0, + 0, 270, 271, 5, 118, 0, 0, 271, 272, 5, 97, 0, 0, 272, 273, 5, 114, 0, 0, + 273, 30, 1, 0, 0, 0, 274, 275, 5, 115, 0, 0, 275, 276, 5, 105, 0, 0, 276, + 277, 5, 103, 0, 0, 277, 278, 5, 110, 0, 0, 278, 279, 5, 97, 0, 0, 279, 280, + 5, 108, 0, 0, 280, 32, 1, 0, 0, 0, 281, 282, 5, 105, 0, 0, 282, 283, 5, 110, + 0, 0, 283, 284, 5, 112, 0, 0, 284, 285, 5, 117, 0, 0, 285, 286, 5, 116, 0, + 0, 286, 34, 1, 0, 0, 0, 287, 288, 5, 111, 0, 0, 288, 289, 5, 117, 0, 0, 289, + 290, 5, 116, 0, 0, 290, 291, 5, 112, 0, 0, 291, 292, 5, 117, 0, 0, 292, 293, + 5, 116, 0, 0, 293, 36, 1, 0, 0, 0, 294, 295, 5, 105, 0, 0, 295, 296, 5, 102, + 0, 0, 296, 38, 1, 0, 0, 0, 297, 298, 5, 101, 0, 0, 298, 299, 5, 108, 0, 0, + 299, 300, 5, 115, 0, 0, 300, 301, 5, 101, 0, 0, 301, 40, 1, 0, 0, 0, 302, + 303, 5, 102, 0, 0, 303, 304, 5, 111, 0, 0, 304, 305, 5, 114, 0, 0, 305, 42, + 1, 0, 0, 0, 306, 307, 5, 119, 0, 0, 307, 308, 5, 104, 0, 0, 308, 309, 5, + 105, 0, 0, 309, 310, 5, 108, 0, 0, 310, 311, 5, 101, 0, 0, 311, 44, 1, 0, 0, + 0, 312, 313, 5, 100, 0, 0, 313, 314, 5, 111, 0, 0, 314, 46, 1, 0, 0, 0, 315, + 316, 5, 108, 0, 0, 316, 317, 5, 111, 0, 0, 317, 318, 5, 103, 0, 0, 318, 48, + 1, 0, 0, 0, 319, 320, 5, 97, 0, 0, 320, 321, 5, 115, 0, 0, 321, 322, 5, 115, + 0, 0, 322, 323, 5, 101, 0, 0, 323, 324, 5, 114, 0, 0, 324, 325, 5, 116, 0, + 0, 325, 50, 1, 0, 0, 0, 326, 327, 5, 114, 0, 0, 327, 328, 5, 101, 0, 0, 328, + 329, 5, 116, 0, 0, 329, 330, 5, 117, 0, 0, 330, 331, 5, 114, 0, 0, 331, 332, + 5, 110, 0, 0, 332, 52, 1, 0, 0, 0, 333, 334, 5, 40, 0, 0, 334, 54, 1, 0, 0, + 0, 335, 336, 5, 41, 0, 0, 336, 56, 1, 0, 0, 0, 337, 338, 5, 91, 0, 0, 338, + 58, 1, 0, 0, 0, 339, 340, 5, 93, 0, 0, 340, 60, 1, 0, 0, 0, 341, 342, 5, + 123, 0, 0, 342, 62, 1, 0, 0, 0, 343, 344, 5, 125, 0, 0, 344, 64, 1, 0, 0, 0, + 345, 346, 5, 59, 0, 0, 346, 66, 1, 0, 0, 0, 347, 348, 5, 46, 0, 0, 348, 68, + 1, 0, 0, 0, 349, 350, 5, 44, 0, 0, 350, 70, 1, 0, 0, 0, 351, 352, 5, 95, 0, + 0, 352, 72, 1, 0, 0, 0, 353, 354, 5, 63, 0, 0, 354, 74, 1, 0, 0, 0, 355, + 356, 5, 58, 0, 0, 356, 76, 1, 0, 0, 0, 357, 358, 5, 61, 0, 0, 358, 359, 5, + 61, 0, 0, 359, 360, 5, 61, 0, 0, 360, 78, 1, 0, 0, 0, 361, 362, 5, 60, 0, 0, + 362, 363, 5, 61, 0, 0, 363, 364, 5, 61, 0, 0, 364, 80, 1, 0, 0, 0, 365, 366, + 5, 60, 0, 0, 366, 367, 5, 45, 0, 0, 367, 368, 5, 45, 0, 0, 368, 82, 1, 0, 0, + 0, 369, 370, 5, 61, 0, 0, 370, 371, 5, 61, 0, 0, 371, 372, 5, 62, 0, 0, 372, + 84, 1, 0, 0, 0, 373, 374, 5, 45, 0, 0, 374, 375, 5, 45, 0, 0, 375, 376, 5, + 62, 0, 0, 376, 86, 1, 0, 0, 0, 377, 378, 5, 43, 0, 0, 378, 382, 5, 43, 0, 0, + 379, 380, 5, 45, 0, 0, 380, 382, 5, 45, 0, 0, 381, 377, 1, 0, 0, 0, 381, + 379, 1, 0, 0, 0, 382, 88, 1, 0, 0, 0, 383, 384, 5, 33, 0, 0, 384, 90, 1, 0, + 0, 0, 385, 386, 5, 126, 0, 0, 386, 92, 1, 0, 0, 0, 387, 388, 5, 42, 0, 0, + 388, 389, 5, 42, 0, 0, 389, 94, 1, 0, 0, 0, 390, 391, 5, 42, 0, 0, 391, 96, + 1, 0, 0, 0, 392, 393, 5, 47, 0, 0, 393, 98, 1, 0, 0, 0, 394, 395, 5, 92, 0, + 0, 395, 100, 1, 0, 0, 0, 396, 397, 5, 37, 0, 0, 397, 102, 1, 0, 0, 0, 398, + 399, 5, 43, 0, 0, 399, 104, 1, 0, 0, 0, 400, 401, 5, 45, 0, 0, 401, 106, 1, + 0, 0, 0, 402, 403, 5, 60, 0, 0, 403, 404, 5, 60, 0, 0, 404, 108, 1, 0, 0, 0, + 405, 406, 5, 62, 0, 0, 406, 407, 5, 62, 0, 0, 407, 110, 1, 0, 0, 0, 408, + 409, 5, 38, 0, 0, 409, 112, 1, 0, 0, 0, 410, 411, 5, 94, 0, 0, 411, 114, 1, + 0, 0, 0, 412, 413, 5, 124, 0, 0, 413, 116, 1, 0, 0, 0, 414, 415, 5, 61, 0, + 0, 415, 416, 5, 61, 0, 0, 416, 118, 1, 0, 0, 0, 417, 418, 5, 33, 0, 0, 418, + 419, 5, 61, 0, 0, 419, 120, 1, 0, 0, 0, 420, 421, 5, 62, 0, 0, 421, 122, 1, + 0, 0, 0, 422, 423, 5, 60, 0, 0, 423, 124, 1, 0, 0, 0, 424, 425, 5, 60, 0, 0, + 425, 426, 5, 61, 0, 0, 426, 126, 1, 0, 0, 0, 427, 428, 5, 62, 0, 0, 428, + 429, 5, 61, 0, 0, 429, 128, 1, 0, 0, 0, 430, 431, 5, 38, 0, 0, 431, 432, 5, + 38, 0, 0, 432, 130, 1, 0, 0, 0, 433, 434, 5, 124, 0, 0, 434, 435, 5, 124, 0, + 0, 435, 132, 1, 0, 0, 0, 436, 437, 5, 61, 0, 0, 437, 134, 1, 0, 0, 0, 438, + 439, 5, 43, 0, 0, 439, 466, 5, 61, 0, 0, 440, 441, 5, 45, 0, 0, 441, 466, 5, + 61, 0, 0, 442, 443, 5, 42, 0, 0, 443, 466, 5, 61, 0, 0, 444, 445, 5, 42, 0, + 0, 445, 446, 5, 42, 0, 0, 446, 466, 5, 61, 0, 0, 447, 448, 5, 47, 0, 0, 448, + 466, 5, 61, 0, 0, 449, 450, 5, 92, 0, 0, 450, 466, 5, 61, 0, 0, 451, 452, 5, + 37, 0, 0, 452, 466, 5, 61, 0, 0, 453, 454, 5, 60, 0, 0, 454, 455, 5, 60, 0, + 0, 455, 466, 5, 61, 0, 0, 456, 457, 5, 62, 0, 0, 457, 458, 5, 62, 0, 0, 458, + 466, 5, 61, 0, 0, 459, 460, 5, 38, 0, 0, 460, 466, 5, 61, 0, 0, 461, 462, 5, + 94, 0, 0, 462, 466, 5, 61, 0, 0, 463, 464, 5, 124, 0, 0, 464, 466, 5, 61, 0, + 0, 465, 438, 1, 0, 0, 0, 465, 440, 1, 0, 0, 0, 465, 442, 1, 0, 0, 0, 465, + 444, 1, 0, 0, 0, 465, 447, 1, 0, 0, 0, 465, 449, 1, 0, 0, 0, 465, 451, 1, 0, + 0, 0, 465, 453, 1, 0, 0, 0, 465, 456, 1, 0, 0, 0, 465, 459, 1, 0, 0, 0, 465, + 461, 1, 0, 0, 0, 465, 463, 1, 0, 0, 0, 466, 136, 1, 0, 0, 0, 467, 469, 3, + 141, 70, 0, 468, 467, 1, 0, 0, 0, 469, 472, 1, 0, 0, 0, 470, 468, 1, 0, 0, + 0, 470, 471, 1, 0, 0, 0, 471, 473, 1, 0, 0, 0, 472, 470, 1, 0, 0, 0, 473, + 479, 3, 139, 69, 0, 474, 478, 3, 139, 69, 0, 475, 478, 3, 141, 70, 0, 476, + 478, 3, 145, 72, 0, 477, 474, 1, 0, 0, 0, 477, 475, 1, 0, 0, 0, 477, 476, 1, + 0, 0, 0, 478, 481, 1, 0, 0, 0, 479, 477, 1, 0, 0, 0, 479, 480, 1, 0, 0, 0, + 480, 138, 1, 0, 0, 0, 481, 479, 1, 0, 0, 0, 482, 483, 7, 0, 0, 0, 483, 140, + 1, 0, 0, 0, 484, 485, 7, 1, 0, 0, 485, 142, 1, 0, 0, 0, 486, 488, 3, 145, + 72, 0, 487, 486, 1, 0, 0, 0, 488, 489, 1, 0, 0, 0, 489, 487, 1, 0, 0, 0, + 489, 490, 1, 0, 0, 0, 490, 493, 1, 0, 0, 0, 491, 493, 3, 147, 73, 0, 492, + 487, 1, 0, 0, 0, 492, 491, 1, 0, 0, 0, 493, 144, 1, 0, 0, 0, 494, 495, 7, 2, + 0, 0, 495, 146, 1, 0, 0, 0, 496, 497, 5, 48, 0, 0, 497, 499, 5, 120, 0, 0, + 498, 500, 3, 149, 74, 0, 499, 498, 1, 0, 0, 0, 500, 501, 1, 0, 0, 0, 501, + 499, 1, 0, 0, 0, 501, 502, 1, 0, 0, 0, 502, 148, 1, 0, 0, 0, 503, 504, 7, 3, + 0, 0, 504, 150, 1, 0, 0, 0, 505, 510, 5, 34, 0, 0, 506, 509, 3, 153, 76, 0, + 507, 509, 9, 0, 0, 0, 508, 506, 1, 0, 0, 0, 508, 507, 1, 0, 0, 0, 509, 512, + 1, 0, 0, 0, 510, 511, 1, 0, 0, 0, 510, 508, 1, 0, 0, 0, 511, 513, 1, 0, 0, + 0, 512, 510, 1, 0, 0, 0, 513, 514, 5, 34, 0, 0, 514, 152, 1, 0, 0, 0, 515, + 516, 5, 92, 0, 0, 516, 517, 7, 4, 0, 0, 517, 154, 1, 0, 0, 0, 518, 519, 5, + 47, 0, 0, 519, 520, 5, 42, 0, 0, 520, 524, 1, 0, 0, 0, 521, 523, 9, 0, 0, 0, + 522, 521, 1, 0, 0, 0, 523, 526, 1, 0, 0, 0, 524, 525, 1, 0, 0, 0, 524, 522, + 1, 0, 0, 0, 525, 527, 1, 0, 0, 0, 526, 524, 1, 0, 0, 0, 527, 528, 5, 42, 0, + 0, 528, 529, 5, 47, 0, 0, 529, 530, 1, 0, 0, 0, 530, 531, 6, 77, 0, 0, 531, + 156, 1, 0, 0, 0, 532, 533, 5, 47, 0, 0, 533, 534, 5, 47, 0, 0, 534, 538, 1, + 0, 0, 0, 535, 537, 8, 5, 0, 0, 536, 535, 1, 0, 0, 0, 537, 540, 1, 0, 0, 0, + 538, 536, 1, 0, 0, 0, 538, 539, 1, 0, 0, 0, 539, 541, 1, 0, 0, 0, 540, 538, + 1, 0, 0, 0, 541, 542, 6, 78, 0, 0, 542, 158, 1, 0, 0, 0, 543, 545, 7, 6, 0, + 0, 544, 543, 1, 0, 0, 0, 545, 546, 1, 0, 0, 0, 546, 544, 1, 0, 0, 0, 546, + 547, 1, 0, 0, 0, 547, 548, 1, 0, 0, 0, 548, 549, 6, 79, 0, 0, 549, 160, 1, + 0, 0, 0, 15, 0, 169, 381, 465, 470, 477, 479, 489, 492, 501, 508, 510, 524, + 538, 546, 1, 0, 1, 0, ]; private static __ATN: ATN; diff --git a/src/generated/CircomParser.ts b/src/generated/CircomParser.ts index f63398b..d44aa99 100644 --- a/src/generated/CircomParser.ts +++ b/src/generated/CircomParser.ts @@ -39,107 +39,117 @@ export default class CircomParser extends Parser { public static readonly INCLUDE = 6; public static readonly CUSTOM = 7; public static readonly PARALLEL = 8; - public static readonly TEMPLATE = 9; - public static readonly FUNCTION = 10; - public static readonly MAIN = 11; - public static readonly PUBLIC = 12; - public static readonly COMPONENT = 13; - public static readonly VAR = 14; - public static readonly SIGNAL = 15; - public static readonly INPUT = 16; - public static readonly OUTPUT = 17; - public static readonly IF = 18; - public static readonly ELSE = 19; - public static readonly FOR = 20; - public static readonly WHILE = 21; - public static readonly DO = 22; - public static readonly LOG = 23; - public static readonly ASSERT = 24; - public static readonly RETURN = 25; - public static readonly LP = 26; - public static readonly RP = 27; - public static readonly LB = 28; - public static readonly RB = 29; - public static readonly LC = 30; - public static readonly RC = 31; - public static readonly SEMICOLON = 32; - public static readonly DOT = 33; - public static readonly COMMA = 34; - public static readonly UNDERSCORE = 35; - public static readonly TERNARY_CONDITION = 36; - public static readonly TERNARY_ALTERNATIVE = 37; - public static readonly EQ_CONSTRAINT = 38; - public static readonly LEFT_CONSTRAINT = 39; - public static readonly RIGHT_CONSTRAINT = 40; - public static readonly SELF_OP = 41; - public static readonly NOT = 42; - public static readonly BNOT = 43; - public static readonly POW = 44; - public static readonly MUL = 45; - public static readonly DIV = 46; - public static readonly QUO = 47; - public static readonly MOD = 48; - public static readonly ADD = 49; - public static readonly SUB = 50; - public static readonly SHL = 51; - public static readonly SHR = 52; - public static readonly BAND = 53; - public static readonly BXOR = 54; - public static readonly BOR = 55; - public static readonly EQ = 56; - public static readonly NEQ = 57; - public static readonly GT = 58; - public static readonly LT = 59; - public static readonly LE = 60; - public static readonly GE = 61; - public static readonly AND = 62; - public static readonly OR = 63; - public static readonly ASSIGNMENT = 64; - public static readonly ASSIGNMENT_WITH_OP = 65; - public static readonly ID = 66; - public static readonly NUMBER = 67; - public static readonly HEX = 68; - public static readonly STRING = 69; - public static readonly COMMENT = 70; - public static readonly LINE_COMMENT = 71; - public static readonly WS = 72; + public static readonly BUS = 9; + public static readonly TEMPLATE = 10; + public static readonly FUNCTION = 11; + public static readonly MAIN = 12; + public static readonly PUBLIC = 13; + public static readonly COMPONENT = 14; + public static readonly VAR = 15; + public static readonly SIGNAL = 16; + public static readonly INPUT = 17; + public static readonly OUTPUT = 18; + public static readonly IF = 19; + public static readonly ELSE = 20; + public static readonly FOR = 21; + public static readonly WHILE = 22; + public static readonly DO = 23; + public static readonly LOG = 24; + public static readonly ASSERT = 25; + public static readonly RETURN = 26; + public static readonly LP = 27; + public static readonly RP = 28; + public static readonly LB = 29; + public static readonly RB = 30; + public static readonly LC = 31; + public static readonly RC = 32; + public static readonly SEMICOLON = 33; + public static readonly DOT = 34; + public static readonly COMMA = 35; + public static readonly UNDERSCORE = 36; + public static readonly TERNARY_CONDITION = 37; + public static readonly TERNARY_ALTERNATIVE = 38; + public static readonly EQ_CONSTRAINT = 39; + public static readonly LEFT_CONSTRAINT = 40; + public static readonly LEFT_ASSIGNMENT = 41; + public static readonly RIGHT_CONSTRAINT = 42; + public static readonly RIGHT_ASSIGNMENT = 43; + public static readonly SELF_OP = 44; + public static readonly NOT = 45; + public static readonly BNOT = 46; + public static readonly POW = 47; + public static readonly MUL = 48; + public static readonly DIV = 49; + public static readonly QUO = 50; + public static readonly MOD = 51; + public static readonly ADD = 52; + public static readonly SUB = 53; + public static readonly SHL = 54; + public static readonly SHR = 55; + public static readonly BAND = 56; + public static readonly BXOR = 57; + public static readonly BOR = 58; + public static readonly EQ = 59; + public static readonly NEQ = 60; + public static readonly GT = 61; + public static readonly LT = 62; + public static readonly LE = 63; + public static readonly GE = 64; + public static readonly AND = 65; + public static readonly OR = 66; + public static readonly ASSIGNMENT = 67; + public static readonly ASSIGNMENT_WITH_OP = 68; + public static readonly ID = 69; + public static readonly NUMBER = 70; + public static readonly HEX = 71; + public static readonly STRING = 72; + public static readonly COMMENT = 73; + public static readonly LINE_COMMENT = 74; + public static readonly WS = 75; public static readonly EOF = Token.EOF; public static readonly RULE_circuit = 0; - public static readonly RULE_pragmaDeclaration = 1; - public static readonly RULE_includeDeclaration = 2; - public static readonly RULE_blockDeclaration = 3; - public static readonly RULE_functionDeclaration = 4; - public static readonly RULE_functionBlock = 5; - public static readonly RULE_functionStmt = 6; - public static readonly RULE_templateDeclaration = 7; - public static readonly RULE_templateBlock = 8; - public static readonly RULE_componentMainDeclaration = 9; - public static readonly RULE_publicInputsList = 10; - public static readonly RULE_templateStmt = 11; - public static readonly RULE_element = 12; - public static readonly RULE_forControl = 13; - public static readonly RULE_forInit = 14; - public static readonly RULE_forUpdate = 15; - public static readonly RULE_parExpression = 16; - public static readonly RULE_expression = 17; - public static readonly RULE_primary = 18; - public static readonly RULE_logStmt = 19; - public static readonly RULE_componentDefinition = 20; - public static readonly RULE_componentDeclaration = 21; - public static readonly RULE_signalDefinition = 22; - public static readonly RULE_tagList = 23; - public static readonly RULE_signalDeclaration = 24; - public static readonly RULE_varDefinition = 25; - public static readonly RULE_varDeclaration = 26; - public static readonly RULE_rhsValue = 27; - public static readonly RULE_componentCall = 28; - public static readonly RULE_blockInstantiation = 29; - public static readonly RULE_expressionList = 30; - public static readonly RULE_identifier = 31; - public static readonly RULE_arrayDimension = 32; - public static readonly RULE_args = 33; - public static readonly RULE_argsWithUnderscore = 34; - public static readonly RULE_numSequence = 35; + public static readonly RULE_signalHeader = 1; + public static readonly RULE_busHeader = 2; + public static readonly RULE_pragmaDefinition = 3; + public static readonly RULE_includeDefinition = 4; + public static readonly RULE_blockDefiniton = 5; + public static readonly RULE_functionDefinition = 6; + public static readonly RULE_templateDefinition = 7; + public static readonly RULE_busDefinition = 8; + public static readonly RULE_publicInputsDefinition = 9; + public static readonly RULE_tagDefinition = 10; + public static readonly RULE_logDefinition = 11; + public static readonly RULE_assertDefinition = 12; + public static readonly RULE_declarations = 13; + public static readonly RULE_varDeclaration = 14; + public static readonly RULE_signalDeclaration = 15; + public static readonly RULE_componentDeclaration = 16; + public static readonly RULE_busDeclaration = 17; + public static readonly RULE_componentMainDeclaration = 18; + public static readonly RULE_body = 19; + public static readonly RULE_statements = 20; + public static readonly RULE_ifStatements = 21; + public static readonly RULE_regularStatements = 22; + public static readonly RULE_cycleStatements = 23; + public static readonly RULE_substitutions = 24; + public static readonly RULE_expressionList = 25; + public static readonly RULE_expressionListWithNames = 26; + public static readonly RULE_expression = 27; + public static readonly RULE_primaryExpression = 28; + public static readonly RULE_assignmentExpression = 29; + public static readonly RULE_varIdentifier = 30; + public static readonly RULE_varIdentifierList = 31; + public static readonly RULE_signalIdentifier = 32; + public static readonly RULE_signalIdentifierList = 33; + public static readonly RULE_identifierStatement = 34; + public static readonly RULE_identifier = 35; + public static readonly RULE_identifierList = 36; + public static readonly RULE_simpleIdentifierList = 37; + public static readonly RULE_idetifierAccess = 38; + public static readonly RULE_arrayDimension = 39; + public static readonly RULE_identifierReferance = 40; + public static readonly RULE_expressionOrString = 41; + public static readonly RULE_expressionOrStringList = 42; public static readonly literalNames: (string | null)[] = [ null, null, @@ -150,6 +160,7 @@ export default class CircomParser extends Parser { "'include'", "'custom'", "'parallel'", + "'bus'", "'template'", "'function'", "'main'", @@ -180,8 +191,10 @@ export default class CircomParser extends Parser { "'?'", "':'", "'==='", - null, - null, + "'<=='", + "'<--'", + "'==>'", + "'-->'", null, "'!'", "'~'", @@ -217,6 +230,7 @@ export default class CircomParser extends Parser { "INCLUDE", "CUSTOM", "PARALLEL", + "BUS", "TEMPLATE", "FUNCTION", "MAIN", @@ -248,7 +262,9 @@ export default class CircomParser extends Parser { "TERNARY_ALTERNATIVE", "EQ_CONSTRAINT", "LEFT_CONSTRAINT", + "LEFT_ASSIGNMENT", "RIGHT_CONSTRAINT", + "RIGHT_ASSIGNMENT", "SELF_OP", "NOT", "BNOT", @@ -285,41 +301,48 @@ export default class CircomParser extends Parser { // tslint:disable:no-trailing-whitespace public static readonly ruleNames: string[] = [ "circuit", - "pragmaDeclaration", - "includeDeclaration", - "blockDeclaration", - "functionDeclaration", - "functionBlock", - "functionStmt", - "templateDeclaration", - "templateBlock", - "componentMainDeclaration", - "publicInputsList", - "templateStmt", - "element", - "forControl", - "forInit", - "forUpdate", - "parExpression", - "expression", - "primary", - "logStmt", - "componentDefinition", - "componentDeclaration", - "signalDefinition", - "tagList", - "signalDeclaration", - "varDefinition", + "signalHeader", + "busHeader", + "pragmaDefinition", + "includeDefinition", + "blockDefiniton", + "functionDefinition", + "templateDefinition", + "busDefinition", + "publicInputsDefinition", + "tagDefinition", + "logDefinition", + "assertDefinition", + "declarations", "varDeclaration", - "rhsValue", - "componentCall", - "blockInstantiation", + "signalDeclaration", + "componentDeclaration", + "busDeclaration", + "componentMainDeclaration", + "body", + "statements", + "ifStatements", + "regularStatements", + "cycleStatements", + "substitutions", "expressionList", + "expressionListWithNames", + "expression", + "primaryExpression", + "assignmentExpression", + "varIdentifier", + "varIdentifierList", + "signalIdentifier", + "signalIdentifierList", + "identifierStatement", "identifier", + "identifierList", + "simpleIdentifierList", + "idetifierAccess", "arrayDimension", - "args", - "argsWithUnderscore", - "numSequence", + "identifierReferance", + "expressionOrString", + "expressionOrStringList", ]; public get grammarFileName(): string { return "CircomParser.g4"; @@ -365,59 +388,59 @@ export default class CircomParser extends Parser { try { this.enterOuterAlt(localctx, 1); { - this.state = 75; + this.state = 89; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === 3) { { { - this.state = 72; - this.pragmaDeclaration(); + this.state = 86; + this.pragmaDefinition(); } } - this.state = 77; + this.state = 91; this._errHandler.sync(this); _la = this._input.LA(1); } - this.state = 81; + this.state = 95; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === 6) { { { - this.state = 78; - this.includeDeclaration(); + this.state = 92; + this.includeDefinition(); } } - this.state = 83; + this.state = 97; this._errHandler.sync(this); _la = this._input.LA(1); } - this.state = 87; + this.state = 101; this._errHandler.sync(this); _la = this._input.LA(1); - while (_la === 9 || _la === 10) { + while ((_la & ~0x1f) === 0 && ((1 << _la) & 3584) !== 0) { { { - this.state = 84; - this.blockDeclaration(); + this.state = 98; + this.blockDefiniton(); } } - this.state = 89; + this.state = 103; this._errHandler.sync(this); _la = this._input.LA(1); } - this.state = 91; + this.state = 105; this._errHandler.sync(this); _la = this._input.LA(1); - if (_la === 13) { + if (_la === 14) { { - this.state = 90; + this.state = 104; this.componentMainDeclaration(); } } - this.state = 93; + this.state = 107; this.match(CircomParser.EOF); } } catch (re) { @@ -434,38 +457,278 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public pragmaDeclaration(): PragmaDeclarationContext { - let localctx: PragmaDeclarationContext = new PragmaDeclarationContext( + public signalHeader(): SignalHeaderContext { + let localctx: SignalHeaderContext = new SignalHeaderContext( + this, + this._ctx, + this.state, + ); + this.enterRule(localctx, 2, CircomParser.RULE_signalHeader); + let _la: number; + try { + this.state = 121; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case 16: + this.enterOuterAlt(localctx, 1); + { + this.state = 109; + this.match(CircomParser.SIGNAL); + this.state = 111; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 2) { + { + this.state = 110; + this.match(CircomParser.SIGNAL_TYPE); + } + } + + this.state = 114; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 31) { + { + this.state = 113; + this.tagDefinition(); + } + } + } + break; + case 2: + this.enterOuterAlt(localctx, 2); + { + this.state = 116; + this.match(CircomParser.SIGNAL_TYPE); + this.state = 117; + this.match(CircomParser.SIGNAL); + this.state = 119; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 31) { + { + this.state = 118; + this.tagDefinition(); + } + } + } + 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 busHeader(): BusHeaderContext { + let localctx: BusHeaderContext = new BusHeaderContext( + this, + this._ctx, + this.state, + ); + this.enterRule(localctx, 4, CircomParser.RULE_busHeader); + let _la: number; + try { + this.state = 157; + this._errHandler.sync(this); + switch (this._interp.adaptivePredict(this._input, 16, this._ctx)) { + case 1: + this.enterOuterAlt(localctx, 1); + { + this.state = 123; + this.match(CircomParser.ID); + this.state = 125; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 2) { + { + this.state = 124; + localctx._wireType = this.match(CircomParser.SIGNAL_TYPE); + } + } + + this.state = 128; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 31) { + { + this.state = 127; + this.tagDefinition(); + } + } + } + break; + case 2: + this.enterOuterAlt(localctx, 2); + { + this.state = 130; + this.match(CircomParser.ID); + this.state = 131; + this.match(CircomParser.LP); + this.state = 133; + this._errHandler.sync(this); + _la = this._input.LA(1); + if ( + (((_la - 8) & ~0x1f) === 0 && + ((1 << (_la - 8)) & 271056897) !== 0) || + (((_la - 45) & ~0x1f) === 0 && + ((1 << (_la - 45)) & 50331907) !== 0) + ) { + { + this.state = 132; + localctx._parameters = this.expressionList(); + } + } + + this.state = 135; + this.match(CircomParser.RP); + this.state = 137; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 2) { + { + this.state = 136; + localctx._wireType = this.match(CircomParser.SIGNAL_TYPE); + } + } + + this.state = 140; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 31) { + { + this.state = 139; + this.tagDefinition(); + } + } + } + break; + case 3: + this.enterOuterAlt(localctx, 3); + { + this.state = 142; + localctx._wireType = this.match(CircomParser.SIGNAL_TYPE); + this.state = 143; + this.match(CircomParser.ID); + this.state = 145; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 31) { + { + this.state = 144; + this.tagDefinition(); + } + } + } + break; + case 4: + this.enterOuterAlt(localctx, 4); + { + this.state = 147; + localctx._wireType = this.match(CircomParser.SIGNAL_TYPE); + this.state = 148; + this.match(CircomParser.ID); + this.state = 149; + this.match(CircomParser.LP); + this.state = 151; + this._errHandler.sync(this); + _la = this._input.LA(1); + if ( + (((_la - 8) & ~0x1f) === 0 && + ((1 << (_la - 8)) & 271056897) !== 0) || + (((_la - 45) & ~0x1f) === 0 && + ((1 << (_la - 45)) & 50331907) !== 0) + ) { + { + this.state = 150; + localctx._parameters = this.expressionList(); + } + } + + this.state = 153; + this.match(CircomParser.RP); + this.state = 155; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 31) { + { + this.state = 154; + this.tagDefinition(); + } + } + } + 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 pragmaDefinition(): PragmaDefinitionContext { + let localctx: PragmaDefinitionContext = new PragmaDefinitionContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 2, CircomParser.RULE_pragmaDeclaration); + this.enterRule(localctx, 6, CircomParser.RULE_pragmaDefinition); try { - this.state = 102; + this.state = 169; this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 4, this._ctx)) { + switch (this._interp.adaptivePredict(this._input, 17, this._ctx)) { case 1: + localctx = new PragmaVersionContext(this, localctx); this.enterOuterAlt(localctx, 1); { - this.state = 95; + this.state = 159; this.match(CircomParser.PRAGMA); - this.state = 96; + this.state = 160; this.match(CircomParser.CIRCOM); - this.state = 97; + this.state = 161; this.match(CircomParser.VERSION); - this.state = 98; + this.state = 162; this.match(CircomParser.SEMICOLON); } break; case 2: + localctx = new PragmaInvalidVersionContext(this, localctx); this.enterOuterAlt(localctx, 2); { - this.state = 99; + this.state = 163; + this.match(CircomParser.PRAGMA); + this.state = 164; + this.match(CircomParser.CIRCOM); + this.state = 165; + this.match(CircomParser.SEMICOLON); + } + break; + case 3: + localctx = new PragmaCustomTemplatesContext(this, localctx); + this.enterOuterAlt(localctx, 3); + { + this.state = 166; this.match(CircomParser.PRAGMA); - this.state = 100; + this.state = 167; this.match(CircomParser.CUSTOM_TEMPLATES); - this.state = 101; + this.state = 168; this.match(CircomParser.SEMICOLON); } break; @@ -484,21 +747,21 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public includeDeclaration(): IncludeDeclarationContext { - let localctx: IncludeDeclarationContext = new IncludeDeclarationContext( + public includeDefinition(): IncludeDefinitionContext { + let localctx: IncludeDefinitionContext = new IncludeDefinitionContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 4, CircomParser.RULE_includeDeclaration); + this.enterRule(localctx, 8, CircomParser.RULE_includeDefinition); try { this.enterOuterAlt(localctx, 1); { - this.state = 104; + this.state = 171; this.match(CircomParser.INCLUDE); - this.state = 105; + this.state = 172; this.match(CircomParser.STRING); - this.state = 106; + this.state = 173; this.match(CircomParser.SEMICOLON); } } catch (re) { @@ -515,29 +778,36 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public blockDeclaration(): BlockDeclarationContext { - let localctx: BlockDeclarationContext = new BlockDeclarationContext( + public blockDefiniton(): BlockDefinitonContext { + let localctx: BlockDefinitonContext = new BlockDefinitonContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 6, CircomParser.RULE_blockDeclaration); + this.enterRule(localctx, 10, CircomParser.RULE_blockDefiniton); try { - this.state = 110; + this.state = 178; this._errHandler.sync(this); switch (this._input.LA(1)) { - case 10: + case 11: this.enterOuterAlt(localctx, 1); { - this.state = 108; - this.functionDeclaration(); + this.state = 175; + this.functionDefinition(); } break; - case 9: + case 10: this.enterOuterAlt(localctx, 2); { - this.state = 109; - this.templateDeclaration(); + this.state = 176; + this.templateDefinition(); + } + break; + case 9: + this.enterOuterAlt(localctx, 3); + { + this.state = 177; + this.busDefinition(); } break; default: @@ -557,37 +827,37 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public functionDeclaration(): FunctionDeclarationContext { - let localctx: FunctionDeclarationContext = new FunctionDeclarationContext( + public functionDefinition(): FunctionDefinitionContext { + let localctx: FunctionDefinitionContext = new FunctionDefinitionContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 8, CircomParser.RULE_functionDeclaration); + this.enterRule(localctx, 12, CircomParser.RULE_functionDefinition); let _la: number; try { this.enterOuterAlt(localctx, 1); { - this.state = 112; + this.state = 180; this.match(CircomParser.FUNCTION); - this.state = 113; + this.state = 181; this.match(CircomParser.ID); - this.state = 114; + this.state = 182; this.match(CircomParser.LP); - this.state = 116; + this.state = 184; this._errHandler.sync(this); _la = this._input.LA(1); - if (_la === 66) { + if (_la === 69) { { - this.state = 115; - this.args(); + this.state = 183; + localctx._argNames = this.simpleIdentifierList(); } } - this.state = 118; + this.state = 186; this.match(CircomParser.RP); - this.state = 119; - this.functionBlock(); + this.state = 187; + this.body(); } } catch (re) { if (re instanceof RecognitionException) { @@ -603,38 +873,57 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public functionBlock(): FunctionBlockContext { - let localctx: FunctionBlockContext = new FunctionBlockContext( + public templateDefinition(): TemplateDefinitionContext { + let localctx: TemplateDefinitionContext = new TemplateDefinitionContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 10, CircomParser.RULE_functionBlock); + this.enterRule(localctx, 14, CircomParser.RULE_templateDefinition); let _la: number; try { this.enterOuterAlt(localctx, 1); { - this.state = 121; - this.match(CircomParser.LC); - this.state = 125; + this.state = 189; + this.match(CircomParser.TEMPLATE); + this.state = 191; this._errHandler.sync(this); _la = this._input.LA(1); - while ( - ((_la & ~0x1f) === 0 && ((1 << _la) & 1202995200) !== 0) || - _la === 66 - ) { + if (_la === 7) { { - { - this.state = 122; - this.functionStmt(); - } + this.state = 190; + this.match(CircomParser.CUSTOM); } - this.state = 127; - this._errHandler.sync(this); - _la = this._input.LA(1); } - this.state = 128; - this.match(CircomParser.RC); + + this.state = 194; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 8) { + { + this.state = 193; + this.match(CircomParser.PARALLEL); + } + } + + this.state = 196; + this.match(CircomParser.ID); + this.state = 197; + this.match(CircomParser.LP); + this.state = 199; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 69) { + { + this.state = 198; + localctx._argNames = this.simpleIdentifierList(); + } + } + + this.state = 201; + this.match(CircomParser.RP); + this.state = 202; + this.body(); } } catch (re) { if (re instanceof RecognitionException) { @@ -650,204 +939,37 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public functionStmt(): FunctionStmtContext { - let localctx: FunctionStmtContext = new FunctionStmtContext( + public busDefinition(): BusDefinitionContext { + let localctx: BusDefinitionContext = new BusDefinitionContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 12, CircomParser.RULE_functionStmt); + this.enterRule(localctx, 16, CircomParser.RULE_busDefinition); let _la: number; try { - this.state = 189; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 11, this._ctx)) { - case 1: - localctx = new FuncBlockContext(this, localctx); - this.enterOuterAlt(localctx, 1); + this.enterOuterAlt(localctx, 1); + { + this.state = 204; + this.match(CircomParser.BUS); + this.state = 205; + this.match(CircomParser.ID); + this.state = 206; + this.match(CircomParser.LP); + this.state = 208; + this._errHandler.sync(this); + _la = this._input.LA(1); + if (_la === 69) { { - this.state = 130; - this.functionBlock(); + this.state = 207; + localctx._argNames = this.simpleIdentifierList(); } - break; - case 2: - localctx = new FuncSelfOpContext(this, localctx); - this.enterOuterAlt(localctx, 2); - { - this.state = 131; - this.match(CircomParser.ID); - this.state = 135; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 28) { - { - { - this.state = 132; - this.arrayDimension(); - } - } - this.state = 137; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 138; - this.match(CircomParser.SELF_OP); - this.state = 139; - this.match(CircomParser.SEMICOLON); - } - break; - case 3: - localctx = new FuncVarDeclarationContext(this, localctx); - this.enterOuterAlt(localctx, 3); - { - this.state = 140; - this.varDeclaration(); - this.state = 141; - this.match(CircomParser.SEMICOLON); - } - break; - case 4: - localctx = new FuncAssignmentExpressionContext(this, localctx); - this.enterOuterAlt(localctx, 4); - { - this.state = 143; - this.identifier(); - this.state = 144; - _la = this._input.LA(1); - if (!(_la === 64 || _la === 65)) { - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 145; - this.expression(0); - this.state = 146; - this.match(CircomParser.SEMICOLON); - } - break; - case 5: - localctx = new FuncVariadicAssignmentContext(this, localctx); - this.enterOuterAlt(localctx, 5); - { - this.state = 148; - this.match(CircomParser.LP); - this.state = 149; - this.argsWithUnderscore(); - this.state = 150; - this.match(CircomParser.RP); - this.state = 151; - this.match(CircomParser.ASSIGNMENT); - this.state = 157; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 9, this._ctx)) { - case 1: - { - this.state = 152; - this.match(CircomParser.LP); - this.state = 153; - this.expressionList(); - this.state = 154; - this.match(CircomParser.RP); - } - break; - case 2: - { - this.state = 156; - this.expression(0); - } - break; - } - this.state = 159; - this.match(CircomParser.SEMICOLON); - } - break; - case 6: - localctx = new IfFuncStmtContext(this, localctx); - this.enterOuterAlt(localctx, 6); - { - this.state = 161; - this.match(CircomParser.IF); - this.state = 162; - this.parExpression(); - this.state = 163; - this.functionStmt(); - this.state = 166; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 10, this._ctx)) { - case 1: - { - this.state = 164; - this.match(CircomParser.ELSE); - this.state = 165; - this.functionStmt(); - } - break; - } - } - break; - case 7: - localctx = new WhileFuncStmtContext(this, localctx); - this.enterOuterAlt(localctx, 7); - { - this.state = 168; - this.match(CircomParser.WHILE); - this.state = 169; - this.parExpression(); - this.state = 170; - this.functionStmt(); - } - break; - case 8: - localctx = new ForFuncStmtContext(this, localctx); - this.enterOuterAlt(localctx, 8); - { - this.state = 172; - this.match(CircomParser.FOR); - this.state = 173; - this.match(CircomParser.LP); - this.state = 174; - this.forControl(); - this.state = 175; - this.match(CircomParser.RP); - this.state = 176; - this.functionStmt(); - } - break; - case 9: - localctx = new ReturnFuncStmtContext(this, localctx); - this.enterOuterAlt(localctx, 9); - { - this.state = 178; - this.match(CircomParser.RETURN); - this.state = 179; - this.expression(0); - this.state = 180; - this.match(CircomParser.SEMICOLON); - } - break; - case 10: - localctx = new AssertFuncStmtContext(this, localctx); - this.enterOuterAlt(localctx, 10); - { - this.state = 182; - this.match(CircomParser.ASSERT); - this.state = 183; - this.parExpression(); - this.state = 184; - this.match(CircomParser.SEMICOLON); - } - break; - case 11: - localctx = new LogFuncStmtContext(this, localctx); - this.enterOuterAlt(localctx, 11); - { - this.state = 186; - this.logStmt(); - this.state = 187; - this.match(CircomParser.SEMICOLON); - } - break; + } + + this.state = 210; + this.match(CircomParser.RP); + this.state = 211; + this.body(); } } catch (re) { if (re instanceof RecognitionException) { @@ -863,57 +985,25 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public templateDeclaration(): TemplateDeclarationContext { - let localctx: TemplateDeclarationContext = new TemplateDeclarationContext( - this, - this._ctx, - this.state, - ); - this.enterRule(localctx, 14, CircomParser.RULE_templateDeclaration); - let _la: number; + public publicInputsDefinition(): PublicInputsDefinitionContext { + let localctx: PublicInputsDefinitionContext = + new PublicInputsDefinitionContext(this, this._ctx, this.state); + this.enterRule(localctx, 18, CircomParser.RULE_publicInputsDefinition); try { this.enterOuterAlt(localctx, 1); { - this.state = 191; - this.match(CircomParser.TEMPLATE); - this.state = 193; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === 7) { - { - this.state = 192; - this.match(CircomParser.CUSTOM); - } - } - - this.state = 196; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === 8) { - { - this.state = 195; - this.match(CircomParser.PARALLEL); - } - } - - this.state = 198; - this.match(CircomParser.ID); - this.state = 199; - this.match(CircomParser.LP); - this.state = 201; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === 66) { - { - this.state = 200; - this.args(); - } - } - - this.state = 203; - this.match(CircomParser.RP); - this.state = 204; - this.templateBlock(); + this.state = 213; + this.match(CircomParser.LC); + this.state = 214; + this.match(CircomParser.PUBLIC); + this.state = 215; + this.match(CircomParser.LB); + this.state = 216; + localctx._publicInputs = this.simpleIdentifierList(); + this.state = 217; + this.match(CircomParser.RB); + this.state = 218; + this.match(CircomParser.RC); } } catch (re) { if (re instanceof RecognitionException) { @@ -929,37 +1019,21 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public templateBlock(): TemplateBlockContext { - let localctx: TemplateBlockContext = new TemplateBlockContext( + public tagDefinition(): TagDefinitionContext { + let localctx: TagDefinitionContext = new TagDefinitionContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 16, CircomParser.RULE_templateBlock); - let _la: number; + this.enterRule(localctx, 20, CircomParser.RULE_tagDefinition); try { this.enterOuterAlt(localctx, 1); { - this.state = 206; + this.state = 220; this.match(CircomParser.LC); - this.state = 210; - this._errHandler.sync(this); - _la = this._input.LA(1); - while ( - (((_la - 8) & ~0x1f) === 0 && ((1 << (_la - 8)) & 139834593) !== 0) || - (((_la - 42) & ~0x1f) === 0 && ((1 << (_la - 42)) & 50331907) !== 0) - ) { - { - { - this.state = 207; - this.templateStmt(); - } - } - this.state = 212; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 213; + this.state = 221; + localctx._values = this.simpleIdentifierList(); + this.state = 222; this.match(CircomParser.RC); } } catch (re) { @@ -976,51 +1050,36 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public componentMainDeclaration(): ComponentMainDeclarationContext { - let localctx: ComponentMainDeclarationContext = - new ComponentMainDeclarationContext(this, this._ctx, this.state); - this.enterRule(localctx, 18, CircomParser.RULE_componentMainDeclaration); + public logDefinition(): LogDefinitionContext { + let localctx: LogDefinitionContext = new LogDefinitionContext( + this, + this._ctx, + this.state, + ); + this.enterRule(localctx, 22, CircomParser.RULE_logDefinition); let _la: number; try { this.enterOuterAlt(localctx, 1); { - this.state = 215; - this.match(CircomParser.COMPONENT); - this.state = 216; - this.match(CircomParser.MAIN); - this.state = 218; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === 30) { - { - this.state = 217; - this.publicInputsList(); - } - } - - this.state = 220; - this.match(CircomParser.ASSIGNMENT); - this.state = 221; - this.match(CircomParser.ID); - this.state = 222; - this.match(CircomParser.LP); this.state = 224; + this.match(CircomParser.LOG); + this.state = 225; + this.match(CircomParser.LP); + this.state = 227; this._errHandler.sync(this); _la = this._input.LA(1); if ( - ((_la & ~0x1f) === 0 && ((1 << _la) & 335544576) !== 0) || - (((_la - 42) & ~0x1f) === 0 && ((1 << (_la - 42)) & 50331907) !== 0) + (((_la - 8) & ~0x1f) === 0 && ((1 << (_la - 8)) & 271056897) !== 0) || + (((_la - 45) & ~0x1f) === 0 && ((1 << (_la - 45)) & 184549635) !== 0) ) { { - this.state = 223; - this.expressionList(); + this.state = 226; + localctx._logArgs = this.expressionOrStringList(); } } - this.state = 226; + this.state = 229; this.match(CircomParser.RP); - this.state = 227; - this.match(CircomParser.SEMICOLON); } } catch (re) { if (re instanceof RecognitionException) { @@ -1036,28 +1095,24 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public publicInputsList(): PublicInputsListContext { - let localctx: PublicInputsListContext = new PublicInputsListContext( + public assertDefinition(): AssertDefinitionContext { + let localctx: AssertDefinitionContext = new AssertDefinitionContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 20, CircomParser.RULE_publicInputsList); + this.enterRule(localctx, 24, CircomParser.RULE_assertDefinition); try { this.enterOuterAlt(localctx, 1); { - this.state = 229; - this.match(CircomParser.LC); - this.state = 230; - this.match(CircomParser.PUBLIC); this.state = 231; - this.match(CircomParser.LB); + this.match(CircomParser.ASSERT); this.state = 232; - this.args(); + this.match(CircomParser.LP); this.state = 233; - this.match(CircomParser.RB); + localctx._assertArgs = this.expression(0); this.state = 234; - this.match(CircomParser.RC); + this.match(CircomParser.RP); } } catch (re) { if (re instanceof RecognitionException) { @@ -1073,421 +1128,43 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public templateStmt(): TemplateStmtContext { - let localctx: TemplateStmtContext = new TemplateStmtContext( + public declarations(): DeclarationsContext { + let localctx: DeclarationsContext = new DeclarationsContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 22, CircomParser.RULE_templateStmt); - let _la: number; + this.enterRule(localctx, 26, CircomParser.RULE_declarations); try { - this.state = 376; + this.state = 240; this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 26, this._ctx)) { + switch (this._interp.adaptivePredict(this._input, 25, this._ctx)) { case 1: this.enterOuterAlt(localctx, 1); { this.state = 236; - this.templateBlock(); + this.varDeclaration(); } break; case 2: this.enterOuterAlt(localctx, 2); { this.state = 237; - this.match(CircomParser.ID); - this.state = 241; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 28) { - { - { - this.state = 238; - this.arrayDimension(); - } - } - this.state = 243; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 244; - this.match(CircomParser.SELF_OP); - this.state = 245; - this.match(CircomParser.SEMICOLON); + this.signalDeclaration(); } break; case 3: this.enterOuterAlt(localctx, 3); { - this.state = 246; - this.varDeclaration(); - this.state = 247; - this.match(CircomParser.SEMICOLON); + this.state = 238; + this.componentDeclaration(); } break; case 4: this.enterOuterAlt(localctx, 4); { - this.state = 249; - this.signalDeclaration(); - this.state = 250; - this.match(CircomParser.SEMICOLON); - } - break; - case 5: - this.enterOuterAlt(localctx, 5); - { - this.state = 252; - this.componentDeclaration(); - this.state = 253; - this.match(CircomParser.SEMICOLON); - } - break; - case 6: - this.enterOuterAlt(localctx, 6); - { - this.state = 255; - this.blockInstantiation(); - this.state = 256; - this.match(CircomParser.SEMICOLON); - } - break; - case 7: - this.enterOuterAlt(localctx, 7); - { - this.state = 258; - this.identifier(); - this.state = 259; - this.match(CircomParser.ASSIGNMENT); - this.state = 260; - this.expression(0); - this.state = 261; - this.match(CircomParser.SEMICOLON); - } - break; - case 8: - this.enterOuterAlt(localctx, 8); - { - this.state = 263; - this.expression(0); - this.state = 264; - this.match(CircomParser.EQ_CONSTRAINT); - this.state = 265; - this.expression(0); - this.state = 266; - this.match(CircomParser.SEMICOLON); - } - break; - case 9: - this.enterOuterAlt(localctx, 9); - { - this.state = 268; - this.element(); - this.state = 269; - _la = this._input.LA(1); - if (!(_la === 39 || _la === 65)) { - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 270; - this.expression(0); - this.state = 271; - this.match(CircomParser.SEMICOLON); - } - break; - case 10: - this.enterOuterAlt(localctx, 10); - { - this.state = 273; - this.match(CircomParser.LP); - this.state = 274; - this.element(); - this.state = 279; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 34) { - { - { - this.state = 275; - this.match(CircomParser.COMMA); - this.state = 276; - this.element(); - } - } - this.state = 281; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 282; - this.match(CircomParser.RP); - this.state = 283; - this.match(CircomParser.LEFT_CONSTRAINT); - this.state = 284; - this.match(CircomParser.LP); - this.state = 285; - this.expression(0); - this.state = 290; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 34) { - { - { - this.state = 286; - this.match(CircomParser.COMMA); - this.state = 287; - this.expression(0); - } - } - this.state = 292; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 293; - this.match(CircomParser.RP); - this.state = 294; - this.match(CircomParser.SEMICOLON); - } - break; - case 11: - this.enterOuterAlt(localctx, 11); - { - this.state = 296; - this.expression(0); - this.state = 297; - this.match(CircomParser.RIGHT_CONSTRAINT); - this.state = 298; - this.element(); - this.state = 299; - this.match(CircomParser.SEMICOLON); - } - break; - case 12: - this.enterOuterAlt(localctx, 12); - { - this.state = 301; - this.expression(0); - this.state = 302; - this.match(CircomParser.RIGHT_CONSTRAINT); - this.state = 303; - this.match(CircomParser.LP); - this.state = 304; - this.element(); - this.state = 309; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 34) { - { - { - this.state = 305; - this.match(CircomParser.COMMA); - this.state = 306; - this.element(); - } - } - this.state = 311; - this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 312; - this.match(CircomParser.RP); - this.state = 313; - this.match(CircomParser.SEMICOLON); - } - break; - case 13: - this.enterOuterAlt(localctx, 13); - { - this.state = 315; - this.match(CircomParser.UNDERSCORE); - this.state = 316; - _la = this._input.LA(1); - if (!(_la === 39 || _la === 64)) { - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 319; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 22, this._ctx)) { - case 1: - { - this.state = 317; - this.expression(0); - } - break; - case 2: - { - this.state = 318; - this.blockInstantiation(); - } - break; - } - this.state = 321; - this.match(CircomParser.SEMICOLON); - } - break; - case 14: - this.enterOuterAlt(localctx, 14); - { - this.state = 325; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 23, this._ctx)) { - case 1: - { - this.state = 323; - this.expression(0); - } - break; - case 2: - { - this.state = 324; - this.blockInstantiation(); - } - break; - } - this.state = 327; - this.match(CircomParser.RIGHT_CONSTRAINT); - this.state = 328; - this.match(CircomParser.UNDERSCORE); - this.state = 329; - this.match(CircomParser.SEMICOLON); - } - break; - case 15: - this.enterOuterAlt(localctx, 15); - { - this.state = 331; - this.match(CircomParser.LP); - this.state = 332; - this.argsWithUnderscore(); - this.state = 333; - this.match(CircomParser.RP); - this.state = 334; - _la = this._input.LA(1); - if (!(_la === 39 || _la === 64)) { - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 341; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 24, this._ctx)) { - case 1: - { - this.state = 335; - this.match(CircomParser.LP); - this.state = 336; - this.expressionList(); - this.state = 337; - this.match(CircomParser.RP); - } - break; - case 2: - { - this.state = 339; - this.blockInstantiation(); - } - break; - case 3: - { - this.state = 340; - this.expression(0); - } - break; - } - this.state = 343; - this.match(CircomParser.SEMICOLON); - } - break; - case 16: - this.enterOuterAlt(localctx, 16); - { - this.state = 345; - this.blockInstantiation(); - this.state = 346; - this.match(CircomParser.RIGHT_CONSTRAINT); - this.state = 347; - this.match(CircomParser.LP); - this.state = 348; - this.argsWithUnderscore(); - this.state = 349; - this.match(CircomParser.RP); - this.state = 350; - this.match(CircomParser.SEMICOLON); - } - break; - case 17: - this.enterOuterAlt(localctx, 17); - { - this.state = 352; - this.match(CircomParser.IF); - this.state = 353; - this.parExpression(); - this.state = 354; - this.templateStmt(); - this.state = 357; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 25, this._ctx)) { - case 1: - { - this.state = 355; - this.match(CircomParser.ELSE); - this.state = 356; - this.templateStmt(); - } - break; - } - } - break; - case 18: - this.enterOuterAlt(localctx, 18); - { - this.state = 359; - this.match(CircomParser.WHILE); - this.state = 360; - this.parExpression(); - this.state = 361; - this.templateStmt(); - } - break; - case 19: - this.enterOuterAlt(localctx, 19); - { - this.state = 363; - this.match(CircomParser.FOR); - this.state = 364; - this.match(CircomParser.LP); - this.state = 365; - this.forControl(); - this.state = 366; - this.match(CircomParser.RP); - this.state = 367; - this.templateStmt(); - } - break; - case 20: - this.enterOuterAlt(localctx, 20); - { - this.state = 369; - this.match(CircomParser.ASSERT); - this.state = 370; - this.parExpression(); - this.state = 371; - this.match(CircomParser.SEMICOLON); - } - break; - case 21: - this.enterOuterAlt(localctx, 21); - { - this.state = 373; - this.logStmt(); - this.state = 374; - this.match(CircomParser.SEMICOLON); + this.state = 239; + this.busDeclaration(); } break; } @@ -1505,32 +1182,52 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public element(): ElementContext { - let localctx: ElementContext = new ElementContext( + public varDeclaration(): VarDeclarationContext { + let localctx: VarDeclarationContext = new VarDeclarationContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 24, CircomParser.RULE_element); + this.enterRule(localctx, 28, CircomParser.RULE_varDeclaration); let _la: number; try { - this.enterOuterAlt(localctx, 1); - { - { - this.state = 378; - this.identifier(); - this.state = 381; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === 33) { - { - this.state = 379; - this.match(CircomParser.DOT); - this.state = 380; - this.identifier(); + this.state = 251; + this._errHandler.sync(this); + switch (this._interp.adaptivePredict(this._input, 27, this._ctx)) { + case 1: + this.enterOuterAlt(localctx, 1); + { + this.state = 242; + this.match(CircomParser.VAR); + this.state = 243; + this.match(CircomParser.LP); + this.state = 244; + this.identifierList(); + this.state = 245; + this.match(CircomParser.RP); + this.state = 247; + this._errHandler.sync(this); + _la = this._input.LA(1); + if ( + ((_la - 40) & ~0x1f) === 0 && + ((1 << (_la - 40)) & 134217731) !== 0 + ) { + { + this.state = 246; + this.assignmentExpression(); + } } } - } + break; + case 2: + this.enterOuterAlt(localctx, 2); + { + this.state = 249; + this.match(CircomParser.VAR); + this.state = 250; + this.varIdentifierList(); + } + break; } } catch (re) { if (re instanceof RecognitionException) { @@ -1546,30 +1243,117 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public forControl(): ForControlContext { - let localctx: ForControlContext = new ForControlContext( + public signalDeclaration(): SignalDeclarationContext { + let localctx: SignalDeclarationContext = new SignalDeclarationContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 26, CircomParser.RULE_forControl); + this.enterRule(localctx, 30, CircomParser.RULE_signalDeclaration); + let _la: number; try { - this.enterOuterAlt(localctx, 1); - { - this.state = 383; - this.forInit(); - this.state = 384; - this.match(CircomParser.SEMICOLON); - this.state = 385; - this.expression(0); - this.state = 386; - this.match(CircomParser.SEMICOLON); - this.state = 387; - this.forUpdate(); - } - } catch (re) { - if (re instanceof RecognitionException) { - localctx.exception = re; + this.state = 263; + this._errHandler.sync(this); + switch (this._interp.adaptivePredict(this._input, 29, this._ctx)) { + case 1: + this.enterOuterAlt(localctx, 1); + { + this.state = 253; + this.signalHeader(); + this.state = 254; + this.match(CircomParser.LP); + this.state = 255; + this.identifierList(); + this.state = 256; + this.match(CircomParser.RP); + this.state = 258; + this._errHandler.sync(this); + _la = this._input.LA(1); + if ( + ((_la - 40) & ~0x1f) === 0 && + ((1 << (_la - 40)) & 134217731) !== 0 + ) { + { + this.state = 257; + this.assignmentExpression(); + } + } + } + break; + case 2: + this.enterOuterAlt(localctx, 2); + { + this.state = 260; + this.signalHeader(); + this.state = 261; + this.signalIdentifierList(); + } + 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 componentDeclaration(): ComponentDeclarationContext { + let localctx: ComponentDeclarationContext = new ComponentDeclarationContext( + this, + this._ctx, + this.state, + ); + this.enterRule(localctx, 32, CircomParser.RULE_componentDeclaration); + let _la: number; + try { + this.state = 274; + this._errHandler.sync(this); + switch (this._interp.adaptivePredict(this._input, 31, this._ctx)) { + case 1: + this.enterOuterAlt(localctx, 1); + { + this.state = 265; + this.match(CircomParser.COMPONENT); + this.state = 266; + this.match(CircomParser.LP); + this.state = 267; + this.identifierList(); + this.state = 268; + this.match(CircomParser.RP); + this.state = 270; + this._errHandler.sync(this); + _la = this._input.LA(1); + if ( + ((_la - 40) & ~0x1f) === 0 && + ((1 << (_la - 40)) & 134217731) !== 0 + ) { + { + this.state = 269; + this.assignmentExpression(); + } + } + } + break; + case 2: + this.enterOuterAlt(localctx, 2); + { + this.state = 272; + this.match(CircomParser.COMPONENT); + this.state = 273; + this.varIdentifierList(); + } + break; + } + } catch (re) { + if (re instanceof RecognitionException) { + localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { @@ -1581,40 +1365,125 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public forInit(): ForInitContext { - let localctx: ForInitContext = new ForInitContext( + public busDeclaration(): BusDeclarationContext { + let localctx: BusDeclarationContext = new BusDeclarationContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 28, CircomParser.RULE_forInit); + this.enterRule(localctx, 34, CircomParser.RULE_busDeclaration); + try { + this.enterOuterAlt(localctx, 1); + { + this.state = 276; + this.busHeader(); + this.state = 277; + this.signalIdentifierList(); + } + } 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 componentMainDeclaration(): ComponentMainDeclarationContext { + let localctx: ComponentMainDeclarationContext = + new ComponentMainDeclarationContext(this, this._ctx, this.state); + this.enterRule(localctx, 36, CircomParser.RULE_componentMainDeclaration); let _la: number; try { this.enterOuterAlt(localctx, 1); { - this.state = 390; + this.state = 279; + this.match(CircomParser.COMPONENT); + this.state = 280; + this.match(CircomParser.MAIN); + this.state = 282; this._errHandler.sync(this); _la = this._input.LA(1); - if (_la === 14) { + if (_la === 31) { { - this.state = 389; - this.match(CircomParser.VAR); + this.state = 281; + this.publicInputsDefinition(); } } - this.state = 392; - this.identifier(); - this.state = 395; + this.state = 284; + this.match(CircomParser.ASSIGNMENT); + this.state = 285; + this.match(CircomParser.ID); + this.state = 286; + this.match(CircomParser.LP); + this.state = 288; this._errHandler.sync(this); _la = this._input.LA(1); - if (_la === 64) { + if ( + (((_la - 8) & ~0x1f) === 0 && ((1 << (_la - 8)) & 271056897) !== 0) || + (((_la - 45) & ~0x1f) === 0 && ((1 << (_la - 45)) & 50331907) !== 0) + ) { { - this.state = 393; - this.match(CircomParser.ASSIGNMENT); - this.state = 394; - this.rhsValue(); + this.state = 287; + localctx._argValues = this.expressionList(); + } + } + + this.state = 290; + this.match(CircomParser.RP); + this.state = 291; + this.match(CircomParser.SEMICOLON); + } + } 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 body(): BodyContext { + let localctx: BodyContext = new BodyContext(this, this._ctx, this.state); + this.enterRule(localctx, 38, CircomParser.RULE_body); + let _la: number; + try { + this.enterOuterAlt(localctx, 1); + { + this.state = 293; + this.match(CircomParser.LC); + this.state = 297; + this._errHandler.sync(this); + _la = this._input.LA(1); + while ( + ((_la & ~0x1f) === 0 && ((1 << _la) & 2942943492) !== 0) || + (((_la - 36) & ~0x1f) === 0 && ((1 << (_la - 36)) & 132865) !== 0) || + _la === 69 || + _la === 70 + ) { + { + { + this.state = 294; + this.statements(); + } } + this.state = 299; + this._errHandler.sync(this); + _la = this._input.LA(1); } + this.state = 300; + this.match(CircomParser.RC); } } catch (re) { if (re instanceof RecognitionException) { @@ -1630,65 +1499,58 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public forUpdate(): ForUpdateContext { - let localctx: ForUpdateContext = new ForUpdateContext( + public statements(): StatementsContext { + let localctx: StatementsContext = new StatementsContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 30, CircomParser.RULE_forUpdate); - let _la: number; + this.enterRule(localctx, 40, CircomParser.RULE_statements); try { - this.state = 405; + this.state = 313; this._errHandler.sync(this); - switch (this._input.LA(1)) { - case 66: + switch (this._interp.adaptivePredict(this._input, 35, this._ctx)) { + case 1: this.enterOuterAlt(localctx, 1); { - this.state = 397; - this.match(CircomParser.ID); - this.state = 401; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case 41: - { - this.state = 398; - this.match(CircomParser.SELF_OP); - } - break; - case 64: - case 65: - { - { - this.state = 399; - _la = this._input.LA(1); - if (!(_la === 64 || _la === 65)) { - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 400; - this.expression(0); - } - } - break; - default: - throw new NoViableAltException(this); - } + this.state = 302; + this.declarations(); + this.state = 303; + this.match(CircomParser.SEMICOLON); } break; - case 41: + case 2: this.enterOuterAlt(localctx, 2); { - this.state = 403; - this.match(CircomParser.SELF_OP); - this.state = 404; - this.match(CircomParser.ID); + this.state = 305; + this.ifStatements(); + } + break; + case 3: + this.enterOuterAlt(localctx, 3); + { + this.state = 306; + this.regularStatements(); + } + break; + case 4: + this.enterOuterAlt(localctx, 4); + { + this.state = 307; + this.logDefinition(); + this.state = 308; + this.match(CircomParser.SEMICOLON); + } + break; + case 5: + this.enterOuterAlt(localctx, 5); + { + this.state = 310; + this.assertDefinition(); + this.state = 311; + this.match(CircomParser.SEMICOLON); } break; - default: - throw new NoViableAltException(this); } } catch (re) { if (re instanceof RecognitionException) { @@ -1704,22 +1566,91 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public parExpression(): ParExpressionContext { - let localctx: ParExpressionContext = new ParExpressionContext( + public ifStatements(): IfStatementsContext { + let localctx: IfStatementsContext = new IfStatementsContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 32, CircomParser.RULE_parExpression); + this.enterRule(localctx, 42, CircomParser.RULE_ifStatements); try { - this.enterOuterAlt(localctx, 1); - { - this.state = 407; - this.match(CircomParser.LP); - this.state = 408; - this.expression(0); - this.state = 409; - this.match(CircomParser.RP); + this.state = 343; + this._errHandler.sync(this); + switch (this._interp.adaptivePredict(this._input, 36, this._ctx)) { + case 1: + localctx = new IfWithFollowUpIfContext(this, localctx); + this.enterOuterAlt(localctx, 1); + { + this.state = 315; + this.match(CircomParser.IF); + this.state = 316; + this.match(CircomParser.LP); + this.state = 317; + (localctx as IfWithFollowUpIfContext)._cond = this.expression(0); + this.state = 318; + this.match(CircomParser.RP); + this.state = 319; + this.ifStatements(); + } + break; + case 2: + localctx = new IfRegularContext(this, localctx); + this.enterOuterAlt(localctx, 2); + { + this.state = 321; + this.match(CircomParser.IF); + this.state = 322; + this.match(CircomParser.LP); + this.state = 323; + (localctx as IfRegularContext)._cond = this.expression(0); + this.state = 324; + this.match(CircomParser.RP); + this.state = 325; + this.regularStatements(); + } + break; + case 3: + localctx = new IfRegularElseWithFollowUpIfContext(this, localctx); + this.enterOuterAlt(localctx, 3); + { + this.state = 327; + this.match(CircomParser.IF); + this.state = 328; + this.match(CircomParser.LP); + this.state = 329; + (localctx as IfRegularElseWithFollowUpIfContext)._cond = + this.expression(0); + this.state = 330; + this.match(CircomParser.RP); + this.state = 331; + this.regularStatements(); + this.state = 332; + this.match(CircomParser.ELSE); + this.state = 333; + this.ifStatements(); + } + break; + case 4: + localctx = new IfRegularElseRegularContext(this, localctx); + this.enterOuterAlt(localctx, 4); + { + this.state = 335; + this.match(CircomParser.IF); + this.state = 336; + this.match(CircomParser.LP); + this.state = 337; + (localctx as IfRegularElseRegularContext)._cond = + this.expression(0); + this.state = 338; + this.match(CircomParser.RP); + this.state = 339; + this.regularStatements(); + this.state = 340; + this.match(CircomParser.ELSE); + this.state = 341; + this.regularStatements(); + } + break; } } catch (re) { if (re instanceof RecognitionException) { @@ -1734,415 +1665,80 @@ export default class CircomParser extends Parser { } 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, - this._ctx, - _parentState, - ); - let _prevctx: ExpressionContext = localctx; - let _startState: number = 34; - this.enterRecursionRule(localctx, 34, CircomParser.RULE_expression, _p); - let _la: number; - try { - let _alt: number; - this.enterOuterAlt(localctx, 1); - { - this.state = 416; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 32, this._ctx)) { - case 1: - { - localctx = new PrimaryExpressionContext(this, localctx); - this._ctx = localctx; - _prevctx = localctx; - - this.state = 412; - this.primary(); - } - break; - case 2: - { - localctx = new BlockInstantiationExpressionContext( - this, - localctx, - ); - this._ctx = localctx; - _prevctx = localctx; - this.state = 413; - this.blockInstantiation(); - } - break; - case 3: - { - localctx = new UnaryExpressionContext(this, localctx); - this._ctx = localctx; - _prevctx = localctx; - this.state = 414; - (localctx as UnaryExpressionContext)._op = this._input.LT(1); - _la = this._input.LA(1); - if ( - !(((_la - 42) & ~0x1f) === 0 && ((1 << (_la - 42)) & 259) !== 0) - ) { - (localctx as UnaryExpressionContext)._op = - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 415; - this.expression(7); - } - break; - } - this._ctx.stop = this._input.LT(-1); - this.state = 450; - this._errHandler.sync(this); - _alt = this._interp.adaptivePredict(this._input, 35, this._ctx); - while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { - if (_alt === 1) { - if (this._parseListeners != null) { - this.triggerExitRuleEvent(); - } - _prevctx = localctx; - { - this.state = 448; - this._errHandler.sync(this); - switch ( - this._interp.adaptivePredict(this._input, 34, this._ctx) - ) { - case 1: - { - localctx = new BinaryExpressionContext( - this, - new ExpressionContext(this, _parentctx, _parentState), - ); - this.pushNewRecursionContext( - localctx, - _startState, - CircomParser.RULE_expression, - ); - this.state = 418; - if (!this.precpred(this._ctx, 6)) { - throw this.createFailedPredicateException( - "this.precpred(this._ctx, 6)", - ); - } - this.state = 419; - (localctx as BinaryExpressionContext)._op = - this._input.LT(1); - _la = this._input.LA(1); - if ( - !( - ((_la - 44) & ~0x1f) === 0 && - ((1 << (_la - 44)) & 31) !== 0 - ) - ) { - (localctx as BinaryExpressionContext)._op = - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 420; - this.expression(7); - } - break; - case 2: - { - localctx = new BinaryExpressionContext( - this, - new ExpressionContext(this, _parentctx, _parentState), - ); - this.pushNewRecursionContext( - localctx, - _startState, - CircomParser.RULE_expression, - ); - this.state = 421; - if (!this.precpred(this._ctx, 5)) { - throw this.createFailedPredicateException( - "this.precpred(this._ctx, 5)", - ); - } - this.state = 422; - (localctx as BinaryExpressionContext)._op = - this._input.LT(1); - _la = this._input.LA(1); - if (!(_la === 49 || _la === 50)) { - (localctx as BinaryExpressionContext)._op = - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 423; - this.expression(6); - } - break; - case 3: - { - localctx = new BinaryExpressionContext( - this, - new ExpressionContext(this, _parentctx, _parentState), - ); - this.pushNewRecursionContext( - localctx, - _startState, - CircomParser.RULE_expression, - ); - this.state = 424; - if (!this.precpred(this._ctx, 4)) { - throw this.createFailedPredicateException( - "this.precpred(this._ctx, 4)", - ); - } - this.state = 425; - (localctx as BinaryExpressionContext)._op = - this._input.LT(1); - _la = this._input.LA(1); - if (!(_la === 51 || _la === 52)) { - (localctx as BinaryExpressionContext)._op = - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 426; - this.expression(5); - } - break; - case 4: - { - localctx = new BinaryExpressionContext( - this, - new ExpressionContext(this, _parentctx, _parentState), - ); - this.pushNewRecursionContext( - localctx, - _startState, - CircomParser.RULE_expression, - ); - this.state = 427; - if (!this.precpred(this._ctx, 3)) { - throw this.createFailedPredicateException( - "this.precpred(this._ctx, 3)", - ); - } - this.state = 428; - (localctx as BinaryExpressionContext)._op = - this._input.LT(1); - _la = this._input.LA(1); - if ( - !( - ((_la - 53) & ~0x1f) === 0 && - ((1 << (_la - 53)) & 7) !== 0 - ) - ) { - (localctx as BinaryExpressionContext)._op = - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 429; - this.expression(4); - } - break; - case 5: - { - localctx = new BinaryExpressionContext( - this, - new ExpressionContext(this, _parentctx, _parentState), - ); - this.pushNewRecursionContext( - localctx, - _startState, - CircomParser.RULE_expression, - ); - this.state = 430; - if (!this.precpred(this._ctx, 2)) { - throw this.createFailedPredicateException( - "this.precpred(this._ctx, 2)", - ); - } - this.state = 431; - (localctx as BinaryExpressionContext)._op = - this._input.LT(1); - _la = this._input.LA(1); - if ( - !( - ((_la - 56) & ~0x1f) === 0 && - ((1 << (_la - 56)) & 255) !== 0 - ) - ) { - (localctx as BinaryExpressionContext)._op = - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 432; - this.expression(3); - } - break; - case 6: - { - localctx = new TernaryExpressionContext( - this, - new ExpressionContext(this, _parentctx, _parentState), - ); - this.pushNewRecursionContext( - localctx, - _startState, - CircomParser.RULE_expression, - ); - this.state = 433; - if (!this.precpred(this._ctx, 1)) { - throw this.createFailedPredicateException( - "this.precpred(this._ctx, 1)", - ); - } - this.state = 434; - this.match(CircomParser.TERNARY_CONDITION); - this.state = 435; - this.expression(0); - this.state = 436; - this.match(CircomParser.TERNARY_ALTERNATIVE); - this.state = 437; - this.expression(2); - } - break; - case 7: - { - localctx = new DotExpressionContext( - this, - new ExpressionContext(this, _parentctx, _parentState), - ); - this.pushNewRecursionContext( - localctx, - _startState, - CircomParser.RULE_expression, - ); - this.state = 439; - if (!this.precpred(this._ctx, 8)) { - throw this.createFailedPredicateException( - "this.precpred(this._ctx, 8)", - ); - } - this.state = 440; - this.match(CircomParser.DOT); - this.state = 441; - this.match(CircomParser.ID); - this.state = 446; - this._errHandler.sync(this); - switch ( - this._interp.adaptivePredict(this._input, 33, this._ctx) - ) { - case 1: - { - this.state = 442; - this.match(CircomParser.LB); - this.state = 443; - this.expression(0); - this.state = 444; - this.match(CircomParser.RB); - } - break; - } - } - break; - } - } - } - this.state = 452; - this._errHandler.sync(this); - _alt = this._interp.adaptivePredict(this._input, 35, 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 primary(): PrimaryContext { - let localctx: PrimaryContext = new PrimaryContext( + public regularStatements(): RegularStatementsContext { + let localctx: RegularStatementsContext = new RegularStatementsContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 36, CircomParser.RULE_primary); + this.enterRule(localctx, 44, CircomParser.RULE_regularStatements); try { - this.state = 465; + this.state = 362; this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 36, this._ctx)) { + switch (this._interp.adaptivePredict(this._input, 37, this._ctx)) { case 1: + localctx = new RStatementBodyContext(this, localctx); this.enterOuterAlt(localctx, 1); { - this.state = 453; - this.match(CircomParser.LP); - this.state = 454; - this.expression(0); - this.state = 455; - this.match(CircomParser.RP); + this.state = 345; + this.body(); } break; case 2: + localctx = new RStatementExpressionContext(this, localctx); this.enterOuterAlt(localctx, 2); { - this.state = 457; - this.match(CircomParser.LB); - this.state = 458; - this.expressionList(); - this.state = 459; - this.match(CircomParser.RB); + this.state = 346; + this.expression(0); + this.state = 347; + this.match(CircomParser.SEMICOLON); } break; case 3: + localctx = new RStatementSucstitutionsContext(this, localctx); this.enterOuterAlt(localctx, 3); { - this.state = 461; - this.match(CircomParser.NUMBER); + this.state = 349; + this.substitutions(); + this.state = 350; + this.match(CircomParser.SEMICOLON); } break; case 4: + localctx = new RStatementCyclesContext(this, localctx); this.enterOuterAlt(localctx, 4); { - this.state = 462; - this.identifier(); + this.state = 352; + this.cycleStatements(); } break; case 5: + localctx = new RStatementEqConstraintContext(this, localctx); this.enterOuterAlt(localctx, 5); { - this.state = 463; - this.args(); + this.state = 353; + (localctx as RStatementEqConstraintContext)._lhs = + this.expression(0); + this.state = 354; + this.match(CircomParser.EQ_CONSTRAINT); + this.state = 355; + (localctx as RStatementEqConstraintContext)._rhs = + this.expression(0); + this.state = 356; + this.match(CircomParser.SEMICOLON); } break; case 6: + localctx = new RStatementReturnContext(this, localctx); this.enterOuterAlt(localctx, 6); { - this.state = 464; - this.numSequence(); + this.state = 358; + this.match(CircomParser.RETURN); + this.state = 359; + (localctx as RStatementReturnContext)._value = this.expression(0); + this.state = 360; + this.match(CircomParser.SEMICOLON); } break; } @@ -2160,98 +1756,87 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public logStmt(): LogStmtContext { - let localctx: LogStmtContext = new LogStmtContext( + public cycleStatements(): CycleStatementsContext { + let localctx: CycleStatementsContext = new CycleStatementsContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 38, CircomParser.RULE_logStmt); - let _la: number; + this.enterRule(localctx, 46, CircomParser.RULE_cycleStatements); try { - this.enterOuterAlt(localctx, 1); - { - this.state = 467; - this.match(CircomParser.LOG); - this.state = 468; - this.match(CircomParser.LP); - this.state = 483; - this._errHandler.sync(this); - _la = this._input.LA(1); - if ( - ((_la & ~0x1f) === 0 && ((1 << _la) & 335544576) !== 0) || - (((_la - 42) & ~0x1f) === 0 && ((1 << (_la - 42)) & 184549635) !== 0) - ) { + this.state = 390; + this._errHandler.sync(this); + switch (this._interp.adaptivePredict(this._input, 38, this._ctx)) { + case 1: + localctx = new CycleForWithDeclarationContext(this, localctx); + this.enterOuterAlt(localctx, 1); { - this.state = 471; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case 69: - { - this.state = 469; - this.match(CircomParser.STRING); - } - break; - case 8: - case 26: - case 28: - case 42: - case 43: - case 50: - case 66: - case 67: - { - this.state = 470; - this.expression(0); - } - break; - default: - throw new NoViableAltException(this); - } - this.state = 480; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 34) { - { - { - this.state = 473; - this.match(CircomParser.COMMA); - this.state = 476; - this._errHandler.sync(this); - switch (this._input.LA(1)) { - case 69: - { - this.state = 474; - this.match(CircomParser.STRING); - } - break; - case 8: - case 26: - case 28: - case 42: - case 43: - case 50: - case 66: - case 67: - { - this.state = 475; - this.expression(0); - } - break; - default: - throw new NoViableAltException(this); - } - } - } - this.state = 482; - this._errHandler.sync(this); - _la = this._input.LA(1); - } + this.state = 364; + this.match(CircomParser.FOR); + this.state = 365; + this.match(CircomParser.LP); + this.state = 366; + this.declarations(); + this.state = 367; + this.match(CircomParser.SEMICOLON); + this.state = 368; + (localctx as CycleForWithDeclarationContext)._cond = + this.expression(0); + this.state = 369; + this.match(CircomParser.SEMICOLON); + this.state = 370; + (localctx as CycleForWithDeclarationContext)._step = + this.substitutions(); + this.state = 371; + this.match(CircomParser.RP); + this.state = 372; + (localctx as CycleForWithDeclarationContext)._forBody = + this.regularStatements(); } - } - - this.state = 485; - this.match(CircomParser.RP); + break; + case 2: + localctx = new CycleForWithoutDeclarationContext(this, localctx); + this.enterOuterAlt(localctx, 2); + { + this.state = 374; + this.match(CircomParser.FOR); + this.state = 375; + this.match(CircomParser.LP); + this.state = 376; + this.substitutions(); + this.state = 377; + this.match(CircomParser.SEMICOLON); + this.state = 378; + (localctx as CycleForWithoutDeclarationContext)._cond = + this.expression(0); + this.state = 379; + this.match(CircomParser.SEMICOLON); + this.state = 380; + (localctx as CycleForWithoutDeclarationContext)._step = + this.substitutions(); + this.state = 381; + this.match(CircomParser.RP); + this.state = 382; + (localctx as CycleForWithoutDeclarationContext)._forBody = + this.regularStatements(); + } + break; + case 3: + localctx = new CycleWhileContext(this, localctx); + this.enterOuterAlt(localctx, 3); + { + this.state = 384; + this.match(CircomParser.WHILE); + this.state = 385; + this.match(CircomParser.LP); + this.state = 386; + (localctx as CycleWhileContext)._cond = this.expression(0); + this.state = 387; + this.match(CircomParser.RP); + this.state = 388; + (localctx as CycleWhileContext)._stmt = this.regularStatements(); + } + break; } } catch (re) { if (re instanceof RecognitionException) { @@ -2267,20 +1852,110 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public componentDefinition(): ComponentDefinitionContext { - let localctx: ComponentDefinitionContext = new ComponentDefinitionContext( + public substitutions(): SubstitutionsContext { + let localctx: SubstitutionsContext = new SubstitutionsContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 40, CircomParser.RULE_componentDefinition); + this.enterRule(localctx, 48, CircomParser.RULE_substitutions); + let _la: number; try { - this.enterOuterAlt(localctx, 1); - { - this.state = 487; - this.match(CircomParser.COMPONENT); - this.state = 488; - this.match(CircomParser.ID); + this.state = 413; + this._errHandler.sync(this); + switch (this._interp.adaptivePredict(this._input, 39, this._ctx)) { + case 1: + localctx = new SubsLeftAssignmentContext(this, localctx); + this.enterOuterAlt(localctx, 1); + { + this.state = 392; + (localctx as SubsLeftAssignmentContext)._lhs = this.expression(0); + this.state = 393; + (localctx as SubsLeftAssignmentContext)._op = this._input.LT(1); + _la = this._input.LA(1); + if ( + !( + ((_la - 40) & ~0x1f) === 0 && + ((1 << (_la - 40)) & 134217731) !== 0 + ) + ) { + (localctx as SubsLeftAssignmentContext)._op = + this._errHandler.recoverInline(this); + } else { + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 394; + (localctx as SubsLeftAssignmentContext)._rhs = this.expression(0); + } + break; + case 2: + localctx = new SubsRightSimpleAssignmentContext(this, localctx); + this.enterOuterAlt(localctx, 2); + { + this.state = 396; + (localctx as SubsRightSimpleAssignmentContext)._lhs = + this.expression(0); + this.state = 397; + (localctx as SubsRightSimpleAssignmentContext)._op = this.match( + CircomParser.RIGHT_ASSIGNMENT, + ); + this.state = 398; + (localctx as SubsRightSimpleAssignmentContext)._variable = + this.expression(0); + } + break; + case 3: + localctx = new SubsRightConstrAssignmentContext(this, localctx); + this.enterOuterAlt(localctx, 3); + { + this.state = 400; + (localctx as SubsRightConstrAssignmentContext)._lhs = + this.expression(0); + this.state = 401; + (localctx as SubsRightConstrAssignmentContext)._op = this.match( + CircomParser.RIGHT_CONSTRAINT, + ); + this.state = 402; + (localctx as SubsRightConstrAssignmentContext)._variable = + this.expression(0); + } + break; + case 4: + localctx = new SubsAssignmentWithOperationContext(this, localctx); + this.enterOuterAlt(localctx, 4); + { + this.state = 404; + this.identifierStatement(); + this.state = 405; + (localctx as SubsAssignmentWithOperationContext)._op = this.match( + CircomParser.ASSIGNMENT_WITH_OP, + ); + this.state = 406; + (localctx as SubsAssignmentWithOperationContext)._rhs = + this.expression(0); + } + break; + case 5: + localctx = new SubsIcnDecOperationContext(this, localctx); + this.enterOuterAlt(localctx, 5); + { + this.state = 408; + this.identifierStatement(); + this.state = 409; + this.match(CircomParser.SELF_OP); + } + break; + case 6: + localctx = new SubsInvalidIcnDecOperationContext(this, localctx); + this.enterOuterAlt(localctx, 6); + { + this.state = 411; + this.match(CircomParser.SELF_OP); + this.state = 412; + this.identifierStatement(); + } + break; } } catch (re) { if (re instanceof RecognitionException) { @@ -2296,44 +1971,37 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public componentDeclaration(): ComponentDeclarationContext { - let localctx: ComponentDeclarationContext = new ComponentDeclarationContext( + public expressionList(): ExpressionListContext { + let localctx: ExpressionListContext = new ExpressionListContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 42, CircomParser.RULE_componentDeclaration); - let _la: number; + this.enterRule(localctx, 50, CircomParser.RULE_expressionList); try { + let _alt: number; this.enterOuterAlt(localctx, 1); { - this.state = 490; - this.componentDefinition(); - this.state = 494; + this.state = 420; this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 28) { - { + _alt = this._interp.adaptivePredict(this._input, 40, this._ctx); + while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { + if (_alt === 1) { { - this.state = 491; - this.arrayDimension(); + { + this.state = 415; + this.expression(0); + this.state = 416; + this.match(CircomParser.COMMA); + } } } - this.state = 496; + this.state = 422; this._errHandler.sync(this); - _la = this._input.LA(1); - } - this.state = 499; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === 64) { - { - this.state = 497; - this.match(CircomParser.ASSIGNMENT); - this.state = 498; - this.blockInstantiation(); - } + _alt = this._interp.adaptivePredict(this._input, 40, this._ctx); } + this.state = 423; + this.expression(0); } } catch (re) { if (re instanceof RecognitionException) { @@ -2349,41 +2017,64 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public signalDefinition(): SignalDefinitionContext { - let localctx: SignalDefinitionContext = new SignalDefinitionContext( - this, - this._ctx, - this.state, - ); - this.enterRule(localctx, 44, CircomParser.RULE_signalDefinition); + public expressionListWithNames(): ExpressionListWithNamesContext { + let localctx: ExpressionListWithNamesContext = + new ExpressionListWithNamesContext(this, this._ctx, this.state); + this.enterRule(localctx, 52, CircomParser.RULE_expressionListWithNames); let _la: number; try { + let _alt: number; this.enterOuterAlt(localctx, 1); { - this.state = 501; - this.match(CircomParser.SIGNAL); - this.state = 503; + this.state = 432; this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === 2) { - { - this.state = 502; - this.match(CircomParser.SIGNAL_TYPE); + _alt = this._interp.adaptivePredict(this._input, 41, this._ctx); + while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { + if (_alt === 1) { + { + { + this.state = 425; + this.match(CircomParser.ID); + this.state = 426; + localctx._ops = this._input.LT(1); + _la = this._input.LA(1); + if ( + !( + ((_la - 40) & ~0x1f) === 0 && + ((1 << (_la - 40)) & 134217731) !== 0 + ) + ) { + localctx._ops = this._errHandler.recoverInline(this); + } else { + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 427; + this.expression(0); + this.state = 428; + this.match(CircomParser.COMMA); + } + } } + this.state = 434; + this._errHandler.sync(this); + _alt = this._interp.adaptivePredict(this._input, 41, this._ctx); } - - this.state = 506; - this._errHandler.sync(this); + this.state = 435; + this.match(CircomParser.ID); + this.state = 436; + localctx._ops = this._input.LT(1); _la = this._input.LA(1); - if (_la === 30) { - { - this.state = 505; - this.tagList(); - } + if ( + !(((_la - 40) & ~0x1f) === 0 && ((1 << (_la - 40)) & 134217731) !== 0) + ) { + localctx._ops = this._errHandler.recoverInline(this); + } else { + this._errHandler.reportMatch(this); + this.consume(); } - - this.state = 508; - this.identifier(); + this.state = 437; + this.expression(0); } } catch (re) { if (re instanceof RecognitionException) { @@ -2398,156 +2089,403 @@ export default class CircomParser extends Parser { } return localctx; } + + public expression(): ExpressionContext; + public expression(_p: number): ExpressionContext; // @RuleVersion(0) - public tagList(): TagListContext { - let localctx: TagListContext = new TagListContext( - this, - this._ctx, - this.state, - ); - this.enterRule(localctx, 46, CircomParser.RULE_tagList); - try { - this.enterOuterAlt(localctx, 1); - { - this.state = 510; - this.match(CircomParser.LC); - this.state = 511; - this.args(); - this.state = 512; - this.match(CircomParser.RC); - } - } 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(); + public expression(_p?: number): ExpressionContext { + if (_p === undefined) { + _p = 0; } - return localctx; - } - // @RuleVersion(0) - public signalDeclaration(): SignalDeclarationContext { - let localctx: SignalDeclarationContext = new SignalDeclarationContext( + + let _parentctx: ParserRuleContext = this._ctx; + let _parentState: number = this.state; + let localctx: ExpressionContext = new ExpressionContext( this, this._ctx, - this.state, + _parentState, ); - this.enterRule(localctx, 48, CircomParser.RULE_signalDeclaration); + let _prevctx: ExpressionContext = localctx; + let _startState: number = 54; + this.enterRecursionRule(localctx, 54, CircomParser.RULE_expression, _p); let _la: number; try { - this.state = 527; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 47, this._ctx)) { - case 1: - this.enterOuterAlt(localctx, 1); - { - this.state = 514; - this.signalDefinition(); - this.state = 517; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === 39) { - { - this.state = 515; - this.match(CircomParser.LEFT_CONSTRAINT); - this.state = 516; - this.rhsValue(); - } + let _alt: number; + this.enterOuterAlt(localctx, 1); + { + this.state = 445; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case 27: + case 29: + case 36: + case 69: + case 70: + { + this.state = 440; + this.primaryExpression(); } - } - break; - case 2: - this.enterOuterAlt(localctx, 2); - { - this.state = 519; - this.signalDefinition(); - this.state = 524; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 34) { - { - { - this.state = 520; - this.match(CircomParser.COMMA); - this.state = 521; - this.identifier(); - } - } - this.state = 526; - this._errHandler.sync(this); + break; + case 45: + case 46: + case 53: + { + this.state = 441; + localctx._op = this._input.LT(1); _la = this._input.LA(1); + if ( + !(((_la - 45) & ~0x1f) === 0 && ((1 << (_la - 45)) & 259) !== 0) + ) { + localctx._op = this._errHandler.recoverInline(this); + } else { + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 442; + this.expression(13); } - } - 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 varDefinition(): VarDefinitionContext { - let localctx: VarDefinitionContext = new VarDefinitionContext( - this, - this._ctx, - this.state, - ); - this.enterRule(localctx, 50, CircomParser.RULE_varDefinition); - let _la: number; - try { - this.state = 543; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 49, this._ctx)) { - case 1: - this.enterOuterAlt(localctx, 1); - { - this.state = 529; - this.match(CircomParser.VAR); - this.state = 530; - this.identifier(); - } - break; - case 2: - this.enterOuterAlt(localctx, 2); - { - this.state = 531; - this.match(CircomParser.VAR); - this.state = 532; - this.match(CircomParser.LP); - this.state = 533; - this.identifier(); - this.state = 538; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 34) { - { - { - this.state = 534; - this.match(CircomParser.COMMA); - this.state = 535; - this.identifier(); - } - } - this.state = 540; + break; + case 8: + { + this.state = 443; + this.match(CircomParser.PARALLEL); + this.state = 444; + this.expression(1); + } + break; + default: + throw new NoViableAltException(this); + } + this._ctx.stop = this._input.LT(-1); + this.state = 485; + this._errHandler.sync(this); + _alt = this._interp.adaptivePredict(this._input, 44, this._ctx); + while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { + if (_alt === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + _prevctx = localctx; + { + this.state = 483; this._errHandler.sync(this); - _la = this._input.LA(1); + switch ( + this._interp.adaptivePredict(this._input, 43, this._ctx) + ) { + case 1: + { + localctx = new ExpressionContext( + this, + _parentctx, + _parentState, + ); + this.pushNewRecursionContext( + localctx, + _startState, + CircomParser.RULE_expression, + ); + this.state = 447; + if (!this.precpred(this._ctx, 12)) { + throw this.createFailedPredicateException( + "this.precpred(this._ctx, 12)", + ); + } + this.state = 448; + localctx._op = this.match(CircomParser.POW); + this.state = 449; + this.expression(13); + } + break; + case 2: + { + localctx = new ExpressionContext( + this, + _parentctx, + _parentState, + ); + this.pushNewRecursionContext( + localctx, + _startState, + CircomParser.RULE_expression, + ); + this.state = 450; + if (!this.precpred(this._ctx, 11)) { + throw this.createFailedPredicateException( + "this.precpred(this._ctx, 11)", + ); + } + this.state = 451; + localctx._op = this._input.LT(1); + _la = this._input.LA(1); + if ( + !( + ((_la - 48) & ~0x1f) === 0 && + ((1 << (_la - 48)) & 15) !== 0 + ) + ) { + localctx._op = this._errHandler.recoverInline(this); + } else { + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 452; + this.expression(12); + } + break; + case 3: + { + localctx = new ExpressionContext( + this, + _parentctx, + _parentState, + ); + this.pushNewRecursionContext( + localctx, + _startState, + CircomParser.RULE_expression, + ); + this.state = 453; + if (!this.precpred(this._ctx, 10)) { + throw this.createFailedPredicateException( + "this.precpred(this._ctx, 10)", + ); + } + this.state = 454; + localctx._op = this._input.LT(1); + _la = this._input.LA(1); + if (!(_la === 52 || _la === 53)) { + localctx._op = this._errHandler.recoverInline(this); + } else { + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 455; + this.expression(11); + } + break; + case 4: + { + localctx = new ExpressionContext( + this, + _parentctx, + _parentState, + ); + this.pushNewRecursionContext( + localctx, + _startState, + CircomParser.RULE_expression, + ); + this.state = 456; + if (!this.precpred(this._ctx, 9)) { + throw this.createFailedPredicateException( + "this.precpred(this._ctx, 9)", + ); + } + this.state = 457; + localctx._op = this._input.LT(1); + _la = this._input.LA(1); + if (!(_la === 54 || _la === 55)) { + localctx._op = this._errHandler.recoverInline(this); + } else { + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 458; + this.expression(10); + } + break; + case 5: + { + localctx = new ExpressionContext( + this, + _parentctx, + _parentState, + ); + this.pushNewRecursionContext( + localctx, + _startState, + CircomParser.RULE_expression, + ); + this.state = 459; + if (!this.precpred(this._ctx, 8)) { + throw this.createFailedPredicateException( + "this.precpred(this._ctx, 8)", + ); + } + this.state = 460; + localctx._op = this.match(CircomParser.BAND); + this.state = 461; + this.expression(9); + } + break; + case 6: + { + localctx = new ExpressionContext( + this, + _parentctx, + _parentState, + ); + this.pushNewRecursionContext( + localctx, + _startState, + CircomParser.RULE_expression, + ); + this.state = 462; + if (!this.precpred(this._ctx, 7)) { + throw this.createFailedPredicateException( + "this.precpred(this._ctx, 7)", + ); + } + this.state = 463; + localctx._op = this.match(CircomParser.BXOR); + this.state = 464; + this.expression(8); + } + break; + case 7: + { + localctx = new ExpressionContext( + this, + _parentctx, + _parentState, + ); + this.pushNewRecursionContext( + localctx, + _startState, + CircomParser.RULE_expression, + ); + this.state = 465; + if (!this.precpred(this._ctx, 6)) { + throw this.createFailedPredicateException( + "this.precpred(this._ctx, 6)", + ); + } + this.state = 466; + localctx._op = this.match(CircomParser.BOR); + this.state = 467; + this.expression(7); + } + break; + case 8: + { + localctx = new ExpressionContext( + this, + _parentctx, + _parentState, + ); + this.pushNewRecursionContext( + localctx, + _startState, + CircomParser.RULE_expression, + ); + this.state = 468; + if (!this.precpred(this._ctx, 5)) { + throw this.createFailedPredicateException( + "this.precpred(this._ctx, 5)", + ); + } + this.state = 469; + localctx._op = this._input.LT(1); + _la = this._input.LA(1); + if ( + !( + ((_la - 59) & ~0x1f) === 0 && + ((1 << (_la - 59)) & 63) !== 0 + ) + ) { + localctx._op = this._errHandler.recoverInline(this); + } else { + this._errHandler.reportMatch(this); + this.consume(); + } + this.state = 470; + this.expression(6); + } + break; + case 9: + { + localctx = new ExpressionContext( + this, + _parentctx, + _parentState, + ); + this.pushNewRecursionContext( + localctx, + _startState, + CircomParser.RULE_expression, + ); + this.state = 471; + if (!this.precpred(this._ctx, 4)) { + throw this.createFailedPredicateException( + "this.precpred(this._ctx, 4)", + ); + } + this.state = 472; + localctx._op = this.match(CircomParser.AND); + this.state = 473; + this.expression(5); + } + break; + case 10: + { + localctx = new ExpressionContext( + this, + _parentctx, + _parentState, + ); + this.pushNewRecursionContext( + localctx, + _startState, + CircomParser.RULE_expression, + ); + this.state = 474; + if (!this.precpred(this._ctx, 3)) { + throw this.createFailedPredicateException( + "this.precpred(this._ctx, 3)", + ); + } + this.state = 475; + localctx._op = this.match(CircomParser.OR); + this.state = 476; + this.expression(4); + } + break; + case 11: + { + localctx = new ExpressionContext( + this, + _parentctx, + _parentState, + ); + localctx._cond = _prevctx; + this.pushNewRecursionContext( + localctx, + _startState, + CircomParser.RULE_expression, + ); + this.state = 477; + if (!this.precpred(this._ctx, 2)) { + throw this.createFailedPredicateException( + "this.precpred(this._ctx, 2)", + ); + } + this.state = 478; + this.match(CircomParser.TERNARY_CONDITION); + this.state = 479; + localctx._ifTrue = this.expression(0); + this.state = 480; + this.match(CircomParser.TERNARY_ALTERNATIVE); + this.state = 481; + localctx._ifFalse = this.expression(3); + } + break; + } } - this.state = 541; - this.match(CircomParser.RP); } - break; + this.state = 487; + this._errHandler.sync(this); + _alt = this._interp.adaptivePredict(this._input, 44, this._ctx); + } } } catch (re) { if (re instanceof RecognitionException) { @@ -2558,232 +2496,142 @@ export default class CircomParser extends Parser { throw re; } } finally { - this.exitRule(); + this.unrollRecursionContexts(_parentctx); } return localctx; } // @RuleVersion(0) - public varDeclaration(): VarDeclarationContext { - let localctx: VarDeclarationContext = new VarDeclarationContext( + public primaryExpression(): PrimaryExpressionContext { + let localctx: PrimaryExpressionContext = new PrimaryExpressionContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 52, CircomParser.RULE_varDeclaration); + this.enterRule(localctx, 56, CircomParser.RULE_primaryExpression); let _la: number; try { - this.state = 558; + this.state = 517; this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 52, this._ctx)) { + switch (this._interp.adaptivePredict(this._input, 48, this._ctx)) { case 1: + localctx = new PIdentifierStatementContext(this, localctx); this.enterOuterAlt(localctx, 1); { - this.state = 545; - this.varDefinition(); - this.state = 548; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === 64) { - { - this.state = 546; - this.match(CircomParser.ASSIGNMENT); - this.state = 547; - this.rhsValue(); - } - } + this.state = 488; + this.identifierStatement(); } break; case 2: + localctx = new PUnderscoreContext(this, localctx); this.enterOuterAlt(localctx, 2); { - this.state = 550; - this.varDefinition(); - this.state = 555; - this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 34) { - { - { - this.state = 551; - this.match(CircomParser.COMMA); - this.state = 552; - this.identifier(); - } - } - this.state = 557; - this._errHandler.sync(this); - _la = this._input.LA(1); - } + this.state = 489; + this.match(CircomParser.UNDERSCORE); } 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 rhsValue(): RhsValueContext { - let localctx: RhsValueContext = new RhsValueContext( - this, - this._ctx, - this.state, - ); - this.enterRule(localctx, 54, CircomParser.RULE_rhsValue); - try { - this.state = 566; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 53, this._ctx)) { - case 1: - this.enterOuterAlt(localctx, 1); + case 3: + localctx = new PNumberContext(this, localctx); + this.enterOuterAlt(localctx, 3); { - this.state = 560; - this.match(CircomParser.LP); - this.state = 561; - this.expressionList(); - this.state = 562; - this.match(CircomParser.RP); + this.state = 490; + this.match(CircomParser.NUMBER); } break; - case 2: - this.enterOuterAlt(localctx, 2); + case 4: + localctx = new PParenthesesContext(this, localctx); + this.enterOuterAlt(localctx, 4); { - this.state = 564; - this.expression(0); + this.state = 491; + this.match(CircomParser.LP); + this.state = 492; + this.expressionList(); + this.state = 493; + this.match(CircomParser.RP); } break; - case 3: - this.enterOuterAlt(localctx, 3); + case 5: + localctx = new PArrayContext(this, localctx); + this.enterOuterAlt(localctx, 5); { - this.state = 565; - this.blockInstantiation(); + this.state = 495; + this.match(CircomParser.LB); + this.state = 496; + this.expressionList(); + this.state = 497; + this.match(CircomParser.RB); } 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 componentCall(): ComponentCallContext { - let localctx: ComponentCallContext = new ComponentCallContext( - this, - this._ctx, - this.state, - ); - this.enterRule(localctx, 56, CircomParser.RULE_componentCall); - let _la: number; - try { - this.state = 604; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 57, this._ctx)) { - case 1: - this.enterOuterAlt(localctx, 1); + case 6: + localctx = new PCallContext(this, localctx); + this.enterOuterAlt(localctx, 6); { - this.state = 568; + this.state = 499; + this.match(CircomParser.ID); + this.state = 500; this.match(CircomParser.LP); - this.state = 570; + this.state = 502; this._errHandler.sync(this); _la = this._input.LA(1); if ( - ((_la & ~0x1f) === 0 && ((1 << _la) & 335544576) !== 0) || - (((_la - 42) & ~0x1f) === 0 && - ((1 << (_la - 42)) & 50331907) !== 0) + (((_la - 8) & ~0x1f) === 0 && + ((1 << (_la - 8)) & 271056897) !== 0) || + (((_la - 45) & ~0x1f) === 0 && + ((1 << (_la - 45)) & 50331907) !== 0) ) { { - this.state = 569; + this.state = 501; this.expressionList(); } } - this.state = 572; + this.state = 504; this.match(CircomParser.RP); } break; - case 2: - this.enterOuterAlt(localctx, 2); + case 7: + localctx = new PAnonymousCallContext(this, localctx); + this.enterOuterAlt(localctx, 7); { - this.state = 573; - this.match(CircomParser.LP); - this.state = 574; + this.state = 505; this.match(CircomParser.ID); - this.state = 575; - this.match(CircomParser.LEFT_CONSTRAINT); - this.state = 576; - this.expression(0); - this.state = 583; + this.state = 506; + this.match(CircomParser.LP); + this.state = 508; this._errHandler.sync(this); _la = this._input.LA(1); - while (_la === 34) { + if ( + (((_la - 8) & ~0x1f) === 0 && + ((1 << (_la - 8)) & 271056897) !== 0) || + (((_la - 45) & ~0x1f) === 0 && + ((1 << (_la - 45)) & 50331907) !== 0) + ) { { - { - this.state = 577; - this.match(CircomParser.COMMA); - this.state = 578; - this.match(CircomParser.ID); - this.state = 579; - this.match(CircomParser.LEFT_CONSTRAINT); - this.state = 580; - this.expression(0); - } + this.state = 507; + this.expressionList(); } - this.state = 585; - this._errHandler.sync(this); - _la = this._input.LA(1); } - this.state = 586; + + this.state = 510; this.match(CircomParser.RP); - } - break; - case 3: - this.enterOuterAlt(localctx, 3); - { - this.state = 588; + this.state = 511; this.match(CircomParser.LP); - this.state = 589; - this.expression(0); - this.state = 590; - this.match(CircomParser.RIGHT_CONSTRAINT); - this.state = 591; - this.match(CircomParser.ID); - this.state = 599; + this.state = 514; this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 34) { - { + switch (this._interp.adaptivePredict(this._input, 47, this._ctx)) { + case 1: + { + this.state = 512; + this.expressionList(); + } + break; + case 2: { - this.state = 592; - this.match(CircomParser.COMMA); - this.state = 593; - this.expression(0); - this.state = 594; - this.match(CircomParser.RIGHT_CONSTRAINT); - this.state = 595; - this.match(CircomParser.ID); + this.state = 513; + this.expressionListWithNames(); } - } - this.state = 601; - this._errHandler.sync(this); - _la = this._input.LA(1); + break; } - this.state = 602; + this.state = 516; this.match(CircomParser.RP); } break; @@ -2802,56 +2650,49 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public blockInstantiation(): BlockInstantiationContext { - let localctx: BlockInstantiationContext = new BlockInstantiationContext( + public assignmentExpression(): AssignmentExpressionContext { + let localctx: AssignmentExpressionContext = new AssignmentExpressionContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 58, CircomParser.RULE_blockInstantiation); - let _la: number; + this.enterRule(localctx, 58, CircomParser.RULE_assignmentExpression); try { - this.enterOuterAlt(localctx, 1); - { - this.state = 607; - this._errHandler.sync(this); - _la = this._input.LA(1); - if (_la === 8) { + this.state = 525; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case 40: + localctx = new AssignExprConstraintContext(this, localctx); + this.enterOuterAlt(localctx, 1); { - this.state = 606; - this.match(CircomParser.PARALLEL); + this.state = 519; + this.match(CircomParser.LEFT_CONSTRAINT); + this.state = 520; + (localctx as AssignExprConstraintContext)._rhs = this.expression(0); } - } - - this.state = 609; - this.match(CircomParser.ID); - this.state = 610; - this.match(CircomParser.LP); - this.state = 612; - this._errHandler.sync(this); - _la = this._input.LA(1); - if ( - ((_la & ~0x1f) === 0 && ((1 << _la) & 335544576) !== 0) || - (((_la - 42) & ~0x1f) === 0 && ((1 << (_la - 42)) & 50331907) !== 0) - ) { + break; + case 41: + localctx = new AssignExprSimpleContext(this, localctx); + this.enterOuterAlt(localctx, 2); { - this.state = 611; - this.expressionList(); + this.state = 521; + this.match(CircomParser.LEFT_ASSIGNMENT); + this.state = 522; + (localctx as AssignExprSimpleContext)._rhs = this.expression(0); } - } - - this.state = 614; - this.match(CircomParser.RP); - this.state = 616; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 60, this._ctx)) { - case 1: - { - this.state = 615; - this.componentCall(); - } - break; - } + break; + case 67: + localctx = new AssignExprRegularContext(this, localctx); + this.enterOuterAlt(localctx, 3); + { + this.state = 523; + this.match(CircomParser.ASSIGNMENT); + this.state = 524; + (localctx as AssignExprRegularContext)._rhs = this.expression(0); + } + break; + default: + throw new NoViableAltException(this); } } catch (re) { if (re instanceof RecognitionException) { @@ -2867,34 +2708,29 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public expressionList(): ExpressionListContext { - let localctx: ExpressionListContext = new ExpressionListContext( + public varIdentifier(): VarIdentifierContext { + let localctx: VarIdentifierContext = new VarIdentifierContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 60, CircomParser.RULE_expressionList); + this.enterRule(localctx, 60, CircomParser.RULE_varIdentifier); let _la: number; try { this.enterOuterAlt(localctx, 1); { - this.state = 618; - this.expression(0); - this.state = 623; + this.state = 527; + this.identifier(); + this.state = 530; this._errHandler.sync(this); _la = this._input.LA(1); - while (_la === 34) { + if (_la === 67) { { - { - this.state = 619; - this.match(CircomParser.COMMA); - this.state = 620; - this.expression(0); - } + this.state = 528; + this.match(CircomParser.ASSIGNMENT); + this.state = 529; + localctx._rhs = this.expression(0); } - this.state = 625; - this._errHandler.sync(this); - _la = this._input.LA(1); } } } catch (re) { @@ -2911,63 +2747,37 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public identifier(): IdentifierContext { - let localctx: IdentifierContext = new IdentifierContext( + public varIdentifierList(): VarIdentifierListContext { + let localctx: VarIdentifierListContext = new VarIdentifierListContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 62, CircomParser.RULE_identifier); + this.enterRule(localctx, 62, CircomParser.RULE_varIdentifierList); try { let _alt: number; this.enterOuterAlt(localctx, 1); { - this.state = 626; - this.match(CircomParser.ID); - this.state = 630; - this._errHandler.sync(this); - _alt = this._interp.adaptivePredict(this._input, 62, this._ctx); - while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { - if (_alt === 1) { - { - { - this.state = 627; - this.arrayDimension(); - } - } - } - this.state = 632; - this._errHandler.sync(this); - _alt = this._interp.adaptivePredict(this._input, 62, this._ctx); - } - this.state = 635; - this._errHandler.sync(this); - switch (this._interp.adaptivePredict(this._input, 63, this._ctx)) { - case 1: - { - this.state = 633; - this.match(CircomParser.DOT); - this.state = 634; - this.match(CircomParser.ID); - } - break; - } - this.state = 640; + this.state = 537; this._errHandler.sync(this); - _alt = this._interp.adaptivePredict(this._input, 64, this._ctx); + _alt = this._interp.adaptivePredict(this._input, 51, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { { { - this.state = 637; - this.arrayDimension(); + this.state = 532; + this.varIdentifier(); + this.state = 533; + this.match(CircomParser.COMMA); } } } - this.state = 642; + this.state = 539; this._errHandler.sync(this); - _alt = this._interp.adaptivePredict(this._input, 64, this._ctx); + _alt = this._interp.adaptivePredict(this._input, 51, this._ctx); } + this.state = 540; + this.varIdentifier(); } } catch (re) { if (re instanceof RecognitionException) { @@ -2983,22 +2793,46 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public arrayDimension(): ArrayDimensionContext { - let localctx: ArrayDimensionContext = new ArrayDimensionContext( + public signalIdentifier(): SignalIdentifierContext { + let localctx: SignalIdentifierContext = new SignalIdentifierContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 64, CircomParser.RULE_arrayDimension); + this.enterRule(localctx, 64, CircomParser.RULE_signalIdentifier); try { - this.enterOuterAlt(localctx, 1); - { - this.state = 643; - this.match(CircomParser.LB); - this.state = 644; - this.expression(0); - this.state = 645; - this.match(CircomParser.RB); + this.state = 551; + this._errHandler.sync(this); + switch (this._interp.adaptivePredict(this._input, 52, this._ctx)) { + case 1: + this.enterOuterAlt(localctx, 1); + { + this.state = 542; + this.identifier(); + } + break; + case 2: + this.enterOuterAlt(localctx, 2); + { + this.state = 543; + this.identifier(); + this.state = 544; + this.match(CircomParser.LEFT_ASSIGNMENT); + this.state = 545; + localctx._rhs = this.expression(0); + } + break; + case 3: + this.enterOuterAlt(localctx, 3); + { + this.state = 547; + this.identifier(); + this.state = 548; + this.match(CircomParser.LEFT_CONSTRAINT); + this.state = 549; + localctx._rhs = this.expression(0); + } + break; } } catch (re) { if (re instanceof RecognitionException) { @@ -3014,33 +2848,37 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public args(): ArgsContext { - let localctx: ArgsContext = new ArgsContext(this, this._ctx, this.state); - this.enterRule(localctx, 66, CircomParser.RULE_args); + public signalIdentifierList(): SignalIdentifierListContext { + let localctx: SignalIdentifierListContext = new SignalIdentifierListContext( + this, + this._ctx, + this.state, + ); + this.enterRule(localctx, 66, CircomParser.RULE_signalIdentifierList); try { let _alt: number; this.enterOuterAlt(localctx, 1); { - this.state = 647; - this.match(CircomParser.ID); - this.state = 652; + this.state = 558; this._errHandler.sync(this); - _alt = this._interp.adaptivePredict(this._input, 65, this._ctx); + _alt = this._interp.adaptivePredict(this._input, 53, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { { { - this.state = 648; + this.state = 553; + this.signalIdentifier(); + this.state = 554; this.match(CircomParser.COMMA); - this.state = 649; - this.match(CircomParser.ID); } } } - this.state = 654; + this.state = 560; this._errHandler.sync(this); - _alt = this._interp.adaptivePredict(this._input, 65, this._ctx); + _alt = this._interp.adaptivePredict(this._input, 53, this._ctx); } + this.state = 561; + this.signalIdentifier(); } } catch (re) { if (re instanceof RecognitionException) { @@ -3056,46 +2894,34 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public argsWithUnderscore(): ArgsWithUnderscoreContext { - let localctx: ArgsWithUnderscoreContext = new ArgsWithUnderscoreContext( + public identifierStatement(): IdentifierStatementContext { + let localctx: IdentifierStatementContext = new IdentifierStatementContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 68, CircomParser.RULE_argsWithUnderscore); - let _la: number; + this.enterRule(localctx, 68, CircomParser.RULE_identifierStatement); try { + let _alt: number; this.enterOuterAlt(localctx, 1); { - this.state = 655; - _la = this._input.LA(1); - if (!(_la === 35 || _la === 66)) { - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); - } - this.state = 660; + this.state = 563; + this.match(CircomParser.ID); + this.state = 567; this._errHandler.sync(this); - _la = this._input.LA(1); - while (_la === 34) { - { + _alt = this._interp.adaptivePredict(this._input, 54, this._ctx); + while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { + if (_alt === 1) { { - this.state = 656; - this.match(CircomParser.COMMA); - this.state = 657; - _la = this._input.LA(1); - if (!(_la === 35 || _la === 66)) { - this._errHandler.recoverInline(this); - } else { - this._errHandler.reportMatch(this); - this.consume(); + { + this.state = 564; + this.idetifierAccess(); } } } - this.state = 662; + this.state = 569; this._errHandler.sync(this); - _la = this._input.LA(1); + _alt = this._interp.adaptivePredict(this._input, 54, this._ctx); } } } catch (re) { @@ -3112,37 +2938,320 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public numSequence(): NumSequenceContext { - let localctx: NumSequenceContext = new NumSequenceContext( - this, + public identifier(): IdentifierContext { + let localctx: IdentifierContext = new IdentifierContext( + this, + this._ctx, + this.state, + ); + this.enterRule(localctx, 70, CircomParser.RULE_identifier); + let _la: number; + try { + this.enterOuterAlt(localctx, 1); + { + this.state = 570; + this.match(CircomParser.ID); + this.state = 574; + this._errHandler.sync(this); + _la = this._input.LA(1); + while (_la === 29) { + { + { + this.state = 571; + this.arrayDimension(); + } + } + this.state = 576; + 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 identifierList(): IdentifierListContext { + let localctx: IdentifierListContext = new IdentifierListContext( + this, + this._ctx, + this.state, + ); + this.enterRule(localctx, 72, CircomParser.RULE_identifierList); + try { + let _alt: number; + this.enterOuterAlt(localctx, 1); + { + this.state = 582; + this._errHandler.sync(this); + _alt = this._interp.adaptivePredict(this._input, 56, this._ctx); + while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { + if (_alt === 1) { + { + { + this.state = 577; + this.identifier(); + this.state = 578; + this.match(CircomParser.COMMA); + } + } + } + this.state = 584; + this._errHandler.sync(this); + _alt = this._interp.adaptivePredict(this._input, 56, this._ctx); + } + this.state = 585; + this.identifier(); + } + } catch (re) { + if (re instanceof RecognitionException) { + localctx.exception = re; + this._errHandler.reportError(this, re); + this._errHandler.recover(this, re); + } else { + throw re; + } + } finally { + this.exitRule(); + } + return localctx; + } + // @RuleVersion(0) + public simpleIdentifierList(): SimpleIdentifierListContext { + let localctx: SimpleIdentifierListContext = new SimpleIdentifierListContext( + this, + this._ctx, + this.state, + ); + this.enterRule(localctx, 74, CircomParser.RULE_simpleIdentifierList); + try { + let _alt: number; + this.enterOuterAlt(localctx, 1); + { + this.state = 591; + this._errHandler.sync(this); + _alt = this._interp.adaptivePredict(this._input, 57, this._ctx); + while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { + if (_alt === 1) { + { + { + this.state = 587; + this.match(CircomParser.ID); + this.state = 588; + this.match(CircomParser.COMMA); + } + } + } + this.state = 593; + this._errHandler.sync(this); + _alt = this._interp.adaptivePredict(this._input, 57, this._ctx); + } + this.state = 594; + this.match(CircomParser.ID); + } + } 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 idetifierAccess(): IdetifierAccessContext { + let localctx: IdetifierAccessContext = new IdetifierAccessContext( + this, + this._ctx, + this.state, + ); + this.enterRule(localctx, 76, CircomParser.RULE_idetifierAccess); + try { + this.state = 598; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case 29: + this.enterOuterAlt(localctx, 1); + { + this.state = 596; + this.arrayDimension(); + } + break; + case 34: + this.enterOuterAlt(localctx, 2); + { + this.state = 597; + this.identifierReferance(); + } + 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 arrayDimension(): ArrayDimensionContext { + let localctx: ArrayDimensionContext = new ArrayDimensionContext( + this, + this._ctx, + this.state, + ); + this.enterRule(localctx, 78, CircomParser.RULE_arrayDimension); + try { + this.enterOuterAlt(localctx, 1); + { + this.state = 600; + this.match(CircomParser.LB); + this.state = 601; + this.expression(0); + this.state = 602; + this.match(CircomParser.RB); + } + } 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 identifierReferance(): IdentifierReferanceContext { + let localctx: IdentifierReferanceContext = new IdentifierReferanceContext( + this, + this._ctx, + this.state, + ); + this.enterRule(localctx, 80, CircomParser.RULE_identifierReferance); + try { + this.enterOuterAlt(localctx, 1); + { + this.state = 604; + this.match(CircomParser.DOT); + this.state = 605; + this.match(CircomParser.ID); + } + } 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 expressionOrString(): ExpressionOrStringContext { + let localctx: ExpressionOrStringContext = new ExpressionOrStringContext( + this, this._ctx, this.state, ); - this.enterRule(localctx, 70, CircomParser.RULE_numSequence); + this.enterRule(localctx, 82, CircomParser.RULE_expressionOrString); + try { + this.state = 609; + this._errHandler.sync(this); + switch (this._input.LA(1)) { + case 8: + case 27: + case 29: + case 36: + case 45: + case 46: + case 53: + case 69: + case 70: + this.enterOuterAlt(localctx, 1); + { + this.state = 607; + this.expression(0); + } + break; + case 72: + this.enterOuterAlt(localctx, 2); + { + this.state = 608; + this.match(CircomParser.STRING); + } + 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 expressionOrStringList(): ExpressionOrStringListContext { + let localctx: ExpressionOrStringListContext = + new ExpressionOrStringListContext(this, this._ctx, this.state); + this.enterRule(localctx, 84, CircomParser.RULE_expressionOrStringList); try { let _alt: number; this.enterOuterAlt(localctx, 1); { - this.state = 663; - this.match(CircomParser.NUMBER); - this.state = 668; + this.state = 616; this._errHandler.sync(this); - _alt = this._interp.adaptivePredict(this._input, 67, this._ctx); + _alt = this._interp.adaptivePredict(this._input, 60, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { { { - this.state = 664; + this.state = 611; + this.expressionOrString(); + this.state = 612; this.match(CircomParser.COMMA); - this.state = 665; - this.match(CircomParser.NUMBER); } } } - this.state = 670; + this.state = 618; this._errHandler.sync(this); - _alt = this._interp.adaptivePredict(this._input, 67, this._ctx); + _alt = this._interp.adaptivePredict(this._input, 60, this._ctx); } + this.state = 619; + this.expressionOrString(); } } catch (re) { if (re instanceof RecognitionException) { @@ -3164,7 +3273,7 @@ export default class CircomParser extends Parser { predIndex: number, ): boolean { switch (ruleIndex) { - case 17: + case 27: return this.expression_sempred( localctx as ExpressionContext, predIndex, @@ -3178,320 +3287,302 @@ export default class CircomParser extends Parser { ): boolean { switch (predIndex) { case 0: - return this.precpred(this._ctx, 6); + return this.precpred(this._ctx, 12); case 1: - return this.precpred(this._ctx, 5); + return this.precpred(this._ctx, 11); case 2: - return this.precpred(this._ctx, 4); + return this.precpred(this._ctx, 10); case 3: - return this.precpred(this._ctx, 3); + return this.precpred(this._ctx, 9); case 4: - return this.precpred(this._ctx, 2); + return this.precpred(this._ctx, 8); case 5: - return this.precpred(this._ctx, 1); + return this.precpred(this._ctx, 7); case 6: - return this.precpred(this._ctx, 8); + return this.precpred(this._ctx, 6); + case 7: + return this.precpred(this._ctx, 5); + case 8: + return this.precpred(this._ctx, 4); + case 9: + return this.precpred(this._ctx, 3); + case 10: + return this.precpred(this._ctx, 2); } return true; } public static readonly _serializedATN: number[] = [ - 4, 1, 72, 672, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, + 4, 1, 75, 622, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, - 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 1, 0, 5, 0, 74, 8, 0, 10, 0, 12, 0, - 77, 9, 0, 1, 0, 5, 0, 80, 8, 0, 10, 0, 12, 0, 83, 9, 0, 1, 0, 5, 0, 86, 8, - 0, 10, 0, 12, 0, 89, 9, 0, 1, 0, 3, 0, 92, 8, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 103, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, - 3, 3, 3, 111, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 117, 8, 4, 1, 4, 1, 4, 1, - 4, 1, 5, 1, 5, 5, 5, 124, 8, 5, 10, 5, 12, 5, 127, 9, 5, 1, 5, 1, 5, 1, 6, - 1, 6, 1, 6, 5, 6, 134, 8, 6, 10, 6, 12, 6, 137, 9, 6, 1, 6, 1, 6, 1, 6, 1, - 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, - 1, 6, 1, 6, 1, 6, 3, 6, 158, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, - 3, 6, 167, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, - 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 190, - 8, 6, 1, 7, 1, 7, 3, 7, 194, 8, 7, 1, 7, 3, 7, 197, 8, 7, 1, 7, 1, 7, 1, 7, - 3, 7, 202, 8, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 5, 8, 209, 8, 8, 10, 8, 12, - 8, 212, 9, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 3, 9, 219, 8, 9, 1, 9, 1, 9, 1, - 9, 1, 9, 3, 9, 225, 8, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, - 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 5, 11, 240, 8, 11, 10, 11, 12, 11, - 243, 9, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, - 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, - 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, - 1, 11, 1, 11, 5, 11, 278, 8, 11, 10, 11, 12, 11, 281, 9, 11, 1, 11, 1, 11, - 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 289, 8, 11, 10, 11, 12, 11, 292, 9, 11, - 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, - 1, 11, 1, 11, 1, 11, 5, 11, 308, 8, 11, 10, 11, 12, 11, 311, 9, 11, 1, 11, - 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 320, 8, 11, 1, 11, 1, 11, - 1, 11, 1, 11, 3, 11, 326, 8, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, - 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 342, 8, 11, - 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, - 1, 11, 1, 11, 1, 11, 3, 11, 358, 8, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, - 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, - 1, 11, 3, 11, 377, 8, 11, 1, 12, 1, 12, 1, 12, 3, 12, 382, 8, 12, 1, 13, 1, - 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 3, 14, 391, 8, 14, 1, 14, 1, 14, 1, - 14, 3, 14, 396, 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 402, 8, 15, 1, 15, - 1, 15, 3, 15, 406, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, - 1, 17, 1, 17, 3, 17, 417, 8, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, - 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, - 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, - 3, 17, 447, 8, 17, 5, 17, 449, 8, 17, 10, 17, 12, 17, 452, 9, 17, 1, 18, 1, - 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, - 18, 466, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 472, 8, 19, 1, 19, 1, 19, - 1, 19, 3, 19, 477, 8, 19, 5, 19, 479, 8, 19, 10, 19, 12, 19, 482, 9, 19, 3, - 19, 484, 8, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 5, 21, 493, - 8, 21, 10, 21, 12, 21, 496, 9, 21, 1, 21, 1, 21, 3, 21, 500, 8, 21, 1, 22, - 1, 22, 3, 22, 504, 8, 22, 1, 22, 3, 22, 507, 8, 22, 1, 22, 1, 22, 1, 23, 1, - 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 3, 24, 518, 8, 24, 1, 24, 1, 24, 1, - 24, 5, 24, 523, 8, 24, 10, 24, 12, 24, 526, 9, 24, 3, 24, 528, 8, 24, 1, 25, - 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 5, 25, 537, 8, 25, 10, 25, 12, 25, - 540, 9, 25, 1, 25, 1, 25, 3, 25, 544, 8, 25, 1, 26, 1, 26, 1, 26, 3, 26, - 549, 8, 26, 1, 26, 1, 26, 1, 26, 5, 26, 554, 8, 26, 10, 26, 12, 26, 557, 9, - 26, 3, 26, 559, 8, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 3, 27, 567, - 8, 27, 1, 28, 1, 28, 3, 28, 571, 8, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, - 1, 28, 1, 28, 1, 28, 1, 28, 5, 28, 582, 8, 28, 10, 28, 12, 28, 585, 9, 28, - 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, - 5, 28, 598, 8, 28, 10, 28, 12, 28, 601, 9, 28, 1, 28, 1, 28, 3, 28, 605, 8, - 28, 1, 29, 3, 29, 608, 8, 29, 1, 29, 1, 29, 1, 29, 3, 29, 613, 8, 29, 1, 29, - 1, 29, 3, 29, 617, 8, 29, 1, 30, 1, 30, 1, 30, 5, 30, 622, 8, 30, 10, 30, - 12, 30, 625, 9, 30, 1, 31, 1, 31, 5, 31, 629, 8, 31, 10, 31, 12, 31, 632, 9, - 31, 1, 31, 1, 31, 3, 31, 636, 8, 31, 1, 31, 5, 31, 639, 8, 31, 10, 31, 12, - 31, 642, 9, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 5, 33, 651, - 8, 33, 10, 33, 12, 33, 654, 9, 33, 1, 34, 1, 34, 1, 34, 5, 34, 659, 8, 34, - 10, 34, 12, 34, 662, 9, 34, 1, 35, 1, 35, 1, 35, 5, 35, 667, 8, 35, 10, 35, - 12, 35, 670, 9, 35, 1, 35, 0, 1, 34, 36, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, - 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, - 58, 60, 62, 64, 66, 68, 70, 0, 10, 1, 0, 64, 65, 2, 0, 39, 39, 65, 65, 2, 0, - 39, 39, 64, 64, 2, 0, 42, 43, 50, 50, 1, 0, 44, 48, 1, 0, 49, 50, 1, 0, 51, - 52, 1, 0, 53, 55, 1, 0, 56, 63, 2, 0, 35, 35, 66, 66, 744, 0, 75, 1, 0, 0, - 0, 2, 102, 1, 0, 0, 0, 4, 104, 1, 0, 0, 0, 6, 110, 1, 0, 0, 0, 8, 112, 1, 0, - 0, 0, 10, 121, 1, 0, 0, 0, 12, 189, 1, 0, 0, 0, 14, 191, 1, 0, 0, 0, 16, - 206, 1, 0, 0, 0, 18, 215, 1, 0, 0, 0, 20, 229, 1, 0, 0, 0, 22, 376, 1, 0, 0, - 0, 24, 378, 1, 0, 0, 0, 26, 383, 1, 0, 0, 0, 28, 390, 1, 0, 0, 0, 30, 405, - 1, 0, 0, 0, 32, 407, 1, 0, 0, 0, 34, 416, 1, 0, 0, 0, 36, 465, 1, 0, 0, 0, - 38, 467, 1, 0, 0, 0, 40, 487, 1, 0, 0, 0, 42, 490, 1, 0, 0, 0, 44, 501, 1, - 0, 0, 0, 46, 510, 1, 0, 0, 0, 48, 527, 1, 0, 0, 0, 50, 543, 1, 0, 0, 0, 52, - 558, 1, 0, 0, 0, 54, 566, 1, 0, 0, 0, 56, 604, 1, 0, 0, 0, 58, 607, 1, 0, 0, - 0, 60, 618, 1, 0, 0, 0, 62, 626, 1, 0, 0, 0, 64, 643, 1, 0, 0, 0, 66, 647, - 1, 0, 0, 0, 68, 655, 1, 0, 0, 0, 70, 663, 1, 0, 0, 0, 72, 74, 3, 2, 1, 0, - 73, 72, 1, 0, 0, 0, 74, 77, 1, 0, 0, 0, 75, 73, 1, 0, 0, 0, 75, 76, 1, 0, 0, - 0, 76, 81, 1, 0, 0, 0, 77, 75, 1, 0, 0, 0, 78, 80, 3, 4, 2, 0, 79, 78, 1, 0, - 0, 0, 80, 83, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 87, 1, - 0, 0, 0, 83, 81, 1, 0, 0, 0, 84, 86, 3, 6, 3, 0, 85, 84, 1, 0, 0, 0, 86, 89, - 1, 0, 0, 0, 87, 85, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 91, 1, 0, 0, 0, 89, - 87, 1, 0, 0, 0, 90, 92, 3, 18, 9, 0, 91, 90, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, - 92, 93, 1, 0, 0, 0, 93, 94, 5, 0, 0, 1, 94, 1, 1, 0, 0, 0, 95, 96, 5, 3, 0, - 0, 96, 97, 5, 4, 0, 0, 97, 98, 5, 1, 0, 0, 98, 103, 5, 32, 0, 0, 99, 100, 5, - 3, 0, 0, 100, 101, 5, 5, 0, 0, 101, 103, 5, 32, 0, 0, 102, 95, 1, 0, 0, 0, - 102, 99, 1, 0, 0, 0, 103, 3, 1, 0, 0, 0, 104, 105, 5, 6, 0, 0, 105, 106, 5, - 69, 0, 0, 106, 107, 5, 32, 0, 0, 107, 5, 1, 0, 0, 0, 108, 111, 3, 8, 4, 0, - 109, 111, 3, 14, 7, 0, 110, 108, 1, 0, 0, 0, 110, 109, 1, 0, 0, 0, 111, 7, - 1, 0, 0, 0, 112, 113, 5, 10, 0, 0, 113, 114, 5, 66, 0, 0, 114, 116, 5, 26, - 0, 0, 115, 117, 3, 66, 33, 0, 116, 115, 1, 0, 0, 0, 116, 117, 1, 0, 0, 0, - 117, 118, 1, 0, 0, 0, 118, 119, 5, 27, 0, 0, 119, 120, 3, 10, 5, 0, 120, 9, - 1, 0, 0, 0, 121, 125, 5, 30, 0, 0, 122, 124, 3, 12, 6, 0, 123, 122, 1, 0, 0, - 0, 124, 127, 1, 0, 0, 0, 125, 123, 1, 0, 0, 0, 125, 126, 1, 0, 0, 0, 126, - 128, 1, 0, 0, 0, 127, 125, 1, 0, 0, 0, 128, 129, 5, 31, 0, 0, 129, 11, 1, 0, - 0, 0, 130, 190, 3, 10, 5, 0, 131, 135, 5, 66, 0, 0, 132, 134, 3, 64, 32, 0, - 133, 132, 1, 0, 0, 0, 134, 137, 1, 0, 0, 0, 135, 133, 1, 0, 0, 0, 135, 136, - 1, 0, 0, 0, 136, 138, 1, 0, 0, 0, 137, 135, 1, 0, 0, 0, 138, 139, 5, 41, 0, - 0, 139, 190, 5, 32, 0, 0, 140, 141, 3, 52, 26, 0, 141, 142, 5, 32, 0, 0, - 142, 190, 1, 0, 0, 0, 143, 144, 3, 62, 31, 0, 144, 145, 7, 0, 0, 0, 145, - 146, 3, 34, 17, 0, 146, 147, 5, 32, 0, 0, 147, 190, 1, 0, 0, 0, 148, 149, 5, - 26, 0, 0, 149, 150, 3, 68, 34, 0, 150, 151, 5, 27, 0, 0, 151, 157, 5, 64, 0, - 0, 152, 153, 5, 26, 0, 0, 153, 154, 3, 60, 30, 0, 154, 155, 5, 27, 0, 0, - 155, 158, 1, 0, 0, 0, 156, 158, 3, 34, 17, 0, 157, 152, 1, 0, 0, 0, 157, - 156, 1, 0, 0, 0, 158, 159, 1, 0, 0, 0, 159, 160, 5, 32, 0, 0, 160, 190, 1, - 0, 0, 0, 161, 162, 5, 18, 0, 0, 162, 163, 3, 32, 16, 0, 163, 166, 3, 12, 6, - 0, 164, 165, 5, 19, 0, 0, 165, 167, 3, 12, 6, 0, 166, 164, 1, 0, 0, 0, 166, - 167, 1, 0, 0, 0, 167, 190, 1, 0, 0, 0, 168, 169, 5, 21, 0, 0, 169, 170, 3, - 32, 16, 0, 170, 171, 3, 12, 6, 0, 171, 190, 1, 0, 0, 0, 172, 173, 5, 20, 0, - 0, 173, 174, 5, 26, 0, 0, 174, 175, 3, 26, 13, 0, 175, 176, 5, 27, 0, 0, - 176, 177, 3, 12, 6, 0, 177, 190, 1, 0, 0, 0, 178, 179, 5, 25, 0, 0, 179, - 180, 3, 34, 17, 0, 180, 181, 5, 32, 0, 0, 181, 190, 1, 0, 0, 0, 182, 183, 5, - 24, 0, 0, 183, 184, 3, 32, 16, 0, 184, 185, 5, 32, 0, 0, 185, 190, 1, 0, 0, - 0, 186, 187, 3, 38, 19, 0, 187, 188, 5, 32, 0, 0, 188, 190, 1, 0, 0, 0, 189, - 130, 1, 0, 0, 0, 189, 131, 1, 0, 0, 0, 189, 140, 1, 0, 0, 0, 189, 143, 1, 0, - 0, 0, 189, 148, 1, 0, 0, 0, 189, 161, 1, 0, 0, 0, 189, 168, 1, 0, 0, 0, 189, - 172, 1, 0, 0, 0, 189, 178, 1, 0, 0, 0, 189, 182, 1, 0, 0, 0, 189, 186, 1, 0, - 0, 0, 190, 13, 1, 0, 0, 0, 191, 193, 5, 9, 0, 0, 192, 194, 5, 7, 0, 0, 193, - 192, 1, 0, 0, 0, 193, 194, 1, 0, 0, 0, 194, 196, 1, 0, 0, 0, 195, 197, 5, 8, - 0, 0, 196, 195, 1, 0, 0, 0, 196, 197, 1, 0, 0, 0, 197, 198, 1, 0, 0, 0, 198, - 199, 5, 66, 0, 0, 199, 201, 5, 26, 0, 0, 200, 202, 3, 66, 33, 0, 201, 200, - 1, 0, 0, 0, 201, 202, 1, 0, 0, 0, 202, 203, 1, 0, 0, 0, 203, 204, 5, 27, 0, - 0, 204, 205, 3, 16, 8, 0, 205, 15, 1, 0, 0, 0, 206, 210, 5, 30, 0, 0, 207, - 209, 3, 22, 11, 0, 208, 207, 1, 0, 0, 0, 209, 212, 1, 0, 0, 0, 210, 208, 1, - 0, 0, 0, 210, 211, 1, 0, 0, 0, 211, 213, 1, 0, 0, 0, 212, 210, 1, 0, 0, 0, - 213, 214, 5, 31, 0, 0, 214, 17, 1, 0, 0, 0, 215, 216, 5, 13, 0, 0, 216, 218, - 5, 11, 0, 0, 217, 219, 3, 20, 10, 0, 218, 217, 1, 0, 0, 0, 218, 219, 1, 0, - 0, 0, 219, 220, 1, 0, 0, 0, 220, 221, 5, 64, 0, 0, 221, 222, 5, 66, 0, 0, - 222, 224, 5, 26, 0, 0, 223, 225, 3, 60, 30, 0, 224, 223, 1, 0, 0, 0, 224, - 225, 1, 0, 0, 0, 225, 226, 1, 0, 0, 0, 226, 227, 5, 27, 0, 0, 227, 228, 5, - 32, 0, 0, 228, 19, 1, 0, 0, 0, 229, 230, 5, 30, 0, 0, 230, 231, 5, 12, 0, 0, - 231, 232, 5, 28, 0, 0, 232, 233, 3, 66, 33, 0, 233, 234, 5, 29, 0, 0, 234, - 235, 5, 31, 0, 0, 235, 21, 1, 0, 0, 0, 236, 377, 3, 16, 8, 0, 237, 241, 5, - 66, 0, 0, 238, 240, 3, 64, 32, 0, 239, 238, 1, 0, 0, 0, 240, 243, 1, 0, 0, - 0, 241, 239, 1, 0, 0, 0, 241, 242, 1, 0, 0, 0, 242, 244, 1, 0, 0, 0, 243, - 241, 1, 0, 0, 0, 244, 245, 5, 41, 0, 0, 245, 377, 5, 32, 0, 0, 246, 247, 3, - 52, 26, 0, 247, 248, 5, 32, 0, 0, 248, 377, 1, 0, 0, 0, 249, 250, 3, 48, 24, - 0, 250, 251, 5, 32, 0, 0, 251, 377, 1, 0, 0, 0, 252, 253, 3, 42, 21, 0, 253, - 254, 5, 32, 0, 0, 254, 377, 1, 0, 0, 0, 255, 256, 3, 58, 29, 0, 256, 257, 5, - 32, 0, 0, 257, 377, 1, 0, 0, 0, 258, 259, 3, 62, 31, 0, 259, 260, 5, 64, 0, - 0, 260, 261, 3, 34, 17, 0, 261, 262, 5, 32, 0, 0, 262, 377, 1, 0, 0, 0, 263, - 264, 3, 34, 17, 0, 264, 265, 5, 38, 0, 0, 265, 266, 3, 34, 17, 0, 266, 267, - 5, 32, 0, 0, 267, 377, 1, 0, 0, 0, 268, 269, 3, 24, 12, 0, 269, 270, 7, 1, - 0, 0, 270, 271, 3, 34, 17, 0, 271, 272, 5, 32, 0, 0, 272, 377, 1, 0, 0, 0, - 273, 274, 5, 26, 0, 0, 274, 279, 3, 24, 12, 0, 275, 276, 5, 34, 0, 0, 276, - 278, 3, 24, 12, 0, 277, 275, 1, 0, 0, 0, 278, 281, 1, 0, 0, 0, 279, 277, 1, - 0, 0, 0, 279, 280, 1, 0, 0, 0, 280, 282, 1, 0, 0, 0, 281, 279, 1, 0, 0, 0, - 282, 283, 5, 27, 0, 0, 283, 284, 5, 39, 0, 0, 284, 285, 5, 26, 0, 0, 285, - 290, 3, 34, 17, 0, 286, 287, 5, 34, 0, 0, 287, 289, 3, 34, 17, 0, 288, 286, - 1, 0, 0, 0, 289, 292, 1, 0, 0, 0, 290, 288, 1, 0, 0, 0, 290, 291, 1, 0, 0, - 0, 291, 293, 1, 0, 0, 0, 292, 290, 1, 0, 0, 0, 293, 294, 5, 27, 0, 0, 294, - 295, 5, 32, 0, 0, 295, 377, 1, 0, 0, 0, 296, 297, 3, 34, 17, 0, 297, 298, 5, - 40, 0, 0, 298, 299, 3, 24, 12, 0, 299, 300, 5, 32, 0, 0, 300, 377, 1, 0, 0, - 0, 301, 302, 3, 34, 17, 0, 302, 303, 5, 40, 0, 0, 303, 304, 5, 26, 0, 0, - 304, 309, 3, 24, 12, 0, 305, 306, 5, 34, 0, 0, 306, 308, 3, 24, 12, 0, 307, - 305, 1, 0, 0, 0, 308, 311, 1, 0, 0, 0, 309, 307, 1, 0, 0, 0, 309, 310, 1, 0, - 0, 0, 310, 312, 1, 0, 0, 0, 311, 309, 1, 0, 0, 0, 312, 313, 5, 27, 0, 0, - 313, 314, 5, 32, 0, 0, 314, 377, 1, 0, 0, 0, 315, 316, 5, 35, 0, 0, 316, - 319, 7, 2, 0, 0, 317, 320, 3, 34, 17, 0, 318, 320, 3, 58, 29, 0, 319, 317, - 1, 0, 0, 0, 319, 318, 1, 0, 0, 0, 320, 321, 1, 0, 0, 0, 321, 322, 5, 32, 0, - 0, 322, 377, 1, 0, 0, 0, 323, 326, 3, 34, 17, 0, 324, 326, 3, 58, 29, 0, - 325, 323, 1, 0, 0, 0, 325, 324, 1, 0, 0, 0, 326, 327, 1, 0, 0, 0, 327, 328, - 5, 40, 0, 0, 328, 329, 5, 35, 0, 0, 329, 330, 5, 32, 0, 0, 330, 377, 1, 0, - 0, 0, 331, 332, 5, 26, 0, 0, 332, 333, 3, 68, 34, 0, 333, 334, 5, 27, 0, 0, - 334, 341, 7, 2, 0, 0, 335, 336, 5, 26, 0, 0, 336, 337, 3, 60, 30, 0, 337, - 338, 5, 27, 0, 0, 338, 342, 1, 0, 0, 0, 339, 342, 3, 58, 29, 0, 340, 342, 3, - 34, 17, 0, 341, 335, 1, 0, 0, 0, 341, 339, 1, 0, 0, 0, 341, 340, 1, 0, 0, 0, - 342, 343, 1, 0, 0, 0, 343, 344, 5, 32, 0, 0, 344, 377, 1, 0, 0, 0, 345, 346, - 3, 58, 29, 0, 346, 347, 5, 40, 0, 0, 347, 348, 5, 26, 0, 0, 348, 349, 3, 68, - 34, 0, 349, 350, 5, 27, 0, 0, 350, 351, 5, 32, 0, 0, 351, 377, 1, 0, 0, 0, - 352, 353, 5, 18, 0, 0, 353, 354, 3, 32, 16, 0, 354, 357, 3, 22, 11, 0, 355, - 356, 5, 19, 0, 0, 356, 358, 3, 22, 11, 0, 357, 355, 1, 0, 0, 0, 357, 358, 1, - 0, 0, 0, 358, 377, 1, 0, 0, 0, 359, 360, 5, 21, 0, 0, 360, 361, 3, 32, 16, - 0, 361, 362, 3, 22, 11, 0, 362, 377, 1, 0, 0, 0, 363, 364, 5, 20, 0, 0, 364, - 365, 5, 26, 0, 0, 365, 366, 3, 26, 13, 0, 366, 367, 5, 27, 0, 0, 367, 368, - 3, 22, 11, 0, 368, 377, 1, 0, 0, 0, 369, 370, 5, 24, 0, 0, 370, 371, 3, 32, - 16, 0, 371, 372, 5, 32, 0, 0, 372, 377, 1, 0, 0, 0, 373, 374, 3, 38, 19, 0, - 374, 375, 5, 32, 0, 0, 375, 377, 1, 0, 0, 0, 376, 236, 1, 0, 0, 0, 376, 237, - 1, 0, 0, 0, 376, 246, 1, 0, 0, 0, 376, 249, 1, 0, 0, 0, 376, 252, 1, 0, 0, - 0, 376, 255, 1, 0, 0, 0, 376, 258, 1, 0, 0, 0, 376, 263, 1, 0, 0, 0, 376, - 268, 1, 0, 0, 0, 376, 273, 1, 0, 0, 0, 376, 296, 1, 0, 0, 0, 376, 301, 1, 0, - 0, 0, 376, 315, 1, 0, 0, 0, 376, 325, 1, 0, 0, 0, 376, 331, 1, 0, 0, 0, 376, - 345, 1, 0, 0, 0, 376, 352, 1, 0, 0, 0, 376, 359, 1, 0, 0, 0, 376, 363, 1, 0, - 0, 0, 376, 369, 1, 0, 0, 0, 376, 373, 1, 0, 0, 0, 377, 23, 1, 0, 0, 0, 378, - 381, 3, 62, 31, 0, 379, 380, 5, 33, 0, 0, 380, 382, 3, 62, 31, 0, 381, 379, - 1, 0, 0, 0, 381, 382, 1, 0, 0, 0, 382, 25, 1, 0, 0, 0, 383, 384, 3, 28, 14, - 0, 384, 385, 5, 32, 0, 0, 385, 386, 3, 34, 17, 0, 386, 387, 5, 32, 0, 0, - 387, 388, 3, 30, 15, 0, 388, 27, 1, 0, 0, 0, 389, 391, 5, 14, 0, 0, 390, - 389, 1, 0, 0, 0, 390, 391, 1, 0, 0, 0, 391, 392, 1, 0, 0, 0, 392, 395, 3, - 62, 31, 0, 393, 394, 5, 64, 0, 0, 394, 396, 3, 54, 27, 0, 395, 393, 1, 0, 0, - 0, 395, 396, 1, 0, 0, 0, 396, 29, 1, 0, 0, 0, 397, 401, 5, 66, 0, 0, 398, - 402, 5, 41, 0, 0, 399, 400, 7, 0, 0, 0, 400, 402, 3, 34, 17, 0, 401, 398, 1, - 0, 0, 0, 401, 399, 1, 0, 0, 0, 402, 406, 1, 0, 0, 0, 403, 404, 5, 41, 0, 0, - 404, 406, 5, 66, 0, 0, 405, 397, 1, 0, 0, 0, 405, 403, 1, 0, 0, 0, 406, 31, - 1, 0, 0, 0, 407, 408, 5, 26, 0, 0, 408, 409, 3, 34, 17, 0, 409, 410, 5, 27, - 0, 0, 410, 33, 1, 0, 0, 0, 411, 412, 6, 17, -1, 0, 412, 417, 3, 36, 18, 0, - 413, 417, 3, 58, 29, 0, 414, 415, 7, 3, 0, 0, 415, 417, 3, 34, 17, 7, 416, - 411, 1, 0, 0, 0, 416, 413, 1, 0, 0, 0, 416, 414, 1, 0, 0, 0, 417, 450, 1, 0, - 0, 0, 418, 419, 10, 6, 0, 0, 419, 420, 7, 4, 0, 0, 420, 449, 3, 34, 17, 7, - 421, 422, 10, 5, 0, 0, 422, 423, 7, 5, 0, 0, 423, 449, 3, 34, 17, 6, 424, - 425, 10, 4, 0, 0, 425, 426, 7, 6, 0, 0, 426, 449, 3, 34, 17, 5, 427, 428, - 10, 3, 0, 0, 428, 429, 7, 7, 0, 0, 429, 449, 3, 34, 17, 4, 430, 431, 10, 2, - 0, 0, 431, 432, 7, 8, 0, 0, 432, 449, 3, 34, 17, 3, 433, 434, 10, 1, 0, 0, - 434, 435, 5, 36, 0, 0, 435, 436, 3, 34, 17, 0, 436, 437, 5, 37, 0, 0, 437, - 438, 3, 34, 17, 2, 438, 449, 1, 0, 0, 0, 439, 440, 10, 8, 0, 0, 440, 441, 5, - 33, 0, 0, 441, 446, 5, 66, 0, 0, 442, 443, 5, 28, 0, 0, 443, 444, 3, 34, 17, - 0, 444, 445, 5, 29, 0, 0, 445, 447, 1, 0, 0, 0, 446, 442, 1, 0, 0, 0, 446, - 447, 1, 0, 0, 0, 447, 449, 1, 0, 0, 0, 448, 418, 1, 0, 0, 0, 448, 421, 1, 0, - 0, 0, 448, 424, 1, 0, 0, 0, 448, 427, 1, 0, 0, 0, 448, 430, 1, 0, 0, 0, 448, - 433, 1, 0, 0, 0, 448, 439, 1, 0, 0, 0, 449, 452, 1, 0, 0, 0, 450, 448, 1, 0, - 0, 0, 450, 451, 1, 0, 0, 0, 451, 35, 1, 0, 0, 0, 452, 450, 1, 0, 0, 0, 453, - 454, 5, 26, 0, 0, 454, 455, 3, 34, 17, 0, 455, 456, 5, 27, 0, 0, 456, 466, - 1, 0, 0, 0, 457, 458, 5, 28, 0, 0, 458, 459, 3, 60, 30, 0, 459, 460, 5, 29, - 0, 0, 460, 466, 1, 0, 0, 0, 461, 466, 5, 67, 0, 0, 462, 466, 3, 62, 31, 0, - 463, 466, 3, 66, 33, 0, 464, 466, 3, 70, 35, 0, 465, 453, 1, 0, 0, 0, 465, - 457, 1, 0, 0, 0, 465, 461, 1, 0, 0, 0, 465, 462, 1, 0, 0, 0, 465, 463, 1, 0, - 0, 0, 465, 464, 1, 0, 0, 0, 466, 37, 1, 0, 0, 0, 467, 468, 5, 23, 0, 0, 468, - 483, 5, 26, 0, 0, 469, 472, 5, 69, 0, 0, 470, 472, 3, 34, 17, 0, 471, 469, - 1, 0, 0, 0, 471, 470, 1, 0, 0, 0, 472, 480, 1, 0, 0, 0, 473, 476, 5, 34, 0, - 0, 474, 477, 5, 69, 0, 0, 475, 477, 3, 34, 17, 0, 476, 474, 1, 0, 0, 0, 476, - 475, 1, 0, 0, 0, 477, 479, 1, 0, 0, 0, 478, 473, 1, 0, 0, 0, 479, 482, 1, 0, - 0, 0, 480, 478, 1, 0, 0, 0, 480, 481, 1, 0, 0, 0, 481, 484, 1, 0, 0, 0, 482, - 480, 1, 0, 0, 0, 483, 471, 1, 0, 0, 0, 483, 484, 1, 0, 0, 0, 484, 485, 1, 0, - 0, 0, 485, 486, 5, 27, 0, 0, 486, 39, 1, 0, 0, 0, 487, 488, 5, 13, 0, 0, - 488, 489, 5, 66, 0, 0, 489, 41, 1, 0, 0, 0, 490, 494, 3, 40, 20, 0, 491, - 493, 3, 64, 32, 0, 492, 491, 1, 0, 0, 0, 493, 496, 1, 0, 0, 0, 494, 492, 1, - 0, 0, 0, 494, 495, 1, 0, 0, 0, 495, 499, 1, 0, 0, 0, 496, 494, 1, 0, 0, 0, - 497, 498, 5, 64, 0, 0, 498, 500, 3, 58, 29, 0, 499, 497, 1, 0, 0, 0, 499, - 500, 1, 0, 0, 0, 500, 43, 1, 0, 0, 0, 501, 503, 5, 15, 0, 0, 502, 504, 5, 2, - 0, 0, 503, 502, 1, 0, 0, 0, 503, 504, 1, 0, 0, 0, 504, 506, 1, 0, 0, 0, 505, - 507, 3, 46, 23, 0, 506, 505, 1, 0, 0, 0, 506, 507, 1, 0, 0, 0, 507, 508, 1, - 0, 0, 0, 508, 509, 3, 62, 31, 0, 509, 45, 1, 0, 0, 0, 510, 511, 5, 30, 0, 0, - 511, 512, 3, 66, 33, 0, 512, 513, 5, 31, 0, 0, 513, 47, 1, 0, 0, 0, 514, - 517, 3, 44, 22, 0, 515, 516, 5, 39, 0, 0, 516, 518, 3, 54, 27, 0, 517, 515, - 1, 0, 0, 0, 517, 518, 1, 0, 0, 0, 518, 528, 1, 0, 0, 0, 519, 524, 3, 44, 22, - 0, 520, 521, 5, 34, 0, 0, 521, 523, 3, 62, 31, 0, 522, 520, 1, 0, 0, 0, 523, - 526, 1, 0, 0, 0, 524, 522, 1, 0, 0, 0, 524, 525, 1, 0, 0, 0, 525, 528, 1, 0, - 0, 0, 526, 524, 1, 0, 0, 0, 527, 514, 1, 0, 0, 0, 527, 519, 1, 0, 0, 0, 528, - 49, 1, 0, 0, 0, 529, 530, 5, 14, 0, 0, 530, 544, 3, 62, 31, 0, 531, 532, 5, - 14, 0, 0, 532, 533, 5, 26, 0, 0, 533, 538, 3, 62, 31, 0, 534, 535, 5, 34, 0, - 0, 535, 537, 3, 62, 31, 0, 536, 534, 1, 0, 0, 0, 537, 540, 1, 0, 0, 0, 538, - 536, 1, 0, 0, 0, 538, 539, 1, 0, 0, 0, 539, 541, 1, 0, 0, 0, 540, 538, 1, 0, - 0, 0, 541, 542, 5, 27, 0, 0, 542, 544, 1, 0, 0, 0, 543, 529, 1, 0, 0, 0, - 543, 531, 1, 0, 0, 0, 544, 51, 1, 0, 0, 0, 545, 548, 3, 50, 25, 0, 546, 547, - 5, 64, 0, 0, 547, 549, 3, 54, 27, 0, 548, 546, 1, 0, 0, 0, 548, 549, 1, 0, - 0, 0, 549, 559, 1, 0, 0, 0, 550, 555, 3, 50, 25, 0, 551, 552, 5, 34, 0, 0, - 552, 554, 3, 62, 31, 0, 553, 551, 1, 0, 0, 0, 554, 557, 1, 0, 0, 0, 555, - 553, 1, 0, 0, 0, 555, 556, 1, 0, 0, 0, 556, 559, 1, 0, 0, 0, 557, 555, 1, 0, - 0, 0, 558, 545, 1, 0, 0, 0, 558, 550, 1, 0, 0, 0, 559, 53, 1, 0, 0, 0, 560, - 561, 5, 26, 0, 0, 561, 562, 3, 60, 30, 0, 562, 563, 5, 27, 0, 0, 563, 567, - 1, 0, 0, 0, 564, 567, 3, 34, 17, 0, 565, 567, 3, 58, 29, 0, 566, 560, 1, 0, - 0, 0, 566, 564, 1, 0, 0, 0, 566, 565, 1, 0, 0, 0, 567, 55, 1, 0, 0, 0, 568, - 570, 5, 26, 0, 0, 569, 571, 3, 60, 30, 0, 570, 569, 1, 0, 0, 0, 570, 571, 1, - 0, 0, 0, 571, 572, 1, 0, 0, 0, 572, 605, 5, 27, 0, 0, 573, 574, 5, 26, 0, 0, - 574, 575, 5, 66, 0, 0, 575, 576, 5, 39, 0, 0, 576, 583, 3, 34, 17, 0, 577, - 578, 5, 34, 0, 0, 578, 579, 5, 66, 0, 0, 579, 580, 5, 39, 0, 0, 580, 582, 3, - 34, 17, 0, 581, 577, 1, 0, 0, 0, 582, 585, 1, 0, 0, 0, 583, 581, 1, 0, 0, 0, - 583, 584, 1, 0, 0, 0, 584, 586, 1, 0, 0, 0, 585, 583, 1, 0, 0, 0, 586, 587, - 5, 27, 0, 0, 587, 605, 1, 0, 0, 0, 588, 589, 5, 26, 0, 0, 589, 590, 3, 34, - 17, 0, 590, 591, 5, 40, 0, 0, 591, 599, 5, 66, 0, 0, 592, 593, 5, 34, 0, 0, - 593, 594, 3, 34, 17, 0, 594, 595, 5, 40, 0, 0, 595, 596, 5, 66, 0, 0, 596, - 598, 1, 0, 0, 0, 597, 592, 1, 0, 0, 0, 598, 601, 1, 0, 0, 0, 599, 597, 1, 0, - 0, 0, 599, 600, 1, 0, 0, 0, 600, 602, 1, 0, 0, 0, 601, 599, 1, 0, 0, 0, 602, - 603, 5, 27, 0, 0, 603, 605, 1, 0, 0, 0, 604, 568, 1, 0, 0, 0, 604, 573, 1, - 0, 0, 0, 604, 588, 1, 0, 0, 0, 605, 57, 1, 0, 0, 0, 606, 608, 5, 8, 0, 0, - 607, 606, 1, 0, 0, 0, 607, 608, 1, 0, 0, 0, 608, 609, 1, 0, 0, 0, 609, 610, - 5, 66, 0, 0, 610, 612, 5, 26, 0, 0, 611, 613, 3, 60, 30, 0, 612, 611, 1, 0, - 0, 0, 612, 613, 1, 0, 0, 0, 613, 614, 1, 0, 0, 0, 614, 616, 5, 27, 0, 0, - 615, 617, 3, 56, 28, 0, 616, 615, 1, 0, 0, 0, 616, 617, 1, 0, 0, 0, 617, 59, - 1, 0, 0, 0, 618, 623, 3, 34, 17, 0, 619, 620, 5, 34, 0, 0, 620, 622, 3, 34, - 17, 0, 621, 619, 1, 0, 0, 0, 622, 625, 1, 0, 0, 0, 623, 621, 1, 0, 0, 0, - 623, 624, 1, 0, 0, 0, 624, 61, 1, 0, 0, 0, 625, 623, 1, 0, 0, 0, 626, 630, - 5, 66, 0, 0, 627, 629, 3, 64, 32, 0, 628, 627, 1, 0, 0, 0, 629, 632, 1, 0, - 0, 0, 630, 628, 1, 0, 0, 0, 630, 631, 1, 0, 0, 0, 631, 635, 1, 0, 0, 0, 632, - 630, 1, 0, 0, 0, 633, 634, 5, 33, 0, 0, 634, 636, 5, 66, 0, 0, 635, 633, 1, - 0, 0, 0, 635, 636, 1, 0, 0, 0, 636, 640, 1, 0, 0, 0, 637, 639, 3, 64, 32, 0, - 638, 637, 1, 0, 0, 0, 639, 642, 1, 0, 0, 0, 640, 638, 1, 0, 0, 0, 640, 641, - 1, 0, 0, 0, 641, 63, 1, 0, 0, 0, 642, 640, 1, 0, 0, 0, 643, 644, 5, 28, 0, - 0, 644, 645, 3, 34, 17, 0, 645, 646, 5, 29, 0, 0, 646, 65, 1, 0, 0, 0, 647, - 652, 5, 66, 0, 0, 648, 649, 5, 34, 0, 0, 649, 651, 5, 66, 0, 0, 650, 648, 1, - 0, 0, 0, 651, 654, 1, 0, 0, 0, 652, 650, 1, 0, 0, 0, 652, 653, 1, 0, 0, 0, - 653, 67, 1, 0, 0, 0, 654, 652, 1, 0, 0, 0, 655, 660, 7, 9, 0, 0, 656, 657, - 5, 34, 0, 0, 657, 659, 7, 9, 0, 0, 658, 656, 1, 0, 0, 0, 659, 662, 1, 0, 0, - 0, 660, 658, 1, 0, 0, 0, 660, 661, 1, 0, 0, 0, 661, 69, 1, 0, 0, 0, 662, - 660, 1, 0, 0, 0, 663, 668, 5, 67, 0, 0, 664, 665, 5, 34, 0, 0, 665, 667, 5, - 67, 0, 0, 666, 664, 1, 0, 0, 0, 667, 670, 1, 0, 0, 0, 668, 666, 1, 0, 0, 0, - 668, 669, 1, 0, 0, 0, 669, 71, 1, 0, 0, 0, 670, 668, 1, 0, 0, 0, 68, 75, 81, - 87, 91, 102, 110, 116, 125, 135, 157, 166, 189, 193, 196, 201, 210, 218, - 224, 241, 279, 290, 309, 319, 325, 341, 357, 376, 381, 390, 395, 401, 405, - 416, 446, 448, 450, 465, 471, 476, 480, 483, 494, 499, 503, 506, 517, 524, - 527, 538, 543, 548, 555, 558, 566, 570, 583, 599, 604, 607, 612, 616, 623, - 630, 635, 640, 652, 660, 668, + 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, + 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 1, 0, 5, 0, 88, + 8, 0, 10, 0, 12, 0, 91, 9, 0, 1, 0, 5, 0, 94, 8, 0, 10, 0, 12, 0, 97, 9, 0, + 1, 0, 5, 0, 100, 8, 0, 10, 0, 12, 0, 103, 9, 0, 1, 0, 3, 0, 106, 8, 0, 1, 0, + 1, 0, 1, 1, 1, 1, 3, 1, 112, 8, 1, 1, 1, 3, 1, 115, 8, 1, 1, 1, 1, 1, 1, 1, + 3, 1, 120, 8, 1, 3, 1, 122, 8, 1, 1, 2, 1, 2, 3, 2, 126, 8, 2, 1, 2, 3, 2, + 129, 8, 2, 1, 2, 1, 2, 1, 2, 3, 2, 134, 8, 2, 1, 2, 1, 2, 3, 2, 138, 8, 2, + 1, 2, 3, 2, 141, 8, 2, 1, 2, 1, 2, 1, 2, 3, 2, 146, 8, 2, 1, 2, 1, 2, 1, 2, + 1, 2, 3, 2, 152, 8, 2, 1, 2, 1, 2, 3, 2, 156, 8, 2, 3, 2, 158, 8, 2, 1, 3, + 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 170, 8, 3, 1, 4, + 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 3, 5, 179, 8, 5, 1, 6, 1, 6, 1, 6, 1, 6, + 3, 6, 185, 8, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 3, 7, 192, 8, 7, 1, 7, 3, 7, + 195, 8, 7, 1, 7, 1, 7, 1, 7, 3, 7, 200, 8, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, + 1, 8, 1, 8, 3, 8, 209, 8, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, + 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 3, 11, 228, 8, + 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, + 13, 3, 13, 241, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 248, 8, 14, + 1, 14, 1, 14, 3, 14, 252, 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, + 259, 8, 15, 1, 15, 1, 15, 1, 15, 3, 15, 264, 8, 15, 1, 16, 1, 16, 1, 16, 1, + 16, 1, 16, 3, 16, 271, 8, 16, 1, 16, 1, 16, 3, 16, 275, 8, 16, 1, 17, 1, 17, + 1, 17, 1, 18, 1, 18, 1, 18, 3, 18, 283, 8, 18, 1, 18, 1, 18, 1, 18, 1, 18, + 3, 18, 289, 8, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 5, 19, 296, 8, 19, 10, + 19, 12, 19, 299, 9, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, + 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 314, 8, 20, 1, 21, 1, 21, 1, + 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, + 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, + 21, 1, 21, 1, 21, 1, 21, 3, 21, 344, 8, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, + 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, + 22, 1, 22, 3, 22, 363, 8, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, + 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, + 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 391, 8, + 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, + 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 3, + 24, 414, 8, 24, 1, 25, 1, 25, 1, 25, 5, 25, 419, 8, 25, 10, 25, 12, 25, 422, + 9, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 5, 26, 431, 8, 26, + 10, 26, 12, 26, 434, 9, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, + 1, 27, 1, 27, 1, 27, 3, 27, 446, 8, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, + 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, + 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, + 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 5, 27, 484, + 8, 27, 10, 27, 12, 27, 487, 9, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, + 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 3, 28, 503, 8, 28, + 1, 28, 1, 28, 1, 28, 1, 28, 3, 28, 509, 8, 28, 1, 28, 1, 28, 1, 28, 1, 28, + 3, 28, 515, 8, 28, 1, 28, 3, 28, 518, 8, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, + 29, 1, 29, 3, 29, 526, 8, 29, 1, 30, 1, 30, 1, 30, 3, 30, 531, 8, 30, 1, 31, + 1, 31, 1, 31, 5, 31, 536, 8, 31, 10, 31, 12, 31, 539, 9, 31, 1, 31, 1, 31, + 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 3, 32, 552, + 8, 32, 1, 33, 1, 33, 1, 33, 5, 33, 557, 8, 33, 10, 33, 12, 33, 560, 9, 33, + 1, 33, 1, 33, 1, 34, 1, 34, 5, 34, 566, 8, 34, 10, 34, 12, 34, 569, 9, 34, + 1, 35, 1, 35, 5, 35, 573, 8, 35, 10, 35, 12, 35, 576, 9, 35, 1, 36, 1, 36, + 1, 36, 5, 36, 581, 8, 36, 10, 36, 12, 36, 584, 9, 36, 1, 36, 1, 36, 1, 37, + 1, 37, 5, 37, 590, 8, 37, 10, 37, 12, 37, 593, 9, 37, 1, 37, 1, 37, 1, 38, + 1, 38, 3, 38, 599, 8, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, + 1, 41, 1, 41, 3, 41, 610, 8, 41, 1, 42, 1, 42, 1, 42, 5, 42, 615, 8, 42, 10, + 42, 12, 42, 618, 9, 42, 1, 42, 1, 42, 1, 42, 0, 1, 54, 43, 0, 2, 4, 6, 8, + 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, + 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, + 0, 6, 2, 0, 40, 41, 67, 67, 2, 0, 45, 46, 53, 53, 1, 0, 48, 51, 1, 0, 52, + 53, 1, 0, 54, 55, 1, 0, 59, 64, 677, 0, 89, 1, 0, 0, 0, 2, 121, 1, 0, 0, 0, + 4, 157, 1, 0, 0, 0, 6, 169, 1, 0, 0, 0, 8, 171, 1, 0, 0, 0, 10, 178, 1, 0, + 0, 0, 12, 180, 1, 0, 0, 0, 14, 189, 1, 0, 0, 0, 16, 204, 1, 0, 0, 0, 18, + 213, 1, 0, 0, 0, 20, 220, 1, 0, 0, 0, 22, 224, 1, 0, 0, 0, 24, 231, 1, 0, 0, + 0, 26, 240, 1, 0, 0, 0, 28, 251, 1, 0, 0, 0, 30, 263, 1, 0, 0, 0, 32, 274, + 1, 0, 0, 0, 34, 276, 1, 0, 0, 0, 36, 279, 1, 0, 0, 0, 38, 293, 1, 0, 0, 0, + 40, 313, 1, 0, 0, 0, 42, 343, 1, 0, 0, 0, 44, 362, 1, 0, 0, 0, 46, 390, 1, + 0, 0, 0, 48, 413, 1, 0, 0, 0, 50, 420, 1, 0, 0, 0, 52, 432, 1, 0, 0, 0, 54, + 445, 1, 0, 0, 0, 56, 517, 1, 0, 0, 0, 58, 525, 1, 0, 0, 0, 60, 527, 1, 0, 0, + 0, 62, 537, 1, 0, 0, 0, 64, 551, 1, 0, 0, 0, 66, 558, 1, 0, 0, 0, 68, 563, + 1, 0, 0, 0, 70, 570, 1, 0, 0, 0, 72, 582, 1, 0, 0, 0, 74, 591, 1, 0, 0, 0, + 76, 598, 1, 0, 0, 0, 78, 600, 1, 0, 0, 0, 80, 604, 1, 0, 0, 0, 82, 609, 1, + 0, 0, 0, 84, 616, 1, 0, 0, 0, 86, 88, 3, 6, 3, 0, 87, 86, 1, 0, 0, 0, 88, + 91, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 95, 1, 0, 0, 0, + 91, 89, 1, 0, 0, 0, 92, 94, 3, 8, 4, 0, 93, 92, 1, 0, 0, 0, 94, 97, 1, 0, 0, + 0, 95, 93, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 101, 1, 0, 0, 0, 97, 95, 1, + 0, 0, 0, 98, 100, 3, 10, 5, 0, 99, 98, 1, 0, 0, 0, 100, 103, 1, 0, 0, 0, + 101, 99, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 105, 1, 0, 0, 0, 103, 101, + 1, 0, 0, 0, 104, 106, 3, 36, 18, 0, 105, 104, 1, 0, 0, 0, 105, 106, 1, 0, 0, + 0, 106, 107, 1, 0, 0, 0, 107, 108, 5, 0, 0, 1, 108, 1, 1, 0, 0, 0, 109, 111, + 5, 16, 0, 0, 110, 112, 5, 2, 0, 0, 111, 110, 1, 0, 0, 0, 111, 112, 1, 0, 0, + 0, 112, 114, 1, 0, 0, 0, 113, 115, 3, 20, 10, 0, 114, 113, 1, 0, 0, 0, 114, + 115, 1, 0, 0, 0, 115, 122, 1, 0, 0, 0, 116, 117, 5, 2, 0, 0, 117, 119, 5, + 16, 0, 0, 118, 120, 3, 20, 10, 0, 119, 118, 1, 0, 0, 0, 119, 120, 1, 0, 0, + 0, 120, 122, 1, 0, 0, 0, 121, 109, 1, 0, 0, 0, 121, 116, 1, 0, 0, 0, 122, 3, + 1, 0, 0, 0, 123, 125, 5, 69, 0, 0, 124, 126, 5, 2, 0, 0, 125, 124, 1, 0, 0, + 0, 125, 126, 1, 0, 0, 0, 126, 128, 1, 0, 0, 0, 127, 129, 3, 20, 10, 0, 128, + 127, 1, 0, 0, 0, 128, 129, 1, 0, 0, 0, 129, 158, 1, 0, 0, 0, 130, 131, 5, + 69, 0, 0, 131, 133, 5, 27, 0, 0, 132, 134, 3, 50, 25, 0, 133, 132, 1, 0, 0, + 0, 133, 134, 1, 0, 0, 0, 134, 135, 1, 0, 0, 0, 135, 137, 5, 28, 0, 0, 136, + 138, 5, 2, 0, 0, 137, 136, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 140, 1, 0, + 0, 0, 139, 141, 3, 20, 10, 0, 140, 139, 1, 0, 0, 0, 140, 141, 1, 0, 0, 0, + 141, 158, 1, 0, 0, 0, 142, 143, 5, 2, 0, 0, 143, 145, 5, 69, 0, 0, 144, 146, + 3, 20, 10, 0, 145, 144, 1, 0, 0, 0, 145, 146, 1, 0, 0, 0, 146, 158, 1, 0, 0, + 0, 147, 148, 5, 2, 0, 0, 148, 149, 5, 69, 0, 0, 149, 151, 5, 27, 0, 0, 150, + 152, 3, 50, 25, 0, 151, 150, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 153, 1, + 0, 0, 0, 153, 155, 5, 28, 0, 0, 154, 156, 3, 20, 10, 0, 155, 154, 1, 0, 0, + 0, 155, 156, 1, 0, 0, 0, 156, 158, 1, 0, 0, 0, 157, 123, 1, 0, 0, 0, 157, + 130, 1, 0, 0, 0, 157, 142, 1, 0, 0, 0, 157, 147, 1, 0, 0, 0, 158, 5, 1, 0, + 0, 0, 159, 160, 5, 3, 0, 0, 160, 161, 5, 4, 0, 0, 161, 162, 5, 1, 0, 0, 162, + 170, 5, 33, 0, 0, 163, 164, 5, 3, 0, 0, 164, 165, 5, 4, 0, 0, 165, 170, 5, + 33, 0, 0, 166, 167, 5, 3, 0, 0, 167, 168, 5, 5, 0, 0, 168, 170, 5, 33, 0, 0, + 169, 159, 1, 0, 0, 0, 169, 163, 1, 0, 0, 0, 169, 166, 1, 0, 0, 0, 170, 7, 1, + 0, 0, 0, 171, 172, 5, 6, 0, 0, 172, 173, 5, 72, 0, 0, 173, 174, 5, 33, 0, 0, + 174, 9, 1, 0, 0, 0, 175, 179, 3, 12, 6, 0, 176, 179, 3, 14, 7, 0, 177, 179, + 3, 16, 8, 0, 178, 175, 1, 0, 0, 0, 178, 176, 1, 0, 0, 0, 178, 177, 1, 0, 0, + 0, 179, 11, 1, 0, 0, 0, 180, 181, 5, 11, 0, 0, 181, 182, 5, 69, 0, 0, 182, + 184, 5, 27, 0, 0, 183, 185, 3, 74, 37, 0, 184, 183, 1, 0, 0, 0, 184, 185, 1, + 0, 0, 0, 185, 186, 1, 0, 0, 0, 186, 187, 5, 28, 0, 0, 187, 188, 3, 38, 19, + 0, 188, 13, 1, 0, 0, 0, 189, 191, 5, 10, 0, 0, 190, 192, 5, 7, 0, 0, 191, + 190, 1, 0, 0, 0, 191, 192, 1, 0, 0, 0, 192, 194, 1, 0, 0, 0, 193, 195, 5, 8, + 0, 0, 194, 193, 1, 0, 0, 0, 194, 195, 1, 0, 0, 0, 195, 196, 1, 0, 0, 0, 196, + 197, 5, 69, 0, 0, 197, 199, 5, 27, 0, 0, 198, 200, 3, 74, 37, 0, 199, 198, + 1, 0, 0, 0, 199, 200, 1, 0, 0, 0, 200, 201, 1, 0, 0, 0, 201, 202, 5, 28, 0, + 0, 202, 203, 3, 38, 19, 0, 203, 15, 1, 0, 0, 0, 204, 205, 5, 9, 0, 0, 205, + 206, 5, 69, 0, 0, 206, 208, 5, 27, 0, 0, 207, 209, 3, 74, 37, 0, 208, 207, + 1, 0, 0, 0, 208, 209, 1, 0, 0, 0, 209, 210, 1, 0, 0, 0, 210, 211, 5, 28, 0, + 0, 211, 212, 3, 38, 19, 0, 212, 17, 1, 0, 0, 0, 213, 214, 5, 31, 0, 0, 214, + 215, 5, 13, 0, 0, 215, 216, 5, 29, 0, 0, 216, 217, 3, 74, 37, 0, 217, 218, + 5, 30, 0, 0, 218, 219, 5, 32, 0, 0, 219, 19, 1, 0, 0, 0, 220, 221, 5, 31, 0, + 0, 221, 222, 3, 74, 37, 0, 222, 223, 5, 32, 0, 0, 223, 21, 1, 0, 0, 0, 224, + 225, 5, 24, 0, 0, 225, 227, 5, 27, 0, 0, 226, 228, 3, 84, 42, 0, 227, 226, + 1, 0, 0, 0, 227, 228, 1, 0, 0, 0, 228, 229, 1, 0, 0, 0, 229, 230, 5, 28, 0, + 0, 230, 23, 1, 0, 0, 0, 231, 232, 5, 25, 0, 0, 232, 233, 5, 27, 0, 0, 233, + 234, 3, 54, 27, 0, 234, 235, 5, 28, 0, 0, 235, 25, 1, 0, 0, 0, 236, 241, 3, + 28, 14, 0, 237, 241, 3, 30, 15, 0, 238, 241, 3, 32, 16, 0, 239, 241, 3, 34, + 17, 0, 240, 236, 1, 0, 0, 0, 240, 237, 1, 0, 0, 0, 240, 238, 1, 0, 0, 0, + 240, 239, 1, 0, 0, 0, 241, 27, 1, 0, 0, 0, 242, 243, 5, 15, 0, 0, 243, 244, + 5, 27, 0, 0, 244, 245, 3, 72, 36, 0, 245, 247, 5, 28, 0, 0, 246, 248, 3, 58, + 29, 0, 247, 246, 1, 0, 0, 0, 247, 248, 1, 0, 0, 0, 248, 252, 1, 0, 0, 0, + 249, 250, 5, 15, 0, 0, 250, 252, 3, 62, 31, 0, 251, 242, 1, 0, 0, 0, 251, + 249, 1, 0, 0, 0, 252, 29, 1, 0, 0, 0, 253, 254, 3, 2, 1, 0, 254, 255, 5, 27, + 0, 0, 255, 256, 3, 72, 36, 0, 256, 258, 5, 28, 0, 0, 257, 259, 3, 58, 29, 0, + 258, 257, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 259, 264, 1, 0, 0, 0, 260, 261, + 3, 2, 1, 0, 261, 262, 3, 66, 33, 0, 262, 264, 1, 0, 0, 0, 263, 253, 1, 0, 0, + 0, 263, 260, 1, 0, 0, 0, 264, 31, 1, 0, 0, 0, 265, 266, 5, 14, 0, 0, 266, + 267, 5, 27, 0, 0, 267, 268, 3, 72, 36, 0, 268, 270, 5, 28, 0, 0, 269, 271, + 3, 58, 29, 0, 270, 269, 1, 0, 0, 0, 270, 271, 1, 0, 0, 0, 271, 275, 1, 0, 0, + 0, 272, 273, 5, 14, 0, 0, 273, 275, 3, 62, 31, 0, 274, 265, 1, 0, 0, 0, 274, + 272, 1, 0, 0, 0, 275, 33, 1, 0, 0, 0, 276, 277, 3, 4, 2, 0, 277, 278, 3, 66, + 33, 0, 278, 35, 1, 0, 0, 0, 279, 280, 5, 14, 0, 0, 280, 282, 5, 12, 0, 0, + 281, 283, 3, 18, 9, 0, 282, 281, 1, 0, 0, 0, 282, 283, 1, 0, 0, 0, 283, 284, + 1, 0, 0, 0, 284, 285, 5, 67, 0, 0, 285, 286, 5, 69, 0, 0, 286, 288, 5, 27, + 0, 0, 287, 289, 3, 50, 25, 0, 288, 287, 1, 0, 0, 0, 288, 289, 1, 0, 0, 0, + 289, 290, 1, 0, 0, 0, 290, 291, 5, 28, 0, 0, 291, 292, 5, 33, 0, 0, 292, 37, + 1, 0, 0, 0, 293, 297, 5, 31, 0, 0, 294, 296, 3, 40, 20, 0, 295, 294, 1, 0, + 0, 0, 296, 299, 1, 0, 0, 0, 297, 295, 1, 0, 0, 0, 297, 298, 1, 0, 0, 0, 298, + 300, 1, 0, 0, 0, 299, 297, 1, 0, 0, 0, 300, 301, 5, 32, 0, 0, 301, 39, 1, 0, + 0, 0, 302, 303, 3, 26, 13, 0, 303, 304, 5, 33, 0, 0, 304, 314, 1, 0, 0, 0, + 305, 314, 3, 42, 21, 0, 306, 314, 3, 44, 22, 0, 307, 308, 3, 22, 11, 0, 308, + 309, 5, 33, 0, 0, 309, 314, 1, 0, 0, 0, 310, 311, 3, 24, 12, 0, 311, 312, 5, + 33, 0, 0, 312, 314, 1, 0, 0, 0, 313, 302, 1, 0, 0, 0, 313, 305, 1, 0, 0, 0, + 313, 306, 1, 0, 0, 0, 313, 307, 1, 0, 0, 0, 313, 310, 1, 0, 0, 0, 314, 41, + 1, 0, 0, 0, 315, 316, 5, 19, 0, 0, 316, 317, 5, 27, 0, 0, 317, 318, 3, 54, + 27, 0, 318, 319, 5, 28, 0, 0, 319, 320, 3, 42, 21, 0, 320, 344, 1, 0, 0, 0, + 321, 322, 5, 19, 0, 0, 322, 323, 5, 27, 0, 0, 323, 324, 3, 54, 27, 0, 324, + 325, 5, 28, 0, 0, 325, 326, 3, 44, 22, 0, 326, 344, 1, 0, 0, 0, 327, 328, 5, + 19, 0, 0, 328, 329, 5, 27, 0, 0, 329, 330, 3, 54, 27, 0, 330, 331, 5, 28, 0, + 0, 331, 332, 3, 44, 22, 0, 332, 333, 5, 20, 0, 0, 333, 334, 3, 42, 21, 0, + 334, 344, 1, 0, 0, 0, 335, 336, 5, 19, 0, 0, 336, 337, 5, 27, 0, 0, 337, + 338, 3, 54, 27, 0, 338, 339, 5, 28, 0, 0, 339, 340, 3, 44, 22, 0, 340, 341, + 5, 20, 0, 0, 341, 342, 3, 44, 22, 0, 342, 344, 1, 0, 0, 0, 343, 315, 1, 0, + 0, 0, 343, 321, 1, 0, 0, 0, 343, 327, 1, 0, 0, 0, 343, 335, 1, 0, 0, 0, 344, + 43, 1, 0, 0, 0, 345, 363, 3, 38, 19, 0, 346, 347, 3, 54, 27, 0, 347, 348, 5, + 33, 0, 0, 348, 363, 1, 0, 0, 0, 349, 350, 3, 48, 24, 0, 350, 351, 5, 33, 0, + 0, 351, 363, 1, 0, 0, 0, 352, 363, 3, 46, 23, 0, 353, 354, 3, 54, 27, 0, + 354, 355, 5, 39, 0, 0, 355, 356, 3, 54, 27, 0, 356, 357, 5, 33, 0, 0, 357, + 363, 1, 0, 0, 0, 358, 359, 5, 26, 0, 0, 359, 360, 3, 54, 27, 0, 360, 361, 5, + 33, 0, 0, 361, 363, 1, 0, 0, 0, 362, 345, 1, 0, 0, 0, 362, 346, 1, 0, 0, 0, + 362, 349, 1, 0, 0, 0, 362, 352, 1, 0, 0, 0, 362, 353, 1, 0, 0, 0, 362, 358, + 1, 0, 0, 0, 363, 45, 1, 0, 0, 0, 364, 365, 5, 21, 0, 0, 365, 366, 5, 27, 0, + 0, 366, 367, 3, 26, 13, 0, 367, 368, 5, 33, 0, 0, 368, 369, 3, 54, 27, 0, + 369, 370, 5, 33, 0, 0, 370, 371, 3, 48, 24, 0, 371, 372, 5, 28, 0, 0, 372, + 373, 3, 44, 22, 0, 373, 391, 1, 0, 0, 0, 374, 375, 5, 21, 0, 0, 375, 376, 5, + 27, 0, 0, 376, 377, 3, 48, 24, 0, 377, 378, 5, 33, 0, 0, 378, 379, 3, 54, + 27, 0, 379, 380, 5, 33, 0, 0, 380, 381, 3, 48, 24, 0, 381, 382, 5, 28, 0, 0, + 382, 383, 3, 44, 22, 0, 383, 391, 1, 0, 0, 0, 384, 385, 5, 22, 0, 0, 385, + 386, 5, 27, 0, 0, 386, 387, 3, 54, 27, 0, 387, 388, 5, 28, 0, 0, 388, 389, + 3, 44, 22, 0, 389, 391, 1, 0, 0, 0, 390, 364, 1, 0, 0, 0, 390, 374, 1, 0, 0, + 0, 390, 384, 1, 0, 0, 0, 391, 47, 1, 0, 0, 0, 392, 393, 3, 54, 27, 0, 393, + 394, 7, 0, 0, 0, 394, 395, 3, 54, 27, 0, 395, 414, 1, 0, 0, 0, 396, 397, 3, + 54, 27, 0, 397, 398, 5, 43, 0, 0, 398, 399, 3, 54, 27, 0, 399, 414, 1, 0, 0, + 0, 400, 401, 3, 54, 27, 0, 401, 402, 5, 42, 0, 0, 402, 403, 3, 54, 27, 0, + 403, 414, 1, 0, 0, 0, 404, 405, 3, 68, 34, 0, 405, 406, 5, 68, 0, 0, 406, + 407, 3, 54, 27, 0, 407, 414, 1, 0, 0, 0, 408, 409, 3, 68, 34, 0, 409, 410, + 5, 44, 0, 0, 410, 414, 1, 0, 0, 0, 411, 412, 5, 44, 0, 0, 412, 414, 3, 68, + 34, 0, 413, 392, 1, 0, 0, 0, 413, 396, 1, 0, 0, 0, 413, 400, 1, 0, 0, 0, + 413, 404, 1, 0, 0, 0, 413, 408, 1, 0, 0, 0, 413, 411, 1, 0, 0, 0, 414, 49, + 1, 0, 0, 0, 415, 416, 3, 54, 27, 0, 416, 417, 5, 35, 0, 0, 417, 419, 1, 0, + 0, 0, 418, 415, 1, 0, 0, 0, 419, 422, 1, 0, 0, 0, 420, 418, 1, 0, 0, 0, 420, + 421, 1, 0, 0, 0, 421, 423, 1, 0, 0, 0, 422, 420, 1, 0, 0, 0, 423, 424, 3, + 54, 27, 0, 424, 51, 1, 0, 0, 0, 425, 426, 5, 69, 0, 0, 426, 427, 7, 0, 0, 0, + 427, 428, 3, 54, 27, 0, 428, 429, 5, 35, 0, 0, 429, 431, 1, 0, 0, 0, 430, + 425, 1, 0, 0, 0, 431, 434, 1, 0, 0, 0, 432, 430, 1, 0, 0, 0, 432, 433, 1, 0, + 0, 0, 433, 435, 1, 0, 0, 0, 434, 432, 1, 0, 0, 0, 435, 436, 5, 69, 0, 0, + 436, 437, 7, 0, 0, 0, 437, 438, 3, 54, 27, 0, 438, 53, 1, 0, 0, 0, 439, 440, + 6, 27, -1, 0, 440, 446, 3, 56, 28, 0, 441, 442, 7, 1, 0, 0, 442, 446, 3, 54, + 27, 13, 443, 444, 5, 8, 0, 0, 444, 446, 3, 54, 27, 1, 445, 439, 1, 0, 0, 0, + 445, 441, 1, 0, 0, 0, 445, 443, 1, 0, 0, 0, 446, 485, 1, 0, 0, 0, 447, 448, + 10, 12, 0, 0, 448, 449, 5, 47, 0, 0, 449, 484, 3, 54, 27, 13, 450, 451, 10, + 11, 0, 0, 451, 452, 7, 2, 0, 0, 452, 484, 3, 54, 27, 12, 453, 454, 10, 10, + 0, 0, 454, 455, 7, 3, 0, 0, 455, 484, 3, 54, 27, 11, 456, 457, 10, 9, 0, 0, + 457, 458, 7, 4, 0, 0, 458, 484, 3, 54, 27, 10, 459, 460, 10, 8, 0, 0, 460, + 461, 5, 56, 0, 0, 461, 484, 3, 54, 27, 9, 462, 463, 10, 7, 0, 0, 463, 464, + 5, 57, 0, 0, 464, 484, 3, 54, 27, 8, 465, 466, 10, 6, 0, 0, 466, 467, 5, 58, + 0, 0, 467, 484, 3, 54, 27, 7, 468, 469, 10, 5, 0, 0, 469, 470, 7, 5, 0, 0, + 470, 484, 3, 54, 27, 6, 471, 472, 10, 4, 0, 0, 472, 473, 5, 65, 0, 0, 473, + 484, 3, 54, 27, 5, 474, 475, 10, 3, 0, 0, 475, 476, 5, 66, 0, 0, 476, 484, + 3, 54, 27, 4, 477, 478, 10, 2, 0, 0, 478, 479, 5, 37, 0, 0, 479, 480, 3, 54, + 27, 0, 480, 481, 5, 38, 0, 0, 481, 482, 3, 54, 27, 3, 482, 484, 1, 0, 0, 0, + 483, 447, 1, 0, 0, 0, 483, 450, 1, 0, 0, 0, 483, 453, 1, 0, 0, 0, 483, 456, + 1, 0, 0, 0, 483, 459, 1, 0, 0, 0, 483, 462, 1, 0, 0, 0, 483, 465, 1, 0, 0, + 0, 483, 468, 1, 0, 0, 0, 483, 471, 1, 0, 0, 0, 483, 474, 1, 0, 0, 0, 483, + 477, 1, 0, 0, 0, 484, 487, 1, 0, 0, 0, 485, 483, 1, 0, 0, 0, 485, 486, 1, 0, + 0, 0, 486, 55, 1, 0, 0, 0, 487, 485, 1, 0, 0, 0, 488, 518, 3, 68, 34, 0, + 489, 518, 5, 36, 0, 0, 490, 518, 5, 70, 0, 0, 491, 492, 5, 27, 0, 0, 492, + 493, 3, 50, 25, 0, 493, 494, 5, 28, 0, 0, 494, 518, 1, 0, 0, 0, 495, 496, 5, + 29, 0, 0, 496, 497, 3, 50, 25, 0, 497, 498, 5, 30, 0, 0, 498, 518, 1, 0, 0, + 0, 499, 500, 5, 69, 0, 0, 500, 502, 5, 27, 0, 0, 501, 503, 3, 50, 25, 0, + 502, 501, 1, 0, 0, 0, 502, 503, 1, 0, 0, 0, 503, 504, 1, 0, 0, 0, 504, 518, + 5, 28, 0, 0, 505, 506, 5, 69, 0, 0, 506, 508, 5, 27, 0, 0, 507, 509, 3, 50, + 25, 0, 508, 507, 1, 0, 0, 0, 508, 509, 1, 0, 0, 0, 509, 510, 1, 0, 0, 0, + 510, 511, 5, 28, 0, 0, 511, 514, 5, 27, 0, 0, 512, 515, 3, 50, 25, 0, 513, + 515, 3, 52, 26, 0, 514, 512, 1, 0, 0, 0, 514, 513, 1, 0, 0, 0, 514, 515, 1, + 0, 0, 0, 515, 516, 1, 0, 0, 0, 516, 518, 5, 28, 0, 0, 517, 488, 1, 0, 0, 0, + 517, 489, 1, 0, 0, 0, 517, 490, 1, 0, 0, 0, 517, 491, 1, 0, 0, 0, 517, 495, + 1, 0, 0, 0, 517, 499, 1, 0, 0, 0, 517, 505, 1, 0, 0, 0, 518, 57, 1, 0, 0, 0, + 519, 520, 5, 40, 0, 0, 520, 526, 3, 54, 27, 0, 521, 522, 5, 41, 0, 0, 522, + 526, 3, 54, 27, 0, 523, 524, 5, 67, 0, 0, 524, 526, 3, 54, 27, 0, 525, 519, + 1, 0, 0, 0, 525, 521, 1, 0, 0, 0, 525, 523, 1, 0, 0, 0, 526, 59, 1, 0, 0, 0, + 527, 530, 3, 70, 35, 0, 528, 529, 5, 67, 0, 0, 529, 531, 3, 54, 27, 0, 530, + 528, 1, 0, 0, 0, 530, 531, 1, 0, 0, 0, 531, 61, 1, 0, 0, 0, 532, 533, 3, 60, + 30, 0, 533, 534, 5, 35, 0, 0, 534, 536, 1, 0, 0, 0, 535, 532, 1, 0, 0, 0, + 536, 539, 1, 0, 0, 0, 537, 535, 1, 0, 0, 0, 537, 538, 1, 0, 0, 0, 538, 540, + 1, 0, 0, 0, 539, 537, 1, 0, 0, 0, 540, 541, 3, 60, 30, 0, 541, 63, 1, 0, 0, + 0, 542, 552, 3, 70, 35, 0, 543, 544, 3, 70, 35, 0, 544, 545, 5, 41, 0, 0, + 545, 546, 3, 54, 27, 0, 546, 552, 1, 0, 0, 0, 547, 548, 3, 70, 35, 0, 548, + 549, 5, 40, 0, 0, 549, 550, 3, 54, 27, 0, 550, 552, 1, 0, 0, 0, 551, 542, 1, + 0, 0, 0, 551, 543, 1, 0, 0, 0, 551, 547, 1, 0, 0, 0, 552, 65, 1, 0, 0, 0, + 553, 554, 3, 64, 32, 0, 554, 555, 5, 35, 0, 0, 555, 557, 1, 0, 0, 0, 556, + 553, 1, 0, 0, 0, 557, 560, 1, 0, 0, 0, 558, 556, 1, 0, 0, 0, 558, 559, 1, 0, + 0, 0, 559, 561, 1, 0, 0, 0, 560, 558, 1, 0, 0, 0, 561, 562, 3, 64, 32, 0, + 562, 67, 1, 0, 0, 0, 563, 567, 5, 69, 0, 0, 564, 566, 3, 76, 38, 0, 565, + 564, 1, 0, 0, 0, 566, 569, 1, 0, 0, 0, 567, 565, 1, 0, 0, 0, 567, 568, 1, 0, + 0, 0, 568, 69, 1, 0, 0, 0, 569, 567, 1, 0, 0, 0, 570, 574, 5, 69, 0, 0, 571, + 573, 3, 78, 39, 0, 572, 571, 1, 0, 0, 0, 573, 576, 1, 0, 0, 0, 574, 572, 1, + 0, 0, 0, 574, 575, 1, 0, 0, 0, 575, 71, 1, 0, 0, 0, 576, 574, 1, 0, 0, 0, + 577, 578, 3, 70, 35, 0, 578, 579, 5, 35, 0, 0, 579, 581, 1, 0, 0, 0, 580, + 577, 1, 0, 0, 0, 581, 584, 1, 0, 0, 0, 582, 580, 1, 0, 0, 0, 582, 583, 1, 0, + 0, 0, 583, 585, 1, 0, 0, 0, 584, 582, 1, 0, 0, 0, 585, 586, 3, 70, 35, 0, + 586, 73, 1, 0, 0, 0, 587, 588, 5, 69, 0, 0, 588, 590, 5, 35, 0, 0, 589, 587, + 1, 0, 0, 0, 590, 593, 1, 0, 0, 0, 591, 589, 1, 0, 0, 0, 591, 592, 1, 0, 0, + 0, 592, 594, 1, 0, 0, 0, 593, 591, 1, 0, 0, 0, 594, 595, 5, 69, 0, 0, 595, + 75, 1, 0, 0, 0, 596, 599, 3, 78, 39, 0, 597, 599, 3, 80, 40, 0, 598, 596, 1, + 0, 0, 0, 598, 597, 1, 0, 0, 0, 599, 77, 1, 0, 0, 0, 600, 601, 5, 29, 0, 0, + 601, 602, 3, 54, 27, 0, 602, 603, 5, 30, 0, 0, 603, 79, 1, 0, 0, 0, 604, + 605, 5, 34, 0, 0, 605, 606, 5, 69, 0, 0, 606, 81, 1, 0, 0, 0, 607, 610, 3, + 54, 27, 0, 608, 610, 5, 72, 0, 0, 609, 607, 1, 0, 0, 0, 609, 608, 1, 0, 0, + 0, 610, 83, 1, 0, 0, 0, 611, 612, 3, 82, 41, 0, 612, 613, 5, 35, 0, 0, 613, + 615, 1, 0, 0, 0, 614, 611, 1, 0, 0, 0, 615, 618, 1, 0, 0, 0, 616, 614, 1, 0, + 0, 0, 616, 617, 1, 0, 0, 0, 617, 619, 1, 0, 0, 0, 618, 616, 1, 0, 0, 0, 619, + 620, 3, 82, 41, 0, 620, 85, 1, 0, 0, 0, 61, 89, 95, 101, 105, 111, 114, 119, + 121, 125, 128, 133, 137, 140, 145, 151, 155, 157, 169, 178, 184, 191, 194, + 199, 208, 227, 240, 247, 251, 258, 263, 270, 274, 282, 288, 297, 313, 343, + 362, 390, 413, 420, 432, 445, 483, 485, 502, 508, 514, 517, 525, 530, 537, + 551, 558, 567, 574, 582, 591, 598, 609, 616, ]; private static __ATN: ATN; @@ -3501,16 +3592,457 @@ export default class CircomParser extends Parser { CircomParser._serializedATN, ); } - - return CircomParser.__ATN; + + return CircomParser.__ATN; + } + + static DecisionsToDFA = CircomParser._ATN.decisionToState.map( + (ds: DecisionState, index: number) => new DFA(ds, index), + ); +} + +export class CircuitContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public EOF(): TerminalNode { + return this.getToken(CircomParser.EOF, 0); + } + public pragmaDefinition_list(): PragmaDefinitionContext[] { + return this.getTypedRuleContexts( + PragmaDefinitionContext, + ) as PragmaDefinitionContext[]; + } + public pragmaDefinition(i: number): PragmaDefinitionContext { + return this.getTypedRuleContext( + PragmaDefinitionContext, + i, + ) as PragmaDefinitionContext; + } + public includeDefinition_list(): IncludeDefinitionContext[] { + return this.getTypedRuleContexts( + IncludeDefinitionContext, + ) as IncludeDefinitionContext[]; + } + public includeDefinition(i: number): IncludeDefinitionContext { + return this.getTypedRuleContext( + IncludeDefinitionContext, + i, + ) as IncludeDefinitionContext; + } + public blockDefiniton_list(): BlockDefinitonContext[] { + return this.getTypedRuleContexts( + BlockDefinitonContext, + ) as BlockDefinitonContext[]; + } + public blockDefiniton(i: number): BlockDefinitonContext { + return this.getTypedRuleContext( + BlockDefinitonContext, + i, + ) as BlockDefinitonContext; + } + public componentMainDeclaration(): ComponentMainDeclarationContext { + return this.getTypedRuleContext( + ComponentMainDeclarationContext, + 0, + ) as ComponentMainDeclarationContext; + } + public get ruleIndex(): number { + return CircomParser.RULE_circuit; + } + public enterRule(listener: CircomParserListener): void { + if (listener.enterCircuit) { + listener.enterCircuit(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitCircuit) { + listener.exitCircuit(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitCircuit) { + return visitor.visitCircuit(this); + } else { + return visitor.visitChildren(this); + } + } +} + +export class SignalHeaderContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public SIGNAL(): TerminalNode { + return this.getToken(CircomParser.SIGNAL, 0); + } + public SIGNAL_TYPE(): TerminalNode { + return this.getToken(CircomParser.SIGNAL_TYPE, 0); + } + public tagDefinition(): TagDefinitionContext { + return this.getTypedRuleContext( + TagDefinitionContext, + 0, + ) as TagDefinitionContext; + } + public get ruleIndex(): number { + return CircomParser.RULE_signalHeader; + } + public enterRule(listener: CircomParserListener): void { + if (listener.enterSignalHeader) { + listener.enterSignalHeader(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitSignalHeader) { + listener.exitSignalHeader(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitSignalHeader) { + return visitor.visitSignalHeader(this); + } else { + return visitor.visitChildren(this); + } + } +} + +export class BusHeaderContext extends ParserRuleContext { + public _wireType!: Token; + public _parameters!: ExpressionListContext; + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public ID(): TerminalNode { + return this.getToken(CircomParser.ID, 0); + } + public tagDefinition(): TagDefinitionContext { + return this.getTypedRuleContext( + TagDefinitionContext, + 0, + ) as TagDefinitionContext; + } + public SIGNAL_TYPE(): TerminalNode { + return this.getToken(CircomParser.SIGNAL_TYPE, 0); + } + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); + } + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); + } + public expressionList(): ExpressionListContext { + return this.getTypedRuleContext( + ExpressionListContext, + 0, + ) as ExpressionListContext; + } + public get ruleIndex(): number { + return CircomParser.RULE_busHeader; + } + public enterRule(listener: CircomParserListener): void { + if (listener.enterBusHeader) { + listener.enterBusHeader(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitBusHeader) { + listener.exitBusHeader(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitBusHeader) { + return visitor.visitBusHeader(this); + } else { + return visitor.visitChildren(this); + } + } +} + +export class PragmaDefinitionContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public get ruleIndex(): number { + return CircomParser.RULE_pragmaDefinition; + } + public copyFrom(ctx: PragmaDefinitionContext): void { + super.copyFrom(ctx); + } +} +export class PragmaCustomTemplatesContext extends PragmaDefinitionContext { + constructor(parser: CircomParser, ctx: PragmaDefinitionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public PRAGMA(): TerminalNode { + return this.getToken(CircomParser.PRAGMA, 0); + } + public CUSTOM_TEMPLATES(): TerminalNode { + return this.getToken(CircomParser.CUSTOM_TEMPLATES, 0); + } + public SEMICOLON(): TerminalNode { + return this.getToken(CircomParser.SEMICOLON, 0); + } + public enterRule(listener: CircomParserListener): void { + if (listener.enterPragmaCustomTemplates) { + listener.enterPragmaCustomTemplates(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitPragmaCustomTemplates) { + listener.exitPragmaCustomTemplates(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitPragmaCustomTemplates) { + return visitor.visitPragmaCustomTemplates(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class PragmaVersionContext extends PragmaDefinitionContext { + constructor(parser: CircomParser, ctx: PragmaDefinitionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public PRAGMA(): TerminalNode { + return this.getToken(CircomParser.PRAGMA, 0); + } + public CIRCOM(): TerminalNode { + return this.getToken(CircomParser.CIRCOM, 0); + } + public VERSION(): TerminalNode { + return this.getToken(CircomParser.VERSION, 0); + } + public SEMICOLON(): TerminalNode { + return this.getToken(CircomParser.SEMICOLON, 0); + } + public enterRule(listener: CircomParserListener): void { + if (listener.enterPragmaVersion) { + listener.enterPragmaVersion(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitPragmaVersion) { + listener.exitPragmaVersion(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitPragmaVersion) { + return visitor.visitPragmaVersion(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class PragmaInvalidVersionContext extends PragmaDefinitionContext { + constructor(parser: CircomParser, ctx: PragmaDefinitionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public PRAGMA(): TerminalNode { + return this.getToken(CircomParser.PRAGMA, 0); + } + public CIRCOM(): TerminalNode { + return this.getToken(CircomParser.CIRCOM, 0); + } + public SEMICOLON(): TerminalNode { + return this.getToken(CircomParser.SEMICOLON, 0); + } + public enterRule(listener: CircomParserListener): void { + if (listener.enterPragmaInvalidVersion) { + listener.enterPragmaInvalidVersion(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitPragmaInvalidVersion) { + listener.exitPragmaInvalidVersion(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitPragmaInvalidVersion) { + return visitor.visitPragmaInvalidVersion(this); + } else { + return visitor.visitChildren(this); + } + } +} + +export class IncludeDefinitionContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public INCLUDE(): TerminalNode { + return this.getToken(CircomParser.INCLUDE, 0); + } + public STRING(): TerminalNode { + return this.getToken(CircomParser.STRING, 0); + } + public SEMICOLON(): TerminalNode { + return this.getToken(CircomParser.SEMICOLON, 0); + } + public get ruleIndex(): number { + return CircomParser.RULE_includeDefinition; + } + public enterRule(listener: CircomParserListener): void { + if (listener.enterIncludeDefinition) { + listener.enterIncludeDefinition(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitIncludeDefinition) { + listener.exitIncludeDefinition(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitIncludeDefinition) { + return visitor.visitIncludeDefinition(this); + } else { + return visitor.visitChildren(this); + } + } +} + +export class BlockDefinitonContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public functionDefinition(): FunctionDefinitionContext { + return this.getTypedRuleContext( + FunctionDefinitionContext, + 0, + ) as FunctionDefinitionContext; + } + public templateDefinition(): TemplateDefinitionContext { + return this.getTypedRuleContext( + TemplateDefinitionContext, + 0, + ) as TemplateDefinitionContext; + } + public busDefinition(): BusDefinitionContext { + return this.getTypedRuleContext( + BusDefinitionContext, + 0, + ) as BusDefinitionContext; + } + public get ruleIndex(): number { + return CircomParser.RULE_blockDefiniton; + } + public enterRule(listener: CircomParserListener): void { + if (listener.enterBlockDefiniton) { + listener.enterBlockDefiniton(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitBlockDefiniton) { + listener.exitBlockDefiniton(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitBlockDefiniton) { + return visitor.visitBlockDefiniton(this); + } else { + return visitor.visitChildren(this); + } + } +} + +export class FunctionDefinitionContext extends ParserRuleContext { + public _argNames!: SimpleIdentifierListContext; + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public FUNCTION(): TerminalNode { + return this.getToken(CircomParser.FUNCTION, 0); + } + public ID(): TerminalNode { + return this.getToken(CircomParser.ID, 0); + } + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); + } + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); + } + public body(): BodyContext { + return this.getTypedRuleContext(BodyContext, 0) as BodyContext; + } + public simpleIdentifierList(): SimpleIdentifierListContext { + return this.getTypedRuleContext( + SimpleIdentifierListContext, + 0, + ) as SimpleIdentifierListContext; + } + public get ruleIndex(): number { + return CircomParser.RULE_functionDefinition; + } + public enterRule(listener: CircomParserListener): void { + if (listener.enterFunctionDefinition) { + listener.enterFunctionDefinition(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitFunctionDefinition) { + listener.exitFunctionDefinition(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitFunctionDefinition) { + return visitor.visitFunctionDefinition(this); + } else { + return visitor.visitChildren(this); + } } - - static DecisionsToDFA = CircomParser._ATN.decisionToState.map( - (ds: DecisionState, index: number) => new DFA(ds, index), - ); } -export class CircuitContext extends ParserRuleContext { +export class TemplateDefinitionContext extends ParserRuleContext { + public _argNames!: SimpleIdentifierListContext; constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -3519,72 +4051,58 @@ export class CircuitContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public EOF(): TerminalNode { - return this.getToken(CircomParser.EOF, 0); + public TEMPLATE(): TerminalNode { + return this.getToken(CircomParser.TEMPLATE, 0); } - public pragmaDeclaration_list(): PragmaDeclarationContext[] { - return this.getTypedRuleContexts( - PragmaDeclarationContext, - ) as PragmaDeclarationContext[]; + public ID(): TerminalNode { + return this.getToken(CircomParser.ID, 0); } - public pragmaDeclaration(i: number): PragmaDeclarationContext { - return this.getTypedRuleContext( - PragmaDeclarationContext, - i, - ) as PragmaDeclarationContext; + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); } - public includeDeclaration_list(): IncludeDeclarationContext[] { - return this.getTypedRuleContexts( - IncludeDeclarationContext, - ) as IncludeDeclarationContext[]; + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); } - public includeDeclaration(i: number): IncludeDeclarationContext { - return this.getTypedRuleContext( - IncludeDeclarationContext, - i, - ) as IncludeDeclarationContext; + public body(): BodyContext { + return this.getTypedRuleContext(BodyContext, 0) as BodyContext; } - public blockDeclaration_list(): BlockDeclarationContext[] { - return this.getTypedRuleContexts( - BlockDeclarationContext, - ) as BlockDeclarationContext[]; + public CUSTOM(): TerminalNode { + return this.getToken(CircomParser.CUSTOM, 0); } - public blockDeclaration(i: number): BlockDeclarationContext { - return this.getTypedRuleContext( - BlockDeclarationContext, - i, - ) as BlockDeclarationContext; + public PARALLEL(): TerminalNode { + return this.getToken(CircomParser.PARALLEL, 0); } - public componentMainDeclaration(): ComponentMainDeclarationContext { + public simpleIdentifierList(): SimpleIdentifierListContext { return this.getTypedRuleContext( - ComponentMainDeclarationContext, + SimpleIdentifierListContext, 0, - ) as ComponentMainDeclarationContext; + ) as SimpleIdentifierListContext; } public get ruleIndex(): number { - return CircomParser.RULE_circuit; + return CircomParser.RULE_templateDefinition; } public enterRule(listener: CircomParserListener): void { - if (listener.enterCircuit) { - listener.enterCircuit(this); + if (listener.enterTemplateDefinition) { + listener.enterTemplateDefinition(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitCircuit) { - listener.exitCircuit(this); + if (listener.exitTemplateDefinition) { + listener.exitTemplateDefinition(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitCircuit) { - return visitor.visitCircuit(this); + if (visitor.visitTemplateDefinition) { + return visitor.visitTemplateDefinition(this); } else { return visitor.visitChildren(this); } } } -export class PragmaDeclarationContext extends ParserRuleContext { +export class BusDefinitionContext extends ParserRuleContext { + public _argNames!: SimpleIdentifierListContext; constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -3593,45 +4111,52 @@ export class PragmaDeclarationContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public PRAGMA(): TerminalNode { - return this.getToken(CircomParser.PRAGMA, 0); + public BUS(): TerminalNode { + return this.getToken(CircomParser.BUS, 0); } - public CIRCOM(): TerminalNode { - return this.getToken(CircomParser.CIRCOM, 0); + public ID(): TerminalNode { + return this.getToken(CircomParser.ID, 0); } - public VERSION(): TerminalNode { - return this.getToken(CircomParser.VERSION, 0); + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); } - public SEMICOLON(): TerminalNode { - return this.getToken(CircomParser.SEMICOLON, 0); + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); } - public CUSTOM_TEMPLATES(): TerminalNode { - return this.getToken(CircomParser.CUSTOM_TEMPLATES, 0); + public body(): BodyContext { + return this.getTypedRuleContext(BodyContext, 0) as BodyContext; + } + public simpleIdentifierList(): SimpleIdentifierListContext { + return this.getTypedRuleContext( + SimpleIdentifierListContext, + 0, + ) as SimpleIdentifierListContext; } public get ruleIndex(): number { - return CircomParser.RULE_pragmaDeclaration; + return CircomParser.RULE_busDefinition; } public enterRule(listener: CircomParserListener): void { - if (listener.enterPragmaDeclaration) { - listener.enterPragmaDeclaration(this); + if (listener.enterBusDefinition) { + listener.enterBusDefinition(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitPragmaDeclaration) { - listener.exitPragmaDeclaration(this); + if (listener.exitBusDefinition) { + listener.exitBusDefinition(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitPragmaDeclaration) { - return visitor.visitPragmaDeclaration(this); + if (visitor.visitBusDefinition) { + return visitor.visitBusDefinition(this); } else { return visitor.visitChildren(this); } } } -export class IncludeDeclarationContext extends ParserRuleContext { +export class PublicInputsDefinitionContext extends ParserRuleContext { + public _publicInputs!: SimpleIdentifierListContext; constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -3640,39 +4165,52 @@ export class IncludeDeclarationContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public INCLUDE(): TerminalNode { - return this.getToken(CircomParser.INCLUDE, 0); + public LC(): TerminalNode { + return this.getToken(CircomParser.LC, 0); } - public STRING(): TerminalNode { - return this.getToken(CircomParser.STRING, 0); + public PUBLIC(): TerminalNode { + return this.getToken(CircomParser.PUBLIC, 0); } - public SEMICOLON(): TerminalNode { - return this.getToken(CircomParser.SEMICOLON, 0); + public LB(): TerminalNode { + return this.getToken(CircomParser.LB, 0); + } + public RB(): TerminalNode { + return this.getToken(CircomParser.RB, 0); + } + public RC(): TerminalNode { + return this.getToken(CircomParser.RC, 0); + } + public simpleIdentifierList(): SimpleIdentifierListContext { + return this.getTypedRuleContext( + SimpleIdentifierListContext, + 0, + ) as SimpleIdentifierListContext; } public get ruleIndex(): number { - return CircomParser.RULE_includeDeclaration; + return CircomParser.RULE_publicInputsDefinition; } public enterRule(listener: CircomParserListener): void { - if (listener.enterIncludeDeclaration) { - listener.enterIncludeDeclaration(this); + if (listener.enterPublicInputsDefinition) { + listener.enterPublicInputsDefinition(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitIncludeDeclaration) { - listener.exitIncludeDeclaration(this); + if (listener.exitPublicInputsDefinition) { + listener.exitPublicInputsDefinition(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitIncludeDeclaration) { - return visitor.visitIncludeDeclaration(this); + if (visitor.visitPublicInputsDefinition) { + return visitor.visitPublicInputsDefinition(this); } else { return visitor.visitChildren(this); } } } -export class BlockDeclarationContext extends ParserRuleContext { +export class TagDefinitionContext extends ParserRuleContext { + public _values!: SimpleIdentifierListContext; constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -3681,42 +4219,43 @@ export class BlockDeclarationContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public functionDeclaration(): FunctionDeclarationContext { - return this.getTypedRuleContext( - FunctionDeclarationContext, - 0, - ) as FunctionDeclarationContext; + public LC(): TerminalNode { + return this.getToken(CircomParser.LC, 0); + } + public RC(): TerminalNode { + return this.getToken(CircomParser.RC, 0); } - public templateDeclaration(): TemplateDeclarationContext { + public simpleIdentifierList(): SimpleIdentifierListContext { return this.getTypedRuleContext( - TemplateDeclarationContext, + SimpleIdentifierListContext, 0, - ) as TemplateDeclarationContext; + ) as SimpleIdentifierListContext; } public get ruleIndex(): number { - return CircomParser.RULE_blockDeclaration; + return CircomParser.RULE_tagDefinition; } public enterRule(listener: CircomParserListener): void { - if (listener.enterBlockDeclaration) { - listener.enterBlockDeclaration(this); + if (listener.enterTagDefinition) { + listener.enterTagDefinition(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitBlockDeclaration) { - listener.exitBlockDeclaration(this); + if (listener.exitTagDefinition) { + listener.exitTagDefinition(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitBlockDeclaration) { - return visitor.visitBlockDeclaration(this); + if (visitor.visitTagDefinition) { + return visitor.visitTagDefinition(this); } else { return visitor.visitChildren(this); } } } -export class FunctionDeclarationContext extends ParserRuleContext { +export class LogDefinitionContext extends ParserRuleContext { + public _logArgs!: ExpressionOrStringListContext; constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -3725,11 +4264,8 @@ export class FunctionDeclarationContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public FUNCTION(): TerminalNode { - return this.getToken(CircomParser.FUNCTION, 0); - } - public ID(): TerminalNode { - return this.getToken(CircomParser.ID, 0); + public LOG(): TerminalNode { + return this.getToken(CircomParser.LOG, 0); } public LP(): TerminalNode { return this.getToken(CircomParser.LP, 0); @@ -3737,39 +4273,37 @@ export class FunctionDeclarationContext extends ParserRuleContext { public RP(): TerminalNode { return this.getToken(CircomParser.RP, 0); } - public functionBlock(): FunctionBlockContext { + public expressionOrStringList(): ExpressionOrStringListContext { return this.getTypedRuleContext( - FunctionBlockContext, + ExpressionOrStringListContext, 0, - ) as FunctionBlockContext; - } - public args(): ArgsContext { - return this.getTypedRuleContext(ArgsContext, 0) as ArgsContext; + ) as ExpressionOrStringListContext; } public get ruleIndex(): number { - return CircomParser.RULE_functionDeclaration; + return CircomParser.RULE_logDefinition; } public enterRule(listener: CircomParserListener): void { - if (listener.enterFunctionDeclaration) { - listener.enterFunctionDeclaration(this); + if (listener.enterLogDefinition) { + listener.enterLogDefinition(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitFunctionDeclaration) { - listener.exitFunctionDeclaration(this); + if (listener.exitLogDefinition) { + listener.exitLogDefinition(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitFunctionDeclaration) { - return visitor.visitFunctionDeclaration(this); + if (visitor.visitLogDefinition) { + return visitor.visitLogDefinition(this); } else { return visitor.visitChildren(this); } } } -export class FunctionBlockContext extends ParserRuleContext { +export class AssertDefinitionContext extends ParserRuleContext { + public _assertArgs!: ExpressionContext; constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -3778,47 +4312,42 @@ export class FunctionBlockContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public LC(): TerminalNode { - return this.getToken(CircomParser.LC, 0); + public ASSERT(): TerminalNode { + return this.getToken(CircomParser.ASSERT, 0); } - public RC(): TerminalNode { - return this.getToken(CircomParser.RC, 0); + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); } - public functionStmt_list(): FunctionStmtContext[] { - return this.getTypedRuleContexts( - FunctionStmtContext, - ) as FunctionStmtContext[]; + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); } - public functionStmt(i: number): FunctionStmtContext { - return this.getTypedRuleContext( - FunctionStmtContext, - i, - ) as FunctionStmtContext; + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } public get ruleIndex(): number { - return CircomParser.RULE_functionBlock; + return CircomParser.RULE_assertDefinition; } public enterRule(listener: CircomParserListener): void { - if (listener.enterFunctionBlock) { - listener.enterFunctionBlock(this); + if (listener.enterAssertDefinition) { + listener.enterAssertDefinition(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitFunctionBlock) { - listener.exitFunctionBlock(this); + if (listener.exitAssertDefinition) { + listener.exitAssertDefinition(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitFunctionBlock) { - return visitor.visitFunctionBlock(this); + if (visitor.visitAssertDefinition) { + return visitor.visitAssertDefinition(this); } else { return visitor.visitChildren(this); } } } -export class FunctionStmtContext extends ParserRuleContext { +export class DeclarationsContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -3827,445 +4356,656 @@ export class FunctionStmtContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } + public varDeclaration(): VarDeclarationContext { + return this.getTypedRuleContext( + VarDeclarationContext, + 0, + ) as VarDeclarationContext; + } + public signalDeclaration(): SignalDeclarationContext { + return this.getTypedRuleContext( + SignalDeclarationContext, + 0, + ) as SignalDeclarationContext; + } + public componentDeclaration(): ComponentDeclarationContext { + return this.getTypedRuleContext( + ComponentDeclarationContext, + 0, + ) as ComponentDeclarationContext; + } + public busDeclaration(): BusDeclarationContext { + return this.getTypedRuleContext( + BusDeclarationContext, + 0, + ) as BusDeclarationContext; + } public get ruleIndex(): number { - return CircomParser.RULE_functionStmt; + return CircomParser.RULE_declarations; } - public copyFrom(ctx: FunctionStmtContext): void { - super.copyFrom(ctx); + public enterRule(listener: CircomParserListener): void { + if (listener.enterDeclarations) { + listener.enterDeclarations(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitDeclarations) { + listener.exitDeclarations(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitDeclarations) { + return visitor.visitDeclarations(this); + } else { + return visitor.visitChildren(this); + } } } -export class ForFuncStmtContext extends FunctionStmtContext { - constructor(parser: CircomParser, ctx: FunctionStmtContext) { - super(parser, ctx.parentCtx, ctx.invokingState); - super.copyFrom(ctx); + +export class VarDeclarationContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; } - public FOR(): TerminalNode { - return this.getToken(CircomParser.FOR, 0); + public VAR(): TerminalNode { + return this.getToken(CircomParser.VAR, 0); } public LP(): TerminalNode { return this.getToken(CircomParser.LP, 0); } - public forControl(): ForControlContext { - return this.getTypedRuleContext(ForControlContext, 0) as ForControlContext; + public identifierList(): IdentifierListContext { + return this.getTypedRuleContext( + IdentifierListContext, + 0, + ) as IdentifierListContext; } public RP(): TerminalNode { return this.getToken(CircomParser.RP, 0); } - public functionStmt(): FunctionStmtContext { + public assignmentExpression(): AssignmentExpressionContext { + return this.getTypedRuleContext( + AssignmentExpressionContext, + 0, + ) as AssignmentExpressionContext; + } + public varIdentifierList(): VarIdentifierListContext { return this.getTypedRuleContext( - FunctionStmtContext, + VarIdentifierListContext, 0, - ) as FunctionStmtContext; + ) as VarIdentifierListContext; + } + public get ruleIndex(): number { + return CircomParser.RULE_varDeclaration; } public enterRule(listener: CircomParserListener): void { - if (listener.enterForFuncStmt) { - listener.enterForFuncStmt(this); + if (listener.enterVarDeclaration) { + listener.enterVarDeclaration(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitForFuncStmt) { - listener.exitForFuncStmt(this); + if (listener.exitVarDeclaration) { + listener.exitVarDeclaration(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitForFuncStmt) { - return visitor.visitForFuncStmt(this); + if (visitor.visitVarDeclaration) { + return visitor.visitVarDeclaration(this); } else { return visitor.visitChildren(this); } } } -export class LogFuncStmtContext extends FunctionStmtContext { - constructor(parser: CircomParser, ctx: FunctionStmtContext) { - super(parser, ctx.parentCtx, ctx.invokingState); - super.copyFrom(ctx); + +export class SignalDeclarationContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; } - public logStmt(): LogStmtContext { - return this.getTypedRuleContext(LogStmtContext, 0) as LogStmtContext; + public signalHeader(): SignalHeaderContext { + return this.getTypedRuleContext( + SignalHeaderContext, + 0, + ) as SignalHeaderContext; } - public SEMICOLON(): TerminalNode { - return this.getToken(CircomParser.SEMICOLON, 0); + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); + } + public identifierList(): IdentifierListContext { + return this.getTypedRuleContext( + IdentifierListContext, + 0, + ) as IdentifierListContext; + } + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); + } + public assignmentExpression(): AssignmentExpressionContext { + return this.getTypedRuleContext( + AssignmentExpressionContext, + 0, + ) as AssignmentExpressionContext; + } + public signalIdentifierList(): SignalIdentifierListContext { + return this.getTypedRuleContext( + SignalIdentifierListContext, + 0, + ) as SignalIdentifierListContext; + } + public get ruleIndex(): number { + return CircomParser.RULE_signalDeclaration; } public enterRule(listener: CircomParserListener): void { - if (listener.enterLogFuncStmt) { - listener.enterLogFuncStmt(this); + if (listener.enterSignalDeclaration) { + listener.enterSignalDeclaration(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitLogFuncStmt) { - listener.exitLogFuncStmt(this); + if (listener.exitSignalDeclaration) { + listener.exitSignalDeclaration(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitLogFuncStmt) { - return visitor.visitLogFuncStmt(this); + if (visitor.visitSignalDeclaration) { + return visitor.visitSignalDeclaration(this); } else { return visitor.visitChildren(this); } } } -export class FuncVarDeclarationContext extends FunctionStmtContext { - constructor(parser: CircomParser, ctx: FunctionStmtContext) { - super(parser, ctx.parentCtx, ctx.invokingState); - super.copyFrom(ctx); + +export class ComponentDeclarationContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; } - public varDeclaration(): VarDeclarationContext { + public COMPONENT(): TerminalNode { + return this.getToken(CircomParser.COMPONENT, 0); + } + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); + } + public identifierList(): IdentifierListContext { return this.getTypedRuleContext( - VarDeclarationContext, + IdentifierListContext, 0, - ) as VarDeclarationContext; + ) as IdentifierListContext; + } + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); + } + public assignmentExpression(): AssignmentExpressionContext { + return this.getTypedRuleContext( + AssignmentExpressionContext, + 0, + ) as AssignmentExpressionContext; + } + public varIdentifierList(): VarIdentifierListContext { + return this.getTypedRuleContext( + VarIdentifierListContext, + 0, + ) as VarIdentifierListContext; } - public SEMICOLON(): TerminalNode { - return this.getToken(CircomParser.SEMICOLON, 0); + public get ruleIndex(): number { + return CircomParser.RULE_componentDeclaration; } public enterRule(listener: CircomParserListener): void { - if (listener.enterFuncVarDeclaration) { - listener.enterFuncVarDeclaration(this); + if (listener.enterComponentDeclaration) { + listener.enterComponentDeclaration(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitFuncVarDeclaration) { - listener.exitFuncVarDeclaration(this); + if (listener.exitComponentDeclaration) { + listener.exitComponentDeclaration(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitFuncVarDeclaration) { - return visitor.visitFuncVarDeclaration(this); + if (visitor.visitComponentDeclaration) { + return visitor.visitComponentDeclaration(this); } else { return visitor.visitChildren(this); } } } -export class AssertFuncStmtContext extends FunctionStmtContext { - constructor(parser: CircomParser, ctx: FunctionStmtContext) { - super(parser, ctx.parentCtx, ctx.invokingState); - super.copyFrom(ctx); + +export class BusDeclarationContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; } - public ASSERT(): TerminalNode { - return this.getToken(CircomParser.ASSERT, 0); + public busHeader(): BusHeaderContext { + return this.getTypedRuleContext(BusHeaderContext, 0) as BusHeaderContext; } - public parExpression(): ParExpressionContext { + public signalIdentifierList(): SignalIdentifierListContext { return this.getTypedRuleContext( - ParExpressionContext, + SignalIdentifierListContext, 0, - ) as ParExpressionContext; + ) as SignalIdentifierListContext; } - public SEMICOLON(): TerminalNode { - return this.getToken(CircomParser.SEMICOLON, 0); + public get ruleIndex(): number { + return CircomParser.RULE_busDeclaration; } public enterRule(listener: CircomParserListener): void { - if (listener.enterAssertFuncStmt) { - listener.enterAssertFuncStmt(this); + if (listener.enterBusDeclaration) { + listener.enterBusDeclaration(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitAssertFuncStmt) { - listener.exitAssertFuncStmt(this); + if (listener.exitBusDeclaration) { + listener.exitBusDeclaration(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitAssertFuncStmt) { - return visitor.visitAssertFuncStmt(this); + if (visitor.visitBusDeclaration) { + return visitor.visitBusDeclaration(this); } else { return visitor.visitChildren(this); } } } -export class FuncBlockContext extends FunctionStmtContext { - constructor(parser: CircomParser, ctx: FunctionStmtContext) { - super(parser, ctx.parentCtx, ctx.invokingState); - super.copyFrom(ctx); + +export class ComponentMainDeclarationContext extends ParserRuleContext { + public _argValues!: ExpressionListContext; + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public COMPONENT(): TerminalNode { + return this.getToken(CircomParser.COMPONENT, 0); + } + public MAIN(): TerminalNode { + return this.getToken(CircomParser.MAIN, 0); + } + public ASSIGNMENT(): TerminalNode { + return this.getToken(CircomParser.ASSIGNMENT, 0); + } + public ID(): TerminalNode { + return this.getToken(CircomParser.ID, 0); } - public functionBlock(): FunctionBlockContext { + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); + } + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); + } + public SEMICOLON(): TerminalNode { + return this.getToken(CircomParser.SEMICOLON, 0); + } + public publicInputsDefinition(): PublicInputsDefinitionContext { + return this.getTypedRuleContext( + PublicInputsDefinitionContext, + 0, + ) as PublicInputsDefinitionContext; + } + public expressionList(): ExpressionListContext { return this.getTypedRuleContext( - FunctionBlockContext, + ExpressionListContext, 0, - ) as FunctionBlockContext; + ) as ExpressionListContext; + } + public get ruleIndex(): number { + return CircomParser.RULE_componentMainDeclaration; } public enterRule(listener: CircomParserListener): void { - if (listener.enterFuncBlock) { - listener.enterFuncBlock(this); + if (listener.enterComponentMainDeclaration) { + listener.enterComponentMainDeclaration(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitFuncBlock) { - listener.exitFuncBlock(this); + if (listener.exitComponentMainDeclaration) { + listener.exitComponentMainDeclaration(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitFuncBlock) { - return visitor.visitFuncBlock(this); + if (visitor.visitComponentMainDeclaration) { + return visitor.visitComponentMainDeclaration(this); } else { return visitor.visitChildren(this); } } } -export class FuncSelfOpContext extends FunctionStmtContext { - constructor(parser: CircomParser, ctx: FunctionStmtContext) { - super(parser, ctx.parentCtx, ctx.invokingState); - super.copyFrom(ctx); + +export class BodyContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; } - public ID(): TerminalNode { - return this.getToken(CircomParser.ID, 0); + public LC(): TerminalNode { + return this.getToken(CircomParser.LC, 0); } - public SELF_OP(): TerminalNode { - return this.getToken(CircomParser.SELF_OP, 0); + public RC(): TerminalNode { + return this.getToken(CircomParser.RC, 0); } - public SEMICOLON(): TerminalNode { - return this.getToken(CircomParser.SEMICOLON, 0); + public statements_list(): StatementsContext[] { + return this.getTypedRuleContexts(StatementsContext) as StatementsContext[]; } - public arrayDimension_list(): ArrayDimensionContext[] { - return this.getTypedRuleContexts( - ArrayDimensionContext, - ) as ArrayDimensionContext[]; + public statements(i: number): StatementsContext { + return this.getTypedRuleContext(StatementsContext, i) as StatementsContext; } - public arrayDimension(i: number): ArrayDimensionContext { - return this.getTypedRuleContext( - ArrayDimensionContext, - i, - ) as ArrayDimensionContext; + public get ruleIndex(): number { + return CircomParser.RULE_body; } public enterRule(listener: CircomParserListener): void { - if (listener.enterFuncSelfOp) { - listener.enterFuncSelfOp(this); + if (listener.enterBody) { + listener.enterBody(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitFuncSelfOp) { - listener.exitFuncSelfOp(this); + if (listener.exitBody) { + listener.exitBody(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitFuncSelfOp) { - return visitor.visitFuncSelfOp(this); + if (visitor.visitBody) { + return visitor.visitBody(this); } else { return visitor.visitChildren(this); } } } -export class IfFuncStmtContext extends FunctionStmtContext { - constructor(parser: CircomParser, ctx: FunctionStmtContext) { - super(parser, ctx.parentCtx, ctx.invokingState); - super.copyFrom(ctx); + +export class StatementsContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; } - public IF(): TerminalNode { - return this.getToken(CircomParser.IF, 0); + public declarations(): DeclarationsContext { + return this.getTypedRuleContext( + DeclarationsContext, + 0, + ) as DeclarationsContext; } - public parExpression(): ParExpressionContext { + public SEMICOLON(): TerminalNode { + return this.getToken(CircomParser.SEMICOLON, 0); + } + public ifStatements(): IfStatementsContext { return this.getTypedRuleContext( - ParExpressionContext, + IfStatementsContext, 0, - ) as ParExpressionContext; + ) as IfStatementsContext; } - public functionStmt_list(): FunctionStmtContext[] { - return this.getTypedRuleContexts( - FunctionStmtContext, - ) as FunctionStmtContext[]; + public regularStatements(): RegularStatementsContext { + return this.getTypedRuleContext( + RegularStatementsContext, + 0, + ) as RegularStatementsContext; } - public functionStmt(i: number): FunctionStmtContext { + public logDefinition(): LogDefinitionContext { return this.getTypedRuleContext( - FunctionStmtContext, - i, - ) as FunctionStmtContext; + LogDefinitionContext, + 0, + ) as LogDefinitionContext; } - public ELSE(): TerminalNode { - return this.getToken(CircomParser.ELSE, 0); + public assertDefinition(): AssertDefinitionContext { + return this.getTypedRuleContext( + AssertDefinitionContext, + 0, + ) as AssertDefinitionContext; + } + public get ruleIndex(): number { + return CircomParser.RULE_statements; } public enterRule(listener: CircomParserListener): void { - if (listener.enterIfFuncStmt) { - listener.enterIfFuncStmt(this); + if (listener.enterStatements) { + listener.enterStatements(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitIfFuncStmt) { - listener.exitIfFuncStmt(this); + if (listener.exitStatements) { + listener.exitStatements(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitIfFuncStmt) { - return visitor.visitIfFuncStmt(this); + if (visitor.visitStatements) { + return visitor.visitStatements(this); } else { return visitor.visitChildren(this); } } } -export class WhileFuncStmtContext extends FunctionStmtContext { - constructor(parser: CircomParser, ctx: FunctionStmtContext) { + +export class IfStatementsContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public get ruleIndex(): number { + return CircomParser.RULE_ifStatements; + } + public copyFrom(ctx: IfStatementsContext): void { + super.copyFrom(ctx); + } +} +export class IfWithFollowUpIfContext extends IfStatementsContext { + public _cond!: ExpressionContext; + constructor(parser: CircomParser, ctx: IfStatementsContext) { super(parser, ctx.parentCtx, ctx.invokingState); super.copyFrom(ctx); } - public WHILE(): TerminalNode { - return this.getToken(CircomParser.WHILE, 0); + public IF(): TerminalNode { + return this.getToken(CircomParser.IF, 0); } - public parExpression(): ParExpressionContext { - return this.getTypedRuleContext( - ParExpressionContext, - 0, - ) as ParExpressionContext; + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); } - public functionStmt(): FunctionStmtContext { + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); + } + public ifStatements(): IfStatementsContext { return this.getTypedRuleContext( - FunctionStmtContext, + IfStatementsContext, 0, - ) as FunctionStmtContext; + ) as IfStatementsContext; + } + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterWhileFuncStmt) { - listener.enterWhileFuncStmt(this); + if (listener.enterIfWithFollowUpIf) { + listener.enterIfWithFollowUpIf(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitWhileFuncStmt) { - listener.exitWhileFuncStmt(this); + if (listener.exitIfWithFollowUpIf) { + listener.exitIfWithFollowUpIf(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitWhileFuncStmt) { - return visitor.visitWhileFuncStmt(this); + if (visitor.visitIfWithFollowUpIf) { + return visitor.visitIfWithFollowUpIf(this); } else { return visitor.visitChildren(this); } } } -export class ReturnFuncStmtContext extends FunctionStmtContext { - constructor(parser: CircomParser, ctx: FunctionStmtContext) { +export class IfRegularElseRegularContext extends IfStatementsContext { + public _cond!: ExpressionContext; + constructor(parser: CircomParser, ctx: IfStatementsContext) { super(parser, ctx.parentCtx, ctx.invokingState); super.copyFrom(ctx); } - public RETURN(): TerminalNode { - return this.getToken(CircomParser.RETURN, 0); + public IF(): TerminalNode { + return this.getToken(CircomParser.IF, 0); + } + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); + } + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); + } + public regularStatements_list(): RegularStatementsContext[] { + return this.getTypedRuleContexts( + RegularStatementsContext, + ) as RegularStatementsContext[]; + } + public regularStatements(i: number): RegularStatementsContext { + return this.getTypedRuleContext( + RegularStatementsContext, + i, + ) as RegularStatementsContext; + } + public ELSE(): TerminalNode { + return this.getToken(CircomParser.ELSE, 0); } public expression(): ExpressionContext { return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } - public SEMICOLON(): TerminalNode { - return this.getToken(CircomParser.SEMICOLON, 0); - } public enterRule(listener: CircomParserListener): void { - if (listener.enterReturnFuncStmt) { - listener.enterReturnFuncStmt(this); + if (listener.enterIfRegularElseRegular) { + listener.enterIfRegularElseRegular(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitReturnFuncStmt) { - listener.exitReturnFuncStmt(this); + if (listener.exitIfRegularElseRegular) { + listener.exitIfRegularElseRegular(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitReturnFuncStmt) { - return visitor.visitReturnFuncStmt(this); + if (visitor.visitIfRegularElseRegular) { + return visitor.visitIfRegularElseRegular(this); } else { return visitor.visitChildren(this); } } } -export class FuncVariadicAssignmentContext extends FunctionStmtContext { - constructor(parser: CircomParser, ctx: FunctionStmtContext) { +export class IfRegularElseWithFollowUpIfContext extends IfStatementsContext { + public _cond!: ExpressionContext; + constructor(parser: CircomParser, ctx: IfStatementsContext) { super(parser, ctx.parentCtx, ctx.invokingState); super.copyFrom(ctx); } - public LP_list(): TerminalNode[] { - return this.getTokens(CircomParser.LP); + public IF(): TerminalNode { + return this.getToken(CircomParser.IF, 0); } - public LP(i: number): TerminalNode { - return this.getToken(CircomParser.LP, i); + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); + } + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); } - public argsWithUnderscore(): ArgsWithUnderscoreContext { + public regularStatements(): RegularStatementsContext { return this.getTypedRuleContext( - ArgsWithUnderscoreContext, + RegularStatementsContext, 0, - ) as ArgsWithUnderscoreContext; - } - public RP_list(): TerminalNode[] { - return this.getTokens(CircomParser.RP); - } - public RP(i: number): TerminalNode { - return this.getToken(CircomParser.RP, i); + ) as RegularStatementsContext; } - public ASSIGNMENT(): TerminalNode { - return this.getToken(CircomParser.ASSIGNMENT, 0); - } - public SEMICOLON(): TerminalNode { - return this.getToken(CircomParser.SEMICOLON, 0); + public ELSE(): TerminalNode { + return this.getToken(CircomParser.ELSE, 0); } - public expressionList(): ExpressionListContext { + public ifStatements(): IfStatementsContext { return this.getTypedRuleContext( - ExpressionListContext, + IfStatementsContext, 0, - ) as ExpressionListContext; + ) as IfStatementsContext; } public expression(): ExpressionContext { return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterFuncVariadicAssignment) { - listener.enterFuncVariadicAssignment(this); + if (listener.enterIfRegularElseWithFollowUpIf) { + listener.enterIfRegularElseWithFollowUpIf(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitFuncVariadicAssignment) { - listener.exitFuncVariadicAssignment(this); + if (listener.exitIfRegularElseWithFollowUpIf) { + listener.exitIfRegularElseWithFollowUpIf(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitFuncVariadicAssignment) { - return visitor.visitFuncVariadicAssignment(this); + if (visitor.visitIfRegularElseWithFollowUpIf) { + return visitor.visitIfRegularElseWithFollowUpIf(this); } else { return visitor.visitChildren(this); } } } -export class FuncAssignmentExpressionContext extends FunctionStmtContext { - constructor(parser: CircomParser, ctx: FunctionStmtContext) { +export class IfRegularContext extends IfStatementsContext { + public _cond!: ExpressionContext; + constructor(parser: CircomParser, ctx: IfStatementsContext) { super(parser, ctx.parentCtx, ctx.invokingState); super.copyFrom(ctx); } - public identifier(): IdentifierContext { - return this.getTypedRuleContext(IdentifierContext, 0) as IdentifierContext; + public IF(): TerminalNode { + return this.getToken(CircomParser.IF, 0); } - public expression(): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); } - public SEMICOLON(): TerminalNode { - return this.getToken(CircomParser.SEMICOLON, 0); + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); } - public ASSIGNMENT(): TerminalNode { - return this.getToken(CircomParser.ASSIGNMENT, 0); + public regularStatements(): RegularStatementsContext { + return this.getTypedRuleContext( + RegularStatementsContext, + 0, + ) as RegularStatementsContext; } - public ASSIGNMENT_WITH_OP(): TerminalNode { - return this.getToken(CircomParser.ASSIGNMENT_WITH_OP, 0); + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterFuncAssignmentExpression) { - listener.enterFuncAssignmentExpression(this); + if (listener.enterIfRegular) { + listener.enterIfRegular(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitFuncAssignmentExpression) { - listener.exitFuncAssignmentExpression(this); + if (listener.exitIfRegular) { + listener.exitIfRegular(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitFuncAssignmentExpression) { - return visitor.visitFuncAssignmentExpression(this); + if (visitor.visitIfRegular) { + return visitor.visitIfRegular(this); } else { return visitor.visitChildren(this); } } } -export class TemplateDeclarationContext extends ParserRuleContext { +export class RegularStatementsContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -4274,221 +5014,207 @@ export class TemplateDeclarationContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public TEMPLATE(): TerminalNode { - return this.getToken(CircomParser.TEMPLATE, 0); - } - public ID(): TerminalNode { - return this.getToken(CircomParser.ID, 0); - } - public LP(): TerminalNode { - return this.getToken(CircomParser.LP, 0); + public get ruleIndex(): number { + return CircomParser.RULE_regularStatements; } - public RP(): TerminalNode { - return this.getToken(CircomParser.RP, 0); + public copyFrom(ctx: RegularStatementsContext): void { + super.copyFrom(ctx); } - public templateBlock(): TemplateBlockContext { - return this.getTypedRuleContext( - TemplateBlockContext, - 0, - ) as TemplateBlockContext; +} +export class RStatementEqConstraintContext extends RegularStatementsContext { + public _lhs!: ExpressionContext; + public _rhs!: ExpressionContext; + constructor(parser: CircomParser, ctx: RegularStatementsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public CUSTOM(): TerminalNode { - return this.getToken(CircomParser.CUSTOM, 0); + public EQ_CONSTRAINT(): TerminalNode { + return this.getToken(CircomParser.EQ_CONSTRAINT, 0); } - public PARALLEL(): TerminalNode { - return this.getToken(CircomParser.PARALLEL, 0); + public SEMICOLON(): TerminalNode { + return this.getToken(CircomParser.SEMICOLON, 0); } - public args(): ArgsContext { - return this.getTypedRuleContext(ArgsContext, 0) as ArgsContext; + public expression_list(): ExpressionContext[] { + return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; } - public get ruleIndex(): number { - return CircomParser.RULE_templateDeclaration; + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterTemplateDeclaration) { - listener.enterTemplateDeclaration(this); + if (listener.enterRStatementEqConstraint) { + listener.enterRStatementEqConstraint(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitTemplateDeclaration) { - listener.exitTemplateDeclaration(this); + if (listener.exitRStatementEqConstraint) { + listener.exitRStatementEqConstraint(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitTemplateDeclaration) { - return visitor.visitTemplateDeclaration(this); + if (visitor.visitRStatementEqConstraint) { + return visitor.visitRStatementEqConstraint(this); } else { return visitor.visitChildren(this); } } } - -export class TemplateBlockContext extends ParserRuleContext { - constructor( - parser?: CircomParser, - parent?: ParserRuleContext, - invokingState?: number, - ) { - super(parent, invokingState); - this.parser = parser; - } - public LC(): TerminalNode { - return this.getToken(CircomParser.LC, 0); - } - public RC(): TerminalNode { - return this.getToken(CircomParser.RC, 0); - } - public templateStmt_list(): TemplateStmtContext[] { - return this.getTypedRuleContexts( - TemplateStmtContext, - ) as TemplateStmtContext[]; +export class RStatementSucstitutionsContext extends RegularStatementsContext { + constructor(parser: CircomParser, ctx: RegularStatementsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public templateStmt(i: number): TemplateStmtContext { + public substitutions(): SubstitutionsContext { return this.getTypedRuleContext( - TemplateStmtContext, - i, - ) as TemplateStmtContext; + SubstitutionsContext, + 0, + ) as SubstitutionsContext; } - public get ruleIndex(): number { - return CircomParser.RULE_templateBlock; + public SEMICOLON(): TerminalNode { + return this.getToken(CircomParser.SEMICOLON, 0); } public enterRule(listener: CircomParserListener): void { - if (listener.enterTemplateBlock) { - listener.enterTemplateBlock(this); + if (listener.enterRStatementSucstitutions) { + listener.enterRStatementSucstitutions(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitTemplateBlock) { - listener.exitTemplateBlock(this); + if (listener.exitRStatementSucstitutions) { + listener.exitRStatementSucstitutions(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitTemplateBlock) { - return visitor.visitTemplateBlock(this); + if (visitor.visitRStatementSucstitutions) { + return visitor.visitRStatementSucstitutions(this); } else { return visitor.visitChildren(this); } } } - -export class ComponentMainDeclarationContext extends ParserRuleContext { - constructor( - parser?: CircomParser, - parent?: ParserRuleContext, - invokingState?: number, - ) { - super(parent, invokingState); - this.parser = parser; +export class RStatementCyclesContext extends RegularStatementsContext { + constructor(parser: CircomParser, ctx: RegularStatementsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public COMPONENT(): TerminalNode { - return this.getToken(CircomParser.COMPONENT, 0); + public cycleStatements(): CycleStatementsContext { + return this.getTypedRuleContext( + CycleStatementsContext, + 0, + ) as CycleStatementsContext; } - public MAIN(): TerminalNode { - return this.getToken(CircomParser.MAIN, 0); + public enterRule(listener: CircomParserListener): void { + if (listener.enterRStatementCycles) { + listener.enterRStatementCycles(this); + } } - public ASSIGNMENT(): TerminalNode { - return this.getToken(CircomParser.ASSIGNMENT, 0); + public exitRule(listener: CircomParserListener): void { + if (listener.exitRStatementCycles) { + listener.exitRStatementCycles(this); + } } - public ID(): TerminalNode { - return this.getToken(CircomParser.ID, 0); + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitRStatementCycles) { + return visitor.visitRStatementCycles(this); + } else { + return visitor.visitChildren(this); + } } - public LP(): TerminalNode { - return this.getToken(CircomParser.LP, 0); +} +export class RStatementReturnContext extends RegularStatementsContext { + public _value!: ExpressionContext; + constructor(parser: CircomParser, ctx: RegularStatementsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public RP(): TerminalNode { - return this.getToken(CircomParser.RP, 0); + public RETURN(): TerminalNode { + return this.getToken(CircomParser.RETURN, 0); } public SEMICOLON(): TerminalNode { return this.getToken(CircomParser.SEMICOLON, 0); } - public publicInputsList(): PublicInputsListContext { - return this.getTypedRuleContext( - PublicInputsListContext, - 0, - ) as PublicInputsListContext; - } - public expressionList(): ExpressionListContext { - return this.getTypedRuleContext( - ExpressionListContext, - 0, - ) as ExpressionListContext; - } - public get ruleIndex(): number { - return CircomParser.RULE_componentMainDeclaration; + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterComponentMainDeclaration) { - listener.enterComponentMainDeclaration(this); + if (listener.enterRStatementReturn) { + listener.enterRStatementReturn(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitComponentMainDeclaration) { - listener.exitComponentMainDeclaration(this); + if (listener.exitRStatementReturn) { + listener.exitRStatementReturn(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitComponentMainDeclaration) { - return visitor.visitComponentMainDeclaration(this); + if (visitor.visitRStatementReturn) { + return visitor.visitRStatementReturn(this); } else { return visitor.visitChildren(this); } } } - -export class PublicInputsListContext extends ParserRuleContext { - constructor( - parser?: CircomParser, - parent?: ParserRuleContext, - invokingState?: number, - ) { - super(parent, invokingState); - this.parser = parser; +export class RStatementExpressionContext extends RegularStatementsContext { + constructor(parser: CircomParser, ctx: RegularStatementsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public LC(): TerminalNode { - return this.getToken(CircomParser.LC, 0); + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } - public PUBLIC(): TerminalNode { - return this.getToken(CircomParser.PUBLIC, 0); + public SEMICOLON(): TerminalNode { + return this.getToken(CircomParser.SEMICOLON, 0); } - public LB(): TerminalNode { - return this.getToken(CircomParser.LB, 0); + public enterRule(listener: CircomParserListener): void { + if (listener.enterRStatementExpression) { + listener.enterRStatementExpression(this); + } } - public args(): ArgsContext { - return this.getTypedRuleContext(ArgsContext, 0) as ArgsContext; + public exitRule(listener: CircomParserListener): void { + if (listener.exitRStatementExpression) { + listener.exitRStatementExpression(this); + } } - public RB(): TerminalNode { - return this.getToken(CircomParser.RB, 0); + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitRStatementExpression) { + return visitor.visitRStatementExpression(this); + } else { + return visitor.visitChildren(this); + } } - public RC(): TerminalNode { - return this.getToken(CircomParser.RC, 0); +} +export class RStatementBodyContext extends RegularStatementsContext { + constructor(parser: CircomParser, ctx: RegularStatementsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public get ruleIndex(): number { - return CircomParser.RULE_publicInputsList; + public body(): BodyContext { + return this.getTypedRuleContext(BodyContext, 0) as BodyContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterPublicInputsList) { - listener.enterPublicInputsList(this); + if (listener.enterRStatementBody) { + listener.enterRStatementBody(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitPublicInputsList) { - listener.exitPublicInputsList(this); + if (listener.exitRStatementBody) { + listener.exitRStatementBody(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitPublicInputsList) { - return visitor.visitPublicInputsList(this); + if (visitor.visitRStatementBody) { + return visitor.visitRStatementBody(this); } else { return visitor.visitChildren(this); } } } -export class TemplateStmtContext extends ParserRuleContext { +export class CycleStatementsContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -4497,181 +5223,184 @@ export class TemplateStmtContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public templateBlock(): TemplateBlockContext { - return this.getTypedRuleContext( - TemplateBlockContext, - 0, - ) as TemplateBlockContext; + public get ruleIndex(): number { + return CircomParser.RULE_cycleStatements; } - public ID(): TerminalNode { - return this.getToken(CircomParser.ID, 0); + public copyFrom(ctx: CycleStatementsContext): void { + super.copyFrom(ctx); } - public SELF_OP(): TerminalNode { - return this.getToken(CircomParser.SELF_OP, 0); +} +export class CycleForWithoutDeclarationContext extends CycleStatementsContext { + public _cond!: ExpressionContext; + public _step!: SubstitutionsContext; + public _forBody!: RegularStatementsContext; + constructor(parser: CircomParser, ctx: CycleStatementsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public SEMICOLON(): TerminalNode { - return this.getToken(CircomParser.SEMICOLON, 0); + public FOR(): TerminalNode { + return this.getToken(CircomParser.FOR, 0); } - public arrayDimension_list(): ArrayDimensionContext[] { + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); + } + public substitutions_list(): SubstitutionsContext[] { return this.getTypedRuleContexts( - ArrayDimensionContext, - ) as ArrayDimensionContext[]; + SubstitutionsContext, + ) as SubstitutionsContext[]; } - public arrayDimension(i: number): ArrayDimensionContext { + public substitutions(i: number): SubstitutionsContext { return this.getTypedRuleContext( - ArrayDimensionContext, + SubstitutionsContext, i, - ) as ArrayDimensionContext; + ) as SubstitutionsContext; } - public varDeclaration(): VarDeclarationContext { - return this.getTypedRuleContext( - VarDeclarationContext, - 0, - ) as VarDeclarationContext; + public SEMICOLON_list(): TerminalNode[] { + return this.getTokens(CircomParser.SEMICOLON); } - public signalDeclaration(): SignalDeclarationContext { - return this.getTypedRuleContext( - SignalDeclarationContext, - 0, - ) as SignalDeclarationContext; + public SEMICOLON(i: number): TerminalNode { + return this.getToken(CircomParser.SEMICOLON, i); } - public componentDeclaration(): ComponentDeclarationContext { - return this.getTypedRuleContext( - ComponentDeclarationContext, - 0, - ) as ComponentDeclarationContext; + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); + } + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } - public blockInstantiation(): BlockInstantiationContext { + public regularStatements(): RegularStatementsContext { return this.getTypedRuleContext( - BlockInstantiationContext, + RegularStatementsContext, 0, - ) as BlockInstantiationContext; - } - public identifier(): IdentifierContext { - return this.getTypedRuleContext(IdentifierContext, 0) as IdentifierContext; - } - public ASSIGNMENT(): TerminalNode { - return this.getToken(CircomParser.ASSIGNMENT, 0); - } - public expression_list(): ExpressionContext[] { - return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; - } - public expression(i: number): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; - } - public EQ_CONSTRAINT(): TerminalNode { - return this.getToken(CircomParser.EQ_CONSTRAINT, 0); + ) as RegularStatementsContext; } - public element_list(): ElementContext[] { - return this.getTypedRuleContexts(ElementContext) as ElementContext[]; + public enterRule(listener: CircomParserListener): void { + if (listener.enterCycleForWithoutDeclaration) { + listener.enterCycleForWithoutDeclaration(this); + } } - public element(i: number): ElementContext { - return this.getTypedRuleContext(ElementContext, i) as ElementContext; + public exitRule(listener: CircomParserListener): void { + if (listener.exitCycleForWithoutDeclaration) { + listener.exitCycleForWithoutDeclaration(this); + } } - public LEFT_CONSTRAINT(): TerminalNode { - return this.getToken(CircomParser.LEFT_CONSTRAINT, 0); + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitCycleForWithoutDeclaration) { + return visitor.visitCycleForWithoutDeclaration(this); + } else { + return visitor.visitChildren(this); + } } - public ASSIGNMENT_WITH_OP(): TerminalNode { - return this.getToken(CircomParser.ASSIGNMENT_WITH_OP, 0); +} +export class CycleWhileContext extends CycleStatementsContext { + public _cond!: ExpressionContext; + public _stmt!: RegularStatementsContext; + constructor(parser: CircomParser, ctx: CycleStatementsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public LP_list(): TerminalNode[] { - return this.getTokens(CircomParser.LP); + public WHILE(): TerminalNode { + return this.getToken(CircomParser.WHILE, 0); } - public LP(i: number): TerminalNode { - return this.getToken(CircomParser.LP, i); + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); } - public RP_list(): TerminalNode[] { - return this.getTokens(CircomParser.RP); + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); } - public RP(i: number): TerminalNode { - return this.getToken(CircomParser.RP, i); + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } - public COMMA_list(): TerminalNode[] { - return this.getTokens(CircomParser.COMMA); + public regularStatements(): RegularStatementsContext { + return this.getTypedRuleContext( + RegularStatementsContext, + 0, + ) as RegularStatementsContext; } - public COMMA(i: number): TerminalNode { - return this.getToken(CircomParser.COMMA, i); + public enterRule(listener: CircomParserListener): void { + if (listener.enterCycleWhile) { + listener.enterCycleWhile(this); + } } - public RIGHT_CONSTRAINT(): TerminalNode { - return this.getToken(CircomParser.RIGHT_CONSTRAINT, 0); + public exitRule(listener: CircomParserListener): void { + if (listener.exitCycleWhile) { + listener.exitCycleWhile(this); + } } - public UNDERSCORE(): TerminalNode { - return this.getToken(CircomParser.UNDERSCORE, 0); + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitCycleWhile) { + return visitor.visitCycleWhile(this); + } else { + return visitor.visitChildren(this); + } } - public argsWithUnderscore(): ArgsWithUnderscoreContext { - return this.getTypedRuleContext( - ArgsWithUnderscoreContext, - 0, - ) as ArgsWithUnderscoreContext; +} +export class CycleForWithDeclarationContext extends CycleStatementsContext { + public _cond!: ExpressionContext; + public _step!: SubstitutionsContext; + public _forBody!: RegularStatementsContext; + constructor(parser: CircomParser, ctx: CycleStatementsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public expressionList(): ExpressionListContext { - return this.getTypedRuleContext( - ExpressionListContext, - 0, - ) as ExpressionListContext; + public FOR(): TerminalNode { + return this.getToken(CircomParser.FOR, 0); } - public IF(): TerminalNode { - return this.getToken(CircomParser.IF, 0); + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); } - public parExpression(): ParExpressionContext { + public declarations(): DeclarationsContext { return this.getTypedRuleContext( - ParExpressionContext, + DeclarationsContext, 0, - ) as ParExpressionContext; - } - public templateStmt_list(): TemplateStmtContext[] { - return this.getTypedRuleContexts( - TemplateStmtContext, - ) as TemplateStmtContext[]; - } - public templateStmt(i: number): TemplateStmtContext { - return this.getTypedRuleContext( - TemplateStmtContext, - i, - ) as TemplateStmtContext; - } - public ELSE(): TerminalNode { - return this.getToken(CircomParser.ELSE, 0); + ) as DeclarationsContext; } - public WHILE(): TerminalNode { - return this.getToken(CircomParser.WHILE, 0); + public SEMICOLON_list(): TerminalNode[] { + return this.getTokens(CircomParser.SEMICOLON); } - public FOR(): TerminalNode { - return this.getToken(CircomParser.FOR, 0); + public SEMICOLON(i: number): TerminalNode { + return this.getToken(CircomParser.SEMICOLON, i); } - public forControl(): ForControlContext { - return this.getTypedRuleContext(ForControlContext, 0) as ForControlContext; + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); } - public ASSERT(): TerminalNode { - return this.getToken(CircomParser.ASSERT, 0); + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } - public logStmt(): LogStmtContext { - return this.getTypedRuleContext(LogStmtContext, 0) as LogStmtContext; + public substitutions(): SubstitutionsContext { + return this.getTypedRuleContext( + SubstitutionsContext, + 0, + ) as SubstitutionsContext; } - public get ruleIndex(): number { - return CircomParser.RULE_templateStmt; + public regularStatements(): RegularStatementsContext { + return this.getTypedRuleContext( + RegularStatementsContext, + 0, + ) as RegularStatementsContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterTemplateStmt) { - listener.enterTemplateStmt(this); + if (listener.enterCycleForWithDeclaration) { + listener.enterCycleForWithDeclaration(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitTemplateStmt) { - listener.exitTemplateStmt(this); + if (listener.exitCycleForWithDeclaration) { + listener.exitCycleForWithDeclaration(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitTemplateStmt) { - return visitor.visitTemplateStmt(this); + if (visitor.visitCycleForWithDeclaration) { + return visitor.visitCycleForWithDeclaration(this); } else { return visitor.visitChildren(this); } } } -export class ElementContext extends ParserRuleContext { +export class SubstitutionsContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -4680,218 +5409,233 @@ export class ElementContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public identifier_list(): IdentifierContext[] { - return this.getTypedRuleContexts(IdentifierContext) as IdentifierContext[]; + public get ruleIndex(): number { + return CircomParser.RULE_substitutions; } - public identifier(i: number): IdentifierContext { - return this.getTypedRuleContext(IdentifierContext, i) as IdentifierContext; + public copyFrom(ctx: SubstitutionsContext): void { + super.copyFrom(ctx); } - public DOT(): TerminalNode { - return this.getToken(CircomParser.DOT, 0); +} +export class SubsLeftAssignmentContext extends SubstitutionsContext { + public _lhs!: ExpressionContext; + public _op!: Token; + public _rhs!: ExpressionContext; + constructor(parser: CircomParser, ctx: SubstitutionsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public get ruleIndex(): number { - return CircomParser.RULE_element; + public expression_list(): ExpressionContext[] { + return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; + } + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + } + public ASSIGNMENT(): TerminalNode { + return this.getToken(CircomParser.ASSIGNMENT, 0); + } + public LEFT_ASSIGNMENT(): TerminalNode { + return this.getToken(CircomParser.LEFT_ASSIGNMENT, 0); + } + public LEFT_CONSTRAINT(): TerminalNode { + return this.getToken(CircomParser.LEFT_CONSTRAINT, 0); } public enterRule(listener: CircomParserListener): void { - if (listener.enterElement) { - listener.enterElement(this); + if (listener.enterSubsLeftAssignment) { + listener.enterSubsLeftAssignment(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitElement) { - listener.exitElement(this); + if (listener.exitSubsLeftAssignment) { + listener.exitSubsLeftAssignment(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitElement) { - return visitor.visitElement(this); + if (visitor.visitSubsLeftAssignment) { + return visitor.visitSubsLeftAssignment(this); } else { return visitor.visitChildren(this); } } } - -export class ForControlContext extends ParserRuleContext { - constructor( - parser?: CircomParser, - parent?: ParserRuleContext, - invokingState?: number, - ) { - super(parent, invokingState); - this.parser = parser; - } - public forInit(): ForInitContext { - return this.getTypedRuleContext(ForInitContext, 0) as ForInitContext; - } - public SEMICOLON_list(): TerminalNode[] { - return this.getTokens(CircomParser.SEMICOLON); - } - public SEMICOLON(i: number): TerminalNode { - return this.getToken(CircomParser.SEMICOLON, i); +export class SubsRightConstrAssignmentContext extends SubstitutionsContext { + public _lhs!: ExpressionContext; + public _op!: Token; + public _variable!: ExpressionContext; + constructor(parser: CircomParser, ctx: SubstitutionsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public expression(): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; + public expression_list(): ExpressionContext[] { + return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; } - public forUpdate(): ForUpdateContext { - return this.getTypedRuleContext(ForUpdateContext, 0) as ForUpdateContext; + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; } - public get ruleIndex(): number { - return CircomParser.RULE_forControl; + public RIGHT_CONSTRAINT(): TerminalNode { + return this.getToken(CircomParser.RIGHT_CONSTRAINT, 0); } public enterRule(listener: CircomParserListener): void { - if (listener.enterForControl) { - listener.enterForControl(this); + if (listener.enterSubsRightConstrAssignment) { + listener.enterSubsRightConstrAssignment(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitForControl) { - listener.exitForControl(this); + if (listener.exitSubsRightConstrAssignment) { + listener.exitSubsRightConstrAssignment(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitForControl) { - return visitor.visitForControl(this); + if (visitor.visitSubsRightConstrAssignment) { + return visitor.visitSubsRightConstrAssignment(this); } else { return visitor.visitChildren(this); } } } - -export class ForInitContext extends ParserRuleContext { - constructor( - parser?: CircomParser, - parent?: ParserRuleContext, - invokingState?: number, - ) { - super(parent, invokingState); - this.parser = parser; - } - public identifier(): IdentifierContext { - return this.getTypedRuleContext(IdentifierContext, 0) as IdentifierContext; - } - public VAR(): TerminalNode { - return this.getToken(CircomParser.VAR, 0); +export class SubsRightSimpleAssignmentContext extends SubstitutionsContext { + public _lhs!: ExpressionContext; + public _op!: Token; + public _variable!: ExpressionContext; + constructor(parser: CircomParser, ctx: SubstitutionsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public ASSIGNMENT(): TerminalNode { - return this.getToken(CircomParser.ASSIGNMENT, 0); + public expression_list(): ExpressionContext[] { + return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; } - public rhsValue(): RhsValueContext { - return this.getTypedRuleContext(RhsValueContext, 0) as RhsValueContext; + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; } - public get ruleIndex(): number { - return CircomParser.RULE_forInit; + public RIGHT_ASSIGNMENT(): TerminalNode { + return this.getToken(CircomParser.RIGHT_ASSIGNMENT, 0); } public enterRule(listener: CircomParserListener): void { - if (listener.enterForInit) { - listener.enterForInit(this); + if (listener.enterSubsRightSimpleAssignment) { + listener.enterSubsRightSimpleAssignment(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitForInit) { - listener.exitForInit(this); + if (listener.exitSubsRightSimpleAssignment) { + listener.exitSubsRightSimpleAssignment(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitForInit) { - return visitor.visitForInit(this); + if (visitor.visitSubsRightSimpleAssignment) { + return visitor.visitSubsRightSimpleAssignment(this); } else { return visitor.visitChildren(this); } } } - -export class ForUpdateContext extends ParserRuleContext { - constructor( - parser?: CircomParser, - parent?: ParserRuleContext, - invokingState?: number, - ) { - super(parent, invokingState); - this.parser = parser; - } - public ID(): TerminalNode { - return this.getToken(CircomParser.ID, 0); +export class SubsInvalidIcnDecOperationContext extends SubstitutionsContext { + constructor(parser: CircomParser, ctx: SubstitutionsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } public SELF_OP(): TerminalNode { return this.getToken(CircomParser.SELF_OP, 0); } - public expression(): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; + public identifierStatement(): IdentifierStatementContext { + return this.getTypedRuleContext( + IdentifierStatementContext, + 0, + ) as IdentifierStatementContext; } - public ASSIGNMENT(): TerminalNode { - return this.getToken(CircomParser.ASSIGNMENT, 0); + public enterRule(listener: CircomParserListener): void { + if (listener.enterSubsInvalidIcnDecOperation) { + listener.enterSubsInvalidIcnDecOperation(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitSubsInvalidIcnDecOperation) { + listener.exitSubsInvalidIcnDecOperation(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitSubsInvalidIcnDecOperation) { + return visitor.visitSubsInvalidIcnDecOperation(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class SubsAssignmentWithOperationContext extends SubstitutionsContext { + public _op!: Token; + public _rhs!: ExpressionContext; + constructor(parser: CircomParser, ctx: SubstitutionsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public identifierStatement(): IdentifierStatementContext { + return this.getTypedRuleContext( + IdentifierStatementContext, + 0, + ) as IdentifierStatementContext; } public ASSIGNMENT_WITH_OP(): TerminalNode { return this.getToken(CircomParser.ASSIGNMENT_WITH_OP, 0); } - public get ruleIndex(): number { - return CircomParser.RULE_forUpdate; + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterForUpdate) { - listener.enterForUpdate(this); + if (listener.enterSubsAssignmentWithOperation) { + listener.enterSubsAssignmentWithOperation(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitForUpdate) { - listener.exitForUpdate(this); + if (listener.exitSubsAssignmentWithOperation) { + listener.exitSubsAssignmentWithOperation(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitForUpdate) { - return visitor.visitForUpdate(this); + if (visitor.visitSubsAssignmentWithOperation) { + return visitor.visitSubsAssignmentWithOperation(this); } else { return visitor.visitChildren(this); } } } - -export class ParExpressionContext extends ParserRuleContext { - constructor( - parser?: CircomParser, - parent?: ParserRuleContext, - invokingState?: number, - ) { - super(parent, invokingState); - this.parser = parser; - } - public LP(): TerminalNode { - return this.getToken(CircomParser.LP, 0); - } - public expression(): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; +export class SubsIcnDecOperationContext extends SubstitutionsContext { + constructor(parser: CircomParser, ctx: SubstitutionsContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public RP(): TerminalNode { - return this.getToken(CircomParser.RP, 0); + public identifierStatement(): IdentifierStatementContext { + return this.getTypedRuleContext( + IdentifierStatementContext, + 0, + ) as IdentifierStatementContext; } - public get ruleIndex(): number { - return CircomParser.RULE_parExpression; + public SELF_OP(): TerminalNode { + return this.getToken(CircomParser.SELF_OP, 0); } public enterRule(listener: CircomParserListener): void { - if (listener.enterParExpression) { - listener.enterParExpression(this); + if (listener.enterSubsIcnDecOperation) { + listener.enterSubsIcnDecOperation(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitParExpression) { - listener.exitParExpression(this); + if (listener.exitSubsIcnDecOperation) { + listener.exitSubsIcnDecOperation(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitParExpression) { - return visitor.visitParExpression(this); + if (visitor.visitSubsIcnDecOperation) { + return visitor.visitSubsIcnDecOperation(this); } else { return visitor.visitChildren(this); } } } -export class ExpressionContext extends ParserRuleContext { +export class ExpressionListContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -4900,53 +5644,56 @@ export class ExpressionContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public get ruleIndex(): number { - return CircomParser.RULE_expression; - } - public copyFrom(ctx: ExpressionContext): void { - super.copyFrom(ctx); - } -} -export class TernaryExpressionContext extends ExpressionContext { - constructor(parser: CircomParser, ctx: ExpressionContext) { - super(parser, ctx.parentCtx, ctx.invokingState); - super.copyFrom(ctx); - } public expression_list(): ExpressionContext[] { return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; } public expression(i: number): ExpressionContext { return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; } - public TERNARY_CONDITION(): TerminalNode { - return this.getToken(CircomParser.TERNARY_CONDITION, 0); + public COMMA_list(): TerminalNode[] { + return this.getTokens(CircomParser.COMMA); } - public TERNARY_ALTERNATIVE(): TerminalNode { - return this.getToken(CircomParser.TERNARY_ALTERNATIVE, 0); + public COMMA(i: number): TerminalNode { + return this.getToken(CircomParser.COMMA, i); + } + public get ruleIndex(): number { + return CircomParser.RULE_expressionList; } public enterRule(listener: CircomParserListener): void { - if (listener.enterTernaryExpression) { - listener.enterTernaryExpression(this); + if (listener.enterExpressionList) { + listener.enterExpressionList(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitTernaryExpression) { - listener.exitTernaryExpression(this); + if (listener.exitExpressionList) { + listener.exitExpressionList(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitTernaryExpression) { - return visitor.visitTernaryExpression(this); + if (visitor.visitExpressionList) { + return visitor.visitExpressionList(this); } else { return visitor.visitChildren(this); } } } -export class DotExpressionContext extends ExpressionContext { - constructor(parser: CircomParser, ctx: ExpressionContext) { - super(parser, ctx.parentCtx, ctx.invokingState); - super.copyFrom(ctx); + +export class ExpressionListWithNamesContext extends ParserRuleContext { + public _ops!: Token; + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public ID_list(): TerminalNode[] { + return this.getTokens(CircomParser.ID); + } + public ID(i: number): TerminalNode { + return this.getToken(CircomParser.ID, i); } public expression_list(): ExpressionContext[] { return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; @@ -4954,75 +5701,89 @@ export class DotExpressionContext extends ExpressionContext { public expression(i: number): ExpressionContext { return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; } - public DOT(): TerminalNode { - return this.getToken(CircomParser.DOT, 0); + public ASSIGNMENT_list(): TerminalNode[] { + return this.getTokens(CircomParser.ASSIGNMENT); } - public ID(): TerminalNode { - return this.getToken(CircomParser.ID, 0); + public ASSIGNMENT(i: number): TerminalNode { + return this.getToken(CircomParser.ASSIGNMENT, i); } - public LB(): TerminalNode { - return this.getToken(CircomParser.LB, 0); + public LEFT_ASSIGNMENT_list(): TerminalNode[] { + return this.getTokens(CircomParser.LEFT_ASSIGNMENT); } - public RB(): TerminalNode { - return this.getToken(CircomParser.RB, 0); + public LEFT_ASSIGNMENT(i: number): TerminalNode { + return this.getToken(CircomParser.LEFT_ASSIGNMENT, i); } - public enterRule(listener: CircomParserListener): void { - if (listener.enterDotExpression) { - listener.enterDotExpression(this); - } + public LEFT_CONSTRAINT_list(): TerminalNode[] { + return this.getTokens(CircomParser.LEFT_CONSTRAINT); } - public exitRule(listener: CircomParserListener): void { - if (listener.exitDotExpression) { - listener.exitDotExpression(this); - } + public LEFT_CONSTRAINT(i: number): TerminalNode { + return this.getToken(CircomParser.LEFT_CONSTRAINT, i); } - // @Override - public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitDotExpression) { - return visitor.visitDotExpression(this); - } else { - return visitor.visitChildren(this); - } + public COMMA_list(): TerminalNode[] { + return this.getTokens(CircomParser.COMMA); } -} -export class PrimaryExpressionContext extends ExpressionContext { - constructor(parser: CircomParser, ctx: ExpressionContext) { - super(parser, ctx.parentCtx, ctx.invokingState); - super.copyFrom(ctx); + public COMMA(i: number): TerminalNode { + return this.getToken(CircomParser.COMMA, i); } - public primary(): PrimaryContext { - return this.getTypedRuleContext(PrimaryContext, 0) as PrimaryContext; + public get ruleIndex(): number { + return CircomParser.RULE_expressionListWithNames; } public enterRule(listener: CircomParserListener): void { - if (listener.enterPrimaryExpression) { - listener.enterPrimaryExpression(this); + if (listener.enterExpressionListWithNames) { + listener.enterExpressionListWithNames(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitPrimaryExpression) { - listener.exitPrimaryExpression(this); + if (listener.exitExpressionListWithNames) { + listener.exitExpressionListWithNames(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitPrimaryExpression) { - return visitor.visitPrimaryExpression(this); + if (visitor.visitExpressionListWithNames) { + return visitor.visitExpressionListWithNames(this); } else { return visitor.visitChildren(this); } } } -export class BinaryExpressionContext extends ExpressionContext { + +export class ExpressionContext extends ParserRuleContext { + public _cond!: ExpressionContext; public _op!: Token; - constructor(parser: CircomParser, ctx: ExpressionContext) { - super(parser, ctx.parentCtx, ctx.invokingState); - super.copyFrom(ctx); + public _ifTrue!: ExpressionContext; + public _ifFalse!: ExpressionContext; + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public primaryExpression(): PrimaryExpressionContext { + return this.getTypedRuleContext( + PrimaryExpressionContext, + 0, + ) as PrimaryExpressionContext; } public expression_list(): ExpressionContext[] { return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; } - public expression(i: number): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + } + public NOT(): TerminalNode { + return this.getToken(CircomParser.NOT, 0); + } + public BNOT(): TerminalNode { + return this.getToken(CircomParser.BNOT, 0); + } + public SUB(): TerminalNode { + return this.getToken(CircomParser.SUB, 0); + } + public PARALLEL(): TerminalNode { + return this.getToken(CircomParser.PARALLEL, 0); } public POW(): TerminalNode { return this.getToken(CircomParser.POW, 0); @@ -5042,9 +5803,6 @@ export class BinaryExpressionContext extends ExpressionContext { public ADD(): TerminalNode { return this.getToken(CircomParser.ADD, 0); } - public SUB(): TerminalNode { - return this.getToken(CircomParser.SUB, 0); - } public SHL(): TerminalNode { return this.getToken(CircomParser.SHL, 0); } @@ -5066,277 +5824,322 @@ export class BinaryExpressionContext extends ExpressionContext { public NEQ(): TerminalNode { return this.getToken(CircomParser.NEQ, 0); } - public GT(): TerminalNode { - return this.getToken(CircomParser.GT, 0); - } public LT(): TerminalNode { return this.getToken(CircomParser.LT, 0); } - public GE(): TerminalNode { - return this.getToken(CircomParser.GE, 0); + public GT(): TerminalNode { + return this.getToken(CircomParser.GT, 0); } public LE(): TerminalNode { return this.getToken(CircomParser.LE, 0); } + public GE(): TerminalNode { + return this.getToken(CircomParser.GE, 0); + } public AND(): TerminalNode { return this.getToken(CircomParser.AND, 0); } public OR(): TerminalNode { return this.getToken(CircomParser.OR, 0); } + public TERNARY_CONDITION(): TerminalNode { + return this.getToken(CircomParser.TERNARY_CONDITION, 0); + } + public TERNARY_ALTERNATIVE(): TerminalNode { + return this.getToken(CircomParser.TERNARY_ALTERNATIVE, 0); + } + public get ruleIndex(): number { + return CircomParser.RULE_expression; + } public enterRule(listener: CircomParserListener): void { - if (listener.enterBinaryExpression) { - listener.enterBinaryExpression(this); + if (listener.enterExpression) { + listener.enterExpression(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitBinaryExpression) { - listener.exitBinaryExpression(this); + if (listener.exitExpression) { + listener.exitExpression(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitBinaryExpression) { - return visitor.visitBinaryExpression(this); + if (visitor.visitExpression) { + return visitor.visitExpression(this); } else { return visitor.visitChildren(this); } } } -export class BlockInstantiationExpressionContext extends ExpressionContext { - constructor(parser: CircomParser, ctx: ExpressionContext) { + +export class PrimaryExpressionContext extends ParserRuleContext { + constructor( + parser?: CircomParser, + parent?: ParserRuleContext, + invokingState?: number, + ) { + super(parent, invokingState); + this.parser = parser; + } + public get ruleIndex(): number { + return CircomParser.RULE_primaryExpression; + } + public copyFrom(ctx: PrimaryExpressionContext): void { + super.copyFrom(ctx); + } +} +export class PIdentifierStatementContext extends PrimaryExpressionContext { + constructor(parser: CircomParser, ctx: PrimaryExpressionContext) { super(parser, ctx.parentCtx, ctx.invokingState); super.copyFrom(ctx); } - public blockInstantiation(): BlockInstantiationContext { + public identifierStatement(): IdentifierStatementContext { return this.getTypedRuleContext( - BlockInstantiationContext, + IdentifierStatementContext, 0, - ) as BlockInstantiationContext; + ) as IdentifierStatementContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterBlockInstantiationExpression) { - listener.enterBlockInstantiationExpression(this); + if (listener.enterPIdentifierStatement) { + listener.enterPIdentifierStatement(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitBlockInstantiationExpression) { - listener.exitBlockInstantiationExpression(this); + if (listener.exitPIdentifierStatement) { + listener.exitPIdentifierStatement(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitBlockInstantiationExpression) { - return visitor.visitBlockInstantiationExpression(this); + if (visitor.visitPIdentifierStatement) { + return visitor.visitPIdentifierStatement(this); } else { return visitor.visitChildren(this); } } } -export class UnaryExpressionContext extends ExpressionContext { - public _op!: Token; - constructor(parser: CircomParser, ctx: ExpressionContext) { +export class PUnderscoreContext extends PrimaryExpressionContext { + constructor(parser: CircomParser, ctx: PrimaryExpressionContext) { super(parser, ctx.parentCtx, ctx.invokingState); super.copyFrom(ctx); } - public expression(): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; - } - public BNOT(): TerminalNode { - return this.getToken(CircomParser.BNOT, 0); - } - public NOT(): TerminalNode { - return this.getToken(CircomParser.NOT, 0); - } - public SUB(): TerminalNode { - return this.getToken(CircomParser.SUB, 0); + public UNDERSCORE(): TerminalNode { + return this.getToken(CircomParser.UNDERSCORE, 0); } public enterRule(listener: CircomParserListener): void { - if (listener.enterUnaryExpression) { - listener.enterUnaryExpression(this); + if (listener.enterPUnderscore) { + listener.enterPUnderscore(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitUnaryExpression) { - listener.exitUnaryExpression(this); + if (listener.exitPUnderscore) { + listener.exitPUnderscore(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitUnaryExpression) { - return visitor.visitUnaryExpression(this); + if (visitor.visitPUnderscore) { + return visitor.visitPUnderscore(this); } else { return visitor.visitChildren(this); } } } - -export class PrimaryContext extends ParserRuleContext { - constructor( - parser?: CircomParser, - parent?: ParserRuleContext, - invokingState?: number, - ) { - super(parent, invokingState); - this.parser = parser; +export class PParenthesesContext extends PrimaryExpressionContext { + constructor(parser: CircomParser, ctx: PrimaryExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } public LP(): TerminalNode { return this.getToken(CircomParser.LP, 0); } - public expression(): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; - } - public RP(): TerminalNode { - return this.getToken(CircomParser.RP, 0); - } - public LB(): TerminalNode { - return this.getToken(CircomParser.LB, 0); - } public expressionList(): ExpressionListContext { return this.getTypedRuleContext( ExpressionListContext, 0, ) as ExpressionListContext; } - public RB(): TerminalNode { - return this.getToken(CircomParser.RB, 0); + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); } - public NUMBER(): TerminalNode { - return this.getToken(CircomParser.NUMBER, 0); + public enterRule(listener: CircomParserListener): void { + if (listener.enterPParentheses) { + listener.enterPParentheses(this); + } } - public identifier(): IdentifierContext { - return this.getTypedRuleContext(IdentifierContext, 0) as IdentifierContext; + public exitRule(listener: CircomParserListener): void { + if (listener.exitPParentheses) { + listener.exitPParentheses(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitPParentheses) { + return visitor.visitPParentheses(this); + } else { + return visitor.visitChildren(this); + } + } +} +export class PAnonymousCallContext extends PrimaryExpressionContext { + constructor(parser: CircomParser, ctx: PrimaryExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public ID(): TerminalNode { + return this.getToken(CircomParser.ID, 0); + } + public LP_list(): TerminalNode[] { + return this.getTokens(CircomParser.LP); + } + public LP(i: number): TerminalNode { + return this.getToken(CircomParser.LP, i); + } + public RP_list(): TerminalNode[] { + return this.getTokens(CircomParser.RP); + } + public RP(i: number): TerminalNode { + return this.getToken(CircomParser.RP, i); } - public args(): ArgsContext { - return this.getTypedRuleContext(ArgsContext, 0) as ArgsContext; + public expressionList_list(): ExpressionListContext[] { + return this.getTypedRuleContexts( + ExpressionListContext, + ) as ExpressionListContext[]; } - public numSequence(): NumSequenceContext { + public expressionList(i: number): ExpressionListContext { return this.getTypedRuleContext( - NumSequenceContext, - 0, - ) as NumSequenceContext; + ExpressionListContext, + i, + ) as ExpressionListContext; } - public get ruleIndex(): number { - return CircomParser.RULE_primary; + public expressionListWithNames(): ExpressionListWithNamesContext { + return this.getTypedRuleContext( + ExpressionListWithNamesContext, + 0, + ) as ExpressionListWithNamesContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterPrimary) { - listener.enterPrimary(this); + if (listener.enterPAnonymousCall) { + listener.enterPAnonymousCall(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitPrimary) { - listener.exitPrimary(this); + if (listener.exitPAnonymousCall) { + listener.exitPAnonymousCall(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitPrimary) { - return visitor.visitPrimary(this); + if (visitor.visitPAnonymousCall) { + return visitor.visitPAnonymousCall(this); } else { return visitor.visitChildren(this); } } } - -export class LogStmtContext extends ParserRuleContext { - constructor( - parser?: CircomParser, - parent?: ParserRuleContext, - invokingState?: number, - ) { - super(parent, invokingState); - this.parser = parser; - } - public LOG(): TerminalNode { - return this.getToken(CircomParser.LOG, 0); - } - public LP(): TerminalNode { - return this.getToken(CircomParser.LP, 0); +export class PArrayContext extends PrimaryExpressionContext { + constructor(parser: CircomParser, ctx: PrimaryExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public RP(): TerminalNode { - return this.getToken(CircomParser.RP, 0); + public LB(): TerminalNode { + return this.getToken(CircomParser.LB, 0); } - public STRING_list(): TerminalNode[] { - return this.getTokens(CircomParser.STRING); + public expressionList(): ExpressionListContext { + return this.getTypedRuleContext( + ExpressionListContext, + 0, + ) as ExpressionListContext; } - public STRING(i: number): TerminalNode { - return this.getToken(CircomParser.STRING, i); + public RB(): TerminalNode { + return this.getToken(CircomParser.RB, 0); } - public expression_list(): ExpressionContext[] { - return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; + public enterRule(listener: CircomParserListener): void { + if (listener.enterPArray) { + listener.enterPArray(this); + } } - public expression(i: number): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + public exitRule(listener: CircomParserListener): void { + if (listener.exitPArray) { + listener.exitPArray(this); + } } - public COMMA_list(): TerminalNode[] { - return this.getTokens(CircomParser.COMMA); + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitPArray) { + return visitor.visitPArray(this); + } else { + return visitor.visitChildren(this); + } } - public COMMA(i: number): TerminalNode { - return this.getToken(CircomParser.COMMA, i); +} +export class PNumberContext extends PrimaryExpressionContext { + constructor(parser: CircomParser, ctx: PrimaryExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public get ruleIndex(): number { - return CircomParser.RULE_logStmt; + public NUMBER(): TerminalNode { + return this.getToken(CircomParser.NUMBER, 0); } public enterRule(listener: CircomParserListener): void { - if (listener.enterLogStmt) { - listener.enterLogStmt(this); + if (listener.enterPNumber) { + listener.enterPNumber(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitLogStmt) { - listener.exitLogStmt(this); + if (listener.exitPNumber) { + listener.exitPNumber(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitLogStmt) { - return visitor.visitLogStmt(this); + if (visitor.visitPNumber) { + return visitor.visitPNumber(this); } else { return visitor.visitChildren(this); } } } - -export class ComponentDefinitionContext extends ParserRuleContext { - constructor( - parser?: CircomParser, - parent?: ParserRuleContext, - invokingState?: number, - ) { - super(parent, invokingState); - this.parser = parser; - } - public COMPONENT(): TerminalNode { - return this.getToken(CircomParser.COMPONENT, 0); +export class PCallContext extends PrimaryExpressionContext { + constructor(parser: CircomParser, ctx: PrimaryExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } public ID(): TerminalNode { return this.getToken(CircomParser.ID, 0); } - public get ruleIndex(): number { - return CircomParser.RULE_componentDefinition; + public LP(): TerminalNode { + return this.getToken(CircomParser.LP, 0); + } + public RP(): TerminalNode { + return this.getToken(CircomParser.RP, 0); + } + public expressionList(): ExpressionListContext { + return this.getTypedRuleContext( + ExpressionListContext, + 0, + ) as ExpressionListContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterComponentDefinition) { - listener.enterComponentDefinition(this); + if (listener.enterPCall) { + listener.enterPCall(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitComponentDefinition) { - listener.exitComponentDefinition(this); + if (listener.exitPCall) { + listener.exitPCall(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitComponentDefinition) { - return visitor.visitComponentDefinition(this); + if (visitor.visitPCall) { + return visitor.visitPCall(this); } else { return visitor.visitChildren(this); } } } -export class ComponentDeclarationContext extends ParserRuleContext { +export class AssignmentExpressionContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -5345,100 +6148,109 @@ export class ComponentDeclarationContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public componentDefinition(): ComponentDefinitionContext { - return this.getTypedRuleContext( - ComponentDefinitionContext, - 0, - ) as ComponentDefinitionContext; + public get ruleIndex(): number { + return CircomParser.RULE_assignmentExpression; } - public arrayDimension_list(): ArrayDimensionContext[] { - return this.getTypedRuleContexts( - ArrayDimensionContext, - ) as ArrayDimensionContext[]; + public copyFrom(ctx: AssignmentExpressionContext): void { + super.copyFrom(ctx); } - public arrayDimension(i: number): ArrayDimensionContext { - return this.getTypedRuleContext( - ArrayDimensionContext, - i, - ) as ArrayDimensionContext; +} +export class AssignExprRegularContext extends AssignmentExpressionContext { + public _rhs!: ExpressionContext; + constructor(parser: CircomParser, ctx: AssignmentExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } public ASSIGNMENT(): TerminalNode { return this.getToken(CircomParser.ASSIGNMENT, 0); } - public blockInstantiation(): BlockInstantiationContext { - return this.getTypedRuleContext( - BlockInstantiationContext, - 0, - ) as BlockInstantiationContext; - } - public get ruleIndex(): number { - return CircomParser.RULE_componentDeclaration; + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterComponentDeclaration) { - listener.enterComponentDeclaration(this); + if (listener.enterAssignExprRegular) { + listener.enterAssignExprRegular(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitComponentDeclaration) { - listener.exitComponentDeclaration(this); + if (listener.exitAssignExprRegular) { + listener.exitAssignExprRegular(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitComponentDeclaration) { - return visitor.visitComponentDeclaration(this); + if (visitor.visitAssignExprRegular) { + return visitor.visitAssignExprRegular(this); } else { return visitor.visitChildren(this); } } } - -export class SignalDefinitionContext extends ParserRuleContext { - constructor( - parser?: CircomParser, - parent?: ParserRuleContext, - invokingState?: number, - ) { - super(parent, invokingState); - this.parser = parser; +export class AssignExprConstraintContext extends AssignmentExpressionContext { + public _rhs!: ExpressionContext; + constructor(parser: CircomParser, ctx: AssignmentExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public SIGNAL(): TerminalNode { - return this.getToken(CircomParser.SIGNAL, 0); + public LEFT_CONSTRAINT(): TerminalNode { + return this.getToken(CircomParser.LEFT_CONSTRAINT, 0); } - public identifier(): IdentifierContext { - return this.getTypedRuleContext(IdentifierContext, 0) as IdentifierContext; + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; + } + public enterRule(listener: CircomParserListener): void { + if (listener.enterAssignExprConstraint) { + listener.enterAssignExprConstraint(this); + } + } + public exitRule(listener: CircomParserListener): void { + if (listener.exitAssignExprConstraint) { + listener.exitAssignExprConstraint(this); + } + } + // @Override + public accept(visitor: CircomParserVisitor): Result { + if (visitor.visitAssignExprConstraint) { + return visitor.visitAssignExprConstraint(this); + } else { + return visitor.visitChildren(this); + } } - public SIGNAL_TYPE(): TerminalNode { - return this.getToken(CircomParser.SIGNAL_TYPE, 0); +} +export class AssignExprSimpleContext extends AssignmentExpressionContext { + public _rhs!: ExpressionContext; + constructor(parser: CircomParser, ctx: AssignmentExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public tagList(): TagListContext { - return this.getTypedRuleContext(TagListContext, 0) as TagListContext; + public LEFT_ASSIGNMENT(): TerminalNode { + return this.getToken(CircomParser.LEFT_ASSIGNMENT, 0); } - public get ruleIndex(): number { - return CircomParser.RULE_signalDefinition; + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } public enterRule(listener: CircomParserListener): void { - if (listener.enterSignalDefinition) { - listener.enterSignalDefinition(this); + if (listener.enterAssignExprSimple) { + listener.enterAssignExprSimple(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitSignalDefinition) { - listener.exitSignalDefinition(this); + if (listener.exitAssignExprSimple) { + listener.exitAssignExprSimple(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitSignalDefinition) { - return visitor.visitSignalDefinition(this); + if (visitor.visitAssignExprSimple) { + return visitor.visitAssignExprSimple(this); } else { return visitor.visitChildren(this); } } } -export class TagListContext extends ParserRuleContext { +export class VarIdentifierContext extends ParserRuleContext { + public _rhs!: ExpressionContext; constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -5447,39 +6259,39 @@ export class TagListContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public LC(): TerminalNode { - return this.getToken(CircomParser.LC, 0); + public identifier(): IdentifierContext { + return this.getTypedRuleContext(IdentifierContext, 0) as IdentifierContext; } - public args(): ArgsContext { - return this.getTypedRuleContext(ArgsContext, 0) as ArgsContext; + public ASSIGNMENT(): TerminalNode { + return this.getToken(CircomParser.ASSIGNMENT, 0); } - public RC(): TerminalNode { - return this.getToken(CircomParser.RC, 0); + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } public get ruleIndex(): number { - return CircomParser.RULE_tagList; + return CircomParser.RULE_varIdentifier; } public enterRule(listener: CircomParserListener): void { - if (listener.enterTagList) { - listener.enterTagList(this); + if (listener.enterVarIdentifier) { + listener.enterVarIdentifier(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitTagList) { - listener.exitTagList(this); + if (listener.exitVarIdentifier) { + listener.exitVarIdentifier(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitTagList) { - return visitor.visitTagList(this); + if (visitor.visitVarIdentifier) { + return visitor.visitVarIdentifier(this); } else { return visitor.visitChildren(this); } } } -export class SignalDeclarationContext extends ParserRuleContext { +export class VarIdentifierListContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -5488,17 +6300,16 @@ export class SignalDeclarationContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public signalDefinition(): SignalDefinitionContext { - return this.getTypedRuleContext( - SignalDefinitionContext, - 0, - ) as SignalDefinitionContext; - } - public LEFT_CONSTRAINT(): TerminalNode { - return this.getToken(CircomParser.LEFT_CONSTRAINT, 0); + public varIdentifier_list(): VarIdentifierContext[] { + return this.getTypedRuleContexts( + VarIdentifierContext, + ) as VarIdentifierContext[]; } - public rhsValue(): RhsValueContext { - return this.getTypedRuleContext(RhsValueContext, 0) as RhsValueContext; + public varIdentifier(i: number): VarIdentifierContext { + return this.getTypedRuleContext( + VarIdentifierContext, + i, + ) as VarIdentifierContext; } public COMMA_list(): TerminalNode[] { return this.getTokens(CircomParser.COMMA); @@ -5506,36 +6317,31 @@ export class SignalDeclarationContext extends ParserRuleContext { public COMMA(i: number): TerminalNode { return this.getToken(CircomParser.COMMA, i); } - public identifier_list(): IdentifierContext[] { - return this.getTypedRuleContexts(IdentifierContext) as IdentifierContext[]; - } - public identifier(i: number): IdentifierContext { - return this.getTypedRuleContext(IdentifierContext, i) as IdentifierContext; - } public get ruleIndex(): number { - return CircomParser.RULE_signalDeclaration; + return CircomParser.RULE_varIdentifierList; } public enterRule(listener: CircomParserListener): void { - if (listener.enterSignalDeclaration) { - listener.enterSignalDeclaration(this); + if (listener.enterVarIdentifierList) { + listener.enterVarIdentifierList(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitSignalDeclaration) { - listener.exitSignalDeclaration(this); + if (listener.exitVarIdentifierList) { + listener.exitVarIdentifierList(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitSignalDeclaration) { - return visitor.visitSignalDeclaration(this); + if (visitor.visitVarIdentifierList) { + return visitor.visitVarIdentifierList(this); } else { return visitor.visitChildren(this); } } } -export class VarDefinitionContext extends ParserRuleContext { +export class SignalIdentifierContext extends ParserRuleContext { + public _rhs!: ExpressionContext; constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -5544,51 +6350,42 @@ export class VarDefinitionContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public VAR(): TerminalNode { - return this.getToken(CircomParser.VAR, 0); - } - public identifier_list(): IdentifierContext[] { - return this.getTypedRuleContexts(IdentifierContext) as IdentifierContext[]; - } - public identifier(i: number): IdentifierContext { - return this.getTypedRuleContext(IdentifierContext, i) as IdentifierContext; - } - public LP(): TerminalNode { - return this.getToken(CircomParser.LP, 0); + public identifier(): IdentifierContext { + return this.getTypedRuleContext(IdentifierContext, 0) as IdentifierContext; } - public RP(): TerminalNode { - return this.getToken(CircomParser.RP, 0); + public LEFT_ASSIGNMENT(): TerminalNode { + return this.getToken(CircomParser.LEFT_ASSIGNMENT, 0); } - public COMMA_list(): TerminalNode[] { - return this.getTokens(CircomParser.COMMA); + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } - public COMMA(i: number): TerminalNode { - return this.getToken(CircomParser.COMMA, i); + public LEFT_CONSTRAINT(): TerminalNode { + return this.getToken(CircomParser.LEFT_CONSTRAINT, 0); } public get ruleIndex(): number { - return CircomParser.RULE_varDefinition; + return CircomParser.RULE_signalIdentifier; } public enterRule(listener: CircomParserListener): void { - if (listener.enterVarDefinition) { - listener.enterVarDefinition(this); + if (listener.enterSignalIdentifier) { + listener.enterSignalIdentifier(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitVarDefinition) { - listener.exitVarDefinition(this); + if (listener.exitSignalIdentifier) { + listener.exitSignalIdentifier(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitVarDefinition) { - return visitor.visitVarDefinition(this); + if (visitor.visitSignalIdentifier) { + return visitor.visitSignalIdentifier(this); } else { return visitor.visitChildren(this); } } } -export class VarDeclarationContext extends ParserRuleContext { +export class SignalIdentifierListContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -5597,17 +6394,16 @@ export class VarDeclarationContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public varDefinition(): VarDefinitionContext { - return this.getTypedRuleContext( - VarDefinitionContext, - 0, - ) as VarDefinitionContext; - } - public ASSIGNMENT(): TerminalNode { - return this.getToken(CircomParser.ASSIGNMENT, 0); + public signalIdentifier_list(): SignalIdentifierContext[] { + return this.getTypedRuleContexts( + SignalIdentifierContext, + ) as SignalIdentifierContext[]; } - public rhsValue(): RhsValueContext { - return this.getTypedRuleContext(RhsValueContext, 0) as RhsValueContext; + public signalIdentifier(i: number): SignalIdentifierContext { + return this.getTypedRuleContext( + SignalIdentifierContext, + i, + ) as SignalIdentifierContext; } public COMMA_list(): TerminalNode[] { return this.getTokens(CircomParser.COMMA); @@ -5615,36 +6411,30 @@ export class VarDeclarationContext extends ParserRuleContext { public COMMA(i: number): TerminalNode { return this.getToken(CircomParser.COMMA, i); } - public identifier_list(): IdentifierContext[] { - return this.getTypedRuleContexts(IdentifierContext) as IdentifierContext[]; - } - public identifier(i: number): IdentifierContext { - return this.getTypedRuleContext(IdentifierContext, i) as IdentifierContext; - } public get ruleIndex(): number { - return CircomParser.RULE_varDeclaration; + return CircomParser.RULE_signalIdentifierList; } public enterRule(listener: CircomParserListener): void { - if (listener.enterVarDeclaration) { - listener.enterVarDeclaration(this); + if (listener.enterSignalIdentifierList) { + listener.enterSignalIdentifierList(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitVarDeclaration) { - listener.exitVarDeclaration(this); + if (listener.exitSignalIdentifierList) { + listener.exitSignalIdentifierList(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitVarDeclaration) { - return visitor.visitVarDeclaration(this); + if (visitor.visitSignalIdentifierList) { + return visitor.visitSignalIdentifierList(this); } else { return visitor.visitChildren(this); } } } -export class RhsValueContext extends ParserRuleContext { +export class IdentifierStatementContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -5653,51 +6443,44 @@ export class RhsValueContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public LP(): TerminalNode { - return this.getToken(CircomParser.LP, 0); - } - public expressionList(): ExpressionListContext { - return this.getTypedRuleContext( - ExpressionListContext, - 0, - ) as ExpressionListContext; - } - public RP(): TerminalNode { - return this.getToken(CircomParser.RP, 0); + public ID(): TerminalNode { + return this.getToken(CircomParser.ID, 0); } - public expression(): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; + public idetifierAccess_list(): IdetifierAccessContext[] { + return this.getTypedRuleContexts( + IdetifierAccessContext, + ) as IdetifierAccessContext[]; } - public blockInstantiation(): BlockInstantiationContext { + public idetifierAccess(i: number): IdetifierAccessContext { return this.getTypedRuleContext( - BlockInstantiationContext, - 0, - ) as BlockInstantiationContext; + IdetifierAccessContext, + i, + ) as IdetifierAccessContext; } public get ruleIndex(): number { - return CircomParser.RULE_rhsValue; + return CircomParser.RULE_identifierStatement; } public enterRule(listener: CircomParserListener): void { - if (listener.enterRhsValue) { - listener.enterRhsValue(this); + if (listener.enterIdentifierStatement) { + listener.enterIdentifierStatement(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitRhsValue) { - listener.exitRhsValue(this); + if (listener.exitIdentifierStatement) { + listener.exitIdentifierStatement(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitRhsValue) { - return visitor.visitRhsValue(this); + if (visitor.visitIdentifierStatement) { + return visitor.visitIdentifierStatement(this); } else { return visitor.visitChildren(this); } } } -export class ComponentCallContext extends ParserRuleContext { +export class IdentifierContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -5706,72 +6489,44 @@ export class ComponentCallContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public LP(): TerminalNode { - return this.getToken(CircomParser.LP, 0); + public ID(): TerminalNode { + return this.getToken(CircomParser.ID, 0); } - public RP(): TerminalNode { - return this.getToken(CircomParser.RP, 0); + public arrayDimension_list(): ArrayDimensionContext[] { + return this.getTypedRuleContexts( + ArrayDimensionContext, + ) as ArrayDimensionContext[]; } - public expressionList(): ExpressionListContext { + public arrayDimension(i: number): ArrayDimensionContext { return this.getTypedRuleContext( - ExpressionListContext, - 0, - ) as ExpressionListContext; - } - public ID_list(): TerminalNode[] { - return this.getTokens(CircomParser.ID); - } - public ID(i: number): TerminalNode { - return this.getToken(CircomParser.ID, i); - } - public LEFT_CONSTRAINT_list(): TerminalNode[] { - return this.getTokens(CircomParser.LEFT_CONSTRAINT); - } - public LEFT_CONSTRAINT(i: number): TerminalNode { - return this.getToken(CircomParser.LEFT_CONSTRAINT, i); - } - public expression_list(): ExpressionContext[] { - return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; - } - public expression(i: number): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; - } - public COMMA_list(): TerminalNode[] { - return this.getTokens(CircomParser.COMMA); - } - public COMMA(i: number): TerminalNode { - return this.getToken(CircomParser.COMMA, i); - } - public RIGHT_CONSTRAINT_list(): TerminalNode[] { - return this.getTokens(CircomParser.RIGHT_CONSTRAINT); - } - public RIGHT_CONSTRAINT(i: number): TerminalNode { - return this.getToken(CircomParser.RIGHT_CONSTRAINT, i); + ArrayDimensionContext, + i, + ) as ArrayDimensionContext; } public get ruleIndex(): number { - return CircomParser.RULE_componentCall; + return CircomParser.RULE_identifier; } public enterRule(listener: CircomParserListener): void { - if (listener.enterComponentCall) { - listener.enterComponentCall(this); + if (listener.enterIdentifier) { + listener.enterIdentifier(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitComponentCall) { - listener.exitComponentCall(this); + if (listener.exitIdentifier) { + listener.exitIdentifier(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitComponentCall) { - return visitor.visitComponentCall(this); + if (visitor.visitIdentifier) { + return visitor.visitIdentifier(this); } else { return visitor.visitChildren(this); } } } -export class BlockInstantiationContext extends ParserRuleContext { +export class IdentifierListContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -5780,54 +6535,42 @@ export class BlockInstantiationContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public ID(): TerminalNode { - return this.getToken(CircomParser.ID, 0); - } - public LP(): TerminalNode { - return this.getToken(CircomParser.LP, 0); - } - public RP(): TerminalNode { - return this.getToken(CircomParser.RP, 0); + public identifier_list(): IdentifierContext[] { + return this.getTypedRuleContexts(IdentifierContext) as IdentifierContext[]; } - public PARALLEL(): TerminalNode { - return this.getToken(CircomParser.PARALLEL, 0); + public identifier(i: number): IdentifierContext { + return this.getTypedRuleContext(IdentifierContext, i) as IdentifierContext; } - public expressionList(): ExpressionListContext { - return this.getTypedRuleContext( - ExpressionListContext, - 0, - ) as ExpressionListContext; + public COMMA_list(): TerminalNode[] { + return this.getTokens(CircomParser.COMMA); } - public componentCall(): ComponentCallContext { - return this.getTypedRuleContext( - ComponentCallContext, - 0, - ) as ComponentCallContext; + public COMMA(i: number): TerminalNode { + return this.getToken(CircomParser.COMMA, i); } public get ruleIndex(): number { - return CircomParser.RULE_blockInstantiation; + return CircomParser.RULE_identifierList; } public enterRule(listener: CircomParserListener): void { - if (listener.enterBlockInstantiation) { - listener.enterBlockInstantiation(this); + if (listener.enterIdentifierList) { + listener.enterIdentifierList(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitBlockInstantiation) { - listener.exitBlockInstantiation(this); + if (listener.exitIdentifierList) { + listener.exitIdentifierList(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitBlockInstantiation) { - return visitor.visitBlockInstantiation(this); + if (visitor.visitIdentifierList) { + return visitor.visitIdentifierList(this); } else { return visitor.visitChildren(this); } } } -export class ExpressionListContext extends ParserRuleContext { +export class SimpleIdentifierListContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -5836,11 +6579,11 @@ export class ExpressionListContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public expression_list(): ExpressionContext[] { - return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; + public ID_list(): TerminalNode[] { + return this.getTokens(CircomParser.ID); } - public expression(i: number): ExpressionContext { - return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + public ID(i: number): TerminalNode { + return this.getToken(CircomParser.ID, i); } public COMMA_list(): TerminalNode[] { return this.getTokens(CircomParser.COMMA); @@ -5849,29 +6592,29 @@ export class ExpressionListContext extends ParserRuleContext { return this.getToken(CircomParser.COMMA, i); } public get ruleIndex(): number { - return CircomParser.RULE_expressionList; + return CircomParser.RULE_simpleIdentifierList; } public enterRule(listener: CircomParserListener): void { - if (listener.enterExpressionList) { - listener.enterExpressionList(this); + if (listener.enterSimpleIdentifierList) { + listener.enterSimpleIdentifierList(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitExpressionList) { - listener.exitExpressionList(this); + if (listener.exitSimpleIdentifierList) { + listener.exitSimpleIdentifierList(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitExpressionList) { - return visitor.visitExpressionList(this); + if (visitor.visitSimpleIdentifierList) { + return visitor.visitSimpleIdentifierList(this); } else { return visitor.visitChildren(this); } } } -export class IdentifierContext extends ParserRuleContext { +export class IdetifierAccessContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -5880,43 +6623,35 @@ export class IdentifierContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public ID_list(): TerminalNode[] { - return this.getTokens(CircomParser.ID); - } - public ID(i: number): TerminalNode { - return this.getToken(CircomParser.ID, i); - } - public arrayDimension_list(): ArrayDimensionContext[] { - return this.getTypedRuleContexts( - ArrayDimensionContext, - ) as ArrayDimensionContext[]; - } - public arrayDimension(i: number): ArrayDimensionContext { + public arrayDimension(): ArrayDimensionContext { return this.getTypedRuleContext( ArrayDimensionContext, - i, + 0, ) as ArrayDimensionContext; } - public DOT(): TerminalNode { - return this.getToken(CircomParser.DOT, 0); + public identifierReferance(): IdentifierReferanceContext { + return this.getTypedRuleContext( + IdentifierReferanceContext, + 0, + ) as IdentifierReferanceContext; } public get ruleIndex(): number { - return CircomParser.RULE_identifier; + return CircomParser.RULE_idetifierAccess; } public enterRule(listener: CircomParserListener): void { - if (listener.enterIdentifier) { - listener.enterIdentifier(this); + if (listener.enterIdetifierAccess) { + listener.enterIdetifierAccess(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitIdentifier) { - listener.exitIdentifier(this); + if (listener.exitIdetifierAccess) { + listener.exitIdetifierAccess(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitIdentifier) { - return visitor.visitIdentifier(this); + if (visitor.visitIdetifierAccess) { + return visitor.visitIdetifierAccess(this); } else { return visitor.visitChildren(this); } @@ -5964,7 +6699,7 @@ export class ArrayDimensionContext extends ParserRuleContext { } } -export class ArgsContext extends ParserRuleContext { +export class IdentifierReferanceContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -5973,42 +6708,36 @@ export class ArgsContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public ID_list(): TerminalNode[] { - return this.getTokens(CircomParser.ID); - } - public ID(i: number): TerminalNode { - return this.getToken(CircomParser.ID, i); - } - public COMMA_list(): TerminalNode[] { - return this.getTokens(CircomParser.COMMA); + public DOT(): TerminalNode { + return this.getToken(CircomParser.DOT, 0); } - public COMMA(i: number): TerminalNode { - return this.getToken(CircomParser.COMMA, i); + public ID(): TerminalNode { + return this.getToken(CircomParser.ID, 0); } public get ruleIndex(): number { - return CircomParser.RULE_args; + return CircomParser.RULE_identifierReferance; } public enterRule(listener: CircomParserListener): void { - if (listener.enterArgs) { - listener.enterArgs(this); + if (listener.enterIdentifierReferance) { + listener.enterIdentifierReferance(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitArgs) { - listener.exitArgs(this); + if (listener.exitIdentifierReferance) { + listener.exitIdentifierReferance(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitArgs) { - return visitor.visitArgs(this); + if (visitor.visitIdentifierReferance) { + return visitor.visitIdentifierReferance(this); } else { return visitor.visitChildren(this); } } } -export class ArgsWithUnderscoreContext extends ParserRuleContext { +export class ExpressionOrStringContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -6017,48 +6746,36 @@ export class ArgsWithUnderscoreContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public UNDERSCORE_list(): TerminalNode[] { - return this.getTokens(CircomParser.UNDERSCORE); - } - public UNDERSCORE(i: number): TerminalNode { - return this.getToken(CircomParser.UNDERSCORE, i); - } - public ID_list(): TerminalNode[] { - return this.getTokens(CircomParser.ID); - } - public ID(i: number): TerminalNode { - return this.getToken(CircomParser.ID, i); - } - public COMMA_list(): TerminalNode[] { - return this.getTokens(CircomParser.COMMA); + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } - public COMMA(i: number): TerminalNode { - return this.getToken(CircomParser.COMMA, i); + public STRING(): TerminalNode { + return this.getToken(CircomParser.STRING, 0); } public get ruleIndex(): number { - return CircomParser.RULE_argsWithUnderscore; + return CircomParser.RULE_expressionOrString; } public enterRule(listener: CircomParserListener): void { - if (listener.enterArgsWithUnderscore) { - listener.enterArgsWithUnderscore(this); + if (listener.enterExpressionOrString) { + listener.enterExpressionOrString(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitArgsWithUnderscore) { - listener.exitArgsWithUnderscore(this); + if (listener.exitExpressionOrString) { + listener.exitExpressionOrString(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitArgsWithUnderscore) { - return visitor.visitArgsWithUnderscore(this); + if (visitor.visitExpressionOrString) { + return visitor.visitExpressionOrString(this); } else { return visitor.visitChildren(this); } } } -export class NumSequenceContext extends ParserRuleContext { +export class ExpressionOrStringListContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -6067,11 +6784,16 @@ export class NumSequenceContext extends ParserRuleContext { super(parent, invokingState); this.parser = parser; } - public NUMBER_list(): TerminalNode[] { - return this.getTokens(CircomParser.NUMBER); + public expressionOrString_list(): ExpressionOrStringContext[] { + return this.getTypedRuleContexts( + ExpressionOrStringContext, + ) as ExpressionOrStringContext[]; } - public NUMBER(i: number): TerminalNode { - return this.getToken(CircomParser.NUMBER, i); + public expressionOrString(i: number): ExpressionOrStringContext { + return this.getTypedRuleContext( + ExpressionOrStringContext, + i, + ) as ExpressionOrStringContext; } public COMMA_list(): TerminalNode[] { return this.getTokens(CircomParser.COMMA); @@ -6080,22 +6802,22 @@ export class NumSequenceContext extends ParserRuleContext { return this.getToken(CircomParser.COMMA, i); } public get ruleIndex(): number { - return CircomParser.RULE_numSequence; + return CircomParser.RULE_expressionOrStringList; } public enterRule(listener: CircomParserListener): void { - if (listener.enterNumSequence) { - listener.enterNumSequence(this); + if (listener.enterExpressionOrStringList) { + listener.enterExpressionOrStringList(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitNumSequence) { - listener.exitNumSequence(this); + if (listener.exitExpressionOrStringList) { + listener.exitExpressionOrStringList(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitNumSequence) { - return visitor.visitNumSequence(this); + if (visitor.visitExpressionOrStringList) { + return visitor.visitExpressionOrStringList(this); } else { return visitor.visitChildren(this); } diff --git a/src/generated/CircomParserListener.ts b/src/generated/CircomParserListener.ts index 034812d..834fd18 100644 --- a/src/generated/CircomParserListener.ts +++ b/src/generated/CircomParserListener.ts @@ -3,56 +3,73 @@ import { ParseTreeListener } from "antlr4"; import { CircuitContext } from "./CircomParser"; -import { PragmaDeclarationContext } from "./CircomParser"; -import { IncludeDeclarationContext } from "./CircomParser"; -import { BlockDeclarationContext } from "./CircomParser"; -import { FunctionDeclarationContext } from "./CircomParser"; -import { FunctionBlockContext } from "./CircomParser"; -import { FuncBlockContext } from "./CircomParser"; -import { FuncSelfOpContext } from "./CircomParser"; -import { FuncVarDeclarationContext } from "./CircomParser"; -import { FuncAssignmentExpressionContext } from "./CircomParser"; -import { FuncVariadicAssignmentContext } from "./CircomParser"; -import { IfFuncStmtContext } from "./CircomParser"; -import { WhileFuncStmtContext } from "./CircomParser"; -import { ForFuncStmtContext } from "./CircomParser"; -import { ReturnFuncStmtContext } from "./CircomParser"; -import { AssertFuncStmtContext } from "./CircomParser"; -import { LogFuncStmtContext } from "./CircomParser"; -import { TemplateDeclarationContext } from "./CircomParser"; -import { TemplateBlockContext } from "./CircomParser"; -import { ComponentMainDeclarationContext } from "./CircomParser"; -import { PublicInputsListContext } from "./CircomParser"; -import { TemplateStmtContext } from "./CircomParser"; -import { ElementContext } from "./CircomParser"; -import { ForControlContext } from "./CircomParser"; -import { ForInitContext } from "./CircomParser"; -import { ForUpdateContext } from "./CircomParser"; -import { ParExpressionContext } from "./CircomParser"; -import { TernaryExpressionContext } from "./CircomParser"; -import { DotExpressionContext } from "./CircomParser"; -import { PrimaryExpressionContext } from "./CircomParser"; -import { BinaryExpressionContext } from "./CircomParser"; -import { BlockInstantiationExpressionContext } from "./CircomParser"; -import { UnaryExpressionContext } from "./CircomParser"; -import { PrimaryContext } from "./CircomParser"; -import { LogStmtContext } from "./CircomParser"; -import { ComponentDefinitionContext } from "./CircomParser"; -import { ComponentDeclarationContext } from "./CircomParser"; -import { SignalDefinitionContext } from "./CircomParser"; -import { TagListContext } from "./CircomParser"; -import { SignalDeclarationContext } from "./CircomParser"; -import { VarDefinitionContext } from "./CircomParser"; +import { SignalHeaderContext } from "./CircomParser"; +import { BusHeaderContext } from "./CircomParser"; +import { PragmaVersionContext } from "./CircomParser"; +import { PragmaInvalidVersionContext } from "./CircomParser"; +import { PragmaCustomTemplatesContext } from "./CircomParser"; +import { IncludeDefinitionContext } from "./CircomParser"; +import { BlockDefinitonContext } from "./CircomParser"; +import { FunctionDefinitionContext } from "./CircomParser"; +import { TemplateDefinitionContext } from "./CircomParser"; +import { BusDefinitionContext } from "./CircomParser"; +import { PublicInputsDefinitionContext } from "./CircomParser"; +import { TagDefinitionContext } from "./CircomParser"; +import { LogDefinitionContext } from "./CircomParser"; +import { AssertDefinitionContext } from "./CircomParser"; +import { DeclarationsContext } from "./CircomParser"; import { VarDeclarationContext } from "./CircomParser"; -import { RhsValueContext } from "./CircomParser"; -import { ComponentCallContext } from "./CircomParser"; -import { BlockInstantiationContext } from "./CircomParser"; +import { SignalDeclarationContext } from "./CircomParser"; +import { ComponentDeclarationContext } from "./CircomParser"; +import { BusDeclarationContext } from "./CircomParser"; +import { ComponentMainDeclarationContext } from "./CircomParser"; +import { BodyContext } from "./CircomParser"; +import { StatementsContext } from "./CircomParser"; +import { IfWithFollowUpIfContext } from "./CircomParser"; +import { IfRegularContext } from "./CircomParser"; +import { IfRegularElseWithFollowUpIfContext } from "./CircomParser"; +import { IfRegularElseRegularContext } from "./CircomParser"; +import { RStatementBodyContext } from "./CircomParser"; +import { RStatementExpressionContext } from "./CircomParser"; +import { RStatementSucstitutionsContext } from "./CircomParser"; +import { RStatementCyclesContext } from "./CircomParser"; +import { RStatementEqConstraintContext } from "./CircomParser"; +import { RStatementReturnContext } from "./CircomParser"; +import { CycleForWithDeclarationContext } from "./CircomParser"; +import { CycleForWithoutDeclarationContext } from "./CircomParser"; +import { CycleWhileContext } from "./CircomParser"; +import { SubsLeftAssignmentContext } from "./CircomParser"; +import { SubsRightSimpleAssignmentContext } from "./CircomParser"; +import { SubsRightConstrAssignmentContext } from "./CircomParser"; +import { SubsAssignmentWithOperationContext } from "./CircomParser"; +import { SubsIcnDecOperationContext } from "./CircomParser"; +import { SubsInvalidIcnDecOperationContext } from "./CircomParser"; import { ExpressionListContext } from "./CircomParser"; +import { ExpressionListWithNamesContext } from "./CircomParser"; +import { ExpressionContext } from "./CircomParser"; +import { PIdentifierStatementContext } from "./CircomParser"; +import { PUnderscoreContext } from "./CircomParser"; +import { PNumberContext } from "./CircomParser"; +import { PParenthesesContext } from "./CircomParser"; +import { PArrayContext } from "./CircomParser"; +import { PCallContext } from "./CircomParser"; +import { PAnonymousCallContext } from "./CircomParser"; +import { AssignExprConstraintContext } from "./CircomParser"; +import { AssignExprSimpleContext } from "./CircomParser"; +import { AssignExprRegularContext } from "./CircomParser"; +import { VarIdentifierContext } from "./CircomParser"; +import { VarIdentifierListContext } from "./CircomParser"; +import { SignalIdentifierContext } from "./CircomParser"; +import { SignalIdentifierListContext } from "./CircomParser"; +import { IdentifierStatementContext } from "./CircomParser"; import { IdentifierContext } from "./CircomParser"; +import { IdentifierListContext } from "./CircomParser"; +import { SimpleIdentifierListContext } from "./CircomParser"; +import { IdetifierAccessContext } from "./CircomParser"; import { ArrayDimensionContext } from "./CircomParser"; -import { ArgsContext } from "./CircomParser"; -import { ArgsWithUnderscoreContext } from "./CircomParser"; -import { NumSequenceContext } from "./CircomParser"; +import { IdentifierReferanceContext } from "./CircomParser"; +import { ExpressionOrStringContext } from "./CircomParser"; +import { ExpressionOrStringListContext } from "./CircomParser"; /** * This interface defines a complete listener for a parse tree produced by @@ -70,209 +87,201 @@ export default class CircomParserListener extends ParseTreeListener { */ exitCircuit?: (ctx: CircuitContext) => void; /** - * Enter a parse tree produced by `CircomParser.pragmaDeclaration`. + * Enter a parse tree produced by `CircomParser.signalHeader`. * @param ctx the parse tree */ - enterPragmaDeclaration?: (ctx: PragmaDeclarationContext) => void; + enterSignalHeader?: (ctx: SignalHeaderContext) => void; /** - * Exit a parse tree produced by `CircomParser.pragmaDeclaration`. + * Exit a parse tree produced by `CircomParser.signalHeader`. * @param ctx the parse tree */ - exitPragmaDeclaration?: (ctx: PragmaDeclarationContext) => void; + exitSignalHeader?: (ctx: SignalHeaderContext) => void; /** - * Enter a parse tree produced by `CircomParser.includeDeclaration`. + * Enter a parse tree produced by `CircomParser.busHeader`. * @param ctx the parse tree */ - enterIncludeDeclaration?: (ctx: IncludeDeclarationContext) => void; + enterBusHeader?: (ctx: BusHeaderContext) => void; /** - * Exit a parse tree produced by `CircomParser.includeDeclaration`. + * Exit a parse tree produced by `CircomParser.busHeader`. * @param ctx the parse tree */ - exitIncludeDeclaration?: (ctx: IncludeDeclarationContext) => void; + exitBusHeader?: (ctx: BusHeaderContext) => void; /** - * Enter a parse tree produced by `CircomParser.blockDeclaration`. + * Enter a parse tree produced by the `PragmaVersion` + * labeled alternative in `CircomParser.pragmaDefinition`. * @param ctx the parse tree */ - enterBlockDeclaration?: (ctx: BlockDeclarationContext) => void; + enterPragmaVersion?: (ctx: PragmaVersionContext) => void; /** - * Exit a parse tree produced by `CircomParser.blockDeclaration`. + * Exit a parse tree produced by the `PragmaVersion` + * labeled alternative in `CircomParser.pragmaDefinition`. * @param ctx the parse tree */ - exitBlockDeclaration?: (ctx: BlockDeclarationContext) => void; + exitPragmaVersion?: (ctx: PragmaVersionContext) => void; /** - * Enter a parse tree produced by `CircomParser.functionDeclaration`. + * Enter a parse tree produced by the `PragmaInvalidVersion` + * labeled alternative in `CircomParser.pragmaDefinition`. * @param ctx the parse tree */ - enterFunctionDeclaration?: (ctx: FunctionDeclarationContext) => void; + enterPragmaInvalidVersion?: (ctx: PragmaInvalidVersionContext) => void; /** - * Exit a parse tree produced by `CircomParser.functionDeclaration`. + * Exit a parse tree produced by the `PragmaInvalidVersion` + * labeled alternative in `CircomParser.pragmaDefinition`. * @param ctx the parse tree */ - exitFunctionDeclaration?: (ctx: FunctionDeclarationContext) => void; + exitPragmaInvalidVersion?: (ctx: PragmaInvalidVersionContext) => void; /** - * Enter a parse tree produced by `CircomParser.functionBlock`. + * Enter a parse tree produced by the `PragmaCustomTemplates` + * labeled alternative in `CircomParser.pragmaDefinition`. * @param ctx the parse tree */ - enterFunctionBlock?: (ctx: FunctionBlockContext) => void; + enterPragmaCustomTemplates?: (ctx: PragmaCustomTemplatesContext) => void; /** - * Exit a parse tree produced by `CircomParser.functionBlock`. + * Exit a parse tree produced by the `PragmaCustomTemplates` + * labeled alternative in `CircomParser.pragmaDefinition`. * @param ctx the parse tree */ - exitFunctionBlock?: (ctx: FunctionBlockContext) => void; + exitPragmaCustomTemplates?: (ctx: PragmaCustomTemplatesContext) => void; /** - * Enter a parse tree produced by the `FuncBlock` - * labeled alternative in `CircomParser.functionStmt`. + * Enter a parse tree produced by `CircomParser.includeDefinition`. * @param ctx the parse tree */ - enterFuncBlock?: (ctx: FuncBlockContext) => void; + enterIncludeDefinition?: (ctx: IncludeDefinitionContext) => void; /** - * Exit a parse tree produced by the `FuncBlock` - * labeled alternative in `CircomParser.functionStmt`. + * Exit a parse tree produced by `CircomParser.includeDefinition`. * @param ctx the parse tree */ - exitFuncBlock?: (ctx: FuncBlockContext) => void; + exitIncludeDefinition?: (ctx: IncludeDefinitionContext) => void; /** - * Enter a parse tree produced by the `FuncSelfOp` - * labeled alternative in `CircomParser.functionStmt`. + * Enter a parse tree produced by `CircomParser.blockDefiniton`. * @param ctx the parse tree */ - enterFuncSelfOp?: (ctx: FuncSelfOpContext) => void; + enterBlockDefiniton?: (ctx: BlockDefinitonContext) => void; /** - * Exit a parse tree produced by the `FuncSelfOp` - * labeled alternative in `CircomParser.functionStmt`. + * Exit a parse tree produced by `CircomParser.blockDefiniton`. * @param ctx the parse tree */ - exitFuncSelfOp?: (ctx: FuncSelfOpContext) => void; + exitBlockDefiniton?: (ctx: BlockDefinitonContext) => void; /** - * Enter a parse tree produced by the `FuncVarDeclaration` - * labeled alternative in `CircomParser.functionStmt`. + * Enter a parse tree produced by `CircomParser.functionDefinition`. * @param ctx the parse tree */ - enterFuncVarDeclaration?: (ctx: FuncVarDeclarationContext) => void; + enterFunctionDefinition?: (ctx: FunctionDefinitionContext) => void; /** - * Exit a parse tree produced by the `FuncVarDeclaration` - * labeled alternative in `CircomParser.functionStmt`. + * Exit a parse tree produced by `CircomParser.functionDefinition`. * @param ctx the parse tree */ - exitFuncVarDeclaration?: (ctx: FuncVarDeclarationContext) => void; + exitFunctionDefinition?: (ctx: FunctionDefinitionContext) => void; /** - * Enter a parse tree produced by the `FuncAssignmentExpression` - * labeled alternative in `CircomParser.functionStmt`. + * Enter a parse tree produced by `CircomParser.templateDefinition`. * @param ctx the parse tree */ - enterFuncAssignmentExpression?: ( - ctx: FuncAssignmentExpressionContext, - ) => void; + enterTemplateDefinition?: (ctx: TemplateDefinitionContext) => void; /** - * Exit a parse tree produced by the `FuncAssignmentExpression` - * labeled alternative in `CircomParser.functionStmt`. + * Exit a parse tree produced by `CircomParser.templateDefinition`. * @param ctx the parse tree */ - exitFuncAssignmentExpression?: (ctx: FuncAssignmentExpressionContext) => void; + exitTemplateDefinition?: (ctx: TemplateDefinitionContext) => void; /** - * Enter a parse tree produced by the `FuncVariadicAssignment` - * labeled alternative in `CircomParser.functionStmt`. + * Enter a parse tree produced by `CircomParser.busDefinition`. * @param ctx the parse tree */ - enterFuncVariadicAssignment?: (ctx: FuncVariadicAssignmentContext) => void; + enterBusDefinition?: (ctx: BusDefinitionContext) => void; /** - * Exit a parse tree produced by the `FuncVariadicAssignment` - * labeled alternative in `CircomParser.functionStmt`. + * Exit a parse tree produced by `CircomParser.busDefinition`. * @param ctx the parse tree */ - exitFuncVariadicAssignment?: (ctx: FuncVariadicAssignmentContext) => void; + exitBusDefinition?: (ctx: BusDefinitionContext) => void; /** - * Enter a parse tree produced by the `IfFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Enter a parse tree produced by `CircomParser.publicInputsDefinition`. * @param ctx the parse tree */ - enterIfFuncStmt?: (ctx: IfFuncStmtContext) => void; + enterPublicInputsDefinition?: (ctx: PublicInputsDefinitionContext) => void; /** - * Exit a parse tree produced by the `IfFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Exit a parse tree produced by `CircomParser.publicInputsDefinition`. * @param ctx the parse tree */ - exitIfFuncStmt?: (ctx: IfFuncStmtContext) => void; + exitPublicInputsDefinition?: (ctx: PublicInputsDefinitionContext) => void; /** - * Enter a parse tree produced by the `WhileFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Enter a parse tree produced by `CircomParser.tagDefinition`. * @param ctx the parse tree */ - enterWhileFuncStmt?: (ctx: WhileFuncStmtContext) => void; + enterTagDefinition?: (ctx: TagDefinitionContext) => void; /** - * Exit a parse tree produced by the `WhileFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Exit a parse tree produced by `CircomParser.tagDefinition`. * @param ctx the parse tree */ - exitWhileFuncStmt?: (ctx: WhileFuncStmtContext) => void; + exitTagDefinition?: (ctx: TagDefinitionContext) => void; /** - * Enter a parse tree produced by the `ForFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Enter a parse tree produced by `CircomParser.logDefinition`. * @param ctx the parse tree */ - enterForFuncStmt?: (ctx: ForFuncStmtContext) => void; + enterLogDefinition?: (ctx: LogDefinitionContext) => void; /** - * Exit a parse tree produced by the `ForFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Exit a parse tree produced by `CircomParser.logDefinition`. * @param ctx the parse tree */ - exitForFuncStmt?: (ctx: ForFuncStmtContext) => void; + exitLogDefinition?: (ctx: LogDefinitionContext) => void; /** - * Enter a parse tree produced by the `ReturnFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Enter a parse tree produced by `CircomParser.assertDefinition`. * @param ctx the parse tree */ - enterReturnFuncStmt?: (ctx: ReturnFuncStmtContext) => void; + enterAssertDefinition?: (ctx: AssertDefinitionContext) => void; /** - * Exit a parse tree produced by the `ReturnFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Exit a parse tree produced by `CircomParser.assertDefinition`. * @param ctx the parse tree */ - exitReturnFuncStmt?: (ctx: ReturnFuncStmtContext) => void; + exitAssertDefinition?: (ctx: AssertDefinitionContext) => void; /** - * Enter a parse tree produced by the `AssertFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Enter a parse tree produced by `CircomParser.declarations`. * @param ctx the parse tree */ - enterAssertFuncStmt?: (ctx: AssertFuncStmtContext) => void; + enterDeclarations?: (ctx: DeclarationsContext) => void; /** - * Exit a parse tree produced by the `AssertFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Exit a parse tree produced by `CircomParser.declarations`. * @param ctx the parse tree */ - exitAssertFuncStmt?: (ctx: AssertFuncStmtContext) => void; + exitDeclarations?: (ctx: DeclarationsContext) => void; /** - * Enter a parse tree produced by the `LogFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Enter a parse tree produced by `CircomParser.varDeclaration`. * @param ctx the parse tree */ - enterLogFuncStmt?: (ctx: LogFuncStmtContext) => void; + enterVarDeclaration?: (ctx: VarDeclarationContext) => void; + /** + * Exit a parse tree produced by `CircomParser.varDeclaration`. + * @param ctx the parse tree + */ + exitVarDeclaration?: (ctx: VarDeclarationContext) => void; + /** + * Enter a parse tree produced by `CircomParser.signalDeclaration`. + * @param ctx the parse tree + */ + enterSignalDeclaration?: (ctx: SignalDeclarationContext) => void; /** - * Exit a parse tree produced by the `LogFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Exit a parse tree produced by `CircomParser.signalDeclaration`. * @param ctx the parse tree */ - exitLogFuncStmt?: (ctx: LogFuncStmtContext) => void; + exitSignalDeclaration?: (ctx: SignalDeclarationContext) => void; /** - * Enter a parse tree produced by `CircomParser.templateDeclaration`. + * Enter a parse tree produced by `CircomParser.componentDeclaration`. * @param ctx the parse tree */ - enterTemplateDeclaration?: (ctx: TemplateDeclarationContext) => void; + enterComponentDeclaration?: (ctx: ComponentDeclarationContext) => void; /** - * Exit a parse tree produced by `CircomParser.templateDeclaration`. + * Exit a parse tree produced by `CircomParser.componentDeclaration`. * @param ctx the parse tree */ - exitTemplateDeclaration?: (ctx: TemplateDeclarationContext) => void; + exitComponentDeclaration?: (ctx: ComponentDeclarationContext) => void; /** - * Enter a parse tree produced by `CircomParser.templateBlock`. + * Enter a parse tree produced by `CircomParser.busDeclaration`. * @param ctx the parse tree */ - enterTemplateBlock?: (ctx: TemplateBlockContext) => void; + enterBusDeclaration?: (ctx: BusDeclarationContext) => void; /** - * Exit a parse tree produced by `CircomParser.templateBlock`. + * Exit a parse tree produced by `CircomParser.busDeclaration`. * @param ctx the parse tree */ - exitTemplateBlock?: (ctx: TemplateBlockContext) => void; + exitBusDeclaration?: (ctx: BusDeclarationContext) => void; /** * Enter a parse tree produced by `CircomParser.componentMainDeclaration`. * @param ctx the parse tree @@ -286,281 +295,477 @@ export default class CircomParserListener extends ParseTreeListener { */ exitComponentMainDeclaration?: (ctx: ComponentMainDeclarationContext) => void; /** - * Enter a parse tree produced by `CircomParser.publicInputsList`. + * Enter a parse tree produced by `CircomParser.body`. * @param ctx the parse tree */ - enterPublicInputsList?: (ctx: PublicInputsListContext) => void; + enterBody?: (ctx: BodyContext) => void; /** - * Exit a parse tree produced by `CircomParser.publicInputsList`. + * Exit a parse tree produced by `CircomParser.body`. * @param ctx the parse tree */ - exitPublicInputsList?: (ctx: PublicInputsListContext) => void; + exitBody?: (ctx: BodyContext) => void; /** - * Enter a parse tree produced by `CircomParser.templateStmt`. + * Enter a parse tree produced by `CircomParser.statements`. * @param ctx the parse tree */ - enterTemplateStmt?: (ctx: TemplateStmtContext) => void; + enterStatements?: (ctx: StatementsContext) => void; /** - * Exit a parse tree produced by `CircomParser.templateStmt`. + * Exit a parse tree produced by `CircomParser.statements`. * @param ctx the parse tree */ - exitTemplateStmt?: (ctx: TemplateStmtContext) => void; + exitStatements?: (ctx: StatementsContext) => void; /** - * Enter a parse tree produced by `CircomParser.element`. + * Enter a parse tree produced by the `IfWithFollowUpIf` + * labeled alternative in `CircomParser.ifStatements`. * @param ctx the parse tree */ - enterElement?: (ctx: ElementContext) => void; + enterIfWithFollowUpIf?: (ctx: IfWithFollowUpIfContext) => void; + /** + * Exit a parse tree produced by the `IfWithFollowUpIf` + * labeled alternative in `CircomParser.ifStatements`. + * @param ctx the parse tree + */ + exitIfWithFollowUpIf?: (ctx: IfWithFollowUpIfContext) => void; + /** + * Enter a parse tree produced by the `IfRegular` + * labeled alternative in `CircomParser.ifStatements`. + * @param ctx the parse tree + */ + enterIfRegular?: (ctx: IfRegularContext) => void; + /** + * Exit a parse tree produced by the `IfRegular` + * labeled alternative in `CircomParser.ifStatements`. + * @param ctx the parse tree + */ + exitIfRegular?: (ctx: IfRegularContext) => void; + /** + * Enter a parse tree produced by the `IfRegularElseWithFollowUpIf` + * labeled alternative in `CircomParser.ifStatements`. + * @param ctx the parse tree + */ + enterIfRegularElseWithFollowUpIf?: ( + ctx: IfRegularElseWithFollowUpIfContext, + ) => void; /** - * Exit a parse tree produced by `CircomParser.element`. + * Exit a parse tree produced by the `IfRegularElseWithFollowUpIf` + * labeled alternative in `CircomParser.ifStatements`. * @param ctx the parse tree */ - exitElement?: (ctx: ElementContext) => void; + exitIfRegularElseWithFollowUpIf?: ( + ctx: IfRegularElseWithFollowUpIfContext, + ) => void; /** - * Enter a parse tree produced by `CircomParser.forControl`. + * Enter a parse tree produced by the `IfRegularElseRegular` + * labeled alternative in `CircomParser.ifStatements`. * @param ctx the parse tree */ - enterForControl?: (ctx: ForControlContext) => void; + enterIfRegularElseRegular?: (ctx: IfRegularElseRegularContext) => void; /** - * Exit a parse tree produced by `CircomParser.forControl`. + * Exit a parse tree produced by the `IfRegularElseRegular` + * labeled alternative in `CircomParser.ifStatements`. * @param ctx the parse tree */ - exitForControl?: (ctx: ForControlContext) => void; + exitIfRegularElseRegular?: (ctx: IfRegularElseRegularContext) => void; /** - * Enter a parse tree produced by `CircomParser.forInit`. + * Enter a parse tree produced by the `RStatementBody` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - enterForInit?: (ctx: ForInitContext) => void; + enterRStatementBody?: (ctx: RStatementBodyContext) => void; /** - * Exit a parse tree produced by `CircomParser.forInit`. + * Exit a parse tree produced by the `RStatementBody` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - exitForInit?: (ctx: ForInitContext) => void; + exitRStatementBody?: (ctx: RStatementBodyContext) => void; /** - * Enter a parse tree produced by `CircomParser.forUpdate`. + * Enter a parse tree produced by the `RStatementExpression` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - enterForUpdate?: (ctx: ForUpdateContext) => void; + enterRStatementExpression?: (ctx: RStatementExpressionContext) => void; /** - * Exit a parse tree produced by `CircomParser.forUpdate`. + * Exit a parse tree produced by the `RStatementExpression` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - exitForUpdate?: (ctx: ForUpdateContext) => void; + exitRStatementExpression?: (ctx: RStatementExpressionContext) => void; /** - * Enter a parse tree produced by `CircomParser.parExpression`. + * Enter a parse tree produced by the `RStatementSucstitutions` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - enterParExpression?: (ctx: ParExpressionContext) => void; + enterRStatementSucstitutions?: (ctx: RStatementSucstitutionsContext) => void; /** - * Exit a parse tree produced by `CircomParser.parExpression`. + * Exit a parse tree produced by the `RStatementSucstitutions` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - exitParExpression?: (ctx: ParExpressionContext) => void; + exitRStatementSucstitutions?: (ctx: RStatementSucstitutionsContext) => void; /** - * Enter a parse tree produced by the `TernaryExpression` - * labeled alternative in `CircomParser.expression`. + * Enter a parse tree produced by the `RStatementCycles` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - enterTernaryExpression?: (ctx: TernaryExpressionContext) => void; + enterRStatementCycles?: (ctx: RStatementCyclesContext) => void; /** - * Exit a parse tree produced by the `TernaryExpression` - * labeled alternative in `CircomParser.expression`. + * Exit a parse tree produced by the `RStatementCycles` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - exitTernaryExpression?: (ctx: TernaryExpressionContext) => void; + exitRStatementCycles?: (ctx: RStatementCyclesContext) => void; /** - * Enter a parse tree produced by the `DotExpression` - * labeled alternative in `CircomParser.expression`. + * Enter a parse tree produced by the `RStatementEqConstraint` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - enterDotExpression?: (ctx: DotExpressionContext) => void; + enterRStatementEqConstraint?: (ctx: RStatementEqConstraintContext) => void; /** - * Exit a parse tree produced by the `DotExpression` - * labeled alternative in `CircomParser.expression`. + * Exit a parse tree produced by the `RStatementEqConstraint` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - exitDotExpression?: (ctx: DotExpressionContext) => void; + exitRStatementEqConstraint?: (ctx: RStatementEqConstraintContext) => void; /** - * Enter a parse tree produced by the `PrimaryExpression` - * labeled alternative in `CircomParser.expression`. + * Enter a parse tree produced by the `RStatementReturn` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - enterPrimaryExpression?: (ctx: PrimaryExpressionContext) => void; + enterRStatementReturn?: (ctx: RStatementReturnContext) => void; /** - * Exit a parse tree produced by the `PrimaryExpression` - * labeled alternative in `CircomParser.expression`. + * Exit a parse tree produced by the `RStatementReturn` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree */ - exitPrimaryExpression?: (ctx: PrimaryExpressionContext) => void; + exitRStatementReturn?: (ctx: RStatementReturnContext) => void; /** - * Enter a parse tree produced by the `BinaryExpression` - * labeled alternative in `CircomParser.expression`. + * Enter a parse tree produced by the `CycleForWithDeclaration` + * labeled alternative in `CircomParser.cycleStatements`. * @param ctx the parse tree */ - enterBinaryExpression?: (ctx: BinaryExpressionContext) => void; + enterCycleForWithDeclaration?: (ctx: CycleForWithDeclarationContext) => void; /** - * Exit a parse tree produced by the `BinaryExpression` - * labeled alternative in `CircomParser.expression`. + * Exit a parse tree produced by the `CycleForWithDeclaration` + * labeled alternative in `CircomParser.cycleStatements`. * @param ctx the parse tree */ - exitBinaryExpression?: (ctx: BinaryExpressionContext) => void; + exitCycleForWithDeclaration?: (ctx: CycleForWithDeclarationContext) => void; /** - * Enter a parse tree produced by the `BlockInstantiationExpression` - * labeled alternative in `CircomParser.expression`. + * Enter a parse tree produced by the `CycleForWithoutDeclaration` + * labeled alternative in `CircomParser.cycleStatements`. * @param ctx the parse tree */ - enterBlockInstantiationExpression?: ( - ctx: BlockInstantiationExpressionContext, + enterCycleForWithoutDeclaration?: ( + ctx: CycleForWithoutDeclarationContext, ) => void; /** - * Exit a parse tree produced by the `BlockInstantiationExpression` - * labeled alternative in `CircomParser.expression`. + * Exit a parse tree produced by the `CycleForWithoutDeclaration` + * labeled alternative in `CircomParser.cycleStatements`. * @param ctx the parse tree */ - exitBlockInstantiationExpression?: ( - ctx: BlockInstantiationExpressionContext, + exitCycleForWithoutDeclaration?: ( + ctx: CycleForWithoutDeclarationContext, ) => void; /** - * Enter a parse tree produced by the `UnaryExpression` - * labeled alternative in `CircomParser.expression`. + * Enter a parse tree produced by the `CycleWhile` + * labeled alternative in `CircomParser.cycleStatements`. * @param ctx the parse tree */ - enterUnaryExpression?: (ctx: UnaryExpressionContext) => void; + enterCycleWhile?: (ctx: CycleWhileContext) => void; /** - * Exit a parse tree produced by the `UnaryExpression` - * labeled alternative in `CircomParser.expression`. + * Exit a parse tree produced by the `CycleWhile` + * labeled alternative in `CircomParser.cycleStatements`. * @param ctx the parse tree */ - exitUnaryExpression?: (ctx: UnaryExpressionContext) => void; + exitCycleWhile?: (ctx: CycleWhileContext) => void; /** - * Enter a parse tree produced by `CircomParser.primary`. + * Enter a parse tree produced by the `SubsLeftAssignment` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - enterPrimary?: (ctx: PrimaryContext) => void; + enterSubsLeftAssignment?: (ctx: SubsLeftAssignmentContext) => void; /** - * Exit a parse tree produced by `CircomParser.primary`. + * Exit a parse tree produced by the `SubsLeftAssignment` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - exitPrimary?: (ctx: PrimaryContext) => void; + exitSubsLeftAssignment?: (ctx: SubsLeftAssignmentContext) => void; /** - * Enter a parse tree produced by `CircomParser.logStmt`. + * Enter a parse tree produced by the `SubsRightSimpleAssignment` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - enterLogStmt?: (ctx: LogStmtContext) => void; + enterSubsRightSimpleAssignment?: ( + ctx: SubsRightSimpleAssignmentContext, + ) => void; /** - * Exit a parse tree produced by `CircomParser.logStmt`. + * Exit a parse tree produced by the `SubsRightSimpleAssignment` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - exitLogStmt?: (ctx: LogStmtContext) => void; + exitSubsRightSimpleAssignment?: ( + ctx: SubsRightSimpleAssignmentContext, + ) => void; /** - * Enter a parse tree produced by `CircomParser.componentDefinition`. + * Enter a parse tree produced by the `SubsRightConstrAssignment` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - enterComponentDefinition?: (ctx: ComponentDefinitionContext) => void; + enterSubsRightConstrAssignment?: ( + ctx: SubsRightConstrAssignmentContext, + ) => void; /** - * Exit a parse tree produced by `CircomParser.componentDefinition`. + * Exit a parse tree produced by the `SubsRightConstrAssignment` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - exitComponentDefinition?: (ctx: ComponentDefinitionContext) => void; + exitSubsRightConstrAssignment?: ( + ctx: SubsRightConstrAssignmentContext, + ) => void; /** - * Enter a parse tree produced by `CircomParser.componentDeclaration`. + * Enter a parse tree produced by the `SubsAssignmentWithOperation` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - enterComponentDeclaration?: (ctx: ComponentDeclarationContext) => void; + enterSubsAssignmentWithOperation?: ( + ctx: SubsAssignmentWithOperationContext, + ) => void; /** - * Exit a parse tree produced by `CircomParser.componentDeclaration`. + * Exit a parse tree produced by the `SubsAssignmentWithOperation` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - exitComponentDeclaration?: (ctx: ComponentDeclarationContext) => void; + exitSubsAssignmentWithOperation?: ( + ctx: SubsAssignmentWithOperationContext, + ) => void; /** - * Enter a parse tree produced by `CircomParser.signalDefinition`. + * Enter a parse tree produced by the `SubsIcnDecOperation` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - enterSignalDefinition?: (ctx: SignalDefinitionContext) => void; + enterSubsIcnDecOperation?: (ctx: SubsIcnDecOperationContext) => void; /** - * Exit a parse tree produced by `CircomParser.signalDefinition`. + * Exit a parse tree produced by the `SubsIcnDecOperation` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - exitSignalDefinition?: (ctx: SignalDefinitionContext) => void; + exitSubsIcnDecOperation?: (ctx: SubsIcnDecOperationContext) => void; /** - * Enter a parse tree produced by `CircomParser.tagList`. + * Enter a parse tree produced by the `SubsInvalidIcnDecOperation` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - enterTagList?: (ctx: TagListContext) => void; + enterSubsInvalidIcnDecOperation?: ( + ctx: SubsInvalidIcnDecOperationContext, + ) => void; /** - * Exit a parse tree produced by `CircomParser.tagList`. + * Exit a parse tree produced by the `SubsInvalidIcnDecOperation` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree */ - exitTagList?: (ctx: TagListContext) => void; + exitSubsInvalidIcnDecOperation?: ( + ctx: SubsInvalidIcnDecOperationContext, + ) => void; /** - * Enter a parse tree produced by `CircomParser.signalDeclaration`. + * Enter a parse tree produced by `CircomParser.expressionList`. * @param ctx the parse tree */ - enterSignalDeclaration?: (ctx: SignalDeclarationContext) => void; + enterExpressionList?: (ctx: ExpressionListContext) => void; /** - * Exit a parse tree produced by `CircomParser.signalDeclaration`. + * Exit a parse tree produced by `CircomParser.expressionList`. * @param ctx the parse tree */ - exitSignalDeclaration?: (ctx: SignalDeclarationContext) => void; + exitExpressionList?: (ctx: ExpressionListContext) => void; /** - * Enter a parse tree produced by `CircomParser.varDefinition`. + * Enter a parse tree produced by `CircomParser.expressionListWithNames`. * @param ctx the parse tree */ - enterVarDefinition?: (ctx: VarDefinitionContext) => void; + enterExpressionListWithNames?: (ctx: ExpressionListWithNamesContext) => void; /** - * Exit a parse tree produced by `CircomParser.varDefinition`. + * Exit a parse tree produced by `CircomParser.expressionListWithNames`. * @param ctx the parse tree */ - exitVarDefinition?: (ctx: VarDefinitionContext) => void; + exitExpressionListWithNames?: (ctx: ExpressionListWithNamesContext) => void; /** - * Enter a parse tree produced by `CircomParser.varDeclaration`. + * Enter a parse tree produced by `CircomParser.expression`. * @param ctx the parse tree */ - enterVarDeclaration?: (ctx: VarDeclarationContext) => void; + enterExpression?: (ctx: ExpressionContext) => void; /** - * Exit a parse tree produced by `CircomParser.varDeclaration`. + * Exit a parse tree produced by `CircomParser.expression`. * @param ctx the parse tree */ - exitVarDeclaration?: (ctx: VarDeclarationContext) => void; + exitExpression?: (ctx: ExpressionContext) => void; /** - * Enter a parse tree produced by `CircomParser.rhsValue`. + * Enter a parse tree produced by the `PIdentifierStatement` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree */ - enterRhsValue?: (ctx: RhsValueContext) => void; + enterPIdentifierStatement?: (ctx: PIdentifierStatementContext) => void; /** - * Exit a parse tree produced by `CircomParser.rhsValue`. + * Exit a parse tree produced by the `PIdentifierStatement` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree */ - exitRhsValue?: (ctx: RhsValueContext) => void; + exitPIdentifierStatement?: (ctx: PIdentifierStatementContext) => void; /** - * Enter a parse tree produced by `CircomParser.componentCall`. + * Enter a parse tree produced by the `PUnderscore` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree */ - enterComponentCall?: (ctx: ComponentCallContext) => void; + enterPUnderscore?: (ctx: PUnderscoreContext) => void; /** - * Exit a parse tree produced by `CircomParser.componentCall`. + * Exit a parse tree produced by the `PUnderscore` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree */ - exitComponentCall?: (ctx: ComponentCallContext) => void; + exitPUnderscore?: (ctx: PUnderscoreContext) => void; /** - * Enter a parse tree produced by `CircomParser.blockInstantiation`. + * Enter a parse tree produced by the `PNumber` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree */ - enterBlockInstantiation?: (ctx: BlockInstantiationContext) => void; + enterPNumber?: (ctx: PNumberContext) => void; /** - * Exit a parse tree produced by `CircomParser.blockInstantiation`. + * Exit a parse tree produced by the `PNumber` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree */ - exitBlockInstantiation?: (ctx: BlockInstantiationContext) => void; + exitPNumber?: (ctx: PNumberContext) => void; /** - * Enter a parse tree produced by `CircomParser.expressionList`. + * Enter a parse tree produced by the `PParentheses` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree */ - enterExpressionList?: (ctx: ExpressionListContext) => void; + enterPParentheses?: (ctx: PParenthesesContext) => void; /** - * Exit a parse tree produced by `CircomParser.expressionList`. + * Exit a parse tree produced by the `PParentheses` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree */ - exitExpressionList?: (ctx: ExpressionListContext) => void; + exitPParentheses?: (ctx: PParenthesesContext) => void; + /** + * Enter a parse tree produced by the `PArray` + * labeled alternative in `CircomParser.primaryExpression`. + * @param ctx the parse tree + */ + enterPArray?: (ctx: PArrayContext) => void; + /** + * Exit a parse tree produced by the `PArray` + * labeled alternative in `CircomParser.primaryExpression`. + * @param ctx the parse tree + */ + exitPArray?: (ctx: PArrayContext) => void; + /** + * Enter a parse tree produced by the `PCall` + * labeled alternative in `CircomParser.primaryExpression`. + * @param ctx the parse tree + */ + enterPCall?: (ctx: PCallContext) => void; + /** + * Exit a parse tree produced by the `PCall` + * labeled alternative in `CircomParser.primaryExpression`. + * @param ctx the parse tree + */ + exitPCall?: (ctx: PCallContext) => void; + /** + * Enter a parse tree produced by the `PAnonymousCall` + * labeled alternative in `CircomParser.primaryExpression`. + * @param ctx the parse tree + */ + enterPAnonymousCall?: (ctx: PAnonymousCallContext) => void; + /** + * Exit a parse tree produced by the `PAnonymousCall` + * labeled alternative in `CircomParser.primaryExpression`. + * @param ctx the parse tree + */ + exitPAnonymousCall?: (ctx: PAnonymousCallContext) => void; + /** + * Enter a parse tree produced by the `AssignExprConstraint` + * labeled alternative in `CircomParser.assignmentExpression`. + * @param ctx the parse tree + */ + enterAssignExprConstraint?: (ctx: AssignExprConstraintContext) => void; + /** + * Exit a parse tree produced by the `AssignExprConstraint` + * labeled alternative in `CircomParser.assignmentExpression`. + * @param ctx the parse tree + */ + exitAssignExprConstraint?: (ctx: AssignExprConstraintContext) => void; + /** + * Enter a parse tree produced by the `AssignExprSimple` + * labeled alternative in `CircomParser.assignmentExpression`. + * @param ctx the parse tree + */ + enterAssignExprSimple?: (ctx: AssignExprSimpleContext) => void; + /** + * Exit a parse tree produced by the `AssignExprSimple` + * labeled alternative in `CircomParser.assignmentExpression`. + * @param ctx the parse tree + */ + exitAssignExprSimple?: (ctx: AssignExprSimpleContext) => void; + /** + * Enter a parse tree produced by the `AssignExprRegular` + * labeled alternative in `CircomParser.assignmentExpression`. + * @param ctx the parse tree + */ + enterAssignExprRegular?: (ctx: AssignExprRegularContext) => void; + /** + * Exit a parse tree produced by the `AssignExprRegular` + * labeled alternative in `CircomParser.assignmentExpression`. + * @param ctx the parse tree + */ + exitAssignExprRegular?: (ctx: AssignExprRegularContext) => void; + /** + * Enter a parse tree produced by `CircomParser.varIdentifier`. + * @param ctx the parse tree + */ + enterVarIdentifier?: (ctx: VarIdentifierContext) => void; + /** + * Exit a parse tree produced by `CircomParser.varIdentifier`. + * @param ctx the parse tree + */ + exitVarIdentifier?: (ctx: VarIdentifierContext) => void; + /** + * Enter a parse tree produced by `CircomParser.varIdentifierList`. + * @param ctx the parse tree + */ + enterVarIdentifierList?: (ctx: VarIdentifierListContext) => void; + /** + * Exit a parse tree produced by `CircomParser.varIdentifierList`. + * @param ctx the parse tree + */ + exitVarIdentifierList?: (ctx: VarIdentifierListContext) => void; + /** + * Enter a parse tree produced by `CircomParser.signalIdentifier`. + * @param ctx the parse tree + */ + enterSignalIdentifier?: (ctx: SignalIdentifierContext) => void; + /** + * Exit a parse tree produced by `CircomParser.signalIdentifier`. + * @param ctx the parse tree + */ + exitSignalIdentifier?: (ctx: SignalIdentifierContext) => void; + /** + * Enter a parse tree produced by `CircomParser.signalIdentifierList`. + * @param ctx the parse tree + */ + enterSignalIdentifierList?: (ctx: SignalIdentifierListContext) => void; + /** + * Exit a parse tree produced by `CircomParser.signalIdentifierList`. + * @param ctx the parse tree + */ + exitSignalIdentifierList?: (ctx: SignalIdentifierListContext) => void; + /** + * Enter a parse tree produced by `CircomParser.identifierStatement`. + * @param ctx the parse tree + */ + enterIdentifierStatement?: (ctx: IdentifierStatementContext) => void; + /** + * Exit a parse tree produced by `CircomParser.identifierStatement`. + * @param ctx the parse tree + */ + exitIdentifierStatement?: (ctx: IdentifierStatementContext) => void; /** * Enter a parse tree produced by `CircomParser.identifier`. * @param ctx the parse tree @@ -571,6 +776,36 @@ export default class CircomParserListener extends ParseTreeListener { * @param ctx the parse tree */ exitIdentifier?: (ctx: IdentifierContext) => void; + /** + * Enter a parse tree produced by `CircomParser.identifierList`. + * @param ctx the parse tree + */ + enterIdentifierList?: (ctx: IdentifierListContext) => void; + /** + * Exit a parse tree produced by `CircomParser.identifierList`. + * @param ctx the parse tree + */ + exitIdentifierList?: (ctx: IdentifierListContext) => void; + /** + * Enter a parse tree produced by `CircomParser.simpleIdentifierList`. + * @param ctx the parse tree + */ + enterSimpleIdentifierList?: (ctx: SimpleIdentifierListContext) => void; + /** + * Exit a parse tree produced by `CircomParser.simpleIdentifierList`. + * @param ctx the parse tree + */ + exitSimpleIdentifierList?: (ctx: SimpleIdentifierListContext) => void; + /** + * Enter a parse tree produced by `CircomParser.idetifierAccess`. + * @param ctx the parse tree + */ + enterIdetifierAccess?: (ctx: IdetifierAccessContext) => void; + /** + * Exit a parse tree produced by `CircomParser.idetifierAccess`. + * @param ctx the parse tree + */ + exitIdetifierAccess?: (ctx: IdetifierAccessContext) => void; /** * Enter a parse tree produced by `CircomParser.arrayDimension`. * @param ctx the parse tree @@ -582,33 +817,33 @@ export default class CircomParserListener extends ParseTreeListener { */ exitArrayDimension?: (ctx: ArrayDimensionContext) => void; /** - * Enter a parse tree produced by `CircomParser.args`. + * Enter a parse tree produced by `CircomParser.identifierReferance`. * @param ctx the parse tree */ - enterArgs?: (ctx: ArgsContext) => void; + enterIdentifierReferance?: (ctx: IdentifierReferanceContext) => void; /** - * Exit a parse tree produced by `CircomParser.args`. + * Exit a parse tree produced by `CircomParser.identifierReferance`. * @param ctx the parse tree */ - exitArgs?: (ctx: ArgsContext) => void; + exitIdentifierReferance?: (ctx: IdentifierReferanceContext) => void; /** - * Enter a parse tree produced by `CircomParser.argsWithUnderscore`. + * Enter a parse tree produced by `CircomParser.expressionOrString`. * @param ctx the parse tree */ - enterArgsWithUnderscore?: (ctx: ArgsWithUnderscoreContext) => void; + enterExpressionOrString?: (ctx: ExpressionOrStringContext) => void; /** - * Exit a parse tree produced by `CircomParser.argsWithUnderscore`. + * Exit a parse tree produced by `CircomParser.expressionOrString`. * @param ctx the parse tree */ - exitArgsWithUnderscore?: (ctx: ArgsWithUnderscoreContext) => void; + exitExpressionOrString?: (ctx: ExpressionOrStringContext) => void; /** - * Enter a parse tree produced by `CircomParser.numSequence`. + * Enter a parse tree produced by `CircomParser.expressionOrStringList`. * @param ctx the parse tree */ - enterNumSequence?: (ctx: NumSequenceContext) => void; + enterExpressionOrStringList?: (ctx: ExpressionOrStringListContext) => void; /** - * Exit a parse tree produced by `CircomParser.numSequence`. + * Exit a parse tree produced by `CircomParser.expressionOrStringList`. * @param ctx the parse tree */ - exitNumSequence?: (ctx: NumSequenceContext) => void; + exitExpressionOrStringList?: (ctx: ExpressionOrStringListContext) => void; } diff --git a/src/generated/CircomParserVisitor.ts b/src/generated/CircomParserVisitor.ts index 6e3318f..8da901d 100644 --- a/src/generated/CircomParserVisitor.ts +++ b/src/generated/CircomParserVisitor.ts @@ -3,56 +3,73 @@ import { ParseTreeVisitor } from "antlr4"; import { CircuitContext } from "./CircomParser"; -import { PragmaDeclarationContext } from "./CircomParser"; -import { IncludeDeclarationContext } from "./CircomParser"; -import { BlockDeclarationContext } from "./CircomParser"; -import { FunctionDeclarationContext } from "./CircomParser"; -import { FunctionBlockContext } from "./CircomParser"; -import { FuncBlockContext } from "./CircomParser"; -import { FuncSelfOpContext } from "./CircomParser"; -import { FuncVarDeclarationContext } from "./CircomParser"; -import { FuncAssignmentExpressionContext } from "./CircomParser"; -import { FuncVariadicAssignmentContext } from "./CircomParser"; -import { IfFuncStmtContext } from "./CircomParser"; -import { WhileFuncStmtContext } from "./CircomParser"; -import { ForFuncStmtContext } from "./CircomParser"; -import { ReturnFuncStmtContext } from "./CircomParser"; -import { AssertFuncStmtContext } from "./CircomParser"; -import { LogFuncStmtContext } from "./CircomParser"; -import { TemplateDeclarationContext } from "./CircomParser"; -import { TemplateBlockContext } from "./CircomParser"; -import { ComponentMainDeclarationContext } from "./CircomParser"; -import { PublicInputsListContext } from "./CircomParser"; -import { TemplateStmtContext } from "./CircomParser"; -import { ElementContext } from "./CircomParser"; -import { ForControlContext } from "./CircomParser"; -import { ForInitContext } from "./CircomParser"; -import { ForUpdateContext } from "./CircomParser"; -import { ParExpressionContext } from "./CircomParser"; -import { TernaryExpressionContext } from "./CircomParser"; -import { DotExpressionContext } from "./CircomParser"; -import { PrimaryExpressionContext } from "./CircomParser"; -import { BinaryExpressionContext } from "./CircomParser"; -import { BlockInstantiationExpressionContext } from "./CircomParser"; -import { UnaryExpressionContext } from "./CircomParser"; -import { PrimaryContext } from "./CircomParser"; -import { LogStmtContext } from "./CircomParser"; -import { ComponentDefinitionContext } from "./CircomParser"; -import { ComponentDeclarationContext } from "./CircomParser"; -import { SignalDefinitionContext } from "./CircomParser"; -import { TagListContext } from "./CircomParser"; -import { SignalDeclarationContext } from "./CircomParser"; -import { VarDefinitionContext } from "./CircomParser"; +import { SignalHeaderContext } from "./CircomParser"; +import { BusHeaderContext } from "./CircomParser"; +import { PragmaVersionContext } from "./CircomParser"; +import { PragmaInvalidVersionContext } from "./CircomParser"; +import { PragmaCustomTemplatesContext } from "./CircomParser"; +import { IncludeDefinitionContext } from "./CircomParser"; +import { BlockDefinitonContext } from "./CircomParser"; +import { FunctionDefinitionContext } from "./CircomParser"; +import { TemplateDefinitionContext } from "./CircomParser"; +import { BusDefinitionContext } from "./CircomParser"; +import { PublicInputsDefinitionContext } from "./CircomParser"; +import { TagDefinitionContext } from "./CircomParser"; +import { LogDefinitionContext } from "./CircomParser"; +import { AssertDefinitionContext } from "./CircomParser"; +import { DeclarationsContext } from "./CircomParser"; import { VarDeclarationContext } from "./CircomParser"; -import { RhsValueContext } from "./CircomParser"; -import { ComponentCallContext } from "./CircomParser"; -import { BlockInstantiationContext } from "./CircomParser"; +import { SignalDeclarationContext } from "./CircomParser"; +import { ComponentDeclarationContext } from "./CircomParser"; +import { BusDeclarationContext } from "./CircomParser"; +import { ComponentMainDeclarationContext } from "./CircomParser"; +import { BodyContext } from "./CircomParser"; +import { StatementsContext } from "./CircomParser"; +import { IfWithFollowUpIfContext } from "./CircomParser"; +import { IfRegularContext } from "./CircomParser"; +import { IfRegularElseWithFollowUpIfContext } from "./CircomParser"; +import { IfRegularElseRegularContext } from "./CircomParser"; +import { RStatementBodyContext } from "./CircomParser"; +import { RStatementExpressionContext } from "./CircomParser"; +import { RStatementSucstitutionsContext } from "./CircomParser"; +import { RStatementCyclesContext } from "./CircomParser"; +import { RStatementEqConstraintContext } from "./CircomParser"; +import { RStatementReturnContext } from "./CircomParser"; +import { CycleForWithDeclarationContext } from "./CircomParser"; +import { CycleForWithoutDeclarationContext } from "./CircomParser"; +import { CycleWhileContext } from "./CircomParser"; +import { SubsLeftAssignmentContext } from "./CircomParser"; +import { SubsRightSimpleAssignmentContext } from "./CircomParser"; +import { SubsRightConstrAssignmentContext } from "./CircomParser"; +import { SubsAssignmentWithOperationContext } from "./CircomParser"; +import { SubsIcnDecOperationContext } from "./CircomParser"; +import { SubsInvalidIcnDecOperationContext } from "./CircomParser"; import { ExpressionListContext } from "./CircomParser"; +import { ExpressionListWithNamesContext } from "./CircomParser"; +import { ExpressionContext } from "./CircomParser"; +import { PIdentifierStatementContext } from "./CircomParser"; +import { PUnderscoreContext } from "./CircomParser"; +import { PNumberContext } from "./CircomParser"; +import { PParenthesesContext } from "./CircomParser"; +import { PArrayContext } from "./CircomParser"; +import { PCallContext } from "./CircomParser"; +import { PAnonymousCallContext } from "./CircomParser"; +import { AssignExprConstraintContext } from "./CircomParser"; +import { AssignExprSimpleContext } from "./CircomParser"; +import { AssignExprRegularContext } from "./CircomParser"; +import { VarIdentifierContext } from "./CircomParser"; +import { VarIdentifierListContext } from "./CircomParser"; +import { SignalIdentifierContext } from "./CircomParser"; +import { SignalIdentifierListContext } from "./CircomParser"; +import { IdentifierStatementContext } from "./CircomParser"; import { IdentifierContext } from "./CircomParser"; +import { IdentifierListContext } from "./CircomParser"; +import { SimpleIdentifierListContext } from "./CircomParser"; +import { IdetifierAccessContext } from "./CircomParser"; import { ArrayDimensionContext } from "./CircomParser"; -import { ArgsContext } from "./CircomParser"; -import { ArgsWithUnderscoreContext } from "./CircomParser"; -import { NumSequenceContext } from "./CircomParser"; +import { IdentifierReferanceContext } from "./CircomParser"; +import { ExpressionOrStringContext } from "./CircomParser"; +import { ExpressionOrStringListContext } from "./CircomParser"; /** * This interface defines a complete generic visitor for a parse tree produced @@ -71,126 +88,122 @@ export default class CircomParserVisitor< */ visitCircuit?: (ctx: CircuitContext) => Result; /** - * Visit a parse tree produced by `CircomParser.pragmaDeclaration`. + * Visit a parse tree produced by `CircomParser.signalHeader`. * @param ctx the parse tree * @return the visitor result */ - visitPragmaDeclaration?: (ctx: PragmaDeclarationContext) => Result; + visitSignalHeader?: (ctx: SignalHeaderContext) => Result; /** - * Visit a parse tree produced by `CircomParser.includeDeclaration`. + * Visit a parse tree produced by `CircomParser.busHeader`. * @param ctx the parse tree * @return the visitor result */ - visitIncludeDeclaration?: (ctx: IncludeDeclarationContext) => Result; + visitBusHeader?: (ctx: BusHeaderContext) => Result; /** - * Visit a parse tree produced by `CircomParser.blockDeclaration`. + * Visit a parse tree produced by the `PragmaVersion` + * labeled alternative in `CircomParser.pragmaDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitBlockDeclaration?: (ctx: BlockDeclarationContext) => Result; + visitPragmaVersion?: (ctx: PragmaVersionContext) => Result; /** - * Visit a parse tree produced by `CircomParser.functionDeclaration`. + * Visit a parse tree produced by the `PragmaInvalidVersion` + * labeled alternative in `CircomParser.pragmaDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitFunctionDeclaration?: (ctx: FunctionDeclarationContext) => Result; + visitPragmaInvalidVersion?: (ctx: PragmaInvalidVersionContext) => Result; /** - * Visit a parse tree produced by `CircomParser.functionBlock`. + * Visit a parse tree produced by the `PragmaCustomTemplates` + * labeled alternative in `CircomParser.pragmaDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitFunctionBlock?: (ctx: FunctionBlockContext) => Result; + visitPragmaCustomTemplates?: (ctx: PragmaCustomTemplatesContext) => Result; /** - * Visit a parse tree produced by the `FuncBlock` - * labeled alternative in `CircomParser.functionStmt`. + * Visit a parse tree produced by `CircomParser.includeDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitFuncBlock?: (ctx: FuncBlockContext) => Result; + visitIncludeDefinition?: (ctx: IncludeDefinitionContext) => Result; /** - * Visit a parse tree produced by the `FuncSelfOp` - * labeled alternative in `CircomParser.functionStmt`. + * Visit a parse tree produced by `CircomParser.blockDefiniton`. * @param ctx the parse tree * @return the visitor result */ - visitFuncSelfOp?: (ctx: FuncSelfOpContext) => Result; + visitBlockDefiniton?: (ctx: BlockDefinitonContext) => Result; /** - * Visit a parse tree produced by the `FuncVarDeclaration` - * labeled alternative in `CircomParser.functionStmt`. + * Visit a parse tree produced by `CircomParser.functionDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitFuncVarDeclaration?: (ctx: FuncVarDeclarationContext) => Result; + visitFunctionDefinition?: (ctx: FunctionDefinitionContext) => Result; /** - * Visit a parse tree produced by the `FuncAssignmentExpression` - * labeled alternative in `CircomParser.functionStmt`. + * Visit a parse tree produced by `CircomParser.templateDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitFuncAssignmentExpression?: ( - ctx: FuncAssignmentExpressionContext, - ) => Result; + visitTemplateDefinition?: (ctx: TemplateDefinitionContext) => Result; /** - * Visit a parse tree produced by the `FuncVariadicAssignment` - * labeled alternative in `CircomParser.functionStmt`. + * Visit a parse tree produced by `CircomParser.busDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitFuncVariadicAssignment?: (ctx: FuncVariadicAssignmentContext) => Result; + visitBusDefinition?: (ctx: BusDefinitionContext) => Result; /** - * Visit a parse tree produced by the `IfFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Visit a parse tree produced by `CircomParser.publicInputsDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitIfFuncStmt?: (ctx: IfFuncStmtContext) => Result; + visitPublicInputsDefinition?: (ctx: PublicInputsDefinitionContext) => Result; /** - * Visit a parse tree produced by the `WhileFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Visit a parse tree produced by `CircomParser.tagDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitWhileFuncStmt?: (ctx: WhileFuncStmtContext) => Result; + visitTagDefinition?: (ctx: TagDefinitionContext) => Result; /** - * Visit a parse tree produced by the `ForFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Visit a parse tree produced by `CircomParser.logDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitForFuncStmt?: (ctx: ForFuncStmtContext) => Result; + visitLogDefinition?: (ctx: LogDefinitionContext) => Result; /** - * Visit a parse tree produced by the `ReturnFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Visit a parse tree produced by `CircomParser.assertDefinition`. * @param ctx the parse tree * @return the visitor result */ - visitReturnFuncStmt?: (ctx: ReturnFuncStmtContext) => Result; + visitAssertDefinition?: (ctx: AssertDefinitionContext) => Result; /** - * Visit a parse tree produced by the `AssertFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Visit a parse tree produced by `CircomParser.declarations`. * @param ctx the parse tree * @return the visitor result */ - visitAssertFuncStmt?: (ctx: AssertFuncStmtContext) => Result; + visitDeclarations?: (ctx: DeclarationsContext) => Result; /** - * Visit a parse tree produced by the `LogFuncStmt` - * labeled alternative in `CircomParser.functionStmt`. + * Visit a parse tree produced by `CircomParser.varDeclaration`. * @param ctx the parse tree * @return the visitor result */ - visitLogFuncStmt?: (ctx: LogFuncStmtContext) => Result; + visitVarDeclaration?: (ctx: VarDeclarationContext) => Result; /** - * Visit a parse tree produced by `CircomParser.templateDeclaration`. + * Visit a parse tree produced by `CircomParser.signalDeclaration`. * @param ctx the parse tree * @return the visitor result */ - visitTemplateDeclaration?: (ctx: TemplateDeclarationContext) => Result; + visitSignalDeclaration?: (ctx: SignalDeclarationContext) => Result; /** - * Visit a parse tree produced by `CircomParser.templateBlock`. + * Visit a parse tree produced by `CircomParser.componentDeclaration`. * @param ctx the parse tree * @return the visitor result */ - visitTemplateBlock?: (ctx: TemplateBlockContext) => Result; + visitComponentDeclaration?: (ctx: ComponentDeclarationContext) => Result; + /** + * Visit a parse tree produced by `CircomParser.busDeclaration`. + * @param ctx the parse tree + * @return the visitor result + */ + visitBusDeclaration?: (ctx: BusDeclarationContext) => Result; /** * Visit a parse tree produced by `CircomParser.componentMainDeclaration`. * @param ctx the parse tree @@ -200,175 +213,310 @@ export default class CircomParserVisitor< ctx: ComponentMainDeclarationContext, ) => Result; /** - * Visit a parse tree produced by `CircomParser.publicInputsList`. + * Visit a parse tree produced by `CircomParser.body`. + * @param ctx the parse tree + * @return the visitor result + */ + visitBody?: (ctx: BodyContext) => Result; + /** + * Visit a parse tree produced by `CircomParser.statements`. + * @param ctx the parse tree + * @return the visitor result + */ + visitStatements?: (ctx: StatementsContext) => Result; + /** + * Visit a parse tree produced by the `IfWithFollowUpIf` + * labeled alternative in `CircomParser.ifStatements`. * @param ctx the parse tree * @return the visitor result */ - visitPublicInputsList?: (ctx: PublicInputsListContext) => Result; + visitIfWithFollowUpIf?: (ctx: IfWithFollowUpIfContext) => Result; /** - * Visit a parse tree produced by `CircomParser.templateStmt`. + * Visit a parse tree produced by the `IfRegular` + * labeled alternative in `CircomParser.ifStatements`. * @param ctx the parse tree * @return the visitor result */ - visitTemplateStmt?: (ctx: TemplateStmtContext) => Result; + visitIfRegular?: (ctx: IfRegularContext) => Result; /** - * Visit a parse tree produced by `CircomParser.element`. + * Visit a parse tree produced by the `IfRegularElseWithFollowUpIf` + * labeled alternative in `CircomParser.ifStatements`. * @param ctx the parse tree * @return the visitor result */ - visitElement?: (ctx: ElementContext) => Result; + visitIfRegularElseWithFollowUpIf?: ( + ctx: IfRegularElseWithFollowUpIfContext, + ) => Result; /** - * Visit a parse tree produced by `CircomParser.forControl`. + * Visit a parse tree produced by the `IfRegularElseRegular` + * labeled alternative in `CircomParser.ifStatements`. * @param ctx the parse tree * @return the visitor result */ - visitForControl?: (ctx: ForControlContext) => Result; + visitIfRegularElseRegular?: (ctx: IfRegularElseRegularContext) => Result; /** - * Visit a parse tree produced by `CircomParser.forInit`. + * Visit a parse tree produced by the `RStatementBody` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree * @return the visitor result */ - visitForInit?: (ctx: ForInitContext) => Result; + visitRStatementBody?: (ctx: RStatementBodyContext) => Result; /** - * Visit a parse tree produced by `CircomParser.forUpdate`. + * Visit a parse tree produced by the `RStatementExpression` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree * @return the visitor result */ - visitForUpdate?: (ctx: ForUpdateContext) => Result; + visitRStatementExpression?: (ctx: RStatementExpressionContext) => Result; /** - * Visit a parse tree produced by `CircomParser.parExpression`. + * Visit a parse tree produced by the `RStatementSucstitutions` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree * @return the visitor result */ - visitParExpression?: (ctx: ParExpressionContext) => Result; + visitRStatementSucstitutions?: ( + ctx: RStatementSucstitutionsContext, + ) => Result; /** - * Visit a parse tree produced by the `TernaryExpression` - * labeled alternative in `CircomParser.expression`. + * Visit a parse tree produced by the `RStatementCycles` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree * @return the visitor result */ - visitTernaryExpression?: (ctx: TernaryExpressionContext) => Result; + visitRStatementCycles?: (ctx: RStatementCyclesContext) => Result; /** - * Visit a parse tree produced by the `DotExpression` - * labeled alternative in `CircomParser.expression`. + * Visit a parse tree produced by the `RStatementEqConstraint` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree * @return the visitor result */ - visitDotExpression?: (ctx: DotExpressionContext) => Result; + visitRStatementEqConstraint?: (ctx: RStatementEqConstraintContext) => Result; /** - * Visit a parse tree produced by the `PrimaryExpression` - * labeled alternative in `CircomParser.expression`. + * Visit a parse tree produced by the `RStatementReturn` + * labeled alternative in `CircomParser.regularStatements`. * @param ctx the parse tree * @return the visitor result */ - visitPrimaryExpression?: (ctx: PrimaryExpressionContext) => Result; + visitRStatementReturn?: (ctx: RStatementReturnContext) => Result; /** - * Visit a parse tree produced by the `BinaryExpression` - * labeled alternative in `CircomParser.expression`. + * Visit a parse tree produced by the `CycleForWithDeclaration` + * labeled alternative in `CircomParser.cycleStatements`. * @param ctx the parse tree * @return the visitor result */ - visitBinaryExpression?: (ctx: BinaryExpressionContext) => Result; + visitCycleForWithDeclaration?: ( + ctx: CycleForWithDeclarationContext, + ) => Result; /** - * Visit a parse tree produced by the `BlockInstantiationExpression` - * labeled alternative in `CircomParser.expression`. + * Visit a parse tree produced by the `CycleForWithoutDeclaration` + * labeled alternative in `CircomParser.cycleStatements`. * @param ctx the parse tree * @return the visitor result */ - visitBlockInstantiationExpression?: ( - ctx: BlockInstantiationExpressionContext, + visitCycleForWithoutDeclaration?: ( + ctx: CycleForWithoutDeclarationContext, ) => Result; /** - * Visit a parse tree produced by the `UnaryExpression` - * labeled alternative in `CircomParser.expression`. + * Visit a parse tree produced by the `CycleWhile` + * labeled alternative in `CircomParser.cycleStatements`. * @param ctx the parse tree * @return the visitor result */ - visitUnaryExpression?: (ctx: UnaryExpressionContext) => Result; + visitCycleWhile?: (ctx: CycleWhileContext) => Result; /** - * Visit a parse tree produced by `CircomParser.primary`. + * Visit a parse tree produced by the `SubsLeftAssignment` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree * @return the visitor result */ - visitPrimary?: (ctx: PrimaryContext) => Result; + visitSubsLeftAssignment?: (ctx: SubsLeftAssignmentContext) => Result; /** - * Visit a parse tree produced by `CircomParser.logStmt`. + * Visit a parse tree produced by the `SubsRightSimpleAssignment` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree * @return the visitor result */ - visitLogStmt?: (ctx: LogStmtContext) => Result; + visitSubsRightSimpleAssignment?: ( + ctx: SubsRightSimpleAssignmentContext, + ) => Result; /** - * Visit a parse tree produced by `CircomParser.componentDefinition`. + * Visit a parse tree produced by the `SubsRightConstrAssignment` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree * @return the visitor result */ - visitComponentDefinition?: (ctx: ComponentDefinitionContext) => Result; + visitSubsRightConstrAssignment?: ( + ctx: SubsRightConstrAssignmentContext, + ) => Result; /** - * Visit a parse tree produced by `CircomParser.componentDeclaration`. + * Visit a parse tree produced by the `SubsAssignmentWithOperation` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree * @return the visitor result */ - visitComponentDeclaration?: (ctx: ComponentDeclarationContext) => Result; + visitSubsAssignmentWithOperation?: ( + ctx: SubsAssignmentWithOperationContext, + ) => Result; /** - * Visit a parse tree produced by `CircomParser.signalDefinition`. + * Visit a parse tree produced by the `SubsIcnDecOperation` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree * @return the visitor result */ - visitSignalDefinition?: (ctx: SignalDefinitionContext) => Result; + visitSubsIcnDecOperation?: (ctx: SubsIcnDecOperationContext) => Result; /** - * Visit a parse tree produced by `CircomParser.tagList`. + * Visit a parse tree produced by the `SubsInvalidIcnDecOperation` + * labeled alternative in `CircomParser.substitutions`. * @param ctx the parse tree * @return the visitor result */ - visitTagList?: (ctx: TagListContext) => Result; + visitSubsInvalidIcnDecOperation?: ( + ctx: SubsInvalidIcnDecOperationContext, + ) => Result; /** - * Visit a parse tree produced by `CircomParser.signalDeclaration`. + * Visit a parse tree produced by `CircomParser.expressionList`. * @param ctx the parse tree * @return the visitor result */ - visitSignalDeclaration?: (ctx: SignalDeclarationContext) => Result; + visitExpressionList?: (ctx: ExpressionListContext) => Result; /** - * Visit a parse tree produced by `CircomParser.varDefinition`. + * Visit a parse tree produced by `CircomParser.expressionListWithNames`. * @param ctx the parse tree * @return the visitor result */ - visitVarDefinition?: (ctx: VarDefinitionContext) => Result; + visitExpressionListWithNames?: ( + ctx: ExpressionListWithNamesContext, + ) => Result; /** - * Visit a parse tree produced by `CircomParser.varDeclaration`. + * Visit a parse tree produced by `CircomParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitVarDeclaration?: (ctx: VarDeclarationContext) => Result; + visitExpression?: (ctx: ExpressionContext) => Result; /** - * Visit a parse tree produced by `CircomParser.rhsValue`. + * Visit a parse tree produced by the `PIdentifierStatement` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree * @return the visitor result */ - visitRhsValue?: (ctx: RhsValueContext) => Result; + visitPIdentifierStatement?: (ctx: PIdentifierStatementContext) => Result; /** - * Visit a parse tree produced by `CircomParser.componentCall`. + * Visit a parse tree produced by the `PUnderscore` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree * @return the visitor result */ - visitComponentCall?: (ctx: ComponentCallContext) => Result; + visitPUnderscore?: (ctx: PUnderscoreContext) => Result; /** - * Visit a parse tree produced by `CircomParser.blockInstantiation`. + * Visit a parse tree produced by the `PNumber` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree * @return the visitor result */ - visitBlockInstantiation?: (ctx: BlockInstantiationContext) => Result; + visitPNumber?: (ctx: PNumberContext) => Result; /** - * Visit a parse tree produced by `CircomParser.expressionList`. + * Visit a parse tree produced by the `PParentheses` + * labeled alternative in `CircomParser.primaryExpression`. * @param ctx the parse tree * @return the visitor result */ - visitExpressionList?: (ctx: ExpressionListContext) => Result; + visitPParentheses?: (ctx: PParenthesesContext) => Result; + /** + * Visit a parse tree produced by the `PArray` + * labeled alternative in `CircomParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitPArray?: (ctx: PArrayContext) => Result; + /** + * Visit a parse tree produced by the `PCall` + * labeled alternative in `CircomParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitPCall?: (ctx: PCallContext) => Result; + /** + * Visit a parse tree produced by the `PAnonymousCall` + * labeled alternative in `CircomParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitPAnonymousCall?: (ctx: PAnonymousCallContext) => Result; + /** + * Visit a parse tree produced by the `AssignExprConstraint` + * labeled alternative in `CircomParser.assignmentExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitAssignExprConstraint?: (ctx: AssignExprConstraintContext) => Result; + /** + * Visit a parse tree produced by the `AssignExprSimple` + * labeled alternative in `CircomParser.assignmentExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitAssignExprSimple?: (ctx: AssignExprSimpleContext) => Result; + /** + * Visit a parse tree produced by the `AssignExprRegular` + * labeled alternative in `CircomParser.assignmentExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitAssignExprRegular?: (ctx: AssignExprRegularContext) => Result; + /** + * Visit a parse tree produced by `CircomParser.varIdentifier`. + * @param ctx the parse tree + * @return the visitor result + */ + visitVarIdentifier?: (ctx: VarIdentifierContext) => Result; + /** + * Visit a parse tree produced by `CircomParser.varIdentifierList`. + * @param ctx the parse tree + * @return the visitor result + */ + visitVarIdentifierList?: (ctx: VarIdentifierListContext) => Result; + /** + * Visit a parse tree produced by `CircomParser.signalIdentifier`. + * @param ctx the parse tree + * @return the visitor result + */ + visitSignalIdentifier?: (ctx: SignalIdentifierContext) => Result; + /** + * Visit a parse tree produced by `CircomParser.signalIdentifierList`. + * @param ctx the parse tree + * @return the visitor result + */ + visitSignalIdentifierList?: (ctx: SignalIdentifierListContext) => Result; + /** + * Visit a parse tree produced by `CircomParser.identifierStatement`. + * @param ctx the parse tree + * @return the visitor result + */ + visitIdentifierStatement?: (ctx: IdentifierStatementContext) => Result; /** * Visit a parse tree produced by `CircomParser.identifier`. * @param ctx the parse tree * @return the visitor result */ visitIdentifier?: (ctx: IdentifierContext) => Result; + /** + * Visit a parse tree produced by `CircomParser.identifierList`. + * @param ctx the parse tree + * @return the visitor result + */ + visitIdentifierList?: (ctx: IdentifierListContext) => Result; + /** + * Visit a parse tree produced by `CircomParser.simpleIdentifierList`. + * @param ctx the parse tree + * @return the visitor result + */ + visitSimpleIdentifierList?: (ctx: SimpleIdentifierListContext) => Result; + /** + * Visit a parse tree produced by `CircomParser.idetifierAccess`. + * @param ctx the parse tree + * @return the visitor result + */ + visitIdetifierAccess?: (ctx: IdetifierAccessContext) => Result; /** * Visit a parse tree produced by `CircomParser.arrayDimension`. * @param ctx the parse tree @@ -376,21 +524,21 @@ export default class CircomParserVisitor< */ visitArrayDimension?: (ctx: ArrayDimensionContext) => Result; /** - * Visit a parse tree produced by `CircomParser.args`. + * Visit a parse tree produced by `CircomParser.identifierReferance`. * @param ctx the parse tree * @return the visitor result */ - visitArgs?: (ctx: ArgsContext) => Result; + visitIdentifierReferance?: (ctx: IdentifierReferanceContext) => Result; /** - * Visit a parse tree produced by `CircomParser.argsWithUnderscore`. + * Visit a parse tree produced by `CircomParser.expressionOrString`. * @param ctx the parse tree * @return the visitor result */ - visitArgsWithUnderscore?: (ctx: ArgsWithUnderscoreContext) => Result; + visitExpressionOrString?: (ctx: ExpressionOrStringContext) => Result; /** - * Visit a parse tree produced by `CircomParser.numSequence`. + * Visit a parse tree produced by `CircomParser.expressionOrStringList`. * @param ctx the parse tree * @return the visitor result */ - visitNumSequence?: (ctx: NumSequenceContext) => Result; + visitExpressionOrStringList?: (ctx: ExpressionOrStringListContext) => Result; } diff --git a/src/index.ts b/src/index.ts index b8ed946..aecc424 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,20 +12,15 @@ export function getCircomParser(source: string): ExtendedCircomParser { const lexer = new CircomLexer(inputStream); const tokens = new antlr4.CommonTokenStream(lexer); - const parser = new ExtendedCircomParser(tokens); - parser.setLexer(lexer); - parser.initErrorListeners(); - - parser.buildParseTrees = true; - - return parser; + return new ExtendedCircomParser(tokens, lexer); } export * from "./types"; -export * from "./builtin"; +export * from "./utils"; export * from "./generated"; export { ExtendedCircomParser } from "./ExtendedCircomParser"; +export { ExtendedCircomVisitor } from "./ExtendedCircomVisitor"; export { ParserError } from "./errors/ParserError"; diff --git a/src/types.ts b/src/types.ts index 4ca1e57..28835ec 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1 +1,2 @@ +export type * from "antlr4"; export * from "./types/index"; diff --git a/src/types/builtin.ts b/src/types/builtin.ts deleted file mode 100644 index 4af5580..0000000 --- a/src/types/builtin.ts +++ /dev/null @@ -1,25 +0,0 @@ -export type Template = { - inputs: { name: string; dimension: string[]; type: string }[]; - parameters: string[]; - isCustom: boolean; -}; - -export type Templates = { - [key: string]: Template; -}; - -export type BigIntOrNestedArray = bigint | BigIntOrNestedArray[]; - -export type Variables = { - [key: string]: { - value: BigIntOrNestedArray; - }; -}; - -export type MainComponent = { - templateName: string | null; - publicInputs: string[]; - parameters: BigIntOrNestedArray[]; -}; - -export type PragmaComponent = { isCustom: boolean; compilerVersion: string }; diff --git a/src/types/common.ts b/src/types/common.ts new file mode 100644 index 0000000..b8cdd85 --- /dev/null +++ b/src/types/common.ts @@ -0,0 +1,3 @@ +export type CircomValueType = bigint | CircomValueType[]; + +export type VariableContext = Record; diff --git a/src/types/errors.ts b/src/types/errors.ts index b10f65e..d4ad109 100644 --- a/src/types/errors.ts +++ b/src/types/errors.ts @@ -1,5 +1,9 @@ +import { ParserRuleContext } from "antlr4"; + export type ParserErrorItem = { + templateName: string | null; message: string; line: number; column: number; + context: ParserRuleContext; }; diff --git a/src/types/index.ts b/src/types/index.ts index eb732c9..6f73f49 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,3 +1,2 @@ -export * from "./parser"; export * from "./errors"; -export * from "./builtin"; +export * from "./common"; diff --git a/src/types/parser.ts b/src/types/parser.ts deleted file mode 100644 index d6b624e..0000000 --- a/src/types/parser.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type LocationCtx = { - line: number; - column: number; -}; diff --git a/src/utils/ExpressionHelper.ts b/src/utils/ExpressionHelper.ts new file mode 100644 index 0000000..a959dcd --- /dev/null +++ b/src/utils/ExpressionHelper.ts @@ -0,0 +1,298 @@ +import { + CircomParser, + ExpressionContext, + PAnonymousCallContext, + PArrayContext, + PCallContext, + PIdentifierStatementContext, + PNumberContext, + PParenthesesContext, + PUnderscoreContext, +} from "../generated"; + +import { CircomValueType, ParserErrorItem, VariableContext } from "../types"; + +import { ExtendedCircomVisitor } from "../ExtendedCircomVisitor"; + +export class ExpressionHelper { + private _expressionContext: ExpressionContext | null = null; + private _variableContext: VariableContext = {}; + + constructor(public templateIdentifier: string) {} + + public setExpressionContext( + expressionContext: ExpressionContext, + ): ExpressionHelper { + this._expressionContext = expressionContext; + + return this; + } + + public setVariableContext( + variableContext: VariableContext, + ): ExpressionHelper { + this._variableContext = variableContext; + + return this; + } + + public addVariablesToTheContext( + variables: VariableContext, + ): ExpressionHelper { + for (const key in variables) { + this._variableContext[key] = variables[key]; + } + + return this; + } + + /** + * This function can throw an error if the expression context is not set. + * All other errors related to the parsing of the expression can be retrieved by the function `getErrors()` + * inside the `ExtendedCircomVisitor` class. + */ + public parseExpression(): [CircomValueType | null, ParserErrorItem[]] { + if (!this._expressionContext) { + throw new Error("Expression context is not set"); + } + + const visitor = new ExpressionVisitor( + this.templateIdentifier, + this._variableContext, + ); + + const result = visitor.visitExpression(this._expressionContext); + + if (result === null) { + return [null, visitor.getErrors()]; + } + + return [result, visitor.getErrors()]; + } +} + +class ExpressionVisitor extends ExtendedCircomVisitor { + constructor( + templateIdentifier: string, + public variableContext: VariableContext, + ) { + super(templateIdentifier); + } + + visitExpression = (ctx: ExpressionContext): CircomValueType | null => { + if (ctx.PARALLEL()) { + return this.visit(ctx.expression(0)); + } + + if (ctx.primaryExpression()) { + return this.visit(ctx.primaryExpression()); + } + + if (ctx.TERNARY_CONDITION() && ctx.TERNARY_ALTERNATIVE()) { + const conditionResult = this.visit(ctx._cond); + + if (conditionResult === null) { + this.addError( + "Failed to resolve the condition of a ternary expression", + ctx._cond, + ); + return null; + } + + if (Array.isArray(conditionResult)) { + this.addError( + "Ternary expression condition cannot be an array", + ctx._cond, + ); + return null; + } + + if (conditionResult === 1n) { + return this.visit(ctx._ifTrue); + } else { + return this.visit(ctx._ifFalse); + } + } + + return this._parseOperation(ctx); + }; + + visitPIdentifierStatement = ( + ctx: PIdentifierStatementContext, + ): CircomValueType | null => { + if (ctx.identifierStatement().idetifierAccess_list().length == 0) { + const variableName = + this.variableContext[ctx.identifierStatement().ID().getText()]; + + if (variableName === undefined) { + this.addError( + `Variable ${ctx.identifierStatement().ID().getText()} is not defined`, + ctx.identifierStatement(), + ); + + return null; + } + + return variableName; + } + + this.addError( + "IdentifierStatement is not supported with access references", + ctx, + ); + return null; + }; + + visitPUnderscore = (_ctx: PUnderscoreContext): CircomValueType | null => { + return null; + }; + + visitPNumber = (ctx: PNumberContext): CircomValueType | null => { + return BigInt(ctx.NUMBER().getText()); + }; + + visitPParentheses = (ctx: PParenthesesContext): CircomValueType | null => { + this.addError("Parentheses are not supported", ctx); + return null; + }; + + visitPArray = (ctx: PArrayContext): CircomValueType | null => { + let arrayItems: CircomValueType | null = []; + + for (let i = 0; i < ctx.expressionList().expression_list().length; i++) { + const resolvedItem = this.visit(ctx.expressionList().expression(i)); + + if (!resolvedItem) { + this.addError( + `Failed to resolve the ${i} element of an array.`, + ctx.expressionList().expression(i), + ); + + arrayItems = null; + + continue; + } + + if (arrayItems) { + arrayItems.push(resolvedItem); + } + } + + return arrayItems; + }; + + visitPCall = (ctx: PCallContext): CircomValueType | null => { + this.addError("Calls are not supported", ctx); + return null; + }; + + visitPAnonymousCall = ( + ctx: PAnonymousCallContext, + ): CircomValueType | null => { + this.addError("Anonymous calls are not supported", ctx); + return null; + }; + + private _parseOperation(ctx: ExpressionContext): CircomValueType | null { + const operationType = ctx._op.type; + + const firstExpression = this.visit(ctx.expression(0)); + + if (firstExpression === null) { + this.addError( + "Failed to resolve the first expression of an operation", + ctx.expression(0), + ); + return null; + } + + if (Array.isArray(firstExpression)) { + this.addError( + "Performing operations on arrays is not allowed", + ctx.expression(0), + ); + return null; + } + + switch (operationType) { + case CircomParser.NOT: + if (firstExpression !== 0n && firstExpression !== 1n) { + this.addError( + "NOT operation can be performed only on boolean values", + ctx.expression(0), + ); + return null; + } + return firstExpression ? 0n : 1n; + case CircomParser.BNOT: + return ~firstExpression; + case CircomParser.SUB: + return -firstExpression; + } + + const secondExpression = this.visit(ctx.expression(1)); + + if (secondExpression === null) { + this.addError( + "Failed to resolve the second expression of an operation", + ctx.expression(1), + ); + return null; + } + + if (Array.isArray(secondExpression)) { + this.addError( + "Performing operations on arrays is not allowed", + ctx.expression(1), + ); + return null; + } + + switch (operationType) { + case CircomParser.POW: + return firstExpression ** secondExpression; + case CircomParser.MUL: + return firstExpression * secondExpression; + case CircomParser.DIV: + return firstExpression / secondExpression; + case CircomParser.QUO: + this.addError("QUO operation is not supported", ctx); + return null; + case CircomParser.MOD: + return firstExpression % secondExpression; + case CircomParser.ADD: + return firstExpression + secondExpression; + case CircomParser.SUB: + return firstExpression - secondExpression; + case CircomParser.SHL: + return firstExpression << secondExpression; + case CircomParser.SHR: + return firstExpression >> secondExpression; + case CircomParser.BAND: + return firstExpression & secondExpression; + case CircomParser.BXOR: + return firstExpression ^ secondExpression; + case CircomParser.BOR: + return firstExpression | secondExpression; + case CircomParser.EQ: + return firstExpression === secondExpression ? 1n : 0n; + case CircomParser.NEQ: + return firstExpression !== secondExpression ? 1n : 0n; + case CircomParser.LT: + return firstExpression < secondExpression ? 1n : 0n; + case CircomParser.GT: + return firstExpression > secondExpression ? 1n : 0n; + case CircomParser.LE: + return firstExpression <= secondExpression ? 1n : 0n; + case CircomParser.GE: + return firstExpression >= secondExpression ? 1n : 0n; + case CircomParser.AND: + return firstExpression && secondExpression ? 1n : 0n; + case CircomParser.OR: + return firstExpression || secondExpression ? 1n : 0n; + } + + this.addError("Reached unknown operation", ctx); + return null; + } +} diff --git a/src/utils/common.ts b/src/utils/common.ts new file mode 100644 index 0000000..5df7df6 --- /dev/null +++ b/src/utils/common.ts @@ -0,0 +1,17 @@ +import { SimpleIdentifierListContext } from "../generated"; + +export function parseSimpleIdentifierList( + ctx: SimpleIdentifierListContext, +): string[] { + const result: string[] = []; + + if (!ctx) { + return result; + } + + ctx.ID_list().forEach((node) => { + result.push(node.getText()); + }); + + return result; +} diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..4cfd7e7 --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,2 @@ +export * from "./common"; +export * from "./ExpressionHelper"; diff --git a/test/circom-template-inputs-visitor.test.ts b/test/circom-template-inputs-visitor.test.ts new file mode 100644 index 0000000..fe6ea86 --- /dev/null +++ b/test/circom-template-inputs-visitor.test.ts @@ -0,0 +1,120 @@ +import { expect } from "chai"; +import { getCircomParser, VariableContext } from "../src"; + +import { Templates } from "./mocks/types"; +import { CircomFilesVisitor } from "./mocks/CircomFilesVisitor"; +import { CircomTemplateInputsVisitor } from "./mocks/CircomTemplateInputsVisitor"; + +describe("Circom Template Inputs Visitor", () => { + function getData(fileName: string): Templates { + const visitor = new CircomFilesVisitor(fileName); + + const parser = getCircomParser(`test/data/${fileName}`); + + visitor.visit(parser.circuit()); + + return visitor.fileData.templates; + } + + it("should analyse the curve.circom circuit", () => { + const mainComponentData: VariableContext = { + SIGNATURE_TYPE: 2n, + DG_HASH_TYPE: 8n, + DOCUMENT_TYPE: 512n, + EC_BLOCK_NUMBER: 256n, + EC_SHIFT: 2n, + DG1_SHIFT: 0n, + AA_SIGNATURE_ALGO: 17n, + DG15_SHIFT: 64n, + DG15_BLOCK_NUMBER: 64n, + AA_SHIFT: 256n, + }; + + const data = getData("curve.circom"); + + const visitor = new CircomTemplateInputsVisitor( + "curve.circom", + data["RegisterIdentityBuilder"].context, + mainComponentData, + ); + + visitor.startParse(); + + expect(visitor.errors.length).to.equal(0); + + expect(visitor.templateInputs.encapsulatedContent.type).to.equal("input"); + expect(visitor.templateInputs.encapsulatedContent.dimension).to.deep.equal([ + 131072n, + ]); + + expect(visitor.templateInputs.dg1.type).to.equal("input"); + expect(visitor.templateInputs.dg1.dimension).to.deep.equal([1024n]); + + expect(visitor.templateInputs.dg15.type).to.equal("input"); + expect(visitor.templateInputs.dg15.dimension).to.deep.equal([32768n]); + + expect(visitor.templateInputs.signedAttributes.type).to.equal("input"); + expect(visitor.templateInputs.signedAttributes.dimension).to.deep.equal([ + 1024n, + ]); + + expect(visitor.templateInputs.signature.type).to.equal("input"); + expect(visitor.templateInputs.signature.dimension).to.deep.equal([64n]); + + expect(visitor.templateInputs.pubkey.type).to.equal("input"); + expect(visitor.templateInputs.pubkey.dimension).to.deep.equal([64n]); + + expect(visitor.templateInputs.slaveMerkleRoot.type).to.equal("input"); + expect(visitor.templateInputs.slaveMerkleRoot.dimension).to.deep.equal([]); + + expect(visitor.templateInputs.slaveMerkleInclusionBranches.type).to.equal( + "input", + ); + expect( + visitor.templateInputs.slaveMerkleInclusionBranches.dimension, + ).to.deep.equal([80n]); + + expect(visitor.templateInputs.skIdentity.type).to.equal("input"); + expect(visitor.templateInputs.skIdentity.dimension).to.deep.equal([]); + + expect(visitor.templateInputs.dg15PubKeyHash.type).to.equal("output"); + expect(visitor.templateInputs.dg15PubKeyHash.dimension).to.deep.equal([]); + + expect(visitor.templateInputs.passportHash.type).to.equal("output"); + expect(visitor.templateInputs.passportHash.dimension).to.deep.equal([]); + + expect(visitor.templateInputs.dg1Commitment.type).to.equal("output"); + expect(visitor.templateInputs.dg1Commitment.dimension).to.deep.equal([]); + + expect(visitor.templateInputs.pkIdentityHash.type).to.equal("output"); + expect(visitor.templateInputs.pkIdentityHash.dimension).to.deep.equal([]); + }); + + it("should analyse the MainComponent.circom circuit", () => { + const mainComponentData: VariableContext = { + p1: 2n, + p2: 8n, + }; + + const data = getData("MainComponent.circom"); + + const visitor = new CircomTemplateInputsVisitor( + "MainComponent.circom", + data["C"].context, + mainComponentData, + ); + + visitor.startParse(); + + expect(visitor.errors.length).to.equal(0); + + expect(visitor.templateInputs.in1.type).to.equal("input"); + expect(visitor.templateInputs.in1.dimension).to.deep.equal([]); + + expect(visitor.templateInputs.in2.type).to.equal("input"); + expect(visitor.templateInputs.in2.dimension).to.deep.equal([3n, 2n]); + + expect(visitor.templateInputs.out.type).to.equal("output"); + expect(visitor.templateInputs.out.dimension).to.deep.equal([]); + }); +}); diff --git a/test/expression-visitor.test.ts b/test/expression-visitor.test.ts deleted file mode 100644 index 099b90e..0000000 --- a/test/expression-visitor.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { expect } from "chai"; - -import { CircomSignalDeclarationVisitor } from "./mocks/CircomSignalDeclarationVisitor"; - -import { getCircomParser, Variables } from "../src"; - -describe("Circom Expression Visitor", () => { - it("should correctly evaluate ternary expressions", async () => { - const vars: Variables = { - p1: { value: 3n }, - }; - - const visitor = new CircomSignalDeclarationVisitor(vars); - - const source = ` - template C() { - signal input in1; - signal input in2[p1 % 2 == 1 ? 10 : 2*2][p1]; - } - `; - - const parser = getCircomParser(source); - - visitor.visit(parser.circuit()); - - expect(visitor.signalDeclarations).to.deep.equal([ - { name: "in1", dimensions: [] }, - { name: "in2", dimensions: [10, 3] }, - ]); - }); - - it("should correctly change vars with 'if' logic -- #1", async () => { - const vars: Variables = { - SIGNATURE_TYPE: { value: 2n }, - DG_HASH_TYPE: { value: 3n }, - DOCUMENT_TYPE: { value: 3n }, - EC_BLOCK_NUMBER: { value: 3n }, - EC_SHIFT: { value: 3n }, - DG1_SHIFT: { value: 3n }, - AA_SIGNATURE_ALGO: { value: 3n }, - DG15_SHIFT: { value: 3n }, - DG15_BLOCK_NUMBER: { value: 3n }, - AA_SHIFT: { value: 3n }, - }; - - const visitor = new CircomSignalDeclarationVisitor(vars); - const parser = getCircomParser("test/data/curve.circom"); - - visitor.visit(parser.circuit()); - - expect(visitor.vars["TREE_DEPTH"]).to.deep.equal({ value: 80n }); - expect(visitor.vars["CHUNK_SIZE"]).to.deep.equal({ value: 64n }); - expect(visitor.vars["HASH_TYPE"]).to.deep.equal({ value: 256n }); - expect(visitor.vars["CHUNK_NUMBER"]).to.deep.equal({ value: 64n }); - expect(visitor.vars["HASH_TYPE"]).to.deep.equal({ value: 256n }); - expect(visitor.vars["DG_HASH_BLOCK_SIZE"]).to.deep.equal({ value: 512n }); - expect(visitor.vars["HASH_BLOCK_SIZE"]).to.deep.equal({ value: 512n }); - expect(visitor.vars["PUBKEY_LEN"]).to.deep.equal({ - value: 64n, - }); - expect(visitor.vars["SIGNATURE_LEN"]).to.deep.equal({ - value: 64n, - }); - }); - - it("should correctly change vars with 'if' logic -- #2", async () => { - const vars: Variables = { - SIGNATURE_TYPE: { value: 8n }, - DG_HASH_TYPE: { value: 8n }, - DOCUMENT_TYPE: { value: 512n }, - EC_BLOCK_NUMBER: { value: 256n }, - EC_SHIFT: { value: 2n }, - DG1_SHIFT: { value: 0n }, - AA_SIGNATURE_ALGO: { value: 17n }, - DG15_SHIFT: { value: 64n }, - DG15_BLOCK_NUMBER: { value: 64n }, - AA_SHIFT: { value: 256n }, - }; - - const visitor = new CircomSignalDeclarationVisitor(vars); - const parser = getCircomParser("test/data/curve.circom"); - - visitor.visit(parser.circuit()); - - expect(visitor.vars["TREE_DEPTH"]).to.deep.equal({ value: 80n }); - expect(visitor.vars["CHUNK_SIZE"]).to.deep.equal({ value: 64n }); - expect(visitor.vars["HASH_TYPE"]).to.deep.equal({ value: 256n }); - expect(visitor.vars["CHUNK_NUMBER"]).to.deep.equal({ value: 32n }); - expect(visitor.vars["HASH_TYPE"]).to.deep.equal({ value: 256n }); - expect(visitor.vars["DG_HASH_BLOCK_SIZE"]).to.deep.equal({ value: 512n }); - expect(visitor.vars["HASH_BLOCK_SIZE"]).to.deep.equal({ value: 512n }); - expect(visitor.vars["PUBKEY_LEN"]).to.deep.equal({ - value: 32n, - }); - expect(visitor.vars["SIGNATURE_LEN"]).to.deep.equal({ - value: 32n, - }); - }); -}); diff --git a/test/file-visitor.test.ts b/test/file-visitor.test.ts new file mode 100644 index 0000000..19c8f14 --- /dev/null +++ b/test/file-visitor.test.ts @@ -0,0 +1,176 @@ +import { expect } from "chai"; + +import { CircomFilesVisitor } from "./mocks/CircomFilesVisitor"; +import { CircomFileData, CircuitResolutionError } from "./mocks/types"; + +import { getCircomParser } from "../src"; + +describe("Circom File Visitor", () => { + function getData( + fileName: string, + ): [CircuitResolutionError[], CircomFileData] { + const visitor = new CircomFilesVisitor(fileName); + + const parser = getCircomParser(`test/data/${fileName}`); + + visitor.visit(parser.circuit()); + + return [visitor.errors, visitor.fileData]; + } + + it("should analyse the curve.circom circuit", () => { + const [errors, fileData] = getData("curve.circom"); + + expect(errors.length).to.equal(0); + expect(fileData.pragmaInfo.isCustom).to.equal(false); + expect(fileData.pragmaInfo.compilerVersion).to.equal("2.1.6"); + expect(fileData.includes.length).to.equal(0); + expect(fileData.mainComponentInfo.templateName).to.equal(null); + expect(fileData.mainComponentInfo.publicInputs.length).to.equal(0); + expect(fileData.mainComponentInfo.parameters.length).to.equal(0); + expect(Object.keys(fileData.templates).length).to.equal(1); + + const template = fileData.templates["RegisterIdentityBuilder"]; + + expect(template.isCustom).to.equal(false); + expect(template.parallel).to.equal(false); + + expect(template.parameters).to.deep.equal([ + "SIGNATURE_TYPE", + "DG_HASH_TYPE", + "DOCUMENT_TYPE", + "EC_BLOCK_NUMBER", + "EC_SHIFT", + "DG1_SHIFT", + "AA_SIGNATURE_ALGO", + "DG15_SHIFT", + "DG15_BLOCK_NUMBER", + "AA_SHIFT", + ]); + }); + + it("should analyse Include.circom circuit", () => { + const [errors, fileData] = getData("Includes.circom"); + + expect(errors.length).to.equal(0); + expect(fileData.pragmaInfo.isCustom).to.equal(false); + expect(fileData.pragmaInfo.compilerVersion).to.equal("2.1.6"); + expect(fileData.includes.length).to.equal(5); + expect(fileData.includes).to.deep.equal([ + "../node_modules/circomlib/circuits/poseidon.circom", + "../node_modules/circomlib/circuits/comparators.circom", + "../merkleTree/merkleTree.circom", + "@circomlib/circuits/comparators.circom", + "comparators.circom", + ]); + expect(fileData.mainComponentInfo.templateName).to.equal(null); + expect(fileData.mainComponentInfo.publicInputs.length).to.equal(0); + expect(fileData.mainComponentInfo.parameters.length).to.equal(0); + expect(Object.keys(fileData.templates).length).to.equal(0); + }); + + it("should analyse the MainComponent.circom circuit", () => { + const [errors, fileData] = getData("MainComponent.circom"); + + expect(errors.length).to.equal(0); + expect(fileData.pragmaInfo.isCustom).to.equal(false); + expect(fileData.pragmaInfo.compilerVersion).to.equal("2.1.6"); + expect(fileData.includes.length).to.equal(1); + expect(fileData.includes).to.deep.equal([ + "../merkleTree/merkleTree.circom", + ]); + expect(fileData.mainComponentInfo.templateName).to.equal("C"); + expect(fileData.mainComponentInfo.publicInputs.length).to.equal(1); + expect(fileData.mainComponentInfo.publicInputs).to.deep.equal(["in1"]); + expect(fileData.mainComponentInfo.parameters.length).to.equal(2); + expect(fileData.mainComponentInfo.parameters).to.deep.equal([ + [10n, 20n], + [30n, 40n], + ]); + expect(Object.keys(fileData.templates).length).to.equal(2); + + const templateB = fileData.templates["B"]; + + expect(templateB.isCustom).to.equal(false); + expect(templateB.parallel).to.equal(false); + expect(templateB.parameters).to.deep.equal(["N"]); + + const templateC = fileData.templates["C"]; + + expect(templateC.isCustom).to.equal(false); + expect(templateC.parallel).to.equal(false); + expect(templateC.parameters).to.deep.equal(["p1", "p2"]); + }); + + it("should analyse the Templates.circom circuit", () => { + const [errors, fileData] = getData("Templates.circom"); + + expect(errors.length).to.equal(0); + expect(fileData.pragmaInfo.isCustom).to.equal(false); + expect(fileData.pragmaInfo.compilerVersion).to.equal("2.1.6"); + expect(fileData.includes.length).to.equal(3); + expect(fileData.includes).to.deep.equal([ + "../node_modules/circomlib/circuits/poseidon.circom", + "../node_modules/circomlib/circuits/comparators.circom", + "../merkleTree/merkleTree.circom", + ]); + expect(fileData.mainComponentInfo.templateName).to.equal("C"); + expect(fileData.mainComponentInfo.publicInputs.length).to.equal(1); + expect(fileData.mainComponentInfo.publicInputs).to.deep.equal(["in1"]); + expect(fileData.mainComponentInfo.parameters.length).to.equal(2); + expect(fileData.mainComponentInfo.parameters).to.deep.equal([ + [10n, 20n], + [30n, 40n], + ]); + expect(Object.keys(fileData.templates).length).to.equal(3); + + const templateA = fileData.templates["A"]; + + expect(templateA.isCustom).to.equal(false); + expect(templateA.parallel).to.equal(false); + expect(templateA.parameters).to.deep.equal(["param1", "param2"]); + + const templateB = fileData.templates["B"]; + + expect(templateB.isCustom).to.equal(true); + expect(templateB.parallel).to.equal(false); + expect(templateB.parameters).to.deep.equal(["N"]); + + const templateC = fileData.templates["C"]; + + expect(templateC.isCustom).to.equal(false); + expect(templateC.parallel).to.equal(false); + expect(templateC.parameters).to.deep.equal(["p1", "p2"]); + }); + + it("should analyse the ToughCircuit.circom circuit", () => { + const [errors, fileData] = getData("ToughCircuit.circom"); + + expect(errors.length).to.equal(0); + expect(fileData.pragmaInfo.isCustom).to.equal(false); + expect(fileData.pragmaInfo.compilerVersion).to.equal("2.0.0"); + expect(fileData.includes.length).to.equal(2); + expect(fileData.includes).to.deep.equal([ + "@circomlib/circuits/comparators.circom", + "comparators.circom", + ]); + expect(fileData.mainComponentInfo.templateName).to.equal("A"); + expect(fileData.mainComponentInfo.publicInputs.length).to.equal(1); + expect(fileData.mainComponentInfo.publicInputs).to.deep.equal(["b"]); + expect(fileData.mainComponentInfo.parameters.length).to.equal(1); + expect(fileData.mainComponentInfo.parameters).to.deep.equal([2n]); + expect(Object.keys(fileData.templates).length).to.equal(2); + + const templateB = fileData.templates["B"]; + + expect(templateB.isCustom).to.equal(false); + expect(templateB.parallel).to.equal(false); + expect(templateB.parameters).to.deep.equal(["a"]); + + const templateA = fileData.templates["A"]; + + expect(templateA.isCustom).to.equal(false); + expect(templateA.parallel).to.equal(true); + expect(templateA.parameters).to.deep.equal(["a1"]); + }); +}); diff --git a/test/include-visitor.test.ts b/test/include-visitor.test.ts deleted file mode 100644 index 4bb9fd4..0000000 --- a/test/include-visitor.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { expect } from "chai"; - -import { findIncludes } from "../src"; - -describe("Circom Include Visitor", () => { - it("should retrieve includes from the valid circom file", () => { - const expectedOutput = [ - "../node_modules/circomlib/circuits/poseidon.circom", - "../node_modules/circomlib/circuits/comparators.circom", - "../merkleTree/merkleTree.circom", - "@circomlib/circuits/comparators.circom", - "comparators.circom", - ]; - - const result = findIncludes("test/data/Includes.circom"); - - expect(result).to.deep.equal(expectedOutput); - }); - - it("should throw an error", () => { - expect(() => findIncludes("test/data/SimpleWrongCircuit.circom")).to.throw( - "mismatched input 'll' expecting ')' (12:49)", - ); - }); -}); diff --git a/test/main-component-visitor.test.ts b/test/main-component-visitor.test.ts deleted file mode 100644 index ca30f31..0000000 --- a/test/main-component-visitor.test.ts +++ /dev/null @@ -1,158 +0,0 @@ -import { expect } from "chai"; - -import { findMainComponent } from "../src"; - -describe("Circom Main Component Visitor", () => { - it("should retrieve main component declaration info from the valid circom file", () => { - const expectedOutput = { - templateName: "C", - publicInputs: ["in1"], - parameters: [ - [10n, 20n], - [30n, 40n], - ], - }; - - expect(findMainComponent("test/data/MainComponent.circom")).to.deep.equal( - expectedOutput, - ); - }); - - it("should handle simple expressions inside the main component declaration parameters", () => { - const expectedOutput = { - templateName: "A", - publicInputs: ["in"], - parameters: [27n, [70n, 34n, 1n], 1n], - }; - - expect( - findMainComponent(` - pragma circom 2.1.6; - - component main {public [in]} = A(3 ** (2 * 10 - 10 - 7), [7*10, 34, 4>>2], !(4 < 3)); - `), - ).to.deep.equal(expectedOutput); - - expect(() => - findMainComponent(` - pragma circom 2.1.6; - - component main {public [in]} = A(3, 4 / 0); - `), - ).to.throw("Division by zero is not allowed (4:40)"); - }); - - it("should handle ternary expressions inside the main component declaration parameters", () => { - const expectedOutput1 = { - templateName: "A", - publicInputs: ["in"], - parameters: [10n, 13n], - }; - - const expectedOutput2 = { - templateName: "A", - publicInputs: ["in"], - parameters: [23n], - }; - - expect( - findMainComponent(` - pragma circom 2.1.6; - - component main {public [in]} = A(10, !(10 > 20) ? 13 : 23); - `), - ).to.deep.equal(expectedOutput1); - - expect( - findMainComponent(` - pragma circom 2.1.6; - - component main {public [in]} = A((10 & 20) ? 13 : 23); - `), - ).to.deep.equal(expectedOutput2); - }); - - it("should handle no public inputs and no parameters inside the main component declaration", () => { - const expectedOutput = { - templateName: "A", - publicInputs: [], - parameters: [], - }; - - const result = findMainComponent(` - pragma circom 2.1.6; - - component main = A(); - `); - - expect(result).to.deep.equal(expectedOutput); - }); - - it("should handle no main component declaration correctly", () => { - expect(findMainComponent("test/data/Includes.circom")).to.deep.equal({ - templateName: null, - publicInputs: [], - parameters: [], - }); - }); - - it("should throw an error if more than 1 main component is declared", () => { - expect(() => - findMainComponent("test/data/WrongMainComponent.circom"), - ).throws("mismatched input 'component' expecting (22:0)"); - }); - - it("should throw an error if identifier is used within main component parameters", () => { - expect(() => - findMainComponent(` - pragma circom 2.1.6; - - component main {public [in]} = A(variable, 4); - `), - ).throws( - "Identifier usage is not allowed within the main component's parameters (4:37)", - ); - }); - - it("should throw an error if invalid expression is used inside the main component parameters", () => { - expect(() => - findMainComponent(` - pragma circom 2.1.6; - - component main {public [in]} = A(3, 4 = 4); - `), - ).throws("mismatched input '=' expecting ')' (4:42)"); - - expect(() => - findMainComponent(` - pragma circom 2.1.6; - - component main {public [in]} = A(3, 4 += 2); - `), - ).throws("mismatched input '+=' expecting ')' (4:42)"); - - expect(() => - findMainComponent(` - pragma circom 2.1.6; - - component main {public [in]} = A([2, 8] + [1, 10]); - `), - ).throws("Expected bigint operands in binary expression (4:37)"); - - expect(() => - findMainComponent(` - pragma circom 2.1.6; - - component main {public [in]} = A(![2, 8]); - `), - ).throws("Expected bigint operand in unary expression (4:37)"); - - expect(() => - findMainComponent(` - pragma circom 2.1.6; - - component main {public [in]} = A([2, 8] ? [2, 10] : 10); - `), - ).throws("Expected bigint conditional value in ternary expression (4:37)"); - }); -}); diff --git a/test/misc.test.ts b/test/misc.test.ts deleted file mode 100644 index 6e456b5..0000000 --- a/test/misc.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { expect } from "chai"; - -import { findIncludes, findTemplates } from "../src"; - -describe("General Parsing", () => { - it("should retrieve ", () => { - const expectedOutput = [ - "@circomlib/circuits/comparators.circom", - "comparators.circom", - ]; - - const data = findIncludes("test/data/ToughCircuit.circom"); - - expect(data).to.deep.equal(expectedOutput); - }); - - it("should retrieve pragma version from the circuit", () => { - expect(() => - findIncludes("test/data/ToughCircuitWithError.circom"), - ).to.throw("missing ';' at 'k2' (23:4)"); - }); - - it("should correctly handle errors for invalid input", () => { - expect(() => - findTemplates(` - template Mul2(levels) { - signal input num1; - signal input num2; - signal input num3[2][4]; - - signal output out1[]; - signal output out2[]; - - signal tmp <== 24; - - for (var i = 0; i < 4; i++) { - out1[i] <== num1 * tmp; - out2[i] <== num1 * num2; - } - } - - component main = Mul2(4); - `), - ).to.throw("no viable alternative at input 'signal output out1[]' (7:29)"); - }); -}); diff --git a/test/mocks/CircomFilesVisitor.ts b/test/mocks/CircomFilesVisitor.ts new file mode 100644 index 0000000..6d26435 --- /dev/null +++ b/test/mocks/CircomFilesVisitor.ts @@ -0,0 +1,128 @@ +import { + CircomVisitor, + ComponentMainDeclarationContext, + ExpressionListContext, + IncludeDefinitionContext, + parseSimpleIdentifierList, + PragmaInvalidVersionContext, + PragmaVersionContext, + PublicInputsDefinitionContext, + TemplateDefinitionContext, + ExpressionHelper, +} from "../../src"; + +import { CircomFileData, CircuitResolutionError, ErrorType } from "./types"; + +export class CircomFilesVisitor extends CircomVisitor { + fileData: CircomFileData; + errors: CircuitResolutionError[] = []; + + constructor(public fileIdentifier: string) { + super(); + + this.fileData = { + pragmaInfo: { isCustom: false, compilerVersion: "" }, + includes: [], + mainComponentInfo: { + templateName: null, + publicInputs: [], + parameters: [], + }, + templates: {}, + }; + } + + visitPragmaVersion = (ctx: PragmaVersionContext) => { + this.fileData.pragmaInfo.compilerVersion = ctx.VERSION().getText(); + }; + + visitPragmaInvalidVersion = (ctx: PragmaInvalidVersionContext) => { + this.errors.push({ + type: ErrorType.InvalidPragmaVersion, + context: ctx, + fileIdentifier: this.fileIdentifier, + }); + }; + + visitPragmaCustomTemplates = () => { + this.fileData.pragmaInfo.isCustom = true; + }; + + visitIncludeDefinition = (ctx: IncludeDefinitionContext) => { + this.fileData.includes.push(ctx.STRING().getText().slice(1, -1)); + }; + + visitTemplateDefinition = (ctx: TemplateDefinitionContext) => { + if (ctx.ID().getText() in this.fileData.templates) { + this.errors.push({ + type: ErrorType.TemplateAlreadyUsed, + context: ctx, + fileIdentifier: this.fileIdentifier, + templateIdentifier: ctx.ID().getText(), + message: `Template name ${ctx.ID().getText()} (${ctx.start.line}:${ctx.start.column}) is already in use`, + }); + + return; + } + + this.fileData.templates[ctx.ID().getText()] = { + parameters: parseSimpleIdentifierList(ctx._argNames), + isCustom: !!ctx.CUSTOM(), + parallel: !!ctx.PARALLEL(), + context: ctx, + }; + + return; + }; + + visitBody = () => { + return; + }; + + visitComponentMainDeclaration = (ctx: ComponentMainDeclarationContext) => { + this.fileData.mainComponentInfo.templateName = ctx.ID().getText(); + + this.visit(ctx.publicInputsDefinition()); + this.visit(ctx._argValues); + }; + + visitPublicInputsDefinition = (ctx: PublicInputsDefinitionContext) => { + for (const input of ctx._publicInputs.ID_list()) { + this.fileData.mainComponentInfo.publicInputs.push(input.getText()); + } + }; + + visitExpressionList = (ctx: ExpressionListContext) => { + const expressionHelper = new ExpressionHelper(this.fileIdentifier); + + for (let i = 0; i < ctx.expression_list().length; i++) { + const [value, errors] = expressionHelper + .setExpressionContext(ctx.expression(i)) + .parseExpression(); + + if (value === null) { + this.errors.push({ + type: ErrorType.FailedToResolveMainComponentParameter, + context: ctx.expression(i), + fileIdentifier: this.fileIdentifier, + linkedParserErrors: errors, + message: `Failed to parse array parameter with index ${i}.\r + \rParameter: ${ctx.expression(i).getText()} (${ctx.expression(i).start.line}:${ctx.expression(i).start.column})`, + }); + + continue; + } + + if (errors.length > 0) { + this.errors.push({ + type: ErrorType.InternalExpressionHelperError, + context: ctx.expression(i), + fileIdentifier: this.fileIdentifier, + linkedParserErrors: errors, + }); + } + + this.fileData.mainComponentInfo.parameters.push(value); + } + }; +} diff --git a/test/mocks/CircomSignalDeclarationVisitor.ts b/test/mocks/CircomSignalDeclarationVisitor.ts deleted file mode 100644 index bf68354..0000000 --- a/test/mocks/CircomSignalDeclarationVisitor.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { - Variables, - CircomVisitor, - SignalDefinitionContext, - resolveDimensions, - VarDeclarationContext, - VarDefinitionContext, - RhsValueContext, - CircomExpressionVisitor, - TemplateStmtContext, -} from "../../src"; - -export class CircomSignalDeclarationVisitor extends CircomVisitor { - signalDeclarations: { - name: string; - dimensions: number[]; - }[]; - - vars: Variables = {}; - - constructor(vars: Variables) { - super(); - this.signalDeclarations = []; - - for (const key of Object.keys(vars)) { - this.vars[key] = { - value: vars[key].value, - }; - } - } - - visitSignalDefinition = (ctx: SignalDefinitionContext) => { - // FIXME: Handle nested components - const signalName = ctx.identifier().ID(0).getText(); - const dimensions = resolveDimensions( - ctx.identifier().arrayDimension_list(), - this.vars, - ); - - this.signalDeclarations.push({ - name: signalName, - dimensions: dimensions, - }); - }; - - visitTemplateStmt = (ctx: TemplateStmtContext) => { - if (ctx.identifier() && ctx.ASSIGNMENT() && ctx.expression(0)) { - const id = ctx.identifier().ID(0).getText(); - const value = new CircomExpressionVisitor( - true, - this.vars, - ).visitExpression(ctx.expression(0)); - - if (Array.isArray(value)) { - throw new Error( - `Currently, only single value assignment is supported - ${value}`, - ); - } - - this.vars[id] = { - value: value, - }; - - return; - } - - if (!ctx.IF()) { - this.visitChildren(ctx); - - return; - } - - const result = new CircomExpressionVisitor(true, this.vars).visitExpression( - ctx.parExpression().expression(), - ); - - if (Array.isArray(result)) { - throw new Error( - `Currently, only single value assignment is supported as a result inside if statement - ${result}`, - ); - } - - if (result === 1n) { - this.visitTemplateStmt(ctx.templateStmt(0)); - - return; - } - - if (result === 0n && !ctx.ELSE()) { - return; - } - - if (result === 0n && ctx.ELSE()) { - this.visitTemplateStmt(ctx.templateStmt(1)); - - return; - } - }; - - visitVarDeclaration = (ctx: VarDeclarationContext) => { - const vars = this._parseVarDefinition(ctx.varDefinition()); - - if (!ctx.ASSIGNMENT()) return; - - const results = this._parseRHSValue(ctx.rhsValue()); - - if (vars.length !== results.length) { - throw new Error( - `Mismatch between variable definitions and values - ${ctx.getText()}`, - ); - } - - vars.forEach((varName, index) => { - this.vars[varName] = { - value: results[index], - }; - }); - }; - - _parseVarDefinition = (ctx: VarDefinitionContext): string[] => { - return ctx - .identifier_list() - .map((identifier) => identifier.ID(0).getText()); - }; - - _parseRHSValue = (ctx: RhsValueContext): bigint[] => { - const expressionVisitor = new CircomExpressionVisitor(true, this.vars); - - if (ctx.expression()) { - const expressionResult = expressionVisitor.visitExpression( - ctx.expression(), - ); - - if (Array.isArray(expressionResult)) { - throw new Error( - `Currently, only single value assignment is supported - ${expressionResult}`, - ); - } - - return [expressionResult]; - } - - if (ctx.expressionList()) { - const expressionsResult: bigint[] = []; - - ctx - .expressionList() - .expression_list() - .forEach((expression) => { - const expressionResult = - expressionVisitor.visitExpression(expression); - - if (Array.isArray(expressionResult)) { - throw new Error( - `Currently, only single value assignment is supported - ${expressionResult}`, - ); - } - - expressionsResult.push(expressionResult); - }); - - return expressionsResult; - } - - throw new Error( - `RHS value as function call is not supported - ${ctx.getText()}`, - ); - }; -} diff --git a/test/mocks/CircomTemplateInputsVisitor.ts b/test/mocks/CircomTemplateInputsVisitor.ts new file mode 100644 index 0000000..1ca37f0 --- /dev/null +++ b/test/mocks/CircomTemplateInputsVisitor.ts @@ -0,0 +1,710 @@ +import { + CircomValueType, + CircomVisitor, + ExpressionContext, + ExpressionHelper, + IdentifierContext, + IfRegularContext, + IfRegularElseRegularContext, + IfRegularElseWithFollowUpIfContext, + IfWithFollowUpIfContext, + ParserErrorItem, + parseSimpleIdentifierList, + PIdentifierStatementContext, + PUnderscoreContext, + SignalDeclarationContext, + SignalIdentifierContext, + SignalIdentifierListContext, + SubsAssignmentWithOperationContext, + SubsIcnDecOperationContext, + SubsLeftAssignmentContext, + TemplateDefinitionContext, + VarDeclarationContext, + VariableContext, + VarIdentifierContext, + ParserRuleContext, +} from "../../src"; + +import { + CircuitResolutionError, + ErrorType, + IdentifierObject, + InputData, +} from "./types"; + +export class CircomTemplateInputsVisitor extends CircomVisitor { + templateInputs: Record; + errors: CircuitResolutionError[] = []; + + private _vars: VariableContext = {}; + private _declaredVariables: Record = {}; + + constructor( + public readonly fileIdentifier: string, + public readonly templateContext: TemplateDefinitionContext, + public readonly parameterValues: Record, + ) { + super(); + + this.templateInputs = {}; + + this._vars = parameterValues; + + this._validateVariableContext(); + } + + startParse = () => { + this.visit(this.templateContext); + }; + + visitVarDeclaration = (ctx: VarDeclarationContext) => { + if (ctx.LP() && ctx.RP()) { + this.errors.push({ + type: ErrorType.VarTupleLikeDeclarationNotSupported, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Tuple-like declarations are not supported (${ctx.start.line}:${ctx.start.column})`, + }); + + return; + } + + this.visitChildren(ctx); + }; + + visitSignalDeclaration = (ctx: SignalDeclarationContext) => { + if (ctx.LP() && ctx.RP()) { + this.errors.push({ + type: ErrorType.VarTupleLikeDeclarationNotSupported, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Tuple-like declarations are not supported (${ctx.start.line}:${ctx.start.column})`, + }); + + return; + } + + this.visitChildren(ctx); + + return; + }; + + visitSignalIdentifier = (ctx: SignalIdentifierContext) => { + const base = ctx.identifier(); + const baseName = base.ID(); + const resolvedDimensions: bigint[] = []; + + for (const dimension of base.arrayDimension_list()) { + const [dimensionValue, linkedErrors] = new ExpressionHelper( + this.fileIdentifier, + ) + .setExpressionContext(dimension.expression()) + .setVariableContext(this._vars) + .parseExpression(); + + if (dimensionValue === null) { + this.errors.push({ + type: ErrorType.SignalDimensionResolution, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Failed to resolve the signal dimension ${dimension.getText()} (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return; + } + + if (Array.isArray(dimensionValue)) { + this.errors.push({ + type: ErrorType.SignalDimensionResolution, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Invalid signal dimension value ${dimension.getText()} (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return; + } + + resolvedDimensions.push(dimensionValue); + } + + if ( + !ctx.parentCtx && + !(ctx.parentCtx! instanceof SignalIdentifierListContext) + ) { + throw new Error( + "INTERNAL ERROR: SignalIdentifier should have a SignalIdentifierListContext as a parent", + ); + } + + if ( + !ctx.parentCtx!.parentCtx && + !(ctx.parentCtx!.parentCtx! instanceof SignalDeclarationContext) + ) { + throw new Error( + "INTERNAL ERROR: SignalIdentifier should have a SignalDeclarationContext as a parent of parent", + ); + } + + const signalDeclarationContext = ctx.parentCtx! + .parentCtx as SignalDeclarationContext; + + let signalType = "intermediate"; + if (signalDeclarationContext.signalHeader().SIGNAL_TYPE()) { + signalType = signalDeclarationContext + .signalHeader() + .SIGNAL_TYPE() + .getText(); + } + + this.templateInputs[baseName.getText()] = { + type: signalType, + dimension: resolvedDimensions, + }; + }; + + /** + * We skip this context to avoid visiting unrelated VarIdentifierContext + */ + visitComponentDeclaration = () => { + return; + }; + + visitIfWithFollowUpIf = (ctx: IfWithFollowUpIfContext) => { + let [condition, linkedErrors] = new ExpressionHelper(this.fileIdentifier) + .setExpressionContext(ctx._cond) + .setVariableContext(this._vars) + .parseExpression(); + + if (!this._validateCondition(condition, linkedErrors, ctx, ctx._cond)) { + return; + } + + if (condition === 1n) { + this.visitChildren(ctx); + } + }; + + visitIfRegular = (ctx: IfRegularContext) => { + let [condition, linkedErrors] = new ExpressionHelper(this.fileIdentifier) + .setExpressionContext(ctx._cond) + .setVariableContext(this._vars) + .parseExpression(); + + if (!this._validateCondition(condition, linkedErrors, ctx, ctx._cond)) { + return; + } + + if (condition === 1n) { + this.visitChildren(ctx); + } + }; + + visitIfRegularElseWithFollowUpIf = ( + ctx: IfRegularElseWithFollowUpIfContext, + ) => { + let [condition, linkedErrors] = new ExpressionHelper(this.fileIdentifier) + .setExpressionContext(ctx._cond) + .setVariableContext(this._vars) + .parseExpression(); + + if (!this._validateCondition(condition, linkedErrors, ctx, ctx._cond)) { + return; + } + + if (condition === 1n) { + this.visit(ctx.regularStatements()); + } else { + this.visit(ctx.ifStatements()); + } + }; + + visitIfRegularElseRegular = (ctx: IfRegularElseRegularContext) => { + let [condition, linkedErrors] = new ExpressionHelper(this.fileIdentifier) + .setExpressionContext(ctx._cond) + .setVariableContext(this._vars) + .parseExpression(); + + if (!this._validateCondition(condition, linkedErrors, ctx, ctx._cond)) { + return; + } + + if (condition === 1n) { + this.visit(ctx.regularStatements(0)); + } else { + this.visit(ctx.regularStatements(1)); + } + }; + + /** + * We are sure that identifier defined below is a variable + */ + visitVarIdentifier = (ctx: VarIdentifierContext) => { + const identifierObjects = this._resolveIdentifier( + ctx.identifier(), + this._vars, + ); + + if (identifierObjects === null) { + this.errors.push({ + type: ErrorType.FailedToResolveIdentifier, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Failed to resolve the identifier ${ctx.identifier().getText()} (${ctx.start.line}:${ctx.start.column})`, + }); + + return; + } + + for (const identifierObject of identifierObjects) { + this._declaredVariables[identifierObject.name] = true; + } + + if (ctx._rhs) { + const [value, linkedErrors] = new ExpressionHelper(this.fileIdentifier) + .setExpressionContext(ctx._rhs) + .setVariableContext(this._vars) + .parseExpression(); + + if (value === null) { + this.errors.push({ + type: ErrorType.FailedToResolveIdentifierValue, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Failed to resolve the identifier value ${ctx._rhs.getText()} (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return; + } + + if (Array.isArray(value)) { + this.errors.push({ + type: ErrorType.VarArraysNotSupported, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Failed to resolve the identifier value ${ctx._rhs.getText()} (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return; + } + + this._vars[identifierObjects[0].name] = value; + this._declaredVariables[identifierObjects[0].name] = true; + } + }; + + visitSubsLeftAssignment = (ctx: SubsLeftAssignmentContext) => { + if (ctx.LEFT_ASSIGNMENT() || ctx.LEFT_CONSTRAINT()) { + return; + } + + const primaryExpression = ctx._lhs.primaryExpression(); + + if (!primaryExpression) { + this.errors.push({ + type: ErrorType.InvalidLeftAssignment, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Expected to assign value to an identifier (${ctx.start.line}:${ctx.start.column})`, + }); + + return; + } + + if (primaryExpression instanceof PUnderscoreContext) { + return; + } + + if (!(primaryExpression instanceof PIdentifierStatementContext)) { + this.errors.push({ + type: ErrorType.InvalidLeftAssignment, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Expected to assign value to an identifier (${ctx.start.line}:${ctx.start.column})`, + }); + + return; + } + + const identifierStatement = primaryExpression.identifierStatement(); + + if (identifierStatement.idetifierAccess_list().length > 0) { + this.errors.push({ + type: ErrorType.ComplexAccessNotSupported, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Complex assignment to an identifier is not supported (${ctx.start.line}:${ctx.start.column})`, + }); + + return; + } + + const [value, linkedErrors] = new ExpressionHelper(this.fileIdentifier) + .setExpressionContext(ctx._rhs) + .setVariableContext(this._vars) + .parseExpression(); + + if (value === null) { + this.errors.push({ + type: ErrorType.FailedToResolveIdentifierValue, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Failed to resolve the identifier value ${ctx._rhs.getText()} (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return; + } + + if (Array.isArray(value)) { + this.errors.push({ + type: ErrorType.VarArraysNotSupported, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Failed to resolve the identifier value ${ctx._rhs.getText()} (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return; + } + + this._vars[identifierStatement.ID().getText()] = value; + this._declaredVariables[identifierStatement.ID().getText()] = true; + + return; + }; + + visitSubsAssignmentWithOperation = ( + ctx: SubsAssignmentWithOperationContext, + ) => { + const identifierStatement = ctx.identifierStatement(); + + if (identifierStatement.idetifierAccess_list().length > 0) { + this.errors.push({ + type: ErrorType.ComplexAccessNotSupported, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Complex assignment to an identifier is not supported (${ctx.start.line}:${ctx.start.column})`, + }); + + return; + } + + const [value, linkedErrors] = new ExpressionHelper(this.fileIdentifier) + .setExpressionContext(ctx._rhs) + .setVariableContext(this._vars) + .parseExpression(); + + if (value === null) { + this.errors.push({ + type: ErrorType.FailedToResolveIdentifierValue, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Failed to resolve the identifier value ${ctx._rhs.getText()} (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return; + } + + if (Array.isArray(value)) { + this.errors.push({ + type: ErrorType.InvalidLeftAssignment, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Cannot perform operation on an array (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return; + } + + const assigneeName = identifierStatement.ID().getText(); + + if (!this._declaredVariables[assigneeName]) { + this.errors.push({ + type: ErrorType.AssigneeNotDeclared, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Assignee ${assigneeName} is not declared (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return; + } + + if (Array.isArray(this._vars[assigneeName])) { + this.errors.push({ + type: ErrorType.VarArraysNotSupported, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Cannot perform operation on an array (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return; + } + + switch (ctx.ASSIGNMENT_WITH_OP().getText()) { + case "+=": + this._vars[assigneeName] = this._vars[assigneeName] + value; + break; + case "-=": + this._vars[assigneeName] = this._vars[assigneeName] - value; + break; + case "*=": + this._vars[assigneeName] = this._vars[assigneeName] * value; + break; + case "**=": + this._vars[assigneeName] = this._vars[assigneeName] ** value; + break; + case "/=": + this._vars[assigneeName] = this._vars[assigneeName] / value; + break; + case "\\\\=": + this.errors.push({ + type: ErrorType.QUOOperationNotSupported, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `QUO operation is not supported (${ctx.start.line}:${ctx.start.column})`, + }); + break; + case "%=": + this._vars[assigneeName] = this._vars[assigneeName] % value; + break; + case "<<=": + this._vars[assigneeName] = this._vars[assigneeName] << value; + break; + case ">>=": + this._vars[assigneeName] = this._vars[assigneeName] >> value; + break; + case "&=": + this._vars[assigneeName] = this._vars[assigneeName] & value; + break; + case "^=": + this._vars[assigneeName] = this._vars[assigneeName] ^ value; + break; + case "|=": + this._vars[assigneeName] = this._vars[assigneeName] | value; + break; + default: + this.errors.push({ + type: ErrorType.ReachedUnkownOperation, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Invalid operation type ${ctx.ASSIGNMENT_WITH_OP().getText()} (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + break; + } + }; + + visitSubsIcnDecOperation = (ctx: SubsIcnDecOperationContext) => { + const identifierStatement = ctx.identifierStatement(); + + if (identifierStatement.idetifierAccess_list().length > 0) { + this.errors.push({ + type: ErrorType.ComplexAccessNotSupported, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Complex assignment to an identifier is not supported (${ctx.start.line}:${ctx.start.column})`, + }); + + return; + } + + const assigneeName = identifierStatement.ID().getText(); + + if (!this._declaredVariables[assigneeName]) { + this.errors.push({ + type: ErrorType.AssigneeNotDeclared, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Assignee ${assigneeName} is not declared (${ctx.start.line}:${ctx.start.column})`, + }); + + return; + } + + if (Array.isArray(this._vars[assigneeName])) { + this.errors.push({ + type: ErrorType.VarArraysNotSupported, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Cannot perform operation on an array (${ctx.start.line}:${ctx.start.column})`, + }); + + return; + } + + switch (ctx.SELF_OP().getText()) { + case "++": + this._vars[assigneeName]++; + break; + case "--": + this._vars[assigneeName]--; + break; + default: + this.errors.push({ + type: ErrorType.ReachedUnkownOperation, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Invalid operation type ${ctx.SELF_OP().getText()} (${ctx.start.line}:${ctx.start.column})`, + }); + break; + } + }; + + visitSubsInvalidIcnDecOperation = (ctx: SubsIcnDecOperationContext) => { + this.errors.push({ + type: ErrorType.InvalidIncDecOperation, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Prefix increment/decrement operations are not allowed (${ctx.start.line}:${ctx.start.column})`, + }); + }; + + private _validateVariableContext() { + const templateParameters = parseSimpleIdentifierList( + this.templateContext.simpleIdentifierList(), + ); + + for (const parameter of templateParameters) { + if ( + this._vars[parameter] === undefined || + this._vars[parameter] === null + ) { + this.errors.push({ + type: ErrorType.MissingTemplateParameterValue, + context: this.templateContext, + fileIdentifier: this.templateContext.ID().getText(), + message: `Missing value for parameter ${parameter} in template ${this.templateContext.ID().getText()}`, + }); + + continue; + } + + this._declaredVariables[parameter] = true; + } + } + + private _resolveIdentifier( + ctx: IdentifierContext, + variableContext: VariableContext = {}, + ): IdentifierObject[] | null { + const baseName = ctx.ID().getText(); + + const expressionHelper = new ExpressionHelper(this.fileIdentifier); + + let result: IdentifierObject[] | null = []; + let resolvedDimensions: bigint[] = []; + + for (let i = 0; i < ctx.arrayDimension_list().length; i++) { + const [dimension, linkedErrors] = expressionHelper + .setExpressionContext(ctx.arrayDimension(i).expression()) + .setVariableContext(variableContext) + .parseExpression(); + + if (dimension === null) { + this.errors.push({ + type: ErrorType.InvalidIdentifierDimensionValue, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Invalid dimension type for identifier ${baseName} (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + result = null; + + continue; + } + + if (Array.isArray(dimension)) { + this.errors.push({ + type: ErrorType.InvalidIdentifierDimensionValue, + context: ctx, + fileIdentifier: this.fileIdentifier, + message: `Invalid dimension value for identifier ${baseName} (${ctx.start.line}:${ctx.start.column})`, + linkedParserErrors: linkedErrors, + }); + + result = null; + + continue; + } + + if (result) { + resolvedDimensions.push(dimension); + } + } + + if (result === null) return null; + + result = [{ name: baseName }]; + + for (let i = 0; i < resolvedDimensions.length; i++) { + const intermediateResult: IdentifierObject[] = []; + + for (let j = 0; j < resolvedDimensions[i]; j++) { + for (const res of result) { + intermediateResult.push({ + name: `${res.name}[${j}]`, + arrayAccess: [...(res.arrayAccess || []), j], + }); + } + } + + result = intermediateResult; + } + + return result; + } + + private _validateCondition( + condition: CircomValueType | null, + linkedErrors: ParserErrorItem[], + parentContext: ParserRuleContext, + expressionContext: ExpressionContext, + ): boolean { + if (condition === null) { + this.errors.push({ + type: ErrorType.FailedToResolveIfCondition, + context: parentContext, + fileIdentifier: this.fileIdentifier, + message: `Failed to resolve the if condition ${expressionContext.getText()} (${expressionContext.start.line}:${expressionContext.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return false; + } + + if (Array.isArray(condition)) { + this.errors.push({ + type: ErrorType.InvalidConditionReturnedValue, + context: parentContext, + fileIdentifier: this.fileIdentifier, + message: `Value returned from the condition is an array ${expressionContext.getText()} (${expressionContext.start.line}:${expressionContext.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return false; + } + + if (condition !== 1n && condition !== 0n) { + this.errors.push({ + type: ErrorType.InvalidConditionReturnedValue, + context: parentContext, + fileIdentifier: this.fileIdentifier, + message: `Value returned from the condition is not a boolean ${expressionContext.getText()} (${expressionContext.start.line}:${expressionContext.start.column})`, + linkedParserErrors: linkedErrors, + }); + + return false; + } + + return true; + } +} diff --git a/test/mocks/types.ts b/test/mocks/types.ts new file mode 100644 index 0000000..efe1ac0 --- /dev/null +++ b/test/mocks/types.ts @@ -0,0 +1,73 @@ +import { + CircomValueType, + ParserErrorItem, + ParserRuleContext, + TemplateDefinitionContext, +} from "../../src"; + +export enum ErrorType { + SignalDimensionResolution, + TemplateAlreadyUsed, + InvalidPragmaVersion, + FailedToResolveMainComponentParameter, + InternalExpressionHelperError, + MissingTemplateParameterValue, + InvalidIdentifierDimensionValue, + FailedToResolveIdentifier, + FailedToResolveIdentifierValue, + VarArraysNotSupported, + VarTupleLikeDeclarationNotSupported, + FailedToResolveIfCondition, + InvalidConditionReturnedValue, + InvalidLeftAssignment, + ComplexAccessNotSupported, + AssigneeNotDeclared, + QUOOperationNotSupported, + ReachedUnkownOperation, + InvalidIncDecOperation, +} + +export type InputData = { + type: string; + dimension: bigint[]; +}; + +export type IdentifierObject = { + name: string; + arrayAccess?: number[]; +}; + +export type CircuitResolutionError = { + type: ErrorType; + fileIdentifier: string; + context: ParserRuleContext; + message?: string; + templateIdentifier?: string; + linkedParserErrors?: ParserErrorItem[]; +}; + +export type MainComponent = { + templateName: string | null; + publicInputs: string[]; + parameters: CircomValueType[]; +}; + +export type PragmaComponent = { isCustom: boolean; compilerVersion: string }; + +export type Template = { + parameters: string[]; + isCustom: boolean; + parallel: boolean; + context: TemplateDefinitionContext; +}; + +export type Templates = { + [key: string]: Template; +}; + +export type CircomFileData = { + pragmaInfo: PragmaComponent; + includes: string[]; + mainComponentInfo: MainComponent; + templates: Templates; +}; diff --git a/test/pragma-visitor.test.ts b/test/pragma-visitor.test.ts deleted file mode 100644 index 1dfe26d..0000000 --- a/test/pragma-visitor.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { expect } from "chai"; - -import { findPragma } from "../src"; - -describe("Circom Pragma Visitor", () => { - it("should retrieve pragma version from the circuit", () => { - const result = findPragma(` - pragma circom 2.1.6; - - component main = A(); - `); - - expect(result.isCustom).to.be.false; - expect(result.compilerVersion).to.equal("2.1.6"); - }); - - it("should retrieve pragma version from the circuit", () => { - const result = findPragma(` - pragma custom_templates; - - component main = A(); - `); - - expect(result.isCustom).to.be.true; - expect(result.compilerVersion).to.equal(""); - }); -}); diff --git a/test/setup.ts b/test/setup.ts new file mode 100644 index 0000000..db853b5 --- /dev/null +++ b/test/setup.ts @@ -0,0 +1,3 @@ +(BigInt.prototype as any).toJSON = function () { + return this.toString(); +}; diff --git a/test/templates-visitor.test.ts b/test/templates-visitor.test.ts deleted file mode 100644 index b66f113..0000000 --- a/test/templates-visitor.test.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { expect } from "chai"; - -import { findTemplates } from "../src"; - -describe("Circom Templates Visitor", () => { - it("should retrieve templates info from the valid circom file", () => { - const expectedOutput = { - A: { - inputs: [ - { - name: "b", - dimension: ["param1", "param2*2", "5"], - type: "input", - }, - { - name: "c", - dimension: [], - type: "input", - }, - { - name: "d", - dimension: ["2"], - type: "input", - }, - { - name: "a", - dimension: [], - type: "input", - }, - { - name: "f", - dimension: [], - type: "output", - }, - ], - parameters: ["param1", "param2"], - isCustom: false, - }, - B: { - inputs: [ - { - name: "in", - dimension: [], - type: "input", - }, - { - name: "out", - dimension: [], - type: "output", - }, - ], - parameters: ["N"], - isCustom: true, - }, - C: { - inputs: [ - { - name: "in1", - dimension: [], - type: "input", - }, - { - name: "in2", - dimension: ["3", "p1"], - type: "input", - }, - { - name: "out", - dimension: [], - type: "output", - }, - ], - parameters: ["p1", "p2"], - isCustom: false, - }, - }; - - const result = findTemplates("test/data/Templates.circom"); - - expect(result).to.deep.equal(expectedOutput); - }); - - it("should throw an error if duplicate template name is used", () => { - expect(() => findTemplates("test/data/WrongTemplates.circom")).to.throw( - "Template name A is already in use (20:0)", - ); - }); -});