Skip to content

Instantly share code, notes, and snippets.

@BohuTANG
Created February 17, 2017 05:34
Show Gist options
  • Save BohuTANG/594e03eb8a89653ce3302c875f4d50cc to your computer and use it in GitHub Desktop.
Save BohuTANG/594e03eb8a89653ce3302c875f4d50cc to your computer and use it in GitHub Desktop.
yacc
index 421e1c4..54dcdac 100644
--- a/src/vendor/github.com/XeLabs/go-mysqlstack/sqlparser/sql.y
+++ b/src/vendor/github.com/XeLabs/go-mysqlstack/sqlparser/sql.y
@@ -4,6 +4,9 @@
%{
package sqlparser
+import (
+ "fmt"
+ )
func setParseTree(yylex interface{}, stmt Statement) {
yylex.(*Tokenizer).ParseTree = stmt
@@ -27,6 +30,8 @@ func decNesting(yylex interface{}) {
func forceEOF(yylex interface{}) {
yylex.(*Tokenizer).ForceEOF = true
+ tkn :=yylex.(*Tokenizer)
+ fmt.Printf("---forceEOF:\teof:%v,\tch:%v,\tpos:%v\n", tkn.ForceEOF, string(tkn.lastChar), tkn.Position)
}
%}
@@ -247,9 +252,9 @@ set_statement:
}
create_statement:
- CREATE TABLE not_exists_opt table_id force_eof
+ CREATE TABLE not_exists_opt table_name force_eof
{
- $$ = &DDL{Action: CreateStr, Table: $4, NewName: $4}
+ $$ = &DDL{Action: CreateStr, Table: $4.Name, NewName: $4.Name}
}
| CREATE constraint_opt INDEX ID using_opt ON table_id force_eof
{
@@ -1276,5 +1281,7 @@ closeb:
force_eof:
{
+ tkn :=yylex.(*Tokenizer)
+ fmt.Printf("---force_eof:\teof:%v,\tch:%v,\tpos:%v\n", tkn.ForceEOF, string(tkn.lastChar), tkn.Position)
forceEOF(yylex)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment