Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: Adjust rule precedence #128

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ import (
logOr "logical or operator"
LowPriorityOptional "LOW_PRIORITY or empty"
name "name"
NotEmptyTableIdentList "Not empty TableIdentList"
NotOpt "optional NOT"
NowSym "CURRENT_TIMESTAMP/LOCALTIME/LOCALTIMESTAMP/NOW"
NumLiteral "Num/Int/Float/Decimal Literal"
Expand Down Expand Up @@ -473,6 +474,12 @@ import (
%precedence lowerThanCalcFoundRows
%precedence calcFoundRows

%precedence lowerThanQuick
%precedence quick

%precedence lowerThanComma
%precedence ','

%left join inner cross left right full
/* A dummy token to force the priority of TableRef production in a join. */
%left tableRefPriority
Expand Down Expand Up @@ -1148,7 +1155,7 @@ DeleteFromStmt:
break
}
}
| "DELETE" LowPriorityOptional QuickOptional IgnoreOptional TableIdentList "FROM" TableRefs WhereClauseOptional
| "DELETE" LowPriorityOptional QuickOptional IgnoreOptional NotEmptyTableIdentList "FROM" TableRefs WhereClauseOptional
{
// Multiple Table
x := &stmts.DeleteStmt{
Expand Down Expand Up @@ -1728,7 +1735,7 @@ Operand:
{
$$ = &expressions.PExpr{Expr: expressions.Expr($2)}
}
| "DEFAULT"
| "DEFAULT" %prec lowerThanLeftParen
{
$$ = &expressions.Default{}
}
Expand Down Expand Up @@ -2149,17 +2156,21 @@ TableIdentList:
{
$$ = []table.Ident{}
}
| TableIdent
| NotEmptyTableIdentList

NotEmptyTableIdentList:
TableIdent
{
tbl := []table.Ident{$1.(table.Ident)}
$$ = tbl
}
| TableIdentList ',' TableIdent
| NotEmptyTableIdentList ',' TableIdent
{
$$ = append($1.([]table.Ident), $3.(table.Ident))
}

QuickOptional:
%prec lowerThanQuick
{
$$ = false
}
Expand Down Expand Up @@ -2886,7 +2897,7 @@ TableOptListOpt:
{
$$ = []*coldef.TableOpt{}
}
| TableOptList
| TableOptList %prec lowerThanComma

TableOptList:
TableOpt
Expand All @@ -2902,7 +2913,6 @@ TableOptList:
$$ = append($1.([]*coldef.TableOpt), $3.(*coldef.TableOpt))
}


TruncateTableStmt:
"TRUNCATE" "TABLE" TableIdent
{
Expand Down