LeastFixedPoint/java-parser-tools

Support extention syntax in grammar

Opened this issue · 2 comments

I have been ponering how to define quoted string in my Turtle grammar 
definition.   Currently I have this (which is not sufficient)...

quotedString ::= ("'"" {anychar} "'"")
anychar ::= (%alpha% | %digit% | " " | ":" | ".")  

What I really need is a quoted string matcher like the one defined in the 
info.reflectionsofmind.parser.Grammar class.

However, in order to be able to use a custom Matcher I would have to 
abandon my grammar defintion file and instead define the Turtle grammar in 
Java, using the info.reflectionsofmind.parser API.

However, if an extension syntax is added to the grammar definition then it 
would be possible to create Matchers in Java and refer to them in the 
grammer.
There is an example of EBNF extension syntax in this article...
http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form

Basically, in java-parser-ttols, the extension syntax would allow a 
Matcher defined in Java to be assigned to a named matcher in the grammar 
definitionwork.  Here is an example...

quotedString= ?info.reflectionsofmind.parser.QuotedStringMatcher?

...where the contents between the question marks names a class that 
implements a Matcher.



Original issue reported on code.google.com by emorning on 14 Apr 2009 at 6:08

NOTE: Intead of using ? to delimit extension I could just extend the current % 
syntax to support class names.
Thus my example would become...

quotedString= %info.reflectionsofmind.parser.QuotedStringMatcher%

Original comment by emorning on 14 Apr 2009 at 6:25

Yes, I agree that this is a very nice feature to have.

Original comment by shooshpa...@gmail.com on 19 Sep 2009 at 8:50