Dear Noel and Team,
compliments! I would like to ask for your kind help please.
My objective is to write an ANTLR V4. grammar for H2 and of course lazy as
I am I would like to use the existing BNF from the CSV and because I am
very lazy I do not want to parse that myself, but use the H2 BNF parser.
I managed already to extract the H2 commands, which will go into the ANTLR
parser definition, e. g.:
SELECT [TOP term [PERCENT] [WITH TIES]] [DISTINCT [ON ( expression [, ...]
)] | ALL] selectExpression [, ...] [FROM tableExpression [, ...]] [WHERE
expression] [GROUP BY groupingElement [, ...]] [HAVING expression] [WINDOW
windowName AS windowSpecification [, ...]] [QUALIFY expression] [UNION
[ALL] | EXCEPT | MINUS | INTERSECT query] [ORDER BY selectOrder [, ...]]
[OFFSET expression ROW | ROWS] [FETCH FIRST | NEXT [expression [PERCENT]]
ROW | ROWS ONLY | WITH TIES] [LIMIT expression [OFFSET expression]] [FOR
UPDATE] ;
After some changes to the various Rule Classes, I am also able to extract
the fragments for the Lexer, e. g.:
*term*
expression
selectExpression
tableExpression
groupingElement
windowName
windowSpecification
query
selectOrder
However, I am stuck in getting the definition of these fragments from the
BNF classes.
For example, in the Spreadsheet, you have defined *TERM* as
{ value
| column
| ?[ int ]
| sequenceValueExpression
| function
| { - | + } term
| ( expression )
| arrayElementReference
| fieldReference
| query
| caseExpression
| castSpecification
| userDefinedFunctionName }
[ timeZone | intervalQualifier ]
But it seems like I can't get that definition from BNF directly, but also
not from the RuleElement term itself.
So how to get that red definition please?
Also, most of the properties in RuleList, RuleFixed, RuleOptional and
RuleElement are private and there are no public getters.
Would you like to consider/accept a patch with getters for these
properties? Especially list in RuleList is crucial.
Thank you as always and best regards
Andreas
On Wednesday, 7 October 2020 at 21:05:31 UTC+7 Andreas Reichel wrote:
>
> On Wed, 2020-10-07 at 15:57 +0200, Noel Grandin wrote:
>
> We use a top-down recursive descent parser, and we have separate
> documentation files which we pass through a build-time
>
>
> tool to generate BNF-type diagrams.
>
>
> This one, right?
>
> public static Bnf getInstance(Reader csv) throws SQLException,
> IOException {
> Bnf bnf = new Bnf();
> if (csv == null) {
> byte[] data = Utils.getResource("*/org/h2/res/help.csv*");
> csv = new InputStreamReader(new ByteArrayInputStream(data));
> }
> bnf.parse(csv);
> return bnf;
> }
>
> Thanks a lot, I appreciate!
> Andreas
>
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/h2-database/e66e8466-e6d6-4829-926e-1d9f5d7bbe94n%40googlegroups.com.