[antlr-interest] EBNF - XML representations

Hans-Juergen Rennau hrennau at yahoo.de
Sat Apr 23 17:42:55 PDT 2011


Hi YY,

to respond to your wondering: there is no primary task requiring an XML 
representation of grammars. It occurred to me when noticing that the official 
JPQL grammar references rules that do not exist, and that an XML representation 
would allow to detect such things with a simple XQuery expression, a one-liner, 
with mathematical precision.

It seems to me there is an irony in the fact that a grammar - artefact meant to 
map syntax to logical structure - is so deeply steeped in syntax itself. This is 
no criticsm, just stirring my curiosity. The terseness and expressiveness of 
EBNF is indispensible, but perhaps we should have the possibility to switch back 
and forth between the terse and an XML representation? XML is a way to present 
logical structure in pure form (I am sure you agree - the angle brackets etc. 
are only the serialization format, not the thing "itself", which is a tree of 
information items), which enables operations on the information, operations 
whose precision, aggregative nature and conciseness are difficult to attain in 
any other way. I consider this example: let there be two grammars, which differ 
in respect to embedded actions, but not in respect to rule references. If we 
have an XML representation of the grammar available, this relationship can be 
revealed with few lines of XSLT or XQuery code, but how else? I am really 
curious. An attempt to to it with a filtering parser which filters out actions 
is, in comparison, much more work to achieve and also less clear in its results, 
more in need of an interpretation ("yes, the equality of the two token streams 
(resulting from the filtering) implies that the two grammars are equal in 
respect to the rule - token reference - structure"). XML allows to express such 
relationships rather explicitly and very tersely. Another example would be the 
possibility to detect equivalence of rules in spite of different choices of rule 
names. I imagine that such relationships may be important when trying to 
integrate work from different sources, or relating own work to existing work.  

Cheers,
-- Hans-Juergen

~~~

Hi,

I had a similar thought myself that this could be very handy while
jumping into the markup realm.

XML itself is described using an adaptation of EBNF. There is also a
respective ISO standard for EBNF.
But I am unaware of any XML (markup) representation of ENBF syntax. I
believe it is not so complicated to produce a XSD for this and s.o.

I wonder if there is any primary task you are urgent to solve with
this besides satisfying own transformation joy?


On Thu, Apr 21, 2011 at 10:55 AM, Hans-Juergen Rennau <hrennau at yahoo.de> wrote:
> Hello People,
>
> is there a translator which transforms an EBNF document into an XML
> representation? And... is there a standardized XML representation of EBNF
> grammers?
>
> The reason for my question: such a representation might enable to write tools
> creating "grammer reports" with little effort and high precision, e.g. using
> XSLT 2.0 or XQuery. (Example for such reporting: "show for each rule the rules
> directly or indirectly referencing this rule".) And it might be a very
> appropriate source for generating configurable "standard" transformations into
> ANTLR grammers, or so I think at least.
>
> Kind regards from
> -- Hans-Juergen
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
>http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>



-- 
With best regards,
Y.Y.



More information about the antlr-interest mailing list