Exemplo n.º 1
0
        /// <summary>
        /// ExprStmt
        ///     ListExpr SEMICOLON
        /// </summary>
        /// <returns></returns>
        private ExprStmt ParseExprStmt()
        {
            ExprStmt ret = new ExprStmt(ParseExprList());

            Consume(TokenType.SEMICOLON);
            return(ret);
        }
Exemplo n.º 2
0
    Stmt ParseStmt()
    {
        Modifier       modifier = ParseModifier();
        IList <string> name1    = ParseName(); // Type of Variable
        IList <string> name2    = ParseName(); // Variable
        string         symb     = GetSymbol();

        if (name1.Count > 0 && name2.Count > 0 && symb == "(")
        {
            FuncDefinition result = new FuncDefinition();
            result.Modifier  = modifier;
            result.Type      = new AType();
            result.Type.Name = name1;
            result.Name      = name2[0];
            result.Args      = ParseArguments();
            Skip(":");
            result.Body = ParseCompoundStmt();
            return(result);
        }
        else if (name1.Count > 0 && name2.Count > 0 && symb == "=")
        {
            VarDeclaration var = new VarDeclaration();
            var.Type      = new AType();
            var.Type.Name = name1;
            var.Name      = name2[0];
            var.Expr      = ParseExpr();
            Skip(";");
            return(var);
        }
        else if (name1.Count > 0 && name2.Count == 0 && symb == "=")
        {
            VarDeclaration result = new VarDeclaration();
            return(result);
        }
        else if (name1.Count > 0 && name2.Count == 0 && symb == "(")
        {// Ex.     hello.Print(str);
            ExprStmt stmt = new ExprStmt();
            stmt.Expr = ParseFuncCall(false, name1);
            return(stmt);
        }
        else
        {
            ExprStmt stmt = new ExprStmt();
            stmt.Expr = ParseExpr();
            return(stmt);
        }
    }
Exemplo n.º 3
0
 public override Null Visit(ExprStmt node)
 {
     base.Visit(node);
     if (node.value.computedType is MetaType) {
         log.ErrorMetaTypeExpr(node.location);
     }
     return null;
 }
 public void visit_expression(ExprStmt expr_stmt)
 {
     evaluate(expr_stmt.expression);
 }
Exemplo n.º 5
0
 public void visit_expression(ExprStmt expr_stmt)
 {
     resolve(expr_stmt.expression);
 }
Exemplo n.º 6
0
    public static Int32 Parse(List<Token> src, Int32 begin, out Stmt stmt)
    {
        stmt = null;
        Expr expr;
        Int32 current = _expression.Parse(src, begin, out expr);
        if (current == -1) {
            expr = null;
            current = begin;
        }

        if (!Parser.IsSEMICOLON(src[current])) {
            return -1;
        }
        current++;

        stmt = new ExprStmt(expr);
        return current;
    }
Exemplo n.º 7
0
 private void Resolve(ExprStmt expression)
 {
     Resolve(expression.Value);
 }
Exemplo n.º 8
0
 Stmt ParseStmt()
 {
     Modifier modifier = ParseModifier();
     IList<string> name1 = ParseName();  // Type of Variable
     IList<string> name2 = ParseName();  // Variable
     string symb = GetSymbol();
     if (name1.Count > 0 && name2.Count > 0 && symb == "(")
     {
         FuncDefinition result = new FuncDefinition();
         result.Modifier = modifier;
         result.Type = new AType();
         result.Type.Name = name1;
         result.Name = name2[0];
         result.Args = ParseArguments();
         Skip(":");
         result.Body = ParseCompoundStmt();
         return result;
     }
     else if (name1.Count > 0 && name2.Count > 0 && symb == "=")
     {
         VarDeclaration var = new VarDeclaration();
         var.Type = new AType();
         var.Type.Name = name1;
         var.Name = name2[0];
         var.Expr = ParseExpr();
         Skip(";");
         return var;
     }
     else if (name1.Count > 0 && name2.Count == 0 && symb == "=")
     {
         VarDeclaration result = new VarDeclaration();
         return result;
     }
     else if (name1.Count > 0 && name2.Count == 0 && symb == "(")
     {// Ex. 	hello.Print(str);
         ExprStmt stmt = new ExprStmt();
         stmt.Expr = ParseFuncCall(false, name1);
         return stmt;
     }
     else
     {
         ExprStmt stmt = new ExprStmt();
         stmt.Expr = ParseExpr();
         return stmt;
     }
 }
Exemplo n.º 9
0
 private void Execute(ExprStmt expression)
 {
     Evaluate(expression.Value);
 }