private bool CheckAndReport(bool expression, SourceLoc sl, string msg) { if (!expression) { Console.WriteLine("TypeError: line {0}, col {1} :: {2}", sl.Row, sl.Col, msg); errors++; return(false); } return(true); }
public override ASTNode VisitStructDecl([NotNull] llangParser.StructDeclContext context) { string name = context.Iden().GetText(); Expression rhs = null; TypeSymbol ts = TypeSymbol.INFER_SYMOBOL(context.typename().GetText()); if (context.expr() != null) { rhs = (Expression)Visit(context.expr()); } SourceLoc sl = MakeSourceLoc(context); return(new VarDeclNode(name, rhs, ts, sl)); }
public EnumDefNode(string name, TypeSymbol type, SourceLoc sl) : base(ASTKind.EnumDef, sl) { enumname = name; Type = type; }
public ASTNode(ASTKind kind, SourceLoc sl) { this.kind = kind; this.sourceLoc = sl; }
public DeferedNode(Expression expr, SourceLoc sl) : base(ASTKind.Defer, sl) { this.expr = expr; }
public FieldAccessNode(Expression basestruct, string fieldname, SourceLoc sl) : base(ASTKind.FieldAccess, TypeSymbol.INFER_SYMOBOL(fieldname), sl) { this.basestruct = basestruct; this.fieldname = fieldname; }
public ConstListExprNode(List <Expression> elems, SourceLoc sl) : base(ASTKind.ListExpr, TypeSymbol.INFER_SYMOBOL(""), sl) { ListValue = elems; IsConstant = true; }
public ImplicitFunCallExprNode(string funname, Expression name, List <Expression> args, SourceLoc sl) : base(name, args, sl) { this.kind = ASTKind.FunCallExprImpl; this.funname = funname; }
public IfNode(Expression test, Statement body, Statement elsebody, SourceLoc sl) : base(ASTKind.If, sl) { this.test = test; this.ifbody = body; this.elsebody = elsebody; }
public ForNode(string var, Expression inlist, Statement body, SourceLoc sl) : base(ASTKind.For, sl) { this.inList = inlist; this.var = var; this.body = body; }
public WhileNode(Expression test, Statement body, SourceLoc sl) : base(ASTKind.While, sl) { this.test = test; this.body = body; }
public FunCallStmtNode(Expression name, List <Expression> args, SourceLoc sl) : base(ASTKind.FunCallStmt, sl) { this.name = name; this.funsig = this.name.Type; this.args = args; }
public AugAssignNode(Expression lhs, Expression rhs, string op, SourceLoc sl) : base(ASTKind.AugAssign, sl) { this.lhs = lhs; this.rhs = rhs; this.op = op; }
public AssignNode(Expression lhs, Expression rhs, SourceLoc sl) : base(ASTKind.Assign, sl) { this.rhs = rhs; this.lhs = lhs; }
public VarDeclNode(string name, Expression rhs, TypeSymbol type, SourceLoc sl) : base(ASTKind.VarDecl, sl) { this.name = name; this.rhs = rhs; this.Type = type; }
public BinaryExprNode(Expression lhs, Expression rhs, string op, SourceLoc sl) : base(ASTKind.BinaryExpr, TypeSymbol.INFER_SYMOBOL(""), sl) { this.lhs = lhs; this.rhs = rhs; this.op = op; }
public FunCallExprNode(Expression name, List <Expression> args, SourceLoc sl) : base(ASTKind.FunCallExpr, TypeSymbol.INFER_SYMOBOL(""), sl) { this.name = name; this.args = args; this.funsig = this.name.Type; }
public ReturnNode(Expression ret, SourceLoc sl) : base(ASTKind.Return, sl) { this.ret = ret; }
public VarListExprNode(Expression lower, Expression upper, Expression stepsize, SourceLoc sl) : base(ASTKind.ConstListExpr, TypeSymbol.INFER_SYMOBOL(""), sl) { this.lower = lower; this.upper = upper; this.stepsize = stepsize; }
public BlockNode(List <Statement> stmts, SourceLoc sl) : base(ASTKind.Block, sl) { this.stmts = stmts; }
public ArrayIndexNode(Expression array, Expression index, SourceLoc sl) : base(ASTKind.ArrayIndex, TypeSymbol.INFER_SYMOBOL("[]"), sl) { this.array = array; this.index = index; }
public IdenExprNode(string name, TypeSymbol type, SourceLoc sl) : base(ASTKind.IdenExpr, type, sl) { this.name = name; }
public NewStructNode(string name, SourceLoc sl) : base(ASTKind.NewStruct, TypeSymbol.INFER_SYMOBOL(name), sl) { }
public IntExprNode(long value, SourceLoc sl) : base(ASTKind.IntExpr, TypeSymbol.INT_SYMBOL, sl) { IntValue = value; IsConstant = true; }
public NullNode(SourceLoc sl) : base(ASTKind.Null, TypeSymbol.VOID_SYMBOL, sl) { IsConstant = true; }
public FloatExprNode(double value, SourceLoc sl) : base(ASTKind.FloatExpr, TypeSymbol.FLOAT_SYMBOL, sl) { FloatValue = value; IsConstant = true; }
public Statement(ASTKind kind, SourceLoc sl) : base(kind, sl) { }
public StringExprNode(string value, SourceLoc sl) : base(ASTKind.StringExpr, TypeSymbol.STRING_SYMBOL, sl) { StringValue = value; IsConstant = true; }
public UnaryExprNode(Expression expr, string op, SourceLoc sl) : base(ASTKind.UnaryExpr, expr.Type, sl) { this.expr = expr; this.op = op; }
public LibImportNode(string name, SourceLoc sl) : base(ASTKind.LibImport, sl) { this.libname = name; }