peg-0.7.0.min.js 45 KB

123456789
  1. /*
  2. * PEG.js 0.7.0
  3. *
  4. * http://pegjs.majda.cz/
  5. *
  6. * Copyright (c) 2010-2012 David Majda
  7. * Licensend under the MIT license.
  8. */var PEG=function(undefined){function range(a,b){b===undefined&&(b=a,a=0);var c=new Array(Math.max(0,b-a));for(var d=0,e=a;e<b;d++,e++)c[d]=e;return c}function find(a,b){var c=a.length;for(var d=0;d<c;d++)if(b(a[d]))return a[d]}function contains(a,b){var c=a.length;for(var d=0;d<c;d++)if(a[d]===b)return!0;return!1}function each(a,b){var c=a.length;for(var d=0;d<c;d++)b(a[d],d)}function map(a,b){var c=[],d=a.length;for(var e=0;e<d;e++)c[e]=b(a[e],e);return c}function pluck(a,b){return map(a,function(a){return a[b]})}function keys(a){var b=[];for(var c in a)b.push(c);return b}function values(a){var b=[];for(var c in a)b.push(a[c]);return b}function padLeft(a,b,c){var d=a,e=c-a.length;for(var f=0;f<e;f++)d=b+d;return d}function escape(a){var b=a.charCodeAt(0),c,d;return b<=255?(c="x",d=2):(c="u",d=4),"\\"+c+padLeft(b.toString(16).toUpperCase(),"0",d)}function quote(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}function quoteForRegexpClass(a){return a.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\]/g,"\\]").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\v/g,"\\x0B").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x01-\x08\x0E-\x1F\x80-\uFFFF]/g,escape)}function buildNodeVisitor(a){return function(b){return a[b.type].apply(null,arguments)}}function findRuleByName(a,b){return find(a.rules,function(a){return a.name===b})}var PEG={VERSION:"0.7.0",buildParser:function(a,b){return PEG.compiler.compile(PEG.parser.parse(a),b)}};return PEG.GrammarError=function(a){this.name="PEG.GrammarError",this.message=a},PEG.GrammarError.prototype=Error.prototype,PEG.parser=function(){function a(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var b={parse:function(b,c){function i(a,b,c){var d=a,e=c-a.length;for(var f=0;f<e;f++)d=b+d;return d}function j(a){var b=a.charCodeAt(0),c,d;return b<=255?(c="x",d=2):(c="u",d=4),"\\"+c+i(b.toString(16).toUpperCase(),"0",d)}function k(a){if(e<g)return;e>g&&(g=e,h=[]),h.push(a)}function l(){var a,b,c,d,f,g;f=e,g=e,a=bg();if(a!==null){b=m(),b=b!==null?b:"";if(b!==null){d=n();if(d!==null){c=[];while(d!==null)c.push(d),d=n()}else c=null;c!==null?a=[a,b,c]:(a=null,e=g)}else a=null,e=g}else a=null,e=g;return a!==null&&(a=function(a,b,c){return{type:"grammar",initializer:b!==""?b:null,rules:c,startRule:c[0].name}}(f,a[1],a[2])),a===null&&(e=f),a}function m(){var a,b,c,d;return c=e,d=e,a=u(),a!==null?(b=A(),b=b!==null?b:"",b!==null?a=[a,b]:(a=null,e=d)):(a=null,e=d),a!==null&&(a=function(a,b){return{type:"initializer",code:b}}(c,a[0])),a===null&&(e=c),a}function n(){var a,b,c,d,f,g,h;return g=e,h=e,a=K(),a!==null?(b=M(),b=b!==null?b:"",b!==null?(c=y(),c!==null?(d=o(),d!==null?(f=A(),f=f!==null?f:"",f!==null?a=[a,b,c,d,f]:(a=null,e=h)):(a=null,e=h)):(a=null,e=h)):(a=null,e=h)):(a=null,e=h),a!==null&&(a=function(a,b,c,d){return{type:"rule",name:b,displayName:c!==""?c:null,expression:d}}(g,a[0],a[1],a[3])),a===null&&(e=g),a}function o(){var a,b,c,d,f,g,h;f=e,g=e,a=p();if(a!==null){b=[],h=e,c=B(),c!==null?(d=p(),d!==null?c=[c,d]:(c=null,e=h)):(c=null,e=h);while(c!==null)b.push(c),h=e,c=B(),c!==null?(d=p(),d!==null?c=[c,d]:(c=null,e=h)):(c=null,e=h);b!==null?a=[a,b]:(a=null,e=g)}else a=null,e=g;return a!==null&&(a=function(a,b,c){if(c.length>0){var d=[b].concat(map(c,function(a){return a[1]}));return{type:"choice",alternatives:d}}return b}(f,a[0],a[1])),a===null&&(e=f),a}function p(){var a,b,c,d;c=e,d=e,a=[],b=q();while(b!==null)a.push(b),b=q();a!==null?(b=u(),b!==null?a=[a,b]:(a=null,e=d)):(a=null,e=d),a!==null&&(a=function(a,b,c){var d=b.length!==1?{type:"sequence",elements:b}:b[0];return{type:"action",expression:d,code:c}}(c,a[0],a[1])),a===null&&(e=c);if(a===null){c=e,a=[],b=q();while(b!==null)a.push(b),b=q();a!==null&&(a=function(a,b){return b.length!==1?{type:"sequence",elements:b}:b[0]}(c,a)),a===null&&(e=c)}return a}function q(){var a,b,c,d,f;return d=e,f=e,a=K(),a!==null?(b=z(),b!==null?(c=r(),c!==null?a=[a,b,c]:(a=null,e=f)):(a=null,e=f)):(a=null,e=f),a!==null&&(a=function(a,b,c){return{type:"labeled",label:b,expression:c}}(d,a[0],a[2])),a===null&&(e=d),a===null&&(a=r()),a}function r(){var a,b,c,d;return c=e,d=e,a=C(),a!==null?(b=u(),b!==null?a=[a,b]:(a=null,e=d)):(a=null,e=d),a!==null&&(a=function(a,b){return{type:"semantic_and",code:b}}(c,a[1])),a===null&&(e=c),a===null&&(c=e,d=e,a=C(),a!==null?(b=s(),b!==null?a=[a,b]:(a=null,e=d)):(a=null,e=d),a!==null&&(a=function(a,b){return{type:"simple_and",expression:b}}(c,a[1])),a===null&&(e=c),a===null&&(c=e,d=e,a=D(),a!==null?(b=u(),b!==null?a=[a,b]:(a=null,e=d)):(a=null,e=d),a!==null&&(a=function(a,b){return{type:"semantic_not",code:b}}(c,a[1])),a===null&&(e=c),a===null&&(c=e,d=e,a=D(),a!==null?(b=s(),b!==null?a=[a,b]:(a=null,e=d)):(a=null,e=d),a!==null&&(a=function(a,b){return{type:"simple_not",expression:b}}(c,a[1])),a===null&&(e=c),a===null&&(a=s())))),a}function s(){var a,b,c,d;return c=e,d=e,a=t(),a!==null?(b=E(),b!==null?a=[a,b]:(a=null,e=d)):(a=null,e=d),a!==null&&(a=function(a,b){return{type:"optional",expression:b}}(c,a[0])),a===null&&(e=c),a===null&&(c=e,d=e,a=t(),a!==null?(b=F(),b!==null?a=[a,b]:(a=null,e=d)):(a=null,e=d),a!==null&&(a=function(a,b){return{type:"zero_or_more",expression:b}}(c,a[0])),a===null&&(e=c),a===null&&(c=e,d=e,a=t(),a!==null?(b=G(),b!==null?a=[a,b]:(a=null,e=d)):(a=null,e=d),a!==null&&(a=function(a,b){return{type:"one_or_more",expression:b}}(c,a[0])),a===null&&(e=c),a===null&&(a=t()))),a}function t(){var a,b,c,d,g,h,i;return d=e,g=e,a=K(),a!==null?(h=e,f++,i=e,b=M(),b=b!==null?b:"",b!==null?(c=y(),c!==null?b=[b,c]:(b=null,e=i)):(b=null,e=i),f--,b===null?b="":(b=null,e=h),b!==null?a=[a,b]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a,b){return{type:"rule_ref",name:b}}(d,a[0])),a===null&&(e=d),a===null&&(a=L(),a===null&&(d=e,a=J(),a!==null&&(a=function(a){return{type:"any"}}(d)),a===null&&(e=d),a===null&&(a=T(),a===null&&(d=e,g=e,a=H(),a!==null?(b=o(),b!==null?(c=I(),c!==null?a=[a,b,c]:(a=null,e=g)):(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a,b){return b}(d,a[1])),a===null&&(e=d))))),a}function u(){var a,b,c,d;return f++,c=e,d=e,a=v(),a!==null?(b=bg(),b!==null?a=[a,b]:(a=null,e=d)):(a=null,e=d),a!==null&&(a=function(a,b){return b.substr(1,b.length-2)}(c,a[0])),a===null&&(e=c),f--,f===0&&a===null&&k("action"),a}function v(){var a,c,d,g,h;g=e,h=e,b.charCodeAt(e)===123?(a="{",e++):(a=null,f===0&&k('"{"'));if(a!==null){c=[],d=v(),d===null&&(d=x());while(d!==null)c.push(d),d=v(),d===null&&(d=x());c!==null?(b.charCodeAt(e)===125?(d="}",e++):(d=null,f===0&&k('"}"')),d!==null?a=[a,c,d]:(a=null,e=h)):(a=null,e=h)}else a=null,e=h;return a!==null&&(a=function(a,b){return"{"+b.join("")+"}"}(g,a[1])),a===null&&(e=g),a}function w(){var a,b,c;c=e,b=x();if(b!==null){a=[];while(b!==null)a.push(b),b=x()}else a=null;return a!==null&&(a=function(a,b){return b.join("")}(c,a)),a===null&&(e=c),a}function x(){var a;return/^[^{}]/.test(b.charAt(e))?(a=b.charAt(e),e++):(a=null,f===0&&k("[^{}]")),a}function y(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===61?(a="=",e++):(a=null,f===0&&k('"="')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return"="}(d)),a===null&&(e=d),a}function z(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===58?(a=":",e++):(a=null,f===0&&k('":"')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return":"}(d)),a===null&&(e=d),a}function A(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===59?(a=";",e++):(a=null,f===0&&k('";"')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return";"}(d)),a===null&&(e=d),a}function B(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===47?(a="/",e++):(a=null,f===0&&k('"/"')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return"/"}(d)),a===null&&(e=d),a}function C(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===38?(a="&",e++):(a=null,f===0&&k('"&"')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return"&"}(d)),a===null&&(e=d),a}function D(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===33?(a="!",e++):(a=null,f===0&&k('"!"')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return"!"}(d)),a===null&&(e=d),a}function E(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===63?(a="?",e++):(a=null,f===0&&k('"?"')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return"?"}(d)),a===null&&(e=d),a}function F(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===42?(a="*",e++):(a=null,f===0&&k('"*"')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return"*"}(d)),a===null&&(e=d),a}function G(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===43?(a="+",e++):(a=null,f===0&&k('"+"')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return"+"}(d)),a===null&&(e=d),a}function H(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===40?(a="(",e++):(a=null,f===0&&k('"("')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return"("}(d)),a===null&&(e=d),a}function I(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===41?(a=")",e++):(a=null,f===0&&k('")"')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return")"}(d)),a===null&&(e=d),a}function J(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===46?(a=".",e++):(a=null,f===0&&k('"."')),a!==null?(c=bg(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return"."}(d)),a===null&&(e=d),a}function K(){var a,c,d,g,h;f++,g=e,h=e,a=bd(),a===null&&(b.charCodeAt(e)===95?(a="_",e++):(a=null,f===0&&k('"_"')),a===null&&(b.charCodeAt(e)===36?(a="$",e++):(a=null,f===0&&k('"$"'))));if(a!==null){c=[],d=bd(),d===null&&(d=bb(),d===null&&(b.charCodeAt(e)===95?(d="_",e++):(d=null,f===0&&k('"_"')),d===null&&(b.charCodeAt(e)===36?(d="$",e++):(d=null,f===0&&k('"$"')))));while(d!==null)c.push(d),d=bd(),d===null&&(d=bb(),d===null&&(b.charCodeAt(e)===95?(d="_",e++):(d=null,f===0&&k('"_"')),d===null&&(b.charCodeAt(e)===36?(d="$",e++):(d=null,f===0&&k('"$"')))));c!==null?(d=bg(),d!==null?a=[a,c,d]:(a=null,e=h)):(a=null,e=h)}else a=null,e=h;return a!==null&&(a=function(a,b,c){return b+c.join("")}(g,a[0],a[1])),a===null&&(e=g),f--,f===0&&a===null&&k("identifier"),a}function L(){var a,c,d,g,h;return f++,g=e,h=e,a=N(),a===null&&(a=Q()),a!==null?(b.charCodeAt(e)===105?(c="i",e++):(c=null,f===0&&k('"i"')),c=c!==null?c:"",c!==null?(d=bg(),d!==null?a=[a,c,d]:(a=null,e=h)):(a=null,e=h)):(a=null,e=h),a!==null&&(a=function(a,b,c){return{type:"literal",value:b,ignoreCase:c==="i"}}(g,a[0],a[1])),a===null&&(e=g),f--,f===0&&a===null&&k("literal"),a}function M(){var a,b,c,d;return f++,c=e,d=e,a=N(),a===null&&(a=Q()),a!==null?(b=bg(),b!==null?a=[a,b]:(a=null,e=d)):(a=null,e=d),a!==null&&(a=function(a,b){return b}(c,a[0])),a===null&&(e=c),f--,f===0&&a===null&&k("string"),a}function N(){var a,c,d,g,h;g=e,h=e,b.charCodeAt(e)===34?(a='"',e++):(a=null,f===0&&k('"\\""'));if(a!==null){c=[],d=O();while(d!==null)c.push(d),d=O();c!==null?(b.charCodeAt(e)===34?(d='"',e++):(d=null,f===0&&k('"\\""')),d!==null?a=[a,c,d]:(a=null,e=h)):(a=null,e=h)}else a=null,e=h;return a!==null&&(a=function(a,b){return b.join("")}(g,a[1])),a===null&&(e=g),a}function O(){var a;return a=P(),a===null&&(a=Y(),a===null&&(a=Z(),a===null&&(a=$(),a===null&&(a=_(),a===null&&(a=ba()))))),a}function P(){var a,c,d,g,h;return d=e,g=e,h=e,f++,b.charCodeAt(e)===34?(a='"',e++):(a=null,f===0&&k('"\\""')),a===null&&(b.charCodeAt(e)===92?(a="\\",e++):(a=null,f===0&&k('"\\\\"')),a===null&&(a=bl())),f--,a===null?a="":(a=null,e=h),a!==null?(b.length>e?(c=b.charAt(e),e++):(c=null,f===0&&k("any character")),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a,b){return b}(d,a[1])),a===null&&(e=d),a}function Q(){var a,c,d,g,h;g=e,h=e,b.charCodeAt(e)===39?(a="'",e++):(a=null,f===0&&k('"\'"'));if(a!==null){c=[],d=R();while(d!==null)c.push(d),d=R();c!==null?(b.charCodeAt(e)===39?(d="'",e++):(d=null,f===0&&k('"\'"')),d!==null?a=[a,c,d]:(a=null,e=h)):(a=null,e=h)}else a=null,e=h;return a!==null&&(a=function(a,b){return b.join("")}(g,a[1])),a===null&&(e=g),a}function R(){var a;return a=S(),a===null&&(a=Y(),a===null&&(a=Z(),a===null&&(a=$(),a===null&&(a=_(),a===null&&(a=ba()))))),a}function S(){var a,c,d,g,h;return d=e,g=e,h=e,f++,b.charCodeAt(e)===39?(a="'",e++):(a=null,f===0&&k('"\'"')),a===null&&(b.charCodeAt(e)===92?(a="\\",e++):(a=null,f===0&&k('"\\\\"')),a===null&&(a=bl())),f--,a===null?a="":(a=null,e=h),a!==null?(b.length>e?(c=b.charAt(e),e++):(c=null,f===0&&k("any character")),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a,b){return b}(d,a[1])),a===null&&(e=d),a}function T(){var a,c,d,g,h,i,j,l;f++,j=e,l=e,b.charCodeAt(e)===91?(a="[",e++):(a=null,f===0&&k('"["'));if(a!==null){b.charCodeAt(e)===94?(c="^",e++):(c=null,f===0&&k('"^"')),c=c!==null?c:"";if(c!==null){d=[],g=U(),g===null&&(g=V());while(g!==null)d.push(g),g=U(),g===null&&(g=V());d!==null?(b.charCodeAt(e)===93?(g="]",e++):(g=null,f===0&&k('"]"')),g!==null?(b.charCodeAt(e)===105?(h="i",e++):(h=null,f===0&&k('"i"')),h=h!==null?h:"",h!==null?(i=bg(),i!==null?a=[a,c,d,g,h,i]:(a=null,e=l)):(a=null,e=l)):(a=null,e=l)):(a=null,e=l)}else a=null,e=l}else a=null,e=l;return a!==null&&(a=function(a,b,c,d){var e=map(c,function(a){return a.data}),f="["+b+map(c,function(a){return a.rawText}).join("")+"]"+d;return{type:"class",inverted:b==="^",ignoreCase:d==="i",parts:e,rawText:f}}(j,a[1],a[2],a[4])),a===null&&(e=j),f--,f===0&&a===null&&k("character class"),a}function U(){var a,c,d,g,h;return g=e,h=e,a=V(),a!==null?(b.charCodeAt(e)===45?(c="-",e++):(c=null,f===0&&k('"-"')),c!==null?(d=V(),d!==null?a=[a,c,d]:(a=null,e=h)):(a=null,e=h)):(a=null,e=h),a!==null&&(a=function(a,b,c){if(b.data.charCodeAt(0)>c.data.charCodeAt(0))throw new this.SyntaxError("Invalid character range: "+b.rawText+"-"+c.rawText+".");return{data:[b.data,c.data],rawText:b.rawText+"-"+c.rawText}}(g,a[0],a[2])),a===null&&(e=g),a}function V(){var a,b;return b=e,a=W(),a!==null&&(a=function(a,b){return{data:b,rawText:quoteForRegexpClass(b)}}(b,a)),a===null&&(e=b),a}function W(){var a;return a=X(),a===null&&(a=Y(),a===null&&(a=Z(),a===null&&(a=$(),a===null&&(a=_(),a===null&&(a=ba()))))),a}function X(){var a,c,d,g,h;return d=e,g=e,h=e,f++,b.charCodeAt(e)===93?(a="]",e++):(a=null,f===0&&k('"]"')),a===null&&(b.charCodeAt(e)===92?(a="\\",e++):(a=null,f===0&&k('"\\\\"')),a===null&&(a=bl())),f--,a===null?a="":(a=null,e=h),a!==null?(b.length>e?(c=b.charAt(e),e++):(c=null,f===0&&k("any character")),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a,b){return b}(d,a[1])),a===null&&(e=d),a}function Y(){var a,c,d,g,h,i;return g=e,h=e,b.charCodeAt(e)===92?(a="\\",e++):(a=null,f===0&&k('"\\\\"')),a!==null?(i=e,f++,c=bb(),c===null&&(b.charCodeAt(e)===120?(c="x",e++):(c=null,f===0&&k('"x"')),c===null&&(b.charCodeAt(e)===117?(c="u",e++):(c=null,f===0&&k('"u"')),c===null&&(c=bl()))),f--,c===null?c="":(c=null,e=i),c!==null?(b.length>e?(d=b.charAt(e),e++):(d=null,f===0&&k("any character")),d!==null?a=[a,c,d]:(a=null,e=h)):(a=null,e=h)):(a=null,e=h),a!==null&&(a=function(a,b){return b.replace("b","\b").replace("f","\f").replace("n","\n").replace("r","\r").replace("t","\t").replace("v"," ")}(g,a[2])),a===null&&(e=g),a}function Z(){var a,c,d,g,h;return d=e,g=e,b.substr(e,2)==="\\0"?(a="\\0",e+=2):(a=null,f===0&&k('"\\\\0"')),a!==null?(h=e,f++,c=bb(),f--,c===null?c="":(c=null,e=h),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a){return"\0"}(d)),a===null&&(e=d),a}function $(){var a,c,d,g,h;return g=e,h=e,b.substr(e,2)==="\\x"?(a="\\x",e+=2):(a=null,f===0&&k('"\\\\x"')),a!==null?(c=bc(),c!==null?(d=bc(),d!==null?a=[a,c,d]:(a=null,e=h)):(a=null,e=h)):(a=null,e=h),a!==null&&(a=function(a,b,c){return String.fromCharCode(parseInt(b+c,16))}(g,a[1],a[2])),a===null&&(e=g),a}function _(){var a,c,d,g,h,i,j;return i=e,j=e,b.substr(e,2)==="\\u"?(a="\\u",e+=2):(a=null,f===0&&k('"\\\\u"')),a!==null?(c=bc(),c!==null?(d=bc(),d!==null?(g=bc(),g!==null?(h=bc(),h!==null?a=[a,c,d,g,h]:(a=null,e=j)):(a=null,e=j)):(a=null,e=j)):(a=null,e=j)):(a=null,e=j),a!==null&&(a=function(a,b,c,d,e){return String.fromCharCode(parseInt(b+c+d+e,16))}(i,a[1],a[2],a[3],a[4])),a===null&&(e=i),a}function ba(){var a,c,d,g;return d=e,g=e,b.charCodeAt(e)===92?(a="\\",e++):(a=null,f===0&&k('"\\\\"')),a!==null?(c=bk(),c!==null?a=[a,c]:(a=null,e=g)):(a=null,e=g),a!==null&&(a=function(a,b){return b}(d,a[1])),a===null&&(e=d),a}function bb(){var a;return/^[0-9]/.test(b.charAt(e))?(a=b.charAt(e),e++):(a=null,f===0&&k("[0-9]")),a}function bc(){var a;return/^[0-9a-fA-F]/.test(b.charAt(e))?(a=b.charAt(e),e++):(a=null,f===0&&k("[0-9a-fA-F]")),a}function bd(){var a;return a=be(),a===null&&(a=bf()),a}function be(){var a;return/^[a-z]/.test(b.charAt(e))?(a=b.charAt(e),e++):(a=null,f===0&&k("[a-z]")),a}function bf(){var a;return/^[A-Z]/.test(b.charAt(e))?(a=b.charAt(e),e++):(a=null,f===0&&k("[A-Z]")),a}function bg(){var a,b;a=[],b=bm(),b===null&&(b=bk(),b===null&&(b=bh()));while(b!==null)a.push(b),b=bm(),b===null&&(b=bk(),b===null&&(b=bh()));return a}function bh(){var a;return f++,a=bi(),a===null&&(a=bj()),f--,f===0&&a===null&&k("comment"),a}function bi(){var a,c,d,g,h,i,j;h=e,b.substr(e,2)==="//"?(a="//",e+=2):(a=null,f===0&&k('"//"'));if(a!==null){c=[],i=e,j=e,f++,d=bl(),f--,d===null?d="":(d=null,e=j),d!==null?(b.length>e?(g=b.charAt(e),e++):(g=null,f===0&&k("any character")),g!==null?d=[d,g]:(d=null,e=i)):(d=null,e=i);while(d!==null)c.push(d),i=e,j=e,f++,d=bl(),f--,d===null?d="":(d=null,e=j),d!==null?(b.length>e?(g=b.charAt(e),e++):(g=null,f===0&&k("any character")),g!==null?d=[d,g]:(d=null,e=i)):(d=null,e=i);c!==null?a=[a,c]:(a=null,e=h)}else a=null,e=h;return a}function bj(){var a,c,d,g,h,i,j;h=e,b.substr(e,2)==="/*"?(a="/*",e+=2):(a=null,f===0&&k('"/*"'));if(a!==null){c=[],i=e,j=e,f++,b.substr(e,2)==="*/"?(d="*/",e+=2):(d=null,f===0&&k('"*/"')),f--,d===null?d="":(d=null,e=j),d!==null?(b.length>e?(g=b.charAt(e),e++):(g=null,f===0&&k("any character")),g!==null?d=[d,g]:(d=null,e=i)):(d=null,e=i);while(d!==null)c.push(d),i=e,j=e,f++,b.substr(e,2)==="*/"?(d="*/",e+=2):(d=null,f===0&&k('"*/"')),f--,d===null?d="":(d=null,e=j),d!==null?(b.length>e?(g=b.charAt(e),e++):(g=null,f===0&&k("any character")),g!==null?d=[d,g]:(d=null,e=i)):(d=null,e=i);c!==null?(b.substr(e,2)==="*/"?(d="*/",e+=2):(d=null,f===0&&k('"*/"')),d!==null?a=[a,c,d]:(a=null,e=h)):(a=null,e=h)}else a=null,e=h;return a}function bk(){var a;return f++,b.charCodeAt(e)===10?(a="\n",e++):(a=null,f===0&&k('"\\n"')),a===null&&(b.substr(e,2)==="\r\n"?(a="\r\n",e+=2):(a=null,f===0&&k('"\\r\\n"')),a===null&&(b.charCodeAt(e)===13?(a="\r",e++):(a=null,f===0&&k('"\\r"')),a===null&&(b.charCodeAt(e)===8232?(a="\u2028",e++):(a=null,f===0&&k('"\\u2028"')),a===null&&(b.charCodeAt(e)===8233?(a="\u2029",e++):(a=null,f===0&&k('"\\u2029"')))))),f--,f===0&&a===null&&k("end of line"),a}function bl(){var a;return/^[\n\r\u2028\u2029]/.test(b.charAt(e))?(a=b.charAt(e),e++):(a=null,f===0&&k("[\\n\\r\\u2028\\u2029]")),a}function bm(){var a;return f++,/^[ \t\x0B\f\xA0\uFEFF\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]/.test(b.charAt(e))?(a=b.charAt(e),e++):(a=null,f===0&&k("[ \\t\\x0B\\f\\xA0\\uFEFF\\u1680\\u180E\\u2000-\\u200A\\u202F\\u205F\\u3000]")),f--,f===0&&a===null&&k("whitespace"),a}function bn(a){a.sort();var b=null,c=[];for(var d=0;d<a.length;d++)a[d]!==b&&(c.push(a[d]),b=a[d]);return c}function bo(){var a=1,c=1,d=!1;for(var f=0;f<Math.max(e,g);f++){var h=b.charAt(f);h==="\n"?(d||a++,c=1,d=!1):h==="\r"||h==="\u2028"||h==="\u2029"?(a++,c=1,d=!0):(c++,d=!1)}return{line:a,column:c}}var d={grammar:l,initializer:m,rule:n,choice:o,sequence:p,labeled:q,prefixed:r,suffixed:s,primary:t,action:u,braced:v,nonBraceCharacters:w,nonBraceCharacter:x,equals:y,colon:z,semicolon:A,slash:B,and:C,not:D,question:E,star:F,plus:G,lparen:H,rparen:I,dot:J,identifier:K,literal:L,string:M,doubleQuotedString:N,doubleQuotedCharacter:O,simpleDoubleQuotedCharacter:P,singleQuotedString:Q,singleQuotedCharacter:R,simpleSingleQuotedCharacter:S,"class":T,classCharacterRange:U,classCharacter:V,bracketDelimitedCharacter:W,simpleBracketDelimitedCharacter:X,simpleEscapeSequence:Y,zeroEscapeSequence:Z,hexEscapeSequence:$,unicodeEscapeSequence:_,eolEscapeSequence:ba,digit:bb,hexDigit:bc,letter:bd,lowerCaseLetter:be,upperCaseLetter:bf,__:bg,comment:bh,singleLineComment:bi,multiLineComment:bj,eol:bk,eolChar:bl,whitespace:bm};if(c!==undefined){if(d[c]===undefined)throw new Error("Invalid rule name: "+a(c)+".")}else c="grammar";var e=0,f=0,g=0,h=[],bp=d[c]();if(bp===null||e!==b.length){var bq=Math.max(e,g),br=bq<b.length?b.charAt(bq):null,bs=bo();throw new this.SyntaxError(bn(h),br,bq,bs.line,bs.column)}return bp},toSource:function(){return this._source}};return b.SyntaxError=function(b,c,d,e,f){function g(b,c){var d,e;switch(b.length){case 0:d="end of input";break;case 1:d=b[0];break;default:d=b.slice(0,b.length-1).join(", ")+" or "+b[b.length-1]}return e=c?a(c):"end of input","Expected "+d+" but "+e+" found."}this.name="SyntaxError",this.expected=b,this.found=c,this.message=g(b,c),this.offset=d,this.line=e,this.column=f},b.SyntaxError.prototype=Error.prototype,b}(),PEG.compiler={appliedPassNames:["reportMissingRules","reportLeftRecursion","removeProxyRules","computeVarNames","computeParams"],compile:function(ast,options){var that=this;each(this.appliedPassNames,function(a){that.passes[a](ast)});var source=this.emitter(ast,options),result=eval(source);return result._source=source,result}},PEG.compiler.passes={reportMissingRules:function(a){function b(){}function c(a){e(a.expression)}function d(a){return function(b){each(b[a],e)}}var e=buildNodeVisitor({grammar:d("rules"),rule:c,choice:d("alternatives"),sequence:d("elements"),labeled:c,simple_and:c,simple_not:c,semantic_and:b,semantic_not:b,optional:c,zero_or_more:c,one_or_more:c,action:c,rule_ref:function(b){if(!findRuleByName(a,b.name))throw new PEG.GrammarError('Referenced rule "'+b.name+'" does not exist.')},literal:b,any:b,"class":b});e(a)},reportLeftRecursion:function(a){function b(){}function c(a,b){e(a.expression,b)}function d(a){return function(b,c){each(b[a],function(a){e(a,c)})}}var e=buildNodeVisitor({grammar:d("rules"),rule:function(a,b){e(a.expression,b.concat(a.name))},choice:d("alternatives"),sequence:function(a,b){a.elements.length>0&&e(a.elements[0],b)},labeled:c,simple_and:c,simple_not:c,semantic_and:b,semantic_not:b,optional:c,zero_or_more:c,one_or_more:c,action:c,rule_ref:function(b,c){if(contains(c,b.name))throw new PEG.GrammarError('Left recursion detected for rule "'+b.name+'".');e(findRuleByName(a,b.name),c)},literal:b,any:b,"class":b});e(a,[])},removeProxyRules:function(a){function b(a){return a.type==="rule"&&a.expression.type==="rule_ref"}function c(a,b,c){function d(){}function e(a,b,c){g(a.expression,b,c)}function f(a){return function(b,c,d){each(b[a],function(a){g(a,c,d)})}}var g=buildNodeVisitor({grammar:f("rules"),rule:e,choice:f("alternatives"),sequence:f("elements"),labeled:e,simple_and:e,simple_not:e,semantic_and:d,semantic_not:d,optional:e,zero_or_more:e,one_or_more:e,action:e,rule_ref:function(a,b,c){a.name===b&&(a.name=c)},literal:d,any:d,"class":d});g(a,b,c)}var d=[];each(a.rules,function(e,f){b(e)&&(c(a,e.name,e.expression.name),e.name===a.startRule&&(a.startRule=e.expression.name),d.push(f))}),d.reverse(),each(d,function(b){a.rules.splice(b,1)})},computeVarNames:function(a){function b(a){return"result"+a}function c(a){return"pos"+a}function d(a,c){return a.resultVar=b(c.result),{result:0,pos:0}}function e(a){return function(d,e){var g=f(d.expression,{result:e.result+a.result,pos:e.pos+a.pos});return d.resultVar=b(e.result),a.pos!==0&&(d.posVar=c(e.pos)),{result:g.result+a.result,pos:g.pos+a.pos}}}var f=buildNodeVisitor({grammar:function(a,b){each(a.rules,function(a){f(a,b)})},rule:function(a,d){var e=f(a.expression,d);a.resultVar=b(d.result),a.resultVars=map(range(e.result+1),b),a.posVars=map(range(e.pos),c)},choice:function(a,c){var d=map(a.alternatives,function(a){return f(a,c)});return a.resultVar=b(c.result),{result:Math.max.apply(null,pluck(d,"result")),pos:Math.max.apply(null,pluck(d,"pos"))}},sequence:function(a,d){var e=map(a.elements,function(a,b){return f(a,{result:d.result+b,pos:d.pos+1})});return a.resultVar=b(d.result),a.posVar=c(d.pos),{result:a.elements.length>0?Math.max.apply(null,map(e,function(a,b){return b+a.result})):0,pos:a.elements.length>0?1+Math.max.apply(null,pluck(e,"pos")):1}},labeled:e({result:0,pos:0}),simple_and:e({result:0,pos:1}),simple_not:e({result:0,pos:1}),semantic_and:d,semantic_not:d,optional:e({result:0,pos:0}),zero_or_more:e({result:1,pos:0}),one_or_more:e({result:1,pos:0}),action:e({result:0,pos:1}),rule_ref:d,literal:d,any:d,"class":d});f(a,{result:0,pos:0})},computeParams:function(a){function c(a){b.push({}),a(),b.pop()}function d(){}function e(a){c(function(){g(a.expression)})}function f(a){var c=b[b.length-1],d={},e;for(e in c)d[e]=c[e];a.params=d}var b=[],g=buildNodeVisitor({grammar:function(a){each(a.rules,g)},rule:e,choice:function(a){c(function(){each(a.alternatives,g)})},sequence:function(a){function e(b){each(pluck(a.elements,"resultVar"),function(d,e){(new RegExp("^"+d+"(\\[\\d+\\])*$")).test(c[b])&&(c[b]=a.resultVar+"["+e+"]"+c[b].substr(d.length))})}var c=b[b.length-1],d;each(a.elements,g);for(d in c)e(d)},labeled:function(a){b[b.length-1][a.label]=a.resultVar,c(function(){g(a.expression)})},simple_and:e,simple_not:e,semantic_and:f,semantic_not:f,optional:e,zero_or_more:e,one_or_more:e,action:function(a){c(function(){g(a.expression),f(a)})},rule_ref:d,literal:d,any:d,"class":d});g(a)}},PEG.compiler.emitter=function(a,b){function e(a,c){return c.string=quote,c.pluck=pluck,c.keys=keys,c.values=values,c.emit=g,c.options=b,b.trackLineAndColumn?(c.posInit=function(a){return"var "+a+" = "+"{ offset: 0, line: 1, column: 1, seenCR: false }"},c.posClone=function(a){return"clone("+a+")"},c.posOffset=function(a){return a+".offset"},c.posAdvance=function(a){return"advance(pos, "+a+")"}):(c.posInit=function(a){return"var "+a+" = 0"},c.posClone=function(a){return a},c.posOffset=function(a){return a},c.posAdvance=function(a){return a===1?"pos++":"pos += "+a}),c.posSave=function(a){return a.posVar+" = "+c.posClone("pos")},c.posRestore=function(a){return"pos = "+c.posClone(a.posVar)},d[a](c)}function f(a){return function(b){return e(a,{node:b})}}b=b||{},b.cache===undefined&&(b.cache=!1),b.trackLineAndColumn===undefined&&(b.trackLineAndColumn=!1);var c=function(a){function b(a){function b(a){return a.charCodeAt(0).toString(16).toUpperCase()}return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(a){return"\\x0"+b(a)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(a){return"\\x"+b(a)}).replace(/[\u0180-\u0FFF]/g,function(a){return"\\u0"+b(a)}).replace(/[\u1080-\uFFFF]/g,function(a){return"\\u"+b(a)})}function c(a){return"__p.push("+a+");"}function d(a,d,e){function f(a,b,c){return a.replace(new RegExp("^.{"+b+"}","gm"),function(a,b){return b===0?c?"":a:""})}var g=b(f(a.substring(0,d),e.indentLevel(),e.atBOL));return g.length>0?c('"'+g+'"'):""}var e={VERSION:"1.1.0",indentStep:2,commands:{"if":{params:/^(.*)$/,compile:function(a,b,c){return["if("+c[0]+"){",[]]},stackOp:"push"},"else":{params:/^$/,compile:function(a){var b=a.commandStack,c=b[b.length-1]==="else",d=b[b.length-1]==="if";if(c)throw new Error("Multiple #elses.");if(!d)throw new Error("Using #else outside of #if.");return["}else{",[]]},stackOp:"replace"},"for":{params:/^([a-zA-Z_][a-zA-Z0-9_]*)[ \t]+in[ \t]+(.*)$/,init:function(a){a.forCurrLevel=0,a.forMaxLevel=0},compile:function(a,b,c){var d="__c"+a.forCurrLevel,e="__l"+a.forCurrLevel,f="__i"+a.forCurrLevel;return a.forCurrLevel++,a.forMaxLevel<a.forCurrLevel&&(a.forMaxLevel=a.forCurrLevel),[d+"="+c[1]+";"+e+"="+d+".length;"+"for("+f+"=0;"+f+"<"+e+";"+f+"++){"+c[0]+"="+d+"["+f+"];",[c[0],d,e,f]]},exit:function(a){a.forCurrLevel--},stackOp:"push"},end:{params:/^$/,compile:function(a){var b=a.commandStack,c;if(b.length===0)throw new Error("Too many #ends.");return c=e.commands[b[b.length-1]].exit,c&&c(a),["}",[]]},stackOp:"pop"},block:{params:/^(.*)$/,compile:function(a,d,e){var f="__x",g="__n",h="__l",i="__i";return[f+'="'+b(d.substring(a.indentLevel()))+'";'+g+"=("+e[0]+').toString().split("\\n");'+h+"="+g+".length;"+"for("+i+"=0;"+i+"<"+h+";"+i+"++){"+g+"["+i+"]="+f+"+"+g+"["+i+']+"\\n";'+"}"+c(g+'.join("")'),[f,g,h,i]]},stackOp:"nop"}},template:function(b){function g(a,b){return a.atBOL=!1,[c(b),[]]}function h(a,b,c,d){var g,h,i;g=e.commands[c];if(!g)throw new Error("Unknown command: #"+c+".");h=g.params.exec(d);if(h===null)throw new Error("Invalid params for command #"+c+": "+d+".");return i=g.compile(a,b,h.slice(1)),f[g.stackOp](a.commandStack,c),a.atBOL=!0,i}var f={push:function(a,b){a.push(b)},replace:function(a,b){a[a.length-1]=b},pop:function(a){a.pop()},nop:function(){}},i={commandStack:[],atBOL:!0,indentLevel:function(){return e.indentStep*this.commandStack.length}},j="",k=["__p=[]"],l,m,n,o;for(l in e.commands)e.commands[l].init&&e.commands[l].init(i);while((m=/^([ \t]*)#([a-zA-Z_][a-zA-Z0-9_]*)(?:[ \t]+([^ \t\n][^\n]*))?[ \t]*(?:\n|$)|#\{([^}]*)\}/m.exec(b))!==null)j+=d(b,m.index,i),n=m[2]!==a&&m[2]!==""?h(i,m[1],m[2],m[3]||""):g(i,m[4]),j+=n[0],k=k.concat(n[1]),b=b.substring(m.index+m[0].length);j+=d(b,b.length,i);if(i.commandStack.length>0)throw new Error("Missing #end.");k.sort();for(o=0;o<k.length;o++)k[o]===k[o-1]&&k.splice(o--,1);return new Function("__v",["__v=__v||{};","var "+k.join(",")+";","with(__v){",j,'return __p.join("").replace(/^\\n+|\\n+$/g,"");};'].join(""))}};return e}(),d=function(){var a,b={},d={grammar:["(function(){"," /*"," * Generated by PEG.js 0.7.0."," *"," * http://pegjs.majda.cz/"," */"," "," function quote(s) {"," /*"," * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a"," * string literal except for the closing quote character, backslash,"," * carriage return, line separator, paragraph separator, and line feed."," * Any character may appear in the form of an escape sequence."," *"," * For portability, we also escape escape all control and non-ASCII",' * characters. Note that "\\0" and "\\v" escape sequences are not used'," * because JSHint does not like the first and IE the second."," */"," return '\"' + s"," .replace(/\\\\/g, '\\\\\\\\') // backslash"," .replace(/\"/g, '\\\\\"') // closing quote character"," .replace(/\\x08/g, '\\\\b') // backspace"," .replace(/\\t/g, '\\\\t') // horizontal tab"," .replace(/\\n/g, '\\\\n') // line feed"," .replace(/\\f/g, '\\\\f') // form feed"," .replace(/\\r/g, '\\\\r') // carriage return"," .replace(/[\\x00-\\x07\\x0B\\x0E-\\x1F\\x80-\\uFFFF]/g, escape)"," + '\"';"," }"," "," var result = {"," /*"," * Parses the input with a generated parser. If the parsing is successfull,"," * returns a value explicitly or implicitly specified by the grammar from"," * which the parser was generated (see |PEG.buildParser|). If the parsing is"," * unsuccessful, throws |PEG.parser.SyntaxError| describing the error."," */"," parse: function(input, startRule) {"," var parseFunctions = {"," #for rule in node.rules",' #{string(rule.name) + ": parse_" + rule.name + (rule !== node.rules[node.rules.length - 1] ? "," : "")}'," #end"," };"," "," if (startRule !== undefined) {"," if (parseFunctions[startRule] === undefined) {",' throw new Error("Invalid rule name: " + quote(startRule) + ".");'," }"," } else {"," startRule = #{string(node.startRule)};"," }"," ",' #{posInit("pos")};'," var reportFailures = 0;",' #{posInit("rightmostFailuresPos")};'," var rightmostFailuresExpected = [];"," #if options.cache"," var cache = {};"," #end"," "," function padLeft(input, padding, length) {"," var result = input;"," "," var padLength = length - input.length;"
  9. ," for (var i = 0; i < padLength; i++) {"," result = padding + result;"," }"," "," return result;"," }"," "," function escape(ch) {"," var charCode = ch.charCodeAt(0);"," var escapeChar;"," var length;"," "," if (charCode <= 0xFF) {"," escapeChar = 'x';"," length = 2;"," } else {"," escapeChar = 'u';"," length = 4;"," }"," "," return '\\\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);"," }"," "," #if options.trackLineAndColumn"," function clone(object) {"," var result = {};"," for (var key in object) {"," result[key] = object[key];"," }"," return result;"," }"," "," function advance(pos, n) {"," var endOffset = pos.offset + n;"," "," for (var offset = pos.offset; offset < endOffset; offset++) {"," var ch = input.charAt(offset);",' if (ch === "\\n") {'," if (!pos.seenCR) { pos.line++; }"," pos.column = 1;"," pos.seenCR = false;",' } else if (ch === "\\r" || ch === "\\u2028" || ch === "\\u2029") {'," pos.line++;"," pos.column = 1;"," pos.seenCR = true;"," } else {"," pos.column++;"," pos.seenCR = false;"," }"," }"," "," pos.offset += n;"," }"," "," #end"," function matchFailed(failure) {",' if (#{posOffset("pos")} < #{posOffset("rightmostFailuresPos")}) {'," return;"," }"," ",' if (#{posOffset("pos")} > #{posOffset("rightmostFailuresPos")}) {',' rightmostFailuresPos = #{posClone("pos")};'," rightmostFailuresExpected = [];"," }"," "," rightmostFailuresExpected.push(failure);"," }"," "," #for rule in node.rules"," #block emit(rule)"," "," #end"," "," function cleanupExpected(expected) {"," expected.sort();"," "," var lastExpected = null;"," var cleanExpected = [];"," for (var i = 0; i < expected.length; i++) {"," if (expected[i] !== lastExpected) {"," cleanExpected.push(expected[i]);"," lastExpected = expected[i];"," }"," }"," return cleanExpected;"," }"," "," #if !options.trackLineAndColumn"," function computeErrorPosition() {"," /*"," * The first idea was to use |String.split| to break the input up to the"," * error position along newlines and derive the line and column from"," * there. However IE's |split| implementation is so broken that it was"," * enough to prevent it."," */"," "," var line = 1;"," var column = 1;"," var seenCR = false;"," "," for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) {"," var ch = input.charAt(i);",' if (ch === "\\n") {'," if (!seenCR) { line++; }"," column = 1;"," seenCR = false;",' } else if (ch === "\\r" || ch === "\\u2028" || ch === "\\u2029") {'," line++;"," column = 1;"," seenCR = true;"," } else {"," column++;"," seenCR = false;"," }"," }"," "," return { line: line, column: column };"," }"," #end"," "," #if node.initializer"," #block emit(node.initializer)"," #end"," "," var result = parseFunctions[startRule]();"," "," /*"," * The parser is now in one of the following three states:"," *"," * 1. The parser successfully parsed the whole input."," *"," * - |result !== null|",' * - |#{posOffset("pos")} === input.length|'," * - |rightmostFailuresExpected| may or may not contain something"," *"," * 2. The parser successfully parsed only a part of the input."," *"," * - |result !== null|",' * - |#{posOffset("pos")} < input.length|'," * - |rightmostFailuresExpected| may or may not contain something"," *"," * 3. The parser did not successfully parse any part of the input."," *"," * - |result === null|",' * - |#{posOffset("pos")} === 0|'," * - |rightmostFailuresExpected| contains at least one failure"," *"," * All code following this comment (including called functions) must"," * handle these states."," */",' if (result === null || #{posOffset("pos")} !== input.length) {',' var offset = Math.max(#{posOffset("pos")}, #{posOffset("rightmostFailuresPos")});'," var found = offset < input.length ? input.charAt(offset) : null;"," #if options.trackLineAndColumn",' var errorPosition = #{posOffset("pos")} > #{posOffset("rightmostFailuresPos")} ? pos : rightmostFailuresPos;'," #else"," var errorPosition = computeErrorPosition();"," #end"," "," throw new this.SyntaxError("," cleanupExpected(rightmostFailuresExpected),"," found,"," offset,"," errorPosition.line,"," errorPosition.column"," );"," }"," "," return result;"," },"," "," /* Returns the parser source code. */"," toSource: function() { return this._source; }"," };"," "," /* Thrown when a parser encounters a syntax error. */"," "," result.SyntaxError = function(expected, found, offset, line, column) {"," function buildMessage(expected, found) {"," var expectedHumanized, foundHumanized;"," "," switch (expected.length) {"," case 0:",' expectedHumanized = "end of input";'," break;"," case 1:"," expectedHumanized = expected[0];"," break;"," default:",' expectedHumanized = expected.slice(0, expected.length - 1).join(", ")',' + " or "'," + expected[expected.length - 1];"," }"," ",' foundHumanized = found ? quote(found) : "end of input";'," ",' return "Expected " + expectedHumanized + " but " + foundHumanized + " found.";'," }"," ",' this.name = "SyntaxError";'," this.expected = expected;"," this.found = found;"," this.message = buildMessage(expected, found);"," this.offset = offset;"," this.line = line;"," this.column = column;"," };"," "," result.SyntaxError.prototype = Error.prototype;"," "," return result;","})()"],rule:["function parse_#{node.name}() {"," #if options.cache",' var cacheKey = "#{node.name}@" + #{posOffset("pos")};'," var cachedResult = cache[cacheKey];"," if (cachedResult) {",' pos = #{posClone("cachedResult.nextPos")};'," return cachedResult.result;"," }"," "," #end"," #if node.resultVars.length > 0",' var #{node.resultVars.join(", ")};'," #end"," #if node.posVars.length > 0",' var #{node.posVars.join(", ")};'," #end"," "," #if node.displayName !== null"," reportFailures++;"," #end"," #block emit(node.expression)"," #if node.displayName !== null"," reportFailures--;"," if (reportFailures === 0 && #{node.resultVar} === null) {"," matchFailed(#{string(node.displayName)});"," }"," #end"," #if options.cache"," "," cache[cacheKey] = {",' nextPos: #{posClone("pos")},'," result: #{node.resultVar}"," };"," #end"," return #{node.resultVar};","}"],choice:["#block emit(alternative)","#block nextAlternativesCode"],"choice.next":["if (#{node.resultVar} === null) {"," #block code","}"],sequence:["#{posSave(node)};","#block code"],"sequence.iteration":["#block emit(element)","if (#{element.resultVar} !== null) {"," #block code","} else {"," #{node.resultVar} = null;"," #{posRestore(node)};","}"],"sequence.inner":['#{node.resultVar} = [#{pluck(node.elements, "resultVar").join(", ")}];'],simple_and:["#{posSave(node)};","reportFailures++;","#block emit(node.expression)","reportFailures--;","if (#{node.resultVar} !== null) {",' #{node.resultVar} = "";'," #{posRestore(node)};","} else {"," #{node.resultVar} = null;","}"],simple_not:["#{posSave(node)};","reportFailures++;","#block emit(node.expression)","reportFailures--;","if (#{node.resultVar} === null) {",' #{node.resultVar} = "";',"} else {"," #{node.resultVar} = null;"," #{posRestore(node)};","}"],semantic_and:['#{node.resultVar} = (function(#{(options.trackLineAndColumn ? ["offset", "line", "column"] : ["offset"]).concat(keys(node.params)).join(", ")}) {#{node.code}})(#{(options.trackLineAndColumn ? ["pos.offset", "pos.line", "pos.column"] : ["pos"]).concat(values(node.params)).join(", ")}) ? "" : null;'],semantic_not:['#{node.resultVar} = (function(#{(options.trackLineAndColumn ? ["offset", "line", "column"] : ["offset"]).concat(keys(node.params)).join(", ")}) {#{node.code}})(#{(options.trackLineAndColumn ? ["pos.offset", "pos.line", "pos.column"] : ["pos"]).concat(values(node.params)).join(", ")}) ? null : "";'],optional:["#block emit(node.expression)",'#{node.resultVar} = #{node.resultVar} !== null ? #{node.resultVar} : "";'],zero_or_more:["#{node.resultVar} = [];","#block emit(node.expression)","while (#{node.expression.resultVar} !== null) {"," #{node.resultVar}.push(#{node.expression.resultVar});"," #block emit(node.expression)","}"],one_or_more:["#block emit(node.expression)","if (#{node.expression.resultVar} !== null) {"," #{node.resultVar} = [];"," while (#{node.expression.resultVar} !== null) {"," #{node.resultVar}.push(#{node.expression.resultVar});"," #block emit(node.expression)"," }","} else {"," #{node.resultVar} = null;","}"],action:["#{posSave(node)};","#block emit(node.expression)","if (#{node.resultVar} !== null) {",' #{node.resultVar} = (function(#{(options.trackLineAndColumn ? ["offset", "line", "column"] : ["offset"]).concat(keys(node.params)).join(", ")}) {#{node.code}})(#{(options.trackLineAndColumn ? [node.posVar + ".offset", node.posVar + ".line", node.posVar + ".column"] : [node.posVar]).concat(values(node.params)).join(", ")});',"}","if (#{node.resultVar} === null) {"," #{posRestore(node)};","}"],rule_ref:["#{node.resultVar} = parse_#{node.name}();"],literal:["#if node.value.length === 0",' #{node.resultVar} = "";',"#else"," #if !node.ignoreCase"," #if node.value.length === 1",' if (input.charCodeAt(#{posOffset("pos")}) === #{node.value.charCodeAt(0)}) {'," #else",' if (input.substr(#{posOffset("pos")}, #{node.value.length}) === #{string(node.value)}) {'," #end"," #else",' if (input.substr(#{posOffset("pos")}, #{node.value.length}).toLowerCase() === #{string(node.value.toLowerCase())}) {'," #end"," #if !node.ignoreCase"," #{node.resultVar} = #{string(node.value)};"," #else",' #{node.resultVar} = input.substr(#{posOffset("pos")}, #{node.value.length});'," #end"," #{posAdvance(node.value.length)};"," } else {"," #{node.resultVar} = null;"," if (reportFailures === 0) {"," matchFailed(#{string(string(node.value))});"," }"," }","#end"],any:['if (input.length > #{posOffset("pos")}) {',' #{node.resultVar} = input.charAt(#{posOffset("pos")});'," #{posAdvance(1)};","} else {"," #{node.resultVar} = null;"," if (reportFailures === 0) {",' matchFailed("any character");'," }","}"],"class":['if (#{regexp}.test(input.charAt(#{posOffset("pos")}))) {',' #{node.resultVar} = input.charAt(#{posOffset("pos")});'," #{posAdvance(1)};","} else {"," #{node.resultVar} = null;"," if (reportFailures === 0) {"," matchFailed(#{string(node.rawText)});"," }","}"]};for(a in d)b[a]=c.template(d[a].join("\n"));return b}(),g=buildNodeVisitor({grammar:f("grammar"),initializer:function(a){return a.code},rule:f("rule"),choice:function(a){var b,c;for(var d=a.alternatives.length-1;d>=0;d--)c=d!==a.alternatives.length-1?e("choice.next",{node:a,code:b}):"",b=e("choice",{alternative:a.alternatives[d],nextAlternativesCode:c});return b},sequence:function(a){var b=e("sequence.inner",{node:a});for(var c=a.elements.length-1;c>=0;c--)b=e("sequence.iteration",{node:a,element:a.elements[c],code:b});return e("sequence",{node:a,code:b})},labeled:function(a){return g(a.expression)},simple_and:f("simple_and"),simple_not:f("simple_not"),semantic_and:f("semantic_and"),semantic_not:f("semantic_not"),optional:f("optional"),zero_or_more:f("zero_or_more"),one_or_more:f("one_or_more"),action:f("action"),rule_ref:f("rule_ref"),literal:f("literal"),any:f("any"),"class":function(a){var b;return a.parts.length>0?b="/^["+(a.inverted?"^":"")+map(a.parts,function(a){return a instanceof Array?quoteForRegexpClass(a[0])+"-"+quoteForRegexpClass(a[1]):quoteForRegexpClass(a)}).join("")+"]/"+(a.ignoreCase?"i":""):b=a.inverted?"/^[\\S\\s]/":"/^(?!)/",e("class",{node:a,regexp:b})}});return g(a)},PEG}();typeof module!="undefined"&&(module.exports=PEG);