[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] New syntax for partial precedence order
From: |
Valentin Tolmer |
Subject: |
[PATCH] New syntax for partial precedence order |
Date: |
Tue, 2 Jul 2013 15:52:57 +0200 |
From: nitnelave <address@hidden>
This patch introduces a new way of defining token precedence, to have a
partial order instead of a total one.
Token precedence can now be declared inside of groups, the order inside the
group is total, but no links exist between the group and tokens declared
outside. Specific links can be added later.
ex:
%gprec arith {
%left '+' '-'
%left '*' '/'
}
%gprec bool {
%left OR
%left AND
}
%precr AND > '+' '-'
%precr bool > '*'
%precr AND = '/'
Conflicts are now resolved using this system alone, and an attempt to compare
two symbols with no relation will result in an error.
Currently the relations are not transitive, but it is planned to make them so
(with an operator >> to specify non transitive relations).
Ideally, the symbols %gprec and %precr will be replaced by %prec, but for now
the grammar wouldbe ambiguous.
The syntax is backward compatible, and has been tested on several major
grammars such as PHP, POSGRESQL or GAWK.
nitnelave (1):
grammar: new syntax allowing for partial order symbol precedence
src/conflicts.c | 127 +++++++++--------
src/gram.h | 3 +
src/parse-gram.y | 74 ++++++++++
src/scan-gram.l | 17 +++
src/symtab.c | 408 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/symtab.h | 92 ++++++++++++
6 files changed, 663 insertions(+), 58 deletions(-)
--
1.7.9.5
- [PATCH] New syntax for partial precedence order,
Valentin Tolmer <=