diff --git a/ChironCore/ChironAST/ChironAST.py b/ChironCore/ChironAST/ChironAST.py index f86c5da..c1e0e3f 100644 --- a/ChironCore/ChironAST/ChironAST.py +++ b/ChironCore/ChironAST/ChironAST.py @@ -12,6 +12,14 @@ class Instruction(AST): pass +class PrintCommand(Instruction): + def __init__(self, expr): + self.expr = expr + + def __str__(self): + return self.expr.__str__() + + class AssignmentCommand(Instruction): def __init__(self, leftvar, rexpr): self.lvar = leftvar @@ -21,6 +29,20 @@ def __str__(self): return self.lvar.__str__() + " = " + self.rexpr.__str__() +class ClassDeclarationCommand(Instruction): + + def __init__(self, className, baseClasses, attributes, objectAttributes): + self.className = className # Class name as a string + self.attributes = attributes # List of AssignmentCommand objects + self.objectAttributes = objectAttributes + self.baseClasses = baseClasses + + def __str__(self): + attr_str = "\n ".join(str(attr) for attr in self.attributes) + obj_attr_str = "\n ".join(str(attr[0]) for attr in self.objectAttributes) + return f"class {self.className} {{\n {attr_str if attr_str else ' // No attributes'}\n\n {obj_attr_str if obj_attr_str else ' // No object attributes'}\n}}" + + class ConditionCommand(Instruction): def __init__(self, condition): self.cond = condition @@ -29,6 +51,8 @@ def __str__(self): return self.cond.__str__() # Not Implemented Yet. + + class AssertCommand(Instruction): def __init__(self, condition): self.cond = condition @@ -36,6 +60,7 @@ def __init__(self, condition): def __str__(self): return self.cond.__str__() + class MoveCommand(Instruction): def __init__(self, motion, expr): self.direction = motion @@ -52,6 +77,7 @@ def __init__(self, penstat): def __str__(self): return self.status + class GotoCommand(Instruction): def __init__(self, x, y): self.xcor = x @@ -60,6 +86,7 @@ def __init__(self, x, y): def __str__(self): return "goto " + str(self.xcor) + " " + str(self.ycor) + class NoOpCommand(Instruction): def __init__(self): pass @@ -67,6 +94,7 @@ def __init__(self): def __str__(self): return "NOP" + class PauseCommand(Instruction): def __init__(self): pass @@ -74,12 +102,60 @@ def __init__(self): def __str__(self): return "pause" + +class FunctionDeclarationCommand(Instruction): + def __init__(self, fname, params=None, body=None): + self.name = fname + self.params = params if params is not None else [] + self.body = body if body is not None else [] + + def __str__(self): + params_str = ", ".join(self.params) + body_str = "\n ".join(str(stmt) for stmt in self.body) + return f"def {self.name}({params_str}):\n {body_str}" + + +class FunctionCallCommand(Instruction): + def __init__(self, fname, arguments=None, caller = None): + self.name = fname + self.args = arguments if arguments is not None else [] + self.caller = caller + + def __str__(self): + args_str = ", ".join(str(arg) for arg in self.args) + if self.caller: + return f"{self.caller}.{self.name}({args_str})" + else: + return f"{self.name}({args_str})" + + +class ReturnCommand(Instruction): + def __init__(self, returnValues): + self.returnValues = returnValues + def __str__(self): + return f"return {self.returnValues}" + +class ReadReturnCommand(Instruction): + def __init__(self, returnValues): + self.returnValues = returnValues + def __str__(self): + return f"read {self.returnValues}" + + +class ParametersPassingCommand(Instruction): + def __init__(self, parameters): + self.params = parameters + + def __str__(self): + return ", ".join(str(param) for param in self.params) + + class Expression(AST): pass - # --Arithmetic Expressions-------------------------------------------- + class ArithExpr(Expression): pass @@ -122,6 +198,7 @@ class Mult(BinArithOp): def __init__(self, lexpr, rexpr): super().__init__(lexpr, rexpr, "*") + class Div(BinArithOp): def __init__(self, lexpr, rexpr): super().__init__(lexpr, rexpr, "/") @@ -147,6 +224,7 @@ class AND(BinCondOp): def __init__(self, expr1, expr2): super().__init__(expr1, expr2, "and") + class OR(BinCondOp): def __init__(self, expr1, expr2): super().__init__(expr1, expr2, "or") @@ -226,6 +304,13 @@ def __init__(self, v): def __str__(self): return str(self.val) +class Real(Value): + def __init__(self, v): + self.val = float(v) + + def __str__(self): + return str(self.val) + class Var(Value): def __init__(self, vname): @@ -233,3 +318,59 @@ def __init__(self, vname): def __str__(self): return self.varname + + +class Array(Value): + def __init__(self, vname): + self.arr = vname + + def __str__(self): + return self.arr + +# class ArrayAccess(Value): +# def __init__(self, var, index): +# self.var = var +# self.idx = index + +# def __str__(self): +# indices_str = "".join(f"[{idx}]" for idx in self.idx) # Format multiple indices +# return f"{self.var}{indices_str}" +# # return self.var.__str__() + "[" + self.idx.__str__() + "]" + + +class DataLocationAccess(Value): + def __init__(self, var, access_chain): + self.var = var + self.access_chain = access_chain # List of attribute names or indices + + def __str__(self): + result = str(self.var) + for access in self.access_chain: + if isinstance(access, list): # Array indexing + indices_str = "".join(f"[{idx}]" for idx in access) + result += indices_str + else: # Object attribute access + result += f".{access}" + return result + +class MethodCaller: + def __init__(self, access_chain): + self.access_chain = access_chain + + def __str__(self): + result = "" + for access in self.access_chain: + if isinstance(access, list): # Array indexing + indices_str = "".join(f"[{idx}]" for idx in access) + result += indices_str + else: # Object attribute access + result += f".{access}" + return result[1:] + +class ObjectInstantiationCommand(Instruction): + def __init__(self, target, class_name): + self.target = target # Variable name or Object/Array Access + self.class_name = class_name # The class being instantiated + + def __str__(self): + return f"{self.target} = new {self.class_name}()" diff --git a/ChironCore/ChironAST/builder.py b/ChironCore/ChironAST/builder.py index b38265e..47d4e69 100644 --- a/ChironCore/ChironAST/builder.py +++ b/ChironCore/ChironAST/builder.py @@ -2,86 +2,287 @@ # -*- coding: utf-8 -*- # ChironLang Abstract Syntax Tree Builder +from ChironAST import ChironAST +from antlr4.tree.Tree import TerminalNodeImpl # Import TerminalNodeImpl +from turtparse.tlangVisitor import tlangVisitor +from turtparse.tlangParser import tlangParser import os import sys sys.path.insert(0, os.path.join("..", "turtparse")) -from turtparse.tlangParser import tlangParser -from turtparse.tlangVisitor import tlangVisitor - -from ChironAST import ChironAST - class astGenPass(tlangVisitor): def __init__(self): - self.repeatInstrCount = 0 # keeps count for no of 'repeat' instructions + self.repeatInstrCount = 0 # Counter for 'repeat' instructions + self.stmtList = [] # Final list of all executable statements + # Temporary list of sub-statements generated for expression breakdown + self.subStmtList = [] + # Counter for naming virtual registers used during code synthesis + self.virtualRegCount = 0 + # Holds the name of the current class context being compiled + self.classRegister = None + + def visitLvalue(self, ctx: tlangParser.LvalueContext): + if ctx.VAR(): + if isinstance(ctx.VAR(), list): + return ChironAST.Var(ctx.VAR()[0].getText()) + return ChironAST.Var(ctx.VAR().getText()) + elif ctx.dataLocationAccess(): + return self.visitDataLocationAccess(ctx.dataLocationAccess()) + + def visitStart(self, ctx: tlangParser.StartContext): + """Entry point for visiting the parse tree. Returns the synthesized statement list.""" + self.visit(ctx.statement_list()) + return self.stmtList + + def visitStatement_list(self, ctx: tlangParser.Statement_listContext): + self.stmtList.extend(self.visit(ctx.declaration_list())) + self.stmtList.extend(self.visit(ctx.strict_ilist())) + + def processInstructionBlock(self, items): + """ + Shared utility for processing declaration or instruction blocks. + Appends the resulting instructions and sub-statements to the main statement list. + """ + stmtListi = [] + for item in items: + currStmtList = self.visit(item) + if not isinstance(currStmtList,list): + currStmtList=[] + stmtListi.extend(self.subStmtList + currStmtList) + self.subStmtList = [] + self.virtualRegCount = 0 + return stmtListi + + def visitDeclaration_list(self, ctx: tlangParser.Declaration_listContext): + return self.processInstructionBlock(ctx.declaration()) + + def visitStrict_ilist(self, ctx: tlangParser.Strict_ilistContext): + return self.processInstructionBlock(ctx.instruction()) + + def visitFunctionDeclaration(self, ctx: tlangParser.FunctionDeclarationContext): + # address(pc) of method will be registered in the interpreter against the key of the form ":className@methodName" + if self.classRegister is not None: + functionName = ":" + self.classRegister + "@" + ctx.NAME().getText() + else: + functionName = ctx.NAME().getText() + functionParams = [param.getText() for param in ctx.parameters( + ).VAR()] if ctx.parameters() is not None else None + functionBody = self.visit(ctx.strict_ilist()) + # function compilation generated two extra statements apart from the function body + # 1. function declaration - This command is used to register the address(pc) of the function in the interpreter + # against the function name + # 2. parameters passing - This command is used to push the parameters to the function on the call stack + return [(ChironAST.FunctionDeclarationCommand(functionName, functionParams, functionBody), len(functionBody) + 2)] + [(ChironAST.ParametersPassingCommand(functionParams), 1)] + functionBody + + + def visitReturnStatement(self, ctx: tlangParser.ReturnStatementContext): + returnValues = [self.visit(expr) for expr in ctx.expression( + )] if ctx.expression() is not None else None + return [(ChironAST.ReturnCommand(returnValues), 1)] + + def visitAssignment(self, ctx: tlangParser.AssignmentContext): + lval = self.visit(ctx.lvalue()) + rval = self.visit(ctx.expression()) + return [(ChironAST.AssignmentCommand(lval, rval), 1)] - def visitStart(self, ctx:tlangParser.StartContext): - stmtList = self.visit(ctx.instruction_list()) - return stmtList + def visitDataLocationAccess(self, ctx: tlangParser.DataLocationAccessContext): - def visitInstruction_list(self, ctx:tlangParser.Instruction_listContext): - instrList = [] - for instr in ctx.instruction(): - instrList.extend(self.visit(instr)) + - return instrList + base=ctx.baseVar().VAR().getText() + + # Traverse through the nested access ('.' for attributes, '[]' for indices) + access_chain = [] + i = 1 # Start from second child (skip baseVar) + while i < len(ctx.children): + child = ctx.children[i] + if isinstance(child, TerminalNodeImpl) and child.getText() == '.': + # Next child must be a VAR (attribute access) + i += 1 # Move to VAR + access = ctx.children[i].getText() + # Handle private attributes + # If the access is with ":self" and the attribute is private, mangle the name + if base == ":self" and i == 2 and ctx.children[i].getText().startswith(":__"): + access = f":_{self.classRegister}{access.replace(':', '')}" + access_chain.append(access) + elif child.getText() == '[': + # Array access: Process the expression inside `[]` + i += 1 # Move to expression inside brackets + # Visit and evaluate expression + expr = self.visit(ctx.children[i]) + access_chain.append([expr]) # Store index as a list + i += 1 # Skip closing ']' + i += 1 # Move to the next child + return ChironAST.DataLocationAccess(base, access_chain) + + def visitMethodCaller(self, ctx: tlangParser.MethodCallerContext): + + if ctx.dataLocationAccess(): + return self.visit(ctx.dataLocationAccess()) + if ctx.VAR(): + var=ctx.VAR().getText() + return ChironAST.DataLocationAccess(var, []) + return None + # access_chain = [] + # i = 0 + # while i < len(ctx.children): + # child = ctx.children[i] + # if isinstance(child, TerminalNodeImpl): + # # Current child must be a VAR (attribute access) + # access_chain.append(ctx.children[i].getText()) + # i += 1 # skip '.' + # elif child.getText() == '[': + # # Array access: Process the expression inside `[]` + # i += 1 # Move to expression inside brackets + # # Visit and evaluate expression + # expr = self.visit(ctx.children[i]) + # access_chain.append([expr.val]) # Store index as a list + # i += 2 # Skip closing ']' + # i += 1 # Move to the next child + # return ChironAST.MethodCaller(access_chain) + + + def visitObjectInstantiation(self, ctx: tlangParser.ObjectInstantiationContext): + # Extract the left-hand side (target variable or object access) + lval = self.visit(ctx.lvalue()) + # Extract the class name + # The last VAR is the class being instantiated + class_name = ctx.VAR().getText() + return [(ChironAST.ObjectInstantiationCommand(lval, class_name), 1)] + + def visitClassDeclaration(self, ctx: tlangParser.ClassDeclarationContext): + className = ctx.VAR()[0].getText() + self.classRegister = className.replace(":", "") + baseClasses = [var.getText() for var in ctx.VAR()[1:]] if len( + ctx.VAR()) > 1 else None # Extract base classes + attributes = [] + # attributes which are object instantiations + objectAttributes = [] + methods = [] + if ctx.classBody(): + for attrDecl in ctx.classBody().classAttributeDeclaration(): + if isinstance(attrDecl.assignment(), tlangParser.AssignmentContext): + assign_instr = self.visitAssignment(attrDecl.assignment()) + attributes.extend(assign_instr) + if isinstance(attrDecl.objectInstantiation(), tlangParser.ObjectInstantiationContext): + objectAttributes.extend(self.visitObjectInstantiation( + attrDecl.objectInstantiation())) + for methodCtx in ctx.classBody().functionDeclaration(): + methods.extend(self.visitFunctionDeclaration( + methodCtx)) + self.classRegister = None # Reset class register + # compiling class declaration generates one extra statement apart from the class body + # 1. class declaration - This command is used to register the class as a python class(along with its attributes) in the interpreter + return [(ChironAST.ClassDeclarationCommand(className, baseClasses, attributes, objectAttributes), 1)] + methods + + def visitValue(self, ctx: tlangParser.ValueContext): + if ctx.NUM(): + return ChironAST.Num(ctx.NUM().getText()) + if ctx.REAL(): + return ChironAST.Real(ctx.REAL().getText()) + elif ctx.VAR(): + return ChironAST.Var(ctx.VAR().getText()) + elif ctx.array(): + return ChironAST.Array(ctx.array().getText()) + elif ctx.dataLocationAccess(): + return self.visitDataLocationAccess(ctx.dataLocationAccess()) + elif ctx.functionCall(): + return self.visitFunctionCallExpr(ctx.functionCall()) + - def visitStrict_ilist(self, ctx:tlangParser.Strict_ilistContext): - # TODO: code refactoring. visitInstruction_list and visitStrict_ilist have same body - instrList = [] - for instr in ctx.instruction(): - visvalue = self.visit(instr) - instrList.extend(visvalue) + def visitFunctionCallExpr(self, ctx: tlangParser.FunctionCallContext): + # TODO: Refactoring, this function has similar body as visitFunctionCall - return instrList + functionName = ctx.NAME().getText() + # the object invoking the method, in case the function call is a method call + methodCaller = self.visitMethodCaller( + ctx.methodCaller()) if ctx.methodCaller().children is not None else None - def visitAssignment(self, ctx:tlangParser.AssignmentContext): - lval = ChironAST.Var(ctx.VAR().getText()) + + functionArgs = [self.visit(arg) for arg in ctx.arguments( + ).expression()] if ctx.arguments() is not None else [] + # if the function is a method call, insert the caller object as the first argument (self) + if methodCaller: + functionArgs.insert(0, methodCaller) + # call private methods with mangled names + # eg, :self.__privateMethod() will be called as :self._className__privateMethod() + # if len(methodCaller.access_chain) == 1 and methodCaller.access_chain[0] == ":self" and functionName.startswith("__"): + # functionName = f"_{self.classRegister}{functionName}" + if methodCaller.var == ":self" and functionName.startswith("__"): + functionName = f"_{self.classRegister}{functionName}" + # create a virtual register to store the return value + returnLocation = ChironAST.Var(":__reg_" + str(self.virtualRegCount)) + self.virtualRegCount += 1 + self.subStmtList.extend([(ChironAST.FunctionCallCommand(functionName, functionArgs, + methodCaller), 1)] + [(ChironAST.ReadReturnCommand([returnLocation]), 1)]) + + return returnLocation + + def visitFunctionCall(self, ctx:tlangParser.FunctionCallContext): + return self.visitFunctionCallExpr(ctx) + + + def visitAssignExpr(self, ctx: tlangParser.AssignExprContext): + lval = self.visit(ctx.lvalue()) rval = self.visit(ctx.expression()) - return [(ChironAST.AssignmentCommand(lval, rval), 1)] + self.subStmtList.extend([(ChironAST.AssignmentCommand(lval, rval), 1)]) + return lval - def visitIfConditional(self, ctx:tlangParser.IfConditionalContext): - condObj = ChironAST.ConditionCommand(self.visit(ctx.condition())) - thenInstrList = self.visit(ctx.strict_ilist()) - return [(condObj, len(thenInstrList) + 1)] + thenInstrList + def visitPrintStatement(self, ctx: tlangParser.PrintStatementContext): + expr_value = self.visit(ctx.expression()) # Evaluate the expression + # Return value in case it's used elsewhere + return [(ChironAST.PrintCommand(expr_value), 1)] - def visitIfElseConditional(self, ctx:tlangParser.IfElseConditionalContext): - condObj = ChironAST.ConditionCommand(self.visit(ctx.condition())) + def visitIfConditional(self, ctx: tlangParser.IfConditionalContext): + condObj = ChironAST.ConditionCommand(self.visit(ctx.expression())) + a=[] + if self.subStmtList: + a.extend(self.subStmtList) + self.subStmtList=[] + thenInstrList = self.visit(ctx.strict_ilist()) + x= a+[(condObj, len(thenInstrList) + 1)] + thenInstrList + return x + + def visitIfElseConditional(self, ctx: tlangParser.IfElseConditionalContext): + condObj = ChironAST.ConditionCommand(self.visit(ctx.expression())) + if self.subStmtList: + self.stmtList.extend(self.subStmtList) + self.subStmtList=[] thenInstrList = self.visit(ctx.strict_ilist(0)) elseInstrList = self.visit(ctx.strict_ilist(1)) - jumpOverElseBlock = [(ChironAST.ConditionCommand(ChironAST.BoolFalse()), len(elseInstrList) + 1)] + jumpOverElseBlock = [(ChironAST.ConditionCommand( + ChironAST.BoolFalse()), len(elseInstrList) + 1)] return [(condObj, len(thenInstrList) + 2)] + thenInstrList + jumpOverElseBlock + elseInstrList - def visitGotoCommand(self, ctx:tlangParser.GotoCommandContext): + def visitGotoCommand(self, ctx: tlangParser.GotoCommandContext): xcor = self.visit(ctx.expression(0)) ycor = self.visit(ctx.expression(1)) return [(ChironAST.GotoCommand(xcor, ycor), 1)] # Visit a parse tree produced by tlangParser#unaryExpr. - def visitUnaryExpr(self, ctx:tlangParser.UnaryExprContext): + def visitUnaryExpr(self, ctx: tlangParser.UnaryExprContext): expr1 = self.visit(ctx.expression()) if ctx.unaryArithOp().MINUS(): return ChironAST.UMinus(expr1) - - return self.visitChildren(ctx) + return self.visitChildren(ctx) # Visit a parse tree produced by tlangParser#addExpr. - def visitAddExpr(self, ctx:tlangParser.AddExprContext): + def visitAddExpr(self, ctx: tlangParser.AddExprContext): left = self.visit(ctx.expression(0)) right = self.visit(ctx.expression(1)) if ctx.additive().PLUS(): - return ChironAST.Sum(left, right) + ext = ChironAST.Sum(left, right) elif ctx.additive().MINUS(): - return ChironAST.Diff(left, right) - + ext = ChironAST.Diff(left, right) + return ext # Visit a parse tree produced by tlangParser#mulExpr. - def visitMulExpr(self, ctx:tlangParser.MulExprContext): + def visitMulExpr(self, ctx: tlangParser.MulExprContext): left = self.visit(ctx.expression(0)) right = self.visit(ctx.expression(1)) if ctx.multiplicative().MUL(): @@ -89,86 +290,73 @@ def visitMulExpr(self, ctx:tlangParser.MulExprContext): elif ctx.multiplicative().DIV(): return ChironAST.Div(left, right) - # Visit a parse tree produced by tlangParser#parenExpr. - def visitParenExpr(self, ctx:tlangParser.ParenExprContext): - return self.visit(ctx.expression()) - - - def visitCondition(self, ctx:tlangParser.ConditionContext): - if ctx.PENCOND(): - return ChironAST.PenStatus(); - - if ctx.NOT(): - expr1 = self.visit(ctx.condition(0)) - return ChironAST.NOT(expr1) - - - if ctx.logicOp(): - expr1 = self.visit(ctx.condition(0)) - expr2 = self.visit(ctx.condition(1)) - logicOpCtx = ctx.logicOp() - - if logicOpCtx.AND(): - return ChironAST.AND(expr1, expr2) - elif logicOpCtx.OR(): - return ChironAST.OR(expr1, expr2) - - - if ctx.binCondOp(): - expr1 = self.visit(ctx.expression(0)) - expr2 = self.visit(ctx.expression(1)) - binOpCtx = ctx.binCondOp() - - if binOpCtx.LT(): - return ChironAST.LT(expr1, expr2) - elif binOpCtx.GT(): - return ChironAST.GT(expr1, expr2) - elif binOpCtx.EQ(): - return ChironAST.EQ(expr1, expr2) - elif binOpCtx.NEQ(): - return ChironAST.NEQ(expr1, expr2) - elif binOpCtx.LTE(): - return ChironAST.LTE(expr1, expr2) - elif binOpCtx.GTE(): - return ChironAST.GTE(expr1, expr2) - - if ctx.condition(): - # condition is inside paranthesis - return self.visit(ctx.condition(0)) - - return self.visitChildren(ctx) - - def visitValue(self, ctx:tlangParser.ValueContext): - if ctx.NUM(): - return ChironAST.Num(ctx.NUM().getText()) - elif ctx.VAR(): - return ChironAST.Var(ctx.VAR().getText()) - - def visitLoop(self, ctx:tlangParser.LoopContext): + def visitParenExpr(self, ctx: tlangParser.ParenExprContext): + return self.visit(ctx.expression()) + + def visitNotExpr(self, ctx: tlangParser.NotExprContext): + expr1 = self.visit(ctx.condition(0)) + return ChironAST.NOT(expr1) + + def visitBinExpr(self, ctx: tlangParser.BinExprContext): + expr1 = self.visit(ctx.expression(0)) + expr2 = self.visit(ctx.expression(1)) + binOpCtx = ctx.binCondOp() + + if binOpCtx.LT(): + return ChironAST.LT(expr1, expr2) + elif binOpCtx.GT(): + return ChironAST.GT(expr1, expr2) + elif binOpCtx.EQ(): + return ChironAST.EQ(expr1, expr2) + elif binOpCtx.NEQ(): + return ChironAST.NEQ(expr1, expr2) + elif binOpCtx.LTE(): + return ChironAST.LTE(expr1, expr2) + elif binOpCtx.GTE(): + return ChironAST.GTE(expr1, expr2) + + def visitLogExpr(self, ctx: tlangParser.LogExprContext): + expr1 = self.visit(ctx.expression(0)) + expr2 = self.visit(ctx.expression(1)) + logicOpCtx = ctx.logicOp() + + if logicOpCtx.AND(): + return ChironAST.AND(expr1, expr2) + elif logicOpCtx.OR(): + return ChironAST.OR(expr1, expr2) + + def visitPenExpr(self, ctx: tlangParser.PenExprContext): + return ChironAST.PenStatus() + + + + def visitLoop(self, ctx: tlangParser.LoopContext): # insert counter variable in IR for tracking repeat count self.repeatInstrCount += 1 repeatNum = self.visit(ctx.value()) - counterVar = ChironAST.Var(":__rep_counter_" + str(self.repeatInstrCount)) - counterVarInitInstr = ChironAST.AssignmentCommand(counterVar, repeatNum) + counterVar = ChironAST.Var( + ":__rep_counter_" + str(self.repeatInstrCount)) + counterVarInitInstr = ChironAST.AssignmentCommand( + counterVar, repeatNum) constZero = ChironAST.Num(0) constOne = ChironAST.Num(1) - loopCond = ChironAST.ConditionCommand(ChironAST.GT(counterVar, constZero)) - counterVarDecrInstr = ChironAST.AssignmentCommand(counterVar, ChironAST.Diff(counterVar, constOne)) + loopCond = ChironAST.ConditionCommand( + ChironAST.GT(counterVar, constZero)) + counterVarDecrInstr = ChironAST.AssignmentCommand( + counterVar, ChironAST.Diff(counterVar, constOne)) + + thenInstrList = self.visit(ctx.strict_ilist()) - thenInstrList = [] - for instr in ctx.strict_ilist().instruction(): - temp = self.visit(instr) - thenInstrList.extend(temp) boolFalse = ChironAST.ConditionCommand(ChironAST.BoolFalse()) return [(counterVarInitInstr, 1), (loopCond, len(thenInstrList) + 3)] + thenInstrList +\ [(counterVarDecrInstr, 1), (boolFalse, -len(thenInstrList) - 2)] - def visitMoveCommand(self, ctx:tlangParser.MoveCommandContext): + def visitMoveCommand(self, ctx: tlangParser.MoveCommandContext): mvcommand = ctx.moveOp().getText() mvexpr = self.visit(ctx.expression()) return [(ChironAST.MoveCommand(mvcommand, mvexpr), 1)] - def visitPenCommand(self, ctx:tlangParser.PenCommandContext): + def visitPenCommand(self, ctx: tlangParser.PenCommandContext): return [(ChironAST.PenCommand(ctx.getText()), 1)] diff --git a/ChironCore/chiron.py b/ChironCore/chiron.py index 2eca801..acd8ea4 100755 --- a/ChironCore/chiron.py +++ b/ChironCore/chiron.py @@ -195,6 +195,12 @@ def stopTurtle(): default=True, type=bool, ) + cmdparser.add_argument( + "-ch", + "--class_hierarchy", + help="To visualize class inheritance and methods", + action="store_true", + ) args = cmdparser.parse_args() ir = "" @@ -210,7 +216,8 @@ def stopTurtle(): if args.bin: ir = irHandler.loadIR(args.progfl) else: - parseTree = getParseTree(args.progfl) + parseTree,parser = getParseTree(args.progfl) + print(parseTree.toStringTree(recog=parser)) astgen = astGenPass() ir = astgen.visitStart(parseTree) diff --git a/ChironCore/class_hierarchy.png b/ChironCore/class_hierarchy.png new file mode 100644 index 0000000..bcaf83a Binary files /dev/null and b/ChironCore/class_hierarchy.png differ diff --git a/ChironCore/example/demo/Binary_Tree.tl b/ChironCore/example/demo/Binary_Tree.tl new file mode 100644 index 0000000..7558c16 --- /dev/null +++ b/ChironCore/example/demo/Binary_Tree.tl @@ -0,0 +1,45 @@ +def drawSquare(:x, :y, :len) { + penup + goto(:x - :len/2, :y + :len/2) + pendown + repeat 4 [ + forward :len + right 90 + ] + return 0 +} + +def drawTree(:x, :y, :len, :depth, :spread) { + drawSquare(:x, :y, :len) + + if :depth > 1 [ + :dy = 80 + :nextY = :y - :dy + :offset = :spread / 2 + + :lx = :x - :offset + + penup + goto(:x, :y - :len/2) + pendown + goto(:lx, :nextY + :len/2) + + drawTree(:lx, :nextY, :len, :depth - 1, :spread / 2) + + goto(:x, :y - :len/2) + + :rx = :x + :offset + + penup + goto(:x, :y - :len/2) + pendown + goto(:rx, :nextY + :len/2) + + drawTree(:rx, :nextY, :len, :depth - 1, :spread / 2) + + goto(:x, :y - :len/2) + ] + return 0 +} + +drawTree(0, 250, 40, 4, 240) diff --git a/ChironCore/example/demo/class_hierarchy.tl b/ChironCore/example/demo/class_hierarchy.tl new file mode 100644 index 0000000..97dcaa9 --- /dev/null +++ b/ChironCore/example/demo/class_hierarchy.tl @@ -0,0 +1,84 @@ +class :BankAccount { + :__accountNumber = 12345678 + :balance = 0 + + def getBalance(:self) { + return :self.:balance + } + + def deposit(:self, :amt) { + :self.:balance = :self.:balance + :amt + return 0 + } + + def withdraw(:self, :amt) { + if :self.:balance >= :amt [ + :self.:balance = :self.:balance - :amt + return 0 + ] + else [ + return -1 + ] + } + def __withdraw(:self, :amt, :minBalance, :fee) { + :total = :amt + :fee + if :self.:balance - :total >= :minBalance [ + :self.:balance = :self.:balance - :total + return 0 + ] + else [ + return -1 + ] + } +} + + +class :SavingsAccount(:BankAccount) { + :__interestRate = 0.05 + + + def withdraw(:self, :amt) { + if :self.:balance >= :amt [ + :self.:balance = :self.:balance - :amt + return 0 + ] + else [ + return -1 + ] + } + + def addInterest(:self) { + :interest = :self.:balance * :self.:__interestRate + :self.:balance = :self.:balance + :interest + return 0 + } +} + + +class :CheckingAccount(:BankAccount) { + :__overdraftLimit = 500 + + + def withdraw(:self, :amt) { + if :self.:balance + :self.:__overdraftLimit >= :amt [ + :self.:balance = :self.:balance - :amt + return 0 + ] + else [ + return -1 + ] + } +} + + +:saveAcc = new :SavingsAccount() +:saveAcc.deposit(1000) +:saveAcc.addInterest() +:bal1 = :saveAcc.getBalance() +print(:bal1) + +:chkAcc = new :CheckingAccount() +:chkAcc.deposit(200) +:chkAcc.withdraw(600) +:bal2 = :chkAcc.getBalance() +print(:bal2) \ No newline at end of file diff --git a/ChironCore/example/demo/class_inheritance.tl b/ChironCore/example/demo/class_inheritance.tl new file mode 100644 index 0000000..de87c24 --- /dev/null +++ b/ChironCore/example/demo/class_inheritance.tl @@ -0,0 +1,15 @@ +class :Shape { + :length = 250 +} + +class :Triangle(:Shape) { + :sides = 3 +} + +:tri = new :Triangle() +:count = 0 +repeat :tri.:sides [ + forward :tri.:length + right 120 + :count = :count + 1 +] diff --git a/ChironCore/example/demo/class_inheritance_2.tl b/ChironCore/example/demo/class_inheritance_2.tl new file mode 100644 index 0000000..9aa00a6 --- /dev/null +++ b/ChironCore/example/demo/class_inheritance_2.tl @@ -0,0 +1,28 @@ +class :Shape { + :length = 250 + def moveForward(:self) + { + forward :self.:length + return 0 + } +} + +class :Hexagon(:Shape) { + :sides = 6 + def drawHex(:self) { + repeat :self.:sides [ + :self.moveForward() + right 60 + ] + return 0 + } + def __moveForward(:self, :distance) { + forward :distance + return 0 + } +} + +:hex = new :Hexagon() +:hex.drawHex() +# This does not work # +:hex.__moveForward(100) \ No newline at end of file diff --git a/ChironCore/example/demo/class_pentagon.tl b/ChironCore/example/demo/class_pentagon.tl new file mode 100644 index 0000000..e63571f --- /dev/null +++ b/ChironCore/example/demo/class_pentagon.tl @@ -0,0 +1,15 @@ +class :Pentagon { + :sides = 5 + :length = 250 + def drawShape(:self) { + :angle = 360 / :self.:sides + repeat :self.:sides [ + forward :self.:length + right :angle + ] + return 0 + } +} + +:pent = new :Pentagon() +:pent.drawShape() diff --git a/ChironCore/example/demo/diamond_problem.tl b/ChironCore/example/demo/diamond_problem.tl new file mode 100644 index 0000000..b3907f4 --- /dev/null +++ b/ChironCore/example/demo/diamond_problem.tl @@ -0,0 +1,25 @@ +class :Animal { + :walk = 1 + def walk(:self) + { + print(:self.:walk) + return 0 + } +} + +class :Lion(:Animal) +{ + +} +class :Tiger(:Animal) +{ + +} + +class :Liger(:Lion, :Tiger) +{ +} + +:liger = new :Liger() +:liger.:walk = 2 +:liger.walk() \ No newline at end of file diff --git a/ChironCore/example/demo/overloading.tl b/ChironCore/example/demo/overloading.tl new file mode 100644 index 0000000..6a1ba63 --- /dev/null +++ b/ChironCore/example/demo/overloading.tl @@ -0,0 +1,41 @@ +def draw(:r) { + + :circumference = 2 * 3.14 * :r + :steps = 36 + :stepLength = :circumference / :steps + :turnAngle = 360 / :steps + + repeat :steps [ + forward(:stepLength) + right(:turnAngle) + ] + return 0 + +} + +def draw(:w, :h) { + forward(:w) + right(90) + forward(:h) + right(90) + forward(:w) + right(90) + forward(:h) + right(90) + return 0 +} + +def draw(:a, :b, :c) { + forward(:a) + right(120) + forward(:b) + right(120) + forward(:c) + right(120) + return 0 +} + + +draw(100) +draw(100,100) +draw(100,100,100) \ No newline at end of file diff --git a/ChironCore/example/demo/rangoli.tl b/ChironCore/example/demo/rangoli.tl new file mode 100644 index 0000000..d8b603e --- /dev/null +++ b/ChironCore/example/demo/rangoli.tl @@ -0,0 +1,66 @@ +def sqroot(:n) +{ + if (:n == 0) [ + return 0 + ] + if (:n == 1) [ + return 1 + ] + + :low = 0 + :high = :n + :ans = 0 + :epsilon = 0.0001 + repeat 50 [ + :mid = (:low + :high) / 2 + :square = :mid * :mid + + if (:square == :n) [ + return :mid + ] + + if (:square < :n) [ + :low = :mid + :ans = :mid + ] + else [ + :high = :mid + ] + + if ((:high - :low) < :epsilon) [ + return :ans + ] + ] + return :ans +} + +def drawRangoli(:size) +{ + pendown + forward :size + left 90 + forward :size + left 90 + forward :size + left 90 + forward :size + penup + + left 90 + forward :size/2 + left 45 + :size = sqroot((:size * :size ) / 2) + if :size > 10 + [ drawRangoli(:size) ] + return 100 +} + +class :Point { + :x = -300 + :y = -300 +} +penup +:point = new :Point() +goto (:point.:x, :point.:y) +:size=200 +drawRangoli(:size) diff --git a/ChironCore/example/demo/star_in_sq.tl b/ChironCore/example/demo/star_in_sq.tl new file mode 100644 index 0000000..6478be5 --- /dev/null +++ b/ChironCore/example/demo/star_in_sq.tl @@ -0,0 +1,31 @@ +class :Shape { + :length = 250 +} + +class :Star(:Shape) { + :points = 5 + def drawStar(:self) { + :angle = 144 + repeat :self.:points [ + forward :self.:length + right :angle + ] + return 10 + } +} + +def drawSquare(:size) { + repeat 4 [ + forward :size + right 90 + ] + return 10 +} + +:star = new :Star() +:star.drawStar() +penup +goto(-25, 100) +pendown +:size = 300 +drawSquare(:size) diff --git a/ChironCore/example/demo/test.tl b/ChironCore/example/demo/test.tl new file mode 100644 index 0000000..f3002d7 --- /dev/null +++ b/ChironCore/example/demo/test.tl @@ -0,0 +1,9 @@ +if :x=0 == :y=:z=3 [ + print(:y) +] +else [ + print(:x) + repeat 4 [ + forward 100 + right 90 + ]] \ No newline at end of file diff --git a/ChironCore/example/example1.tl b/ChironCore/example/example1.tl index 7d15f80..a23ac7f 100644 --- a/ChironCore/example/example1.tl +++ b/ChironCore/example/example1.tl @@ -1,5 +1,8 @@ pendown - +:x = 4 +:y = 2 +:z = 4 +:p = 10 repeat 3 [ if (:x > :y) [ diff --git a/ChironCore/example/example2.tl b/ChironCore/example/example2.tl index 7d2984e..bacdeb1 100644 --- a/ChironCore/example/example2.tl +++ b/ChironCore/example/example2.tl @@ -1,8 +1,6 @@ penup goto (50, 50) pendown -:two = 200 -:one = 100 forward 50 right 90 forward 50 diff --git a/ChironCore/example/exampleFC.tl b/ChironCore/example/exampleFC.tl new file mode 100644 index 0000000..8a2c2ba --- /dev/null +++ b/ChironCore/example/exampleFC.tl @@ -0,0 +1,59 @@ + +def drawRectangle(:l, :b) +{ + penup + goto (:l, :b) + pendown + forward :l + right 90 + forward :b + right 90 + forward :l + right 90 + forward :b + penup + return 0 +} + +def drawCircle() +{ + :vara = 20 + :varb = 100 + :varc = 60 + repeat 1 [ + goto (0, 0) + pendown + repeat 6 [ + if (:vara != :varb) [ + if ( :vara > :varb) [ right :vara ] + else [ left :varb ] + ] + else [ + if ((:vara <= :varc) || (:varb <= :varc)) [ + :vara = :varc / :vara + :varb = :varb / :varc + :varc = :varb + ] + ] + forward :vara + right :varb + forward :varc + left :varc + ] + left 45 + ] + penup + return :vara, :varb +} + +def factorial(:n) +{ + if :n == 1 [ + return 1 + ] + return :n * factorial(:n - 1) +} + +drawRectangle(50, 50) +drawCircle() +print(factorial(6)) diff --git a/ChironCore/example/exampleSE.tl b/ChironCore/example/exampleSE.tl index f2096f5..2d2cab6 100644 --- a/ChironCore/example/exampleSE.tl +++ b/ChironCore/example/exampleSE.tl @@ -1,6 +1,116 @@ -:y = :x -if :x <= 42 [ - :y = :y + 40 -] else [ - :y = :y + 22 -] +class :__Node { + :x = 0 + :y = 0 +} + + +def drawV(:__x, :__y, :__r) { + penup + goto(:__x - :__r, :__y + :__r) + pendown + goto(:__x, :__y - :__r) + goto(:__x + :__r, :__y + :__r) + return 0 +} + +def drawSquare(:__x, :__y, :__r) { + penup + goto(:__x - :__r, :__y + :__r) + pendown + repeat 4 [ + forward (2 * :__r) + right 90 + ] + return 0 +} + +def drawLine(:__x1, :__y1, :__x2, :__y2) { + penup + goto(:__x1, :__y1) + pendown + goto(:__x2, :__y2) + return 0 +} + + +def saveNode(:__x, :__y,:__allNodes,:cnt) { + :__n = new :__Node() + :__n.:x = :__x + :__n.:y = :__y + :__allNodes[:cnt]=:__n + return 0 +} + +def crossNode(:__x, :__y, :__r) { + drawLine(:__x - :__r, :__y + :__r, :__x + :__r, :__y - :__r) + drawLine(:__x - :__r, :__y - :__r, :__x + :__r, :__y + :__r) + return 0 +} + + +def drawTree(:__x, :__y, :__r, :__depth, :__spread, :__allNodes,:cnt) { + drawSquare(:__x, :__y, :__r) + saveNode(:__x, :__y,:__allNodes,:cnt) + if :__depth > 1 [ + :__offset = :__spread / 2 + :__dy = 80 + :__lx = :__x - :__offset + :__rx = :__x + :__offset + :__cy = :__y - :__dy + drawLine(:__x - :__r, :__y - :__r, :__lx - :__r, :__cy + :__r) + drawLine(:__x + :__r, :__y - :__r, :__rx + :__r, :__cy + :__r) + drawTree(:__lx, :__cy, :__r, :__depth - 1, :__spread / 2, :__allNodes,2*:cnt+1) + drawTree(:__rx, :__cy, :__r, :__depth - 1, :__spread / 2, :__allNodes,2*:cnt+2) + ] + return 0 +} + +def dfsmark(:node, :__allNodes, :target) { + if :node >=7 [ + return 0 + ] + + :cur = :__allNodes[:node] + + if :cur.:x == :target.:x && :cur.:y == :target.:y [ + crossNode(:cur.:x, :cur.:y, 20) + return 1 + ] + + drawV(:cur.:x, :cur.:y, 20) + + :lhs = 2 * :node + 1 + :rhs = 2 * :node + 2 + + + + if dfsmark(:lhs, :__allNodes, :target) == 1 [ + return 1 + ] + + if dfsmark(:rhs, :__allNodes, :target)== 1 [ + return 1 + ] + + return 0 +} + + + +:n = new :__Node() + +:__allNodes = [:n, :n , :n, :n , :n, :n , :n ] + +:cnt = 0 +drawTree(0, 250, 20, 3, 240,:__allNodes,:cnt) + +:target = new :__Node() + +:target.:x=:__allNodes[3].:x +:target.:y=:__allNodes[3].:y + + +:r= dfsmark(0,:__allNodes,:target) + +print(:r) + diff --git a/ChironCore/example/issues.txt b/ChironCore/example/issues.txt new file mode 100644 index 0000000..016a030 --- /dev/null +++ b/ChironCore/example/issues.txt @@ -0,0 +1,25 @@ +1. loop should have expression rather than just value +2. condition should be true for non zero values and not just true/false +3. class currently should have at least one member or python dynamic class initiation throw indentation error +4. Setting objects to N0ne in declaration is not done yet +5. instruction_list can contain both function declaration and classDeclaration this can cause problems +6. Multiple class inheritance is not yet supported! [fixed] +7. return is compulsory in function declaration with at least one return value +8. Solution to Avoid Unexpected Changes in Mutable Class Variables: use __init__ method during class declaration [fixed] +9. Writing self is compulsory in methods of class parameters +10. class must have at least one assignment statement [fixed] +11. Function overloading with number of arguments [fixed] +12. print the CHA +13. Regular variables can also start with __ !! +14. Raise error when the normal function name start with __. semantic analysis. allow only private method in classes +15. :self can only come in the first position in the object access of method call chain +16. commenting now supported [fixed] +17. first all the declaration will be processed and then the instructions! +18. Strictly enforce the keywords like return and def to not be used as function of class names +19. There should be at least one instruction apart from function and class definitions in the program + + + + +Details on interpreter.py +1. Function address in the address-map can be searched by forming a string with the function name and number of parameters \ No newline at end of file diff --git a/ChironCore/example/kachuapur.tl b/ChironCore/example/kachuapur.tl index be3bc51..6cbb899 100644 --- a/ChironCore/example/kachuapur.tl +++ b/ChironCore/example/kachuapur.tl @@ -1,6 +1,5 @@ -:i = 0 -repeat 8 [ - :i = 1 + :i - right(90) - forward(:delta * :i) -] +:i = [0,[2,3,4],3,4] +:i[1][0] = 30 +:j= :i[0] = :k = 6 + :i[2*1+1*:i[0]] +print(:j) +print(:i) \ No newline at end of file diff --git a/ChironCore/example/kachuapur2.tl b/ChironCore/example/kachuapur2.tl index 448f1d3..593b953 100644 --- a/ChironCore/example/kachuapur2.tl +++ b/ChironCore/example/kachuapur2.tl @@ -1,8 +1,6 @@ -:cnt = 0 -:i = 0 -repeat :steps [ - :i = :cnt + :i - :cnt = :cnt + 1 - forward(1 + :cnt) - right(:radius) -] +:b = 2 +:e = 3 +:steps = (:c = :b = :e) * (:d = 4) + :e * 5 +print(:steps = 3) +print(:steps ) +print(2*4+5+:b) diff --git a/ChironCore/example/kachuapur3.tl b/ChironCore/example/kachuapur3.tl new file mode 100644 index 0000000..70e7f29 --- /dev/null +++ b/ChironCore/example/kachuapur3.tl @@ -0,0 +1,32 @@ +class :Point { + :x = 6 + :y = 4 + def draw(:self) + { + print(:self.:x) + return 0 + } + def drawy(:self) + { + print(:self.:y) + return 0 + } +} + +class :Circle { + :point = new :Point() + +} + +:point = new :Point() +:circle = new :Circle() +:circle1 = new :Circle() +print(:circle.:point.:x) +:circle.:point.:x = :circle.:point.:y = -100 +print(:point.:x) +print(:circle.:point.:x) +print(:circle1.:point.:x) + +:circle.:point.draw() + +:circle1.:point.drawy() \ No newline at end of file diff --git a/ChironCore/example/kachuapur4.tl b/ChironCore/example/kachuapur4.tl new file mode 100644 index 0000000..da91dd6 --- /dev/null +++ b/ChironCore/example/kachuapur4.tl @@ -0,0 +1,16 @@ +def add(:a, :b) +{ + return :a + :b +} +class :Test +{ +def increment(:self, :val) +{ + return add(2, 3) +} +} + +:test = new :Test() +:val = 1 +:val = :test.increment(:val) * 2 +print(:val) \ No newline at end of file diff --git a/ChironCore/example/library.tl b/ChironCore/example/library.tl new file mode 100644 index 0000000..5f9fc46 --- /dev/null +++ b/ChironCore/example/library.tl @@ -0,0 +1,38 @@ +def sqroot(:n) +{ + if (:n == 0) [ + return 0 + ] + if (:n == 1) [ + return 1 + ] + + :low = 0 + :high = :n + :ans = 0 + :epsilon = 0.0001 + repeat 50 [ + :mid = (:low + :high) / 2 + :square = :mid * :mid + + if (:square == :n) [ + return :mid + ] + + if (:square < :n) [ + :low = :mid + :ans = :mid + ] + else [ + :high = :mid + ] + + if ((:high - :low) < :epsilon) [ + return :ans + ] + ] + return :ans +} + +:a = sqroot(20) +print(:a) \ No newline at end of file diff --git a/ChironCore/example/test.tl b/ChironCore/example/test.tl new file mode 100644 index 0000000..1a14e07 --- /dev/null +++ b/ChironCore/example/test.tl @@ -0,0 +1,11 @@ +def add(:a, :b) +{ + return :a + :b +} +def increment(:a) +{ + return add(:a, 1),3,4 +} +:x = increment(3) +add(4,3) +print(:x) \ No newline at end of file diff --git a/ChironCore/interpreter.py b/ChironCore/interpreter.py index bb30bcb..b8775cf 100644 --- a/ChironCore/interpreter.py +++ b/ChironCore/interpreter.py @@ -1,12 +1,19 @@ - from ChironAST import ChironAST from ChironHooks import Chironhooks import turtle +import re +from graphviz import Digraph +import tkinter as tk +from PIL import Image, ImageTk +Release = "Chiron v5.3" -Release="Chiron v5.3" def addContext(s): - return str(s).strip().replace(":", "self.prg.") + s = re.sub(r'(?= len(self.ir): # This is the ending of the interpreter. + if self.args.class_hierarchy: + self.print_class_hierarchy() self.trtl.write("End, Press ESC", font=("Arial", 15, "bold")) if self.args is not None and self.args.hooks: self.chironhook.ChironEndHook(self) return True else: return False - + def initProgramContext(self, params): # This is the starting of the interpreter at setup stage. if self.args is not None and self.args.hooks: self.chironhook.ChironStartHook(self) self.trtl.write("Start", font=("Arial", 15, "bold")) - for key,val in params.items(): - var = key.replace(":","") + for key, val in params.items(): + var = key.replace(":", "") exec("setattr(self.prg,\"%s\",%s)" % (var, val)) + + def handleFunctionDeclaration(self, stmt, tgt): + # mangle the name of private method as _ClassName__methodName + if "@" in stmt.name and stmt.name.split("@")[1].startswith("__"): + class_name, method_name = stmt.name.split("@") + + function_name = class_name+ "@" + "_" + class_name.replace(":","") + method_name + else: + function_name = stmt.name + + + + self.function_addresses[function_name + "_" + str(len(stmt.params))] = self.pc + 1 # body of the function starts from next instruction + + # Record method in class_methods if it's a class method + if "@" in stmt.name: + class_name, method_name = stmt.name.split("@") + class_name = class_name.replace(":", "") + arity = len(stmt.params) + if class_name not in self.class_methods: + self.class_methods[class_name] = [] + is_private = method_name.startswith("__") + self.class_methods[class_name].append((method_name, arity, is_private)) + + return tgt + + def handleFunctionCall(self, stmt, tgt): + # Handling call stack + # Save the return address on the call stack + self.call_stack.append(self.pc + 1) + # Save the current program context on the call stack + self.call_stack.append(self.prg) + # Save the arguments on the call stack + for arg in stmt.args: + arg_value = addContext(arg) + exec(f"self.argument = {arg_value}") + self.call_stack.append(self.argument) + # Jump to the function address + # If the function is a method, the name will be in the form of "caller@method" + if stmt.caller: + caller_class = eval(addContext(stmt.caller)).__class__.__name__ + method_name = ":" + str(caller_class) + "@" + str(stmt.name) + "_" + str(len(stmt.args)) + self.pc = self.function_addresses[method_name] + else: + self.pc = self.function_addresses[stmt.name + "_" + str(len(stmt.args))] + # Initialize a new program context for the new activation record + self.prg = ProgramContext() + return 0 + + # Copying the return values in their respective placeholders + def handleReturnRead(self, stmt, tgt): + + # print(f"Read Return: {stmt.returnValues}") + cnt=self.call_stack.pop() + rval=stmt.returnValues[0] + rval = str(rval).replace(":", "") + if(cnt==1): + exec(f"self.prg.{rval} = self.call_stack.pop()") + else: + exec(f"self.prg.{rval} = self.call_stack[-{cnt}:]") + self.call_stack=self.call_stack[:-cnt] + + return 1 + + + def handleFunctionReturn(self, stmt, tgt): + + # print(f"Function Return: {stmt}") + # Restore the previous program context + rval_list = [] + cnt=0 + for rval in stmt.returnValues: + cnt=cnt+1 + rval_value = addContext(rval) + exec(f"self.return_value = {rval_value}") + rval_list.append(self.return_value) + self.prg = self.call_stack.pop() + self.pc = self.call_stack.pop() + self.call_stack.extend(rval_list) + self.call_stack.append(cnt) + + return 0 + + # Copying the parameters in their respective placeholders + def handleParametersPassing(self, stmt, tgt): + for param in reversed(stmt.params): + param = str(param).replace(":", "") + param_value = self.call_stack.pop() + setattr(self.prg, param, param_value) + return 1 + + def handleClassDeclaration(self, stmt, tgt): + className = stmt.className.replace(":", "") + attributes = stmt.attributes # List of attribute assignments + + # Handle inheritance if base classes exist + if hasattr(stmt, "baseClasses") and stmt.baseClasses: + base_classes = [base.replace(":", "") for base in stmt.baseClasses] + self.class_hierarchy[className] = base_classes + base_classes_for_def = [getattr(self.class_list, str(b).replace(":", "")) for b in stmt.baseClasses] + base_str = ", ".join([b.__name__ for b in base_classes_for_def]) + class_header = f"class {className}({base_str}):\n" + else: + self.class_hierarchy[className] = [] + class_header = f"class {className}:\n" + + class_def = class_header + init_method = " def __init__(self" # Start of __init__ + init_body = " super().__init__()\n" + + # Handle normal attributes (non-object attributes) + for attr in attributes: + attr, target = attr + attr_name = str(attr.lvar).replace(":", "") + attr_value = addContext(attr.rexpr) if attr.rexpr else "None" + init_body += f" self.{attr_name} = {attr_value}\n" + if className not in self.class_attributes: + self.class_attributes[className] = [] + is_private = attr_name.startswith("__") + self.class_attributes[className].append((attr_name, attr_value, className, is_private)) + + # Handle object attributes + for objectAttr in stmt.objectAttributes: + objectAttr, target = objectAttr + lhs = str(objectAttr.target).replace(":", "") + rhs_classname = addContext(objectAttr.class_name).replace("self.prg.", "") + + init_body += f" self.{lhs} = class_list.{rhs_classname}()\n" + if className not in self.class_attributes: + self.class_attributes[className] = [] + is_private = lhs.startswith("__") + self.class_attributes[className].append((lhs, f"{rhs_classname}()", className, is_private)) + + # init_body += f" self.{lhs} = None\n" + + init_method += "):\n" # Close the __init__ method signature + class_def += init_method + class_def += init_body + + # Step 1: Execute the class definition (store it inside self.class_list) + context = globals().copy() + context["class_list"] = self.class_list + exec(class_def, context,self.class_list.__dict__) + + # self.class_list.__dict__[className] = context[className] + inherited_function_addresses = {} + if stmt.baseClasses: + for function_name, address in self.function_addresses.items(): + class_name, method_name = function_name.split("@") + if class_name in reversed(stmt.baseClasses): + new_function_name = f"{stmt.className}@{method_name}" + inherited_function_addresses[new_function_name] = address + self.function_addresses.update(inherited_function_addresses) + + return 1 + + def handleObjectInstantiation(self, stmt, tgt): + # lhs = str(stmt.target).replace(":", "") + lhs=addContext(str(stmt.target)) + rhs = addContext(stmt.class_name).replace( + "self.prg.", "self.class_list.") + exec(f"{lhs} = {rhs}()") + return 1 + def handleAssignment(self, stmt, tgt): - print(" Assignment Statement") - lhs = str(stmt.lvar).replace(":","") + # print(" Assignment Statement") + # lhs = str(stmt.lvar).replace(":", "") + lhs = addContext(str(stmt.lvar)) + rhs = addContext(stmt.rexpr) - exec("setattr(self.prg,\"%s\",%s)" % (lhs,rhs)) + print(lhs, rhs, "Assignment Statement") + # exec("setattr(self.prg,\"%s\",%s)" % (lhs,rhs)) + exec(f"{lhs} = {rhs}") + return 1 + + def handlePrint(self, stmt, tgt): + # print(" PrintCommand") + expr = addContext(stmt.expr) + print("Executing print with expression:", expr) + exec("print(%s)" % expr) return 1 def handleCondition(self, stmt, tgt): - print(" Branch Instruction") + # print(" Branch Instruction") condstr = addContext(stmt) exec("self.cond_eval = %s" % (condstr)) return 1 if self.cond_eval else tgt def handleMove(self, stmt, tgt): - print(" MoveCommand") - exec("self.trtl.%s(%s)" % (stmt.direction,addContext(stmt.expr))) + # print(" MoveCommand") + exec("self.trtl.%s(%s)" % (stmt.direction, addContext(stmt.expr))) return 1 def handleNoOpCommand(self, stmt, tgt): - print(" No-Op Command") + # print(" No-Op Command") return 1 def handlePen(self, stmt, tgt): - print(" PenCommand") - exec("self.trtl.%s()"%(stmt.status)) + # print(" PenCommand") + exec("self.trtl.%s()" % (stmt.status)) return 1 def handleGotoCommand(self, stmt, tgt): - print(" GotoCommand") + # print(" GotoCommand") xcor = addContext(stmt.xcor) ycor = addContext(stmt.ycor) exec("self.trtl.goto(%s, %s)" % (xcor, ycor)) return 1 + + def get_all_methods(self, class_name): + if class_name not in self.class_hierarchy: + return {} + methods = {} + # Add methods defined in this class first (they override inherited ones) + if class_name in self.class_methods: + for method, arity, is_private in self.class_methods[class_name]: + + methods[(method, arity)] = (class_name, is_private) + + # Add inherited methods from base classes, only for non-private methods + + for base in self.class_hierarchy[class_name]: + + base_methods = self.get_all_methods(base) + + for (method, arity), (defining_class, is_private) in base_methods.items(): + + if not is_private and (method, arity) not in methods: + + methods[(method, arity)] = (defining_class, is_private) + return methods + + def get_all_attributes(self, class_name): + if class_name not in self.class_hierarchy: + return [] + attributes = self.class_attributes.get(class_name, []) + # Add inherited attributes from base classes, avoiding duplicates, only for public attributes + + for base in self.class_hierarchy[class_name]: + + base_attributes = self.get_all_attributes(base) + + for attr_name, attr_value, defining_class, is_private in base_attributes: + + if not is_private and not any(a[0] == attr_name for a in attributes): + + attributes.append((attr_name, attr_value, defining_class, is_private)) + return attributes + + def print_class_hierarchy(self): + dot = Digraph(comment='Class Hierarchy') + dot.attr(rankdir='BT') + + # Generate random colors for each class + import random + for class_name in self.class_hierarchy: + if class_name not in self.class_colors: + self.class_colors[class_name] = "#{:06x}".format(random.randint(0, 0xFFFFFF)) + + for class_name in self.class_hierarchy: + + methods = self.get_all_methods(class_name) + + attributes = self.get_all_attributes(class_name) + + # Include all attributes (public and private) defined in this class + + all_attributes = self.class_attributes.get(class_name, []) + + label = f"<{class_name}
" # Newline after class name + + # Methods first + + for (method, arity), (defining_class, is_private) in sorted(methods.items()): + + class_color = self.class_colors.get(defining_class, "#000000") + + label += f"{method}({arity})
" + + # Blank line + + label += "

" + + # Attributes next (including private from this class) + + for attr_name, attr_value, defining_class, is_private in all_attributes: + class_color = self.class_colors.get(defining_class, "#000000") + label += f"{attr_name} = {attr_value}
" + label += ">" + dot.node(class_name, label=label, shape='record', color=self.class_colors[class_name], style="solid") + + for class_name, bases in self.class_hierarchy.items(): + for base in bases: + dot.edge(base, class_name) + + dot.render('class_hierarchy', format='png', cleanup=True) + self.display_graph('class_hierarchy.png') + + def display_graph(self, image_path): + screen = self.t_screen + root = screen._root + top = tk.Toplevel(root) + top.title("Class Hierarchy Diagram") + img = Image.open(image_path) + photo = ImageTk.PhotoImage(img) + panel = tk.Label(top, image=photo) + panel.pack(side="bottom", fill="both", expand="yes") + panel.image = photo diff --git a/ChironCore/irhandler.py b/ChironCore/irhandler.py index 56e60de..a49c777 100644 --- a/ChironCore/irhandler.py +++ b/ChironCore/irhandler.py @@ -23,7 +23,7 @@ def getParseTree(progfl): print(e.__str__() + "\033[0m\n") exit(1) - return tree + return tree,tparser class IRHandler: diff --git a/ChironCore/optimized.kw b/ChironCore/optimized.kw new file mode 100644 index 0000000..ff8a327 Binary files /dev/null and b/ChironCore/optimized.kw differ diff --git a/ChironCore/test-1.ipynb b/ChironCore/test-1.ipynb new file mode 100644 index 0000000..5136ee1 --- /dev/null +++ b/ChironCore/test-1.ipynb @@ -0,0 +1,62 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 5, + "id": "9b064b62", + "metadata": {}, + "outputs": [], + "source": [ + "import pickle\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "3c5514cd", + "metadata": {}, + "outputs": [ + { + "ename": "FileNotFoundError", + "evalue": "[Errno 2] No such file or directory: 'optimized.kw'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[7], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28;43mopen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43moptimized.kw\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mrb\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mas\u001b[39;00m f:\n\u001b[1;32m 2\u001b[0m ir \u001b[38;5;241m=\u001b[39m pickle\u001b[38;5;241m.\u001b[39mload(f)\n\u001b[1;32m 4\u001b[0m \u001b[38;5;66;03m# You can now inspect `ir`\u001b[39;00m\n", + "File \u001b[0;32m~/Library/Python/3.11/lib/python/site-packages/IPython/core/interactiveshell.py:310\u001b[0m, in \u001b[0;36m_modified_open\u001b[0;34m(file, *args, **kwargs)\u001b[0m\n\u001b[1;32m 303\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m file \u001b[38;5;129;01min\u001b[39;00m {\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m2\u001b[39m}:\n\u001b[1;32m 304\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 305\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mIPython won\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mt let you open fd=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfile\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m by default \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 306\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mas it is likely to crash IPython. If you know what you are doing, \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 307\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124myou can use builtins\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m open.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 308\u001b[0m )\n\u001b[0;32m--> 310\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mio_open\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfile\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'optimized.kw'" + ] + } + ], + "source": [ + "with open(\"optimized.kw\", \"rb\") as f:\n", + " ir = pickle.load(f)\n", + "\n", + "# You can now inspect `ir`\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/ChironCore/test.sh b/ChironCore/test.sh new file mode 100755 index 0000000..8a4625c --- /dev/null +++ b/ChironCore/test.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Step 1: Generate ANTLR files +cd turtparse || exit +java -cp ../extlib/antlr-4.7.2-complete.jar org.antlr.v4.Tool \ + -Dlanguage=Python3 -visitor -no-listener tlang.g4 +cd .. + +# Step 2: Loop through arguments +for path in "$@"; do + if [[ -d "$path" ]]; then + # Argument is a directory: loop over files inside + for file in "$path"/*; do + if [[ -f "$file" ]]; then + echo "Running: $file" + python3 ./chiron.py -r "$file" + pid=$! + + wait "$pid" + fi + done + elif [[ -f "$path" ]]; then + # Argument is a file: run directly + echo "Running: $path" + python3 ./chiron.py -r "$path" + pid=$! + + wait "$pid" + else + echo "Warning: '$path' is not a valid file or directory" + fi +done + diff --git a/ChironCore/turtparse/parseError.py b/ChironCore/turtparse/parseError.py index 48c62ec..ca88ac5 100644 --- a/ChironCore/turtparse/parseError.py +++ b/ChironCore/turtparse/parseError.py @@ -13,8 +13,62 @@ class SyntaxErrorListener(): def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): raise SyntaxException("Syntax Error", (line, column, msg)) - def reportAmbiguity(self): + def reportAmbiguity(self, recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs): + print("Ambiguity detected:") + print(f" Start index: {startIndex}") + print(f" Stop index: {stopIndex}") + print(f" Exact: {exact}") + print(f" Ambiguous alternatives: {ambigAlts}") raise ValueError("Ambiguity error.") - def reportContextSensitivity(self): - raise ValueError("Exit due to context sensitivity.") + + # # Print details about each alternative + # for alt in ambigAlts: + # print(f" Alternative {alt}:") + # for config in configs: + # if config.alt == alt: + # print(f" {self.getConfigDescription(recognizer, config)}") + + def reportAttemptingFullContext(self, recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs): + print("Full context attempt:") + print(f" Start index: {startIndex}") + print(f" Stop index: {stopIndex}") + print(f" Conflicting alternatives: {conflictingAlts}") + + # Print details about each alternative + for alt in conflictingAlts: + print(f" Alternative {alt}:") + for config in configs: + if config.alt == alt: + print(f" {self.getConfigDescription(recognizer, config)}") + + def getConfigDescription(self, recognizer, config): + return (f"(Rule: {recognizer.ruleNames[config.state.ruleIndex]}, " + f"State: {config.state.stateNumber}, " + ) + + + # Add any additional custom error handling or logging as needed + + + + def reportContextSensitivity(self, recognizer, dfa, startIndex, stopIndex, prediction, configs): + # Get the current token + current_token = recognizer.getCurrentToken() + + # Get the rule names + rule_names = recognizer.ruleNames + + # Print basic information + print(f"Context sensitivity detected at token '{current_token.text}' (line {current_token.line}, column {current_token.column})") + + # Print conflicting rules + print("Conflicting rules:") + for config in configs: + rule_index = config.state.ruleIndex + if rule_index >= 0 and rule_index < len(rule_names): + rule_name = rule_names[rule_index] + print(f" - {rule_name}") + + print(f"Predicted alternative: {prediction}") + # raise ValueError("Exit due to context sensitivity.") diff --git a/ChironCore/turtparse/tlang.g4 b/ChironCore/turtparse/tlang.g4 index ff3a2f6..adaf245 100644 --- a/ChironCore/turtparse/tlang.g4 +++ b/ChironCore/turtparse/tlang.g4 @@ -1,37 +1,45 @@ grammar tlang; -start : instruction_list EOF +start : statement_list EOF ; -instruction_list : (instruction)* - ; +statement_list : declaration_list strict_ilist ; -strict_ilist : (instruction)+ +declaration_list : (declaration)* ; + +strict_ilist : (instruction | comment)* ; -instruction : assignment +declaration : classDeclaration + | functionDeclaration + ; + +instruction : + assignment + | printStatement | conditional | loop | moveCommand | penCommand | gotoCommand | pauseCommand + | objectInstantiation + | returnStatement + | functionCall + ; conditional : ifConditional | ifElseConditional ; -ifConditional : 'if' condition '[' strict_ilist ']' ; +ifConditional : 'if' expression '[' strict_ilist ']' ; -ifElseConditional : 'if' condition '[' strict_ilist ']' 'else' '[' strict_ilist ']' ; +ifElseConditional : 'if' expression '[' strict_ilist ']' 'else' '[' strict_ilist ']' ; loop : 'repeat' value '[' strict_ilist ']' ; gotoCommand : 'goto' '(' expression ',' expression ')'; -assignment : VAR '=' expression - ; - moveCommand : moveOp expression ; moveOp : 'forward' | 'backward' | 'left' | 'right' ; @@ -39,40 +47,90 @@ penCommand : 'penup' | 'pendown' ; pauseCommand : 'pause' ; +array + : '[' ( expression ( ',' expression )* )? ']' + ; + +assignment : + lvalue '=' expression + ; + +printStatement : PRINT '(' expression ')' ; + +multiplicative : MUL | DIV; +additive : PLUS | MINUS; + +unaryArithOp : MINUS ; + + + +returnStatement : RETURN ( expression ( ',' expression )* ) ; + expression : unaryArithOp expression #unaryExpr | expression multiplicative expression #mulExpr | expression additive expression #addExpr - | value #valueExpr + | lvalue '=' expression #assignExpr | '(' expression ')' #parenExpr - ; + | value #valueExpr + | NOT expression #notExpr + | expression binCondOp expression #binExpr + | expression logicOp expression #logExpr + | PENCOND #penExpr -multiplicative : MUL | DIV; -additive : PLUS | MINUS; -unaryArithOp : MINUS ; +; -PLUS : '+' ; -MINUS : '-' ; -MUL : '*' ; -DIV : '/' ; +classDeclaration : 'class' VAR ('(' VAR (',' (VAR)*)? ')')? '{' classBody '}' ; + +classBody : (classAttributeDeclaration)* (functionDeclaration)*; +classAttributeDeclaration : assignment | objectInstantiation ; -// TODO : -// procedure_declaration : 'to' NAME (VAR)+ strict_ilist 'end' ; +objectInstantiation : lvalue '=' 'new' VAR '(' ')' ; -condition : NOT condition - |expression binCondOp expression - | condition logicOp condition - | PENCOND - | '(' condition ')' - ; +dataLocationAccess : baseVar ('.' VAR | '[' expression ']')+ ; + +baseVar : VAR ; + +lvalue + : VAR + | dataLocationAccess + ; + +// function call +functionCall : methodCaller NAME '(' arguments ')' ; +methodCaller : (( VAR | dataLocationAccess ) '.')? ; + + +// function declaration +functionDeclaration : 'def' NAME '(' parameters ')' '{' strict_ilist '}' ; + +parameters : ( VAR ( ',' VAR )* )? ; +arguments : ( expression ( ',' expression )* )? ; + + +comment : '#' (NAME)* '#' ; + +logicOp : AND | OR ; binCondOp : EQ | NEQ | LT | GT | LTE | GTE ; -logicOp : AND | OR ; + +PLUS : '+' ; +MINUS : '-' ; +MUL : '*' ; +DIV : '/' ; + +AND: '&&'; +OR : '||'; + +RETURN : 'return' ; + +PRINT : 'print' ; + PENCOND : 'pendown?'; LT : '<' ; @@ -81,18 +139,21 @@ EQ : '=='; NEQ: '!='; LTE: '<='; GTE: '>='; -AND: '&&'; -OR : '||'; + NOT: '!' ; value : NUM | VAR + | array + | dataLocationAccess + | functionCall + | REAL ; NUM : [0-9]+ ; +REAL : [0-9]+('.'[0-9]+)?; +VAR : ':''__'?[a-zA-Z_] [a-zA-Z0-9]* ; -VAR : ':'[a-zA-Z_] [a-zA-Z0-9]* ; - -NAME : [a-zA-Z]+ ; +NAME : '__'?[a-zA-Z]+ ; Whitespace: [ \t\n\r]+ -> skip; diff --git a/ChironCore/turtparse/tlang.interp b/ChironCore/turtparse/tlang.interp index f3cba53..a8e7138 100644 --- a/ChironCore/turtparse/tlang.interp +++ b/ChironCore/turtparse/tlang.interp @@ -9,7 +9,6 @@ null '(' ',' ')' -'=' 'forward' 'backward' 'left' @@ -17,10 +16,22 @@ null 'penup' 'pendown' 'pause' +'=' +'class' +'{' +'}' +'new' +'.' +'def' +'#' '+' '-' '*' '/' +'&&' +'||' +'return' +'print' 'pendown?' '<' '>' @@ -28,13 +39,12 @@ null '!=' '<=' '>=' -'&&' -'||' '!' null null null null +null token symbolic names: null @@ -55,10 +65,21 @@ null null null null +null +null +null +null +null +null +null PLUS MINUS MUL DIV +AND +OR +RETURN +PRINT PENCOND LT GT @@ -66,38 +87,54 @@ EQ NEQ LTE GTE -AND -OR NOT NUM +REAL VAR NAME Whitespace rule names: start -instruction_list +statement_list +declaration_list strict_ilist +declaration instruction conditional ifConditional ifElseConditional loop gotoCommand -assignment moveCommand moveOp penCommand pauseCommand -expression +array +assignment +printStatement multiplicative additive unaryArithOp -condition -binCondOp +returnStatement +expression +classDeclaration +classBody +classAttributeDeclaration +objectInstantiation +dataLocationAccess +baseVar +lvalue +functionCall +methodCaller +functionDeclaration +parameters +arguments +comment logicOp +binCondOp value atn: -[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 37, 175, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 3, 2, 3, 2, 3, 2, 3, 3, 7, 3, 51, 10, 3, 12, 3, 14, 3, 54, 11, 3, 3, 4, 6, 4, 57, 10, 4, 13, 4, 14, 4, 58, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 5, 5, 68, 10, 5, 3, 6, 3, 6, 5, 6, 72, 10, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 5, 16, 125, 10, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 7, 16, 135, 10, 16, 12, 16, 14, 16, 138, 11, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 5, 20, 158, 10, 20, 3, 20, 3, 20, 3, 20, 3, 20, 7, 20, 164, 10, 20, 12, 20, 14, 20, 167, 11, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 2, 4, 30, 38, 24, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 2, 9, 3, 2, 13, 16, 3, 2, 17, 18, 3, 2, 22, 23, 3, 2, 20, 21, 3, 2, 25, 30, 3, 2, 31, 32, 3, 2, 34, 35, 2, 169, 2, 46, 3, 2, 2, 2, 4, 52, 3, 2, 2, 2, 6, 56, 3, 2, 2, 2, 8, 67, 3, 2, 2, 2, 10, 71, 3, 2, 2, 2, 12, 73, 3, 2, 2, 2, 14, 79, 3, 2, 2, 2, 16, 89, 3, 2, 2, 2, 18, 95, 3, 2, 2, 2, 20, 102, 3, 2, 2, 2, 22, 106, 3, 2, 2, 2, 24, 109, 3, 2, 2, 2, 26, 111, 3, 2, 2, 2, 28, 113, 3, 2, 2, 2, 30, 124, 3, 2, 2, 2, 32, 139, 3, 2, 2, 2, 34, 141, 3, 2, 2, 2, 36, 143, 3, 2, 2, 2, 38, 157, 3, 2, 2, 2, 40, 168, 3, 2, 2, 2, 42, 170, 3, 2, 2, 2, 44, 172, 3, 2, 2, 2, 46, 47, 5, 4, 3, 2, 47, 48, 7, 2, 2, 3, 48, 3, 3, 2, 2, 2, 49, 51, 5, 8, 5, 2, 50, 49, 3, 2, 2, 2, 51, 54, 3, 2, 2, 2, 52, 50, 3, 2, 2, 2, 52, 53, 3, 2, 2, 2, 53, 5, 3, 2, 2, 2, 54, 52, 3, 2, 2, 2, 55, 57, 5, 8, 5, 2, 56, 55, 3, 2, 2, 2, 57, 58, 3, 2, 2, 2, 58, 56, 3, 2, 2, 2, 58, 59, 3, 2, 2, 2, 59, 7, 3, 2, 2, 2, 60, 68, 5, 20, 11, 2, 61, 68, 5, 10, 6, 2, 62, 68, 5, 16, 9, 2, 63, 68, 5, 22, 12, 2, 64, 68, 5, 26, 14, 2, 65, 68, 5, 18, 10, 2, 66, 68, 5, 28, 15, 2, 67, 60, 3, 2, 2, 2, 67, 61, 3, 2, 2, 2, 67, 62, 3, 2, 2, 2, 67, 63, 3, 2, 2, 2, 67, 64, 3, 2, 2, 2, 67, 65, 3, 2, 2, 2, 67, 66, 3, 2, 2, 2, 68, 9, 3, 2, 2, 2, 69, 72, 5, 12, 7, 2, 70, 72, 5, 14, 8, 2, 71, 69, 3, 2, 2, 2, 71, 70, 3, 2, 2, 2, 72, 11, 3, 2, 2, 2, 73, 74, 7, 3, 2, 2, 74, 75, 5, 38, 20, 2, 75, 76, 7, 4, 2, 2, 76, 77, 5, 6, 4, 2, 77, 78, 7, 5, 2, 2, 78, 13, 3, 2, 2, 2, 79, 80, 7, 3, 2, 2, 80, 81, 5, 38, 20, 2, 81, 82, 7, 4, 2, 2, 82, 83, 5, 6, 4, 2, 83, 84, 7, 5, 2, 2, 84, 85, 7, 6, 2, 2, 85, 86, 7, 4, 2, 2, 86, 87, 5, 6, 4, 2, 87, 88, 7, 5, 2, 2, 88, 15, 3, 2, 2, 2, 89, 90, 7, 7, 2, 2, 90, 91, 5, 44, 23, 2, 91, 92, 7, 4, 2, 2, 92, 93, 5, 6, 4, 2, 93, 94, 7, 5, 2, 2, 94, 17, 3, 2, 2, 2, 95, 96, 7, 8, 2, 2, 96, 97, 7, 9, 2, 2, 97, 98, 5, 30, 16, 2, 98, 99, 7, 10, 2, 2, 99, 100, 5, 30, 16, 2, 100, 101, 7, 11, 2, 2, 101, 19, 3, 2, 2, 2, 102, 103, 7, 35, 2, 2, 103, 104, 7, 12, 2, 2, 104, 105, 5, 30, 16, 2, 105, 21, 3, 2, 2, 2, 106, 107, 5, 24, 13, 2, 107, 108, 5, 30, 16, 2, 108, 23, 3, 2, 2, 2, 109, 110, 9, 2, 2, 2, 110, 25, 3, 2, 2, 2, 111, 112, 9, 3, 2, 2, 112, 27, 3, 2, 2, 2, 113, 114, 7, 19, 2, 2, 114, 29, 3, 2, 2, 2, 115, 116, 8, 16, 1, 2, 116, 117, 5, 36, 19, 2, 117, 118, 5, 30, 16, 7, 118, 125, 3, 2, 2, 2, 119, 125, 5, 44, 23, 2, 120, 121, 7, 9, 2, 2, 121, 122, 5, 30, 16, 2, 122, 123, 7, 11, 2, 2, 123, 125, 3, 2, 2, 2, 124, 115, 3, 2, 2, 2, 124, 119, 3, 2, 2, 2, 124, 120, 3, 2, 2, 2, 125, 136, 3, 2, 2, 2, 126, 127, 12, 6, 2, 2, 127, 128, 5, 32, 17, 2, 128, 129, 5, 30, 16, 7, 129, 135, 3, 2, 2, 2, 130, 131, 12, 5, 2, 2, 131, 132, 5, 34, 18, 2, 132, 133, 5, 30, 16, 6, 133, 135, 3, 2, 2, 2, 134, 126, 3, 2, 2, 2, 134, 130, 3, 2, 2, 2, 135, 138, 3, 2, 2, 2, 136, 134, 3, 2, 2, 2, 136, 137, 3, 2, 2, 2, 137, 31, 3, 2, 2, 2, 138, 136, 3, 2, 2, 2, 139, 140, 9, 4, 2, 2, 140, 33, 3, 2, 2, 2, 141, 142, 9, 5, 2, 2, 142, 35, 3, 2, 2, 2, 143, 144, 7, 21, 2, 2, 144, 37, 3, 2, 2, 2, 145, 146, 8, 20, 1, 2, 146, 147, 7, 33, 2, 2, 147, 158, 5, 38, 20, 7, 148, 149, 5, 30, 16, 2, 149, 150, 5, 40, 21, 2, 150, 151, 5, 30, 16, 2, 151, 158, 3, 2, 2, 2, 152, 158, 7, 24, 2, 2, 153, 154, 7, 9, 2, 2, 154, 155, 5, 38, 20, 2, 155, 156, 7, 11, 2, 2, 156, 158, 3, 2, 2, 2, 157, 145, 3, 2, 2, 2, 157, 148, 3, 2, 2, 2, 157, 152, 3, 2, 2, 2, 157, 153, 3, 2, 2, 2, 158, 165, 3, 2, 2, 2, 159, 160, 12, 5, 2, 2, 160, 161, 5, 42, 22, 2, 161, 162, 5, 38, 20, 6, 162, 164, 3, 2, 2, 2, 163, 159, 3, 2, 2, 2, 164, 167, 3, 2, 2, 2, 165, 163, 3, 2, 2, 2, 165, 166, 3, 2, 2, 2, 166, 39, 3, 2, 2, 2, 167, 165, 3, 2, 2, 2, 168, 169, 9, 6, 2, 2, 169, 41, 3, 2, 2, 2, 170, 171, 9, 7, 2, 2, 171, 43, 3, 2, 2, 2, 172, 173, 9, 8, 2, 2, 173, 45, 3, 2, 2, 2, 11, 52, 58, 67, 71, 124, 134, 136, 157, 165] \ No newline at end of file +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 47, 364, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 4, 7, 4, 88, 10, 4, 12, 4, 14, 4, 91, 11, 4, 3, 5, 3, 5, 7, 5, 95, 10, 5, 12, 5, 14, 5, 98, 11, 5, 3, 6, 3, 6, 5, 6, 102, 10, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 5, 7, 115, 10, 7, 3, 8, 3, 8, 5, 8, 119, 10, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 7, 17, 163, 10, 17, 12, 17, 14, 17, 166, 11, 17, 5, 17, 168, 10, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 7, 23, 191, 10, 23, 12, 23, 14, 23, 194, 11, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 5, 24, 212, 10, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 7, 24, 230, 10, 24, 12, 24, 14, 24, 233, 11, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 7, 25, 241, 10, 25, 12, 25, 14, 25, 244, 11, 25, 5, 25, 246, 10, 25, 3, 25, 5, 25, 249, 10, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 7, 26, 256, 10, 26, 12, 26, 14, 26, 259, 11, 26, 3, 26, 7, 26, 262, 10, 26, 12, 26, 14, 26, 265, 11, 26, 3, 27, 3, 27, 5, 27, 269, 10, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 6, 29, 285, 10, 29, 13, 29, 14, 29, 286, 3, 30, 3, 30, 3, 31, 3, 31, 5, 31, 293, 10, 31, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 5, 33, 306, 10, 33, 3, 33, 7, 33, 309, 10, 33, 12, 33, 14, 33, 312, 11, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 7, 35, 326, 10, 35, 12, 35, 14, 35, 329, 11, 35, 5, 35, 331, 10, 35, 3, 36, 3, 36, 3, 36, 7, 36, 336, 10, 36, 12, 36, 14, 36, 339, 11, 36, 5, 36, 341, 10, 36, 3, 37, 3, 37, 7, 37, 345, 10, 37, 12, 37, 14, 37, 348, 11, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 39, 3, 39, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 5, 40, 362, 10, 40, 3, 40, 2, 3, 46, 41, 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, 2, 8, 3, 2, 12, 15, 3, 2, 16, 17, 3, 2, 29, 30, 3, 2, 27, 28, 3, 2, 31, 32, 3, 2, 36, 41, 2, 372, 2, 80, 3, 2, 2, 2, 4, 83, 3, 2, 2, 2, 6, 89, 3, 2, 2, 2, 8, 96, 3, 2, 2, 2, 10, 101, 3, 2, 2, 2, 12, 114, 3, 2, 2, 2, 14, 118, 3, 2, 2, 2, 16, 120, 3, 2, 2, 2, 18, 126, 3, 2, 2, 2, 20, 136, 3, 2, 2, 2, 22, 142, 3, 2, 2, 2, 24, 149, 3, 2, 2, 2, 26, 152, 3, 2, 2, 2, 28, 154, 3, 2, 2, 2, 30, 156, 3, 2, 2, 2, 32, 158, 3, 2, 2, 2, 34, 171, 3, 2, 2, 2, 36, 175, 3, 2, 2, 2, 38, 180, 3, 2, 2, 2, 40, 182, 3, 2, 2, 2, 42, 184, 3, 2, 2, 2, 44, 186, 3, 2, 2, 2, 46, 211, 3, 2, 2, 2, 48, 234, 3, 2, 2, 2, 50, 257, 3, 2, 2, 2, 52, 268, 3, 2, 2, 2, 54, 270, 3, 2, 2, 2, 56, 277, 3, 2, 2, 2, 58, 288, 3, 2, 2, 2, 60, 292, 3, 2, 2, 2, 62, 294, 3, 2, 2, 2, 64, 310, 3, 2, 2, 2, 66, 313, 3, 2, 2, 2, 68, 330, 3, 2, 2, 2, 70, 340, 3, 2, 2, 2, 72, 342, 3, 2, 2, 2, 74, 351, 3, 2, 2, 2, 76, 353, 3, 2, 2, 2, 78, 361, 3, 2, 2, 2, 80, 81, 5, 4, 3, 2, 81, 82, 7, 2, 2, 3, 82, 3, 3, 2, 2, 2, 83, 84, 5, 6, 4, 2, 84, 85, 5, 8, 5, 2, 85, 5, 3, 2, 2, 2, 86, 88, 5, 10, 6, 2, 87, 86, 3, 2, 2, 2, 88, 91, 3, 2, 2, 2, 89, 87, 3, 2, 2, 2, 89, 90, 3, 2, 2, 2, 90, 7, 3, 2, 2, 2, 91, 89, 3, 2, 2, 2, 92, 95, 5, 12, 7, 2, 93, 95, 5, 72, 37, 2, 94, 92, 3, 2, 2, 2, 94, 93, 3, 2, 2, 2, 95, 98, 3, 2, 2, 2, 96, 94, 3, 2, 2, 2, 96, 97, 3, 2, 2, 2, 97, 9, 3, 2, 2, 2, 98, 96, 3, 2, 2, 2, 99, 102, 5, 48, 25, 2, 100, 102, 5, 66, 34, 2, 101, 99, 3, 2, 2, 2, 101, 100, 3, 2, 2, 2, 102, 11, 3, 2, 2, 2, 103, 115, 5, 34, 18, 2, 104, 115, 5, 36, 19, 2, 105, 115, 5, 14, 8, 2, 106, 115, 5, 20, 11, 2, 107, 115, 5, 24, 13, 2, 108, 115, 5, 28, 15, 2, 109, 115, 5, 22, 12, 2, 110, 115, 5, 30, 16, 2, 111, 115, 5, 54, 28, 2, 112, 115, 5, 44, 23, 2, 113, 115, 5, 62, 32, 2, 114, 103, 3, 2, 2, 2, 114, 104, 3, 2, 2, 2, 114, 105, 3, 2, 2, 2, 114, 106, 3, 2, 2, 2, 114, 107, 3, 2, 2, 2, 114, 108, 3, 2, 2, 2, 114, 109, 3, 2, 2, 2, 114, 110, 3, 2, 2, 2, 114, 111, 3, 2, 2, 2, 114, 112, 3, 2, 2, 2, 114, 113, 3, 2, 2, 2, 115, 13, 3, 2, 2, 2, 116, 119, 5, 16, 9, 2, 117, 119, 5, 18, 10, 2, 118, 116, 3, 2, 2, 2, 118, 117, 3, 2, 2, 2, 119, 15, 3, 2, 2, 2, 120, 121, 7, 3, 2, 2, 121, 122, 5, 46, 24, 2, 122, 123, 7, 4, 2, 2, 123, 124, 5, 8, 5, 2, 124, 125, 7, 5, 2, 2, 125, 17, 3, 2, 2, 2, 126, 127, 7, 3, 2, 2, 127, 128, 5, 46, 24, 2, 128, 129, 7, 4, 2, 2, 129, 130, 5, 8, 5, 2, 130, 131, 7, 5, 2, 2, 131, 132, 7, 6, 2, 2, 132, 133, 7, 4, 2, 2, 133, 134, 5, 8, 5, 2, 134, 135, 7, 5, 2, 2, 135, 19, 3, 2, 2, 2, 136, 137, 7, 7, 2, 2, 137, 138, 5, 78, 40, 2, 138, 139, 7, 4, 2, 2, 139, 140, 5, 8, 5, 2, 140, 141, 7, 5, 2, 2, 141, 21, 3, 2, 2, 2, 142, 143, 7, 8, 2, 2, 143, 144, 7, 9, 2, 2, 144, 145, 5, 46, 24, 2, 145, 146, 7, 10, 2, 2, 146, 147, 5, 46, 24, 2, 147, 148, 7, 11, 2, 2, 148, 23, 3, 2, 2, 2, 149, 150, 5, 26, 14, 2, 150, 151, 5, 46, 24, 2, 151, 25, 3, 2, 2, 2, 152, 153, 9, 2, 2, 2, 153, 27, 3, 2, 2, 2, 154, 155, 9, 3, 2, 2, 155, 29, 3, 2, 2, 2, 156, 157, 7, 18, 2, 2, 157, 31, 3, 2, 2, 2, 158, 167, 7, 4, 2, 2, 159, 164, 5, 46, 24, 2, 160, 161, 7, 10, 2, 2, 161, 163, 5, 46, 24, 2, 162, 160, 3, 2, 2, 2, 163, 166, 3, 2, 2, 2, 164, 162, 3, 2, 2, 2, 164, 165, 3, 2, 2, 2, 165, 168, 3, 2, 2, 2, 166, 164, 3, 2, 2, 2, 167, 159, 3, 2, 2, 2, 167, 168, 3, 2, 2, 2, 168, 169, 3, 2, 2, 2, 169, 170, 7, 5, 2, 2, 170, 33, 3, 2, 2, 2, 171, 172, 5, 60, 31, 2, 172, 173, 7, 19, 2, 2, 173, 174, 5, 46, 24, 2, 174, 35, 3, 2, 2, 2, 175, 176, 7, 34, 2, 2, 176, 177, 7, 9, 2, 2, 177, 178, 5, 46, 24, 2, 178, 179, 7, 11, 2, 2, 179, 37, 3, 2, 2, 2, 180, 181, 9, 4, 2, 2, 181, 39, 3, 2, 2, 2, 182, 183, 9, 5, 2, 2, 183, 41, 3, 2, 2, 2, 184, 185, 7, 28, 2, 2, 185, 43, 3, 2, 2, 2, 186, 187, 7, 33, 2, 2, 187, 192, 5, 46, 24, 2, 188, 189, 7, 10, 2, 2, 189, 191, 5, 46, 24, 2, 190, 188, 3, 2, 2, 2, 191, 194, 3, 2, 2, 2, 192, 190, 3, 2, 2, 2, 192, 193, 3, 2, 2, 2, 193, 45, 3, 2, 2, 2, 194, 192, 3, 2, 2, 2, 195, 196, 8, 24, 1, 2, 196, 197, 5, 42, 22, 2, 197, 198, 5, 46, 24, 12, 198, 212, 3, 2, 2, 2, 199, 200, 5, 60, 31, 2, 200, 201, 7, 19, 2, 2, 201, 202, 5, 46, 24, 9, 202, 212, 3, 2, 2, 2, 203, 204, 7, 9, 2, 2, 204, 205, 5, 46, 24, 2, 205, 206, 7, 11, 2, 2, 206, 212, 3, 2, 2, 2, 207, 212, 5, 78, 40, 2, 208, 209, 7, 42, 2, 2, 209, 212, 5, 46, 24, 6, 210, 212, 7, 35, 2, 2, 211, 195, 3, 2, 2, 2, 211, 199, 3, 2, 2, 2, 211, 203, 3, 2, 2, 2, 211, 207, 3, 2, 2, 2, 211, 208, 3, 2, 2, 2, 211, 210, 3, 2, 2, 2, 212, 231, 3, 2, 2, 2, 213, 214, 12, 11, 2, 2, 214, 215, 5, 38, 20, 2, 215, 216, 5, 46, 24, 12, 216, 230, 3, 2, 2, 2, 217, 218, 12, 10, 2, 2, 218, 219, 5, 40, 21, 2, 219, 220, 5, 46, 24, 11, 220, 230, 3, 2, 2, 2, 221, 222, 12, 5, 2, 2, 222, 223, 5, 76, 39, 2, 223, 224, 5, 46, 24, 6, 224, 230, 3, 2, 2, 2, 225, 226, 12, 4, 2, 2, 226, 227, 5, 74, 38, 2, 227, 228, 5, 46, 24, 5, 228, 230, 3, 2, 2, 2, 229, 213, 3, 2, 2, 2, 229, 217, 3, 2, 2, 2, 229, 221, 3, 2, 2, 2, 229, 225, 3, 2, 2, 2, 230, 233, 3, 2, 2, 2, 231, 229, 3, 2, 2, 2, 231, 232, 3, 2, 2, 2, 232, 47, 3, 2, 2, 2, 233, 231, 3, 2, 2, 2, 234, 235, 7, 20, 2, 2, 235, 248, 7, 45, 2, 2, 236, 237, 7, 9, 2, 2, 237, 245, 7, 45, 2, 2, 238, 242, 7, 10, 2, 2, 239, 241, 7, 45, 2, 2, 240, 239, 3, 2, 2, 2, 241, 244, 3, 2, 2, 2, 242, 240, 3, 2, 2, 2, 242, 243, 3, 2, 2, 2, 243, 246, 3, 2, 2, 2, 244, 242, 3, 2, 2, 2, 245, 238, 3, 2, 2, 2, 245, 246, 3, 2, 2, 2, 246, 247, 3, 2, 2, 2, 247, 249, 7, 11, 2, 2, 248, 236, 3, 2, 2, 2, 248, 249, 3, 2, 2, 2, 249, 250, 3, 2, 2, 2, 250, 251, 7, 21, 2, 2, 251, 252, 5, 50, 26, 2, 252, 253, 7, 22, 2, 2, 253, 49, 3, 2, 2, 2, 254, 256, 5, 52, 27, 2, 255, 254, 3, 2, 2, 2, 256, 259, 3, 2, 2, 2, 257, 255, 3, 2, 2, 2, 257, 258, 3, 2, 2, 2, 258, 263, 3, 2, 2, 2, 259, 257, 3, 2, 2, 2, 260, 262, 5, 66, 34, 2, 261, 260, 3, 2, 2, 2, 262, 265, 3, 2, 2, 2, 263, 261, 3, 2, 2, 2, 263, 264, 3, 2, 2, 2, 264, 51, 3, 2, 2, 2, 265, 263, 3, 2, 2, 2, 266, 269, 5, 34, 18, 2, 267, 269, 5, 54, 28, 2, 268, 266, 3, 2, 2, 2, 268, 267, 3, 2, 2, 2, 269, 53, 3, 2, 2, 2, 270, 271, 5, 60, 31, 2, 271, 272, 7, 19, 2, 2, 272, 273, 7, 23, 2, 2, 273, 274, 7, 45, 2, 2, 274, 275, 7, 9, 2, 2, 275, 276, 7, 11, 2, 2, 276, 55, 3, 2, 2, 2, 277, 284, 5, 58, 30, 2, 278, 279, 7, 24, 2, 2, 279, 285, 7, 45, 2, 2, 280, 281, 7, 4, 2, 2, 281, 282, 5, 46, 24, 2, 282, 283, 7, 5, 2, 2, 283, 285, 3, 2, 2, 2, 284, 278, 3, 2, 2, 2, 284, 280, 3, 2, 2, 2, 285, 286, 3, 2, 2, 2, 286, 284, 3, 2, 2, 2, 286, 287, 3, 2, 2, 2, 287, 57, 3, 2, 2, 2, 288, 289, 7, 45, 2, 2, 289, 59, 3, 2, 2, 2, 290, 293, 7, 45, 2, 2, 291, 293, 5, 56, 29, 2, 292, 290, 3, 2, 2, 2, 292, 291, 3, 2, 2, 2, 293, 61, 3, 2, 2, 2, 294, 295, 5, 64, 33, 2, 295, 296, 7, 46, 2, 2, 296, 297, 7, 9, 2, 2, 297, 298, 5, 70, 36, 2, 298, 299, 7, 11, 2, 2, 299, 63, 3, 2, 2, 2, 300, 306, 7, 45, 2, 2, 301, 302, 7, 4, 2, 2, 302, 303, 5, 46, 24, 2, 303, 304, 7, 5, 2, 2, 304, 306, 3, 2, 2, 2, 305, 300, 3, 2, 2, 2, 305, 301, 3, 2, 2, 2, 306, 307, 3, 2, 2, 2, 307, 309, 7, 24, 2, 2, 308, 305, 3, 2, 2, 2, 309, 312, 3, 2, 2, 2, 310, 308, 3, 2, 2, 2, 310, 311, 3, 2, 2, 2, 311, 65, 3, 2, 2, 2, 312, 310, 3, 2, 2, 2, 313, 314, 7, 25, 2, 2, 314, 315, 7, 46, 2, 2, 315, 316, 7, 9, 2, 2, 316, 317, 5, 68, 35, 2, 317, 318, 7, 11, 2, 2, 318, 319, 7, 21, 2, 2, 319, 320, 5, 8, 5, 2, 320, 321, 7, 22, 2, 2, 321, 67, 3, 2, 2, 2, 322, 327, 7, 45, 2, 2, 323, 324, 7, 10, 2, 2, 324, 326, 7, 45, 2, 2, 325, 323, 3, 2, 2, 2, 326, 329, 3, 2, 2, 2, 327, 325, 3, 2, 2, 2, 327, 328, 3, 2, 2, 2, 328, 331, 3, 2, 2, 2, 329, 327, 3, 2, 2, 2, 330, 322, 3, 2, 2, 2, 330, 331, 3, 2, 2, 2, 331, 69, 3, 2, 2, 2, 332, 337, 5, 46, 24, 2, 333, 334, 7, 10, 2, 2, 334, 336, 5, 46, 24, 2, 335, 333, 3, 2, 2, 2, 336, 339, 3, 2, 2, 2, 337, 335, 3, 2, 2, 2, 337, 338, 3, 2, 2, 2, 338, 341, 3, 2, 2, 2, 339, 337, 3, 2, 2, 2, 340, 332, 3, 2, 2, 2, 340, 341, 3, 2, 2, 2, 341, 71, 3, 2, 2, 2, 342, 346, 7, 26, 2, 2, 343, 345, 7, 46, 2, 2, 344, 343, 3, 2, 2, 2, 345, 348, 3, 2, 2, 2, 346, 344, 3, 2, 2, 2, 346, 347, 3, 2, 2, 2, 347, 349, 3, 2, 2, 2, 348, 346, 3, 2, 2, 2, 349, 350, 7, 26, 2, 2, 350, 73, 3, 2, 2, 2, 351, 352, 9, 6, 2, 2, 352, 75, 3, 2, 2, 2, 353, 354, 9, 7, 2, 2, 354, 77, 3, 2, 2, 2, 355, 362, 7, 43, 2, 2, 356, 362, 7, 45, 2, 2, 357, 362, 5, 32, 17, 2, 358, 362, 5, 56, 29, 2, 359, 362, 5, 62, 32, 2, 360, 362, 7, 44, 2, 2, 361, 355, 3, 2, 2, 2, 361, 356, 3, 2, 2, 2, 361, 357, 3, 2, 2, 2, 361, 358, 3, 2, 2, 2, 361, 359, 3, 2, 2, 2, 361, 360, 3, 2, 2, 2, 362, 79, 3, 2, 2, 2, 31, 89, 94, 96, 101, 114, 118, 164, 167, 192, 211, 229, 231, 242, 245, 248, 257, 263, 268, 284, 286, 292, 305, 310, 327, 330, 337, 340, 346, 361] \ No newline at end of file diff --git a/ChironCore/turtparse/tlang.tokens b/ChironCore/turtparse/tlang.tokens index 78f9526..feb2c1e 100644 --- a/ChironCore/turtparse/tlang.tokens +++ b/ChironCore/turtparse/tlang.tokens @@ -15,24 +15,34 @@ T__13=14 T__14=15 T__15=16 T__16=17 -PLUS=18 -MINUS=19 -MUL=20 -DIV=21 -PENCOND=22 -LT=23 -GT=24 -EQ=25 -NEQ=26 -LTE=27 -GTE=28 +T__17=18 +T__18=19 +T__19=20 +T__20=21 +T__21=22 +T__22=23 +T__23=24 +PLUS=25 +MINUS=26 +MUL=27 +DIV=28 AND=29 OR=30 -NOT=31 -NUM=32 -VAR=33 -NAME=34 -Whitespace=35 +RETURN=31 +PRINT=32 +PENCOND=33 +LT=34 +GT=35 +EQ=36 +NEQ=37 +LTE=38 +GTE=39 +NOT=40 +NUM=41 +REAL=42 +VAR=43 +NAME=44 +Whitespace=45 'if'=1 '['=2 ']'=3 @@ -42,25 +52,34 @@ Whitespace=35 '('=7 ','=8 ')'=9 -'='=10 -'forward'=11 -'backward'=12 -'left'=13 -'right'=14 -'penup'=15 -'pendown'=16 -'pause'=17 -'+'=18 -'-'=19 -'*'=20 -'/'=21 -'pendown?'=22 -'<'=23 -'>'=24 -'=='=25 -'!='=26 -'<='=27 -'>='=28 +'forward'=10 +'backward'=11 +'left'=12 +'right'=13 +'penup'=14 +'pendown'=15 +'pause'=16 +'='=17 +'class'=18 +'{'=19 +'}'=20 +'new'=21 +'.'=22 +'def'=23 +'#'=24 +'+'=25 +'-'=26 +'*'=27 +'/'=28 '&&'=29 '||'=30 -'!'=31 +'return'=31 +'print'=32 +'pendown?'=33 +'<'=34 +'>'=35 +'=='=36 +'!='=37 +'<='=38 +'>='=39 +'!'=40 diff --git a/ChironCore/turtparse/tlangLexer.interp b/ChironCore/turtparse/tlangLexer.interp index 106eae4..895e42b 100644 --- a/ChironCore/turtparse/tlangLexer.interp +++ b/ChironCore/turtparse/tlangLexer.interp @@ -9,7 +9,6 @@ null '(' ',' ')' -'=' 'forward' 'backward' 'left' @@ -17,10 +16,22 @@ null 'penup' 'pendown' 'pause' +'=' +'class' +'{' +'}' +'new' +'.' +'def' +'#' '+' '-' '*' '/' +'&&' +'||' +'return' +'print' 'pendown?' '<' '>' @@ -28,13 +39,12 @@ null '!=' '<=' '>=' -'&&' -'||' '!' null null null null +null token symbolic names: null @@ -55,10 +65,21 @@ null null null null +null +null +null +null +null +null +null PLUS MINUS MUL DIV +AND +OR +RETURN +PRINT PENCOND LT GT @@ -66,10 +87,9 @@ EQ NEQ LTE GTE -AND -OR NOT NUM +REAL VAR NAME Whitespace @@ -92,10 +112,21 @@ T__13 T__14 T__15 T__16 +T__17 +T__18 +T__19 +T__20 +T__21 +T__22 +T__23 PLUS MINUS MUL DIV +AND +OR +RETURN +PRINT PENCOND LT GT @@ -103,10 +134,9 @@ EQ NEQ LTE GTE -AND -OR NOT NUM +REAL VAR NAME Whitespace @@ -119,4 +149,4 @@ mode names: DEFAULT_MODE atn: -[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 37, 219, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 33, 6, 33, 196, 10, 33, 13, 33, 14, 33, 197, 3, 34, 3, 34, 3, 34, 7, 34, 203, 10, 34, 12, 34, 14, 34, 206, 11, 34, 3, 35, 6, 35, 209, 10, 35, 13, 35, 14, 35, 210, 3, 36, 6, 36, 214, 10, 36, 13, 36, 14, 36, 215, 3, 36, 3, 36, 2, 2, 37, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 3, 2, 7, 3, 2, 50, 59, 5, 2, 67, 92, 97, 97, 99, 124, 5, 2, 50, 59, 67, 92, 99, 124, 4, 2, 67, 92, 99, 124, 5, 2, 11, 12, 15, 15, 34, 34, 2, 222, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 3, 73, 3, 2, 2, 2, 5, 76, 3, 2, 2, 2, 7, 78, 3, 2, 2, 2, 9, 80, 3, 2, 2, 2, 11, 85, 3, 2, 2, 2, 13, 92, 3, 2, 2, 2, 15, 97, 3, 2, 2, 2, 17, 99, 3, 2, 2, 2, 19, 101, 3, 2, 2, 2, 21, 103, 3, 2, 2, 2, 23, 105, 3, 2, 2, 2, 25, 113, 3, 2, 2, 2, 27, 122, 3, 2, 2, 2, 29, 127, 3, 2, 2, 2, 31, 133, 3, 2, 2, 2, 33, 139, 3, 2, 2, 2, 35, 147, 3, 2, 2, 2, 37, 153, 3, 2, 2, 2, 39, 155, 3, 2, 2, 2, 41, 157, 3, 2, 2, 2, 43, 159, 3, 2, 2, 2, 45, 161, 3, 2, 2, 2, 47, 170, 3, 2, 2, 2, 49, 172, 3, 2, 2, 2, 51, 174, 3, 2, 2, 2, 53, 177, 3, 2, 2, 2, 55, 180, 3, 2, 2, 2, 57, 183, 3, 2, 2, 2, 59, 186, 3, 2, 2, 2, 61, 189, 3, 2, 2, 2, 63, 192, 3, 2, 2, 2, 65, 195, 3, 2, 2, 2, 67, 199, 3, 2, 2, 2, 69, 208, 3, 2, 2, 2, 71, 213, 3, 2, 2, 2, 73, 74, 7, 107, 2, 2, 74, 75, 7, 104, 2, 2, 75, 4, 3, 2, 2, 2, 76, 77, 7, 93, 2, 2, 77, 6, 3, 2, 2, 2, 78, 79, 7, 95, 2, 2, 79, 8, 3, 2, 2, 2, 80, 81, 7, 103, 2, 2, 81, 82, 7, 110, 2, 2, 82, 83, 7, 117, 2, 2, 83, 84, 7, 103, 2, 2, 84, 10, 3, 2, 2, 2, 85, 86, 7, 116, 2, 2, 86, 87, 7, 103, 2, 2, 87, 88, 7, 114, 2, 2, 88, 89, 7, 103, 2, 2, 89, 90, 7, 99, 2, 2, 90, 91, 7, 118, 2, 2, 91, 12, 3, 2, 2, 2, 92, 93, 7, 105, 2, 2, 93, 94, 7, 113, 2, 2, 94, 95, 7, 118, 2, 2, 95, 96, 7, 113, 2, 2, 96, 14, 3, 2, 2, 2, 97, 98, 7, 42, 2, 2, 98, 16, 3, 2, 2, 2, 99, 100, 7, 46, 2, 2, 100, 18, 3, 2, 2, 2, 101, 102, 7, 43, 2, 2, 102, 20, 3, 2, 2, 2, 103, 104, 7, 63, 2, 2, 104, 22, 3, 2, 2, 2, 105, 106, 7, 104, 2, 2, 106, 107, 7, 113, 2, 2, 107, 108, 7, 116, 2, 2, 108, 109, 7, 121, 2, 2, 109, 110, 7, 99, 2, 2, 110, 111, 7, 116, 2, 2, 111, 112, 7, 102, 2, 2, 112, 24, 3, 2, 2, 2, 113, 114, 7, 100, 2, 2, 114, 115, 7, 99, 2, 2, 115, 116, 7, 101, 2, 2, 116, 117, 7, 109, 2, 2, 117, 118, 7, 121, 2, 2, 118, 119, 7, 99, 2, 2, 119, 120, 7, 116, 2, 2, 120, 121, 7, 102, 2, 2, 121, 26, 3, 2, 2, 2, 122, 123, 7, 110, 2, 2, 123, 124, 7, 103, 2, 2, 124, 125, 7, 104, 2, 2, 125, 126, 7, 118, 2, 2, 126, 28, 3, 2, 2, 2, 127, 128, 7, 116, 2, 2, 128, 129, 7, 107, 2, 2, 129, 130, 7, 105, 2, 2, 130, 131, 7, 106, 2, 2, 131, 132, 7, 118, 2, 2, 132, 30, 3, 2, 2, 2, 133, 134, 7, 114, 2, 2, 134, 135, 7, 103, 2, 2, 135, 136, 7, 112, 2, 2, 136, 137, 7, 119, 2, 2, 137, 138, 7, 114, 2, 2, 138, 32, 3, 2, 2, 2, 139, 140, 7, 114, 2, 2, 140, 141, 7, 103, 2, 2, 141, 142, 7, 112, 2, 2, 142, 143, 7, 102, 2, 2, 143, 144, 7, 113, 2, 2, 144, 145, 7, 121, 2, 2, 145, 146, 7, 112, 2, 2, 146, 34, 3, 2, 2, 2, 147, 148, 7, 114, 2, 2, 148, 149, 7, 99, 2, 2, 149, 150, 7, 119, 2, 2, 150, 151, 7, 117, 2, 2, 151, 152, 7, 103, 2, 2, 152, 36, 3, 2, 2, 2, 153, 154, 7, 45, 2, 2, 154, 38, 3, 2, 2, 2, 155, 156, 7, 47, 2, 2, 156, 40, 3, 2, 2, 2, 157, 158, 7, 44, 2, 2, 158, 42, 3, 2, 2, 2, 159, 160, 7, 49, 2, 2, 160, 44, 3, 2, 2, 2, 161, 162, 7, 114, 2, 2, 162, 163, 7, 103, 2, 2, 163, 164, 7, 112, 2, 2, 164, 165, 7, 102, 2, 2, 165, 166, 7, 113, 2, 2, 166, 167, 7, 121, 2, 2, 167, 168, 7, 112, 2, 2, 168, 169, 7, 65, 2, 2, 169, 46, 3, 2, 2, 2, 170, 171, 7, 62, 2, 2, 171, 48, 3, 2, 2, 2, 172, 173, 7, 64, 2, 2, 173, 50, 3, 2, 2, 2, 174, 175, 7, 63, 2, 2, 175, 176, 7, 63, 2, 2, 176, 52, 3, 2, 2, 2, 177, 178, 7, 35, 2, 2, 178, 179, 7, 63, 2, 2, 179, 54, 3, 2, 2, 2, 180, 181, 7, 62, 2, 2, 181, 182, 7, 63, 2, 2, 182, 56, 3, 2, 2, 2, 183, 184, 7, 64, 2, 2, 184, 185, 7, 63, 2, 2, 185, 58, 3, 2, 2, 2, 186, 187, 7, 40, 2, 2, 187, 188, 7, 40, 2, 2, 188, 60, 3, 2, 2, 2, 189, 190, 7, 126, 2, 2, 190, 191, 7, 126, 2, 2, 191, 62, 3, 2, 2, 2, 192, 193, 7, 35, 2, 2, 193, 64, 3, 2, 2, 2, 194, 196, 9, 2, 2, 2, 195, 194, 3, 2, 2, 2, 196, 197, 3, 2, 2, 2, 197, 195, 3, 2, 2, 2, 197, 198, 3, 2, 2, 2, 198, 66, 3, 2, 2, 2, 199, 200, 7, 60, 2, 2, 200, 204, 9, 3, 2, 2, 201, 203, 9, 4, 2, 2, 202, 201, 3, 2, 2, 2, 203, 206, 3, 2, 2, 2, 204, 202, 3, 2, 2, 2, 204, 205, 3, 2, 2, 2, 205, 68, 3, 2, 2, 2, 206, 204, 3, 2, 2, 2, 207, 209, 9, 5, 2, 2, 208, 207, 3, 2, 2, 2, 209, 210, 3, 2, 2, 2, 210, 208, 3, 2, 2, 2, 210, 211, 3, 2, 2, 2, 211, 70, 3, 2, 2, 2, 212, 214, 9, 6, 2, 2, 213, 212, 3, 2, 2, 2, 214, 215, 3, 2, 2, 2, 215, 213, 3, 2, 2, 2, 215, 216, 3, 2, 2, 2, 216, 217, 3, 2, 2, 2, 217, 218, 8, 36, 2, 2, 218, 72, 3, 2, 2, 2, 7, 2, 197, 204, 210, 215, 3, 8, 2, 2] \ No newline at end of file +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 47, 295, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 27, 3, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 39, 3, 40, 3, 40, 3, 40, 3, 41, 3, 41, 3, 42, 6, 42, 251, 10, 42, 13, 42, 14, 42, 252, 3, 43, 6, 43, 256, 10, 43, 13, 43, 14, 43, 257, 3, 43, 3, 43, 6, 43, 262, 10, 43, 13, 43, 14, 43, 263, 5, 43, 266, 10, 43, 3, 44, 3, 44, 3, 44, 5, 44, 271, 10, 44, 3, 44, 3, 44, 7, 44, 275, 10, 44, 12, 44, 14, 44, 278, 11, 44, 3, 45, 3, 45, 5, 45, 282, 10, 45, 3, 45, 6, 45, 285, 10, 45, 13, 45, 14, 45, 286, 3, 46, 6, 46, 290, 10, 46, 13, 46, 14, 46, 291, 3, 46, 3, 46, 2, 2, 47, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 77, 40, 79, 41, 81, 42, 83, 43, 85, 44, 87, 45, 89, 46, 91, 47, 3, 2, 7, 3, 2, 50, 59, 5, 2, 67, 92, 97, 97, 99, 124, 5, 2, 50, 59, 67, 92, 99, 124, 4, 2, 67, 92, 99, 124, 5, 2, 11, 12, 15, 15, 34, 34, 2, 303, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 2, 85, 3, 2, 2, 2, 2, 87, 3, 2, 2, 2, 2, 89, 3, 2, 2, 2, 2, 91, 3, 2, 2, 2, 3, 93, 3, 2, 2, 2, 5, 96, 3, 2, 2, 2, 7, 98, 3, 2, 2, 2, 9, 100, 3, 2, 2, 2, 11, 105, 3, 2, 2, 2, 13, 112, 3, 2, 2, 2, 15, 117, 3, 2, 2, 2, 17, 119, 3, 2, 2, 2, 19, 121, 3, 2, 2, 2, 21, 123, 3, 2, 2, 2, 23, 131, 3, 2, 2, 2, 25, 140, 3, 2, 2, 2, 27, 145, 3, 2, 2, 2, 29, 151, 3, 2, 2, 2, 31, 157, 3, 2, 2, 2, 33, 165, 3, 2, 2, 2, 35, 171, 3, 2, 2, 2, 37, 173, 3, 2, 2, 2, 39, 179, 3, 2, 2, 2, 41, 181, 3, 2, 2, 2, 43, 183, 3, 2, 2, 2, 45, 187, 3, 2, 2, 2, 47, 189, 3, 2, 2, 2, 49, 193, 3, 2, 2, 2, 51, 195, 3, 2, 2, 2, 53, 197, 3, 2, 2, 2, 55, 199, 3, 2, 2, 2, 57, 201, 3, 2, 2, 2, 59, 203, 3, 2, 2, 2, 61, 206, 3, 2, 2, 2, 63, 209, 3, 2, 2, 2, 65, 216, 3, 2, 2, 2, 67, 222, 3, 2, 2, 2, 69, 231, 3, 2, 2, 2, 71, 233, 3, 2, 2, 2, 73, 235, 3, 2, 2, 2, 75, 238, 3, 2, 2, 2, 77, 241, 3, 2, 2, 2, 79, 244, 3, 2, 2, 2, 81, 247, 3, 2, 2, 2, 83, 250, 3, 2, 2, 2, 85, 255, 3, 2, 2, 2, 87, 267, 3, 2, 2, 2, 89, 281, 3, 2, 2, 2, 91, 289, 3, 2, 2, 2, 93, 94, 7, 107, 2, 2, 94, 95, 7, 104, 2, 2, 95, 4, 3, 2, 2, 2, 96, 97, 7, 93, 2, 2, 97, 6, 3, 2, 2, 2, 98, 99, 7, 95, 2, 2, 99, 8, 3, 2, 2, 2, 100, 101, 7, 103, 2, 2, 101, 102, 7, 110, 2, 2, 102, 103, 7, 117, 2, 2, 103, 104, 7, 103, 2, 2, 104, 10, 3, 2, 2, 2, 105, 106, 7, 116, 2, 2, 106, 107, 7, 103, 2, 2, 107, 108, 7, 114, 2, 2, 108, 109, 7, 103, 2, 2, 109, 110, 7, 99, 2, 2, 110, 111, 7, 118, 2, 2, 111, 12, 3, 2, 2, 2, 112, 113, 7, 105, 2, 2, 113, 114, 7, 113, 2, 2, 114, 115, 7, 118, 2, 2, 115, 116, 7, 113, 2, 2, 116, 14, 3, 2, 2, 2, 117, 118, 7, 42, 2, 2, 118, 16, 3, 2, 2, 2, 119, 120, 7, 46, 2, 2, 120, 18, 3, 2, 2, 2, 121, 122, 7, 43, 2, 2, 122, 20, 3, 2, 2, 2, 123, 124, 7, 104, 2, 2, 124, 125, 7, 113, 2, 2, 125, 126, 7, 116, 2, 2, 126, 127, 7, 121, 2, 2, 127, 128, 7, 99, 2, 2, 128, 129, 7, 116, 2, 2, 129, 130, 7, 102, 2, 2, 130, 22, 3, 2, 2, 2, 131, 132, 7, 100, 2, 2, 132, 133, 7, 99, 2, 2, 133, 134, 7, 101, 2, 2, 134, 135, 7, 109, 2, 2, 135, 136, 7, 121, 2, 2, 136, 137, 7, 99, 2, 2, 137, 138, 7, 116, 2, 2, 138, 139, 7, 102, 2, 2, 139, 24, 3, 2, 2, 2, 140, 141, 7, 110, 2, 2, 141, 142, 7, 103, 2, 2, 142, 143, 7, 104, 2, 2, 143, 144, 7, 118, 2, 2, 144, 26, 3, 2, 2, 2, 145, 146, 7, 116, 2, 2, 146, 147, 7, 107, 2, 2, 147, 148, 7, 105, 2, 2, 148, 149, 7, 106, 2, 2, 149, 150, 7, 118, 2, 2, 150, 28, 3, 2, 2, 2, 151, 152, 7, 114, 2, 2, 152, 153, 7, 103, 2, 2, 153, 154, 7, 112, 2, 2, 154, 155, 7, 119, 2, 2, 155, 156, 7, 114, 2, 2, 156, 30, 3, 2, 2, 2, 157, 158, 7, 114, 2, 2, 158, 159, 7, 103, 2, 2, 159, 160, 7, 112, 2, 2, 160, 161, 7, 102, 2, 2, 161, 162, 7, 113, 2, 2, 162, 163, 7, 121, 2, 2, 163, 164, 7, 112, 2, 2, 164, 32, 3, 2, 2, 2, 165, 166, 7, 114, 2, 2, 166, 167, 7, 99, 2, 2, 167, 168, 7, 119, 2, 2, 168, 169, 7, 117, 2, 2, 169, 170, 7, 103, 2, 2, 170, 34, 3, 2, 2, 2, 171, 172, 7, 63, 2, 2, 172, 36, 3, 2, 2, 2, 173, 174, 7, 101, 2, 2, 174, 175, 7, 110, 2, 2, 175, 176, 7, 99, 2, 2, 176, 177, 7, 117, 2, 2, 177, 178, 7, 117, 2, 2, 178, 38, 3, 2, 2, 2, 179, 180, 7, 125, 2, 2, 180, 40, 3, 2, 2, 2, 181, 182, 7, 127, 2, 2, 182, 42, 3, 2, 2, 2, 183, 184, 7, 112, 2, 2, 184, 185, 7, 103, 2, 2, 185, 186, 7, 121, 2, 2, 186, 44, 3, 2, 2, 2, 187, 188, 7, 48, 2, 2, 188, 46, 3, 2, 2, 2, 189, 190, 7, 102, 2, 2, 190, 191, 7, 103, 2, 2, 191, 192, 7, 104, 2, 2, 192, 48, 3, 2, 2, 2, 193, 194, 7, 37, 2, 2, 194, 50, 3, 2, 2, 2, 195, 196, 7, 45, 2, 2, 196, 52, 3, 2, 2, 2, 197, 198, 7, 47, 2, 2, 198, 54, 3, 2, 2, 2, 199, 200, 7, 44, 2, 2, 200, 56, 3, 2, 2, 2, 201, 202, 7, 49, 2, 2, 202, 58, 3, 2, 2, 2, 203, 204, 7, 40, 2, 2, 204, 205, 7, 40, 2, 2, 205, 60, 3, 2, 2, 2, 206, 207, 7, 126, 2, 2, 207, 208, 7, 126, 2, 2, 208, 62, 3, 2, 2, 2, 209, 210, 7, 116, 2, 2, 210, 211, 7, 103, 2, 2, 211, 212, 7, 118, 2, 2, 212, 213, 7, 119, 2, 2, 213, 214, 7, 116, 2, 2, 214, 215, 7, 112, 2, 2, 215, 64, 3, 2, 2, 2, 216, 217, 7, 114, 2, 2, 217, 218, 7, 116, 2, 2, 218, 219, 7, 107, 2, 2, 219, 220, 7, 112, 2, 2, 220, 221, 7, 118, 2, 2, 221, 66, 3, 2, 2, 2, 222, 223, 7, 114, 2, 2, 223, 224, 7, 103, 2, 2, 224, 225, 7, 112, 2, 2, 225, 226, 7, 102, 2, 2, 226, 227, 7, 113, 2, 2, 227, 228, 7, 121, 2, 2, 228, 229, 7, 112, 2, 2, 229, 230, 7, 65, 2, 2, 230, 68, 3, 2, 2, 2, 231, 232, 7, 62, 2, 2, 232, 70, 3, 2, 2, 2, 233, 234, 7, 64, 2, 2, 234, 72, 3, 2, 2, 2, 235, 236, 7, 63, 2, 2, 236, 237, 7, 63, 2, 2, 237, 74, 3, 2, 2, 2, 238, 239, 7, 35, 2, 2, 239, 240, 7, 63, 2, 2, 240, 76, 3, 2, 2, 2, 241, 242, 7, 62, 2, 2, 242, 243, 7, 63, 2, 2, 243, 78, 3, 2, 2, 2, 244, 245, 7, 64, 2, 2, 245, 246, 7, 63, 2, 2, 246, 80, 3, 2, 2, 2, 247, 248, 7, 35, 2, 2, 248, 82, 3, 2, 2, 2, 249, 251, 9, 2, 2, 2, 250, 249, 3, 2, 2, 2, 251, 252, 3, 2, 2, 2, 252, 250, 3, 2, 2, 2, 252, 253, 3, 2, 2, 2, 253, 84, 3, 2, 2, 2, 254, 256, 9, 2, 2, 2, 255, 254, 3, 2, 2, 2, 256, 257, 3, 2, 2, 2, 257, 255, 3, 2, 2, 2, 257, 258, 3, 2, 2, 2, 258, 265, 3, 2, 2, 2, 259, 261, 7, 48, 2, 2, 260, 262, 9, 2, 2, 2, 261, 260, 3, 2, 2, 2, 262, 263, 3, 2, 2, 2, 263, 261, 3, 2, 2, 2, 263, 264, 3, 2, 2, 2, 264, 266, 3, 2, 2, 2, 265, 259, 3, 2, 2, 2, 265, 266, 3, 2, 2, 2, 266, 86, 3, 2, 2, 2, 267, 270, 7, 60, 2, 2, 268, 269, 7, 97, 2, 2, 269, 271, 7, 97, 2, 2, 270, 268, 3, 2, 2, 2, 270, 271, 3, 2, 2, 2, 271, 272, 3, 2, 2, 2, 272, 276, 9, 3, 2, 2, 273, 275, 9, 4, 2, 2, 274, 273, 3, 2, 2, 2, 275, 278, 3, 2, 2, 2, 276, 274, 3, 2, 2, 2, 276, 277, 3, 2, 2, 2, 277, 88, 3, 2, 2, 2, 278, 276, 3, 2, 2, 2, 279, 280, 7, 97, 2, 2, 280, 282, 7, 97, 2, 2, 281, 279, 3, 2, 2, 2, 281, 282, 3, 2, 2, 2, 282, 284, 3, 2, 2, 2, 283, 285, 9, 5, 2, 2, 284, 283, 3, 2, 2, 2, 285, 286, 3, 2, 2, 2, 286, 284, 3, 2, 2, 2, 286, 287, 3, 2, 2, 2, 287, 90, 3, 2, 2, 2, 288, 290, 9, 6, 2, 2, 289, 288, 3, 2, 2, 2, 290, 291, 3, 2, 2, 2, 291, 289, 3, 2, 2, 2, 291, 292, 3, 2, 2, 2, 292, 293, 3, 2, 2, 2, 293, 294, 8, 46, 2, 2, 294, 92, 3, 2, 2, 2, 12, 2, 252, 257, 263, 265, 270, 276, 281, 286, 291, 3, 8, 2, 2] \ No newline at end of file diff --git a/ChironCore/turtparse/tlangLexer.py b/ChironCore/turtparse/tlangLexer.py index fc951de..4f24906 100644 --- a/ChironCore/turtparse/tlangLexer.py +++ b/ChironCore/turtparse/tlangLexer.py @@ -5,93 +5,129 @@ import sys + def serializedATN(): with StringIO() as buf: - buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2%") - buf.write("\u00db\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7") + buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2/") + buf.write("\u0127\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7") buf.write("\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r") buf.write("\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23") buf.write("\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30") buf.write("\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36") - buf.write("\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\3\2\3") - buf.write("\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6") - buf.write("\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\t\3\t\3") - buf.write("\n\3\n\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3") - buf.write("\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16") - buf.write("\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20\3\20") - buf.write("\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22") - buf.write("\3\22\3\22\3\22\3\22\3\23\3\23\3\24\3\24\3\25\3\25\3\26") - buf.write("\3\26\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\30") - buf.write("\3\30\3\31\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\34\3\34") - buf.write("\3\34\3\35\3\35\3\35\3\36\3\36\3\36\3\37\3\37\3\37\3 ") - buf.write("\3 \3!\6!\u00c4\n!\r!\16!\u00c5\3\"\3\"\3\"\7\"\u00cb") - buf.write("\n\"\f\"\16\"\u00ce\13\"\3#\6#\u00d1\n#\r#\16#\u00d2\3") - buf.write("$\6$\u00d6\n$\r$\16$\u00d7\3$\3$\2\2%\3\3\5\4\7\5\t\6") - buf.write("\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20") - buf.write("\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65") - buf.write("\34\67\359\36;\37= ?!A\"C#E$G%\3\2\7\3\2\62;\5\2C\\aa") - buf.write("c|\5\2\62;C\\c|\4\2C\\c|\5\2\13\f\17\17\"\"\2\u00de\2") - buf.write("\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3") - buf.write("\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2") - buf.write("\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2") - buf.write("\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%") - buf.write("\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2") - buf.write("\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67") - buf.write("\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2") - buf.write("A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\3I\3\2\2\2") - buf.write("\5L\3\2\2\2\7N\3\2\2\2\tP\3\2\2\2\13U\3\2\2\2\r\\\3\2") - buf.write("\2\2\17a\3\2\2\2\21c\3\2\2\2\23e\3\2\2\2\25g\3\2\2\2\27") - buf.write("i\3\2\2\2\31q\3\2\2\2\33z\3\2\2\2\35\177\3\2\2\2\37\u0085") - buf.write("\3\2\2\2!\u008b\3\2\2\2#\u0093\3\2\2\2%\u0099\3\2\2\2") - buf.write("\'\u009b\3\2\2\2)\u009d\3\2\2\2+\u009f\3\2\2\2-\u00a1") - buf.write("\3\2\2\2/\u00aa\3\2\2\2\61\u00ac\3\2\2\2\63\u00ae\3\2") - buf.write("\2\2\65\u00b1\3\2\2\2\67\u00b4\3\2\2\29\u00b7\3\2\2\2") - buf.write(";\u00ba\3\2\2\2=\u00bd\3\2\2\2?\u00c0\3\2\2\2A\u00c3\3") - buf.write("\2\2\2C\u00c7\3\2\2\2E\u00d0\3\2\2\2G\u00d5\3\2\2\2IJ") - buf.write("\7k\2\2JK\7h\2\2K\4\3\2\2\2LM\7]\2\2M\6\3\2\2\2NO\7_\2") - buf.write("\2O\b\3\2\2\2PQ\7g\2\2QR\7n\2\2RS\7u\2\2ST\7g\2\2T\n\3") - buf.write("\2\2\2UV\7t\2\2VW\7g\2\2WX\7r\2\2XY\7g\2\2YZ\7c\2\2Z[") - buf.write("\7v\2\2[\f\3\2\2\2\\]\7i\2\2]^\7q\2\2^_\7v\2\2_`\7q\2") - buf.write("\2`\16\3\2\2\2ab\7*\2\2b\20\3\2\2\2cd\7.\2\2d\22\3\2\2") - buf.write("\2ef\7+\2\2f\24\3\2\2\2gh\7?\2\2h\26\3\2\2\2ij\7h\2\2") - buf.write("jk\7q\2\2kl\7t\2\2lm\7y\2\2mn\7c\2\2no\7t\2\2op\7f\2\2") - buf.write("p\30\3\2\2\2qr\7d\2\2rs\7c\2\2st\7e\2\2tu\7m\2\2uv\7y") - buf.write("\2\2vw\7c\2\2wx\7t\2\2xy\7f\2\2y\32\3\2\2\2z{\7n\2\2{") - buf.write("|\7g\2\2|}\7h\2\2}~\7v\2\2~\34\3\2\2\2\177\u0080\7t\2") - buf.write("\2\u0080\u0081\7k\2\2\u0081\u0082\7i\2\2\u0082\u0083\7") - buf.write("j\2\2\u0083\u0084\7v\2\2\u0084\36\3\2\2\2\u0085\u0086") - buf.write("\7r\2\2\u0086\u0087\7g\2\2\u0087\u0088\7p\2\2\u0088\u0089") - buf.write("\7w\2\2\u0089\u008a\7r\2\2\u008a \3\2\2\2\u008b\u008c") - buf.write("\7r\2\2\u008c\u008d\7g\2\2\u008d\u008e\7p\2\2\u008e\u008f") - buf.write("\7f\2\2\u008f\u0090\7q\2\2\u0090\u0091\7y\2\2\u0091\u0092") - buf.write("\7p\2\2\u0092\"\3\2\2\2\u0093\u0094\7r\2\2\u0094\u0095") - buf.write("\7c\2\2\u0095\u0096\7w\2\2\u0096\u0097\7u\2\2\u0097\u0098") - buf.write("\7g\2\2\u0098$\3\2\2\2\u0099\u009a\7-\2\2\u009a&\3\2\2") - buf.write("\2\u009b\u009c\7/\2\2\u009c(\3\2\2\2\u009d\u009e\7,\2") - buf.write("\2\u009e*\3\2\2\2\u009f\u00a0\7\61\2\2\u00a0,\3\2\2\2") - buf.write("\u00a1\u00a2\7r\2\2\u00a2\u00a3\7g\2\2\u00a3\u00a4\7p") - buf.write("\2\2\u00a4\u00a5\7f\2\2\u00a5\u00a6\7q\2\2\u00a6\u00a7") - buf.write("\7y\2\2\u00a7\u00a8\7p\2\2\u00a8\u00a9\7A\2\2\u00a9.\3") - buf.write("\2\2\2\u00aa\u00ab\7>\2\2\u00ab\60\3\2\2\2\u00ac\u00ad") - buf.write("\7@\2\2\u00ad\62\3\2\2\2\u00ae\u00af\7?\2\2\u00af\u00b0") - buf.write("\7?\2\2\u00b0\64\3\2\2\2\u00b1\u00b2\7#\2\2\u00b2\u00b3") - buf.write("\7?\2\2\u00b3\66\3\2\2\2\u00b4\u00b5\7>\2\2\u00b5\u00b6") - buf.write("\7?\2\2\u00b68\3\2\2\2\u00b7\u00b8\7@\2\2\u00b8\u00b9") - buf.write("\7?\2\2\u00b9:\3\2\2\2\u00ba\u00bb\7(\2\2\u00bb\u00bc") - buf.write("\7(\2\2\u00bc<\3\2\2\2\u00bd\u00be\7~\2\2\u00be\u00bf") - buf.write("\7~\2\2\u00bf>\3\2\2\2\u00c0\u00c1\7#\2\2\u00c1@\3\2\2") - buf.write("\2\u00c2\u00c4\t\2\2\2\u00c3\u00c2\3\2\2\2\u00c4\u00c5") - buf.write("\3\2\2\2\u00c5\u00c3\3\2\2\2\u00c5\u00c6\3\2\2\2\u00c6") - buf.write("B\3\2\2\2\u00c7\u00c8\7<\2\2\u00c8\u00cc\t\3\2\2\u00c9") - buf.write("\u00cb\t\4\2\2\u00ca\u00c9\3\2\2\2\u00cb\u00ce\3\2\2\2") - buf.write("\u00cc\u00ca\3\2\2\2\u00cc\u00cd\3\2\2\2\u00cdD\3\2\2") - buf.write("\2\u00ce\u00cc\3\2\2\2\u00cf\u00d1\t\5\2\2\u00d0\u00cf") - buf.write("\3\2\2\2\u00d1\u00d2\3\2\2\2\u00d2\u00d0\3\2\2\2\u00d2") - buf.write("\u00d3\3\2\2\2\u00d3F\3\2\2\2\u00d4\u00d6\t\6\2\2\u00d5") - buf.write("\u00d4\3\2\2\2\u00d6\u00d7\3\2\2\2\u00d7\u00d5\3\2\2\2") - buf.write("\u00d7\u00d8\3\2\2\2\u00d8\u00d9\3\2\2\2\u00d9\u00da\b") - buf.write("$\2\2\u00daH\3\2\2\2\7\2\u00c5\u00cc\u00d2\u00d7\3\b\2") - buf.write("\2") + buf.write("\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\4%\t%") + buf.write("\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4,\t,\4-\t-\4.") + buf.write("\t.\3\2\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3") + buf.write("\6\3\6\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\b\3\b") + buf.write("\3\t\3\t\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3") + buf.write("\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3") + buf.write("\r\3\r\3\16\3\16\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3") + buf.write("\17\3\17\3\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20") + buf.write("\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3\23\3\23\3\23") + buf.write("\3\23\3\23\3\23\3\24\3\24\3\25\3\25\3\26\3\26\3\26\3\26") + buf.write("\3\27\3\27\3\30\3\30\3\30\3\30\3\31\3\31\3\32\3\32\3\33") + buf.write("\3\33\3\34\3\34\3\35\3\35\3\36\3\36\3\36\3\37\3\37\3\37") + buf.write("\3 \3 \3 \3 \3 \3 \3 \3!\3!\3!\3!\3!\3!\3\"\3\"\3\"\3") + buf.write("\"\3\"\3\"\3\"\3\"\3\"\3#\3#\3$\3$\3%\3%\3%\3&\3&\3&\3") + buf.write("\'\3\'\3\'\3(\3(\3(\3)\3)\3*\6*\u00fb\n*\r*\16*\u00fc") + buf.write("\3+\6+\u0100\n+\r+\16+\u0101\3+\3+\6+\u0106\n+\r+\16+") + buf.write("\u0107\5+\u010a\n+\3,\3,\3,\5,\u010f\n,\3,\3,\7,\u0113") + buf.write("\n,\f,\16,\u0116\13,\3-\3-\5-\u011a\n-\3-\6-\u011d\n-") + buf.write("\r-\16-\u011e\3.\6.\u0122\n.\r.\16.\u0123\3.\3.\2\2/\3") + buf.write("\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16") + buf.write("\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61") + buf.write("\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*") + buf.write("S+U,W-Y.[/\3\2\7\3\2\62;\5\2C\\aac|\5\2\62;C\\c|\4\2C") + buf.write("\\c|\5\2\13\f\17\17\"\"\2\u012f\2\3\3\2\2\2\2\5\3\2\2") + buf.write("\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2") + buf.write("\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27") + buf.write("\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3") + buf.write("\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2") + buf.write(")\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2") + buf.write("\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2") + buf.write(";\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2") + buf.write("\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2") + buf.write("\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U\3\2\2\2\2W\3\2") + buf.write("\2\2\2Y\3\2\2\2\2[\3\2\2\2\3]\3\2\2\2\5`\3\2\2\2\7b\3") + buf.write("\2\2\2\td\3\2\2\2\13i\3\2\2\2\rp\3\2\2\2\17u\3\2\2\2\21") + buf.write("w\3\2\2\2\23y\3\2\2\2\25{\3\2\2\2\27\u0083\3\2\2\2\31") + buf.write("\u008c\3\2\2\2\33\u0091\3\2\2\2\35\u0097\3\2\2\2\37\u009d") + buf.write("\3\2\2\2!\u00a5\3\2\2\2#\u00ab\3\2\2\2%\u00ad\3\2\2\2") + buf.write("\'\u00b3\3\2\2\2)\u00b5\3\2\2\2+\u00b7\3\2\2\2-\u00bb") + buf.write("\3\2\2\2/\u00bd\3\2\2\2\61\u00c1\3\2\2\2\63\u00c3\3\2") + buf.write("\2\2\65\u00c5\3\2\2\2\67\u00c7\3\2\2\29\u00c9\3\2\2\2") + buf.write(";\u00cb\3\2\2\2=\u00ce\3\2\2\2?\u00d1\3\2\2\2A\u00d8\3") + buf.write("\2\2\2C\u00de\3\2\2\2E\u00e7\3\2\2\2G\u00e9\3\2\2\2I\u00eb") + buf.write("\3\2\2\2K\u00ee\3\2\2\2M\u00f1\3\2\2\2O\u00f4\3\2\2\2") + buf.write("Q\u00f7\3\2\2\2S\u00fa\3\2\2\2U\u00ff\3\2\2\2W\u010b\3") + buf.write("\2\2\2Y\u0119\3\2\2\2[\u0121\3\2\2\2]^\7k\2\2^_\7h\2\2") + buf.write("_\4\3\2\2\2`a\7]\2\2a\6\3\2\2\2bc\7_\2\2c\b\3\2\2\2de") + buf.write("\7g\2\2ef\7n\2\2fg\7u\2\2gh\7g\2\2h\n\3\2\2\2ij\7t\2\2") + buf.write("jk\7g\2\2kl\7r\2\2lm\7g\2\2mn\7c\2\2no\7v\2\2o\f\3\2\2") + buf.write("\2pq\7i\2\2qr\7q\2\2rs\7v\2\2st\7q\2\2t\16\3\2\2\2uv\7") + buf.write("*\2\2v\20\3\2\2\2wx\7.\2\2x\22\3\2\2\2yz\7+\2\2z\24\3") + buf.write("\2\2\2{|\7h\2\2|}\7q\2\2}~\7t\2\2~\177\7y\2\2\177\u0080") + buf.write("\7c\2\2\u0080\u0081\7t\2\2\u0081\u0082\7f\2\2\u0082\26") + buf.write("\3\2\2\2\u0083\u0084\7d\2\2\u0084\u0085\7c\2\2\u0085\u0086") + buf.write("\7e\2\2\u0086\u0087\7m\2\2\u0087\u0088\7y\2\2\u0088\u0089") + buf.write("\7c\2\2\u0089\u008a\7t\2\2\u008a\u008b\7f\2\2\u008b\30") + buf.write("\3\2\2\2\u008c\u008d\7n\2\2\u008d\u008e\7g\2\2\u008e\u008f") + buf.write("\7h\2\2\u008f\u0090\7v\2\2\u0090\32\3\2\2\2\u0091\u0092") + buf.write("\7t\2\2\u0092\u0093\7k\2\2\u0093\u0094\7i\2\2\u0094\u0095") + buf.write("\7j\2\2\u0095\u0096\7v\2\2\u0096\34\3\2\2\2\u0097\u0098") + buf.write("\7r\2\2\u0098\u0099\7g\2\2\u0099\u009a\7p\2\2\u009a\u009b") + buf.write("\7w\2\2\u009b\u009c\7r\2\2\u009c\36\3\2\2\2\u009d\u009e") + buf.write("\7r\2\2\u009e\u009f\7g\2\2\u009f\u00a0\7p\2\2\u00a0\u00a1") + buf.write("\7f\2\2\u00a1\u00a2\7q\2\2\u00a2\u00a3\7y\2\2\u00a3\u00a4") + buf.write("\7p\2\2\u00a4 \3\2\2\2\u00a5\u00a6\7r\2\2\u00a6\u00a7") + buf.write("\7c\2\2\u00a7\u00a8\7w\2\2\u00a8\u00a9\7u\2\2\u00a9\u00aa") + buf.write("\7g\2\2\u00aa\"\3\2\2\2\u00ab\u00ac\7?\2\2\u00ac$\3\2") + buf.write("\2\2\u00ad\u00ae\7e\2\2\u00ae\u00af\7n\2\2\u00af\u00b0") + buf.write("\7c\2\2\u00b0\u00b1\7u\2\2\u00b1\u00b2\7u\2\2\u00b2&\3") + buf.write("\2\2\2\u00b3\u00b4\7}\2\2\u00b4(\3\2\2\2\u00b5\u00b6\7") + buf.write("\177\2\2\u00b6*\3\2\2\2\u00b7\u00b8\7p\2\2\u00b8\u00b9") + buf.write("\7g\2\2\u00b9\u00ba\7y\2\2\u00ba,\3\2\2\2\u00bb\u00bc") + buf.write("\7\60\2\2\u00bc.\3\2\2\2\u00bd\u00be\7f\2\2\u00be\u00bf") + buf.write("\7g\2\2\u00bf\u00c0\7h\2\2\u00c0\60\3\2\2\2\u00c1\u00c2") + buf.write("\7%\2\2\u00c2\62\3\2\2\2\u00c3\u00c4\7-\2\2\u00c4\64\3") + buf.write("\2\2\2\u00c5\u00c6\7/\2\2\u00c6\66\3\2\2\2\u00c7\u00c8") + buf.write("\7,\2\2\u00c88\3\2\2\2\u00c9\u00ca\7\61\2\2\u00ca:\3\2") + buf.write("\2\2\u00cb\u00cc\7(\2\2\u00cc\u00cd\7(\2\2\u00cd<\3\2") + buf.write("\2\2\u00ce\u00cf\7~\2\2\u00cf\u00d0\7~\2\2\u00d0>\3\2") + buf.write("\2\2\u00d1\u00d2\7t\2\2\u00d2\u00d3\7g\2\2\u00d3\u00d4") + buf.write("\7v\2\2\u00d4\u00d5\7w\2\2\u00d5\u00d6\7t\2\2\u00d6\u00d7") + buf.write("\7p\2\2\u00d7@\3\2\2\2\u00d8\u00d9\7r\2\2\u00d9\u00da") + buf.write("\7t\2\2\u00da\u00db\7k\2\2\u00db\u00dc\7p\2\2\u00dc\u00dd") + buf.write("\7v\2\2\u00ddB\3\2\2\2\u00de\u00df\7r\2\2\u00df\u00e0") + buf.write("\7g\2\2\u00e0\u00e1\7p\2\2\u00e1\u00e2\7f\2\2\u00e2\u00e3") + buf.write("\7q\2\2\u00e3\u00e4\7y\2\2\u00e4\u00e5\7p\2\2\u00e5\u00e6") + buf.write("\7A\2\2\u00e6D\3\2\2\2\u00e7\u00e8\7>\2\2\u00e8F\3\2\2") + buf.write("\2\u00e9\u00ea\7@\2\2\u00eaH\3\2\2\2\u00eb\u00ec\7?\2") + buf.write("\2\u00ec\u00ed\7?\2\2\u00edJ\3\2\2\2\u00ee\u00ef\7#\2") + buf.write("\2\u00ef\u00f0\7?\2\2\u00f0L\3\2\2\2\u00f1\u00f2\7>\2") + buf.write("\2\u00f2\u00f3\7?\2\2\u00f3N\3\2\2\2\u00f4\u00f5\7@\2") + buf.write("\2\u00f5\u00f6\7?\2\2\u00f6P\3\2\2\2\u00f7\u00f8\7#\2") + buf.write("\2\u00f8R\3\2\2\2\u00f9\u00fb\t\2\2\2\u00fa\u00f9\3\2") + buf.write("\2\2\u00fb\u00fc\3\2\2\2\u00fc\u00fa\3\2\2\2\u00fc\u00fd") + buf.write("\3\2\2\2\u00fdT\3\2\2\2\u00fe\u0100\t\2\2\2\u00ff\u00fe") + buf.write("\3\2\2\2\u0100\u0101\3\2\2\2\u0101\u00ff\3\2\2\2\u0101") + buf.write("\u0102\3\2\2\2\u0102\u0109\3\2\2\2\u0103\u0105\7\60\2") + buf.write("\2\u0104\u0106\t\2\2\2\u0105\u0104\3\2\2\2\u0106\u0107") + buf.write("\3\2\2\2\u0107\u0105\3\2\2\2\u0107\u0108\3\2\2\2\u0108") + buf.write("\u010a\3\2\2\2\u0109\u0103\3\2\2\2\u0109\u010a\3\2\2\2") + buf.write("\u010aV\3\2\2\2\u010b\u010e\7<\2\2\u010c\u010d\7a\2\2") + buf.write("\u010d\u010f\7a\2\2\u010e\u010c\3\2\2\2\u010e\u010f\3") + buf.write("\2\2\2\u010f\u0110\3\2\2\2\u0110\u0114\t\3\2\2\u0111\u0113") + buf.write("\t\4\2\2\u0112\u0111\3\2\2\2\u0113\u0116\3\2\2\2\u0114") + buf.write("\u0112\3\2\2\2\u0114\u0115\3\2\2\2\u0115X\3\2\2\2\u0116") + buf.write("\u0114\3\2\2\2\u0117\u0118\7a\2\2\u0118\u011a\7a\2\2\u0119") + buf.write("\u0117\3\2\2\2\u0119\u011a\3\2\2\2\u011a\u011c\3\2\2\2") + buf.write("\u011b\u011d\t\5\2\2\u011c\u011b\3\2\2\2\u011d\u011e\3") + buf.write("\2\2\2\u011e\u011c\3\2\2\2\u011e\u011f\3\2\2\2\u011fZ") + buf.write("\3\2\2\2\u0120\u0122\t\6\2\2\u0121\u0120\3\2\2\2\u0122") + buf.write("\u0123\3\2\2\2\u0123\u0121\3\2\2\2\u0123\u0124\3\2\2\2") + buf.write("\u0124\u0125\3\2\2\2\u0125\u0126\b.\2\2\u0126\\\3\2\2") + buf.write("\2\f\2\u00fc\u0101\u0107\u0109\u010e\u0114\u0119\u011e") + buf.write("\u0123\3\b\2\2") return buf.getvalue() @@ -118,24 +154,34 @@ class tlangLexer(Lexer): T__14 = 15 T__15 = 16 T__16 = 17 - PLUS = 18 - MINUS = 19 - MUL = 20 - DIV = 21 - PENCOND = 22 - LT = 23 - GT = 24 - EQ = 25 - NEQ = 26 - LTE = 27 - GTE = 28 + T__17 = 18 + T__18 = 19 + T__19 = 20 + T__20 = 21 + T__21 = 22 + T__22 = 23 + T__23 = 24 + PLUS = 25 + MINUS = 26 + MUL = 27 + DIV = 28 AND = 29 OR = 30 - NOT = 31 - NUM = 32 - VAR = 33 - NAME = 34 - Whitespace = 35 + RETURN = 31 + PRINT = 32 + PENCOND = 33 + LT = 34 + GT = 35 + EQ = 36 + NEQ = 37 + LTE = 38 + GTE = 39 + NOT = 40 + NUM = 41 + REAL = 42 + VAR = 43 + NAME = 44 + Whitespace = 45 channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] @@ -143,21 +189,24 @@ class tlangLexer(Lexer): literalNames = [ "", "'if'", "'['", "']'", "'else'", "'repeat'", "'goto'", "'('", - "','", "')'", "'='", "'forward'", "'backward'", "'left'", "'right'", - "'penup'", "'pendown'", "'pause'", "'+'", "'-'", "'*'", "'/'", - "'pendown?'", "'<'", "'>'", "'=='", "'!='", "'<='", "'>='", - "'&&'", "'||'", "'!'" ] + "','", "')'", "'forward'", "'backward'", "'left'", "'right'", + "'penup'", "'pendown'", "'pause'", "'='", "'class'", "'{'", + "'}'", "'new'", "'.'", "'def'", "'#'", "'+'", "'-'", "'*'", + "'/'", "'&&'", "'||'", "'return'", "'print'", "'pendown?'", + "'<'", "'>'", "'=='", "'!='", "'<='", "'>='", "'!'" ] symbolicNames = [ "", - "PLUS", "MINUS", "MUL", "DIV", "PENCOND", "LT", "GT", "EQ", - "NEQ", "LTE", "GTE", "AND", "OR", "NOT", "NUM", "VAR", "NAME", - "Whitespace" ] + "PLUS", "MINUS", "MUL", "DIV", "AND", "OR", "RETURN", "PRINT", + "PENCOND", "LT", "GT", "EQ", "NEQ", "LTE", "GTE", "NOT", "NUM", + "REAL", "VAR", "NAME", "Whitespace" ] ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "T__13", - "T__14", "T__15", "T__16", "PLUS", "MINUS", "MUL", "DIV", - "PENCOND", "LT", "GT", "EQ", "NEQ", "LTE", "GTE", "AND", - "OR", "NOT", "NUM", "VAR", "NAME", "Whitespace" ] + "T__14", "T__15", "T__16", "T__17", "T__18", "T__19", + "T__20", "T__21", "T__22", "T__23", "PLUS", "MINUS", "MUL", + "DIV", "AND", "OR", "RETURN", "PRINT", "PENCOND", "LT", + "GT", "EQ", "NEQ", "LTE", "GTE", "NOT", "NUM", "REAL", + "VAR", "NAME", "Whitespace" ] grammarFileName = "tlang.g4" diff --git a/ChironCore/turtparse/tlangLexer.tokens b/ChironCore/turtparse/tlangLexer.tokens index 78f9526..feb2c1e 100644 --- a/ChironCore/turtparse/tlangLexer.tokens +++ b/ChironCore/turtparse/tlangLexer.tokens @@ -15,24 +15,34 @@ T__13=14 T__14=15 T__15=16 T__16=17 -PLUS=18 -MINUS=19 -MUL=20 -DIV=21 -PENCOND=22 -LT=23 -GT=24 -EQ=25 -NEQ=26 -LTE=27 -GTE=28 +T__17=18 +T__18=19 +T__19=20 +T__20=21 +T__21=22 +T__22=23 +T__23=24 +PLUS=25 +MINUS=26 +MUL=27 +DIV=28 AND=29 OR=30 -NOT=31 -NUM=32 -VAR=33 -NAME=34 -Whitespace=35 +RETURN=31 +PRINT=32 +PENCOND=33 +LT=34 +GT=35 +EQ=36 +NEQ=37 +LTE=38 +GTE=39 +NOT=40 +NUM=41 +REAL=42 +VAR=43 +NAME=44 +Whitespace=45 'if'=1 '['=2 ']'=3 @@ -42,25 +52,34 @@ Whitespace=35 '('=7 ','=8 ')'=9 -'='=10 -'forward'=11 -'backward'=12 -'left'=13 -'right'=14 -'penup'=15 -'pendown'=16 -'pause'=17 -'+'=18 -'-'=19 -'*'=20 -'/'=21 -'pendown?'=22 -'<'=23 -'>'=24 -'=='=25 -'!='=26 -'<='=27 -'>='=28 +'forward'=10 +'backward'=11 +'left'=12 +'right'=13 +'penup'=14 +'pendown'=15 +'pause'=16 +'='=17 +'class'=18 +'{'=19 +'}'=20 +'new'=21 +'.'=22 +'def'=23 +'#'=24 +'+'=25 +'-'=26 +'*'=27 +'/'=28 '&&'=29 '||'=30 -'!'=31 +'return'=31 +'print'=32 +'pendown?'=33 +'<'=34 +'>'=35 +'=='=36 +'!='=37 +'<='=38 +'>='=39 +'!'=40 diff --git a/ChironCore/turtparse/tlangParser.py b/ChironCore/turtparse/tlangParser.py index b02d4a2..38adf99 100644 --- a/ChironCore/turtparse/tlangParser.py +++ b/ChironCore/turtparse/tlangParser.py @@ -5,71 +5,168 @@ from typing.io import TextIO import sys + def serializedATN(): with StringIO() as buf: - buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3%") - buf.write("\u00af\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7") + buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3/") + buf.write("\u016c\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7") buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16") buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23\t\23") - buf.write("\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\3\2\3\2\3\2\3") - buf.write("\3\7\3\63\n\3\f\3\16\3\66\13\3\3\4\6\49\n\4\r\4\16\4:") - buf.write("\3\5\3\5\3\5\3\5\3\5\3\5\3\5\5\5D\n\5\3\6\3\6\5\6H\n\6") - buf.write("\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3") - buf.write("\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n") - buf.write("\3\n\3\n\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\r\3\r\3\16") - buf.write("\3\16\3\17\3\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20") - buf.write("\3\20\5\20}\n\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3") - buf.write("\20\7\20\u0087\n\20\f\20\16\20\u008a\13\20\3\21\3\21\3") - buf.write("\22\3\22\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\24\3\24") - buf.write("\3\24\3\24\3\24\3\24\3\24\5\24\u009e\n\24\3\24\3\24\3") - buf.write("\24\3\24\7\24\u00a4\n\24\f\24\16\24\u00a7\13\24\3\25\3") - buf.write("\25\3\26\3\26\3\27\3\27\3\27\2\4\36&\30\2\4\6\b\n\f\16") - buf.write("\20\22\24\26\30\32\34\36 \"$&(*,\2\t\3\2\r\20\3\2\21\22") - buf.write("\3\2\26\27\3\2\24\25\3\2\31\36\3\2\37 \3\2\"#\2\u00a9") - buf.write("\2.\3\2\2\2\4\64\3\2\2\2\68\3\2\2\2\bC\3\2\2\2\nG\3\2") - buf.write("\2\2\fI\3\2\2\2\16O\3\2\2\2\20Y\3\2\2\2\22_\3\2\2\2\24") - buf.write("f\3\2\2\2\26j\3\2\2\2\30m\3\2\2\2\32o\3\2\2\2\34q\3\2") - buf.write("\2\2\36|\3\2\2\2 \u008b\3\2\2\2\"\u008d\3\2\2\2$\u008f") - buf.write("\3\2\2\2&\u009d\3\2\2\2(\u00a8\3\2\2\2*\u00aa\3\2\2\2") - buf.write(",\u00ac\3\2\2\2./\5\4\3\2/\60\7\2\2\3\60\3\3\2\2\2\61") - buf.write("\63\5\b\5\2\62\61\3\2\2\2\63\66\3\2\2\2\64\62\3\2\2\2") - buf.write("\64\65\3\2\2\2\65\5\3\2\2\2\66\64\3\2\2\2\679\5\b\5\2") - buf.write("8\67\3\2\2\29:\3\2\2\2:8\3\2\2\2:;\3\2\2\2;\7\3\2\2\2") - buf.write("D\5\20\t\2?D\5\26\f\2@D\5\32\16") - buf.write("\2AD\5\22\n\2BD\5\34\17\2C<\3\2\2\2C=\3\2\2\2C>\3\2\2") - buf.write("\2C?\3\2\2\2C@\3\2\2\2CA\3\2\2\2CB\3\2\2\2D\t\3\2\2\2") - buf.write("EH\5\f\7\2FH\5\16\b\2GE\3\2\2\2GF\3\2\2\2H\13\3\2\2\2") - buf.write("IJ\7\3\2\2JK\5&\24\2KL\7\4\2\2LM\5\6\4\2MN\7\5\2\2N\r") - buf.write("\3\2\2\2OP\7\3\2\2PQ\5&\24\2QR\7\4\2\2RS\5\6\4\2ST\7\5") - buf.write("\2\2TU\7\6\2\2UV\7\4\2\2VW\5\6\4\2WX\7\5\2\2X\17\3\2\2") - buf.write("\2YZ\7\7\2\2Z[\5,\27\2[\\\7\4\2\2\\]\5\6\4\2]^\7\5\2\2") - buf.write("^\21\3\2\2\2_`\7\b\2\2`a\7\t\2\2ab\5\36\20\2bc\7\n\2\2") - buf.write("cd\5\36\20\2de\7\13\2\2e\23\3\2\2\2fg\7#\2\2gh\7\f\2\2") - buf.write("hi\5\36\20\2i\25\3\2\2\2jk\5\30\r\2kl\5\36\20\2l\27\3") - buf.write("\2\2\2mn\t\2\2\2n\31\3\2\2\2op\t\3\2\2p\33\3\2\2\2qr\7") - buf.write("\23\2\2r\35\3\2\2\2st\b\20\1\2tu\5$\23\2uv\5\36\20\7v") - buf.write("}\3\2\2\2w}\5,\27\2xy\7\t\2\2yz\5\36\20\2z{\7\13\2\2{") - buf.write("}\3\2\2\2|s\3\2\2\2|w\3\2\2\2|x\3\2\2\2}\u0088\3\2\2\2") - buf.write("~\177\f\6\2\2\177\u0080\5 \21\2\u0080\u0081\5\36\20\7") - buf.write("\u0081\u0087\3\2\2\2\u0082\u0083\f\5\2\2\u0083\u0084\5") - buf.write("\"\22\2\u0084\u0085\5\36\20\6\u0085\u0087\3\2\2\2\u0086") - buf.write("~\3\2\2\2\u0086\u0082\3\2\2\2\u0087\u008a\3\2\2\2\u0088") - buf.write("\u0086\3\2\2\2\u0088\u0089\3\2\2\2\u0089\37\3\2\2\2\u008a") - buf.write("\u0088\3\2\2\2\u008b\u008c\t\4\2\2\u008c!\3\2\2\2\u008d") - buf.write("\u008e\t\5\2\2\u008e#\3\2\2\2\u008f\u0090\7\25\2\2\u0090") - buf.write("%\3\2\2\2\u0091\u0092\b\24\1\2\u0092\u0093\7!\2\2\u0093") - buf.write("\u009e\5&\24\7\u0094\u0095\5\36\20\2\u0095\u0096\5(\25") - buf.write("\2\u0096\u0097\5\36\20\2\u0097\u009e\3\2\2\2\u0098\u009e") - buf.write("\7\30\2\2\u0099\u009a\7\t\2\2\u009a\u009b\5&\24\2\u009b") - buf.write("\u009c\7\13\2\2\u009c\u009e\3\2\2\2\u009d\u0091\3\2\2") - buf.write("\2\u009d\u0094\3\2\2\2\u009d\u0098\3\2\2\2\u009d\u0099") - buf.write("\3\2\2\2\u009e\u00a5\3\2\2\2\u009f\u00a0\f\5\2\2\u00a0") - buf.write("\u00a1\5*\26\2\u00a1\u00a2\5&\24\6\u00a2\u00a4\3\2\2\2") - buf.write("\u00a3\u009f\3\2\2\2\u00a4\u00a7\3\2\2\2\u00a5\u00a3\3") - buf.write("\2\2\2\u00a5\u00a6\3\2\2\2\u00a6\'\3\2\2\2\u00a7\u00a5") - buf.write("\3\2\2\2\u00a8\u00a9\t\6\2\2\u00a9)\3\2\2\2\u00aa\u00ab") - buf.write("\t\7\2\2\u00ab+\3\2\2\2\u00ac\u00ad\t\b\2\2\u00ad-\3\2") - buf.write("\2\2\13\64:CG|\u0086\u0088\u009d\u00a5") + buf.write("\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31") + buf.write("\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36") + buf.write("\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t") + buf.write("&\4\'\t\'\4(\t(\3\2\3\2\3\2\3\3\3\3\3\3\3\4\7\4X\n\4\f") + buf.write("\4\16\4[\13\4\3\5\3\5\7\5_\n\5\f\5\16\5b\13\5\3\6\3\6") + buf.write("\5\6f\n\6\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7") + buf.write("\5\7s\n\7\3\b\3\b\5\bw\n\b\3\t\3\t\3\t\3\t\3\t\3\t\3\n") + buf.write("\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3") + buf.write("\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r") + buf.write("\3\16\3\16\3\17\3\17\3\20\3\20\3\21\3\21\3\21\3\21\7\21") + buf.write("\u00a3\n\21\f\21\16\21\u00a6\13\21\5\21\u00a8\n\21\3\21") + buf.write("\3\21\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\24") + buf.write("\3\24\3\25\3\25\3\26\3\26\3\27\3\27\3\27\3\27\7\27\u00bf") + buf.write("\n\27\f\27\16\27\u00c2\13\27\3\30\3\30\3\30\3\30\3\30") + buf.write("\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30") + buf.write("\5\30\u00d4\n\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3") + buf.write("\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\7\30\u00e6") + buf.write("\n\30\f\30\16\30\u00e9\13\30\3\31\3\31\3\31\3\31\3\31") + buf.write("\3\31\7\31\u00f1\n\31\f\31\16\31\u00f4\13\31\5\31\u00f6") + buf.write("\n\31\3\31\5\31\u00f9\n\31\3\31\3\31\3\31\3\31\3\32\7") + buf.write("\32\u0100\n\32\f\32\16\32\u0103\13\32\3\32\7\32\u0106") + buf.write("\n\32\f\32\16\32\u0109\13\32\3\33\3\33\5\33\u010d\n\33") + buf.write("\3\34\3\34\3\34\3\34\3\34\3\34\3\34\3\35\3\35\3\35\3\35") + buf.write("\3\35\3\35\3\35\6\35\u011d\n\35\r\35\16\35\u011e\3\36") + buf.write("\3\36\3\37\3\37\5\37\u0125\n\37\3 \3 \3 \3 \3 \3 \3!\3") + buf.write("!\3!\3!\3!\5!\u0132\n!\3!\7!\u0135\n!\f!\16!\u0138\13") + buf.write("!\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3#\3#\3#\7#\u0146") + buf.write("\n#\f#\16#\u0149\13#\5#\u014b\n#\3$\3$\3$\7$\u0150\n$") + buf.write("\f$\16$\u0153\13$\5$\u0155\n$\3%\3%\7%\u0159\n%\f%\16") + buf.write("%\u015c\13%\3%\3%\3&\3&\3\'\3\'\3(\3(\3(\3(\3(\3(\5(\u016a") + buf.write("\n(\3(\2\3.)\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"") + buf.write("$&(*,.\60\62\64\668:<>@BDFHJLN\2\b\3\2\f\17\3\2\20\21") + buf.write("\3\2\35\36\3\2\33\34\3\2\37 \3\2$)\2\u0174\2P\3\2\2\2") + buf.write("\4S\3\2\2\2\6Y\3\2\2\2\b`\3\2\2\2\ne\3\2\2\2\fr\3\2\2") + buf.write("\2\16v\3\2\2\2\20x\3\2\2\2\22~\3\2\2\2\24\u0088\3\2\2") + buf.write("\2\26\u008e\3\2\2\2\30\u0095\3\2\2\2\32\u0098\3\2\2\2") + buf.write("\34\u009a\3\2\2\2\36\u009c\3\2\2\2 \u009e\3\2\2\2\"\u00ab") + buf.write("\3\2\2\2$\u00af\3\2\2\2&\u00b4\3\2\2\2(\u00b6\3\2\2\2") + buf.write("*\u00b8\3\2\2\2,\u00ba\3\2\2\2.\u00d3\3\2\2\2\60\u00ea") + buf.write("\3\2\2\2\62\u0101\3\2\2\2\64\u010c\3\2\2\2\66\u010e\3") + buf.write("\2\2\28\u0115\3\2\2\2:\u0120\3\2\2\2<\u0124\3\2\2\2>\u0126") + buf.write("\3\2\2\2@\u0136\3\2\2\2B\u0139\3\2\2\2D\u014a\3\2\2\2") + buf.write("F\u0154\3\2\2\2H\u0156\3\2\2\2J\u015f\3\2\2\2L\u0161\3") + buf.write("\2\2\2N\u0169\3\2\2\2PQ\5\4\3\2QR\7\2\2\3R\3\3\2\2\2S") + buf.write("T\5\6\4\2TU\5\b\5\2U\5\3\2\2\2VX\5\n\6\2WV\3\2\2\2X[\3") + buf.write("\2\2\2YW\3\2\2\2YZ\3\2\2\2Z\7\3\2\2\2[Y\3\2\2\2\\_\5\f") + buf.write("\7\2]_\5H%\2^\\\3\2\2\2^]\3\2\2\2_b\3\2\2\2`^\3\2\2\2") + buf.write("`a\3\2\2\2a\t\3\2\2\2b`\3\2\2\2cf\5\60\31\2df\5B\"\2e") + buf.write("c\3\2\2\2ed\3\2\2\2f\13\3\2\2\2gs\5\"\22\2hs\5$\23\2i") + buf.write("s\5\16\b\2js\5\24\13\2ks\5\30\r\2ls\5\34\17\2ms\5\26\f") + buf.write("\2ns\5\36\20\2os\5\66\34\2ps\5,\27\2qs\5> \2rg\3\2\2\2") + buf.write("rh\3\2\2\2ri\3\2\2\2rj\3\2\2\2rk\3\2\2\2rl\3\2\2\2rm\3") + buf.write("\2\2\2rn\3\2\2\2ro\3\2\2\2rp\3\2\2\2rq\3\2\2\2s\r\3\2") + buf.write("\2\2tw\5\20\t\2uw\5\22\n\2vt\3\2\2\2vu\3\2\2\2w\17\3\2") + buf.write("\2\2xy\7\3\2\2yz\5.\30\2z{\7\4\2\2{|\5\b\5\2|}\7\5\2\2") + buf.write("}\21\3\2\2\2~\177\7\3\2\2\177\u0080\5.\30\2\u0080\u0081") + buf.write("\7\4\2\2\u0081\u0082\5\b\5\2\u0082\u0083\7\5\2\2\u0083") + buf.write("\u0084\7\6\2\2\u0084\u0085\7\4\2\2\u0085\u0086\5\b\5\2") + buf.write("\u0086\u0087\7\5\2\2\u0087\23\3\2\2\2\u0088\u0089\7\7") + buf.write("\2\2\u0089\u008a\5N(\2\u008a\u008b\7\4\2\2\u008b\u008c") + buf.write("\5\b\5\2\u008c\u008d\7\5\2\2\u008d\25\3\2\2\2\u008e\u008f") + buf.write("\7\b\2\2\u008f\u0090\7\t\2\2\u0090\u0091\5.\30\2\u0091") + buf.write("\u0092\7\n\2\2\u0092\u0093\5.\30\2\u0093\u0094\7\13\2") + buf.write("\2\u0094\27\3\2\2\2\u0095\u0096\5\32\16\2\u0096\u0097") + buf.write("\5.\30\2\u0097\31\3\2\2\2\u0098\u0099\t\2\2\2\u0099\33") + buf.write("\3\2\2\2\u009a\u009b\t\3\2\2\u009b\35\3\2\2\2\u009c\u009d") + buf.write("\7\22\2\2\u009d\37\3\2\2\2\u009e\u00a7\7\4\2\2\u009f\u00a4") + buf.write("\5.\30\2\u00a0\u00a1\7\n\2\2\u00a1\u00a3\5.\30\2\u00a2") + buf.write("\u00a0\3\2\2\2\u00a3\u00a6\3\2\2\2\u00a4\u00a2\3\2\2\2") + buf.write("\u00a4\u00a5\3\2\2\2\u00a5\u00a8\3\2\2\2\u00a6\u00a4\3") + buf.write("\2\2\2\u00a7\u009f\3\2\2\2\u00a7\u00a8\3\2\2\2\u00a8\u00a9") + buf.write("\3\2\2\2\u00a9\u00aa\7\5\2\2\u00aa!\3\2\2\2\u00ab\u00ac") + buf.write("\5<\37\2\u00ac\u00ad\7\23\2\2\u00ad\u00ae\5.\30\2\u00ae") + buf.write("#\3\2\2\2\u00af\u00b0\7\"\2\2\u00b0\u00b1\7\t\2\2\u00b1") + buf.write("\u00b2\5.\30\2\u00b2\u00b3\7\13\2\2\u00b3%\3\2\2\2\u00b4") + buf.write("\u00b5\t\4\2\2\u00b5\'\3\2\2\2\u00b6\u00b7\t\5\2\2\u00b7") + buf.write(")\3\2\2\2\u00b8\u00b9\7\34\2\2\u00b9+\3\2\2\2\u00ba\u00bb") + buf.write("\7!\2\2\u00bb\u00c0\5.\30\2\u00bc\u00bd\7\n\2\2\u00bd") + buf.write("\u00bf\5.\30\2\u00be\u00bc\3\2\2\2\u00bf\u00c2\3\2\2\2") + buf.write("\u00c0\u00be\3\2\2\2\u00c0\u00c1\3\2\2\2\u00c1-\3\2\2") + buf.write("\2\u00c2\u00c0\3\2\2\2\u00c3\u00c4\b\30\1\2\u00c4\u00c5") + buf.write("\5*\26\2\u00c5\u00c6\5.\30\f\u00c6\u00d4\3\2\2\2\u00c7") + buf.write("\u00c8\5<\37\2\u00c8\u00c9\7\23\2\2\u00c9\u00ca\5.\30") + buf.write("\t\u00ca\u00d4\3\2\2\2\u00cb\u00cc\7\t\2\2\u00cc\u00cd") + buf.write("\5.\30\2\u00cd\u00ce\7\13\2\2\u00ce\u00d4\3\2\2\2\u00cf") + buf.write("\u00d4\5N(\2\u00d0\u00d1\7*\2\2\u00d1\u00d4\5.\30\6\u00d2") + buf.write("\u00d4\7#\2\2\u00d3\u00c3\3\2\2\2\u00d3\u00c7\3\2\2\2") + buf.write("\u00d3\u00cb\3\2\2\2\u00d3\u00cf\3\2\2\2\u00d3\u00d0\3") + buf.write("\2\2\2\u00d3\u00d2\3\2\2\2\u00d4\u00e7\3\2\2\2\u00d5\u00d6") + buf.write("\f\13\2\2\u00d6\u00d7\5&\24\2\u00d7\u00d8\5.\30\f\u00d8") + buf.write("\u00e6\3\2\2\2\u00d9\u00da\f\n\2\2\u00da\u00db\5(\25\2") + buf.write("\u00db\u00dc\5.\30\13\u00dc\u00e6\3\2\2\2\u00dd\u00de") + buf.write("\f\5\2\2\u00de\u00df\5L\'\2\u00df\u00e0\5.\30\6\u00e0") + buf.write("\u00e6\3\2\2\2\u00e1\u00e2\f\4\2\2\u00e2\u00e3\5J&\2\u00e3") + buf.write("\u00e4\5.\30\5\u00e4\u00e6\3\2\2\2\u00e5\u00d5\3\2\2\2") + buf.write("\u00e5\u00d9\3\2\2\2\u00e5\u00dd\3\2\2\2\u00e5\u00e1\3") + buf.write("\2\2\2\u00e6\u00e9\3\2\2\2\u00e7\u00e5\3\2\2\2\u00e7\u00e8") + buf.write("\3\2\2\2\u00e8/\3\2\2\2\u00e9\u00e7\3\2\2\2\u00ea\u00eb") + buf.write("\7\24\2\2\u00eb\u00f8\7-\2\2\u00ec\u00ed\7\t\2\2\u00ed") + buf.write("\u00f5\7-\2\2\u00ee\u00f2\7\n\2\2\u00ef\u00f1\7-\2\2\u00f0") + buf.write("\u00ef\3\2\2\2\u00f1\u00f4\3\2\2\2\u00f2\u00f0\3\2\2\2") + buf.write("\u00f2\u00f3\3\2\2\2\u00f3\u00f6\3\2\2\2\u00f4\u00f2\3") + buf.write("\2\2\2\u00f5\u00ee\3\2\2\2\u00f5\u00f6\3\2\2\2\u00f6\u00f7") + buf.write("\3\2\2\2\u00f7\u00f9\7\13\2\2\u00f8\u00ec\3\2\2\2\u00f8") + buf.write("\u00f9\3\2\2\2\u00f9\u00fa\3\2\2\2\u00fa\u00fb\7\25\2") + buf.write("\2\u00fb\u00fc\5\62\32\2\u00fc\u00fd\7\26\2\2\u00fd\61") + buf.write("\3\2\2\2\u00fe\u0100\5\64\33\2\u00ff\u00fe\3\2\2\2\u0100") + buf.write("\u0103\3\2\2\2\u0101\u00ff\3\2\2\2\u0101\u0102\3\2\2\2") + buf.write("\u0102\u0107\3\2\2\2\u0103\u0101\3\2\2\2\u0104\u0106\5") + buf.write("B\"\2\u0105\u0104\3\2\2\2\u0106\u0109\3\2\2\2\u0107\u0105") + buf.write("\3\2\2\2\u0107\u0108\3\2\2\2\u0108\63\3\2\2\2\u0109\u0107") + buf.write("\3\2\2\2\u010a\u010d\5\"\22\2\u010b\u010d\5\66\34\2\u010c") + buf.write("\u010a\3\2\2\2\u010c\u010b\3\2\2\2\u010d\65\3\2\2\2\u010e") + buf.write("\u010f\5<\37\2\u010f\u0110\7\23\2\2\u0110\u0111\7\27\2") + buf.write("\2\u0111\u0112\7-\2\2\u0112\u0113\7\t\2\2\u0113\u0114") + buf.write("\7\13\2\2\u0114\67\3\2\2\2\u0115\u011c\5:\36\2\u0116\u0117") + buf.write("\7\30\2\2\u0117\u011d\7-\2\2\u0118\u0119\7\4\2\2\u0119") + buf.write("\u011a\5.\30\2\u011a\u011b\7\5\2\2\u011b\u011d\3\2\2\2") + buf.write("\u011c\u0116\3\2\2\2\u011c\u0118\3\2\2\2\u011d\u011e\3") + buf.write("\2\2\2\u011e\u011c\3\2\2\2\u011e\u011f\3\2\2\2\u011f9") + buf.write("\3\2\2\2\u0120\u0121\7-\2\2\u0121;\3\2\2\2\u0122\u0125") + buf.write("\7-\2\2\u0123\u0125\58\35\2\u0124\u0122\3\2\2\2\u0124") + buf.write("\u0123\3\2\2\2\u0125=\3\2\2\2\u0126\u0127\5@!\2\u0127") + buf.write("\u0128\7.\2\2\u0128\u0129\7\t\2\2\u0129\u012a\5F$\2\u012a") + buf.write("\u012b\7\13\2\2\u012b?\3\2\2\2\u012c\u0132\7-\2\2\u012d") + buf.write("\u012e\7\4\2\2\u012e\u012f\5.\30\2\u012f\u0130\7\5\2\2") + buf.write("\u0130\u0132\3\2\2\2\u0131\u012c\3\2\2\2\u0131\u012d\3") + buf.write("\2\2\2\u0132\u0133\3\2\2\2\u0133\u0135\7\30\2\2\u0134") + buf.write("\u0131\3\2\2\2\u0135\u0138\3\2\2\2\u0136\u0134\3\2\2\2") + buf.write("\u0136\u0137\3\2\2\2\u0137A\3\2\2\2\u0138\u0136\3\2\2") + buf.write("\2\u0139\u013a\7\31\2\2\u013a\u013b\7.\2\2\u013b\u013c") + buf.write("\7\t\2\2\u013c\u013d\5D#\2\u013d\u013e\7\13\2\2\u013e") + buf.write("\u013f\7\25\2\2\u013f\u0140\5\b\5\2\u0140\u0141\7\26\2") + buf.write("\2\u0141C\3\2\2\2\u0142\u0147\7-\2\2\u0143\u0144\7\n\2") + buf.write("\2\u0144\u0146\7-\2\2\u0145\u0143\3\2\2\2\u0146\u0149") + buf.write("\3\2\2\2\u0147\u0145\3\2\2\2\u0147\u0148\3\2\2\2\u0148") + buf.write("\u014b\3\2\2\2\u0149\u0147\3\2\2\2\u014a\u0142\3\2\2\2") + buf.write("\u014a\u014b\3\2\2\2\u014bE\3\2\2\2\u014c\u0151\5.\30") + buf.write("\2\u014d\u014e\7\n\2\2\u014e\u0150\5.\30\2\u014f\u014d") + buf.write("\3\2\2\2\u0150\u0153\3\2\2\2\u0151\u014f\3\2\2\2\u0151") + buf.write("\u0152\3\2\2\2\u0152\u0155\3\2\2\2\u0153\u0151\3\2\2\2") + buf.write("\u0154\u014c\3\2\2\2\u0154\u0155\3\2\2\2\u0155G\3\2\2") + buf.write("\2\u0156\u015a\7\32\2\2\u0157\u0159\7.\2\2\u0158\u0157") + buf.write("\3\2\2\2\u0159\u015c\3\2\2\2\u015a\u0158\3\2\2\2\u015a") + buf.write("\u015b\3\2\2\2\u015b\u015d\3\2\2\2\u015c\u015a\3\2\2\2") + buf.write("\u015d\u015e\7\32\2\2\u015eI\3\2\2\2\u015f\u0160\t\6\2") + buf.write("\2\u0160K\3\2\2\2\u0161\u0162\t\7\2\2\u0162M\3\2\2\2\u0163") + buf.write("\u016a\7+\2\2\u0164\u016a\7-\2\2\u0165\u016a\5 \21\2\u0166") + buf.write("\u016a\58\35\2\u0167\u016a\5> \2\u0168\u016a\7,\2\2\u0169") + buf.write("\u0163\3\2\2\2\u0169\u0164\3\2\2\2\u0169\u0165\3\2\2\2") + buf.write("\u0169\u0166\3\2\2\2\u0169\u0167\3\2\2\2\u0169\u0168\3") + buf.write("\2\2\2\u016aO\3\2\2\2\37Y^`erv\u00a4\u00a7\u00c0\u00d3") + buf.write("\u00e5\u00e7\u00f2\u00f5\u00f8\u0101\u0107\u010c\u011c") + buf.write("\u011e\u0124\u0131\u0136\u0147\u014a\u0151\u0154\u015a") + buf.write("\u0169") return buf.getvalue() @@ -84,49 +181,74 @@ class tlangParser ( Parser ): sharedContextCache = PredictionContextCache() literalNames = [ "", "'if'", "'['", "']'", "'else'", "'repeat'", - "'goto'", "'('", "','", "')'", "'='", "'forward'", - "'backward'", "'left'", "'right'", "'penup'", "'pendown'", - "'pause'", "'+'", "'-'", "'*'", "'/'", "'pendown?'", - "'<'", "'>'", "'=='", "'!='", "'<='", "'>='", "'&&'", - "'||'", "'!'" ] + "'goto'", "'('", "','", "')'", "'forward'", "'backward'", + "'left'", "'right'", "'penup'", "'pendown'", "'pause'", + "'='", "'class'", "'{'", "'}'", "'new'", "'.'", "'def'", + "'#'", "'+'", "'-'", "'*'", "'/'", "'&&'", "'||'", + "'return'", "'print'", "'pendown?'", "'<'", "'>'", + "'=='", "'!='", "'<='", "'>='", "'!'" ] symbolicNames = [ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "PLUS", "MINUS", "MUL", - "DIV", "PENCOND", "LT", "GT", "EQ", "NEQ", "LTE", - "GTE", "AND", "OR", "NOT", "NUM", "VAR", "NAME", "Whitespace" ] + "", "", "", "", + "", "", "", "", + "", "PLUS", "MINUS", "MUL", "DIV", "AND", + "OR", "RETURN", "PRINT", "PENCOND", "LT", "GT", "EQ", + "NEQ", "LTE", "GTE", "NOT", "NUM", "REAL", "VAR", + "NAME", "Whitespace" ] RULE_start = 0 - RULE_instruction_list = 1 - RULE_strict_ilist = 2 - RULE_instruction = 3 - RULE_conditional = 4 - RULE_ifConditional = 5 - RULE_ifElseConditional = 6 - RULE_loop = 7 - RULE_gotoCommand = 8 - RULE_assignment = 9 - RULE_moveCommand = 10 - RULE_moveOp = 11 - RULE_penCommand = 12 - RULE_pauseCommand = 13 - RULE_expression = 14 - RULE_multiplicative = 15 - RULE_additive = 16 - RULE_unaryArithOp = 17 - RULE_condition = 18 - RULE_binCondOp = 19 - RULE_logicOp = 20 - RULE_value = 21 - - ruleNames = [ "start", "instruction_list", "strict_ilist", "instruction", - "conditional", "ifConditional", "ifElseConditional", - "loop", "gotoCommand", "assignment", "moveCommand", "moveOp", - "penCommand", "pauseCommand", "expression", "multiplicative", - "additive", "unaryArithOp", "condition", "binCondOp", - "logicOp", "value" ] + RULE_statement_list = 1 + RULE_declaration_list = 2 + RULE_strict_ilist = 3 + RULE_declaration = 4 + RULE_instruction = 5 + RULE_conditional = 6 + RULE_ifConditional = 7 + RULE_ifElseConditional = 8 + RULE_loop = 9 + RULE_gotoCommand = 10 + RULE_moveCommand = 11 + RULE_moveOp = 12 + RULE_penCommand = 13 + RULE_pauseCommand = 14 + RULE_array = 15 + RULE_assignment = 16 + RULE_printStatement = 17 + RULE_multiplicative = 18 + RULE_additive = 19 + RULE_unaryArithOp = 20 + RULE_returnStatement = 21 + RULE_expression = 22 + RULE_classDeclaration = 23 + RULE_classBody = 24 + RULE_classAttributeDeclaration = 25 + RULE_objectInstantiation = 26 + RULE_dataLocationAccess = 27 + RULE_baseVar = 28 + RULE_lvalue = 29 + RULE_functionCall = 30 + RULE_methodCaller = 31 + RULE_functionDeclaration = 32 + RULE_parameters = 33 + RULE_arguments = 34 + RULE_comment = 35 + RULE_logicOp = 36 + RULE_binCondOp = 37 + RULE_value = 38 + + ruleNames = [ "start", "statement_list", "declaration_list", "strict_ilist", + "declaration", "instruction", "conditional", "ifConditional", + "ifElseConditional", "loop", "gotoCommand", "moveCommand", + "moveOp", "penCommand", "pauseCommand", "array", "assignment", + "printStatement", "multiplicative", "additive", "unaryArithOp", + "returnStatement", "expression", "classDeclaration", + "classBody", "classAttributeDeclaration", "objectInstantiation", + "dataLocationAccess", "baseVar", "lvalue", "functionCall", + "methodCaller", "functionDeclaration", "parameters", + "arguments", "comment", "logicOp", "binCondOp", "value" ] EOF = Token.EOF T__0=1 @@ -146,24 +268,34 @@ class tlangParser ( Parser ): T__14=15 T__15=16 T__16=17 - PLUS=18 - MINUS=19 - MUL=20 - DIV=21 - PENCOND=22 - LT=23 - GT=24 - EQ=25 - NEQ=26 - LTE=27 - GTE=28 + T__17=18 + T__18=19 + T__19=20 + T__20=21 + T__21=22 + T__22=23 + T__23=24 + PLUS=25 + MINUS=26 + MUL=27 + DIV=28 AND=29 OR=30 - NOT=31 - NUM=32 - VAR=33 - NAME=34 - Whitespace=35 + RETURN=31 + PRINT=32 + PENCOND=33 + LT=34 + GT=35 + EQ=36 + NEQ=37 + LTE=38 + GTE=39 + NOT=40 + NUM=41 + REAL=42 + VAR=43 + NAME=44 + Whitespace=45 def __init__(self, input:TokenStream, output:TextIO = sys.stdout): super().__init__(input, output) @@ -173,14 +305,15 @@ def __init__(self, input:TokenStream, output:TextIO = sys.stdout): + class StartContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def instruction_list(self): - return self.getTypedRuleContext(tlangParser.Instruction_listContext,0) + def statement_list(self): + return self.getTypedRuleContext(tlangParser.Statement_listContext,0) def EOF(self): @@ -204,9 +337,9 @@ def start(self): self.enterRule(localctx, 0, self.RULE_start) try: self.enterOuterAlt(localctx, 1) - self.state = 44 - self.instruction_list() - self.state = 45 + self.state = 78 + self.statement_list() + self.state = 79 self.match(tlangParser.EOF) except RecognitionException as re: localctx.exception = re @@ -216,45 +349,91 @@ def start(self): self.exitRule() return localctx - class Instruction_listContext(ParserRuleContext): + + class Statement_listContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def instruction(self, i:int=None): + def declaration_list(self): + return self.getTypedRuleContext(tlangParser.Declaration_listContext,0) + + + def strict_ilist(self): + return self.getTypedRuleContext(tlangParser.Strict_ilistContext,0) + + + def getRuleIndex(self): + return tlangParser.RULE_statement_list + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitStatement_list" ): + return visitor.visitStatement_list(self) + else: + return visitor.visitChildren(self) + + + + + def statement_list(self): + + localctx = tlangParser.Statement_listContext(self, self._ctx, self.state) + self.enterRule(localctx, 2, self.RULE_statement_list) + try: + self.enterOuterAlt(localctx, 1) + self.state = 81 + self.declaration_list() + self.state = 82 + self.strict_ilist() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Declaration_listContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def declaration(self, i:int=None): if i is None: - return self.getTypedRuleContexts(tlangParser.InstructionContext) + return self.getTypedRuleContexts(tlangParser.DeclarationContext) else: - return self.getTypedRuleContext(tlangParser.InstructionContext,i) + return self.getTypedRuleContext(tlangParser.DeclarationContext,i) def getRuleIndex(self): - return tlangParser.RULE_instruction_list + return tlangParser.RULE_declaration_list def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitInstruction_list" ): - return visitor.visitInstruction_list(self) + if hasattr( visitor, "visitDeclaration_list" ): + return visitor.visitDeclaration_list(self) else: return visitor.visitChildren(self) - def instruction_list(self): + def declaration_list(self): - localctx = tlangParser.Instruction_listContext(self, self._ctx, self.state) - self.enterRule(localctx, 2, self.RULE_instruction_list) + localctx = tlangParser.Declaration_listContext(self, self._ctx, self.state) + self.enterRule(localctx, 4, self.RULE_declaration_list) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 50 + self.state = 87 self._errHandler.sync(self) _la = self._input.LA(1) - while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << tlangParser.T__0) | (1 << tlangParser.T__4) | (1 << tlangParser.T__5) | (1 << tlangParser.T__10) | (1 << tlangParser.T__11) | (1 << tlangParser.T__12) | (1 << tlangParser.T__13) | (1 << tlangParser.T__14) | (1 << tlangParser.T__15) | (1 << tlangParser.T__16) | (1 << tlangParser.VAR))) != 0): - self.state = 47 - self.instruction() - self.state = 52 + while _la==tlangParser.T__17 or _la==tlangParser.T__22: + self.state = 84 + self.declaration() + self.state = 89 self._errHandler.sync(self) _la = self._input.LA(1) @@ -266,6 +445,7 @@ def instruction_list(self): self.exitRule() return localctx + class Strict_ilistContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): @@ -279,6 +459,13 @@ def instruction(self, i:int=None): return self.getTypedRuleContext(tlangParser.InstructionContext,i) + def comment(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(tlangParser.CommentContext) + else: + return self.getTypedRuleContext(tlangParser.CommentContext,i) + + def getRuleIndex(self): return tlangParser.RULE_strict_ilist @@ -294,21 +481,31 @@ def accept(self, visitor:ParseTreeVisitor): def strict_ilist(self): localctx = tlangParser.Strict_ilistContext(self, self._ctx, self.state) - self.enterRule(localctx, 4, self.RULE_strict_ilist) + self.enterRule(localctx, 6, self.RULE_strict_ilist) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 54 + self.state = 94 self._errHandler.sync(self) _la = self._input.LA(1) - while True: - self.state = 53 - self.instruction() - self.state = 56 + while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << tlangParser.T__0) | (1 << tlangParser.T__1) | (1 << tlangParser.T__4) | (1 << tlangParser.T__5) | (1 << tlangParser.T__9) | (1 << tlangParser.T__10) | (1 << tlangParser.T__11) | (1 << tlangParser.T__12) | (1 << tlangParser.T__13) | (1 << tlangParser.T__14) | (1 << tlangParser.T__15) | (1 << tlangParser.T__23) | (1 << tlangParser.RETURN) | (1 << tlangParser.PRINT) | (1 << tlangParser.VAR) | (1 << tlangParser.NAME))) != 0): + self.state = 92 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [tlangParser.T__0, tlangParser.T__1, tlangParser.T__4, tlangParser.T__5, tlangParser.T__9, tlangParser.T__10, tlangParser.T__11, tlangParser.T__12, tlangParser.T__13, tlangParser.T__14, tlangParser.T__15, tlangParser.RETURN, tlangParser.PRINT, tlangParser.VAR, tlangParser.NAME]: + self.state = 90 + self.instruction() + pass + elif token in [tlangParser.T__23]: + self.state = 91 + self.comment() + pass + else: + raise NoViableAltException(self) + + self.state = 96 self._errHandler.sync(self) _la = self._input.LA(1) - if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << tlangParser.T__0) | (1 << tlangParser.T__4) | (1 << tlangParser.T__5) | (1 << tlangParser.T__10) | (1 << tlangParser.T__11) | (1 << tlangParser.T__12) | (1 << tlangParser.T__13) | (1 << tlangParser.T__14) | (1 << tlangParser.T__15) | (1 << tlangParser.T__16) | (1 << tlangParser.VAR))) != 0)): - break except RecognitionException as re: localctx.exception = re @@ -318,6 +515,63 @@ def strict_ilist(self): self.exitRule() return localctx + + class DeclarationContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def classDeclaration(self): + return self.getTypedRuleContext(tlangParser.ClassDeclarationContext,0) + + + def functionDeclaration(self): + return self.getTypedRuleContext(tlangParser.FunctionDeclarationContext,0) + + + def getRuleIndex(self): + return tlangParser.RULE_declaration + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitDeclaration" ): + return visitor.visitDeclaration(self) + else: + return visitor.visitChildren(self) + + + + + def declaration(self): + + localctx = tlangParser.DeclarationContext(self, self._ctx, self.state) + self.enterRule(localctx, 8, self.RULE_declaration) + try: + self.state = 99 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [tlangParser.T__17]: + self.enterOuterAlt(localctx, 1) + self.state = 97 + self.classDeclaration() + pass + elif token in [tlangParser.T__22]: + self.enterOuterAlt(localctx, 2) + self.state = 98 + self.functionDeclaration() + pass + else: + raise NoViableAltException(self) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class InstructionContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): @@ -328,6 +582,10 @@ def assignment(self): return self.getTypedRuleContext(tlangParser.AssignmentContext,0) + def printStatement(self): + return self.getTypedRuleContext(tlangParser.PrintStatementContext,0) + + def conditional(self): return self.getTypedRuleContext(tlangParser.ConditionalContext,0) @@ -352,6 +610,18 @@ def pauseCommand(self): return self.getTypedRuleContext(tlangParser.PauseCommandContext,0) + def objectInstantiation(self): + return self.getTypedRuleContext(tlangParser.ObjectInstantiationContext,0) + + + def returnStatement(self): + return self.getTypedRuleContext(tlangParser.ReturnStatementContext,0) + + + def functionCall(self): + return self.getTypedRuleContext(tlangParser.FunctionCallContext,0) + + def getRuleIndex(self): return tlangParser.RULE_instruction @@ -367,48 +637,77 @@ def accept(self, visitor:ParseTreeVisitor): def instruction(self): localctx = tlangParser.InstructionContext(self, self._ctx, self.state) - self.enterRule(localctx, 6, self.RULE_instruction) + self.enterRule(localctx, 10, self.RULE_instruction) try: - self.state = 65 + self.state = 112 self._errHandler.sync(self) - token = self._input.LA(1) - if token in [tlangParser.VAR]: + la_ = self._interp.adaptivePredict(self._input,4,self._ctx) + if la_ == 1: self.enterOuterAlt(localctx, 1) - self.state = 58 + self.state = 101 self.assignment() pass - elif token in [tlangParser.T__0]: + + elif la_ == 2: self.enterOuterAlt(localctx, 2) - self.state = 59 - self.conditional() + self.state = 102 + self.printStatement() pass - elif token in [tlangParser.T__4]: + + elif la_ == 3: self.enterOuterAlt(localctx, 3) - self.state = 60 - self.loop() + self.state = 103 + self.conditional() pass - elif token in [tlangParser.T__10, tlangParser.T__11, tlangParser.T__12, tlangParser.T__13]: + + elif la_ == 4: self.enterOuterAlt(localctx, 4) - self.state = 61 - self.moveCommand() + self.state = 104 + self.loop() pass - elif token in [tlangParser.T__14, tlangParser.T__15]: + + elif la_ == 5: self.enterOuterAlt(localctx, 5) - self.state = 62 - self.penCommand() + self.state = 105 + self.moveCommand() pass - elif token in [tlangParser.T__5]: + + elif la_ == 6: self.enterOuterAlt(localctx, 6) - self.state = 63 - self.gotoCommand() + self.state = 106 + self.penCommand() pass - elif token in [tlangParser.T__16]: + + elif la_ == 7: self.enterOuterAlt(localctx, 7) - self.state = 64 + self.state = 107 + self.gotoCommand() + pass + + elif la_ == 8: + self.enterOuterAlt(localctx, 8) + self.state = 108 self.pauseCommand() pass - else: - raise NoViableAltException(self) + + elif la_ == 9: + self.enterOuterAlt(localctx, 9) + self.state = 109 + self.objectInstantiation() + pass + + elif la_ == 10: + self.enterOuterAlt(localctx, 10) + self.state = 110 + self.returnStatement() + pass + + elif la_ == 11: + self.enterOuterAlt(localctx, 11) + self.state = 111 + self.functionCall() + pass + except RecognitionException as re: localctx.exception = re @@ -418,6 +717,7 @@ def instruction(self): self.exitRule() return localctx + class ConditionalContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): @@ -447,20 +747,20 @@ def accept(self, visitor:ParseTreeVisitor): def conditional(self): localctx = tlangParser.ConditionalContext(self, self._ctx, self.state) - self.enterRule(localctx, 8, self.RULE_conditional) + self.enterRule(localctx, 12, self.RULE_conditional) try: - self.state = 69 + self.state = 116 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,3,self._ctx) + la_ = self._interp.adaptivePredict(self._input,5,self._ctx) if la_ == 1: self.enterOuterAlt(localctx, 1) - self.state = 67 + self.state = 114 self.ifConditional() pass elif la_ == 2: self.enterOuterAlt(localctx, 2) - self.state = 68 + self.state = 115 self.ifElseConditional() pass @@ -473,14 +773,15 @@ def conditional(self): self.exitRule() return localctx + class IfConditionalContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def condition(self): - return self.getTypedRuleContext(tlangParser.ConditionContext,0) + def expression(self): + return self.getTypedRuleContext(tlangParser.ExpressionContext,0) def strict_ilist(self): @@ -502,18 +803,18 @@ def accept(self, visitor:ParseTreeVisitor): def ifConditional(self): localctx = tlangParser.IfConditionalContext(self, self._ctx, self.state) - self.enterRule(localctx, 10, self.RULE_ifConditional) + self.enterRule(localctx, 14, self.RULE_ifConditional) try: self.enterOuterAlt(localctx, 1) - self.state = 71 + self.state = 118 self.match(tlangParser.T__0) - self.state = 72 - self.condition(0) - self.state = 73 + self.state = 119 + self.expression(0) + self.state = 120 self.match(tlangParser.T__1) - self.state = 74 + self.state = 121 self.strict_ilist() - self.state = 75 + self.state = 122 self.match(tlangParser.T__2) except RecognitionException as re: localctx.exception = re @@ -523,14 +824,15 @@ def ifConditional(self): self.exitRule() return localctx + class IfElseConditionalContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def condition(self): - return self.getTypedRuleContext(tlangParser.ConditionContext,0) + def expression(self): + return self.getTypedRuleContext(tlangParser.ExpressionContext,0) def strict_ilist(self, i:int=None): @@ -555,26 +857,26 @@ def accept(self, visitor:ParseTreeVisitor): def ifElseConditional(self): localctx = tlangParser.IfElseConditionalContext(self, self._ctx, self.state) - self.enterRule(localctx, 12, self.RULE_ifElseConditional) + self.enterRule(localctx, 16, self.RULE_ifElseConditional) try: self.enterOuterAlt(localctx, 1) - self.state = 77 + self.state = 124 self.match(tlangParser.T__0) - self.state = 78 - self.condition(0) - self.state = 79 + self.state = 125 + self.expression(0) + self.state = 126 self.match(tlangParser.T__1) - self.state = 80 + self.state = 127 self.strict_ilist() - self.state = 81 + self.state = 128 self.match(tlangParser.T__2) - self.state = 82 + self.state = 129 self.match(tlangParser.T__3) - self.state = 83 + self.state = 130 self.match(tlangParser.T__1) - self.state = 84 + self.state = 131 self.strict_ilist() - self.state = 85 + self.state = 132 self.match(tlangParser.T__2) except RecognitionException as re: localctx.exception = re @@ -584,6 +886,7 @@ def ifElseConditional(self): self.exitRule() return localctx + class LoopContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): @@ -613,18 +916,18 @@ def accept(self, visitor:ParseTreeVisitor): def loop(self): localctx = tlangParser.LoopContext(self, self._ctx, self.state) - self.enterRule(localctx, 14, self.RULE_loop) + self.enterRule(localctx, 18, self.RULE_loop) try: self.enterOuterAlt(localctx, 1) - self.state = 87 + self.state = 134 self.match(tlangParser.T__4) - self.state = 88 + self.state = 135 self.value() - self.state = 89 + self.state = 136 self.match(tlangParser.T__1) - self.state = 90 + self.state = 137 self.strict_ilist() - self.state = 91 + self.state = 138 self.match(tlangParser.T__2) except RecognitionException as re: localctx.exception = re @@ -634,6 +937,7 @@ def loop(self): self.exitRule() return localctx + class GotoCommandContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): @@ -662,20 +966,20 @@ def accept(self, visitor:ParseTreeVisitor): def gotoCommand(self): localctx = tlangParser.GotoCommandContext(self, self._ctx, self.state) - self.enterRule(localctx, 16, self.RULE_gotoCommand) + self.enterRule(localctx, 20, self.RULE_gotoCommand) try: self.enterOuterAlt(localctx, 1) - self.state = 93 + self.state = 140 self.match(tlangParser.T__5) - self.state = 94 + self.state = 141 self.match(tlangParser.T__6) - self.state = 95 + self.state = 142 self.expression(0) - self.state = 96 + self.state = 143 self.match(tlangParser.T__7) - self.state = 97 + self.state = 144 self.expression(0) - self.state = 98 + self.state = 145 self.match(tlangParser.T__8) except RecognitionException as re: localctx.exception = re @@ -685,50 +989,6 @@ def gotoCommand(self): self.exitRule() return localctx - class AssignmentContext(ParserRuleContext): - - def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): - super().__init__(parent, invokingState) - self.parser = parser - - def VAR(self): - return self.getToken(tlangParser.VAR, 0) - - def expression(self): - return self.getTypedRuleContext(tlangParser.ExpressionContext,0) - - - def getRuleIndex(self): - return tlangParser.RULE_assignment - - def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitAssignment" ): - return visitor.visitAssignment(self) - else: - return visitor.visitChildren(self) - - - - - def assignment(self): - - localctx = tlangParser.AssignmentContext(self, self._ctx, self.state) - self.enterRule(localctx, 18, self.RULE_assignment) - try: - self.enterOuterAlt(localctx, 1) - self.state = 100 - self.match(tlangParser.VAR) - self.state = 101 - self.match(tlangParser.T__9) - self.state = 102 - self.expression(0) - except RecognitionException as re: - localctx.exception = re - self._errHandler.reportError(self, re) - self._errHandler.recover(self, re) - finally: - self.exitRule() - return localctx class MoveCommandContext(ParserRuleContext): @@ -759,12 +1019,12 @@ def accept(self, visitor:ParseTreeVisitor): def moveCommand(self): localctx = tlangParser.MoveCommandContext(self, self._ctx, self.state) - self.enterRule(localctx, 20, self.RULE_moveCommand) + self.enterRule(localctx, 22, self.RULE_moveCommand) try: self.enterOuterAlt(localctx, 1) - self.state = 104 + self.state = 147 self.moveOp() - self.state = 105 + self.state = 148 self.expression(0) except RecognitionException as re: localctx.exception = re @@ -774,6 +1034,7 @@ def moveCommand(self): self.exitRule() return localctx + class MoveOpContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): @@ -796,13 +1057,13 @@ def accept(self, visitor:ParseTreeVisitor): def moveOp(self): localctx = tlangParser.MoveOpContext(self, self._ctx, self.state) - self.enterRule(localctx, 22, self.RULE_moveOp) + self.enterRule(localctx, 24, self.RULE_moveOp) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 107 + self.state = 150 _la = self._input.LA(1) - if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << tlangParser.T__10) | (1 << tlangParser.T__11) | (1 << tlangParser.T__12) | (1 << tlangParser.T__13))) != 0)): + if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << tlangParser.T__9) | (1 << tlangParser.T__10) | (1 << tlangParser.T__11) | (1 << tlangParser.T__12))) != 0)): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -815,6 +1076,7 @@ def moveOp(self): self.exitRule() return localctx + class PenCommandContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): @@ -837,13 +1099,13 @@ def accept(self, visitor:ParseTreeVisitor): def penCommand(self): localctx = tlangParser.PenCommandContext(self, self._ctx, self.state) - self.enterRule(localctx, 24, self.RULE_penCommand) + self.enterRule(localctx, 26, self.RULE_penCommand) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 109 + self.state = 152 _la = self._input.LA(1) - if not(_la==tlangParser.T__14 or _la==tlangParser.T__15): + if not(_la==tlangParser.T__13 or _la==tlangParser.T__14): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -856,6 +1118,7 @@ def penCommand(self): self.exitRule() return localctx + class PauseCommandContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): @@ -878,11 +1141,11 @@ def accept(self, visitor:ParseTreeVisitor): def pauseCommand(self): localctx = tlangParser.PauseCommandContext(self, self._ctx, self.state) - self.enterRule(localctx, 26, self.RULE_pauseCommand) + self.enterRule(localctx, 28, self.RULE_pauseCommand) try: self.enterOuterAlt(localctx, 1) - self.state = 111 - self.match(tlangParser.T__16) + self.state = 154 + self.match(tlangParser.T__15) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -891,63 +1154,1004 @@ def pauseCommand(self): self.exitRule() return localctx - class ExpressionContext(ParserRuleContext): + + class ArrayContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser + def expression(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(tlangParser.ExpressionContext) + else: + return self.getTypedRuleContext(tlangParser.ExpressionContext,i) + def getRuleIndex(self): - return tlangParser.RULE_expression + return tlangParser.RULE_array - - def copyFrom(self, ctx:ParserRuleContext): - super().copyFrom(ctx) + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitArray" ): + return visitor.visitArray(self) + else: + return visitor.visitChildren(self) - class UnaryExprContext(ExpressionContext): - def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext - super().__init__(parser) - self.copyFrom(ctx) - def unaryArithOp(self): - return self.getTypedRuleContext(tlangParser.UnaryArithOpContext,0) + def array(self): - def expression(self): - return self.getTypedRuleContext(tlangParser.ExpressionContext,0) + localctx = tlangParser.ArrayContext(self, self._ctx, self.state) + self.enterRule(localctx, 30, self.RULE_array) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 156 + self.match(tlangParser.T__1) + self.state = 165 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << tlangParser.T__1) | (1 << tlangParser.T__6) | (1 << tlangParser.MINUS) | (1 << tlangParser.PENCOND) | (1 << tlangParser.NOT) | (1 << tlangParser.NUM) | (1 << tlangParser.REAL) | (1 << tlangParser.VAR) | (1 << tlangParser.NAME))) != 0): + self.state = 157 + self.expression(0) + self.state = 162 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==tlangParser.T__7: + self.state = 158 + self.match(tlangParser.T__7) + self.state = 159 + self.expression(0) + self.state = 164 + self._errHandler.sync(self) + _la = self._input.LA(1) - def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitUnaryExpr" ): - return visitor.visitUnaryExpr(self) - else: - return visitor.visitChildren(self) + self.state = 167 + self.match(tlangParser.T__2) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx - class ValueExprContext(ExpressionContext): - def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext - super().__init__(parser) - self.copyFrom(ctx) + class AssignmentContext(ParserRuleContext): - def value(self): - return self.getTypedRuleContext(tlangParser.ValueContext,0) + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + def lvalue(self): + return self.getTypedRuleContext(tlangParser.LvalueContext,0) + + + def expression(self): + return self.getTypedRuleContext(tlangParser.ExpressionContext,0) + + + def getRuleIndex(self): + return tlangParser.RULE_assignment + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitAssignment" ): + return visitor.visitAssignment(self) + else: + return visitor.visitChildren(self) + + + + + def assignment(self): + + localctx = tlangParser.AssignmentContext(self, self._ctx, self.state) + self.enterRule(localctx, 32, self.RULE_assignment) + try: + self.enterOuterAlt(localctx, 1) + self.state = 169 + self.lvalue() + self.state = 170 + self.match(tlangParser.T__16) + self.state = 171 + self.expression(0) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class PrintStatementContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def PRINT(self): + return self.getToken(tlangParser.PRINT, 0) + + def expression(self): + return self.getTypedRuleContext(tlangParser.ExpressionContext,0) + + + def getRuleIndex(self): + return tlangParser.RULE_printStatement + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitPrintStatement" ): + return visitor.visitPrintStatement(self) + else: + return visitor.visitChildren(self) + + + + + def printStatement(self): + + localctx = tlangParser.PrintStatementContext(self, self._ctx, self.state) + self.enterRule(localctx, 34, self.RULE_printStatement) + try: + self.enterOuterAlt(localctx, 1) + self.state = 173 + self.match(tlangParser.PRINT) + self.state = 174 + self.match(tlangParser.T__6) + self.state = 175 + self.expression(0) + self.state = 176 + self.match(tlangParser.T__8) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class MultiplicativeContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def MUL(self): + return self.getToken(tlangParser.MUL, 0) + + def DIV(self): + return self.getToken(tlangParser.DIV, 0) + + def getRuleIndex(self): + return tlangParser.RULE_multiplicative + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitMultiplicative" ): + return visitor.visitMultiplicative(self) + else: + return visitor.visitChildren(self) + + + + + def multiplicative(self): + + localctx = tlangParser.MultiplicativeContext(self, self._ctx, self.state) + self.enterRule(localctx, 36, self.RULE_multiplicative) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 178 + _la = self._input.LA(1) + if not(_la==tlangParser.MUL or _la==tlangParser.DIV): + self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class AdditiveContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def PLUS(self): + return self.getToken(tlangParser.PLUS, 0) + + def MINUS(self): + return self.getToken(tlangParser.MINUS, 0) + + def getRuleIndex(self): + return tlangParser.RULE_additive + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitAdditive" ): + return visitor.visitAdditive(self) + else: + return visitor.visitChildren(self) + + + + + def additive(self): + + localctx = tlangParser.AdditiveContext(self, self._ctx, self.state) + self.enterRule(localctx, 38, self.RULE_additive) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 180 + _la = self._input.LA(1) + if not(_la==tlangParser.PLUS or _la==tlangParser.MINUS): + self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class UnaryArithOpContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def MINUS(self): + return self.getToken(tlangParser.MINUS, 0) + + def getRuleIndex(self): + return tlangParser.RULE_unaryArithOp + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitUnaryArithOp" ): + return visitor.visitUnaryArithOp(self) + else: + return visitor.visitChildren(self) + + + + + def unaryArithOp(self): + + localctx = tlangParser.UnaryArithOpContext(self, self._ctx, self.state) + self.enterRule(localctx, 40, self.RULE_unaryArithOp) + try: + self.enterOuterAlt(localctx, 1) + self.state = 182 + self.match(tlangParser.MINUS) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class ReturnStatementContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def RETURN(self): + return self.getToken(tlangParser.RETURN, 0) + + def expression(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(tlangParser.ExpressionContext) + else: + return self.getTypedRuleContext(tlangParser.ExpressionContext,i) + + + def getRuleIndex(self): + return tlangParser.RULE_returnStatement + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitReturnStatement" ): + return visitor.visitReturnStatement(self) + else: + return visitor.visitChildren(self) + + + + + def returnStatement(self): + + localctx = tlangParser.ReturnStatementContext(self, self._ctx, self.state) + self.enterRule(localctx, 42, self.RULE_returnStatement) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 184 + self.match(tlangParser.RETURN) + + self.state = 185 + self.expression(0) + self.state = 190 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==tlangParser.T__7: + self.state = 186 + self.match(tlangParser.T__7) + self.state = 187 + self.expression(0) + self.state = 192 + self._errHandler.sync(self) + _la = self._input.LA(1) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class ExpressionContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + + def getRuleIndex(self): + return tlangParser.RULE_expression + + + def copyFrom(self, ctx:ParserRuleContext): + super().copyFrom(ctx) + + + class BinExprContext(ExpressionContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def expression(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(tlangParser.ExpressionContext) + else: + return self.getTypedRuleContext(tlangParser.ExpressionContext,i) + + def binCondOp(self): + return self.getTypedRuleContext(tlangParser.BinCondOpContext,0) + + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitBinExpr" ): + return visitor.visitBinExpr(self) + else: + return visitor.visitChildren(self) + + + class UnaryExprContext(ExpressionContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def unaryArithOp(self): + return self.getTypedRuleContext(tlangParser.UnaryArithOpContext,0) + + def expression(self): + return self.getTypedRuleContext(tlangParser.ExpressionContext,0) + + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitUnaryExpr" ): + return visitor.visitUnaryExpr(self) + else: + return visitor.visitChildren(self) + + + class ValueExprContext(ExpressionContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def value(self): + return self.getTypedRuleContext(tlangParser.ValueContext,0) + + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitValueExpr" ): + return visitor.visitValueExpr(self) + else: + return visitor.visitChildren(self) + + + class NotExprContext(ExpressionContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def NOT(self): + return self.getToken(tlangParser.NOT, 0) + def expression(self): + return self.getTypedRuleContext(tlangParser.ExpressionContext,0) + + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitNotExpr" ): + return visitor.visitNotExpr(self) + else: + return visitor.visitChildren(self) + + + class AddExprContext(ExpressionContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def expression(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(tlangParser.ExpressionContext) + else: + return self.getTypedRuleContext(tlangParser.ExpressionContext,i) + + def additive(self): + return self.getTypedRuleContext(tlangParser.AdditiveContext,0) + + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitAddExpr" ): + return visitor.visitAddExpr(self) + else: + return visitor.visitChildren(self) + + + class MulExprContext(ExpressionContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def expression(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(tlangParser.ExpressionContext) + else: + return self.getTypedRuleContext(tlangParser.ExpressionContext,i) + + def multiplicative(self): + return self.getTypedRuleContext(tlangParser.MultiplicativeContext,0) + + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitMulExpr" ): + return visitor.visitMulExpr(self) + else: + return visitor.visitChildren(self) + + + class PenExprContext(ExpressionContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def PENCOND(self): + return self.getToken(tlangParser.PENCOND, 0) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitPenExpr" ): + return visitor.visitPenExpr(self) + else: + return visitor.visitChildren(self) + + + class AssignExprContext(ExpressionContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def lvalue(self): + return self.getTypedRuleContext(tlangParser.LvalueContext,0) + + def expression(self): + return self.getTypedRuleContext(tlangParser.ExpressionContext,0) + + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitAssignExpr" ): + return visitor.visitAssignExpr(self) + else: + return visitor.visitChildren(self) + + + class ParenExprContext(ExpressionContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def expression(self): + return self.getTypedRuleContext(tlangParser.ExpressionContext,0) + + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitParenExpr" ): + return visitor.visitParenExpr(self) + else: + return visitor.visitChildren(self) + + + class LogExprContext(ExpressionContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def expression(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(tlangParser.ExpressionContext) + else: + return self.getTypedRuleContext(tlangParser.ExpressionContext,i) + + def logicOp(self): + return self.getTypedRuleContext(tlangParser.LogicOpContext,0) + + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitLogExpr" ): + return visitor.visitLogExpr(self) + else: + return visitor.visitChildren(self) + + + + def expression(self, _p:int=0): + _parentctx = self._ctx + _parentState = self.state + localctx = tlangParser.ExpressionContext(self, self._ctx, _parentState) + _prevctx = localctx + _startState = 44 + self.enterRecursionRule(localctx, 44, self.RULE_expression, _p) + try: + self.enterOuterAlt(localctx, 1) + self.state = 209 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,9,self._ctx) + if la_ == 1: + localctx = tlangParser.UnaryExprContext(self, localctx) + self._ctx = localctx + _prevctx = localctx + + self.state = 194 + self.unaryArithOp() + self.state = 195 + self.expression(10) + pass + + elif la_ == 2: + localctx = tlangParser.AssignExprContext(self, localctx) + self._ctx = localctx + _prevctx = localctx + self.state = 197 + self.lvalue() + self.state = 198 + self.match(tlangParser.T__16) + self.state = 199 + self.expression(7) + pass + + elif la_ == 3: + localctx = tlangParser.ParenExprContext(self, localctx) + self._ctx = localctx + _prevctx = localctx + self.state = 201 + self.match(tlangParser.T__6) + self.state = 202 + self.expression(0) + self.state = 203 + self.match(tlangParser.T__8) + pass + + elif la_ == 4: + localctx = tlangParser.ValueExprContext(self, localctx) + self._ctx = localctx + _prevctx = localctx + self.state = 205 + self.value() + pass + + elif la_ == 5: + localctx = tlangParser.NotExprContext(self, localctx) + self._ctx = localctx + _prevctx = localctx + self.state = 206 + self.match(tlangParser.NOT) + self.state = 207 + self.expression(4) + pass + + elif la_ == 6: + localctx = tlangParser.PenExprContext(self, localctx) + self._ctx = localctx + _prevctx = localctx + self.state = 208 + self.match(tlangParser.PENCOND) + pass + + + self._ctx.stop = self._input.LT(-1) + self.state = 229 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,11,self._ctx) + while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + if _alt==1: + if self._parseListeners is not None: + self.triggerExitRuleEvent() + _prevctx = localctx + self.state = 227 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,10,self._ctx) + if la_ == 1: + localctx = tlangParser.MulExprContext(self, tlangParser.ExpressionContext(self, _parentctx, _parentState)) + self.pushNewRecursionContext(localctx, _startState, self.RULE_expression) + self.state = 211 + if not self.precpred(self._ctx, 9): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 9)") + self.state = 212 + self.multiplicative() + self.state = 213 + self.expression(10) + pass + + elif la_ == 2: + localctx = tlangParser.AddExprContext(self, tlangParser.ExpressionContext(self, _parentctx, _parentState)) + self.pushNewRecursionContext(localctx, _startState, self.RULE_expression) + self.state = 215 + if not self.precpred(self._ctx, 8): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 8)") + self.state = 216 + self.additive() + self.state = 217 + self.expression(9) + pass + + elif la_ == 3: + localctx = tlangParser.BinExprContext(self, tlangParser.ExpressionContext(self, _parentctx, _parentState)) + self.pushNewRecursionContext(localctx, _startState, self.RULE_expression) + self.state = 219 + if not self.precpred(self._ctx, 3): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 3)") + self.state = 220 + self.binCondOp() + self.state = 221 + self.expression(4) + pass + + elif la_ == 4: + localctx = tlangParser.LogExprContext(self, tlangParser.ExpressionContext(self, _parentctx, _parentState)) + self.pushNewRecursionContext(localctx, _startState, self.RULE_expression) + self.state = 223 + if not self.precpred(self._ctx, 2): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 2)") + self.state = 224 + self.logicOp() + self.state = 225 + self.expression(3) + pass + + + self.state = 231 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,11,self._ctx) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.unrollRecursionContexts(_parentctx) + return localctx + + + class ClassDeclarationContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def VAR(self, i:int=None): + if i is None: + return self.getTokens(tlangParser.VAR) + else: + return self.getToken(tlangParser.VAR, i) + + def classBody(self): + return self.getTypedRuleContext(tlangParser.ClassBodyContext,0) + + + def getRuleIndex(self): + return tlangParser.RULE_classDeclaration + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitClassDeclaration" ): + return visitor.visitClassDeclaration(self) + else: + return visitor.visitChildren(self) + + + + + def classDeclaration(self): + + localctx = tlangParser.ClassDeclarationContext(self, self._ctx, self.state) + self.enterRule(localctx, 46, self.RULE_classDeclaration) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 232 + self.match(tlangParser.T__17) + self.state = 233 + self.match(tlangParser.VAR) + self.state = 246 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==tlangParser.T__6: + self.state = 234 + self.match(tlangParser.T__6) + self.state = 235 + self.match(tlangParser.VAR) + self.state = 243 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==tlangParser.T__7: + self.state = 236 + self.match(tlangParser.T__7) + self.state = 240 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==tlangParser.VAR: + self.state = 237 + self.match(tlangParser.VAR) + self.state = 242 + self._errHandler.sync(self) + _la = self._input.LA(1) + + + + self.state = 245 + self.match(tlangParser.T__8) + + + self.state = 248 + self.match(tlangParser.T__18) + self.state = 249 + self.classBody() + self.state = 250 + self.match(tlangParser.T__19) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class ClassBodyContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def classAttributeDeclaration(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(tlangParser.ClassAttributeDeclarationContext) + else: + return self.getTypedRuleContext(tlangParser.ClassAttributeDeclarationContext,i) + + + def functionDeclaration(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(tlangParser.FunctionDeclarationContext) + else: + return self.getTypedRuleContext(tlangParser.FunctionDeclarationContext,i) + + + def getRuleIndex(self): + return tlangParser.RULE_classBody + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitClassBody" ): + return visitor.visitClassBody(self) + else: + return visitor.visitChildren(self) + + + + + def classBody(self): + + localctx = tlangParser.ClassBodyContext(self, self._ctx, self.state) + self.enterRule(localctx, 48, self.RULE_classBody) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 255 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==tlangParser.VAR: + self.state = 252 + self.classAttributeDeclaration() + self.state = 257 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 261 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==tlangParser.T__22: + self.state = 258 + self.functionDeclaration() + self.state = 263 + self._errHandler.sync(self) + _la = self._input.LA(1) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class ClassAttributeDeclarationContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def assignment(self): + return self.getTypedRuleContext(tlangParser.AssignmentContext,0) + + + def objectInstantiation(self): + return self.getTypedRuleContext(tlangParser.ObjectInstantiationContext,0) + + + def getRuleIndex(self): + return tlangParser.RULE_classAttributeDeclaration + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitClassAttributeDeclaration" ): + return visitor.visitClassAttributeDeclaration(self) + else: + return visitor.visitChildren(self) + + + + + def classAttributeDeclaration(self): + + localctx = tlangParser.ClassAttributeDeclarationContext(self, self._ctx, self.state) + self.enterRule(localctx, 50, self.RULE_classAttributeDeclaration) + try: + self.state = 266 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,17,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 264 + self.assignment() + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 265 + self.objectInstantiation() + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class ObjectInstantiationContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def lvalue(self): + return self.getTypedRuleContext(tlangParser.LvalueContext,0) + + + def VAR(self): + return self.getToken(tlangParser.VAR, 0) + + def getRuleIndex(self): + return tlangParser.RULE_objectInstantiation def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitValueExpr" ): - return visitor.visitValueExpr(self) + if hasattr( visitor, "visitObjectInstantiation" ): + return visitor.visitObjectInstantiation(self) else: return visitor.visitChildren(self) - class AddExprContext(ExpressionContext): - def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext - super().__init__(parser) - self.copyFrom(ctx) + + def objectInstantiation(self): + + localctx = tlangParser.ObjectInstantiationContext(self, self._ctx, self.state) + self.enterRule(localctx, 52, self.RULE_objectInstantiation) + try: + self.enterOuterAlt(localctx, 1) + self.state = 268 + self.lvalue() + self.state = 269 + self.match(tlangParser.T__16) + self.state = 270 + self.match(tlangParser.T__20) + self.state = 271 + self.match(tlangParser.VAR) + self.state = 272 + self.match(tlangParser.T__6) + self.state = 273 + self.match(tlangParser.T__8) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class DataLocationAccessContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def baseVar(self): + return self.getTypedRuleContext(tlangParser.BaseVarContext,0) + + + def VAR(self, i:int=None): + if i is None: + return self.getTokens(tlangParser.VAR) + else: + return self.getToken(tlangParser.VAR, i) def expression(self, i:int=None): if i is None: @@ -955,190 +2159,341 @@ def expression(self, i:int=None): else: return self.getTypedRuleContext(tlangParser.ExpressionContext,i) - def additive(self): - return self.getTypedRuleContext(tlangParser.AdditiveContext,0) + def getRuleIndex(self): + return tlangParser.RULE_dataLocationAccess def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitAddExpr" ): - return visitor.visitAddExpr(self) + if hasattr( visitor, "visitDataLocationAccess" ): + return visitor.visitDataLocationAccess(self) else: return visitor.visitChildren(self) - class MulExprContext(ExpressionContext): - def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext - super().__init__(parser) - self.copyFrom(ctx) - def expression(self, i:int=None): - if i is None: - return self.getTypedRuleContexts(tlangParser.ExpressionContext) - else: - return self.getTypedRuleContext(tlangParser.ExpressionContext,i) + def dataLocationAccess(self): - def multiplicative(self): - return self.getTypedRuleContext(tlangParser.MultiplicativeContext,0) + localctx = tlangParser.DataLocationAccessContext(self, self._ctx, self.state) + self.enterRule(localctx, 54, self.RULE_dataLocationAccess) + try: + self.enterOuterAlt(localctx, 1) + self.state = 275 + self.baseVar() + self.state = 282 + self._errHandler.sync(self) + _alt = 1 + while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + if _alt == 1: + self.state = 282 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [tlangParser.T__21]: + self.state = 276 + self.match(tlangParser.T__21) + self.state = 277 + self.match(tlangParser.VAR) + pass + elif token in [tlangParser.T__1]: + self.state = 278 + self.match(tlangParser.T__1) + self.state = 279 + self.expression(0) + self.state = 280 + self.match(tlangParser.T__2) + pass + else: + raise NoViableAltException(self) + + + else: + raise NoViableAltException(self) + self.state = 284 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,19,self._ctx) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class BaseVarContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + def VAR(self): + return self.getToken(tlangParser.VAR, 0) + + def getRuleIndex(self): + return tlangParser.RULE_baseVar def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitMulExpr" ): - return visitor.visitMulExpr(self) + if hasattr( visitor, "visitBaseVar" ): + return visitor.visitBaseVar(self) else: return visitor.visitChildren(self) - class ParenExprContext(ExpressionContext): - def __init__(self, parser, ctx:ParserRuleContext): # actually a tlangParser.ExpressionContext - super().__init__(parser) - self.copyFrom(ctx) - def expression(self): - return self.getTypedRuleContext(tlangParser.ExpressionContext,0) + def baseVar(self): + + localctx = tlangParser.BaseVarContext(self, self._ctx, self.state) + self.enterRule(localctx, 56, self.RULE_baseVar) + try: + self.enterOuterAlt(localctx, 1) + self.state = 286 + self.match(tlangParser.VAR) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class LvalueContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def VAR(self): + return self.getToken(tlangParser.VAR, 0) + + def dataLocationAccess(self): + return self.getTypedRuleContext(tlangParser.DataLocationAccessContext,0) + + + def getRuleIndex(self): + return tlangParser.RULE_lvalue def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitParenExpr" ): - return visitor.visitParenExpr(self) + if hasattr( visitor, "visitLvalue" ): + return visitor.visitLvalue(self) else: return visitor.visitChildren(self) - def expression(self, _p:int=0): - _parentctx = self._ctx - _parentState = self.state - localctx = tlangParser.ExpressionContext(self, self._ctx, _parentState) - _prevctx = localctx - _startState = 28 - self.enterRecursionRule(localctx, 28, self.RULE_expression, _p) + + def lvalue(self): + + localctx = tlangParser.LvalueContext(self, self._ctx, self.state) + self.enterRule(localctx, 58, self.RULE_lvalue) try: - self.enterOuterAlt(localctx, 1) - self.state = 122 + self.state = 290 self._errHandler.sync(self) - token = self._input.LA(1) - if token in [tlangParser.MINUS]: - localctx = tlangParser.UnaryExprContext(self, localctx) - self._ctx = localctx - _prevctx = localctx - - self.state = 114 - self.unaryArithOp() - self.state = 115 - self.expression(5) - pass - elif token in [tlangParser.NUM, tlangParser.VAR]: - localctx = tlangParser.ValueExprContext(self, localctx) - self._ctx = localctx - _prevctx = localctx - self.state = 117 - self.value() + la_ = self._interp.adaptivePredict(self._input,20,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 288 + self.match(tlangParser.VAR) pass - elif token in [tlangParser.T__6]: - localctx = tlangParser.ParenExprContext(self, localctx) - self._ctx = localctx - _prevctx = localctx - self.state = 118 - self.match(tlangParser.T__6) - self.state = 119 - self.expression(0) - self.state = 120 - self.match(tlangParser.T__8) + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 289 + self.dataLocationAccess() pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class FunctionCallContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def methodCaller(self): + return self.getTypedRuleContext(tlangParser.MethodCallerContext,0) + + + def NAME(self): + return self.getToken(tlangParser.NAME, 0) + + def arguments(self): + return self.getTypedRuleContext(tlangParser.ArgumentsContext,0) + + + def getRuleIndex(self): + return tlangParser.RULE_functionCall + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitFunctionCall" ): + return visitor.visitFunctionCall(self) else: - raise NoViableAltException(self) + return visitor.visitChildren(self) - self._ctx.stop = self._input.LT(-1) - self.state = 134 - self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,6,self._ctx) - while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: - if _alt==1: - if self._parseListeners is not None: - self.triggerExitRuleEvent() - _prevctx = localctx - self.state = 132 - self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,5,self._ctx) - if la_ == 1: - localctx = tlangParser.MulExprContext(self, tlangParser.ExpressionContext(self, _parentctx, _parentState)) - self.pushNewRecursionContext(localctx, _startState, self.RULE_expression) - self.state = 124 - if not self.precpred(self._ctx, 4): - from antlr4.error.Errors import FailedPredicateException - raise FailedPredicateException(self, "self.precpred(self._ctx, 4)") - self.state = 125 - self.multiplicative() - self.state = 126 - self.expression(5) - pass - elif la_ == 2: - localctx = tlangParser.AddExprContext(self, tlangParser.ExpressionContext(self, _parentctx, _parentState)) - self.pushNewRecursionContext(localctx, _startState, self.RULE_expression) - self.state = 128 - if not self.precpred(self._ctx, 3): - from antlr4.error.Errors import FailedPredicateException - raise FailedPredicateException(self, "self.precpred(self._ctx, 3)") - self.state = 129 - self.additive() - self.state = 130 - self.expression(4) - pass - - self.state = 136 + + def functionCall(self): + + localctx = tlangParser.FunctionCallContext(self, self._ctx, self.state) + self.enterRule(localctx, 60, self.RULE_functionCall) + try: + self.enterOuterAlt(localctx, 1) + self.state = 292 + self.methodCaller() + self.state = 293 + self.match(tlangParser.NAME) + self.state = 294 + self.match(tlangParser.T__6) + self.state = 295 + self.arguments() + self.state = 296 + self.match(tlangParser.T__8) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class MethodCallerContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def VAR(self, i:int=None): + if i is None: + return self.getTokens(tlangParser.VAR) + else: + return self.getToken(tlangParser.VAR, i) + + def expression(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(tlangParser.ExpressionContext) + else: + return self.getTypedRuleContext(tlangParser.ExpressionContext,i) + + + def getRuleIndex(self): + return tlangParser.RULE_methodCaller + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitMethodCaller" ): + return visitor.visitMethodCaller(self) + else: + return visitor.visitChildren(self) + + + + + def methodCaller(self): + + localctx = tlangParser.MethodCallerContext(self, self._ctx, self.state) + self.enterRule(localctx, 62, self.RULE_methodCaller) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 308 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==tlangParser.T__1 or _la==tlangParser.VAR: + self.state = 303 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,6,self._ctx) + token = self._input.LA(1) + if token in [tlangParser.VAR]: + self.state = 298 + self.match(tlangParser.VAR) + pass + elif token in [tlangParser.T__1]: + self.state = 299 + self.match(tlangParser.T__1) + self.state = 300 + self.expression(0) + self.state = 301 + self.match(tlangParser.T__2) + pass + else: + raise NoViableAltException(self) + + self.state = 305 + self.match(tlangParser.T__21) + self.state = 310 + self._errHandler.sync(self) + _la = self._input.LA(1) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) self._errHandler.recover(self, re) finally: - self.unrollRecursionContexts(_parentctx) + self.exitRule() return localctx - class MultiplicativeContext(ParserRuleContext): + + class FunctionDeclarationContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def MUL(self): - return self.getToken(tlangParser.MUL, 0) + def NAME(self): + return self.getToken(tlangParser.NAME, 0) + + def parameters(self): + return self.getTypedRuleContext(tlangParser.ParametersContext,0) + + + def strict_ilist(self): + return self.getTypedRuleContext(tlangParser.Strict_ilistContext,0) - def DIV(self): - return self.getToken(tlangParser.DIV, 0) def getRuleIndex(self): - return tlangParser.RULE_multiplicative + return tlangParser.RULE_functionDeclaration def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitMultiplicative" ): - return visitor.visitMultiplicative(self) + if hasattr( visitor, "visitFunctionDeclaration" ): + return visitor.visitFunctionDeclaration(self) else: return visitor.visitChildren(self) - def multiplicative(self): + def functionDeclaration(self): - localctx = tlangParser.MultiplicativeContext(self, self._ctx, self.state) - self.enterRule(localctx, 30, self.RULE_multiplicative) - self._la = 0 # Token type + localctx = tlangParser.FunctionDeclarationContext(self, self._ctx, self.state) + self.enterRule(localctx, 64, self.RULE_functionDeclaration) try: self.enterOuterAlt(localctx, 1) - self.state = 137 - _la = self._input.LA(1) - if not(_la==tlangParser.MUL or _la==tlangParser.DIV): - self._errHandler.recoverInline(self) - else: - self._errHandler.reportMatch(self) - self.consume() + self.state = 311 + self.match(tlangParser.T__22) + self.state = 312 + self.match(tlangParser.NAME) + self.state = 313 + self.match(tlangParser.T__6) + self.state = 314 + self.parameters() + self.state = 315 + self.match(tlangParser.T__8) + self.state = 316 + self.match(tlangParser.T__18) + self.state = 317 + self.strict_ilist() + self.state = 318 + self.match(tlangParser.T__19) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -1147,44 +2502,58 @@ def multiplicative(self): self.exitRule() return localctx - class AdditiveContext(ParserRuleContext): + + class ParametersContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def PLUS(self): - return self.getToken(tlangParser.PLUS, 0) - - def MINUS(self): - return self.getToken(tlangParser.MINUS, 0) + def VAR(self, i:int=None): + if i is None: + return self.getTokens(tlangParser.VAR) + else: + return self.getToken(tlangParser.VAR, i) def getRuleIndex(self): - return tlangParser.RULE_additive + return tlangParser.RULE_parameters def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitAdditive" ): - return visitor.visitAdditive(self) + if hasattr( visitor, "visitParameters" ): + return visitor.visitParameters(self) else: return visitor.visitChildren(self) - def additive(self): + def parameters(self): - localctx = tlangParser.AdditiveContext(self, self._ctx, self.state) - self.enterRule(localctx, 32, self.RULE_additive) + localctx = tlangParser.ParametersContext(self, self._ctx, self.state) + self.enterRule(localctx, 66, self.RULE_parameters) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 139 + self.state = 328 + self._errHandler.sync(self) _la = self._input.LA(1) - if not(_la==tlangParser.PLUS or _la==tlangParser.MINUS): - self._errHandler.recoverInline(self) - else: - self._errHandler.reportMatch(self) - self.consume() + if _la==tlangParser.VAR: + self.state = 320 + self.match(tlangParser.VAR) + self.state = 325 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==tlangParser.T__7: + self.state = 321 + self.match(tlangParser.T__7) + self.state = 322 + self.match(tlangParser.VAR) + self.state = 327 + self._errHandler.sync(self) + _la = self._input.LA(1) + + + except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -1193,35 +2562,59 @@ def additive(self): self.exitRule() return localctx - class UnaryArithOpContext(ParserRuleContext): + + class ArgumentsContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def MINUS(self): - return self.getToken(tlangParser.MINUS, 0) + def expression(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(tlangParser.ExpressionContext) + else: + return self.getTypedRuleContext(tlangParser.ExpressionContext,i) + def getRuleIndex(self): - return tlangParser.RULE_unaryArithOp + return tlangParser.RULE_arguments def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitUnaryArithOp" ): - return visitor.visitUnaryArithOp(self) + if hasattr( visitor, "visitArguments" ): + return visitor.visitArguments(self) else: return visitor.visitChildren(self) - def unaryArithOp(self): + def arguments(self): - localctx = tlangParser.UnaryArithOpContext(self, self._ctx, self.state) - self.enterRule(localctx, 34, self.RULE_unaryArithOp) + localctx = tlangParser.ArgumentsContext(self, self._ctx, self.state) + self.enterRule(localctx, 68, self.RULE_arguments) + self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 141 - self.match(tlangParser.MINUS) + self.state = 338 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << tlangParser.T__1) | (1 << tlangParser.T__6) | (1 << tlangParser.MINUS) | (1 << tlangParser.PENCOND) | (1 << tlangParser.NOT) | (1 << tlangParser.NUM) | (1 << tlangParser.REAL) | (1 << tlangParser.VAR) | (1 << tlangParser.NAME))) != 0): + self.state = 330 + self.expression(0) + self.state = 335 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==tlangParser.T__7: + self.state = 331 + self.match(tlangParser.T__7) + self.state = 332 + self.expression(0) + self.state = 337 + self._errHandler.sync(self) + _la = self._input.LA(1) + + + except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -1230,171 +2623,95 @@ def unaryArithOp(self): self.exitRule() return localctx - class ConditionContext(ParserRuleContext): + + class CommentContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def NOT(self): - return self.getToken(tlangParser.NOT, 0) - - def condition(self, i:int=None): - if i is None: - return self.getTypedRuleContexts(tlangParser.ConditionContext) - else: - return self.getTypedRuleContext(tlangParser.ConditionContext,i) - - - def expression(self, i:int=None): + def NAME(self, i:int=None): if i is None: - return self.getTypedRuleContexts(tlangParser.ExpressionContext) + return self.getTokens(tlangParser.NAME) else: - return self.getTypedRuleContext(tlangParser.ExpressionContext,i) - - - def binCondOp(self): - return self.getTypedRuleContext(tlangParser.BinCondOpContext,0) - - - def PENCOND(self): - return self.getToken(tlangParser.PENCOND, 0) - - def logicOp(self): - return self.getTypedRuleContext(tlangParser.LogicOpContext,0) - + return self.getToken(tlangParser.NAME, i) def getRuleIndex(self): - return tlangParser.RULE_condition + return tlangParser.RULE_comment def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitCondition" ): - return visitor.visitCondition(self) + if hasattr( visitor, "visitComment" ): + return visitor.visitComment(self) else: return visitor.visitChildren(self) - def condition(self, _p:int=0): - _parentctx = self._ctx - _parentState = self.state - localctx = tlangParser.ConditionContext(self, self._ctx, _parentState) - _prevctx = localctx - _startState = 36 - self.enterRecursionRule(localctx, 36, self.RULE_condition, _p) - try: - self.enterOuterAlt(localctx, 1) - self.state = 155 - self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,7,self._ctx) - if la_ == 1: - self.state = 144 - self.match(tlangParser.NOT) - self.state = 145 - self.condition(5) - pass - - elif la_ == 2: - self.state = 146 - self.expression(0) - self.state = 147 - self.binCondOp() - self.state = 148 - self.expression(0) - pass - - elif la_ == 3: - self.state = 150 - self.match(tlangParser.PENCOND) - pass - - elif la_ == 4: - self.state = 151 - self.match(tlangParser.T__6) - self.state = 152 - self.condition(0) - self.state = 153 - self.match(tlangParser.T__8) - pass + def comment(self): - self._ctx.stop = self._input.LT(-1) - self.state = 163 + localctx = tlangParser.CommentContext(self, self._ctx, self.state) + self.enterRule(localctx, 70, self.RULE_comment) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 340 + self.match(tlangParser.T__23) + self.state = 344 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,8,self._ctx) - while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: - if _alt==1: - if self._parseListeners is not None: - self.triggerExitRuleEvent() - _prevctx = localctx - localctx = tlangParser.ConditionContext(self, _parentctx, _parentState) - self.pushNewRecursionContext(localctx, _startState, self.RULE_condition) - self.state = 157 - if not self.precpred(self._ctx, 3): - from antlr4.error.Errors import FailedPredicateException - raise FailedPredicateException(self, "self.precpred(self._ctx, 3)") - self.state = 158 - self.logicOp() - self.state = 159 - self.condition(4) - self.state = 165 + _la = self._input.LA(1) + while _la==tlangParser.NAME: + self.state = 341 + self.match(tlangParser.NAME) + self.state = 346 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,8,self._ctx) + _la = self._input.LA(1) + self.state = 347 + self.match(tlangParser.T__23) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) self._errHandler.recover(self, re) finally: - self.unrollRecursionContexts(_parentctx) + self.exitRule() return localctx - class BinCondOpContext(ParserRuleContext): + + class LogicOpContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def EQ(self): - return self.getToken(tlangParser.EQ, 0) - - def NEQ(self): - return self.getToken(tlangParser.NEQ, 0) - - def LT(self): - return self.getToken(tlangParser.LT, 0) - - def GT(self): - return self.getToken(tlangParser.GT, 0) - - def LTE(self): - return self.getToken(tlangParser.LTE, 0) + def AND(self): + return self.getToken(tlangParser.AND, 0) - def GTE(self): - return self.getToken(tlangParser.GTE, 0) + def OR(self): + return self.getToken(tlangParser.OR, 0) def getRuleIndex(self): - return tlangParser.RULE_binCondOp + return tlangParser.RULE_logicOp def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitBinCondOp" ): - return visitor.visitBinCondOp(self) + if hasattr( visitor, "visitLogicOp" ): + return visitor.visitLogicOp(self) else: return visitor.visitChildren(self) - def binCondOp(self): + def logicOp(self): - localctx = tlangParser.BinCondOpContext(self, self._ctx, self.state) - self.enterRule(localctx, 38, self.RULE_binCondOp) + localctx = tlangParser.LogicOpContext(self, self._ctx, self.state) + self.enterRule(localctx, 72, self.RULE_logicOp) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 166 + self.state = 349 _la = self._input.LA(1) - if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << tlangParser.LT) | (1 << tlangParser.GT) | (1 << tlangParser.EQ) | (1 << tlangParser.NEQ) | (1 << tlangParser.LTE) | (1 << tlangParser.GTE))) != 0)): + if not(_la==tlangParser.AND or _la==tlangParser.OR): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -1407,40 +2724,53 @@ def binCondOp(self): self.exitRule() return localctx - class LogicOpContext(ParserRuleContext): + + class BinCondOpContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def AND(self): - return self.getToken(tlangParser.AND, 0) + def EQ(self): + return self.getToken(tlangParser.EQ, 0) - def OR(self): - return self.getToken(tlangParser.OR, 0) + def NEQ(self): + return self.getToken(tlangParser.NEQ, 0) + + def LT(self): + return self.getToken(tlangParser.LT, 0) + + def GT(self): + return self.getToken(tlangParser.GT, 0) + + def LTE(self): + return self.getToken(tlangParser.LTE, 0) + + def GTE(self): + return self.getToken(tlangParser.GTE, 0) def getRuleIndex(self): - return tlangParser.RULE_logicOp + return tlangParser.RULE_binCondOp def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitLogicOp" ): - return visitor.visitLogicOp(self) + if hasattr( visitor, "visitBinCondOp" ): + return visitor.visitBinCondOp(self) else: return visitor.visitChildren(self) - def logicOp(self): + def binCondOp(self): - localctx = tlangParser.LogicOpContext(self, self._ctx, self.state) - self.enterRule(localctx, 40, self.RULE_logicOp) + localctx = tlangParser.BinCondOpContext(self, self._ctx, self.state) + self.enterRule(localctx, 74, self.RULE_binCondOp) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 168 + self.state = 351 _la = self._input.LA(1) - if not(_la==tlangParser.AND or _la==tlangParser.OR): + if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << tlangParser.LT) | (1 << tlangParser.GT) | (1 << tlangParser.EQ) | (1 << tlangParser.NEQ) | (1 << tlangParser.LTE) | (1 << tlangParser.GTE))) != 0)): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -1453,6 +2783,7 @@ def logicOp(self): self.exitRule() return localctx + class ValueContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): @@ -1465,6 +2796,21 @@ def NUM(self): def VAR(self): return self.getToken(tlangParser.VAR, 0) + def array(self): + return self.getTypedRuleContext(tlangParser.ArrayContext,0) + + + def dataLocationAccess(self): + return self.getTypedRuleContext(tlangParser.DataLocationAccessContext,0) + + + def functionCall(self): + return self.getTypedRuleContext(tlangParser.FunctionCallContext,0) + + + def REAL(self): + return self.getToken(tlangParser.REAL, 0) + def getRuleIndex(self): return tlangParser.RULE_value @@ -1480,17 +2826,48 @@ def accept(self, visitor:ParseTreeVisitor): def value(self): localctx = tlangParser.ValueContext(self, self._ctx, self.state) - self.enterRule(localctx, 42, self.RULE_value) - self._la = 0 # Token type + self.enterRule(localctx, 76, self.RULE_value) try: - self.enterOuterAlt(localctx, 1) - self.state = 170 - _la = self._input.LA(1) - if not(_la==tlangParser.NUM or _la==tlangParser.VAR): - self._errHandler.recoverInline(self) - else: - self._errHandler.reportMatch(self) - self.consume() + self.state = 359 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,28,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 353 + self.match(tlangParser.NUM) + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 354 + self.match(tlangParser.VAR) + pass + + elif la_ == 3: + self.enterOuterAlt(localctx, 3) + self.state = 355 + self.array() + pass + + elif la_ == 4: + self.enterOuterAlt(localctx, 4) + self.state = 356 + self.dataLocationAccess() + pass + + elif la_ == 5: + self.enterOuterAlt(localctx, 5) + self.state = 357 + self.functionCall() + pass + + elif la_ == 6: + self.enterOuterAlt(localctx, 6) + self.state = 358 + self.match(tlangParser.REAL) + pass + + except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -1504,8 +2881,7 @@ def value(self): def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int): if self._predicates == None: self._predicates = dict() - self._predicates[14] = self.expression_sempred - self._predicates[18] = self.condition_sempred + self._predicates[22] = self.expression_sempred pred = self._predicates.get(ruleIndex, None) if pred is None: raise Exception("No predicate with index:" + str(ruleIndex)) @@ -1514,18 +2890,21 @@ def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int): def expression_sempred(self, localctx:ExpressionContext, predIndex:int): if predIndex == 0: - return self.precpred(self._ctx, 4) + return self.precpred(self._ctx, 9) if predIndex == 1: - return self.precpred(self._ctx, 3) + return self.precpred(self._ctx, 8) - def condition_sempred(self, localctx:ConditionContext, predIndex:int): if predIndex == 2: return self.precpred(self._ctx, 3) + if predIndex == 3: + return self.precpred(self._ctx, 2) + + diff --git a/ChironCore/turtparse/tlangVisitor.py b/ChironCore/turtparse/tlangVisitor.py index 7ac289a..e36f0bb 100644 --- a/ChironCore/turtparse/tlangVisitor.py +++ b/ChironCore/turtparse/tlangVisitor.py @@ -14,8 +14,13 @@ def visitStart(self, ctx:tlangParser.StartContext): return self.visitChildren(ctx) - # Visit a parse tree produced by tlangParser#instruction_list. - def visitInstruction_list(self, ctx:tlangParser.Instruction_listContext): + # Visit a parse tree produced by tlangParser#statement_list. + def visitStatement_list(self, ctx:tlangParser.Statement_listContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#declaration_list. + def visitDeclaration_list(self, ctx:tlangParser.Declaration_listContext): return self.visitChildren(ctx) @@ -24,6 +29,11 @@ def visitStrict_ilist(self, ctx:tlangParser.Strict_ilistContext): return self.visitChildren(ctx) + # Visit a parse tree produced by tlangParser#declaration. + def visitDeclaration(self, ctx:tlangParser.DeclarationContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by tlangParser#instruction. def visitInstruction(self, ctx:tlangParser.InstructionContext): return self.visitChildren(ctx) @@ -54,11 +64,6 @@ def visitGotoCommand(self, ctx:tlangParser.GotoCommandContext): return self.visitChildren(ctx) - # Visit a parse tree produced by tlangParser#assignment. - def visitAssignment(self, ctx:tlangParser.AssignmentContext): - return self.visitChildren(ctx) - - # Visit a parse tree produced by tlangParser#moveCommand. def visitMoveCommand(self, ctx:tlangParser.MoveCommandContext): return self.visitChildren(ctx) @@ -79,6 +84,46 @@ def visitPauseCommand(self, ctx:tlangParser.PauseCommandContext): return self.visitChildren(ctx) + # Visit a parse tree produced by tlangParser#array. + def visitArray(self, ctx:tlangParser.ArrayContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#assignment. + def visitAssignment(self, ctx:tlangParser.AssignmentContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#printStatement. + def visitPrintStatement(self, ctx:tlangParser.PrintStatementContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#multiplicative. + def visitMultiplicative(self, ctx:tlangParser.MultiplicativeContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#additive. + def visitAdditive(self, ctx:tlangParser.AdditiveContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#unaryArithOp. + def visitUnaryArithOp(self, ctx:tlangParser.UnaryArithOpContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#returnStatement. + def visitReturnStatement(self, ctx:tlangParser.ReturnStatementContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#binExpr. + def visitBinExpr(self, ctx:tlangParser.BinExprContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by tlangParser#unaryExpr. def visitUnaryExpr(self, ctx:tlangParser.UnaryExprContext): return self.visitChildren(ctx) @@ -89,6 +134,11 @@ def visitValueExpr(self, ctx:tlangParser.ValueExprContext): return self.visitChildren(ctx) + # Visit a parse tree produced by tlangParser#notExpr. + def visitNotExpr(self, ctx:tlangParser.NotExprContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by tlangParser#addExpr. def visitAddExpr(self, ctx:tlangParser.AddExprContext): return self.visitChildren(ctx) @@ -99,33 +149,88 @@ def visitMulExpr(self, ctx:tlangParser.MulExprContext): return self.visitChildren(ctx) + # Visit a parse tree produced by tlangParser#penExpr. + def visitPenExpr(self, ctx:tlangParser.PenExprContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#assignExpr. + def visitAssignExpr(self, ctx:tlangParser.AssignExprContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by tlangParser#parenExpr. def visitParenExpr(self, ctx:tlangParser.ParenExprContext): return self.visitChildren(ctx) - # Visit a parse tree produced by tlangParser#multiplicative. - def visitMultiplicative(self, ctx:tlangParser.MultiplicativeContext): + # Visit a parse tree produced by tlangParser#logExpr. + def visitLogExpr(self, ctx:tlangParser.LogExprContext): return self.visitChildren(ctx) - # Visit a parse tree produced by tlangParser#additive. - def visitAdditive(self, ctx:tlangParser.AdditiveContext): + # Visit a parse tree produced by tlangParser#classDeclaration. + def visitClassDeclaration(self, ctx:tlangParser.ClassDeclarationContext): return self.visitChildren(ctx) - # Visit a parse tree produced by tlangParser#unaryArithOp. - def visitUnaryArithOp(self, ctx:tlangParser.UnaryArithOpContext): + # Visit a parse tree produced by tlangParser#classBody. + def visitClassBody(self, ctx:tlangParser.ClassBodyContext): return self.visitChildren(ctx) - # Visit a parse tree produced by tlangParser#condition. - def visitCondition(self, ctx:tlangParser.ConditionContext): + # Visit a parse tree produced by tlangParser#classAttributeDeclaration. + def visitClassAttributeDeclaration(self, ctx:tlangParser.ClassAttributeDeclarationContext): return self.visitChildren(ctx) - # Visit a parse tree produced by tlangParser#binCondOp. - def visitBinCondOp(self, ctx:tlangParser.BinCondOpContext): + # Visit a parse tree produced by tlangParser#objectInstantiation. + def visitObjectInstantiation(self, ctx:tlangParser.ObjectInstantiationContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#dataLocationAccess. + def visitDataLocationAccess(self, ctx:tlangParser.DataLocationAccessContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#baseVar. + def visitBaseVar(self, ctx:tlangParser.BaseVarContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#lvalue. + def visitLvalue(self, ctx:tlangParser.LvalueContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#functionCall. + def visitFunctionCall(self, ctx:tlangParser.FunctionCallContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#methodCaller. + def visitMethodCaller(self, ctx:tlangParser.MethodCallerContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#functionDeclaration. + def visitFunctionDeclaration(self, ctx:tlangParser.FunctionDeclarationContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#parameters. + def visitParameters(self, ctx:tlangParser.ParametersContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#arguments. + def visitArguments(self, ctx:tlangParser.ArgumentsContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by tlangParser#comment. + def visitComment(self, ctx:tlangParser.CommentContext): return self.visitChildren(ctx) @@ -134,6 +239,11 @@ def visitLogicOp(self, ctx:tlangParser.LogicOpContext): return self.visitChildren(ctx) + # Visit a parse tree produced by tlangParser#binCondOp. + def visitBinCondOp(self, ctx:tlangParser.BinCondOpContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by tlangParser#value. def visitValue(self, ctx:tlangParser.ValueContext): return self.visitChildren(ctx)