alternative keywords/symbols

Jul 18, 2010 at 12:42 PM

My question is, what is the best way to specify a grammar for a language where there are alternative symbols.

For example, I want to support a query statement in this form:

"SELECT DIMENSIONS a,b,c ON ROWS"

but also have this be valid so that queries can be shorter:

"SELECT D a,b,c ON R"

Coordinator
Jul 22, 2010 at 6:29 PM
Sorry for the delay, was hoping somebody would jump in.. :) Well, there's no magic, just declare intermediate non-terminals for keywords: var dim = new NonTerminal("Dim"); dim.Rule = ToTerm("DIMENSIONS") | "D"; and use this "dim" term in your expressions.