Uniform input stream from various kind of sources ?

F

fabricemarchant

Hi !

I'm writing a tiny interpreted language. The interpreter will first
be able to load a list of source files before giving the hand to the
keyboard : I use GNU readline/history library that returns the line
input string that could be converted into a stream by std::istrstream.

My aim is to cut the interpreter from this input system by feeding it
with a unique input stream.
Maybe I could use <sstream> to build this input stream. It is
maybepossible inside a buffered input to switch from one source file
to another one and then to the istrstream of readline() ?

I have always neglected to seriously study input / output streams and
always used them in a poor basic way... it's a shame since they do
carry a powerful abstraction feature that can make the things a lot
easier.

Please can you give me an idea of a frame to build this unified input
stream ?

Thanks in advance.

Fabrice
 
J

Jerry Coffin

@r2g2000cwb.googlegroups.com>, (e-mail address removed)
says...
Hi !

I'm writing a tiny interpreted language. The interpreter will first
be able to load a list of source files before giving the hand to the
keyboard : I use GNU readline/history library that returns the line
input string that could be converted into a stream by std::istrstream.

My aim is to cut the interpreter from this input system by feeding it
with a unique input stream.

I've have the interpreter use an input iterator, and
create a custom iterator that reads from some current
stream, and switches to a different stream when needed.
 
F

fabricemarchant

A week later...

Apologize, my 56k modem was actually destroyed wednesday by a flash
lightning. It happens.

I've followed your adviice, Jerry : implemented in switching like you
said.

Thanx Jerry !
 

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

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top