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; }
|
||||
connect { return CONNECT; }
|
||||
disconnect { return DISCONNECT; }
|
||||
to { return TO; }
|
||||
list { return LIST; }
|
||||
where { return WHERE; }
|
||||
tables { return TABLES; }
|
||||
table { return TABLE; }
|
||||
tables { return TABLES; }
|
||||
table { return TABLE; }
|
||||
describe { return DESCRIBE; }
|
||||
and { return AND; }
|
||||
or { return OR; }
|
||||
not { return NOT; }
|
||||
is { return IS; }
|
||||
null { return NUL; }
|
||||
"=" { return EQ; }
|
||||
(<=) { return LTEQ; }
|
||||
(>=) { return GTEQ; }
|
||||
"<" { return LT; }
|
||||
">" { return GT; }
|
||||
like { return LIKE; }
|
||||
limit { return LIMIT; }
|
||||
limit { return LIMIT; }
|
||||
count { return COUNT; }
|
||||
strptime { return STRPTIME; }
|
||||
[ \t\r] ;
|
||||
|
@ -71,6 +71,18 @@ typedef struct sql_context
|
||||
%type <ival> nulloperator
|
||||
%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:
|
||||
@ -142,9 +154,9 @@ identifier:
|
||||
;
|
||||
|
||||
operator:
|
||||
'=' { $$ = MDB_EQUAL; }
|
||||
| '>' { $$ = MDB_GT; }
|
||||
| '<' { $$ = MDB_LT; }
|
||||
EQ { $$ = MDB_EQUAL; }
|
||||
| GT { $$ = MDB_GT; }
|
||||
| LT { $$ = MDB_LT; }
|
||||
| LTEQ { $$ = MDB_LTEQ; }
|
||||
| GTEQ { $$ = MDB_GTEQ; }
|
||||
| LIKE { $$ = MDB_LIKE; }
|
||||
|
Loading…
Reference in New Issue
Block a user