Parsing slate files

John Leuner jewel at pixie.co.za
Sun Jun 6 05:38:04 PDT 2004


Yes, atEnd works perfectly.

s@(String traits) fileIn
[ | input aparser interp p|
" Console ; 'Filing in $'' ; s ; '$'.$\n'."
 input: (File open: s).
 aparser: ((Syntax Parser clone) newOn: (input reader)).
 [ aparser atEnd ] whileFalse: [ p: aparser next. (lobby interpretHook:
[ p evaluateIn: lobby ])].
 input close.
].


I've been trying to implement the basic classes of SRP in slate. I'm at
the point where I need to get a collection containing all the subclasses
(prototypes derived from) of a prototype.

How can I do this in the bootstrapped VM?

John

On Sat, 2004-06-05 at 19:03, Brian Rice wrote:
> 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/
-- 
John Leuner <jewel at pixie.co.za>




More information about the Slate mailing list