dabeaz / sly

Sly Lex Yacc
Other
816 stars 107 forks source link

Using stream instead of string? #99

Open davidmcnabnz opened 2 years ago

davidmcnabnz commented 2 years ago

Hi David,

I notice Sly's tokeniser is designed to feed only from an indexable, sliceable string-like object. I need to have it feeding instead from a "stack of streams", to allow nested file inclusions.

One option is to implement a string-like class which, under the hood, sources input from a 'stack' of file-like streams. With this, the parser can then 'push' a new stream to the stack when it sees an include command, and the include stream can 'pop' from the stack when exhausted.

Do you think this is the best way to go, or can you recommend I take a better approach?

Cheers David

P.S. Sly has sure come a long way since the earlier Ply days. You may remember me from my contribution of a class-based calc parser.