Hi Eric,
I finally got time to work on an uniform way to plug the different
parsers into Semantic :-)
Attached you will find a tarball of all the files I updated (mainly in
wisent stuff) to achieve that. Just notice that this work, even if
all seems to work well, is probably alpha-release quality and needs
more testing ;-)
The tarball contains a ChangeLog. Here is an overview of new design.
After studying the code in semantic.el I observed that the only
function which is actually specific to the parser is
`semantic-bovinate-nonterminal'. All other parser related functions
rely on it!
So I concluded that the more natural way to plug new parsers in
Semantic would be to allow overriding of that function!
IMO, this design has several advantages:
- It is very simple, only one function need to be overrode.
- It permits to reuse most of the existing parsing code.
- Semantic's behavior is consistent, as it not depends on the parser
actually used.
The main requirement with a such design is that the new parser must be
able to parse one nonterminal at a time! Because
`semantic-bovinate-nonterminal' must return one raw semantic token at
each call. Fortunately the current LL and LALR parsers can do that
:-)
In the attached first implementation, I made the following changes in
semantic.el:
- Removed all references to the default nonterminal symbol
'bovine-toplevel which is specific to the LL parser. Now the
default nonterminal is nil! These references were unnecessary
because `semantic-bovinate-nonterminal' already used
'bovine-toplevel as the default nonterminal value.
- Created a new buffer-local variable `semantic-bovinate-parser' that
specifies the override function for `semantic-bovinate-nonterminal'.
- Renamed `semantic-bovinate-nonterminal' to
`semantic-bovinate-nonterminal-default'.
- Implemented `semantic-bovinate-nonterminal' as a wrapper to call
the function specified in `semantic-bovinate-parser', or to call
`semantic-bovinate-nonterminal-default' by default.
- Fixed a little problem in `semantic-bovinate-nonterminals' that
didn't correctly setup the 'reparse-symbol property of expanded
tokens.
The rest of my work consisted in updating Wisent's stuff to obey the
new API! As you will notice I removed a lot of code no more
necessary, from wisent-bovine.el ;-)
Unfortunately the new design has broken the wisent-java.wy/el
implementation which was designed to parse a Java source in one pass
like traditional bison use _ that is the grammar returns a list of
tokens ready for use instead of one raw token as required by the
`semantic-bovinate-nonterminal' API :-(
IMO, this is not really a big issue. It is far better to use the
"semantic orthodox" implementation in wisent-java-tags.wy/el!
I am looking forward for you remarks ;-)
Thank you for your time!
David
__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@...! http://shopnow.netscape.com/
Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
|