[Mondrian] RE: MDX Grammar (Parser.cup)

Julian Hyde julianhyde at speakeasy.net
Thu Jan 25 02:59:51 EST 2007

The formal specifications of computer languages often contain a grammar, and
implementors of the language often feel they should convert that grammar
literally into a parser-generator.
In my experience, that is generally a mistake. Low-level tokens such as
identifiers, keywords and numbers are better handled by a tokenizer before
the parser is invoked, and semantic validation is better done by a
validation phase after the parser has finished.
This results in a more efficient, more maintainable grammar and better error
messages. It also makes it possible to extend the language at runtime,
without changing the grammar.
This was the approach I took with mondrian's grammar. I didn't want to have
to change the grammar each time I implemented a new function, so I made the
grammar recognize the general syntax of a function call:
value_expression_primary ::=
    |   identifier:i LPAREN exp_list_opt:lis RPAREN {:
            RESULT = new UnresolvedFunCall(
                i.name, Syntax.Function, Parser.toExpArray(lis));

and created the BuiltinFunTable as a data-driven way to determine what
function names were valid.
The DrilldownLevel function is defined by the class DrilldownLevelFunDef and
registered in BuiltinFunTable.
If I were implementing the MDX grammar today, I would do most of it the same
-- but I would use javacc rather than JavaCUP, because it's more modern and
efficient and more actively maintained.


From: Joel da Silva [mailto:joeldasilva at gmail.com] 
Sent: Wednesday, January 24, 2007 7:29 PM
To: Julian Hyde
Subject: MDX Grammar (Parser.cup)

I am studying the mdx grammar in the file Parser.cup, which is contained in
the mondrian source directory  and I have some doubts:  
The mdx grammar int the Parser.cup file   seems to me simplified  and
differs of the original MDX Grammar of the OLE DB reference.   
Why it is simplified?  
For example, why the  " DRILLDOWNLEVEL(<set> [, <level>]]) " specification
is ignored in the Parser.cup grammar?  
Why the <set>, <member>, and <tuple> specification and many others are
Where the tokens ROWS and COLUMNS  are defined?

Can you help me?
thanks for your attention
best regards 
Joel Silva

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20070124/5ba03004/attachment.html 

More information about the Mondrian mailing list