Flex/Bison/ANTLR question... alternative tools for translation?

rgaupsas <elikon@cox.net>
15 Mar 2005 01:42:26 -0500

          From comp.compilers

Related articles
Flex/Bison/ANTLR question... alternative tools for translation? elikon@cox.net (rgaupsas) (2005-03-15)
Re: Flex/Bison/ANTLR question... alternative tools for translation? lfinsto1@gwdg.de (Laurence Finston) (2005-03-18)
Re: Flex/Bison/ANTLR question... alternative tools for translation? Brian.Inglis@SystematicSW.ab.ca (Brian Inglis) (2005-03-20)
Re: Flex/Bison/ANTLR question... alternative tools for translation? sk@z.pl (Sebastian) (2005-03-20)
Re: Flex/Bison/ANTLR question... alternative tools for translation? elikon@cox.net (rgaupsas) (2005-03-24)
Re: Flex/Bison/ANTLR question... alternative tools for translation? Brian.Inglis@SystematicSW.ab.ca (2005-03-25)
Re: Flex/Bison/ANTLR question... alternative tools for translation? elikon@cox.net (rgaupsas) (2005-03-31)
[1 later articles]
| List of all articles for this month |
From: rgaupsas <elikon@cox.net>
Newsgroups: comp.compilers,comp.compilers.tools.pccts
Date: 15 Mar 2005 01:42:26 -0500
Organization: Cox Communications
Keywords: lex, yacc, question
Posted-Date: 15 Mar 2005 01:42:26 EST

I'm working on a translator whereby the input grammar is poorly
defined; a lot is contextually dependent. I've gotten pretty far with
Flex/Bison, making heavy use of lexical tie-ins to deal with
this. However I have some cases, and expect to see more, which Bison
handles poorly, e.g.:


WK COLOR COLOR ... COLOR NAME PARAM = NUMBER


The problem is that syntactically NAME and PARAM are indistinguishable
from COLOR (both are alpha numeric of the same form), so the following
form will not work (note Bflag sets the start_state in Flex).


...
                  | WK {Bflag=F_X1;} x_color { }
        ;


          x_color: COLOR { }
| x_color COLOR { }
| x_color COLOR NAME PARAM '=' NUMBER { }
        ;




The only thing I can get to work with this is a kluge: use the token
type COLOR token for NAME and PARAM, then modify the concatenated list
of colors:


| x_color COLOR '=' NUMBER { }




Any way to better handle this with Flex/Bison? This brings up the next
question... would ANTLER be more friendly in dealing with such context
dependent grammar. Performance is a big consideration, so this is why I
haven't gotten too deep into ANTLR ( anyone know just how much faster
ANTLR 3.0 might be when it is available?).


Any other recommended tools or methods for building a translator for a
poorly structured language. Something will proven/supported. Flex/Bison
will likely work but I'm afraid there will be too many "kluges". I've
already done a lot of searching on the web.


I've thought of using Lisp instead ... any comments on this.


Thanks


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.