Re: Semanctic newbie

David Engster <[email protected]>
Newsgroups gmane.emacs.cedet
Message-ID <[email protected]>
Bix writes:
> I'm looking for some information about how to use semantic to parse some
> grammar and generate the relative AST. I'm using ANTLR in different context.
> I start reading the manual but I'm a bit lost and probably I'm looking
> for some simple example ( probably start with bovine would be better.)

Starting with Bovine has the advantage that - like ANTLR - it is an LL
parser and hence easier to understand and debug (there's also a
single-step debugger). It is also more forgiving w.r.t. conflicts in the
grammar. The main disadvantage is that it is way slower than Wisent,
since it is a recursive descent algorithm.

However, the grammar format between Bovine and Wisent is actually pretty
similar. The main difference are some details in the Lexer definitions,
but they're not very hard to port. So starting a grammar in Bovine and
then later porting it to Wisent is a possibility, but also has the
danger that you'll be getting overwhelmed by conflicts, which you see
earlier when you start with Wisent right away.

> Can you help me and give me some simple example? I'm also a newbie in
> emacs so I need some guidance also how I can develop with semantic
> within emacs.

Well, you should definitely know some Emacs Lisp before diving into
this. That aside, I recommend cloning the CEDET repository, where you'll
find more examples and grammars to play with. Please see

http://cedet.sourceforge.net/bzr-repo.shtml

on how to get it. For instance, in lisp/cedet/semantic/wisent you'll
find 'calc.wy', which is a port of the Calc example grammar from the
Bison manual, as well as 'calc.el' which shows how to use it. For
understanding the grammar format, the Bison manual is a very good
resource - if you can write a Bison grammar, you shouldn't have too much
trouble writing one for Wisent.

Good luck,
David

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.