public static FTL.AST.INode Parse(CharStream cs) { FTL.AST.INode expression = Expresson.Parse(cs); int bufferPos = cs.Position; WhiteSpace.Parse(cs); if (cs.PeekNext() != SEPERATOR[0]) { // it's not a select expression, so let's return early cs.Rewind(bufferPos); return(expression); } // it must be a select expression cs.SkipString(SEPERATOR); WhiteSpace.Parse(cs); // we expect now a memberList (REQUIRED) FTL.AST.MemberList memberList = MemberList.Parse(cs); // skip extra new-line in case one is available if (CharStream.IsNL(cs.PeekNext())) { NewLine.Parse(cs); } // return it all return(new FTL.AST.SelectExpression(expression, memberList)); }
private void checkValidExpression <T>(string input, string rest = "") { var cs = NCS(input); var expression = Expresson.Parse(cs); Assert.IsNotNull(expression); Assert.AreEqual(rest, cs.ReadUntilEnd()); Assert.AreEqual(typeof(T), expression.GetType()); }