For Programmers: Free Programming Magazines  


Home > Archive > Compilers > May 2005 > Conversion to LR grammar









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Conversion to LR grammar
Alpana

2005-05-01, 9:12 pm

I want to write an LR grammar whose corresponding non-LR version is
with me. Does any algorithm exists for do this? I know some of the
tricks for conversion but had not encountered with any algorithm.
Hans Aberg

2005-05-14, 7:14 pm

alpanad@gmail.com (Alpana) wrote:

> I want to write an LR grammar whose corresponding non-LR version is
> with me. Does any algorithm exists for do this? I know some of the
> tricks for conversion but had not encountered with any algorithm.


If you just have a general grammar, and want to decide whether it is
LR(k) for some k, I think that such problem might not be decidable,
even though I do not remember for sure.

There are grammar rewritings from LR(k) to LR(1), but those are not
usable for in practical implementations. In addition, many computer
languages are context sensitive, but by clever programming, one can
put that into the semantics, and reduce to a context free
grammar. Sometimes special tweaks are needed, in the lexer or the
parser, so that one can implement a language using LL(1) or LALR(1).

So it depends really what you want to do with you language: Is it
theoretical or a practical implementation?

--
Hans Aberg
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com