Lex/Yacc and multiple input files

M

max.giacometti

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

B. Augestad

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
This is off topic in comp.lang.c, a better place to ask is in
comp.compilers and/or comp.unix.programmer.

<ot>
If you use flex, you can read the man page for flex and search for the
section named MULTIPLE INPUT BUFFERS.
</ot>

Bjørn
 
S

SM Ryan

(e-mail address removed) 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.

Use three stages: character input --> lex --> yacc. The character input
is responsible for input files, character set translations, include
file stacking, etc, to present lex with a continuous stream of characters
from various sources. Depending on how vhdl does inclusion, either lex
or yacc might recognise it and send back to the character input commands
on including files. The tricky part is that you may have characters
buffered in lex and tokens buffered in yacc so that if you don't arrange
it carefully, you can read past where included text is inserted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top