Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find rule for token #5

Closed
schuemie opened this issue Feb 16, 2017 · 3 comments
Closed

Cannot find rule for token #5

schuemie opened this issue Feb 16, 2017 · 3 comments
Labels

Comments

@schuemie
Copy link

I am probably abusing Bullwinkle in several ways, but could use some guidance in how to do it right.

I've converted the ANSI SQL BNF to what I think it the correct Bullwinkle syntax: sql_bnf.txt

I then tried to parse some simple SQL:

File file = new File("sql_bnf.txt");
try {
	BnfParser parser = new BnfParser(file);
	ParseNode node = parser.parse("SELECT * FROM my_table WHERE x = 5;");
} catch (InvalidGrammarException | IOException | ParseException e) {
	e.printStackTrace();
}

which results in this error message:

Cannot find rule for token <SQL_language_character>
	at ca.uqac.lif.bullwinkle.BnfParser.parse(BnfParser.java:483)
	at ca.uqac.lif.bullwinkle.BnfParser.parse(BnfParser.java:398)
	at org.ohdsi.parserTest.BullwinkleTest.main(BullwinkleTest.java:28)

I tried both the latest release (v1.3) as well as the current version in master, with no difference in results.

Help?

@sylvainhalle
Copy link
Owner

Hi Martijn,

First, thanks for your interest in Bullwinkle! I think the problem is that your BNF file uses ::= instead of := to separate the non-terminal symbol from its cases. Try that and let me know if this fixes your problem.

On a side note, I see that the grammar defines rules down to the level of single characters, for example to define the format of a valid identifier. BW was designed to parse whitespace-separated sequences of words, so I'm not sure this is a good fit for it. This could probably be better represented in Bullwinkle as a regex that defines the format of a particular word.

Best!

@schuemie
Copy link
Author

Thanks! Changing ::= to := solved the error message, but now the parser produces a null object.

Now that I'm reading the instructions more thoroughly I see that Bullwinkle support only the basic BNF syntax, and not fancy things like optional elements [] and repetition * like mentioned here. I guess those are not on the development path for Bullwinkle?

@sylvainhalle
Copy link
Owner

sylvainhalle commented Feb 27, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants