[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why token are numbered from 258?
From: |
Akim Demaille |
Subject: |
Re: Why token are numbered from 258? |
Date: |
Thu, 7 Feb 2019 21:31:35 +0100 |
> Le 7 févr. 2019 à 18:33, Peng Yu <address@hidden> a écrit :
>
> Hi,
>
> I don't quite understand why tokens are numbered starting from 258.
> What are 256 and 257 for? Thanks.
>
> #define IF 258
256 is the error token, and 257 is the undef token (when we receive unknown
tokens from yylex).
256 is mandated by POSIX :
https://pubs.opengroup.org/onlinepubs/007904875/utilities/yacc.html
> The token error shall be reserved for error handling. The name error can be
> used in grammar rules. It indicates places where the parser can recover from
> a syntax error. The default value of error shall be 256. Its value can be
> changed using a %token declaration. The lexical analyzer should not return
> the value of error.
It seems to say that we should be able to change the value with `%token error
2400`, but we don't support that. (checking...) OMG, we do support it! New
test case...