Parsing slate files
Brian Rice
water at tunes.org
Sat Jun 5 10:03:52 PDT 2004
Hi John,
You can ask any stream atEnd and it will return whether it is at the
end of its data source. Parser and Lexer should have these defined,
being streams, as delegating to their source streams. Parser reads from
Lexer reads from any ReadStream, and a (for fileIn) File ReadStream
should tell you it's atEnd when it reaches the EOF. However, I can see
why an exception-throwing setup would help, but atEnd is a good start.
On Jun 5, 2004, at 4:35 AM, John Leuner wrote:
> How do I determine when the parser has reached the last node in a file?
>
> When I call (aparser next) it continuously returns a Nil Literal. What
> is the correct test to determine EOF/EOS?
>
> (The code below is the result of experimentation, it is not intended to
> be coherent)
>
> s@(String traits) fileIn
> [ | input aparser interp p|
> " Console ; 'Filing in $'' ; s ; '$'.$\n'."
> input: (File open: s).
> aparser: ((Syntax Parser clone) newOn: (input reader)).
> p: aparser next.
> [ p is: Syntax Literal /\ (p value) isNil] whileFalse: [ (lobby
> interpretHook: [ p evaluateIn: lobby ]).
> p: aparser next.
> ].
> " (lobby interpretHook: [ (aparser next) evaluateIn: lobby ]).
> (lobby interpretHook: [ (aparser next) evaluateIn: lobby ]).
> (lobby interpretHook: [ (aparser next) evaluateIn: lobby ])."
> input close.
> ].
>
> --
> John Leuner <jewel at pixie.co.za>
>
>
--
Brian T. Rice
LOGOS Research and Development
http://tunes.org/~water/
More information about the Slate
mailing list