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 > Compiler Tools Pccts > Flex/Bison/ANTL...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 95 of 134
Post > Topic >>

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

by rgaupsas <elikon@[EMAIL PROTECTED] > Mar 15, 2005 at 01:42 AM

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/sup****ted. 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
 




 7 Posts in Topic:
Flex/Bison/ANTLR question... alternative tools for translation?
rgaupsas <elikon@[EMAI  2005-03-15 01:42:26 
Re: Flex/Bison/ANTLR question... alternative tools for translati
Brian Inglis <Brian.In  2005-03-20 10:14:12 
Re: Flex/Bison/ANTLR question... alternative tools for translati
rgaupsas <elikon@[EMAI  2005-03-24 21:12:48 
Re: Flex/Bison/ANTLR question... alternative tools for translati
Brian.Inglis@[EMAIL PROTE  2005-03-25 21:53:51 
Re: Flex/Bison/ANTLR question... alternative tools for translati
rgaupsas <elikon@[EMAI  2005-03-31 23:29:09 
Re: Flex/Bison/ANTLR question... alternative tools for translati
Brian Inglis <Brian.In  2005-04-02 19:32:21 
Re: Flex/Bison/ANTLR question... alternative tools for translati
Sebastian <sk@[EMAIL P  2005-03-20 10:15:58 

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:02:19 CDT 2008.