[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Pasrser and EOF
>From: Archie Cobbs <archie@whistle.com>
>
>I'm curious: what would the "unexpected" behavior be? Are you
>saying that backtracking would always be needed, or would it only
>be needed to make the behavior less "unexpected"?
I was implying that backtracking could be needed [if the start production is
not LR(0)] to get a somewhat expected behavior: get the longest acceptable
input. But this "expected" behavior is different from the normal behavior:
verify that the string exactly matches the grammar.
>
>I wouldn't claim that most languages remain non-ambiguous when
>you leave off the terminating eof .. clearly not ("C" is an easy
>counter example because you can define an arbitrary number of functions
>in a file).
I think that hendrik's idea of making the start state LR(0) would cause the
rejection of the C grammar, if you don't provide an eof marker.
>
>But this token doesn't necessarily have to not appear anywhere else
>in the input, e.g.:
>
> start =
> foo bar* foo;
>
>This language is not ambiguous, and doesn't need the implicit EOF
>rule...
>
True. And it is LR(0), if I am right.
Etienne