瀏覽代碼

HUE-4031 [editor] Create initial syntax parser for error highligting

Johan Ahlen 8 年之前
父節點
當前提交
2ae87fb

+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sql_end.jison → desktop/core/src/desktop/static/desktop/js/autocomplete/jison/autocomplete_footer.jison


+ 4 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison

@@ -14,6 +14,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+SqlSyntax
+ : NewStatement SqlStatements EOF
+ ;
+
 SqlAutocomplete
  : NewStatement SqlStatements EOF
    {

+ 17 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/syntax_footer.jison

@@ -0,0 +1,17 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+%%

+ 28 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/syntax_header.jison

@@ -0,0 +1,28 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+%left 'AND' 'OR'
+%left 'BETWEEN'
+%left 'NOT' '!' '~'
+%left '=' '<' '>' 'COMPARISON_OPERATOR'
+%left '-' '*' 'ARITHMETIC_OPERATOR'
+
+%left ';' ','
+%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
+
+%start SqlSyntax
+
+%%

文件差異過大導致無法顯示
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlAutocompleteParser.js


文件差異過大導致無法顯示
+ 88 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlSyntaxParser.js


+ 12 - 1
tools/jison/hue-jison.sh

@@ -30,7 +30,8 @@ pushd ../../desktop/core/src/desktop/static/desktop/js/autocomplete/jison
 # For quick version of select with create only and no support for value expressions (i.e. a = b or a IN (1, 2, 3))
 # cat sql_main.jison sql_create.jison sql_end.jison > sql.jison
 
-cat autocomplete_header.jison sql_main.jison sql_valueExpression.jison sql_error.jison sql_alter.jison sql_analyze.jison sql_create.jison sql_drop.jison sql_grant.jison sql_insert.jison sql_load.jison sql_set.jison sql_show.jison sql_update.jison sql_use.jison ../sql_end.jison > sqlAutocompleteParser.jison
+# === Autocomplete parser ===
+cat autocomplete_header.jison sql_main.jison sql_valueExpression.jison sql_error.jison sql_alter.jison sql_analyze.jison sql_create.jison sql_drop.jison sql_grant.jison sql_insert.jison sql_load.jison sql_set.jison sql_show.jison sql_update.jison sql_use.jison autocomplete_footer.jison > sqlAutocompleteParser.jison
 
 echo "Creating SQL autocomplete parser..."
 jison sqlAutocompleteParser.jison sql.jisonlex
@@ -38,6 +39,16 @@ cat license.txt sqlAutocompleteParser.js > ../sqlAutocompleteParser.js
 rm sqlAutocompleteParser.jison
 rm sqlAutocompleteParser.js
 
+# === Syntax parser ===
+cat syntax_header.jison sql_main.jison sql_valueExpression.jison  sql_alter.jison sql_analyze.jison sql_create.jison sql_drop.jison sql_grant.jison sql_insert.jison sql_load.jison sql_set.jison sql_show.jison sql_update.jison sql_use.jison syntax_footer.jison > sqlSyntaxParser.jison
+
+echo "Creating SQL syntax parser..."
+jison sqlSyntaxParser.jison sql.jisonlex
+cat license.txt sqlSyntaxParser.js > ../sqlSyntaxParser.js
+rm sqlSyntaxParser.jison
+rm sqlSyntaxParser.js
+
+# === Statement parser ===
 echo "Creating SQL statements parser..."
 jison sqlStatementsParser.jison
 cat license.txt sqlStatementsParser.js > ../sqlStatementsParser.js

部分文件因文件數量過多而無法顯示