Closed springcomp closed 2 years ago
Is there a way to detect ambiguous grammars with BNF Playground ?
Yes, you can detect ambiguous grammars. This tool was intentionally designed to accept ambiguous grammars to be beginner friendly.
When you click the compile button, you can see how many ways the nearley parser found to parse your grammar in you have the console open and see how large the array is that is printed beside the "bnfparser results" console message. The size of the array indicates the number of ways the grammar can be parsed.
https://nearley.js.org/docs/parser#a-note-on-ambiguity
Would there be a way to specify precedence of some sample constructs ?
Within this tool, not that I know of without serious modification.
That’s a really useful feedback. Thank you very much.
I’m trying to use the BNF Playground to model my grammar and communicate with others as this is a very handy tool.
The grammar for the language I’m helping design improvements for is originally written using ABNF.
Here is a gist that contains the same grammar in EBNF syntax for use in the playground.
I’m trying to design a new feature and try to change the
<sub_expression>
rule to accept a more general<expression>
on its right-hand side. Thus changing this rule:to this:
When doing so within the playground, everything is perfect. However, when later trying to do the same using my ABNF grammar, I get a lot of reduce/reduce conflicts that signal that the resulting grammar is ambiguous.
Is there a way to detect ambiguous grammars with BNF Playground ? Would there be a way to specify precedence of some sample constructs ?