private void checkout(AstNode theNode) { foreach (AstNode node in theNode.Children) { if (node is BinOpNode) { BinOpNode bnode = ((BinOpNode)node); if (((BinOpNode)node).BinOp == BinaryOperation.Assignment) { if (!result.Symbols.Contains(bnode.Left.ToString())) { result.Symbols.Add(bnode.Left.ToString()); } } } else { checkout(node); } } foreach (AstNode node in theNode.Children) { if (node is FuncNode) { FuncNode fnode = ((FuncNode)node); currentLocalScope = new LocalScope(); result.ChildScopes[fnode.Name] = currentLocalScope; currentLocalScope.Symbols.AddRange(fnode.Parameters); analyseLocalCode(fnode.Body); } } }
public static AstNode Parse(Parser.Parser parser) { if (parser.MatchToken(TokenType.Identifier, "if")) { return(IfNode.Parse(parser)); } else if (parser.MatchToken(TokenType.Identifier, "while")) { return(WhileNode.Parse(parser)); } else if (parser.MatchToken(TokenType.Identifier, "for")) { return(ForNode.Parse(parser)); } else if (parser.MatchToken(TokenType.Identifier, "foreach")) { return(ForEachNode.Parse(parser)); } else if (parser.MatchToken(TokenType.Identifier, "try")) { return(TryNode.Parse(parser)); } else if (parser.MatchToken(TokenType.Identifier, "func")) { return(FuncNode.Parse(parser)); } else if (parser.MatchToken(TokenType.Identifier, "thread")) { return(ThreadNode.Parse(parser)); } else if (parser.MatchToken(TokenType.Identifier, "return")) { return(ReturnNode.Parse(parser)); } else if (parser.MatchToken(TokenType.Brace, "{")) { return(CodeBlock.Parse(parser)); } else { AstNode expr = ExpressionNode.Parse(parser); parser.ExpectToken(TokenType.EndOfLine); return(expr); } }
public HassiumFunction(Interpreter interpreter, FuncNode funcNode, LocalScope localScope) { this.interpreter = interpreter; this.funcNode = funcNode; this.localScope = localScope; }