[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pasrser and EOF


It seems that implementing a parser without some kind of end-of-input
character is not really feasible without changing the "expected"
behavior of the parser. This is because some backtracking would be
needed, and I am not sure I want to deal with this kind of headache.

On the other hand, the "end-of-input" token could be user specified.

Something along the line:

  id = ['a'..'z']+;
  number = ['0'..'9']+;
  blank = ' ';
  new_line = 13 | 10 | 13 10;

Ignored Tokens

End Of Stream Token

  grammar = id* | number*;

The effect of the "End Of Stream Token" directive would be to change the
implicit start production to:

start = grammar new_line;

instead of

start = grammar eof;

There is a catch, though. The "End Of Stream Token" cannot be used in
the grammar.

Would that satisfy everybody's need?