Unix Programming - Lex/Yacc and multiple input files

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2007 > Lex/Yacc and multiple input files





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 Lex/Yacc and multiple input files
max.giacometti@gmail.com

2007-05-21, 7:22 am

Hi everybody!

I am using lex and yacc to write a vhdl to systemc converter.

Lex simply reads the input file and yacc implements grammar and
translation.

I'd like to be able to make yacc able to command lex to stop reading
the current file and starting reading another file, when the inclusion
syntax is reached.

How can I do that?

Thanks,

Max

B. Augestad

2007-05-21, 1:19 pm

max.giacometti@gmail.com wrote:
> Hi everybody!
>
> I am using lex and yacc to write a vhdl to systemc converter.
>
> Lex simply reads the input file and yacc implements grammar and
> translation.
>
> I'd like to be able to make yacc able to command lex to stop reading
> the current file and starting reading another file, when the inclusion
> syntax is reached.
>
> How can I do that?
>


I guess that the easiest and most maintainable way is to use a
preprocessor step, just like the C compiler does. That way lex&yacc can
parse everything as one file.

If you stick with the C syntax for preprocessing directives, you can
even use the C preprocessor itself.

Just my 0.02$
Boa


--
Looking for an embeddable web server?
http://www.metasystems.no/products/...nder/index.html
Thomas Dickey

2007-05-22, 7:18 am

max.giacometti@gmail.com wrote:

> I'd like to be able to make yacc able to command lex to stop reading
> the current file and starting reading another file, when the inclusion
> syntax is reached.


By having a rule in either the lex or yacc that recognizes the inclusion
syntax. I've found lex to be more malleable than yacc.

For an example, cproto does this -

http://invisible-island.net/cproto/

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com