Closed stephe-ada-guru closed 2 years ago
Aliased
and Constant
nodes are known to Langkit as “boolean nodes”, for which parsers are special: in Constant("constant")
, a ConstantPresent
node is created when the parser finds a constant
token, and a ConstantAbsent
node is created otherwise (in both cases, the parser succeeds). So in practice they are optional (as you can see when asking Libadalang to parse V : T;
with the sub_object_decl
parsing rule.
Consider this rule from libadalang grammar.py:
The corresponding EBNF declaration in the Ada Language Reference Manual Annex P is:
In the LRM, 'aliased' and 'constant' are optional, but in libadalang they appear to be not optional; they are not enclosed in Opt().
There are several other occurrences of this issue.
How does the parser know that 'aliased' and 'constant' are optional here?