Format code

This commit is contained in:
Tyler Long 2017-04-17 17:13:37 +08:00
parent 0ebf162673
commit 4032824c79
2 changed files with 64 additions and 62 deletions

View File

@ -12,12 +12,12 @@ gulp.task('jison', function () {
gulp.task('jison_legacy', function () {
shell.task([
'node node_modules/jison/lib/cli.js src/diagrams/classDiagram/parser/classDiagram.jison -o src/diagrams/classDiagram/parser/classDiagram.js',
'node node_modules/jison/lib/cli.js src/diagrams/classDiagram/parser/classDiagram.jison -o src/diagrams/classDiagram/parser/classDiagram.js',
'node node_modules/jison/lib/cli.js src/diagrams/sequenceDiagram/parser/sequenceDiagram.jison -o src/diagrams/sequenceDiagram/parser/sequenceDiagram.js',
'node node_modules/jison/lib/cli.js src/diagrams/example/parser/example.jison -o src/diagrams/example/parser/example.js',
'node node_modules/jison/lib/cli.js src/diagrams/flowchart/parser/flow.jison -o src/diagrams/flowchart/parser/flow.js',
'node node_modules/jison/lib/cli.js src/diagrams/flowchart/parser/dot.jison -o src/diagrams/flowchart/parser/dot.js',
'node node_modules/jison/lib/cli.js src/diagrams/gitGraph/parser/gitGraph.jison -o src/diagrams/gitGraph/parser/gitGraph.js',
'node node_modules/jison/lib/cli.js src/diagrams/gantt/parser/gantt.jison -o src/diagrams/gantt/parser/gantt.js'
'node node_modules/jison/lib/cli.js src/diagrams/example/parser/example.jison -o src/diagrams/example/parser/example.js',
'node node_modules/jison/lib/cli.js src/diagrams/flowchart/parser/flow.jison -o src/diagrams/flowchart/parser/flow.js',
'node node_modules/jison/lib/cli.js src/diagrams/flowchart/parser/dot.jison -o src/diagrams/flowchart/parser/dot.js',
'node node_modules/jison/lib/cli.js src/diagrams/gitGraph/parser/gitGraph.jison -o src/diagrams/gitGraph/parser/gitGraph.js',
'node node_modules/jison/lib/cli.js src/diagrams/gantt/parser/gantt.jison -o src/diagrams/gantt/parser/gantt.js'
])
})

View File

@ -70,14 +70,15 @@
}
*/
var parser = (function () {
var o = function (k, v, o, l) { for (o = o || {}, l = k.length; l--; o[k[l]] = v);return o }, $V0 = [6, 8, 10, 11, 12, 13, 14], $V1 = [1, 9], $V2 = [1, 10], $V3 = [1, 11], $V4 = [1, 12]
var parser = {trace: function trace () { },
var o = function (k, v, o, l) { for (o = o || {}, l = k.length; l--; o[k[l]] = v); return o }, $V0 = [6, 8, 10, 11, 12, 13, 14], $V1 = [1, 9], $V2 = [1, 10], $V3 = [1, 11], $V4 = [1, 12]
var parser = {
trace: function trace () { },
yy: {},
symbols_: {'error': 2, 'start': 3, 'gantt': 4, 'document': 5, 'EOF': 6, 'line': 7, 'SPACE': 8, 'statement': 9, 'NL': 10, 'dateFormat': 11, 'title': 12, 'section': 13, 'taskTxt': 14, 'taskData': 15, '$accept': 0, '$end': 1},
terminals_: {2: 'error', 4: 'gantt', 6: 'EOF', 8: 'SPACE', 10: 'NL', 11: 'dateFormat', 12: 'title', 13: 'section', 14: 'taskTxt', 15: 'taskData'},
symbols_: { 'error': 2, 'start': 3, 'gantt': 4, 'document': 5, 'EOF': 6, 'line': 7, 'SPACE': 8, 'statement': 9, 'NL': 10, 'dateFormat': 11, 'title': 12, 'section': 13, 'taskTxt': 14, 'taskData': 15, '$accept': 0, '$end': 1 },
terminals_: { 2: 'error', 4: 'gantt', 6: 'EOF', 8: 'SPACE', 10: 'NL', 11: 'dateFormat', 12: 'title', 13: 'section', 14: 'taskTxt', 15: 'taskData' },
productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 1], [9, 1], [9, 1], [9, 2]],
performAction: function anonymous (yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
/* this == yyval */
/* this == yyval */
var $0 = $$.length - 1
switch (yystate) {
@ -110,7 +111,7 @@ var parser = (function () {
break
}
},
table: [{3: 1, 4: [1, 2]}, {1: [3]}, o($V0, [2, 2], {5: 3}), {6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: $V1, 12: $V2, 13: $V3, 14: $V4}, o($V0, [2, 7], {1: [2, 1]}), o($V0, [2, 3]), {9: 13, 11: $V1, 12: $V2, 13: $V3, 14: $V4}, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 8]), o($V0, [2, 9]), o($V0, [2, 10]), {15: [1, 14]}, o($V0, [2, 4]), o($V0, [2, 11])],
table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: $V1, 12: $V2, 13: $V3, 14: $V4 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 13, 11: $V1, 12: $V2, 13: $V3, 14: $V4 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 8]), o($V0, [2, 9]), o($V0, [2, 10]), { 15: [1, 14] }, o($V0, [2, 4]), o($V0, [2, 11])],
defaultActions: {},
parseError: function parseError (str, hash) {
if (hash.recoverable) {
@ -155,14 +156,14 @@ var parser = (function () {
lstack.length = lstack.length - n
}
_token_stack:
var lex = function () {
var token
token = lexer.lex() || EOF
if (typeof token !== 'number') {
token = self.symbols_[token] || token
}
return token
var lex = function () {
var token
token = lexer.lex() || EOF
if (typeof token !== 'number') {
token = self.symbols_[token] || token
}
return token
}
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected
while (true) {
state = stack[stack.length - 1]
@ -261,8 +262,9 @@ var parser = (function () {
}
}
return true
}}
/* generated by jison-lex 0.3.4 */
}
}
/* generated by jison-lex 0.3.4 */
var lexer = (function () {
var lexer = ({
@ -276,7 +278,7 @@ var parser = (function () {
}
},
// resets the lexer, sets new input
// resets the lexer, sets new input
setInput: function (input, yy) {
this.yy = yy || this.yy || {}
this._input = input
@ -297,7 +299,7 @@ var parser = (function () {
return this
},
// consumes and returns one char from the input
// consumes and returns one char from the input
input: function () {
var ch = this._input[0]
this.yytext += ch
@ -320,7 +322,7 @@ var parser = (function () {
return ch
},
// unshifts one char (or a string) into the input
// unshifts one char (or a string) into the input
unput: function (ch) {
var len = ch.length
var lines = ch.split(/(?:\r\n?|\n)/g)
@ -343,9 +345,9 @@ var parser = (function () {
last_line: this.yylineno + 1,
first_column: this.yylloc.first_column,
last_column: lines
? (lines.length === oldLines.length ? this.yylloc.first_column : 0) +
oldLines[oldLines.length - lines.length].length - lines[0].length
: this.yylloc.first_column - len
? (lines.length === oldLines.length ? this.yylloc.first_column : 0) +
oldLines[oldLines.length - lines.length].length - lines[0].length
: this.yylloc.first_column - len
}
if (this.options.ranges) {
@ -355,13 +357,13 @@ var parser = (function () {
return this
},
// When called from action, caches matched text and appends it on next action
// When called from action, caches matched text and appends it on next action
more: function () {
this._more = true
return this
},
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
reject: function () {
if (this.options.backtrack_lexer) {
this._backtrack = true
@ -375,18 +377,18 @@ var parser = (function () {
return this
},
// retain first n characters of the match
// retain first n characters of the match
less: function (n) {
this.unput(this.match.slice(n))
},
// displays already matched input, i.e. for error messages
// displays already matched input, i.e. for error messages
pastInput: function () {
var past = this.matched.substr(0, this.matched.length - this.match.length)
return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '')
},
// displays upcoming input, i.e. for error messages
// displays upcoming input, i.e. for error messages
upcomingInput: function () {
var next = this.match
if (next.length < 20) {
@ -395,21 +397,21 @@ var parser = (function () {
return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, '')
},
// displays the character position where the lexing error occurred, i.e. for error messages
// displays the character position where the lexing error occurred, i.e. for error messages
showPosition: function () {
var pre = this.pastInput()
var c = new Array(pre.length + 1).join('-')
return pre + this.upcomingInput() + '\n' + c + '^'
},
// test the lexed token: return FALSE when not a match, otherwise return token
// test the lexed token: return FALSE when not a match, otherwise return token
test_match: function (match, indexed_rule) {
var token,
lines,
backup
if (this.options.backtrack_lexer) {
// save context
// save context
backup = {
yylineno: this.yylineno,
yylloc: {
@ -444,8 +446,8 @@ var parser = (function () {
last_line: this.yylineno + 1,
first_column: this.yylloc.last_column,
last_column: lines
? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length
: this.yylloc.last_column + match[0].length
? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length
: this.yylloc.last_column + match[0].length
}
this.yytext += match[0]
this.match += match[0]
@ -465,7 +467,7 @@ var parser = (function () {
if (token) {
return token
} else if (this._backtrack) {
// recover context
// recover context
for (var k in backup) {
this[k] = backup[k]
}
@ -474,7 +476,7 @@ var parser = (function () {
return false
},
// return next match in input
// return next match in input
next: function () {
if (this.done) {
return this.EOF
@ -505,7 +507,7 @@ var parser = (function () {
match = false
continue // rule action called reject() implying a rule MISmatch.
} else {
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false
}
} else if (!this.options.flex) {
@ -518,7 +520,7 @@ var parser = (function () {
if (token !== false) {
return token
}
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false
}
if (this._input === '') {
@ -532,7 +534,7 @@ var parser = (function () {
}
},
// return next match that has a token
// return next match that has a token
lex: function lex () {
var r = this.next()
if (r) {
@ -542,12 +544,12 @@ var parser = (function () {
}
},
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
begin: function begin (condition) {
this.conditionStack.push(condition)
},
// pop the previously active lexer condition state off the condition stack
// pop the previously active lexer condition state off the condition stack
popState: function popState () {
var n = this.conditionStack.length - 1
if (n > 0) {
@ -557,7 +559,7 @@ var parser = (function () {
}
},
// produce the lexer rule set which is active for the currently active lexer condition state
// produce the lexer rule set which is active for the currently active lexer condition state
_currentRules: function _currentRules () {
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules
@ -566,7 +568,7 @@ var parser = (function () {
}
},
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
topState: function topState (n) {
n = this.conditionStack.length - 1 - Math.abs(n || 0)
if (n >= 0) {
@ -576,22 +578,22 @@ var parser = (function () {
}
},
// alias for begin(condition)
// alias for begin(condition)
pushState: function pushState (condition) {
this.begin(condition)
},
// return the number of states currently on the stack
// return the number of states currently on the stack
stateStackSize: function stateStackSize () {
return this.conditionStack.length
},
options: {'case-insensitive': true},
options: { 'case-insensitive': true },
performAction: function anonymous (yy, yy_, $avoiding_name_collisions, YY_START) {
// Pre-lexer code can go here
// Pre-lexer code can go here
var YYSTATE = YY_START
switch ($avoiding_name_collisions) {
case 0:return 10
case 0: return 10
break
case 1:/* skip whitespace */
break
@ -599,30 +601,30 @@ var parser = (function () {
break
case 3:/* skip comments */
break
case 4:return 4
case 4: return 4
break
case 5:return 11
case 5: return 11
break
case 6:return 'date'
case 6: return 'date'
break
case 7:return 12
case 7: return 12
break
case 8:return 13
case 8: return 13
break
case 9:return 14
case 9: return 14
break
case 10:return 15
case 10: return 15
break
case 11:return ':'
case 11: return ':'
break
case 12:return 6
case 12: return 6
break
case 13:return 'INVALID'
case 13: return 'INVALID'
break
}
},
rules: [/^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:gantt\b)/i, /^(?:dateFormat\s[^#\n;]+)/i, /^(?:\d\d\d\d-\d\d-\d\d\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:section\s[^#:\n;]+)/i, /^(?:[^#:\n;]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/i, /^(?:$)/i, /^(?:.)/i],
conditions: {'INITIAL': {'rules': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], 'inclusive': true}}
conditions: { 'INITIAL': { 'rules': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], 'inclusive': true } }
})
return lexer
})()