From: Maximilian Mader Date: Fri, 30 Sep 2016 18:52:21 +0000 (+0200) Subject: Allow comments and literals to span multiple lines in Template.grammar.jison X-Git-Tag: 3.0.0_Beta_2~49^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6ebad43db540dc44eec773da88bebbaac2485302;p=GitHub%2FWoltLab%2FWCF.git Allow comments and literals to span multiple lines in Template.grammar.jison --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.jison b/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.jison index 6184c9c416..b8184bd5a6 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.jison +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.jison @@ -15,8 +15,8 @@ %s command %% -\{\*.*\*\} /* comment */ -\{literal\}.*?\{\/literal\} { yytext = yytext.substring(9, yytext.length - 10); return 'T_LITERAL'; } +\{\*[\s\S]*?\*\} /* comment */ +\{literal\}[\s\S]*?\{\/literal\} { yytext = yytext.substring(9, yytext.length - 10); return 'T_LITERAL'; } \"([^"]|\\\.)*\" return 'T_QUOTED_STRING'; \'([^']|\\\.)*\' return 'T_QUOTED_STRING'; \$ return 'T_VARIABLE'; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.js index 4dad8f3980..0960817d36 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.js @@ -151,7 +151,13 @@ parseError: function parseError(str, hash) { if (hash.recoverable) { this.trace(str); } else { - throw new Error(str); + function _parseError (msg, hash) { + this.message = msg; + this.hash = hash; + } + _parseError.prototype = Error; + + throw new _parseError(str, hash); } }, parse: function parse(input) { @@ -184,14 +190,14 @@ parse: function parse(input) { lstack.length = lstack.length - n; } _token_stack: - function lex() { + 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]; @@ -692,7 +698,7 @@ case 34:return 11; break; } }, -rules: [/^(?:\{\*.*\*\})/,/^(?:\{literal\}.*?\{\/literal\})/,/^(?:"([^"]|\\\.)*")/,/^(?:'([^']|\\\.)*')/,/^(?:\$)/,/^(?:[_a-zA-Z][_a-zA-Z0-9]*)/,/^(?:\.)/,/^(?:\[)/,/^(?:\])/,/^(?:\()/,/^(?:\))/,/^(?:=)/,/^(?:\{ldelim\})/,/^(?:\{rdelim\})/,/^(?:\{#)/,/^(?:\{@)/,/^(?:\{if )/,/^(?:\{else if )/,/^(?:\{elseif )/,/^(?:\{else\})/,/^(?:\{\/if\})/,/^(?:\{lang\})/,/^(?:\{\/lang\})/,/^(?:\{include )/,/^(?:\{implode )/,/^(?:\{\/implode\})/,/^(?:\{foreach )/,/^(?:\{foreachelse\})/,/^(?:\{\/foreach\})/,/^(?:\{)/,/^(?:\})/,/^(?:\})/,/^(?:\s+)/,/^(?:$)/,/^(?:[^{])/], +rules: [/^(?:\{\*[\s\S]*?\*\})/,/^(?:\{literal\}[\s\S]*?\{\/literal\})/,/^(?:"([^"]|\\\.)*")/,/^(?:'([^']|\\\.)*')/,/^(?:\$)/,/^(?:[_a-zA-Z][_a-zA-Z0-9]*)/,/^(?:\.)/,/^(?:\[)/,/^(?:\])/,/^(?:\()/,/^(?:\))/,/^(?:=)/,/^(?:\{ldelim\})/,/^(?:\{rdelim\})/,/^(?:\{#)/,/^(?:\{@)/,/^(?:\{if )/,/^(?:\{else if )/,/^(?:\{elseif )/,/^(?:\{else\})/,/^(?:\{\/if\})/,/^(?:\{lang\})/,/^(?:\{\/lang\})/,/^(?:\{include )/,/^(?:\{implode )/,/^(?:\{\/implode\})/,/^(?:\{foreach )/,/^(?:\{foreachelse\})/,/^(?:\{\/foreach\})/,/^(?:\{)/,/^(?:\})/,/^(?:\})/,/^(?:\s+)/,/^(?:$)/,/^(?:[^{])/], conditions: {"command":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"inclusive":true},"INITIAL":{"rules":[0,1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,32,33,34],"inclusive":true}} }); return lexer;