Grammar.extend''. But its interface being quite complicated
and, as it must be used with appropriate type constraints, the Camlp4
library provides a file, named ``pa_extend.cmo'', compatible
with ``pa_o.cmo'' and ``pa_r.cmo'' which creates a new
instruction doing this work.EXTEND'' which has the following
format:EXTEND |
{ GLOBAL : global-list ; } |
| entry : { position } extension ; |
| ... |
| entry : { position } extension ; |
END |
EXTEND, GLOBAL and END are keywords.
There are some other keywords in this instruction, all in uppercase.EXTEND''
instruction. The other entries are created locally. By default, all
entries are global and must correspond to entry variables visible at
the ``EXTEND'' instruction point.FIRST: The extension is inserted at the beginning
of the precedence levels.
LAST: The extension is inserted as the end of the
precedence levels.
BEFORE label: The extension is inserted
before the precedence level so labelled.
AFTER label: The extension is inserted
after the precedence level so labelled.
LEVEL label: The extension is inserted
at the precedence level so labelled.
LEVEL extends already existing levels: the other
cases create new levels.[ |
{ label } { associativity } level-rules | |
| |
... | |
| |
{ label } { associativity } level-rules | ] |
LEFTA, RIGHTA or NONA for respectively left,
right and no associativity: the default is left associativity.[ |
{ pattern = } symbol ; ... { pattern
= } symbol { -> action } |
|
| |
... | |
| |
{ pattern = } symbol ; ... { pattern
= } symbol { -> action } |
] |
loc'' is bound to the source location of the rule.
The action part is optional; by default it is the value ``()''.string.
LIST0 and LIST1 whose syntax is:
LISTx symbol1 { SEP symbol2 }
LIST0 and with at least
one element for LIST1) of symbol1, whose
elements are optionally separated by symbol2.
The type is t1 list where t1 is the type of symbol1 (the result of the optional symbol2 is lost).
OPT followed by a symbol, meaning this symbol or
nothing. The type is t option where t is the type of
symbol.