{user declarations}You can define values available in the semantic actions of the rules in the user declarations section. It is recommended that you keep the size of this section as small as possible and place large blocks of code in other modules.
%%
{ML-Yacc declarations}
%%
{rules}
The following classes of ML symbols are used:
of for = { } , * -> : | ( )
The following classes of non-ML symbols are used:
- identifiers:
- nonsymbolic ML identifiers, which consist of an alphabetic character followed by one or more alphabetic characters, numeric characters, primes ``''', or underscores ``_''.
- type variables:
- nonsymbolic ML identifier starting with a prime ``'''
- integers:
- one or more decimal digits.
- qualified identifiers:
- an identifer followed by a period.
- % identifiers:
- a percent sign followed by one or more lowercase alphabet letters. The valid % identifiers are:
%arg %eop %header %keyword %left %name %nodefault %nonassoc %nonterm %noshift %pos %prec %prefer %pure %right %start %subst %term %value %verbose- code:
- This class is meant to hold ML code. The ML code is not parsed for syntax errors. It consists of a left parenthesis followed by all characters up to a balancing right parenthesis. Parentheses in ML comments and ML strings are excluded from the count of balancing parentheses.
spec | ::= | user-declarations %% cmd-list %% rule-list |
ML-type | ::= | nonpolymorphic ML types (see the Standard ML manual) |
symbol | ::= | identifier |
symbol-list | ::= | symbol-list symbol |
| | e | |
symbol-type-list | ::= | symbol-type-list | symbol of ML-type |
| | symbol-type list | symbol | |
| | symbol of ML-type | |
| | symbol | |
subst-list | ::= | subst-list | symbol for symbol |
| | e | |
cmd | ::= | %arg (Any-ML-pattern) : ML-type |
| | %eop symbol-list | |
| | %header code | |
| | %keyword symbol-list | |
| | %left symbol-list | |
| | %name identifier | |
| | %nodefault | |
| | %nonassoc symbol-list | |
| | %nonterm symbol-type list | |
| | %noshift symbol-list | |
| | %pos ML-type | |
| | %prefer symbol-list | |
| | %pure | |
| | %right symbol-list | |
| | %start symbol | |
| | %subst subst-list | |
| | %term symbol-type-list | |
| | %value symbol code | |
| | %verbose | |
cmd-list | ::= | cmd-list cmd |
| | cmd | |
rule-prec | ::= | %prec symbol |
| | e | |
clause-list | ::= | symbol-list rule-prec code |
| | clause-list | symbol-list rule-prec code | |
rule | ::= | symbol : clause-list |
rule-list | ::= | rule-list rule |
| | rule |
specifies the argument to the parser, as well as its type. For example:
%arg (Any-ML-pattern) : <ML-type>
%arg (filename) : string
%header (functor {parser name}LrValsFun( structure Token : TOKEN ...) )
tokens1awhere each tokens is a (possibly empty) seqence of tokens. The idea is that any instance of tokens1a can be ``corrected'' to tokens1b, and so on. For example, to suggest that a good error correction to try is->
tokens1b|
tokens2a->
tokens2b etc.
IN ID END
(which is useful for the
ML parser), write,
%change -> IN ID END