Esempio n. 1
0
 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);
 }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
 public EnumDefNode(string name, TypeSymbol type, SourceLoc sl) : base(ASTKind.EnumDef, sl)
 {
     enumname = name;
     Type     = type;
 }
Esempio n. 4
0
 public ASTNode(ASTKind kind, SourceLoc sl)
 {
     this.kind      = kind;
     this.sourceLoc = sl;
 }
Esempio n. 5
0
 public DeferedNode(Expression expr, SourceLoc sl) : base(ASTKind.Defer, sl)
 {
     this.expr = expr;
 }
Esempio n. 6
0
 public FieldAccessNode(Expression basestruct, string fieldname, SourceLoc sl) : base(ASTKind.FieldAccess, TypeSymbol.INFER_SYMOBOL(fieldname), sl)
 {
     this.basestruct = basestruct;
     this.fieldname  = fieldname;
 }
Esempio n. 7
0
 public ConstListExprNode(List <Expression> elems, SourceLoc sl)
     : base(ASTKind.ListExpr, TypeSymbol.INFER_SYMOBOL(""), sl)
 {
     ListValue  = elems;
     IsConstant = true;
 }
Esempio n. 8
0
 public ImplicitFunCallExprNode(string funname, Expression name, List <Expression> args, SourceLoc sl) : base(name, args, sl)
 {
     this.kind    = ASTKind.FunCallExprImpl;
     this.funname = funname;
 }
Esempio n. 9
0
 public IfNode(Expression test, Statement body, Statement elsebody, SourceLoc sl) : base(ASTKind.If, sl)
 {
     this.test     = test;
     this.ifbody   = body;
     this.elsebody = elsebody;
 }
Esempio n. 10
0
 public ForNode(string var, Expression inlist, Statement body, SourceLoc sl) : base(ASTKind.For, sl)
 {
     this.inList = inlist;
     this.var    = var;
     this.body   = body;
 }
Esempio n. 11
0
 public WhileNode(Expression test, Statement body, SourceLoc sl) : base(ASTKind.While, sl)
 {
     this.test = test;
     this.body = body;
 }
Esempio n. 12
0
 public FunCallStmtNode(Expression name, List <Expression> args, SourceLoc sl) : base(ASTKind.FunCallStmt, sl)
 {
     this.name   = name;
     this.funsig = this.name.Type;
     this.args   = args;
 }
Esempio n. 13
0
 public AugAssignNode(Expression lhs, Expression rhs, string op, SourceLoc sl) : base(ASTKind.AugAssign, sl)
 {
     this.lhs = lhs;
     this.rhs = rhs;
     this.op  = op;
 }
Esempio n. 14
0
 public AssignNode(Expression lhs, Expression rhs, SourceLoc sl) : base(ASTKind.Assign, sl)
 {
     this.rhs = rhs;
     this.lhs = lhs;
 }
Esempio n. 15
0
 public VarDeclNode(string name, Expression rhs, TypeSymbol type, SourceLoc sl) : base(ASTKind.VarDecl, sl)
 {
     this.name = name;
     this.rhs  = rhs;
     this.Type = type;
 }
Esempio n. 16
0
 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;
 }
Esempio n. 17
0
 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;
 }
Esempio n. 18
0
 public ReturnNode(Expression ret, SourceLoc sl) : base(ASTKind.Return, sl)
 {
     this.ret = ret;
 }
Esempio n. 19
0
 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;
 }
Esempio n. 20
0
 public BlockNode(List <Statement> stmts, SourceLoc sl) : base(ASTKind.Block, sl)
 {
     this.stmts = stmts;
 }
Esempio n. 21
0
 public ArrayIndexNode(Expression array, Expression index, SourceLoc sl) : base(ASTKind.ArrayIndex, TypeSymbol.INFER_SYMOBOL("[]"), sl)
 {
     this.array = array;
     this.index = index;
 }
Esempio n. 22
0
 public IdenExprNode(string name, TypeSymbol type, SourceLoc sl) : base(ASTKind.IdenExpr, type, sl)
 {
     this.name = name;
 }
Esempio n. 23
0
 public NewStructNode(string name, SourceLoc sl) : base(ASTKind.NewStruct, TypeSymbol.INFER_SYMOBOL(name), sl)
 {
 }
Esempio n. 24
0
 public IntExprNode(long value, SourceLoc sl) : base(ASTKind.IntExpr, TypeSymbol.INT_SYMBOL, sl)
 {
     IntValue   = value;
     IsConstant = true;
 }
Esempio n. 25
0
 public NullNode(SourceLoc sl) : base(ASTKind.Null, TypeSymbol.VOID_SYMBOL, sl)
 {
     IsConstant = true;
 }
Esempio n. 26
0
 public FloatExprNode(double value, SourceLoc sl) : base(ASTKind.FloatExpr, TypeSymbol.FLOAT_SYMBOL, sl)
 {
     FloatValue = value;
     IsConstant = true;
 }
Esempio n. 27
0
 public Statement(ASTKind kind, SourceLoc sl) : base(kind, sl)
 {
 }
Esempio n. 28
0
 public StringExprNode(string value, SourceLoc sl) : base(ASTKind.StringExpr, TypeSymbol.STRING_SYMBOL, sl)
 {
     StringValue = value;
     IsConstant  = true;
 }
Esempio n. 29
0
 public UnaryExprNode(Expression expr, string op, SourceLoc sl) : base(ASTKind.UnaryExpr, expr.Type, sl)
 {
     this.expr = expr;
     this.op   = op;
 }
Esempio n. 30
0
 public LibImportNode(string name, SourceLoc sl) : base(ASTKind.LibImport, sl)
 {
     this.libname = name;
 }