parser.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  1. /* parser generated by jison 0.4.15 */
  2. /*
  3. Returns a Parser object of the following structure:
  4. Parser: {
  5. yy: {}
  6. }
  7. Parser.prototype: {
  8. yy: {},
  9. trace: function(),
  10. symbols_: {associative list: name ==> number},
  11. terminals_: {associative list: number ==> name},
  12. productions_: [...],
  13. performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
  14. table: [...],
  15. defaultActions: {...},
  16. parseError: function(str, hash),
  17. parse: function(input),
  18. lexer: {
  19. EOF: 1,
  20. parseError: function(str, hash),
  21. setInput: function(input),
  22. input: function(),
  23. unput: function(str),
  24. more: function(),
  25. less: function(n),
  26. pastInput: function(),
  27. upcomingInput: function(),
  28. showPosition: function(),
  29. test_match: function(regex_match_array, rule_index),
  30. next: function(),
  31. lex: function(),
  32. begin: function(condition),
  33. popState: function(),
  34. _currentRules: function(),
  35. topState: function(),
  36. pushState: function(condition),
  37. options: {
  38. ranges: boolean (optional: true ==> token location info will include a .range[] member)
  39. flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
  40. backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
  41. },
  42. performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
  43. rules: [...],
  44. conditions: {associative list: name ==> set},
  45. }
  46. }
  47. token location info (@$, _$, etc.): {
  48. first_line: n,
  49. last_line: n,
  50. first_column: n,
  51. last_column: n,
  52. range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
  53. }
  54. the parseError function receives a 'hash' object with these members for lexer and parser errors: {
  55. text: (matched text)
  56. token: (the produced terminal token, if any)
  57. line: (yylineno)
  58. }
  59. while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
  60. loc: (yylloc)
  61. expected: (string describing the set of expected tokens)
  62. recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
  63. }
  64. */
  65. var Parser = (function(){
  66. var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,4],$V1=[1,5],$V2=[1,7],$V3=[1,10],$V4=[1,8],$V5=[1,9],$V6=[1,11],$V7=[1,16],$V8=[1,17],$V9=[1,14],$Va=[1,15],$Vb=[1,18],$Vc=[1,20],$Vd=[1,21],$Ve=[1,22],$Vf=[1,23],$Vg=[1,24],$Vh=[1,25],$Vi=[1,26],$Vj=[1,27],$Vk=[1,28],$Vl=[1,29],$Vm=[5,11,12,13,15,16,17,18,19,20,21,22,30,31],$Vn=[5,11,12,13,15,16,17,18,19,20,21,22,30,31,33],$Vo=[1,38],$Vp=[5,11,12,13,15,16,17,18,19,20,21,22,30,31,35],$Vq=[5,12,13,15,16,17,18,19,30,31],$Vr=[5,12,15,16,17,18,30,31],$Vs=[5,12,13,15,16,17,18,19,20,21,30,31],$Vt=[15,30,31],$Vu=[5,11,12,13,15,16,17,18,19,20,21,22,30,31,32,36];
  67. var parser = {trace: function trace() { },
  68. yy: {},
  69. symbols_: {"error":2,"expressions":3,"expression":4,"EOF":5,"variableSequence":6,"TIME_AMPM":7,"TIME_24":8,"number":9,"STRING":10,"&":11,"=":12,"+":13,"(":14,")":15,"<":16,">":17,"NOT":18,"-":19,"*":20,"/":21,"^":22,"FUNCTION":23,"expseq":24,"cell":25,"FIXEDCELL":26,":":27,"CELL":28,"ARRAY":29,";":30,",":31,"VARIABLE":32,"DECIMAL":33,"NUMBER":34,"%":35,"#":36,"!":37,"$accept":0,"$end":1},
  70. terminals_: {5:"EOF",7:"TIME_AMPM",8:"TIME_24",10:"STRING",11:"&",12:"=",13:"+",14:"(",15:")",16:"<",17:">",18:"NOT",19:"-",20:"*",21:"/",22:"^",23:"FUNCTION",26:"FIXEDCELL",27:":",28:"CELL",29:"ARRAY",30:";",31:",",32:"VARIABLE",33:"DECIMAL",34:"NUMBER",35:"%",36:"#",37:"!"},
  71. productions_: [0,[3,2],[4,1],[4,1],[4,1],[4,1],[4,1],[4,3],[4,3],[4,3],[4,3],[4,4],[4,4],[4,4],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,2],[4,2],[4,3],[4,4],[4,1],[4,1],[4,2],[25,1],[25,3],[25,1],[25,3],[24,1],[24,1],[24,3],[24,3],[6,1],[6,3],[9,1],[9,3],[9,2],[2,3],[2,4]],
  72. performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
  73. /* this == yyval */
  74. var $0 = $$.length - 1;
  75. switch (yystate) {
  76. case 1:
  77. return $$[$0-1];
  78. break;
  79. case 2:
  80. this.$ = yy.handler.helper.callVariable.call(this, $$[$0]);
  81. break;
  82. case 3:
  83. this.$ = yy.handler.time.call(yy.obj, $$[$0], true);
  84. break;
  85. case 4:
  86. this.$ = yy.handler.time.call(yy.obj, $$[$0]);
  87. break;
  88. case 5:
  89. this.$ = yy.handler.helper.number($$[$0]);
  90. break;
  91. case 6:
  92. this.$ = yy.handler.helper.string($$[$0]);
  93. break;
  94. case 7:
  95. this.$ = yy.handler.helper.specialMatch('&', $$[$0-2], $$[$0]);
  96. break;
  97. case 8:
  98. this.$ = yy.handler.helper.logicMatch('=', $$[$0-2], $$[$0]);
  99. break;
  100. case 9:
  101. this.$ = yy.handler.helper.mathMatch('+', $$[$0-2], $$[$0]);
  102. break;
  103. case 10:
  104. this.$ = yy.handler.helper.number($$[$0-1]);
  105. break;
  106. case 11:
  107. this.$ = yy.handler.helper.logicMatch('<=', $$[$0-3], $$[$0]);
  108. break;
  109. case 12:
  110. this.$ = yy.handler.helper.logicMatch('>=', $$[$0-3], $$[$0]);
  111. break;
  112. case 13:
  113. this.$ = yy.handler.helper.logicMatch('<>', $$[$0-3], $$[$0]);
  114. break;
  115. case 14:
  116. this.$ = yy.handler.helper.logicMatch('NOT', $$[$0-2], $$[$0]);
  117. break;
  118. case 15:
  119. this.$ = yy.handler.helper.logicMatch('>', $$[$0-2], $$[$0]);
  120. break;
  121. case 16:
  122. this.$ = yy.handler.helper.logicMatch('<', $$[$0-2], $$[$0]);
  123. break;
  124. case 17:
  125. this.$ = yy.handler.helper.mathMatch('-', $$[$0-2], $$[$0]);
  126. break;
  127. case 18:
  128. this.$ = yy.handler.helper.mathMatch('*', $$[$0-2], $$[$0]);
  129. break;
  130. case 19:
  131. this.$ = yy.handler.helper.mathMatch('/', $$[$0-2], $$[$0]);
  132. break;
  133. case 20:
  134. this.$ = yy.handler.helper.mathMatch('^', $$[$0-2], $$[$0]);
  135. break;
  136. case 21:
  137. var n1 = yy.handler.helper.numberInverted($$[$0]);
  138. this.$ = n1;
  139. if (isNaN(this.$)) {
  140. this.$ = 0;
  141. }
  142. break;
  143. case 22:
  144. var n1 = yy.handler.helper.number($$[$0]);
  145. this.$ = n1;
  146. if (isNaN(this.$)) {
  147. this.$ = 0;
  148. }
  149. break;
  150. case 23:
  151. this.$ = yy.handler.helper.callFunction.call(this, $$[$0-2], '');
  152. break;
  153. case 24:
  154. this.$ = yy.handler.helper.callFunction.call(this, $$[$0-3], $$[$0-1]);
  155. break;
  156. case 28:
  157. this.$ = yy.handler.helper.fixedCellValue.call(yy.obj, $$[$0]);
  158. break;
  159. case 29:
  160. this.$ = yy.handler.helper.fixedCellRangeValue.call(yy.obj, $$[$0-2], $$[$0]);
  161. break;
  162. case 30:
  163. this.$ = yy.handler.helper.cellValue.call(yy.obj, $$[$0]);
  164. break;
  165. case 31:
  166. this.$ = yy.handler.helper.cellRangeValue.call(yy.obj, $$[$0-2], $$[$0]);
  167. break;
  168. case 32:
  169. if (yy.handler.utils.isArray($$[$0])) {
  170. this.$ = $$[$0];
  171. } else {
  172. this.$ = [$$[$0]];
  173. }
  174. break;
  175. case 33:
  176. var result = [],
  177. arr = eval("[" + yytext + "]");
  178. arr.forEach(function (item) {
  179. result.push(item);
  180. });
  181. this.$ = result;
  182. break;
  183. case 34: case 35:
  184. $$[$0-2].push($$[$0]);
  185. this.$ = $$[$0-2];
  186. break;
  187. case 36:
  188. this.$ = [$$[$0]];
  189. break;
  190. case 37:
  191. this.$ = (yy.handler.utils.isArray($$[$0-2]) ? $$[$0-2] : [$$[$0-2]]);
  192. this.$.push($$[$0]);
  193. break;
  194. case 38:
  195. this.$ = $$[$0];
  196. break;
  197. case 39:
  198. this.$ = ($$[$0-2] + '.' + $$[$0]) * 1;
  199. break;
  200. case 40:
  201. this.$ = $$[$0-1] * 0.01;
  202. break;
  203. case 41: case 42:
  204. this.$ = $$[$0-2] + $$[$0-1] + $$[$0];
  205. break;
  206. }
  207. },
  208. table: [{2:13,3:1,4:2,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{1:[3]},{5:[1,19],11:$Vc,12:$Vd,13:$Ve,16:$Vf,17:$Vg,18:$Vh,19:$Vi,20:$Vj,21:$Vk,22:$Vl},o($Vm,[2,2],{33:[1,30]}),o($Vm,[2,3]),o($Vm,[2,4]),o($Vm,[2,5],{35:[1,31]}),o($Vm,[2,6]),{2:13,4:32,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:33,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:34,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{14:[1,35]},o($Vm,[2,25]),o($Vm,[2,26],{2:36,32:[1,37],36:$Vb}),o($Vn,[2,36],{36:$Vo}),o($Vp,[2,38],{33:[1,39]}),o($Vm,[2,28],{27:[1,40]}),o($Vm,[2,30],{27:[1,41]}),{32:[1,42]},{1:[2,1]},{2:13,4:43,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:44,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:45,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:48,6:3,7:$V0,8:$V1,9:6,10:$V2,12:[1,46],13:$V3,14:$V4,17:[1,47],19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:50,6:3,7:$V0,8:$V1,9:6,10:$V2,12:[1,49],13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:51,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:52,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:53,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:54,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:55,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{32:[1,56]},o($Vp,[2,40]),{11:$Vc,12:$Vd,13:$Ve,15:[1,57],16:$Vf,17:$Vg,18:$Vh,19:$Vi,20:$Vj,21:$Vk,22:$Vl},o($Vq,[2,21],{11:$Vc,20:$Vj,21:$Vk,22:$Vl}),o($Vq,[2,22],{11:$Vc,20:$Vj,21:$Vk,22:$Vl}),{2:13,4:60,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,15:[1,58],19:$V5,23:$V6,24:59,25:12,26:$V7,28:$V8,29:[1,61],32:$V9,34:$Va,36:$Vb},o($Vm,[2,27]),{36:$Vo},{32:[1,62]},{34:[1,63]},{26:[1,64]},{28:[1,65]},{37:[1,66]},o($Vm,[2,7]),o([5,12,15,30,31],[2,8],{11:$Vc,13:$Ve,16:$Vf,17:$Vg,18:$Vh,19:$Vi,20:$Vj,21:$Vk,22:$Vl}),o($Vq,[2,9],{11:$Vc,20:$Vj,21:$Vk,22:$Vl}),{2:13,4:67,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:68,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},o($Vr,[2,16],{11:$Vc,13:$Ve,19:$Vi,20:$Vj,21:$Vk,22:$Vl}),{2:13,4:69,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},o($Vr,[2,15],{11:$Vc,13:$Ve,19:$Vi,20:$Vj,21:$Vk,22:$Vl}),o([5,12,15,18,30,31],[2,14],{11:$Vc,13:$Ve,16:$Vf,17:$Vg,19:$Vi,20:$Vj,21:$Vk,22:$Vl}),o($Vq,[2,17],{11:$Vc,20:$Vj,21:$Vk,22:$Vl}),o($Vs,[2,18],{11:$Vc,22:$Vl}),o($Vs,[2,19],{11:$Vc,22:$Vl}),o([5,12,13,15,16,17,18,19,20,21,22,30,31],[2,20],{11:$Vc}),o($Vn,[2,37]),o($Vm,[2,10]),o($Vm,[2,23]),{15:[1,70],30:[1,71],31:[1,72]},o($Vt,[2,32],{11:$Vc,12:$Vd,13:$Ve,16:$Vf,17:$Vg,18:$Vh,19:$Vi,20:$Vj,21:$Vk,22:$Vl}),o($Vt,[2,33]),{37:[1,73]},o($Vp,[2,39]),o($Vm,[2,29]),o($Vm,[2,31]),o($Vu,[2,41]),o($Vr,[2,11],{11:$Vc,13:$Ve,19:$Vi,20:$Vj,21:$Vk,22:$Vl}),o($Vr,[2,13],{11:$Vc,13:$Ve,19:$Vi,20:$Vj,21:$Vk,22:$Vl}),o($Vr,[2,12],{11:$Vc,13:$Ve,19:$Vi,20:$Vj,21:$Vk,22:$Vl}),o($Vm,[2,24]),{2:13,4:74,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},{2:13,4:75,6:3,7:$V0,8:$V1,9:6,10:$V2,13:$V3,14:$V4,19:$V5,23:$V6,25:12,26:$V7,28:$V8,32:$V9,34:$Va,36:$Vb},o($Vu,[2,42]),o($Vt,[2,34],{11:$Vc,12:$Vd,13:$Ve,16:$Vf,17:$Vg,18:$Vh,19:$Vi,20:$Vj,21:$Vk,22:$Vl}),o($Vt,[2,35],{11:$Vc,12:$Vd,13:$Ve,16:$Vf,17:$Vg,18:$Vh,19:$Vi,20:$Vj,21:$Vk,22:$Vl})],
  209. defaultActions: {19:[2,1]},
  210. parseError: function parseError(str, hash) {
  211. if (hash.recoverable) {
  212. this.trace(str);
  213. } else {
  214. throw new Error(str);
  215. }
  216. },
  217. parse: function parse(input) {
  218. var self = this,
  219. stack = [0],
  220. tstack = [], // token stack
  221. vstack = [null], // semantic value stack
  222. lstack = [], // location stack
  223. table = this.table,
  224. yytext = '',
  225. yylineno = 0,
  226. yyleng = 0,
  227. recovering = 0,
  228. TERROR = 2,
  229. EOF = 1;
  230. var args = lstack.slice.call(arguments, 1);
  231. //this.reductionCount = this.shiftCount = 0;
  232. var lexer = Object.create(this.lexer);
  233. var sharedState = { yy: {} };
  234. // copy state
  235. for (var k in this.yy) {
  236. if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
  237. sharedState.yy[k] = this.yy[k];
  238. }
  239. }
  240. lexer.setInput(input, sharedState.yy);
  241. sharedState.yy.lexer = lexer;
  242. sharedState.yy.parser = this;
  243. if (typeof lexer.yylloc == 'undefined') {
  244. lexer.yylloc = {};
  245. }
  246. var yyloc = lexer.yylloc;
  247. lstack.push(yyloc);
  248. var ranges = lexer.options && lexer.options.ranges;
  249. if (typeof sharedState.yy.parseError === 'function') {
  250. this.parseError = sharedState.yy.parseError;
  251. } else {
  252. this.parseError = Object.getPrototypeOf(this).parseError;
  253. }
  254. function popStack (n) {
  255. stack.length = stack.length - 2 * n;
  256. vstack.length = vstack.length - n;
  257. lstack.length = lstack.length - n;
  258. }
  259. _token_stack:
  260. function lex() {
  261. var token;
  262. token = lexer.lex() || EOF;
  263. // if token isn't its numeric value, convert
  264. if (typeof token !== 'number') {
  265. token = self.symbols_[token] || token;
  266. }
  267. return token;
  268. }
  269. var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
  270. while (true) {
  271. // retreive state number from top of stack
  272. state = stack[stack.length - 1];
  273. // use default actions if available
  274. if (this.defaultActions[state]) {
  275. action = this.defaultActions[state];
  276. } else {
  277. if (symbol === null || typeof symbol == 'undefined') {
  278. symbol = lex();
  279. }
  280. // read action for current state and first input
  281. action = table[state] && table[state][symbol];
  282. }
  283. _handle_error:
  284. // handle parse error
  285. if (typeof action === 'undefined' || !action.length || !action[0]) {
  286. var error_rule_depth;
  287. var errStr = '';
  288. // Return the rule stack depth where the nearest error rule can be found.
  289. // Return FALSE when no error recovery rule was found.
  290. function locateNearestErrorRecoveryRule(state) {
  291. var stack_probe = stack.length - 1;
  292. var depth = 0;
  293. // try to recover from error
  294. for(;;) {
  295. // check for error recovery rule in this state
  296. if ((TERROR.toString()) in table[state]) {
  297. return depth;
  298. }
  299. if (state === 0 || stack_probe < 2) {
  300. return false; // No suitable error recovery rule available.
  301. }
  302. stack_probe -= 2; // popStack(1): [symbol, action]
  303. state = stack[stack_probe];
  304. ++depth;
  305. }
  306. }
  307. if (!recovering) {
  308. // first see if there's any chance at hitting an error recovery rule:
  309. error_rule_depth = locateNearestErrorRecoveryRule(state);
  310. // Report error
  311. expected = [];
  312. for (p in table[state]) {
  313. if (this.terminals_[p] && p > TERROR) {
  314. expected.push("'"+this.terminals_[p]+"'");
  315. }
  316. }
  317. if (lexer.showPosition) {
  318. errStr = 'Parse error on line '+(yylineno+1)+":\n"+lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + (this.terminals_[symbol] || symbol)+ "'";
  319. } else {
  320. errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
  321. (symbol == EOF ? "end of input" :
  322. ("'"+(this.terminals_[symbol] || symbol)+"'"));
  323. }
  324. this.parseError(errStr, {
  325. text: lexer.match,
  326. token: this.terminals_[symbol] || symbol,
  327. line: lexer.yylineno,
  328. loc: yyloc,
  329. expected: expected,
  330. recoverable: (error_rule_depth !== false)
  331. });
  332. } else if (preErrorSymbol !== EOF) {
  333. error_rule_depth = locateNearestErrorRecoveryRule(state);
  334. }
  335. // just recovered from another error
  336. if (recovering == 3) {
  337. if (symbol === EOF || preErrorSymbol === EOF) {
  338. throw new Error(errStr || 'Parsing halted while starting to recover from another error.');
  339. }
  340. // discard current lookahead and grab another
  341. yyleng = lexer.yyleng;
  342. yytext = lexer.yytext;
  343. yylineno = lexer.yylineno;
  344. yyloc = lexer.yylloc;
  345. symbol = lex();
  346. }
  347. // try to recover from error
  348. if (error_rule_depth === false) {
  349. throw new Error(errStr || 'Parsing halted. No suitable error recovery rule available.');
  350. }
  351. popStack(error_rule_depth);
  352. preErrorSymbol = (symbol == TERROR ? null : symbol); // save the lookahead token
  353. symbol = TERROR; // insert generic error symbol as new lookahead
  354. state = stack[stack.length-1];
  355. action = table[state] && table[state][TERROR];
  356. recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
  357. }
  358. // this shouldn't happen, unless resolve defaults are off
  359. if (action[0] instanceof Array && action.length > 1) {
  360. throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
  361. }
  362. switch (action[0]) {
  363. case 1: // shift
  364. //this.shiftCount++;
  365. stack.push(symbol);
  366. vstack.push(lexer.yytext);
  367. lstack.push(lexer.yylloc);
  368. stack.push(action[1]); // push state
  369. symbol = null;
  370. if (!preErrorSymbol) { // normal execution/no error
  371. yyleng = lexer.yyleng;
  372. yytext = lexer.yytext;
  373. yylineno = lexer.yylineno;
  374. yyloc = lexer.yylloc;
  375. if (recovering > 0) {
  376. recovering--;
  377. }
  378. } else {
  379. // error just occurred, resume old lookahead f/ before error
  380. symbol = preErrorSymbol;
  381. preErrorSymbol = null;
  382. }
  383. break;
  384. case 2:
  385. // reduce
  386. //this.reductionCount++;
  387. len = this.productions_[action[1]][1];
  388. // perform semantic action
  389. yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
  390. // default location, uses first token for firsts, last for lasts
  391. yyval._$ = {
  392. first_line: lstack[lstack.length-(len||1)].first_line,
  393. last_line: lstack[lstack.length-1].last_line,
  394. first_column: lstack[lstack.length-(len||1)].first_column,
  395. last_column: lstack[lstack.length-1].last_column
  396. };
  397. if (ranges) {
  398. yyval._$.range = [lstack[lstack.length-(len||1)].range[0], lstack[lstack.length-1].range[1]];
  399. }
  400. r = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));
  401. if (typeof r !== 'undefined') {
  402. return r;
  403. }
  404. // pop off stack
  405. if (len) {
  406. stack = stack.slice(0,-1*len*2);
  407. vstack = vstack.slice(0, -1*len);
  408. lstack = lstack.slice(0, -1*len);
  409. }
  410. stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
  411. vstack.push(yyval.$);
  412. lstack.push(yyval._$);
  413. // goto new state = table[STATE][NONTERMINAL]
  414. newState = table[stack[stack.length-2]][stack[stack.length-1]];
  415. stack.push(newState);
  416. break;
  417. case 3:
  418. // accept
  419. return true;
  420. }
  421. }
  422. return true;
  423. }};
  424. /* generated by jison-lex 0.3.4 */
  425. var lexer = (function(){
  426. var lexer = ({
  427. EOF:1,
  428. parseError:function parseError(str, hash) {
  429. if (this.yy.parser) {
  430. this.yy.parser.parseError(str, hash);
  431. } else {
  432. throw new Error(str);
  433. }
  434. },
  435. // resets the lexer, sets new input
  436. setInput:function (input, yy) {
  437. this.yy = yy || this.yy || {};
  438. this._input = input;
  439. this._more = this._backtrack = this.done = false;
  440. this.yylineno = this.yyleng = 0;
  441. this.yytext = this.matched = this.match = '';
  442. this.conditionStack = ['INITIAL'];
  443. this.yylloc = {
  444. first_line: 1,
  445. first_column: 0,
  446. last_line: 1,
  447. last_column: 0
  448. };
  449. if (this.options.ranges) {
  450. this.yylloc.range = [0,0];
  451. }
  452. this.offset = 0;
  453. return this;
  454. },
  455. // consumes and returns one char from the input
  456. input:function () {
  457. var ch = this._input[0];
  458. this.yytext += ch;
  459. this.yyleng++;
  460. this.offset++;
  461. this.match += ch;
  462. this.matched += ch;
  463. var lines = ch.match(/(?:\r\n?|\n).*/g);
  464. if (lines) {
  465. this.yylineno++;
  466. this.yylloc.last_line++;
  467. } else {
  468. this.yylloc.last_column++;
  469. }
  470. if (this.options.ranges) {
  471. this.yylloc.range[1]++;
  472. }
  473. this._input = this._input.slice(1);
  474. return ch;
  475. },
  476. // unshifts one char (or a string) into the input
  477. unput:function (ch) {
  478. var len = ch.length;
  479. var lines = ch.split(/(?:\r\n?|\n)/g);
  480. this._input = ch + this._input;
  481. this.yytext = this.yytext.substr(0, this.yytext.length - len);
  482. //this.yyleng -= len;
  483. this.offset -= len;
  484. var oldLines = this.match.split(/(?:\r\n?|\n)/g);
  485. this.match = this.match.substr(0, this.match.length - 1);
  486. this.matched = this.matched.substr(0, this.matched.length - 1);
  487. if (lines.length - 1) {
  488. this.yylineno -= lines.length - 1;
  489. }
  490. var r = this.yylloc.range;
  491. this.yylloc = {
  492. first_line: this.yylloc.first_line,
  493. last_line: this.yylineno + 1,
  494. first_column: this.yylloc.first_column,
  495. last_column: lines ?
  496. (lines.length === oldLines.length ? this.yylloc.first_column : 0)
  497. + oldLines[oldLines.length - lines.length].length - lines[0].length :
  498. this.yylloc.first_column - len
  499. };
  500. if (this.options.ranges) {
  501. this.yylloc.range = [r[0], r[0] + this.yyleng - len];
  502. }
  503. this.yyleng = this.yytext.length;
  504. return this;
  505. },
  506. // When called from action, caches matched text and appends it on next action
  507. more:function () {
  508. this._more = true;
  509. return this;
  510. },
  511. // 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.
  512. reject:function () {
  513. if (this.options.backtrack_lexer) {
  514. this._backtrack = true;
  515. } else {
  516. return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
  517. text: "",
  518. token: null,
  519. line: this.yylineno
  520. });
  521. }
  522. return this;
  523. },
  524. // retain first n characters of the match
  525. less:function (n) {
  526. this.unput(this.match.slice(n));
  527. },
  528. // displays already matched input, i.e. for error messages
  529. pastInput:function () {
  530. var past = this.matched.substr(0, this.matched.length - this.match.length);
  531. return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
  532. },
  533. // displays upcoming input, i.e. for error messages
  534. upcomingInput:function () {
  535. var next = this.match;
  536. if (next.length < 20) {
  537. next += this._input.substr(0, 20-next.length);
  538. }
  539. return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
  540. },
  541. // displays the character position where the lexing error occurred, i.e. for error messages
  542. showPosition:function () {
  543. var pre = this.pastInput();
  544. var c = new Array(pre.length + 1).join("-");
  545. return pre + this.upcomingInput() + "\n" + c + "^";
  546. },
  547. // test the lexed token: return FALSE when not a match, otherwise return token
  548. test_match:function (match, indexed_rule) {
  549. var token,
  550. lines,
  551. backup;
  552. if (this.options.backtrack_lexer) {
  553. // save context
  554. backup = {
  555. yylineno: this.yylineno,
  556. yylloc: {
  557. first_line: this.yylloc.first_line,
  558. last_line: this.last_line,
  559. first_column: this.yylloc.first_column,
  560. last_column: this.yylloc.last_column
  561. },
  562. yytext: this.yytext,
  563. match: this.match,
  564. matches: this.matches,
  565. matched: this.matched,
  566. yyleng: this.yyleng,
  567. offset: this.offset,
  568. _more: this._more,
  569. _input: this._input,
  570. yy: this.yy,
  571. conditionStack: this.conditionStack.slice(0),
  572. done: this.done
  573. };
  574. if (this.options.ranges) {
  575. backup.yylloc.range = this.yylloc.range.slice(0);
  576. }
  577. }
  578. lines = match[0].match(/(?:\r\n?|\n).*/g);
  579. if (lines) {
  580. this.yylineno += lines.length;
  581. }
  582. this.yylloc = {
  583. first_line: this.yylloc.last_line,
  584. last_line: this.yylineno + 1,
  585. first_column: this.yylloc.last_column,
  586. last_column: lines ?
  587. lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
  588. this.yylloc.last_column + match[0].length
  589. };
  590. this.yytext += match[0];
  591. this.match += match[0];
  592. this.matches = match;
  593. this.yyleng = this.yytext.length;
  594. if (this.options.ranges) {
  595. this.yylloc.range = [this.offset, this.offset += this.yyleng];
  596. }
  597. this._more = false;
  598. this._backtrack = false;
  599. this._input = this._input.slice(match[0].length);
  600. this.matched += match[0];
  601. token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
  602. if (this.done && this._input) {
  603. this.done = false;
  604. }
  605. if (token) {
  606. return token;
  607. } else if (this._backtrack) {
  608. // recover context
  609. for (var k in backup) {
  610. this[k] = backup[k];
  611. }
  612. return false; // rule action called reject() implying the next rule should be tested instead.
  613. }
  614. return false;
  615. },
  616. // return next match in input
  617. next:function () {
  618. if (this.done) {
  619. return this.EOF;
  620. }
  621. if (!this._input) {
  622. this.done = true;
  623. }
  624. var token,
  625. match,
  626. tempMatch,
  627. index;
  628. if (!this._more) {
  629. this.yytext = '';
  630. this.match = '';
  631. }
  632. var rules = this._currentRules();
  633. for (var i = 0; i < rules.length; i++) {
  634. tempMatch = this._input.match(this.rules[rules[i]]);
  635. if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
  636. match = tempMatch;
  637. index = i;
  638. if (this.options.backtrack_lexer) {
  639. token = this.test_match(tempMatch, rules[i]);
  640. if (token !== false) {
  641. return token;
  642. } else if (this._backtrack) {
  643. match = false;
  644. continue; // rule action called reject() implying a rule MISmatch.
  645. } else {
  646. // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
  647. return false;
  648. }
  649. } else if (!this.options.flex) {
  650. break;
  651. }
  652. }
  653. }
  654. if (match) {
  655. token = this.test_match(match, rules[index]);
  656. if (token !== false) {
  657. return token;
  658. }
  659. // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
  660. return false;
  661. }
  662. if (this._input === "") {
  663. return this.EOF;
  664. } else {
  665. return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
  666. text: "",
  667. token: null,
  668. line: this.yylineno
  669. });
  670. }
  671. },
  672. // return next match that has a token
  673. lex:function lex() {
  674. var r = this.next();
  675. if (r) {
  676. return r;
  677. } else {
  678. return this.lex();
  679. }
  680. },
  681. // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
  682. begin:function begin(condition) {
  683. this.conditionStack.push(condition);
  684. },
  685. // pop the previously active lexer condition state off the condition stack
  686. popState:function popState() {
  687. var n = this.conditionStack.length - 1;
  688. if (n > 0) {
  689. return this.conditionStack.pop();
  690. } else {
  691. return this.conditionStack[0];
  692. }
  693. },
  694. // produce the lexer rule set which is active for the currently active lexer condition state
  695. _currentRules:function _currentRules() {
  696. if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
  697. return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
  698. } else {
  699. return this.conditions["INITIAL"].rules;
  700. }
  701. },
  702. // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
  703. topState:function topState(n) {
  704. n = this.conditionStack.length - 1 - Math.abs(n || 0);
  705. if (n >= 0) {
  706. return this.conditionStack[n];
  707. } else {
  708. return "INITIAL";
  709. }
  710. },
  711. // alias for begin(condition)
  712. pushState:function pushState(condition) {
  713. this.begin(condition);
  714. },
  715. // return the number of states currently on the stack
  716. stateStackSize:function stateStackSize() {
  717. return this.conditionStack.length;
  718. },
  719. options: {},
  720. performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
  721. var YYSTATE=YY_START;
  722. switch($avoiding_name_collisions) {
  723. case 0:/* skip whitespace */
  724. break;
  725. case 1:return 10;
  726. break;
  727. case 2:return 10;
  728. break;
  729. case 3:return 23;
  730. break;
  731. case 4:return 7;
  732. break;
  733. case 5:return 8;
  734. break;
  735. case 6:return 26;
  736. break;
  737. case 7:return 26;
  738. break;
  739. case 8:return 26;
  740. break;
  741. case 9:return 28;
  742. break;
  743. case 10:return 23;
  744. break;
  745. case 11:return 32;
  746. break;
  747. case 12:return 32;
  748. break;
  749. case 13:return 34;
  750. break;
  751. case 14:return 29;
  752. break;
  753. case 15:/* skip whitespace */
  754. break;
  755. case 16:return 11;
  756. break;
  757. case 17:return ' ';
  758. break;
  759. case 18:return 33;
  760. break;
  761. case 19:return 27;
  762. break;
  763. case 20:return 30;
  764. break;
  765. case 21:return 31;
  766. break;
  767. case 22:return 20;
  768. break;
  769. case 23:return 21;
  770. break;
  771. case 24:return 19;
  772. break;
  773. case 25:return 13;
  774. break;
  775. case 26:return 22;
  776. break;
  777. case 27:return 14;
  778. break;
  779. case 28:return 15;
  780. break;
  781. case 29:return 17;
  782. break;
  783. case 30:return 16;
  784. break;
  785. case 31:return 18;
  786. break;
  787. case 32:return '"';
  788. break;
  789. case 33:return "'";
  790. break;
  791. case 34:return "!";
  792. break;
  793. case 35:return 12;
  794. break;
  795. case 36:return 35;
  796. break;
  797. case 37:return 36;
  798. break;
  799. case 38:return 5;
  800. break;
  801. }
  802. },
  803. rules: [/^(?:\s+)/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:[A-Za-z]{1,}[A-Za-z_0-9]+(?=[(]))/,/^(?:([0]?[1-9]|1[0-2])[:][0-5][0-9]([:][0-5][0-9])?[ ]?(AM|am|aM|Am|PM|pm|pM|Pm))/,/^(?:([0]?[0-9]|1[0-9]|2[0-3])[:][0-5][0-9]([:][0-5][0-9])?)/,/^(?:\$[A-Za-z]+\$[0-9]+)/,/^(?:\$[A-Za-z]+[0-9]+)/,/^(?:[A-Za-z]+\$[0-9]+)/,/^(?:[A-Za-z]+[0-9]+)/,/^(?:[A-Za-z]+(?=[(]))/,/^(?:[A-Za-z]{1,}[A-Za-z_0-9]+)/,/^(?:[A-Za-z_]+)/,/^(?:[0-9]+)/,/^(?:\[(.*)?\])/,/^(?:\$)/,/^(?:&)/,/^(?: )/,/^(?:[.])/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:\*)/,/^(?:\/)/,/^(?:-)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\))/,/^(?:>)/,/^(?:<)/,/^(?:NOT\b)/,/^(?:")/,/^(?:')/,/^(?:!)/,/^(?:=)/,/^(?:%)/,/^(?:[#])/,/^(?:$)/],
  804. conditions: {"INITIAL":{"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,35,36,37,38],"inclusive":true}}
  805. });
  806. return lexer;
  807. })();
  808. parser.lexer = lexer;
  809. function Parser () {
  810. this.yy = {};
  811. }
  812. Parser.prototype = parser;parser.Parser = Parser;
  813. return new Parser;
  814. })();