develooper Front page | perl.recdescent | Postings from November 2010

recursive error reporting

Thread Next
Robert Lemmen
November 8, 2010 16:35
recursive error reporting
Message ID:
hi folks,

I am playing around with PRD, and really like it so far. But I can quite
get my head around some details of the error reporting. consider the
following grammar:

	code : fact(s?) eofile
		{ $item[1] }
		| <error>

	eofile : /^\Z/

	fact : 'fact' <commit> identifier  ';' 
		{ [$item[0], $item[3]] }
		| <error?><reject>

	identifier : m{[A-Za-z_][A-Za-z0-9_]*}

and an input like this:

	fact TFactA;
	# case 1
	# fact TFactB 234;
	# case 2
	# blablabla

the unmodified input parses nicely, and if I uncomment any of the two
syntax errors, it correctly rejects the input. excellent. but the error
reporting is slightly less than ideal: the error case 1 will set off the
<error> directive of the 'fact' rule (good), but *also* the <error>
directive of the 'code' rule, which is a bit odd. If I remove the error
directive of the parent rule, i'll miss errors of type 2, and if remove
the error directive of 'fact', then the error is reported in a very hard
to decipher way. Ideally i would like to have an error directive of most
rules in my syntax, but simply stop processing after I hit any of them.
Is there a way to achieve that?

I have read the FAQ and some other pages which talk about similar
problems, but please note that in this case the parser correctly rejects
the input, it just emits too many error messages

thanks  robert
Robert Lemmen                      

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About