[antlr-interest] Idea: semantic grammar

Adam Connelly adam.rpconnelly at googlemail.com
Sat May 24 05:41:25 PDT 2008


Point taken.  I might have a look at the ErrorManager plus template solution
you mentioned since it sounds interesting.  There definitely seems to be a
gap anyway where error reporting could be made a lot easier - but maybe
doing so would take too much control away.

I know how I would like to do things anyway (not that that's the right way
:))

Cheers,
Adam

2008/5/24 Loring Craymer <lgcraymer at yahoo.com>:

> Yes on separation (I rather like the ErrorManager plus template solution
> that Ter used in the ANTLR 3 tool), and a skeptical "maybe" on widespread
> commonality of errors.  "How should you report an error to the user" rarely
> has a single, correct answer.  Users of different applications have
> different problem perspectives, so that the same error occurring in two
> different applications might or might not be properly reported with the same
> error message.  It all depends on how the user will react to the
> message--different kinds of users tends to mean different error reports are
> likely to be effective.
>
> --Loring
>
>
> ----- Original Message ----
> From: Adam Connelly <adam.rpconnelly at googlemail.com>
> To: Loring Craymer <lgcraymer at yahoo.com>
> Cc: Johannes Luber <JALuber at gmx.de>; antlr-interest at antlr.org
> Sent: Friday, May 23, 2008 5:01:30 PM
> Subject: Re: [antlr-interest] Idea: semantic grammar
>
> Ok, but do you think it would be fair to say that there is a separation
> between the method that you use to identify that an error has occurred, the
> method used to generate an error message, and what you then do with that
> message?  Also, is it fair to assume that many applications share a very
> similar set of errors (I've got no idea about this one since I'm pretty much
> only familiar with compiled programming languages)?
>
> Adam
>
> 2008/5/22 Loring Craymer <lgcraymer at yahoo.com>:
>
>> Johannes, Adam--
>>
>> Yes, Yggdrasil will let you do the analysis in a target-independent way.
>>  Semantics, however, are application-dependent, not language-dependent.  If
>> your application processes a language as a compiler, then it finds compiler
>> errors.  On the other hand, if the application is a static analyzer, then
>> you have a different set of errors--race condition detection or memory
>> leaks, and so forth.
>>
>> --Loring
>>
>> ----- Original Message ----
>> > From: Johannes Luber <JALuber at gmx.de>
>> > To: Adam Connelly <adam.rpconnelly at googlemail.com>;
>> antlr-interest at antlr.org
>> > Sent: Thursday, May 22, 2008 9:09:53 AM
>> > Subject: Re: [antlr-interest] Idea: semantic grammar
>> >
>> > > Hi,
>> > > I don't know if there is anything like this about at the moment, or
>> even
>> > > if
>> > > it's a good idea.  What I've been thinking about is having a grammar
>> that
>> > > defines the semantics of a language that parsers can then import.  It
>> > > would
>> > > basically be a list of the possible types of semantic error that could
>> > > occur, along with any information necessary to generate an error
>> message,
>> > > and an action that creates the message.
>> > >
>> > > >>From this a number of exception classes would be generated, along
>> with a
>> > > MessageCreator that would generate error messages based on the actions
>> > > supplied.  Inside the parser grammar, when semantic predicates are
>> > > declared,
>> > > the type of error would be indicated, and from this the correct
>> exception
>> > > would be thrown.  The parser would then ask its ErrorReporter to
>> handle
>> > > the
>> > > error, which would use the MessageCreator to create the error message,
>> and
>> > > would then add it to a list / print to the console / whatever.
>> > >
>> > > >>From this, "catalogs" of pre-defined semantic errors could be
>> provided
>> > > along
>> > > with the correct messages to display for these errors.  Obviously this
>> > > wouldn't define the actual semantics of the language (since you'd
>> still
>> > > need
>> > > to implement this in actions), but it would simplify the error
>> reporting
>> > > part since users would just import the correct semantics, then
>> indicate
>> > > when
>> > > a certain semantic error should be thrown.
>> > >
>> > > Any thoughts?
>> > > Adam
>> >
>> > A nice idea but probably infeasible. There are too many semantic
>> differences for
>> > basically one thing - recently I read an article about "PHP sucks" and
>> saw that
>> > references were handled in 4.3, 4.4 and 5 differently. Granted, 4.3 was
>> leaky
>> > and 4.4 made it too complicated, so restricting options to sensible ones
>> has a
>> > benefit, but if you want to be able to parse even the most idiotic
>> things, you
>> > have to able to define arbitrary semantics. And then you can use the
>> target
>> > language itself.
>> >
>> > Maybe Yggdrasil of Loring Craymer can do that in target independent
>> manner, but
>> > it would be basically still Turing equivalent. At least you can do far
>> more
>> > things target independent in Yggdrasil than in ANTLR - just a shame,
>> that he
>> > didn't got around to finish it yet.
>> >
>> > Johannes
>> > --
>> > Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
>> > Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
>>
>>
>>
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080524/d2876bbc/attachment.html 


More information about the antlr-interest mailing list