[antlr-interest] Idea: semantic grammar

Loring Craymer lgcraymer at yahoo.com
Thu May 22 13:11:02 PDT 2008


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



      



More information about the antlr-interest mailing list