AjErl.Compiler.Parser.ParseForm C# (CSharp) Method

ParseForm() public method

public ParseForm ( ) : IForm
return IForm
        public IForm ParseForm()
        {
            Token token = this.NextToken();

            if (token == null)
                return null;

            if (token.Type == TokenType.Operator && token.Value == "-")
            {
                if (this.TryParseAtom("module"))
                    return this.ParseModuleForm();
                if (this.TryParseAtom("export"))
                    return this.ParseExportForm();
                throw new ParserException("Unknown form");
            }

            this.PushToken(token);

            var fform = this.ParseFunctionForm();
            var fforms = new List<FunctionForm>();
            fforms.Add(fform);

            while (this.TryParseToken(TokenType.Separator, ";"))
                fforms.Add(this.ParseFunctionForm());

            this.ParsePoint();

            if (fforms.Count == 1)
                return fform;

            return new MultiFunctionForm(fforms);
        }

Usage Example

Example #1
0
 private Function MakeFunction(string text)
 {
     Context context = new Context();
     Parser parser = new Parser(text);
     var form = parser.ParseForm();
     return (Function)form.Evaluate(context);
 }
All Usage Examples Of AjErl.Compiler.Parser::ParseForm