develooper Front page | perl.perl5.porters | Postings from September 2014

Parse error vs syntax error

From:
Father Chrysostomos
Date:
September 19, 2014 06:20
Subject:
Parse error vs syntax error
Message ID:
20140919062020.18915.qmail@lists-nntp.develooper.com
In normal circumstances, a syntax error will cause an error message
beginning with 'syntax error'.

The recursive descent parsing API checks for errors and dies with
'Parse error'.  Subroutine signatures also do the same.

Is there any reason why the message needs to be different?

Actually, we get both;

$ ./miniperl -Ilib -Mfeature=:all -Xle 'sub foo(@ $){}'
Parse error at -e line 1.
syntax error at -e line 1, near "@ $)"
Execution of -e aborted due to compilation errors.

Is there any reason to emit 'Parse error' at all?

Also, is there any reason why subroutine signature errors in general
do not use yyerror?  If we switch to yyerror, this:

$ ./miniperl -Ilib -Mfeature=:all -Xle 'sub foo(@, $){}'
Slurpy parameter not last at -e line 1.
Execution of -e aborted due to compilation errors.

becomes this:

$ ./miniperl -Ilib -Mfeature=:all -Xle 'sub foo(@, $){}'
Slurpy parameter not last at -e line 1, near "@, "
Execution of -e aborted due to compilation errors.




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About