Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers > Re: Popularity ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 11 of 14 Topic 2372 of 2474
Post > Topic >>

Re: Popularity of compiler tools, was LRgen

by wclodius@[EMAIL PROTECTED] (William Clodius) Apr 11, 2008 at 10:09 PM

Anton Ertl <anton@[EMAIL PROTECTED]
> wrote:

><snip>
>   In particular, while I know of several tools for instruction
>   selection using tree parsing, none of them seems to be widely-used;
>   many compilers use hand-written instruction selectors, and of those
>   where I have heard that they use generated tree-parsing instruction
>   selectors, the generator was developed or extended in-house.
>
>   One explanation I have heard is that the compiler writers don't like
>   to make themselves dependent on a tool that may go away.  OTOH, gcc
>   reverted from using bison-generated parsers to hand-written ones (at
>   least for C++ and C), and I very much doubt that the future of bison
>   was the reason for that.
> <snip>

If I remember correctly they had two problems with the bison generated
grammars, poor error re****ting and a gemneral mismatch between the
grammar bein parsed and the capabilities of the tools.

The minimal grammars needed to define syntax compatible with LR
parsing leave little context for determining the cause of a syntax
error in user code.  While an LL(k) grammar provides sufficient
context for detailed error re****ting, and is compatible with an LR(k)
parser, for an LR parser generator to use this detail in aiding
language implementers it would need to add a switch to: recognize when
a given grammar is LR, but not LL(k); tell users the problems that
prevent the grammar from being LL(k); and add additional hooks to
allow the grammar developer to incor****ate the error re****ting. These
additions detract from the compact code size and high processing speed
of an LR parser, and I am unaware of any such parser that has
incor****ated sufficient error re****ting. Further some languages that
can be expressed using LR compatible grammars, cannot be rewritten to
LL(k) form. (Note however that the LR compatible grammar may generate
a language that is a subset of a language that is LL compatible, and
the LL compatible languagee may be useful in recognizing common coing
errors.) Parser generator developers have on the whole decided that an
LR parser generator should be an LR parser generator, and if language
developers want to give up the speed and flexibility of an LR grammar
for the error re****ting of an LL(k) grammar, then they should use an
LL(k) parser generator such as ANTLR.

The other problem is that C++(and to a lesser extent C) do not have
true LR grammars (let alone LL(k) ones). Awkward hacks are required to
deal with the context dependencies in C++ using an LR generator. These
context dependencies are easilly accessed in a recursive descent
parser.

[My understanding is that GCC switched to a hand-written parser
because of the difficulty of parsing the awful C++ grammar with
anything other than hand-written hacks.  The new parser may be a
little faster but that wasn't a big issue, since parse time is never a
bottleneck in a compiler. -John]
 




 14 Posts in Topic:
Re: Seeking recommendations for a Visual Parser to replace Visua
"Marcel Satchell&quo  2008-03-28 06:59:11 
Re: LRgen, was Seeking recommendations for a Visual Parser to re
"Paul B Mann" &  2008-03-31 02:35:38 
Re: LRgen, was Seeking recommendations for a Visual Parser to re
Hans-Peter Diettrich <  2008-04-01 10:32:26 
Popularity of compiler tools, was LRgen
anton@[EMAIL PROTECTED]   2008-04-06 15:25:04 
Re: Popularity of compiler tools, was LRgen
Jason Evans <joevans@[  2008-04-07 08:24:11 
Re: Popularity of compiler tools, was LRgen
Tegiri Nenashi <Tegiri  2008-04-08 13:13:38 
Re: Popularity of compiler tools, was LRgen
Hans-Peter Diettrich <  2008-04-11 15:57:04 
Re: Popularity of compiler tools, was LRgen
idbaxter@[EMAIL PROTECTED  2008-04-11 10:52:35 
Re: Popularity of compiler tools, was LRgen
Tegiri Nenashi <Tegiri  2008-04-11 17:00:09 
Re: Popularity of compiler tools, was LRgen
Walter Banks <walter@[  2008-04-11 09:28:14 
Re: Popularity of compiler tools, was LRgen
wclodius@[EMAIL PROTECTED  2008-04-11 22:09:16 
Re: parser performance, was Popularity of compiler tools, was LR
Ian Lance Taylor <ian@  2008-04-12 08:28:56 
Re: parser performance, was Popularity of compiler tools, was LR
Ian Lance Taylor <ian@  2008-04-12 13:06:06 
Re: parser performance, was Popularity of compiler tools, was LR
"Derek M. Jones"  2008-04-12 23:02:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 20:07:39 CDT 2008.