I'm new to this, but a few days ago I was asking on a different list
whether anybody had a YACC description for parsing YACC... which is
essentially what you're looking for I think?
Your goal is to parse arbitrary grammars in order to be able to reflect
upon their structure (that XML is your desired output format, enabling
to use some of it's common 'tool chain' is more or less irrelevant in
this case)?
I'm not sure it is difficult at all to build a grammar for parsing
grammars, I am just less convinced as time goes by whether that's a
really useful thing to do.
It's all very well knowing how rules are related (these are the kinds of
things ANTLRWorks excels at showing anyway) but most of the time what
would be really useful is to be able to get better access to the state
of the living breathing compiler ( a beast whose only real description
is the pushdown state machine, whose state is then intimately connected
to where you happen to be in your inputs). For that, somebody here
recommended XTEXT.
I do, however, agree that the way grammars are described (and work)
seems not to have been designed to make it easy for meta-grammars (I
don't know how else to put it, I'm afraid I'm still too green to know
the vocabulary here :-) )
B
On 24/04/2011 02:42, Hans-Juergen Rennau wrote:
> 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<[email protected]>
> 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
>>
>
>
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.