LeastFixedPoint/java-parser-tools

Need escape syntax for grammer text.

Closed this issue · 2 comments

I need to define 'quoted strings' in my grammer.
Something like this...

quotedString ::= ("\"" {anychar} "\"")

I looked around at how other ebnf syntaxes handle this.
I can think of two ways to handle this.

1) Allow either single quotes or double quotes when defining text.
This is what the 'official' EBNF specification does.
http://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf

2) Use backslash as an escape character like I did above.
This approach would be familiar to Java programmers.

I chose appoach #1 since it is easily implemented by changing java-parsing-
tools grammer definition.




Original issue reported on code.google.com by emorning on 13 Apr 2009 at 9:07

So, the example I used will actually written thus...

quotedString ::= ('"' {anychar} '"')

Original comment by emorning on 13 Apr 2009 at 9:08

Oops, nevermind.
I just figued out that I can already escape double quotes with a single quote.
Therefore I should write above like so...

quotedString ::= ("'"" {anychar} "'"")

Original comment by emorning on 13 Apr 2009 at 9:18

  • Changed state: WontFix