How do I report line no. on errors with racc?

Hi:

I am using racc to parse a file. I need to be able to
report a clear error message when a syntax error is
encountered.

I don’t think this can be done in the tokenizer (#parse)
and I don’t see how on_error yields a line number.

Any help on how to do this would be appreciated.

Thanks

···


Jim Freeze

Life would be so much easier if we could just look at the source code.

Hi,

In mail “How do I report line no. on errors with racc?”

I am using racc to parse a file. I need to be able to
report a clear error message when a syntax error is
encountered.

I don’t think this can be done in the tokenizer (#parse)
and I don’t see how on_error yields a line number.

I don’t think the parser can know the line number. If the
tokenizer discards line terminators, how the parser counts
line number?

For example, the tokenizer reports line number in Racc
(racc/raccs.rb).

Regards,
Minero Aoki

···

Jim Freeze jim@freeze.org wrote:

Thanks. I’ll take a look. BTW, can you add an example of
this in your sample directory?


···

On Sunday, 25 May 2003 at 17:26:28 +0900, Minero Aoki wrote:

Hi,

In mail “How do I report line no. on errors with racc?”
Jim Freeze jim@freeze.org wrote:

I am using racc to parse a file. I need to be able to
report a clear error message when a syntax error is
encountered.

I don’t think this can be done in the tokenizer (#parse)
and I don’t see how on_error yields a line number.

I don’t think the parser can know the line number. If the
tokenizer discards line terminators, how the parser counts
line number?

For example, the tokenizer reports line number in Racc
(racc/raccs.rb).


Jim Freeze

“It’s Fabulous! We haven’t seen anything like it in the last half an
hour!”
– Macy’s