Skip to content

Commit 14fb133

Browse files
committed
add spark sql antlr4 js
1 parent 5d2f00b commit 14fb133

12 files changed

+29595
-3
lines changed

package-lock.json

+15-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"build": "node build/build.js"
1212
},
1313
"dependencies": {
14+
"antlr4": "^4.7.2",
1415
"axios": "^0.19.0",
1516
"element-ui": "^2.12.0",
1617
"vue": "^2.5.2",

src/components/SparksqlEditor.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ import 'codemirror/addon/lint/lint.js'
2020
2121
import 'codemirror/addon/hint/sql-hint.js'
2222
import 'codemirror/mode/sql/sql.js'
23+
import '../sparkSql/sparksql-lint.js'
2324
2425
export default {
2526
name: 'SparksqlEditor',
2627
data () {
2728
const code =
2829
`
29-
select a from b;
30+
selct a from b;
3031
`
3132
return {
3233
code,

src/sparkSql/ParseErrorListener.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const antlr4 = require('antlr4')
2+
3+
var ParseErrorListener = function () {
4+
antlr4.error.ErrorListener.call(this)
5+
this.annotations = []
6+
return this
7+
}
8+
9+
ParseErrorListener.prototype = Object.create(antlr4.error.ErrorListener.prototype)
10+
ParseErrorListener.prototype.constructor = ParseErrorListener
11+
12+
ParseErrorListener.prototype.syntaxError = function (recognizer, offendingSymbol, line, column, msg, e) {
13+
this.annotations.push({
14+
row: line - 1,
15+
col: column,
16+
text: msg
17+
})
18+
}
19+
20+
ParseErrorListener.prototype.getErrors = function () {
21+
return this.annotations
22+
}
23+
24+
export {
25+
ParseErrorListener
26+
}

0 commit comments

Comments
 (0)