From 9433de879756e5e326408609d1e4b6cd0192b322 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 5 Mar 2017 02:04:31 +0100 Subject: [PATCH] Fix regression of 5324611c30069603bb767707f0aafb6b4a2b07c9 This makes the grammar ambiguous, but jison generates the correct parser. --- .../WoltLabSuite/Core/Template.grammar.jison | 17 +++------- .../js/WoltLabSuite/Core/Template.grammar.js | 32 +++++++++---------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.jison b/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.jison index f8c00ed639..15b715108f 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.jison +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.jison @@ -125,9 +125,9 @@ COMMAND: + "return (looped ? result : " + ($5 || "''") + "); })()" } | '{lang}' CHUNK_STAR '{/lang}' -> "Language.get(" + $2 + ")" -| '{' FUNCTION_CALL '}' -> "StringUtil.escapeHTML(" + $2 + ")" -| '{#' FUNCTION_CALL '}' -> "StringUtil.formatNumeric(" + $2 + ")" -| '{@' FUNCTION_CALL '}' -> $2 +| '{' VARIABLE '}' -> "StringUtil.escapeHTML(" + $2 + ")" +| '{#' VARIABLE '}' -> "StringUtil.formatNumeric(" + $2 + ")" +| '{@' VARIABLE '}' -> $2 | '{ldelim}' -> "'{'" | '{rdelim}' -> "'}'" ; @@ -145,19 +145,10 @@ FOREACH_ELSE: '{foreachelse}' CHUNK_STAR -> $2 VARIABLE: T_VARIABLE T_VARIABLE_NAME VARIABLE_SUFFIX* -> "v['" + $2 + "']" + $3.join(''); ; -// FUNCTION_CALL parses a valid function call -FUNCTION_CALL: T_VARIABLE T_VARIABLE_NAME FUNCTION_CALL_SUFFIX* -> "v['" + $2 + "']" + $3.join(''); -; - VARIABLE_SUFFIX: '[' COMMAND_PARAMETERS ']' -> $1 + $2 + $3 | '.' T_VARIABLE_NAME -> "['" + $2 + "']" -; - -FUNCTION_CALL_SUFFIX: - VARIABLE_SUFFIX -| '(' ')' -> $1 + $2 -| '(' COMMAND_PARAMETERS ')' -> $1 + ($2 || '') + $3 +| '(' COMMAND_PARAMETERS? ')' -> $1 + ($2 || '') + $3 ; COMMAND_PARAMETER_LIST: diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.js index 62f1fa7b7f..1cddb106b7 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Template.grammar.js @@ -1,12 +1,12 @@ define(function(require){ -var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[2,51],$V1=[5,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,28,29,31,32,33,35,36,37,39,40,41,42,44,46,48],$V2=[1,33],$V3=[1,37],$V4=[1,38],$V5=[1,43],$V6=[1,39],$V7=[1,44],$V8=[1,42],$V9=[1,40],$Va=[1,46],$Vb=[11,12,14,15,17,18,20,21,22,23],$Vc=[12,16,18,19],$Vd=[9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,28,29,31,33,36,39,40,41,42,44,46],$Ve=[11,12,14,15,16,17,18,19,20,21,22,23],$Vf=[1,77],$Vg=[1,78],$Vh=[28,44,46],$Vi=[12,14]; +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[2,48],$V1=[5,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,28,29,31,32,33,35,36,37,39,40,41,42,44,46,48],$V2=[1,33],$V3=[1,37],$V4=[1,38],$V5=[1,43],$V6=[1,39],$V7=[1,42],$V8=[1,40],$V9=[1,45],$Va=[11,12,14,15,17,18,20,21,22,23],$Vb=[11,12,14,15,16,17,18,19,20,21,22,23],$Vc=[9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,28,29,31,33,36,39,40,41,42,44,46],$Vd=[28,44,46],$Ve=[12,14]; var parser = {trace: function trace() { }, yy: {}, -symbols_: {"error":2,"TEMPLATE":3,"CHUNK_STAR":4,"EOF":5,"CHUNK_STAR_repetition0":6,"CHUNK":7,"PLAIN_ANY":8,"T_LITERAL":9,"COMMAND":10,"T_ANY":11,"}":12,"{":13,"T_WS":14,"]":15,"[":16,")":17,"(":18,".":19,"=":20,"T_VARIABLE":21,"T_VARIABLE_NAME":22,"T_QUOTED_STRING":23,"{if":24,"COMMAND_PARAMETERS":25,"COMMAND_repetition0":26,"COMMAND_option0":27,"{/if}":28,"{include":29,"COMMAND_PARAMETER_LIST":30,"{implode":31,"{/implode}":32,"{foreach":33,"COMMAND_option1":34,"{/foreach}":35,"{lang}":36,"{/lang}":37,"FUNCTION_CALL":38,"{#":39,"{@":40,"{ldelim}":41,"{rdelim}":42,"ELSE":43,"{else}":44,"ELSE_IF":45,"{elseif":46,"FOREACH_ELSE":47,"{foreachelse}":48,"VARIABLE":49,"VARIABLE_repetition0":50,"FUNCTION_CALL_repetition0":51,"VARIABLE_SUFFIX":52,"FUNCTION_CALL_SUFFIX":53,"COMMAND_PARAMETER_VALUE":54,"COMMAND_PARAMETERS_repetition_plus0":55,"COMMAND_PARAMETER":56,"$accept":0,"$end":1}, +symbols_: {"error":2,"TEMPLATE":3,"CHUNK_STAR":4,"EOF":5,"CHUNK_STAR_repetition0":6,"CHUNK":7,"PLAIN_ANY":8,"T_LITERAL":9,"COMMAND":10,"T_ANY":11,"}":12,"{":13,"T_WS":14,"]":15,"[":16,")":17,"(":18,".":19,"=":20,"T_VARIABLE":21,"T_VARIABLE_NAME":22,"T_QUOTED_STRING":23,"{if":24,"COMMAND_PARAMETERS":25,"COMMAND_repetition0":26,"COMMAND_option0":27,"{/if}":28,"{include":29,"COMMAND_PARAMETER_LIST":30,"{implode":31,"{/implode}":32,"{foreach":33,"COMMAND_option1":34,"{/foreach}":35,"{lang}":36,"{/lang}":37,"VARIABLE":38,"{#":39,"{@":40,"{ldelim}":41,"{rdelim}":42,"ELSE":43,"{else}":44,"ELSE_IF":45,"{elseif":46,"FOREACH_ELSE":47,"{foreachelse}":48,"VARIABLE_repetition0":49,"VARIABLE_SUFFIX":50,"VARIABLE_SUFFIX_option0":51,"COMMAND_PARAMETER_VALUE":52,"COMMAND_PARAMETERS_repetition_plus0":53,"COMMAND_PARAMETER":54,"$accept":0,"$end":1}, terminals_: {2:"error",5:"EOF",9:"T_LITERAL",11:"T_ANY",12:"}",13:"{",14:"T_WS",15:"]",16:"[",17:")",18:"(",19:".",20:"=",21:"T_VARIABLE",22:"T_VARIABLE_NAME",23:"T_QUOTED_STRING",24:"{if",28:"{/if}",29:"{include",31:"{implode",32:"{/implode}",33:"{foreach",35:"{/foreach}",36:"{lang}",37:"{/lang}",39:"{#",40:"{@",41:"{ldelim}",42:"{rdelim}",44:"{else}",46:"{elseif",48:"{foreachelse}"}, -productions_: [0,[3,2],[4,1],[7,1],[7,1],[7,1],[8,1],[8,1],[8,2],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[10,7],[10,3],[10,5],[10,6],[10,3],[10,3],[10,3],[10,3],[10,1],[10,1],[43,2],[45,4],[47,2],[49,3],[38,3],[52,3],[52,2],[53,1],[53,2],[53,3],[30,5],[30,3],[54,1],[54,1],[25,1],[56,1],[56,1],[56,1],[56,1],[56,1],[56,1],[56,3],[6,0],[6,2],[26,0],[26,2],[27,0],[27,1],[34,0],[34,1],[50,0],[50,2],[51,0],[51,2],[55,1],[55,2]], +productions_: [0,[3,2],[4,1],[7,1],[7,1],[7,1],[8,1],[8,1],[8,2],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[10,7],[10,3],[10,5],[10,6],[10,3],[10,3],[10,3],[10,3],[10,1],[10,1],[43,2],[45,4],[47,2],[38,3],[50,3],[50,2],[50,3],[30,5],[30,3],[52,1],[52,1],[25,1],[54,1],[54,1],[54,1],[54,1],[54,1],[54,1],[54,3],[6,0],[6,2],[26,0],[26,2],[27,0],[27,1],[34,0],[34,1],[49,0],[49,2],[51,0],[51,1],[53,1],[53,2]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { /* this == yyval */ @@ -37,7 +37,7 @@ break; case 5: this.$ = { encode: false, value: $$[$0] }; break; -case 8: case 37: +case 8: this.$ = $$[$0-1] + $$[$0]; break; case 19: @@ -113,40 +113,40 @@ break; case 31: this.$ = $$[$0]; break; -case 32: case 33: +case 32: this.$ = "v['" + $$[$0-1] + "']" + $$[$0].join('');; break; -case 34: +case 33: this.$ = $$[$0-2] + $$[$0-1] + $$[$0]; break; -case 35: +case 34: this.$ = "['" + $$[$0] + "']"; break; -case 38: case 50: +case 35: case 47: this.$ = $$[$0-2] + ($$[$0-1] || '') + $$[$0]; break; -case 39: +case 36: this.$ = $$[$0]; this.$[$$[$0-4]] = $$[$0-2]; break; -case 40: +case 37: this.$ = {}; this.$[$$[$0-2]] = $$[$0]; break; -case 43: +case 40: this.$ = $$[$0].join(''); break; -case 51: case 53: case 59: case 61: +case 48: case 50: case 56: this.$ = []; break; -case 52: case 54: case 60: case 62: case 64: +case 49: case 51: case 57: case 61: $$[$0-1].push($$[$0]); break; -case 63: +case 60: this.$ = [$$[$0]]; break; } }, -table: [o([5,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,29,31,33,36,39,40,41,42],$V0,{3:1,4:2,6:3}),{1:[3]},{5:[1,4]},o([5,28,32,35,37,44,46,48],[2,2],{7:5,8:6,10:8,9:[1,7],11:[1,9],12:[1,10],13:[1,11],14:[1,21],15:[1,12],16:[1,13],17:[1,14],18:[1,15],19:[1,16],20:[1,17],21:[1,18],22:[1,19],23:[1,20],24:[1,22],29:[1,23],31:[1,24],33:[1,25],36:[1,26],39:[1,27],40:[1,28],41:[1,29],42:[1,30]}),{1:[2,1]},o($V1,[2,52]),o($V1,[2,3]),o($V1,[2,4]),o($V1,[2,5]),o($V1,[2,6]),o($V1,[2,7]),{14:[1,31],21:$V2,38:32},o($V1,[2,9]),o($V1,[2,10]),o($V1,[2,11]),o($V1,[2,12]),o($V1,[2,13]),o($V1,[2,14]),o($V1,[2,15]),o($V1,[2,16]),o($V1,[2,17]),o($V1,[2,18]),{11:$V3,14:$V4,18:$V5,20:$V6,21:$V7,22:$V8,23:$V9,25:34,49:41,55:35,56:36},{22:$Va,30:45},{22:$Va,30:47},{22:$Va,30:48},o([9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,29,31,33,36,37,39,40,41,42],$V0,{6:3,4:49}),{21:$V2,38:50},{21:$V2,38:51},o($V1,[2,27]),o($V1,[2,28]),o($V1,[2,8]),{12:[1,52]},{22:[1,53]},{12:[1,54]},o([12,15,17],[2,43],{49:41,56:55,11:$V3,14:$V4,18:$V5,20:$V6,21:$V7,22:$V8,23:$V9}),o($Vb,[2,63]),o($Vb,[2,44]),o($Vb,[2,45]),o($Vb,[2,46]),o($Vb,[2,47]),o($Vb,[2,48]),o($Vb,[2,49]),{11:$V3,14:$V4,18:$V5,20:$V6,21:$V7,22:$V8,23:$V9,25:56,49:41,55:35,56:36},{22:[1,57]},{12:[1,58]},{20:[1,59]},{12:[1,60]},{12:[1,61]},{37:[1,62]},{12:[1,63]},{12:[1,64]},o($V1,[2,24]),o($Vc,[2,61],{51:65}),o($Vd,$V0,{6:3,4:66}),o($Vb,[2,64]),{17:[1,67]},o($Ve,[2,59],{50:68}),o($V1,[2,20]),{21:$V7,23:[1,70],49:71,54:69},o([9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,29,31,32,33,36,39,40,41,42],$V0,{6:3,4:72}),o([9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,29,31,33,35,36,39,40,41,42,48],$V0,{6:3,4:73}),o($V1,[2,23]),o($V1,[2,25]),o($V1,[2,26]),{12:[2,33],16:$Vf,18:[1,76],19:$Vg,52:75,53:74},o($Vh,[2,53],{26:79}),o($Vb,[2,50]),o($Vb,[2,32],{52:80,16:$Vf,19:$Vg}),{12:[2,40],14:[1,81]},o($Vi,[2,41]),o($Vi,[2,42]),{32:[1,82]},{34:83,35:[2,57],47:84,48:[1,85]},o($Vc,[2,62]),o($Vc,[2,36]),{11:$V3,14:$V4,17:[1,86],18:$V5,20:$V6,21:$V7,22:$V8,23:$V9,25:87,49:41,55:35,56:36},{11:$V3,14:$V4,18:$V5,20:$V6,21:$V7,22:$V8,23:$V9,25:88,49:41,55:35,56:36},{22:[1,89]},{27:90,28:[2,55],43:92,44:[1,94],45:91,46:[1,93]},o($Ve,[2,60]),{22:$Va,30:95},o($V1,[2,21]),{35:[1,96]},{35:[2,58]},o([9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,29,31,33,35,36,39,40,41,42],$V0,{6:3,4:97}),o($Vc,[2,37]),{17:[1,98]},{15:[1,99]},o($Ve,[2,35]),{28:[1,100]},o($Vh,[2,54]),{28:[2,56]},{11:$V3,14:$V4,18:$V5,20:$V6,21:$V7,22:$V8,23:$V9,25:101,49:41,55:35,56:36},o([9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,28,29,31,33,36,39,40,41,42],$V0,{6:3,4:102}),{12:[2,39]},o($V1,[2,22]),{35:[2,31]},o($Vc,[2,38]),o($Ve,[2,34]),o($V1,[2,19]),{12:[1,103]},{28:[2,29]},o($Vd,$V0,{6:3,4:104}),o($Vh,[2,30])], -defaultActions: {4:[2,1],84:[2,58],92:[2,56],95:[2,39],97:[2,31],102:[2,29]}, +table: [o([5,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,29,31,33,36,39,40,41,42],$V0,{3:1,4:2,6:3}),{1:[3]},{5:[1,4]},o([5,28,32,35,37,44,46,48],[2,2],{7:5,8:6,10:8,9:[1,7],11:[1,9],12:[1,10],13:[1,11],14:[1,21],15:[1,12],16:[1,13],17:[1,14],18:[1,15],19:[1,16],20:[1,17],21:[1,18],22:[1,19],23:[1,20],24:[1,22],29:[1,23],31:[1,24],33:[1,25],36:[1,26],39:[1,27],40:[1,28],41:[1,29],42:[1,30]}),{1:[2,1]},o($V1,[2,49]),o($V1,[2,3]),o($V1,[2,4]),o($V1,[2,5]),o($V1,[2,6]),o($V1,[2,7]),{14:[1,31],21:$V2,38:32},o($V1,[2,9]),o($V1,[2,10]),o($V1,[2,11]),o($V1,[2,12]),o($V1,[2,13]),o($V1,[2,14]),o($V1,[2,15]),o($V1,[2,16]),o($V1,[2,17]),o($V1,[2,18]),{11:$V3,14:$V4,18:$V5,20:$V6,21:$V2,22:$V7,23:$V8,25:34,38:41,53:35,54:36},{22:$V9,30:44},{22:$V9,30:46},{22:$V9,30:47},o([9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,29,31,33,36,37,39,40,41,42],$V0,{6:3,4:48}),{21:$V2,38:49},{21:$V2,38:50},o($V1,[2,27]),o($V1,[2,28]),o($V1,[2,8]),{12:[1,51]},{22:[1,52]},{12:[1,53]},o([12,15,17],[2,40],{38:41,54:54,11:$V3,14:$V4,18:$V5,20:$V6,21:$V2,22:$V7,23:$V8}),o($Va,[2,60]),o($Va,[2,41]),o($Va,[2,42]),o($Va,[2,43]),o($Va,[2,44]),o($Va,[2,45]),o($Va,[2,46]),{11:$V3,14:$V4,18:$V5,20:$V6,21:$V2,22:$V7,23:$V8,25:55,38:41,53:35,54:36},{12:[1,56]},{20:[1,57]},{12:[1,58]},{12:[1,59]},{37:[1,60]},{12:[1,61]},{12:[1,62]},o($V1,[2,24]),o($Vb,[2,56],{49:63}),o($Vc,$V0,{6:3,4:64}),o($Va,[2,61]),{17:[1,65]},o($V1,[2,20]),{21:$V2,23:[1,67],38:68,52:66},o([9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,29,31,32,33,36,39,40,41,42],$V0,{6:3,4:69}),o([9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,29,31,33,35,36,39,40,41,42,48],$V0,{6:3,4:70}),o($V1,[2,23]),o($V1,[2,25]),o($V1,[2,26]),o([11,12,14,15,17,20,21,22,23],[2,32],{50:71,16:[1,72],18:[1,74],19:[1,73]}),o($Vd,[2,50],{26:75}),o($Va,[2,47]),{12:[2,37],14:[1,76]},o($Ve,[2,38]),o($Ve,[2,39]),{32:[1,77]},{34:78,35:[2,54],47:79,48:[1,80]},o($Vb,[2,57]),{11:$V3,14:$V4,18:$V5,20:$V6,21:$V2,22:$V7,23:$V8,25:81,38:41,53:35,54:36},{22:[1,82]},{11:$V3,14:$V4,17:[2,58],18:$V5,20:$V6,21:$V2,22:$V7,23:$V8,25:84,38:41,51:83,53:35,54:36},{27:85,28:[2,52],43:87,44:[1,89],45:86,46:[1,88]},{22:$V9,30:90},o($V1,[2,21]),{35:[1,91]},{35:[2,55]},o([9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,29,31,33,35,36,39,40,41,42],$V0,{6:3,4:92}),{15:[1,93]},o($Vb,[2,34]),{17:[1,94]},{17:[2,59]},{28:[1,95]},o($Vd,[2,51]),{28:[2,53]},{11:$V3,14:$V4,18:$V5,20:$V6,21:$V2,22:$V7,23:$V8,25:96,38:41,53:35,54:36},o([9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,28,29,31,33,36,39,40,41,42],$V0,{6:3,4:97}),{12:[2,36]},o($V1,[2,22]),{35:[2,31]},o($Vb,[2,33]),o($Vb,[2,35]),o($V1,[2,19]),{12:[1,98]},{28:[2,29]},o($Vc,$V0,{6:3,4:99}),o($Vd,[2,30])], +defaultActions: {4:[2,1],79:[2,55],84:[2,59],87:[2,53],90:[2,36],92:[2,31],97:[2,29]}, parseError: function parseError(str, hash) { if (hash.recoverable) { this.trace(str); -- 2.20.1