It is now possible to add specific precedence relations between two symbols,
or a symbol and a group, with the %precr keyword:
%gprec arith {
%left '+' '-'
%left '*' '/'
}
%gprec boolean {
%left OR
%left AND
}
%right '^'
%precr '^' > arith
%precr OR AND > '^'
Here, the symbol ^ is of higher priority than the the ones in arith, but of
lower priority than both OR and AND. OR and '+', for example, cannot be
compared.
* src/parse-gram.y, src/scan-gram.l: Lexer and grammar implementation of
%precr.
* src/symtab.c, src/symtab.h: implementation of the addition of single link
precedence relationships.
It is now possible to introduce precedence groups, with precedence
relationships inside the group, but not with the outside tokens. Ex:
%gprec arith {
%left '+' '-'
%left '*' '/'
%right '^'
}
%gprec {
%left OR
%left AND
}
%left OTHER
%precedence OTHER2
Here, the arithmetical operators (in the "arith" group) can be compared, the
boolean operators can be compared, but OTHER can only be compared to OTHER2.
* src/gram.c, src/gram.h, src/scan-gram.l, src/parse-gram.y: {} blocks after
%gprec are understood by the lexer
* src/parse-gram.y: New syntax
* tests/input.at, tests/regression.at: Fix due to lexer change
Even though it is not yet fully deployed, this commit lays the ground for
the partial order precedence system, by changing to a graph-based order and
introducing precedence groups (only the default one can be used for now).
* src/symtab.h (struct symbol): Removed extra fields
* src/symtab.h: New function declarations
* src/symtab.c: New functions for precedence and groups, new hash table for
groups
* src/AnnotationList.c, src/conflicts.c, src/gram.c, src/print-xml.c,
* src/symtab.c: Adaptation to the new prec_node structure
* tests/existing.at (GAWK LALR): Fix
New structures: symgroup, prec_link, prec_node, and an enum of the
precedence relation operators. Symbols have two more fields to prepare for
the precedence graph and grouping to come.
* src/symtab.h (struct symbol): Two new fields
* src/symtab.h: New structures