Re: Overlay and actions/OLE

David Engster <[email protected]> Sat, 10 Jan 2015 16:31:36 +0100
Newsgroups gmane.emacs.cedet
Message-ID <[email protected]>
Martin Stein writes:
>> It might also be that you'd be more happy with Wisent, which is
>> Semantic's LALR parser (pretty much a Bison port).

> Is there a particular advantage of Wisent with respect to Fortran.

No, not really. The resulting parser is faster. I also think error
handling is better, and it is better documented, simply because large
parts of the Bison manual directly apply to Wisent. I'd also say that
setting up the Lexer is a bit cleaner.

> The only interesting piece of information I stumbled upon was that old
> languages have been defined to facilitate LL parsing with at most most
> one look-ahead as there were efficient algorithms back then - 60-70
> years ago :) Coupled with the fact that the c.by/c.el parser is a good
> example to learn or copy from I went for (or rather stayed with)
> bovine.

As I've written, I find this shift/reduce parsing pretty much impossible
to debug. I hear that this gets better with experience, but I didn't
have the patience, so I stayed with LL.

>> Yeah well, I ducked that one. The preprocessor is handled as a special
>> lexer (see lex-spp.el) and isn't directly tied to C/C++, so it should be
>> reusable for Fortran.

> I have already seen as much. As far as I know, fortran preprocessors
> are somewhat more restrictive than C preprocessors (e.g. no ## concat,
> no continuation lines).

Yes, that's what I remember from my Fortran days as well. It's usually
just #include and #define and the macros are fairly simple. That should
work reasonably fine.

>> but for now I'm rather looking into writing a GCC plugin instead to pretty
>> much replace our existing parser, which will also get rid of "the
>> preprocessor problem".

> How does gcc produce tags (or a readable parse tree)? If gcc can do
> that, gfortran might be suitable as well.

Unfortunately, that project just died on emacs-devel because of Richard
Stallman's intervention. GCC does not produce a readable parse tree,
this is precisely what Stallman does not want. But inside a plugin, you
have access to the AST, and hence you can walk the tree and produce
Semantic tags as output. And indeed, my hope was that if we can do that
for C++, it wouldn't be too much work to do this for other frontends as
well, like Fortran, Java, Ada and Go. That would have been nice.

-David

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net