public Expression Parse_Chain() { Tuple <Token, string> t = consume(Token.ID); Expression expr = new IDExpression(t.Item2); return(Parse_ChainHelp(expr)); }
public Expression Parse_ChainHelp(Expression expr) { if (Lookahead() == Token.LParen) { consume(Token.LParen); List <Expression> args = new List <Expression>(); if (Lookahead() != Token.RParen) { args.Add(Parse_Expressison()); while (Lookahead() == Token.Comma) { consume(Token.Comma); args.Add(Parse_Expressison()); } } consume(Token.RParen); return(Parse_ChainHelp(new FunctionCallExpression(expr, args))); } else if (Lookahead() == Token.Dot) { consume(Token.Dot); if (Lookahead() == Token.LParen) { consume(Token.LParen); Expression right_expr = Parse_Expressison(); consume(Token.RParen); return(Parse_ChainHelp(new DotExpression(expr, right_expr))); } else { Tuple <Token, string> t = consume(Token.ID); Expression right_expr = new IDExpression(t.Item2); return(Parse_ChainHelp(new DotExpression(expr, right_expr))); } } else { return(expr); } }