public FunctionAST GenerateFunctionAST() { localVariables.Clear(); var modifier = modifierGenerator.GenerateModifier(); var prototype = GenerateFunctionPrototype(modifier); var functionAst = new FunctionAST(); functionAst.Prototype = prototype; // 中身をパース var expressions = new List <ExpressionAST>(); while (parser.LastToken.TokenType != TokenType.BlockEnd) { expressions.Add(expressionGenerator.GenerateExpressionAST()); } functionAst.Expressions = expressions; parser.ProceedToken(); // end を消費 functionAst.Variables = localVariables; return(functionAst); }
public IEnumerable <ASTBase> Parse() { var asts = new List <ASTBase>(); while (_tokenReader.HasNext) { this.ProceedToken(); switch (this.LastToken.TokenType) { case TokenType.Using: this.ProceedToken(); // using をスキップ _usings.Add(this.LastToken.Value); continue; case TokenType.Namespace: this.ProceedToken(); // namespace をスキップ _currentNamespace = this.LastToken.Value; this.ProceedToken(); // : を消費すように一個ずらす continue; } GenericModifier modifier = _modifierGenerator.GenerateModifier(); ClassPrototypeAST prototype = this.GenerateClassPrototype(modifier); ClassAST classAst = this.GenerateClassAST(prototype); asts.Add(classAst); if (this.LastToken.TokenType == TokenType.BlockEnd) { break; } } return(asts); }