Closed haexhub closed 5 years ago
Hello,
I've got a question about writing the right grammer for relational algebra.
$.RULE('tableExpression', () => { $.OPTION(() => { $.CONSUME(openBrace) }) $.OR([ { ALT: () => $.CONSUME(Identifier, { LABEL: 'tableName' }) } , { ALT: () => $.SUBRULE($.renameClause) } ]) $.OPTION1(() => { $.CONSUME(closeBrace) }) })
It is optional to write a table expression with and without braces. But if an open brace is used, than there must be a closing brace. For example:
π column_a, column_b table_name
is as valid as
π column_a, column_b (table_name)
but its not valid to write it like this
π column_a, column_b table_name)
nor
π column_a, column_b (table_name
How do i check this? In fact, it is also allowed to use as much braces as wanted, but for each open brace a corresponding close brace is needed.
(((( π column_a, column_b (table_name) ))))
is valid too.
Thank you very much for help.
Have a look here. https://github.com/SAP/chevrotain/blob/master/examples/grammars/calculator/calculator_pure_grammar.js#L121-L135
Your are incredible fast in answering! Thank you very much, I'll have a look! :)
re-open this if any farther help is required
Hello,
I've got a question about writing the right grammer for relational algebra.
It is optional to write a table expression with and without braces. But if an open brace is used, than there must be a closing brace. For example:
is as valid as
but its not valid to write it like this
nor
How do i check this? In fact, it is also allowed to use as much braces as wanted, but for each open brace a corresponding close brace is needed.
is valid too.
Thank you very much for help.