public static FTL.AST.CallExpression Parse(CharStream cs, FTL.AST.StringPrimitive builtin) { if (!Builtin.IsValid(builtin.Value)) { throw cs.CreateException( string.Format("{0} is not a valid builtin, while one was expected", builtin.Value), null); } cs.SkipCharacter(PREFIX); FTL.AST.ArgumentsList arguments = new FTL.AST.ArgumentsList(); while (cs.PeekNext() != POSTFIX) { WhiteSpace.Parse(cs); arguments.AddArgument(Argument.Parse(cs)); WhiteSpace.Parse(cs); if (cs.PeekNext() != ',') { break; // exit early, as no more arguments are expected } cs.SkipNext(); // skip ',' } // make sure last non-ws char is ')', // otherwise something went wrong cs.SkipCharacter(POSTFIX); return(new FTL.AST.CallExpression(builtin, arguments)); }
public static FTL.AST.INode Parse(CharStream cs) { FTL.AST.INode node; // could be <identifier>/<keyword> if (Identifier.PeekAndParse(cs, out node)) { // do we also require a keyword? if (cs.PeekNext() == '/') { cs.SkipNext(); // '/' FTL.AST.StringPrimitive keyword = Keyword.Parse(cs); return(new FTL.AST.Attribute( node as FTL.AST.StringPrimitive, // node == identifier keyword)); } // it's just an identifier that's used as a member-key return(node); } // it must a number that's used as a member-key node = Number.Parse(cs); return(node); }
public static FTL.AST.MemberExpression Parse(CharStream cs, FTL.AST.StringPrimitive identifier) { cs.SkipCharacter(PREFIX); FTL.AST.StringPrimitive keyword = Keyword.Parse(cs); cs.SkipCharacter(POSTFIX); return(new FTL.AST.MemberExpression(identifier, keyword)); }
public static FTL.AST.INode ParseWithIdentifier( CharStream stream, FTL.AST.StringPrimitive identifier) { if (MemberExpression.Peek(stream)) { return(MemberExpression.Parse(stream, identifier)); } if (CallExpression.Peek(stream)) { return(CallExpression.Parse(stream, identifier)); } return(new FTL.AST.Reference(identifier)); }
private static FTL.AST.Message Parse(CharStream cs, Context ctx, FTL.AST.StringPrimitive identifier) { WhiteSpace.Parse(cs); cs.SkipCharacter('='); WhiteSpace.Parse(cs); FTL.AST.Pattern pattern = null; // check if we have a Pattern available bool hasPattern = Pattern.PeekAndParse(cs, out pattern); FTL.AST.MemberList memberList; bool parsedMemberList = MemberList.PeekAndParse(cs, out memberList); if (!parsedMemberList && !hasPattern) { throw cs.CreateException( "member-list was expected, as no pattern was found", null); } return(new FTL.AST.Message(identifier, pattern, memberList)); }
public static FTL.AST.Variable Parse(CharStream cs) { cs.SkipCharacter(PREFIX); FTL.AST.StringPrimitive identifier = Identifier.Parse(cs); return(new FTL.AST.Variable(identifier)); }