What I had in mind is really no different from the stateful lexer
previously proposed. Unless I'm mistaken, an abstract model might be a
language over {0, 1, 2} where each 1 or 2 must be prececed by a run of
1 or more 0's, but each run differ in length from the preceding one by
0, 1 or -1. But that's only a local constraint. You also also want to
eventually get back to a run of 1 as the string ends (You don't want
the program to end in the middle of a nested block.) So, maybe a single
register would work locally (so long as transitions can be conditioned
on its value), but you still need a stack for global correctness. 

--- Larry Wall <[EMAIL PROTECTED]> wrote:

> On Thu, Sep 08, 2005 at 02:16:33PM -0700, Greg Woodhouse wrote:
> : In the case of the
> : "indentation grammar", then the (one) stack in a push-down
> automaton is
> : basically used up keeping track of the indentation level. But you
> don't
> : need a whole stack to keep track of indntation level, just a
> register
> : that can be used to track the current level.
> It seems to me you need a stack of levels so you know how many
> indentation levels to pop off.  Otherwise you can't parse this:
>       if foo1
>               bar1
>               if foo2
>                       bar2
>                       if foo3
>                               bar3
>               else
>                       baz2
> Larry

Gregory Woodhouse  <[EMAIL PROTECTED]>

"Without the requirement of mathematical aesthetics a great many discoveries 
would not have been made."

-- Albert Einstein

Reply via email to