At 08:01 PM 4/23/2001 -0500, David L. Nicol wrote:
>Larry Wall wrote:
> >
> > David L. Nicol writes:
> > :
> > : [this parser switch thing]
> > : sounds a lot like an "exec" system call: there are some things
> > : which remain in effect (open file handles, current directory,
> > : environment) but there are many others which do not.  Maybe
> > : switching parsers is best an absolute kind of thing rather than
> > : a stacked kind of thing, with the later parser responsible for
> > : switching back.
> >
> > The truth is somewhere in the middle.  It is incumbent on the
> > outer rule to inform the inner rule how it thinks the inner rule
> > ought to terminate, and it is the choice of the inner rule whether
> > to follow the convention suggested by the outer rule.  A rule that
> > starts at a left parenthesis will suggest stopping on a right
> > parenthesis, but if the inner rule is parsing troff, all bets are
> > off on properly nesting parens.
> >
> > Larry
>
>Right.  The existence of these "all bets are off" cases is what
>makes, IMO, a non-stacked system look better.  If the conversation
>starts in Russian, switches to Chechen, then Turkish, then English,
>the conversants might want to switch back to Russian without having
>to say a single word of Turkish or Chechen on the way back.  Or they
>might not switch back at all!

Well, it actually argues for a way to both nest parsers and switch parsers.

Most of the parser switching is going to be of the nesting variety. Every 
time the parser processes a double-quoted string constant or a regular 
expression you're going to be jumping parsers. That's all temporary, and we 
really do want them to nest. (You really don't want the perl parser to lose 
all its state every time you start a string...)

In some cases you might not, for example if you switch to Python or Forth 
mid-source. Those arguably might still nest, as there'd be end-of-parsing 
cleanup you'd want to do, and probably wouldn't want to do it before the 
very end, at which point the parser would just close down all the nested 
parsers.

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to