mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
Merge pull request #36 from nyalldawson/precedence
Setup operator precedence for parser to avoid ambiguity and fix shift/reduce warnings
This commit is contained in:
commit
8b40423f65
@ -50,25 +50,28 @@ struct sql_context;
|
|||||||
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
select { return SELECT; }
|
select { return SELECT; }
|
||||||
from { return FROM; }
|
from { return FROM; }
|
||||||
connect { return CONNECT; }
|
connect { return CONNECT; }
|
||||||
disconnect { return DISCONNECT; }
|
disconnect { return DISCONNECT; }
|
||||||
to { return TO; }
|
to { return TO; }
|
||||||
list { return LIST; }
|
list { return LIST; }
|
||||||
where { return WHERE; }
|
where { return WHERE; }
|
||||||
tables { return TABLES; }
|
tables { return TABLES; }
|
||||||
table { return TABLE; }
|
table { return TABLE; }
|
||||||
describe { return DESCRIBE; }
|
describe { return DESCRIBE; }
|
||||||
and { return AND; }
|
and { return AND; }
|
||||||
or { return OR; }
|
or { return OR; }
|
||||||
not { return NOT; }
|
not { return NOT; }
|
||||||
is { return IS; }
|
is { return IS; }
|
||||||
null { return NUL; }
|
null { return NUL; }
|
||||||
|
"=" { return EQ; }
|
||||||
(<=) { return LTEQ; }
|
(<=) { return LTEQ; }
|
||||||
(>=) { return GTEQ; }
|
(>=) { return GTEQ; }
|
||||||
|
"<" { return LT; }
|
||||||
|
">" { return GT; }
|
||||||
like { return LIKE; }
|
like { return LIKE; }
|
||||||
limit { return LIMIT; }
|
limit { return LIMIT; }
|
||||||
count { return COUNT; }
|
count { return COUNT; }
|
||||||
strptime { return STRPTIME; }
|
strptime { return STRPTIME; }
|
||||||
[ \t\r] ;
|
[ \t\r] ;
|
||||||
|
@ -71,6 +71,18 @@ typedef struct sql_context
|
|||||||
%type <ival> nulloperator
|
%type <ival> nulloperator
|
||||||
%type <name> identifier
|
%type <name> identifier
|
||||||
|
|
||||||
|
//
|
||||||
|
// operator precedence
|
||||||
|
//
|
||||||
|
|
||||||
|
// left associativity means that 1+2+3 translates to (1+2)+3
|
||||||
|
// the order of operators here determines their precedence
|
||||||
|
|
||||||
|
%left OR
|
||||||
|
%left AND
|
||||||
|
%right NOT
|
||||||
|
%left EQ LTEQ GTEQ LT GT LIKE IS
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
stmt:
|
stmt:
|
||||||
@ -142,9 +154,9 @@ identifier:
|
|||||||
;
|
;
|
||||||
|
|
||||||
operator:
|
operator:
|
||||||
'=' { $$ = MDB_EQUAL; }
|
EQ { $$ = MDB_EQUAL; }
|
||||||
| '>' { $$ = MDB_GT; }
|
| GT { $$ = MDB_GT; }
|
||||||
| '<' { $$ = MDB_LT; }
|
| LT { $$ = MDB_LT; }
|
||||||
| LTEQ { $$ = MDB_LTEQ; }
|
| LTEQ { $$ = MDB_LTEQ; }
|
||||||
| GTEQ { $$ = MDB_GTEQ; }
|
| GTEQ { $$ = MDB_GTEQ; }
|
||||||
| LIKE { $$ = MDB_LIKE; }
|
| LIKE { $$ = MDB_LIKE; }
|
||||||
|
Loading…
Reference in New Issue
Block a user