/// <summary> /// ExprStmt /// ListExpr SEMICOLON /// </summary> /// <returns></returns> private ExprStmt ParseExprStmt() { ExprStmt ret = new ExprStmt(ParseExprList()); Consume(TokenType.SEMICOLON); return(ret); }
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); } }
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); }
public void visit_expression(ExprStmt expr_stmt) { resolve(expr_stmt.expression); }
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; }
private void Resolve(ExprStmt expression) { Resolve(expression.Value); }
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; } }
private void Execute(ExprStmt expression) { Evaluate(expression.Value); }