Detect all text up to key term as single non-terminal

Jun 22, 2015 at 8:38 PM
Edited Jun 22, 2015 at 8:43 PM
I have the following grammar:
            StringLiteral STRING = new StringLiteral("string", "'", StringOptions.AllowsDoubledQuote);
            KeyTerm WITH = ToTerm("WITH");
            KeyTerm LIKE = ToTerm("LIKE");
            KeyTerm AND = ToTerm("AND");
            KeyTerm OR = ToTerm("OR");
            KeyTerm BY = ToTerm("BY");

            NonTerminal expression = new NonTerminal("expression");

            IdentifierTerminal id = new IdentifierTerminal("id");

            NonTerminal filterList = new NonTerminal("filterList");
            NonTerminal filter = new NonTerminal("filter");

            NonTerminal connectionFilter = new NonTerminal("connectionFilter");

            NonTerminal stringFilter = new NonTerminal("stringFilter");
            NonTerminal stringQuery = new NonTerminal("stringQuery");
            NonTerminal stringOperator = new NonTerminal("stringOperator");

            var Column = new NonTerminal("Column", id);
            var Table = new NonTerminal("Table", id);

            connectionFilter.Rule = Column + BY + Table | WITH + Table;

            stringFilter.Rule = Column + stringQuery
                              | WITH + Column + stringQuery;

            stringQuery.Rule = STRING
                             | LIKE + STRING;

            var linker = new NonTerminal("linker", AND | OR | Empty);

            filterList.Rule = MakePlusRule(filterList, linker, filter);

            filter.Rule = connectionFilter | stringFilter;

            var RootTable = new NonTerminal("RootTable", id);

            expression.Rule = RootTable + filterList;

            

            Root = expression;
Feeding it "Employees with email address like 'abc' ", I get:
Employees   with email    address    like   'abc' 
Table       with table    column     LIKE  STRING
However I want all text (including spaces) up to the "LIKE" term to be extracted in the following manner, knowing that none of the terms within the column will contain the LIKE key term :
Employees   with                email address                        like     'abc' 
Table       with                   column                            LIKE    STRING
Is there a possibility to enforce the grammar to get multiple tokens (basically all free text) into the column non-terminal (column="email address") up to the LIKE key term?

Or more general, having something like:
> Expression.Rule = TERM_ONE + InnerExpression + TERM_TWO
and knowing that InnerExpression will never contain TERM_ONE or TERM_TWO, to force the parser to take all free text between these 2 terms?
Coordinator
Jun 23, 2015 at 8:33 AM
There's a terminal FreeTextLiteral that does what you need - all text until certain terminator(s)