diff options
author | François Pottier <francois.pottier@inria.fr> | 2015-10-07 13:22:25 +0200 |
---|---|---|
committer | François Pottier <francois.pottier@inria.fr> | 2015-10-23 11:45:52 +0200 |
commit | 431d01db20514292c75fa00f522a8b56d7150b03 (patch) | |
tree | 2ebcb3badeadde9c24e39b04ce4056ad1a4e5b76 /cparser/pre_parser.mly | |
parent | abf35973bb7128689b94a0e518cc50d26c4d5e10 (diff) | |
download | compcert-431d01db20514292c75fa00f522a8b56d7150b03.tar.gz compcert-431d01db20514292c75fa00f522a8b56d7150b03.zip |
A general comment about phantom parameters.
Diffstat (limited to 'cparser/pre_parser.mly')
-rw-r--r-- | cparser/pre_parser.mly | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 23ef1bc5..df0244b7 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -145,6 +145,22 @@ declare_varname(nt): declare_typename(nt): i = nt { declare_typename i; i } +(* A note about phantom parameters. The definition of a non-terminal symbol + [nt] is sometimes parameterized with a parameter that is unused in the + right-hand side. This parameter disappears when macro-expansion takes + place. Thus, the presence of this parameter does not influence the language + that is accepted by the parser. Yet, it carries information about the + context, since different call sites can supply different values of this + parameter. This forces the creation of two (or more) identical copies of + the definition of [nt], which leads to a larger automaton, where some + states have been duplicated. In these states, more information about the + context is available, which allows better syntax error messages to be + given. + + By convention, a formal phantom parameter is named [phantom], so as to be + easily recognizable. For clarity, we usually explicitly document which + actual values it can take. *) + (* Actual grammar *) primary_expression: |