From 34af804abbe35e1668930b21209cdeade6b7b8d0 Mon Sep 17 00:00:00 2001 From: HSunboy Date: Mon, 3 Sep 2018 15:44:45 +0800 Subject: [PATCH] fix --- .vscode/launch.json | 14 ++++++++++++++ core/sqlSyntaxParser.js | 14 ++++++++------ jison/comment.txt | 10 ++++++++++ jison/sql_main.jison | 14 ++++++++------ 4 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 jison/comment.txt diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a671a33 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "启动程序", + "program": "${workspaceFolder}/index.js" + } + ] +} \ No newline at end of file diff --git a/core/sqlSyntaxParser.js b/core/sqlSyntaxParser.js index 89ae676..6b93248 100644 --- a/core/sqlSyntaxParser.js +++ b/core/sqlSyntaxParser.js @@ -3931,14 +3931,16 @@ case 1183: // We need to handle arbitrary UDFs here instead of inside UserDefinedFunction or there will be a conflict // with columnReference for functions like: db.udf(foo) - var fn = $$[$0-1].chain[$$[$0-1].chain.length - 1].name.toLowerCase(); + var fn = $$[$0-1].chain[$$[$0-1].chain.length - 1].name.toLowerCase(); $$[$0-1].lastLoc.type = 'function'; $$[$0-1].lastLoc.function = fn; - $$[$0-1].lastLoc.location = { - first_line: $$[$0-1].lastLoc.location.first_line, - last_line: $$[$0-1].lastLoc.location.last_line, - first_column: $$[$0-1].lastLoc.location.first_column, - last_column: $$[$0-1].lastLoc.location.last_column - 1 + if($$[$0-1].lastLoc.location){ + $$[$0-1].lastLoc.location = { + first_line: $$[$0-1].lastLoc.location.first_line, + last_line: $$[$0-1].lastLoc.location.last_line, + first_column: $$[$0-1].lastLoc.location.first_column, + last_column: $$[$0-1].lastLoc.location.last_column - 1 + } } if ($$[$0-1].lastLoc !== $$[$0-1].firstLoc) { $$[$0-1].firstLoc.type = 'database'; diff --git a/jison/comment.txt b/jison/comment.txt new file mode 100644 index 0000000..1e5d50e --- /dev/null +++ b/jison/comment.txt @@ -0,0 +1,10 @@ +ColumnIdentifier +UnsignedValueSpecification #各种非负数字和普通字符串常量bool值 +UnsignedLiteral #各种非负数字和普通字符串常量bool值 +ExactNumericLiteral #非负数字和小数 +ApproximateNumericLiteral #带有E的非负数字 +GeneralLiteral #普通字符串常量/bool值 +RegularIdentifier #常规标识符 +RegularOrBacktickedIdentifier #标识符 +NonReservedKeyword #非保留关键字 +ColumnIdentifier #标识符和各种对象数组写法 \ No newline at end of file diff --git a/jison/sql_main.jison b/jison/sql_main.jison index 6ef9b53..e8f6c71 100755 --- a/jison/sql_main.jison +++ b/jison/sql_main.jison @@ -2412,14 +2412,16 @@ NonParenthesizedValueExpressionPrimary { // We need to handle arbitrary UDFs here instead of inside UserDefinedFunction or there will be a conflict // with columnReference for functions like: db.udf(foo) - var fn = $1.chain[$1.chain.length - 1].name.toLowerCase(); + var fn = $1.chain[$1.chain.length - 1].name.toLowerCase(); $1.lastLoc.type = 'function'; $1.lastLoc.function = fn; - $1.lastLoc.location = { - first_line: $1.lastLoc.location.first_line, - last_line: $1.lastLoc.location.last_line, - first_column: $1.lastLoc.location.first_column, - last_column: $1.lastLoc.location.last_column - 1 + if($1.lastLoc.location){ + $1.lastLoc.location = { + first_line: $1.lastLoc.location.first_line, + last_line: $1.lastLoc.location.last_line, + first_column: $1.lastLoc.location.first_column, + last_column: $1.lastLoc.location.last_column - 1 + } } if ($1.lastLoc !== $1.firstLoc) { $1.firstLoc.type = 'database';