From 6b46617dbd92f5efad04e5fc934a22f4393fae28 Mon Sep 17 00:00:00 2001 From: Neil Jewers Date: Sun, 13 Nov 2016 00:31:33 -0600 Subject: [PATCH] Experimental fix for #21 --- dist/ohm.min.js | 10 +++++----- src/MatchResult.js | 15 +-------------- src/errors.js | 38 ++++++++++++++++++++++++++++++++++---- src/util.js | 5 +++++ visualizer/index.js | 9 ++++++++- 5 files changed, 53 insertions(+), 24 deletions(-) diff --git a/dist/ohm.min.js b/dist/ohm.min.js index 44c0bddd..abb1296c 100644 --- a/dist/ohm.min.js +++ b/dist/ohm.min.js @@ -1,6 +1,6 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ohm=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o\n = NonemptyListOf\n | EmptyListOf\n\n NonemptyListOf\n = elem (sep elem)*\n\n EmptyListOf\n = /* nothing */\n\n listOf\n = nonemptyListOf\n | emptyListOf\n\n nonemptyListOf\n = elem (sep elem)*\n\n emptyListOf\n = /* nothing */\n\n}'},"BuiltInRules",null,null,{alnum:["define",{sourceInterval:[18,78]},"an alpha-numeric character",[],["alt",{sourceInterval:[60,78]},["app",{sourceInterval:[60,66]},"letter",[]],["app",{sourceInterval:[73,78]},"digit",[]]]],letter:["define",{sourceInterval:[82,142]},"a letter",[],["alt",{sourceInterval:[107,142]},["app",{sourceInterval:[107,112]},"lower",[]],["app",{sourceInterval:[119,124]},"upper",[]],["app",{sourceInterval:[131,142]},"unicodeLtmo",[]]]],digit:["define",{sourceInterval:[146,177]},"a digit",[],["range",{sourceInterval:[169,177]},"0","9"]],hexDigit:["define",{sourceInterval:[181,254]},"a hexadecimal digit",[],["alt",{sourceInterval:[219,254]},["app",{sourceInterval:[219,224]},"digit",[]],["range",{sourceInterval:[231,239]},"a","f"],["range",{sourceInterval:[246,254]},"A","F"]]],ListOf:["define",{sourceInterval:[258,336]},null,["elem","sep"],["alt",{sourceInterval:[282,336]},["app",{sourceInterval:[282,307]},"NonemptyListOf",[["param",{},0],["param",{},1]]],["app",{sourceInterval:[314,336]},"EmptyListOf",[["param",{},0],["param",{},1]]]]],NonemptyListOf:["define",{sourceInterval:[340,388]},null,["elem","sep"],["seq",{sourceInterval:[372,388]},["param",{},0],["star",{sourceInterval:[377,388]},["seq",{sourceInterval:[378,386]},["param",{},1],["param",{},0]]]]],EmptyListOf:["define",{sourceInterval:[392,434]},null,["elem","sep"],["seq",{sourceInterval:[438,438]}]],listOf:["define",{sourceInterval:[438,516]},null,["elem","sep"],["alt",{sourceInterval:[462,516]},["app",{sourceInterval:[462,487]},"nonemptyListOf",[["param",{},0],["param",{},1]]],["app",{sourceInterval:[494,516]},"emptyListOf",[["param",{},0],["param",{},1]]]]],nonemptyListOf:["define",{sourceInterval:[520,568]},null,["elem","sep"],["seq",{sourceInterval:[552,568]},["param",{},0],["star",{sourceInterval:[557,568]},["seq",{sourceInterval:[558,566]},["param",{},1],["param",{},0]]]]],emptyListOf:["define",{sourceInterval:[572,614]},null,["elem","sep"],["seq",{sourceInterval:[616,616]}]]}])},{"..":43}],2:[function(require,module,exports){var ohm=require("..");module.exports=ohm.makeRecipe(["grammar",{source:'Ohm {\n\n Grammars\n = Grammar*\n\n Grammar\n = ident SuperGrammar? "{" Rule* "}"\n\n SuperGrammar\n = "<:" ident\n\n Rule\n = ident Formals? ruleDescr? "=" RuleBody -- define\n | ident Formals? ":=" RuleBody -- override\n | ident Formals? "+=" RuleBody -- extend\n\n RuleBody\n = "|"? NonemptyListOf\n\n TopLevelTerm\n = Seq caseName -- inline\n | Seq\n\n Formals\n = "<" ListOf ">"\n\n Params\n = "<" ListOf ">"\n\n Alt\n = NonemptyListOf\n\n Seq\n = Iter*\n\n Iter\n = Pred "*" -- star\n | Pred "+" -- plus\n | Pred "?" -- opt\n | Pred\n\n Pred\n = "~" Lex -- not\n | "&" Lex -- lookahead\n | Lex\n\n Lex\n = "#" Base -- lex\n | Base\n\n Base\n = ident Params? ~(ruleDescr? "=" | ":=" | "+=") -- application\n | terminal ".." terminal -- range\n | terminal -- terminal\n | "(" Alt ")" -- paren\n\n ruleDescr (a rule description)\n = "(" ruleDescrText ")"\n\n ruleDescrText\n = (~")" any)*\n\n caseName\n = "--" (~"\\n" space)* name (~"\\n" space)* ("\\n" | &"}")\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = "_"\n | letter\n\n nameRest\n = "_"\n | alnum\n\n ident (an identifier)\n = name\n\n terminal\n = "\\"" terminalChar* "\\""\n\n terminalChar\n = escapeChar\n | ~"\\\\" ~"\\"" ~"\\n" any\n\n escapeChar (an escape sequence)\n = "\\\\\\\\" -- backslash\n | "\\\\\\"" -- doubleQuote\n | "\\\\\\\'" -- singleQuote\n | "\\\\b" -- backspace\n | "\\\\n" -- lineFeed\n | "\\\\r" -- carriageReturn\n | "\\\\t" -- tab\n | "\\\\u" hexDigit hexDigit hexDigit hexDigit -- unicodeEscape\n | "\\\\x" hexDigit hexDigit -- hexEscape\n\n space\n += comment\n\n comment\n = "//" (~"\\n" any)* "\\n" -- singleLine\n | "/*" (~"*/" any)* "*/" -- multiLine\n\n tokens = token*\n\n token = caseName | comment | ident | operator | punctuation | terminal | any\n\n operator = "<:" | "=" | ":=" | "+=" | "*" | "+" | "?" | "~" | "&"\n\n punctuation = "<" | ">" | "," | "--"\n}'},"Ohm",null,"Grammars",{Grammars:["define",{sourceInterval:[9,32]},null,[],["star",{sourceInterval:[24,32]},["app",{sourceInterval:[24,31]},"Grammar",[]]]],Grammar:["define",{sourceInterval:[36,83]},null,[],["seq",{sourceInterval:[50,83]},["app",{sourceInterval:[50,55]},"ident",[]],["opt",{sourceInterval:[56,69]},["app",{sourceInterval:[56,68]},"SuperGrammar",[]]],["terminal",{sourceInterval:[70,73]},"{"],["star",{sourceInterval:[74,79]},["app",{sourceInterval:[74,78]},"Rule",[]]],["terminal",{sourceInterval:[80,83]},"}"]]],SuperGrammar:["define",{sourceInterval:[87,116]},null,[],["seq",{sourceInterval:[106,116]},["terminal",{sourceInterval:[106,110]},"<:"],["app",{sourceInterval:[111,116]},"ident",[]]]],Rule_define:["define",{sourceInterval:[131,181]},null,[],["seq",{sourceInterval:[131,170]},["app",{sourceInterval:[131,136]},"ident",[]],["opt",{sourceInterval:[137,145]},["app",{sourceInterval:[137,144]},"Formals",[]]],["opt",{sourceInterval:[146,156]},["app",{sourceInterval:[146,155]},"ruleDescr",[]]],["terminal",{sourceInterval:[157,160]},"="],["app",{sourceInterval:[162,170]},"RuleBody",[]]]],Rule_override:["define",{sourceInterval:[188,240]},null,[],["seq",{sourceInterval:[188,227]},["app",{sourceInterval:[188,193]},"ident",[]],["opt",{sourceInterval:[194,202]},["app",{sourceInterval:[194,201]},"Formals",[]]],["terminal",{sourceInterval:[214,218]},":="],["app",{sourceInterval:[219,227]},"RuleBody",[]]]],Rule_extend:["define",{sourceInterval:[247,297]},null,[],["seq",{sourceInterval:[247,286]},["app",{sourceInterval:[247,252]},"ident",[]],["opt",{sourceInterval:[253,261]},["app",{sourceInterval:[253,260]},"Formals",[]]],["terminal",{sourceInterval:[273,277]},"+="],["app",{sourceInterval:[278,286]},"RuleBody",[]]]],Rule:["define",{sourceInterval:[120,297]},null,[],["alt",{sourceInterval:[131,297]},["app",{sourceInterval:[131,170]},"Rule_define",[]],["app",{sourceInterval:[188,227]},"Rule_override",[]],["app",{sourceInterval:[247,286]},"Rule_extend",[]]]],RuleBody:["define",{sourceInterval:[301,354]},null,[],["seq",{sourceInterval:[316,354]},["opt",{sourceInterval:[316,320]},["terminal",{sourceInterval:[316,319]},"|"]],["app",{sourceInterval:[321,354]},"NonemptyListOf",[["app",{sourceInterval:[336,348]},"TopLevelTerm",[]],["terminal",{sourceInterval:[350,353]},"|"]]]]],TopLevelTerm_inline:["define",{sourceInterval:[377,400]},null,[],["seq",{sourceInterval:[377,389]},["app",{sourceInterval:[377,380]},"Seq",[]],["app",{sourceInterval:[381,389]},"caseName",[]]]],TopLevelTerm:["define",{sourceInterval:[358,410]},null,[],["alt",{sourceInterval:[377,410]},["app",{sourceInterval:[377,389]},"TopLevelTerm_inline",[]],["app",{sourceInterval:[407,410]},"Seq",[]]]],Formals:["define",{sourceInterval:[414,454]},null,[],["seq",{sourceInterval:[428,454]},["terminal",{sourceInterval:[428,431]},"<"],["app",{sourceInterval:[432,450]},"ListOf",[["app",{sourceInterval:[439,444]},"ident",[]],["terminal",{sourceInterval:[446,449]},","]]],["terminal",{sourceInterval:[451,454]},">"]]],Params:["define",{sourceInterval:[458,495]},null,[],["seq",{sourceInterval:[471,495]},["terminal",{sourceInterval:[471,474]},"<"],["app",{sourceInterval:[475,491]},"ListOf",[["app",{sourceInterval:[482,485]},"Seq",[]],["terminal",{sourceInterval:[487,490]},","]]],["terminal",{sourceInterval:[492,495]},">"]]],Alt:["define",{sourceInterval:[499,533]},null,[],["app",{sourceInterval:[509,533]},"NonemptyListOf",[["app",{sourceInterval:[524,527]},"Seq",[]],["terminal",{sourceInterval:[529,532]},"|"]]]],Seq:["define",{sourceInterval:[537,552]},null,[],["star",{sourceInterval:[547,552]},["app",{sourceInterval:[547,551]},"Iter",[]]]],Iter_star:["define",{sourceInterval:[567,584]},null,[],["seq",{sourceInterval:[567,575]},["app",{sourceInterval:[567,571]},"Pred",[]],["terminal",{sourceInterval:[572,575]},"*"]]],Iter_plus:["define",{sourceInterval:[591,608]},null,[],["seq",{sourceInterval:[591,599]},["app",{sourceInterval:[591,595]},"Pred",[]],["terminal",{sourceInterval:[596,599]},"+"]]],Iter_opt:["define",{sourceInterval:[615,631]},null,[],["seq",{sourceInterval:[615,623]},["app",{sourceInterval:[615,619]},"Pred",[]],["terminal",{sourceInterval:[620,623]},"?"]]],Iter:["define",{sourceInterval:[556,642]},null,[],["alt",{sourceInterval:[567,642]},["app",{sourceInterval:[567,575]},"Iter_star",[]],["app",{sourceInterval:[591,599]},"Iter_plus",[]],["app",{sourceInterval:[615,623]},"Iter_opt",[]],["app",{sourceInterval:[638,642]},"Pred",[]]]],Pred_not:["define",{sourceInterval:[657,672]},null,[],["seq",{sourceInterval:[657,664]},["terminal",{sourceInterval:[657,660]},"~"],["app",{sourceInterval:[661,664]},"Lex",[]]]],Pred_lookahead:["define",{sourceInterval:[679,700]},null,[],["seq",{sourceInterval:[679,686]},["terminal",{sourceInterval:[679,682]},"&"],["app",{sourceInterval:[683,686]},"Lex",[]]]],Pred:["define",{sourceInterval:[646,710]},null,[],["alt",{sourceInterval:[657,710]},["app",{sourceInterval:[657,664]},"Pred_not",[]],["app",{sourceInterval:[679,686]},"Pred_lookahead",[]],["app",{sourceInterval:[707,710]},"Lex",[]]]],Lex_lex:["define",{sourceInterval:[724,740]},null,[],["seq",{sourceInterval:[724,732]},["terminal",{sourceInterval:[724,727]},"#"],["app",{sourceInterval:[728,732]},"Base",[]]]],Lex:["define",{sourceInterval:[714,751]},null,[],["alt",{sourceInterval:[724,751]},["app",{sourceInterval:[724,732]},"Lex_lex",[]],["app",{sourceInterval:[747,751]},"Base",[]]]],Base_application:["define",{sourceInterval:[766,827]},null,[],["seq",{sourceInterval:[766,811]},["app",{sourceInterval:[766,771]},"ident",[]],["opt",{sourceInterval:[772,779]},["app",{sourceInterval:[772,778]},"Params",[]]],["not",{sourceInterval:[780,811]},["alt",{sourceInterval:[782,810]},["seq",{sourceInterval:[782,796]},["opt",{sourceInterval:[782,792]},["app",{sourceInterval:[782,791]},"ruleDescr",[]]],["terminal",{sourceInterval:[793,796]},"="]],["terminal",{sourceInterval:[799,803]},":="],["terminal",{sourceInterval:[806,810]},"+="]]]]],Base_range:["define",{sourceInterval:[834,889]},null,[],["seq",{sourceInterval:[834,856]},["app",{sourceInterval:[834,842]},"terminal",[]],["terminal",{sourceInterval:[843,847]},".."],["app",{sourceInterval:[848,856]},"terminal",[]]]],Base_terminal:["define",{sourceInterval:[896,954]},null,[],["app",{sourceInterval:[896,904]},"terminal",[]]],Base_paren:["define",{sourceInterval:[961,1016]},null,[],["seq",{sourceInterval:[961,972]},["terminal",{sourceInterval:[961,964]},"("],["app",{sourceInterval:[965,968]},"Alt",[]],["terminal",{sourceInterval:[969,972]},")"]]],Base:["define",{sourceInterval:[755,1016]},null,[],["alt",{sourceInterval:[766,1016]},["app",{sourceInterval:[766,811]},"Base_application",[]],["app",{sourceInterval:[834,856]},"Base_range",[]],["app",{sourceInterval:[896,904]},"Base_terminal",[]],["app",{sourceInterval:[961,972]},"Base_paren",[]]]],ruleDescr:["define",{sourceInterval:[1020,1079]},"a rule description",[],["seq",{sourceInterval:[1058,1079]},["terminal",{sourceInterval:[1058,1061]},"("],["app",{sourceInterval:[1062,1075]},"ruleDescrText",[]],["terminal",{sourceInterval:[1076,1079]},")"]]],ruleDescrText:["define",{sourceInterval:[1083,1114]},null,[],["star",{sourceInterval:[1103,1114]},["seq",{sourceInterval:[1104,1112]},["not",{sourceInterval:[1104,1108]},["terminal",{sourceInterval:[1105,1108]},")"]],["app",{sourceInterval:[1109,1112]},"any",[]]]]],caseName:["define",{sourceInterval:[1118,1186]},null,[],["seq",{sourceInterval:[1133,1186]},["terminal",{sourceInterval:[1133,1137]},"--"],["star",{sourceInterval:[1138,1152]},["seq",{sourceInterval:[1139,1150]},["not",{sourceInterval:[1139,1144]},["terminal",{sourceInterval:[1140,1144]},"\n"]],["app",{sourceInterval:[1145,1150]},"space",[]]]],["app",{sourceInterval:[1153,1157]},"name",[]],["star",{sourceInterval:[1158,1172]},["seq",{sourceInterval:[1159,1170]},["not",{sourceInterval:[1159,1164]},["terminal",{sourceInterval:[1160,1164]},"\n"]],["app",{sourceInterval:[1165,1170]},"space",[]]]],["alt",{sourceInterval:[1174,1185]},["terminal",{sourceInterval:[1174,1178]},"\n"],["lookahead",{sourceInterval:[1181,1185]},["terminal",{sourceInterval:[1182,1185]},"}"]]]]],name:["define",{sourceInterval:[1190,1230]},"a name",[],["seq",{sourceInterval:[1211,1230]},["app",{sourceInterval:[1211,1220]},"nameFirst",[]],["star",{sourceInterval:[1221,1230]},["app",{sourceInterval:[1221,1229]},"nameRest",[]]]]],nameFirst:["define",{sourceInterval:[1234,1266]},null,[],["alt",{sourceInterval:[1250,1266]},["terminal",{sourceInterval:[1250,1253]},"_"],["app",{sourceInterval:[1260,1266]},"letter",[]]]],nameRest:["define",{sourceInterval:[1270,1300]},null,[],["alt",{sourceInterval:[1285,1300]},["terminal",{sourceInterval:[1285,1288]},"_"],["app",{sourceInterval:[1295,1300]},"alnum",[]]]],ident:["define",{sourceInterval:[1304,1337]},"an identifier",[],["app",{sourceInterval:[1333,1337]},"name",[]]],terminal:["define",{sourceInterval:[1341,1379]},null,[],["seq",{sourceInterval:[1356,1379]},["terminal",{sourceInterval:[1356,1360]},'"'],["star",{sourceInterval:[1361,1374]},["app",{sourceInterval:[1361,1373]},"terminalChar",[]]],["terminal",{sourceInterval:[1375,1379]},'"']]],terminalChar:["define",{sourceInterval:[1383,1440]},null,[],["alt",{sourceInterval:[1402,1440]},["app",{sourceInterval:[1402,1412]},"escapeChar",[]],["seq",{sourceInterval:[1419,1440]},["not",{sourceInterval:[1419,1424]},["terminal",{sourceInterval:[1420,1424]},"\\"]],["not",{sourceInterval:[1425,1430]},["terminal",{sourceInterval:[1426,1430]},'"']],["not",{sourceInterval:[1431,1436]},["terminal",{sourceInterval:[1432,1436]},"\n"]],["app",{sourceInterval:[1437,1440]},"any",[]]]]],escapeChar_backslash:["define",{sourceInterval:[1483,1538]},null,[],["terminal",{sourceInterval:[1483,1489]},"\\\\"]],escapeChar_doubleQuote:["define",{sourceInterval:[1545,1602]},null,[],["terminal",{sourceInterval:[1545,1551]},'\\"']],escapeChar_singleQuote:["define",{sourceInterval:[1609,1666]},null,[],["terminal",{sourceInterval:[1609,1615]},"\\'"]],escapeChar_backspace:["define",{sourceInterval:[1673,1728]},null,[],["terminal",{sourceInterval:[1673,1678]},"\\b"]],escapeChar_lineFeed:["define",{sourceInterval:[1735,1789]},null,[],["terminal",{sourceInterval:[1735,1740]},"\\n"]],escapeChar_carriageReturn:["define",{sourceInterval:[1796,1856]},null,[],["terminal",{sourceInterval:[1796,1801]},"\\r"]],escapeChar_tab:["define",{sourceInterval:[1863,1912]},null,[],["terminal",{sourceInterval:[1863,1868]},"\\t"]],escapeChar_unicodeEscape:["define",{sourceInterval:[1919,1978]},null,[],["seq",{sourceInterval:[1919,1960]},["terminal",{sourceInterval:[1919,1924]},"\\u"],["app",{sourceInterval:[1925,1933]},"hexDigit",[]],["app",{sourceInterval:[1934,1942]},"hexDigit",[]],["app",{sourceInterval:[1943,1951]},"hexDigit",[]],["app",{sourceInterval:[1952,1960]},"hexDigit",[]]]],escapeChar_hexEscape:["define",{sourceInterval:[1985,2040]},null,[],["seq",{sourceInterval:[1985,2008]},["terminal",{sourceInterval:[1985,1990]},"\\x"],["app",{sourceInterval:[1991,1999]},"hexDigit",[]],["app",{sourceInterval:[2e3,2008]},"hexDigit",[]]]],escapeChar:["define",{sourceInterval:[1444,2040]},"an escape sequence",[],["alt",{sourceInterval:[1483,2040]},["app",{sourceInterval:[1483,1489]},"escapeChar_backslash",[]],["app",{sourceInterval:[1545,1551]},"escapeChar_doubleQuote",[]],["app",{sourceInterval:[1609,1615]},"escapeChar_singleQuote",[]],["app",{sourceInterval:[1673,1678]},"escapeChar_backspace",[]],["app",{sourceInterval:[1735,1740]},"escapeChar_lineFeed",[]],["app",{sourceInterval:[1796,1801]},"escapeChar_carriageReturn",[]],["app",{sourceInterval:[1863,1868]},"escapeChar_tab",[]],["app",{sourceInterval:[1919,1960]},"escapeChar_unicodeEscape",[]],["app",{sourceInterval:[1985,2008]},"escapeChar_hexEscape",[]]]],space:["extend",{sourceInterval:[2044,2063]},null,[],["app",{sourceInterval:[2056,2063]},"comment",[]]],comment_singleLine:["define",{sourceInterval:[2081,2118]},null,[],["seq",{sourceInterval:[2081,2103]},["terminal",{sourceInterval:[2081,2085]},"//"],["star",{sourceInterval:[2086,2098]},["seq",{sourceInterval:[2087,2096]},["not",{sourceInterval:[2087,2092]},["terminal",{sourceInterval:[2088,2092]},"\n"]],["app",{sourceInterval:[2093,2096]},"any",[]]]],["terminal",{sourceInterval:[2099,2103]},"\n"]]],comment_multiLine:["define",{sourceInterval:[2125,2161]},null,[],["seq",{sourceInterval:[2125,2147]},["terminal",{sourceInterval:[2125,2129]},"/*"],["star",{sourceInterval:[2130,2142]},["seq",{sourceInterval:[2131,2140]},["not",{sourceInterval:[2131,2136]},["terminal",{sourceInterval:[2132,2136]},"*/"]],["app",{sourceInterval:[2137,2140]},"any",[]]]],["terminal",{sourceInterval:[2143,2147]},"*/"]]],comment:["define",{sourceInterval:[2067,2161]},null,[],["alt",{sourceInterval:[2081,2161]},["app",{sourceInterval:[2081,2103]},"comment_singleLine",[]],["app",{sourceInterval:[2125,2147]},"comment_multiLine",[]]]],tokens:["define",{sourceInterval:[2165,2180]},null,[],["star",{sourceInterval:[2174,2180]},["app",{sourceInterval:[2174,2179]},"token",[]]]],token:["define",{sourceInterval:[2184,2260]},null,[],["alt",{sourceInterval:[2192,2260]},["app",{sourceInterval:[2192,2200]},"caseName",[]],["app",{sourceInterval:[2203,2210]},"comment",[]],["app",{sourceInterval:[2213,2218]},"ident",[]],["app",{sourceInterval:[2221,2229]},"operator",[]],["app",{sourceInterval:[2232,2243]},"punctuation",[]],["app",{sourceInterval:[2246,2254]},"terminal",[]],["app",{sourceInterval:[2257,2260]},"any",[]]]],operator:["define",{sourceInterval:[2264,2329]},null,[],["alt",{sourceInterval:[2275,2329]},["terminal",{sourceInterval:[2275,2279]},"<:"],["terminal",{sourceInterval:[2282,2285]},"="],["terminal",{sourceInterval:[2288,2292]},":="],["terminal",{sourceInterval:[2295,2299]},"+="],["terminal",{sourceInterval:[2302,2305]},"*"],["terminal",{sourceInterval:[2308,2311]},"+"],["terminal",{sourceInterval:[2314,2317]},"?"],["terminal",{sourceInterval:[2320,2323]},"~"],["terminal",{sourceInterval:[2326,2329]},"&"]]],punctuation:["define",{sourceInterval:[2333,2369]},null,[],["alt",{sourceInterval:[2347,2369]},["terminal",{sourceInterval:[2347,2350]},"<"],["terminal",{sourceInterval:[2353,2356]},">"],["terminal",{sourceInterval:[2359,2362]},","],["terminal",{sourceInterval:[2365,2369]},"--"]]]}])},{"..":43}],3:[function(require,module,exports){var ohm=require("..");module.exports=ohm.makeRecipe(["grammar",{source:'OperationsAndAttributes {\n\n AttributeSignature =\n name\n\n OperationSignature =\n name Formals?\n\n Formals\n = "(" ListOf ")"\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = "_"\n | letter\n\n nameRest\n = "_"\n | alnum\n\n}'},"OperationsAndAttributes",null,"AttributeSignature",{AttributeSignature:["define",{sourceInterval:[29,58]},null,[],["app",{sourceInterval:[54,58]},"name",[]]],OperationSignature:["define",{sourceInterval:[62,100]},null,[],["seq",{sourceInterval:[87,100]},["app",{sourceInterval:[87,91]},"name",[]],["opt",{sourceInterval:[92,100]},["app",{sourceInterval:[92,99]},"Formals",[]]]]],Formals:["define",{sourceInterval:[104,143]},null,[],["seq",{sourceInterval:[118,143]},["terminal",{sourceInterval:[118,121]},"("],["app",{sourceInterval:[122,139]},"ListOf",[["app",{sourceInterval:[129,133]},"name",[]],["terminal",{sourceInterval:[135,138]},","]]],["terminal",{sourceInterval:[140,143]},")"]]],name:["define",{sourceInterval:[147,187]},"a name",[],["seq",{sourceInterval:[168,187]},["app",{sourceInterval:[168,177]},"nameFirst",[]],["star",{sourceInterval:[178,187]},["app",{sourceInterval:[178,186]},"nameRest",[]]]]],nameFirst:["define",{sourceInterval:[191,223]},null,[],["alt",{sourceInterval:[207,223]},["terminal",{sourceInterval:[207,210]},"_"],["app",{sourceInterval:[217,223]},"letter",[]]]],nameRest:["define",{sourceInterval:[227,257]},null,[],["alt",{sourceInterval:[242,257]},["terminal",{sourceInterval:[242,245]},"_"],["app",{sourceInterval:[252,257]},"alnum",[]]]]}])},{"..":43}],4:[function(require,module,exports){"use strict";var assert=require("../src/common").assert;function getProp(name,thing,fn){return fn(thing[name])}function mapProp(name,thing,fn){return thing[name].map(fn)}function getPropWalkFn(descriptor){var parts=descriptor.split(/ ?\[\]/);if(parts.length===2){return mapProp.bind(null,parts[0])}return getProp.bind(null,descriptor)}function getProps(walkFns,thing,fn){return walkFns.map(function(walkFn){return walkFn(thing,fn)})}function getWalkFn(shape){if(typeof shape==="string"){return getProps.bind(null,[getPropWalkFn(shape)])}else if(Array.isArray(shape)){return getProps.bind(null,shape.map(getPropWalkFn))}else{assert(typeof shape==="function","Expected a string, Array, or function");assert(shape.length===2,"Expected a function of arity 2, got "+shape.length);return shape}}function isRestrictedIdentifier(str){return/^[a-zA-Z_][0-9a-zA-Z_]*$/.test(str)}function trim(s){return s.trim()}function parseSignature(sig){var parts=sig.split(/[()]/).map(trim);if(parts.length===3&&parts[2]===""){var name=parts[0];var params=[];if(parts[1].length>0){params=parts[1].split(",").map(trim)}if(isRestrictedIdentifier(name)&¶ms.every(isRestrictedIdentifier)){return{name:name,formals:params}}}throw new Error("Invalid operation signature: "+sig)}function VisitorFamily(config){this._shapes=config.shapes;this._getTag=config.getTag;this.Adapter=function(thing,family){this._adaptee=thing;this._family=family};this.Adapter.prototype.valueOf=function(){throw new Error("heeey!")};this.operations={};this._arities=Object.create(null);this._getChildren=Object.create(null);var self=this;Object.keys(this._shapes).forEach(function(k){var shape=self._shapes[k];self._getChildren[k]=getWalkFn(shape);if(typeof shape!=="function"){self._arities[k]=Array.isArray(shape)?shape.length:1}});this._wrap=function(thing){return new self.Adapter(thing,self)}}VisitorFamily.prototype.wrap=function(thing){return this._wrap(thing)};VisitorFamily.prototype._checkActionDict=function(dict){var self=this;Object.keys(dict).forEach(function(k){assert(k in self._getChildren,"Unrecognized action name '"+k+"'");var action=dict[k];assert(typeof action==="function","Key '"+k+"': expected function, got "+action);if(k in self._arities){var expected=self._arities[k];var actual=dict[k].length;assert(actual===expected,"Action '"+k+"' has the wrong arity: expected "+expected+", got "+actual)}})};VisitorFamily.prototype.addOperation=function(signature,actions){var sig=parseSignature(signature);var name=sig.name;this._checkActionDict(actions);this.operations[name]={name:name,formals:sig.formals,actions:actions};var family=this;this.Adapter.prototype[name]=function(){var tag=family._getTag(this._adaptee);assert(tag in family._getChildren,"getTag returned unrecognized tag '"+tag+"'");assert(tag in actions,"No action for '"+tag+"' in operation '"+name+"'");var args=Object.create(null);for(var i=0;i-1}},{}],23:[function(require,module,exports){"use strict";var d=require("d"),validateSymbol=require("./validate-symbol"),create=Object.create,defineProperties=Object.defineProperties,defineProperty=Object.defineProperty,objPrototype=Object.prototype,NativeSymbol,SymbolPolyfill,HiddenSymbol,globalSymbols=create(null),isNativeSafe;if(typeof Symbol==="function"){NativeSymbol=Symbol;try{String(NativeSymbol());isNativeSafe=true}catch(ignore){}}var generateName=function(){var created=create(null);return function(desc){var postfix=0,name,ie11BugWorkaround;while(created[desc+(postfix||"")])++postfix;desc+=postfix||"";created[desc]=true;name="@@"+desc;defineProperty(objPrototype,name,d.gs(null,function(value){if(ie11BugWorkaround)return;ie11BugWorkaround=true;defineProperty(this,name,d(value));ie11BugWorkaround=false}));return name}}();HiddenSymbol=function Symbol(description){if(this instanceof HiddenSymbol)throw new TypeError("TypeError: Symbol is not a constructor");return SymbolPolyfill(description)};module.exports=SymbolPolyfill=function Symbol(description){var symbol;if(this instanceof Symbol)throw new TypeError("TypeError: Symbol is not a constructor");if(isNativeSafe)return NativeSymbol(description);symbol=create(HiddenSymbol.prototype);description=description===undefined?"":String(description);return defineProperties(symbol,{__description__:d("",description),__name__:d("",generateName(description))})};defineProperties(SymbolPolyfill,{for:d(function(key){if(globalSymbols[key])return globalSymbols[key];return globalSymbols[key]=SymbolPolyfill(String(key))}),keyFor:d(function(s){var key;validateSymbol(s);for(key in globalSymbols)if(globalSymbols[key]===s)return key}),hasInstance:d("",NativeSymbol&&NativeSymbol.hasInstance||SymbolPolyfill("hasInstance")),isConcatSpreadable:d("",NativeSymbol&&NativeSymbol.isConcatSpreadable||SymbolPolyfill("isConcatSpreadable")),iterator:d("",NativeSymbol&&NativeSymbol.iterator||SymbolPolyfill("iterator")),match:d("",NativeSymbol&&NativeSymbol.match||SymbolPolyfill("match")),replace:d("",NativeSymbol&&NativeSymbol.replace||SymbolPolyfill("replace")),search:d("",NativeSymbol&&NativeSymbol.search||SymbolPolyfill("search")),species:d("",NativeSymbol&&NativeSymbol.species||SymbolPolyfill("species")),split:d("",NativeSymbol&&NativeSymbol.split||SymbolPolyfill("split")),toPrimitive:d("",NativeSymbol&&NativeSymbol.toPrimitive||SymbolPolyfill("toPrimitive")),toStringTag:d("",NativeSymbol&&NativeSymbol.toStringTag||SymbolPolyfill("toStringTag")),unscopables:d("",NativeSymbol&&NativeSymbol.unscopables||SymbolPolyfill("unscopables"))});defineProperties(HiddenSymbol.prototype,{constructor:d(SymbolPolyfill),toString:d("",function(){return this.__name__})});defineProperties(SymbolPolyfill.prototype,{toString:d(function(){return"Symbol ("+validateSymbol(this).__description__+")"}),valueOf:d(function(){return validateSymbol(this)})});defineProperty(SymbolPolyfill.prototype,SymbolPolyfill.toPrimitive,d("",function(){var symbol=validateSymbol(this);if(typeof symbol==="symbol")return symbol;return symbol.toString()}));defineProperty(SymbolPolyfill.prototype,SymbolPolyfill.toStringTag,d("c","Symbol"));defineProperty(HiddenSymbol.prototype,SymbolPolyfill.toStringTag,d("c",SymbolPolyfill.prototype[SymbolPolyfill.toStringTag]));defineProperty(HiddenSymbol.prototype,SymbolPolyfill.toPrimitive,d("c",SymbolPolyfill.prototype[SymbolPolyfill.toPrimitive]))},{"./validate-symbol":24,d:10}],24:[function(require,module,exports){"use strict";var isSymbol=require("./is-symbol");module.exports=function(value){if(!isSymbol(value))throw new TypeError(value+" is not a symbol");return value}},{"./is-symbol":9}],25:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],26:[function(require,module,exports){module.exports=function(obj){return obj!=null&&(isBuffer(obj)||isSlowBuffer(obj)||!!obj._isBuffer)};function isBuffer(obj){return!!obj.constructor&&typeof obj.constructor.isBuffer==="function"&&obj.constructor.isBuffer(obj)}function isSlowBuffer(obj){return typeof obj.readFloatLE==="function"&&typeof obj.slice==="function"&&isBuffer(obj.slice(0,0))}},{}],27:[function(require,module,exports){module.exports=extend;function extend(origin,add){if(!add||typeof add!=="object")return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin}},{}],28:[function(require,module,exports){"use strict";var GrammarDecl=require("./GrammarDecl");var pexprs=require("./pexprs");function Builder(){}Builder.prototype={currentDecl:null,newGrammar:function(name){return new GrammarDecl(name)},grammar:function(metaInfo,name,superGrammar,defaultStartRule,rules){var gDecl=new GrammarDecl(name);if(superGrammar){gDecl.withSuperGrammar(this.fromRecipe(superGrammar))}if(defaultStartRule){gDecl.withDefaultStartRule(defaultStartRule)}if(metaInfo&&metaInfo.source){gDecl.withSource(metaInfo.source)}var self=this;this.currentDecl=gDecl;Object.keys(rules).forEach(function(ruleName){var ruleRecipe=rules[ruleName];var action=ruleRecipe[0];var metaInfo=ruleRecipe[1];var description=ruleRecipe[2];var formals=ruleRecipe[3];var body=self.fromRecipe(ruleRecipe[4]);var source;if(gDecl.source&&metaInfo&&metaInfo.sourceInterval){var inputStream=gDecl.source.inputStream;source=inputStream.interval.apply(inputStream,metaInfo.sourceInterval)}gDecl[action](ruleName,formals,body,description,source)});this.currentDecl=null;return gDecl.build()},terminal:function(x){return new pexprs.Terminal(x)},range:function(from,to){return new pexprs.Range(from,to)},param:function(index){return new pexprs.Param(index)},alt:function(){var terms=[];for(var idx=0;idx0){optParams=optParams.map(function(param){return param instanceof pexprs.PExpr?param:this.fromRecipe(param)},this)}return new pexprs.Apply(ruleName,optParams)},fromRecipe:function(recipe){var result=this[recipe[0]].apply(this,recipe[0]==="grammar"?recipe.slice(1):recipe.slice(2));var metaInfo=recipe[1];if(metaInfo){if(metaInfo.sourceInterval&&this.currentDecl){result.withSource(this.currentDecl.sourceInterval.apply(this.currentDecl,metaInfo.sourceInterval))}}return result}};module.exports=Builder},{"./GrammarDecl":32,"./pexprs":61}],29:[function(require,module,exports){"use strict";var Failure=require("./Failure");var TerminalNode=require("./nodes").TerminalNode;var assert=require("./common").assert;var inherits=require("inherits");var pexprs=require("./pexprs");function CaseInsensitiveTerminal(param){this.obj=param}inherits(CaseInsensitiveTerminal,pexprs.PExpr);CaseInsensitiveTerminal.prototype={_getString:function(state){var terminal=state.currentApplication().args[this.obj.index];assert(terminal instanceof pexprs.Terminal,"expected a Terminal expression");return terminal.obj},allowsSkippingPrecedingSpace:function(){return true},eval:function(state){var inputStream=state.inputStream;var origPos=inputStream.pos;var matchStr=this._getString(state);if(!inputStream.matchString(matchStr,true)){state.processFailure(origPos,this);return false}else{state.bindings.push(new TerminalNode(state.grammar,this.obj,inputStream.interval(origPos)));return true}},generateExamples:function(grammar,examples,inSyntacticContext,actuals){var str=this.obj.generateExamples(grammar,examples,inSyntacticContext,actuals).value;var value="";for(var i=0;i0){var prettyProblems=problems.map(function(problem){return"- "+problem});var error=new Error("Found errors in the action dictionary of the '"+name+"' "+what+":\n"+prettyProblems.join("\n"));error.problems=problems;throw error}},_topDownActionArity:function(actionName){if(actionName==="_iter"||actionName==="_nonterminal"||actionName==="_default"){return 1}else if(actionName==="_terminal"){return 0}return this.rules[actionName].body.getArity()},_inheritsFrom:function(grammar){var g=this.superGrammar;while(g){if(g.equals(grammar,true)){return true}g=g.superGrammar}return false},toRecipe:function(optVarName){var metaInfo={};if(this.source){metaInfo.source=this.source.contents}var superGrammar=null;if(this.superGrammar&&!this.superGrammar.isBuiltIn()){superGrammar=JSON.parse(this.superGrammar.toRecipe())}var startRule=null;if(this.defaultStartRule){startRule=this.defaultStartRule}var rules={};var self=this;Object.keys(this.rules).forEach(function(ruleName){var ruleInfo=self.rules[ruleName];var body=ruleInfo.body;var isDefinition=!self.superGrammar||!self.superGrammar.rules[ruleName];var operation;if(isDefinition){operation="define"}else{operation=body instanceof pexprs.Extend?"extend":"override"}var metaInfo={};if(ruleInfo.source&&self.source){var adjusted=ruleInfo.source.relativeTo(self.source);metaInfo.sourceInterval=[adjusted.startIdx,adjusted.endIdx]}var description=isDefinition?ruleInfo.description:null;var bodyRecipe=body.outputRecipe(ruleInfo.formals,self.source);rules[ruleName]=[operation,metaInfo,description,ruleInfo.formals,bodyRecipe]});return JSON.stringify(["grammar",metaInfo,this.name,superGrammar,startRule,rules])},toOperationActionDictionaryTemplate:function(){return this._toOperationOrAttributeActionDictionaryTemplate()},toAttributeActionDictionaryTemplate:function(){return this._toOperationOrAttributeActionDictionaryTemplate()},_toOperationOrAttributeActionDictionaryTemplate:function(){var sb=new common.StringBuffer;sb.append("{");var first=true;for(var ruleName in this.rules){var body=this.rules[ruleName].body;if(first){first=false}else{sb.append(",")}sb.append("\n");sb.append(" ");this.addSemanticActionTemplate(ruleName,body,sb)}sb.append("\n}");return sb.contents()},addSemanticActionTemplate:function(ruleName,body,sb){sb.append(ruleName);sb.append(": function(");var arity=this._topDownActionArity(ruleName);sb.append(common.repeat("_",arity).join(", "));sb.append(") {\n");sb.append(" }")},parseApplication:function(str){var app;if(str.indexOf("<")===-1){app=new pexprs.Apply(str)}else{var cst=ohmGrammar.match(str,"Base_application");app=buildGrammar(cst,{})}if(!(app.ruleName in this.rules)){throw errors.undeclaredRule(app.ruleName,this.name)}var formals=this.rules[app.ruleName].formals;if(formals.length!==app.args.length){var source=this.rules[app.ruleName].source;throw errors.wrongNumberOfParameters(app.ruleName,formals.length,app.args.length,source)}return app}};Grammar.ProtoBuiltInRules=new Grammar("ProtoBuiltInRules",undefined,{any:{body:pexprs.any,formals:[],description:"any object"},end:{body:pexprs.end,formals:[],description:"end of input"},caseInsensitive:{body:new CaseInsensitiveTerminal(new pexprs.Param(0)),formals:["expr"]},spaces:{body:new pexprs.Star(new pexprs.Apply("space")),formals:[]},space:{body:new pexprs.Range("\0"," "),formals:[],description:"a space"},lower:{body:new pexprs.UnicodeChar("Ll"),formals:[],description:"a lowercase letter"},upper:{body:new pexprs.UnicodeChar("Lu"),formals:[],description:"an uppercase letter"},unicodeLtmo:{body:new pexprs.UnicodeChar("Ltmo"),formals:[]}});module.exports=Grammar},{"./CaseInsensitiveTerminal":29,"./MatchResult":35,"./Semantics":38,"./State":39,"./common":41,"./errors":42,"./pexprs":61}],32:[function(require,module,exports){"use strict";var Grammar=require("./Grammar");var InputStream=require("./InputStream");var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");function GrammarDecl(name){this.name=name}GrammarDecl.prototype.sourceInterval=function(startIdx,endIdx){var inputStream=this.source.inputStream;return inputStream.interval(startIdx,endIdx)};GrammarDecl.prototype.ensureSuperGrammar=function(){if(!this.superGrammar){this.withSuperGrammar(this.name==="BuiltInRules"?Grammar.ProtoBuiltInRules:Grammar.BuiltInRules)}return this.superGrammar};GrammarDecl.prototype.installOverriddenOrExtendedRule=function(name,formals,body,source){var duplicateParameterNames=common.getDuplicates(formals);if(duplicateParameterNames.length>0){throw errors.duplicateParameterNames(name,duplicateParameterNames,source)}var ruleInfo=this.ensureSuperGrammar().rules[name];var expectedFormals=ruleInfo.formals;var expectedNumFormals=expectedFormals?expectedFormals.length:0;if(formals.length!==expectedNumFormals){throw errors.wrongNumberOfParameters(name,expectedNumFormals,formals.length,source)}return this.install(name,formals,body,ruleInfo.description,source)};GrammarDecl.prototype.install=function(name,formals,body,description,source){this.rules[name]={body:body.introduceParams(formals),formals:formals,description:description,source:source};return this};GrammarDecl.prototype.withSuperGrammar=function(superGrammar){if(this.superGrammar){throw new Error("the super grammar of a GrammarDecl cannot be set more than once")}this.superGrammar=superGrammar;this.rules=Object.create(superGrammar.rules);if(!superGrammar.isBuiltIn()){this.defaultStartRule=superGrammar.defaultStartRule}return this};GrammarDecl.prototype.withDefaultStartRule=function(ruleName){this.defaultStartRule=ruleName;return this};GrammarDecl.prototype.withSource=function(source){this.source=new InputStream(source).interval(0,source.length);return this};GrammarDecl.prototype.build=function(){var grammar=new Grammar(this.name,this.ensureSuperGrammar(),this.rules,this.defaultStartRule);var grammarErrors=[];var grammarHasInvalidApplications=false;Object.keys(grammar.rules).forEach(function(ruleName){var body=grammar.rules[ruleName].body;try{body.assertChoicesHaveUniformArity(ruleName)}catch(e){grammarErrors.push(e)}try{body.assertAllApplicationsAreValid(ruleName,grammar)}catch(e){grammarErrors.push(e);grammarHasInvalidApplications=true}});if(!grammarHasInvalidApplications){Object.keys(grammar.rules).forEach(function(ruleName){var body=grammar.rules[ruleName].body;try{body.assertIteratedExprsAreNotNullable(grammar,ruleName)}catch(e){grammarErrors.push(e)}})}if(grammarErrors.length>0){errors.throwErrors(grammarErrors)}if(this.source){grammar.source=this.source}return grammar};GrammarDecl.prototype.define=function(name,formals,body,description,source){this.ensureSuperGrammar();if(this.superGrammar.rules[name]){throw errors.duplicateRuleDeclaration(name,this.name,this.superGrammar.name,source)}else if(this.rules[name]){throw errors.duplicateRuleDeclaration(name,this.name,this.name,source)}var duplicateParameterNames=common.getDuplicates(formals);if(duplicateParameterNames.length>0){throw errors.duplicateParameterNames(name,duplicateParameterNames,source)}return this.install(name,formals,body,description,source)};GrammarDecl.prototype.override=function(name,formals,body,descIgnored,source){var ruleInfo=this.ensureSuperGrammar().rules[name];if(!ruleInfo){throw errors.cannotOverrideUndeclaredRule(name,this.superGrammar.name,source)}this.installOverriddenOrExtendedRule(name,formals,body,source);return this};GrammarDecl.prototype.extend=function(name,formals,fragment,descIgnored,source){var ruleInfo=this.ensureSuperGrammar().rules[name];if(!ruleInfo){throw errors.cannotExtendUndeclaredRule(name,this.superGrammar.name,source)}var body=new pexprs.Extend(this.superGrammar,name,fragment);body.source=fragment.source;this.installOverriddenOrExtendedRule(name,formals,body,source);return this};module.exports=GrammarDecl},{"./Grammar":31,"./InputStream":33,"./common":41,"./errors":42,"./pexprs":61}],33:[function(require,module,exports){"use strict";var Interval=require("./Interval");function InputStream(source){this.source=source;this.pos=0;this.posInfos=[]}InputStream.prototype={atEnd:function(){return this.pos===this.source.length},next:function(){return this.source[this.pos++]},matchString:function(s,optIgnoreCase){var idx;if(optIgnoreCase){for(idx=0;idx=that.startIdx&&this.endIdx<=that.endIdx,"other interval does not cover this one");return new Interval(newInputStream,this.startIdx-that.startIdx,this.endIdx-that.startIdx)},trimmed:function(){var contents=this.contents;var startIdx=this.startIdx+contents.match(/^\s*/)[0].length;var endIdx=this.endIdx-contents.match(/\s*$/)[0].length;return new Interval(this.inputStream,startIdx,endIdx)}};Object.defineProperties(Interval.prototype,{contents:{get:function(){if(this._contents===undefined){this._contents=this.inputStream.sourceSlice(this.startIdx,this.endIdx)}return this._contents},enumerable:true},length:{get:function(){return this.endIdx-this.startIdx},enumerable:true}});module.exports=Interval},{"./common":41,"./errors":42,"./util":62}],35:[function(require,module,exports){"use strict";var inherits=require("inherits");var common=require("./common");var nodes=require("./nodes");var util=require("./util");var Interval=require("./Interval");function getShortMatchErrorMessage(pos,source,detail){var errorInfo=util.getLineAndColumn(source,pos);return"Line "+errorInfo.lineNum+", col "+errorInfo.colNum+": "+detail}function MatchResult(state){this.state=state;this._cst=state.bindings[0]}MatchResult.newFor=function(state){var succeeded=state.bindings.length>0;return succeeded?new MatchResult(state):new MatchFailure(state)};MatchResult.prototype.failed=function(){return false};MatchResult.prototype.succeeded=function(){return!this.failed()};MatchResult.prototype.getDiscardedSpaces=function(){if(this.failed()){return[]}var state=this.state;var grammar=state.grammar;var inputStream=state.inputStream;var intervals=[new Interval(inputStream,0,inputStream.source.length)];var s=grammar.createSemantics().addOperation("subtractTerminals",{_nonterminal:function(children){children.forEach(function(child){child.subtractTerminals()})},_terminal:function(){var t=this;intervals=intervals.map(function(interval){return interval.minus(t.source)}).reduce(function(xs,ys){return xs.concat(ys)},[])}});s(this).subtractTerminals();s.addOperation("fixIntervals(idxOffset)",{_default:function(children){var idxOffset=this.args.idxOffset;this.source.inputStream=inputStream;this.source.startIdx+=idxOffset;this.source.endIdx+=idxOffset;if(!this.isTerminal()){children.forEach(function(child){child.fixIntervals(idxOffset)})}}});var discardedNodes=intervals.map(function(interval){var r=grammar.match(interval.contents,"spaces");s(r).fixIntervals(interval.startIdx);return r._cst});discardedNodes=new nodes.IterationNode(grammar,discardedNodes,discardedNodes.length===0?new Interval(inputStream,0,0):new Interval(inputStream,discardedNodes[0].source.startIdx,discardedNodes[discardedNodes.length-1].source.endIdx));var r=Object.create(this);r._cst=discardedNodes;r.getDiscardedSpaces=function(){return r};return r};function MatchFailure(state){this.state=state;common.defineLazyProperty(this,"_failures",function(){return this.state.getFailures()});common.defineLazyProperty(this,"message",function(){var source=this.state.inputStream.source;if(typeof source!=="string"){return"match failed at position "+this.getRightmostFailurePosition()}var detail="Expected "+this.getExpectedText();return util.getLineAndColumnMessage(source,this.getRightmostFailurePosition())+detail});common.defineLazyProperty(this,"shortMessage",function(){if(typeof this.state.inputStream.source!=="string"){return"match failed at position "+this.getRightmostFailurePosition()}var detail="expected "+this.getExpectedText();return getShortMatchErrorMessage(this.getRightmostFailurePosition(),this.state.inputStream.source,detail)})}inherits(MatchFailure,MatchResult);MatchFailure.prototype.toString=function(){return"[MatchFailure at position "+this.getRightmostFailurePosition()+"]"};MatchFailure.prototype.failed=function(){return true};MatchFailure.prototype.getRightmostFailurePosition=function(){return this.state.getRightmostFailurePosition()};MatchFailure.prototype.getRightmostFailures=function(){return this._failures};MatchFailure.prototype.getExpectedText=function(){var sb=new common.StringBuffer;var failures=this.getRightmostFailures();failures=failures.filter(function(failure){return!failure.isFluffy()});for(var idx=0;idx0){if(idx===failures.length-1){sb.append(failures.length>2?", or ":" or ")}else{sb.append(", ")}}sb.append(failures[idx].toString())}return sb.contents()};MatchFailure.prototype.getInterval=function(){var pos=this.state.getRightmostFailurePosition();return new Interval(this.state.inputStream,pos,pos)};module.exports=MatchResult},{"./Interval":34,"./common":41,"./nodes":44,"./util":62,inherits:25}],36:[function(require,module,exports){"use strict";var extend=require("util-extend");function Namespace(){}Namespace.prototype=Object.create(null);Namespace.asNamespace=function(objOrNamespace){if(objOrNamespace instanceof Namespace){return objOrNamespace}return Namespace.createNamespace(objOrNamespace)};Namespace.createNamespace=function(optProps){return Namespace.extend(Namespace.prototype,optProps)};Namespace.extend=function(namespace,optProps){if(namespace!==Namespace.prototype&&!(namespace instanceof Namespace)){throw new TypeError("not a Namespace object: "+namespace)}var ns=Object.create(namespace,{constructor:{value:Namespace,enumerable:false,writable:true,configurable:true}});return extend(ns,optProps)};Namespace.toString=function(ns){return Object.prototype.toString.call(ns)};module.exports=Namespace},{"util-extend":27}],37:[function(require,module,exports){"use strict";function PosInfo(state){this.state=state;this.applicationMemoKeyStack=[];this.memo={};this.currentLeftRecursion=undefined}PosInfo.prototype={isActive:function(application){return this.applicationMemoKeyStack.indexOf(application.toMemoKey())>=0},enter:function(application){this.state.enter(application);this.applicationMemoKeyStack.push(application.toMemoKey())},exit:function(){this.state.exit();this.applicationMemoKeyStack.pop()},startLeftRecursion:function(headApplication,memoRec){memoRec.isLeftRecursion=true;memoRec.headApplication=headApplication;memoRec.nextLeftRecursion=this.currentLeftRecursion;this.currentLeftRecursion=memoRec;var applicationMemoKeyStack=this.applicationMemoKeyStack;var indexOfFirstInvolvedRule=applicationMemoKeyStack.indexOf(headApplication.toMemoKey())+1;var involvedApplicationMemoKeys=applicationMemoKeyStack.slice(indexOfFirstInvolvedRule);memoRec.isInvolved=function(applicationMemoKey){ -return involvedApplicationMemoKeys.indexOf(applicationMemoKey)>=0};memoRec.updateInvolvedApplicationMemoKeys=function(){for(var idx=indexOfFirstInvolvedRule;idx0){signature+="("+semanticOperations[name].formals.join(", ")+")"}var method;if(hasSuperSemantics(this)&&this.super[type.toLowerCase()+"s"][name]){method="extend"+type}else{method="add"+type}str+="\n ."+method+"("+JSON.stringify(signature)+", {";var actions=semanticOperations[name].actionDict;var srcArray=[];Object.keys(actions).forEach(function(actionName){if(semanticOperations[name].builtInDefault!==actions[actionName]){srcArray.push("\n "+JSON.stringify(actionName)+": "+actions[actionName].toString())}});str+=srcArray.join(",");str+="\n })"},this)},this);str+=";\n })";if(!semanticsOnly){str="(function() {\n"+" var grammar = this.fromRecipe("+jsonToJS(this.grammar.toRecipe())+");\n"+" var semantics = "+str+"(grammar);\n"+" return semantics;\n"+"});\n"}return str};var prototypeGrammar;var prototypeGrammarSemantics;Semantics.initPrototypeParser=function(grammar){prototypeGrammarSemantics=grammar.createSemantics().addOperation("parse",{AttributeSignature:function(name){return{name:name.parse(),formals:[]}},OperationSignature:function(name,optFormals){return{name:name.parse(),formals:optFormals.parse()[0]||[]}},Formals:function(oparen,fs,cparen){return fs.asIteration().parse()},name:function(first,rest){return this.sourceString}});prototypeGrammar=grammar};function parseSignature(signature,type){if(!prototypeGrammar){common.assert(signature.indexOf("(")===-1);return{name:signature,formals:[]}}var r=prototypeGrammar.match(signature,type==="operation"?"OperationSignature":"AttributeSignature");if(r.failed()){throw new Error(r.message)}return prototypeGrammarSemantics(r).parse()}function newDefaultAction(type,name,doIt){return function(children){var self=this;var thisThing=this._semantics.operations[name]||this._semantics.attributes[name];var args=thisThing.formals.map(function(formal){return self.args[formal]});if(this.isIteration()){return children.map(function(child){return doIt.apply(child,args)})}if(children.length===1){return doIt.apply(children[0],args)}else{throw new Error("Missing semantic action for "+this.ctorName+" in "+name+" "+type)}}}Semantics.prototype.addOperationOrAttribute=function(type,signature,actionDict){var typePlural=type+"s";var parsedNameAndFormalArgs=parseSignature(signature,type);var name=parsedNameAndFormalArgs.name;var formals=parsedNameAndFormalArgs.formals;this.assertNewName(name,type);var builtInDefault=newDefaultAction(type,name,doIt);var realActionDict={_default:builtInDefault};Object.keys(actionDict).forEach(function(name){realActionDict[name]=actionDict[name]});var entry=type==="operation"?new Operation(name,formals,realActionDict,builtInDefault):new Attribute(name,realActionDict,builtInDefault);entry.checkActionDict(this.grammar);this[typePlural][name]=entry;function doIt(){var thisThing=this._semantics[typePlural][name];if(arguments.length!==thisThing.formals.length){throw new Error("Invalid number of arguments passed to "+name+" "+type+" (expected "+thisThing.formals.length+", got "+arguments.length+")")}var args=Object.create(null);for(var idx=0;idxnewLength){this.bindings.pop()}},getCurrentPosInfo:function(){return this.getPosInfo(this.inputStream.pos)},getPosInfo:function(pos){var posInfo=this.posInfos[pos];if(!posInfo){posInfo=this.posInfos[pos]=new PosInfo(this)}return posInfo},processFailure:function(pos,expr){if(this.recordingMode===RM_RIGHTMOST_FAILURE_POSITION){if(pos>this.rightmostFailurePosition){this.rightmostFailurePosition=pos}}else if(pos===this.rightmostFailurePosition){var app=this.currentApplication();if(app){expr=expr.substituteParams(app.args)}else{}this.addRightmostFailure(expr.toFailure(this.grammar),false)}},ensureRightmostFailures:function(){if(!this.rightmostFailures){this.rightmostFailures=Object.create(null)}},addRightmostFailure:function(failure,shouldCloneIfNew){this.ensureRightmostFailures();var key=failure.toKey();if(!this.rightmostFailures[key]){this.rightmostFailures[key]=shouldCloneIfNew?failure.clone():failure}else if(this.rightmostFailures[key].isFluffy()&&!failure.isFluffy()){this.rightmostFailures[key].clearFluffy()}},addRightmostFailures:function(failures,shouldCloneIfNew){var self=this;Object.keys(failures).forEach(function(key){self.addRightmostFailure(failures[key],shouldCloneIfNew)})},cloneRightmostFailures:function(){if(!this.rightmostFailures){return undefined}var ans=Object.create(null);var self=this;Object.keys(this.rightmostFailures).forEach(function(key){ans[key]=self.rightmostFailures[key].clone()});return ans},getRightmostFailurePosition:function(){return this.rightmostFailurePosition},getFailures:function(){if(this.recordingMode===RM_RIGHTMOST_FAILURE_POSITION){this.init(RM_RIGHTMOST_FAILURES);this.evalFromStart()}this.ensureRightmostFailures();var self=this;return Object.keys(this.rightmostFailures).map(function(key){return self.rightmostFailures[key]})},getMemoizedTraceEntry:function(pos,expr){var posInfo=this.posInfos[pos];if(posInfo&&expr.ruleName){var memoRec=posInfo.memo[expr.toMemoKey()];if(memoRec&&memoRec.traceEntry){var entry=memoRec.traceEntry.cloneWithExpr(expr);entry.isMemoized=true;return entry}}return null},getTraceEntry:function(pos,expr,succeeded,bindings){return this.getMemoizedTraceEntry(pos,expr)||new Trace(this.inputStream,pos,expr,succeeded,bindings,this.trace)},isTracing:function(){return this.tracingEnabled},useMemoizedResult:function(memoRec){if(this.isTracing()){this.trace.push(memoRec.traceEntry)}if(this.recordingMode===RM_RIGHTMOST_FAILURES&&memoRec.failuresAtRightmostPosition){this.addRightmostFailures(memoRec.failuresAtRightmostPosition,true)}if(memoRec.value){this.inputStream.pos=memoRec.pos;this.bindings.push(memoRec.value);return true}return false},eval:function(expr){var inputStream=this.inputStream;var origNumBindings=this.bindings.length;var origFailures;if(this.recordingMode===RM_RIGHTMOST_FAILURES){origFailures=this.rightmostFailures;this.rightmostFailures=undefined}var origPos=inputStream.pos;var memoPos=this.maybeSkipSpacesBefore(expr);var origTrace;if(this.isTracing()){origTrace=this.trace;this.trace=[]}var ans=expr.eval(this);if(this.isTracing()){var bindings=this.bindings.slice(origNumBindings);var traceEntry=this.getTraceEntry(memoPos,expr,ans,bindings);traceEntry.isImplicitSpaces=expr===applySpaces;traceEntry.isRootNode=expr===this.startExpr;origTrace.push(traceEntry);this.trace=origTrace}if(ans){if(this.rightmostFailures&&(inputStream.pos===this.rightmostFailurePosition||this.skipSpacesIfInSyntacticContext()===this.rightmostFailurePosition)){var self=this;Object.keys(this.rightmostFailures).forEach(function(key){self.rightmostFailures[key].makeFluffy()})}}else{inputStream.pos=origPos;this.truncateBindings(origNumBindings)}if(this.recordingMode===RM_RIGHTMOST_FAILURES&&origFailures){this.addRightmostFailures(origFailures,false)}return ans},_getStartExpr:function(grammar,optStartApplication){var applicationStr=optStartApplication||grammar.defaultStartRule;if(!applicationStr){throw new Error("Missing start rule argument -- the grammar has no default start rule.")}var startApp=grammar.parseApplication(applicationStr);return new pexprs.Seq([startApp,pexprs.end])},evalFromStart:function(){this.eval(this.startExpr)},getFailuresInfo:function(){if(this.recordingMode===RM_RIGHTMOST_FAILURE_POSITION){return this.rightmostFailurePosition}else{return this.rightmostFailures}},restoreFailuresInfo:function(failuresInfo){if(this.recordingMode===RM_RIGHTMOST_FAILURE_POSITION){this.rightmostFailurePosition=failuresInfo}else{this.rightmostFailures=failuresInfo}}};module.exports=State},{"./InputStream":33,"./PosInfo":37,"./Trace":40,"./pexprs":61}],40:[function(require,module,exports){"use strict";var Interval=require("./Interval");var common=require("./common");var BALLOT_X="✗";var CHECK_MARK="✓";var DOT_OPERATOR="⋅";var RIGHTWARDS_DOUBLE_ARROW="⇒";var SYMBOL_FOR_HORIZONTAL_TABULATION="␉";var SYMBOL_FOR_LINE_FEED="␊";var SYMBOL_FOR_CARRIAGE_RETURN="␍";function spaces(n){return common.repeat(" ",n).join("")}function getInputExcerpt(inputStream,pos,len){var excerpt=asEscapedString(inputStream.sourceSlice(pos,pos+len));if(excerpt.length0){arr.push(fn())}return arr};exports.repeatStr=function(str,n){return new Array(n+1).join(str)};exports.repeat=function(x,n){return exports.repeatFn(function(){return x},n)};exports.getDuplicates=function(array){var duplicates=[];for(var idx=0;idx1){throw multipleErrors(errors)}}}},{"./Namespace":36}],43:[function(require,module,exports){"use strict";var Builder=require("./Builder");var Grammar=require("./Grammar");var Namespace=require("./Namespace");var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");var util=require("./util");var isBuffer=require("is-buffer");var ohmGrammar;var documentInterface={querySelector:function(sel){return document.querySelector(sel)},querySelectorAll:function(sel){return document.querySelectorAll(sel)}};function isElement(obj){return!!(obj&&obj.nodeType===1)}function isUndefined(obj){return obj===void 0}var MAX_ARRAY_INDEX=Math.pow(2,53)-1;function isArrayLike(obj){if(obj==null){return false}var length=obj.length;return typeof length==="number"&&length>=0&&length<=MAX_ARRAY_INDEX}function load(url){var req=new XMLHttpRequest;req.open("GET",url,false);try{req.send();if(req.status===0||req.status===200){return req.responseText}}catch(e){}throw new Error("unable to load url "+url)}function buildGrammar(match,namespace,optOhmGrammarForTesting){var builder=new Builder;var decl;var currentRuleName;var currentRuleFormals;var overriding=false;var metaGrammar=optOhmGrammarForTesting||ohmGrammar;var helpers=metaGrammar.createSemantics().addOperation("visit",{Grammar:function(n,s,open,rs,close){var grammarName=n.visit();decl=builder.newGrammar(grammarName,namespace);s.visit();rs.visit();var g=decl.build();g.source=this.source.trimmed();if(grammarName in namespace){throw errors.duplicateGrammarDeclaration(g,namespace)}namespace[grammarName]=g;return g},SuperGrammar:function(_,n){var superGrammarName=n.visit();if(superGrammarName==="null"){decl.withSuperGrammar(null)}else{if(!namespace||!(superGrammarName in namespace)){throw errors.undeclaredGrammar(superGrammarName,namespace,n.source)}decl.withSuperGrammar(namespace[superGrammarName])}},Rule_define:function(n,fs,d,_,b){currentRuleName=n.visit();currentRuleFormals=fs.visit()[0]||[];if(!decl.defaultStartRule&&decl.ensureSuperGrammar()!==Grammar.ProtoBuiltInRules){decl.withDefaultStartRule(currentRuleName)}var body=b.visit();var description=d.visit()[0];var source=this.source.trimmed();return decl.define(currentRuleName,currentRuleFormals,body,description,source)},Rule_override:function(n,fs,_,b){currentRuleName=n.visit();currentRuleFormals=fs.visit()[0]||[];overriding=true;var body=b.visit();var source=this.source.trimmed();var ans=decl.override(currentRuleName,currentRuleFormals,body,null,source);overriding=false;return ans},Rule_extend:function(n,fs,_,b){currentRuleName=n.visit();currentRuleFormals=fs.visit()[0]||[];var body=b.visit();var source=this.source.trimmed();var ans=decl.extend(currentRuleName,currentRuleFormals,body,null,source);return ans},RuleBody:function(_,terms){var args=terms.visit();return builder.alt.apply(builder,args).withSource(this.source)},Formals:function(opointy,fs,cpointy){return fs.visit()},Params:function(opointy,ps,cpointy){return ps.visit()},Alt:function(seqs){var args=seqs.visit();return builder.alt.apply(builder,args).withSource(this.source)},TopLevelTerm_inline:function(b,n){var inlineRuleName=currentRuleName+"_"+n.visit();var body=b.visit();var source=this.source.trimmed();var isNewRuleDeclaration=!(decl.superGrammar&&decl.superGrammar.rules[inlineRuleName]);if(overriding&&!isNewRuleDeclaration){decl.override(inlineRuleName,currentRuleFormals,body,null,source)}else{decl.define(inlineRuleName,currentRuleFormals,body,null,source)}var params=currentRuleFormals.map(function(formal){return builder.app(formal)});return builder.app(inlineRuleName,params).withSource(body.source)},Seq:function(expr){return builder.seq.apply(builder,expr.visit()).withSource(this.source)},Iter_star:function(x,_){return builder.star(x.visit()).withSource(this.source)},Iter_plus:function(x,_){return builder.plus(x.visit()).withSource(this.source)},Iter_opt:function(x,_){return builder.opt(x.visit()).withSource(this.source)},Pred_not:function(_,x){return builder.not(x.visit()).withSource(this.source)},Pred_lookahead:function(_,x){return builder.lookahead(x.visit()).withSource(this.source)},Lex_lex:function(_,x){return builder.lex(x.visit()).withSource(this.source)},Base_application:function(rule,ps){return builder.app(rule.visit(),ps.visit()[0]||[]).withSource(this.source)},Base_range:function(from,_,to){return builder.range(from.visit(),to.visit()).withSource(this.source)},Base_terminal:function(expr){return builder.terminal(expr.visit()).withSource(this.source)},Base_paren:function(open,x,close){return x.visit()},ruleDescr:function(open,t,close){return t.visit()},ruleDescrText:function(_){return this.sourceString.trim()},caseName:function(_,space1,n,space2,end){return n.visit()},name:function(first,rest){return this.sourceString},nameFirst:function(expr){},nameRest:function(expr){},terminal:function(open,cs,close){return cs.visit().map(function(c){return common.unescapeChar(c)}).join("")},terminalChar:function(_){return this.sourceString},escapeChar:function(_){return this.sourceString},NonemptyListOf:function(x,_,xs){return[x.visit()].concat(xs.visit())},EmptyListOf:function(){return[]},_terminal:function(){return this.primitiveValue}});return helpers(match).visit()}function compileAndLoad(source,namespace){var m=ohmGrammar.match(source,"Grammars");if(m.failed()){throw errors.grammarSyntaxError(m)}return buildGrammar(m,namespace)}function getScriptElementContents(el){if(!isElement(el)){throw new TypeError("Expected a DOM Node, got "+common.unexpectedObjToString(el))}if(el.type!=="text/ohm-js"){throw new Error('Expected a script tag with type="text/ohm-js", got '+el)}return el.getAttribute("src")?load(el.getAttribute("src")):el.innerHTML}function grammar(source,optNamespace){var ns=grammars(source,optNamespace);var grammarNames=Object.keys(ns);if(grammarNames.length===0){throw new Error("Missing grammar definition")}else if(grammarNames.length>1){var secondGrammar=ns[grammarNames[1]];var interval=secondGrammar.source;throw new Error(util.getLineAndColumnMessage(interval.inputStream.source,interval.startIdx)+"Found more than one grammar definition -- use ohm.grammars() instead.")}return ns[grammarNames[0]]}function grammars(source,optNamespace){var ns=Namespace.extend(Namespace.asNamespace(optNamespace));if(typeof source!=="string"){if(isBuffer(source)){source=source.toString()}else{throw new TypeError("Expected string as first argument, got "+common.unexpectedObjToString(source))}}compileAndLoad(source,ns);return ns}function grammarFromScriptElement(optNode){var node=optNode;if(isUndefined(node)){var nodeList=documentInterface.querySelectorAll('script[type="text/ohm-js"]');if(nodeList.length!==1){throw new Error('Expected exactly one script tag with type="text/ohm-js", found '+nodeList.length)}node=nodeList[0]}return grammar(getScriptElementContents(node))}function grammarsFromScriptElements(optNodeOrNodeList){if(isElement(optNodeOrNodeList)){return grammars(optNodeOrNodeList)}var nodeList=optNodeOrNodeList;if(isUndefined(nodeList)){nodeList=documentInterface.querySelectorAll('script[type="text/ohm-js"]')}else if(typeof nodeList==="string"||!isElement(nodeList)&&!isArrayLike(nodeList)){throw new TypeError("Expected a Node, NodeList, or Array, but got "+nodeList)}var ns=Namespace.createNamespace();for(var i=0;i0};Node.prototype.hasNoChildren=function(){return!this.hasChildren()};Node.prototype.onlyChild=function(){if(this.children.length!==1){throw new Error("cannot get only child of a node of type "+this.ctorName+" (it has "+this.numChildren()+" children)")}else{return this.firstChild()}};Node.prototype.firstChild=function(){if(this.hasNoChildren()){throw new Error("cannot get first child of a "+this.ctorName+" node, which has no children")}else{return this.childAt(0)}};Node.prototype.lastChild=function(){if(this.hasNoChildren()){throw new Error("cannot get last child of a "+this.ctorName+" node, which has no children")}else{return this.childAt(this.numChildren()-1)}};Node.prototype.childBefore=function(child){var childIdx=this.indexOfChild(child);if(childIdx<0){throw new Error("Node.childBefore() called w/ an argument that is not a child")}else if(childIdx===0){throw new Error("cannot get child before first child")}else{return this.childAt(childIdx-1)}};Node.prototype.childAfter=function(child){var childIdx=this.indexOfChild(child);if(childIdx<0){throw new Error("Node.childAfter() called w/ an argument that is not a child")}else if(childIdx===this.numChildren()-1){throw new Error("cannot get child after last child")}else{return this.childAt(childIdx+1)}};Node.prototype.isTerminal=function(){return false};Node.prototype.isNonterminal=function(){return false};Node.prototype.isIteration=function(){return false};Node.prototype.isOptional=function(){return false};Node.prototype.toJSON=function(){var r={};r[this.ctorName]=this.children;return r};function TerminalNode(grammar,value,source){Node.call(this,grammar,"_terminal",[],source);this.primitiveValue=value}inherits(TerminalNode,Node);TerminalNode.prototype.isTerminal=function(){return true};TerminalNode.prototype.toJSON=function(){var r={};r[this.ctorName]=this.primitiveValue;return r};function NonterminalNode(grammar,ruleName,children,source){Node.call(this,grammar,ruleName,children,source)}inherits(NonterminalNode,Node);NonterminalNode.prototype.isNonterminal=function(){return true};NonterminalNode.prototype.isLexical=function(){return common.isLexical(this.ctorName)};NonterminalNode.prototype.isSyntactic=function(){return common.isSyntactic(this.ctorName)};function IterationNode(grammar,children,source,optional){Node.call(this,grammar,"_iter",children,source);this.optional=optional}inherits(IterationNode,Node);IterationNode.prototype.isIteration=function(){return true};IterationNode.prototype.isOptional=function(){return this.optional};module.exports={Node:Node,TerminalNode:TerminalNode,NonterminalNode:NonterminalNode,IterationNode:IterationNode}},{"./common":41,inherits:25}],45:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");pexprs.PExpr.prototype.allowsSkippingPrecedingSpace=common.abstract("allowsSkippingPrecedingSpace");pexprs.any.allowsSkippingPrecedingSpace=pexprs.end.allowsSkippingPrecedingSpace=pexprs.Apply.prototype.allowsSkippingPrecedingSpace=pexprs.Terminal.prototype.allowsSkippingPrecedingSpace=pexprs.Range.prototype.allowsSkippingPrecedingSpace=pexprs.UnicodeChar.prototype.allowsSkippingPrecedingSpace=function(){return true};pexprs.Alt.prototype.allowsSkippingPrecedingSpace=pexprs.Iter.prototype.allowsSkippingPrecedingSpace=pexprs.Lex.prototype.allowsSkippingPrecedingSpace=pexprs.Lookahead.prototype.allowsSkippingPrecedingSpace=pexprs.Not.prototype.allowsSkippingPrecedingSpace=pexprs.Param.prototype.allowsSkippingPrecedingSpace=pexprs.Seq.prototype.allowsSkippingPrecedingSpace=function(){return false}},{"./common":41,"./pexprs":61}],46:[function(require,module,exports){"use strict";var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");var lexifyCount;pexprs.PExpr.prototype.assertAllApplicationsAreValid=function(ruleName,grammar){lexifyCount=0;this._assertAllApplicationsAreValid(ruleName,grammar)};pexprs.PExpr.prototype._assertAllApplicationsAreValid=common.abstract("_assertAllApplicationsAreValid");pexprs.any._assertAllApplicationsAreValid=pexprs.end._assertAllApplicationsAreValid=pexprs.Terminal.prototype._assertAllApplicationsAreValid=pexprs.Range.prototype._assertAllApplicationsAreValid=pexprs.Param.prototype._assertAllApplicationsAreValid=pexprs.UnicodeChar.prototype._assertAllApplicationsAreValid=function(ruleName,grammar){};pexprs.Lex.prototype._assertAllApplicationsAreValid=function(ruleName,grammar){lexifyCount++;this.expr._assertAllApplicationsAreValid(ruleName,grammar);lexifyCount--};pexprs.Alt.prototype._assertAllApplicationsAreValid=function(ruleName,grammar){for(var idx=0;idx0)){throw errors.applicationOfSyntacticRuleFromLexicalContext(this.ruleName,this)}var actual=this.args.length;var expected=ruleInfo.formals.length;if(actual!==expected){throw errors.wrongNumberOfArguments(this.ruleName,expected,actual,this.source)}var self=this;this.args.forEach(function(arg){arg._assertAllApplicationsAreValid(ruleName,grammar);if(arg.getArity()!==1){throw errors.invalidParameter(self.ruleName,arg)}})}},{"./common":41,"./errors":42,"./pexprs":61}],47:[function(require,module,exports){"use strict";var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");pexprs.PExpr.prototype.assertChoicesHaveUniformArity=common.abstract("assertChoicesHaveUniformArity");pexprs.any.assertChoicesHaveUniformArity=pexprs.end.assertChoicesHaveUniformArity=pexprs.Terminal.prototype.assertChoicesHaveUniformArity=pexprs.Range.prototype.assertChoicesHaveUniformArity=pexprs.Param.prototype.assertChoicesHaveUniformArity=pexprs.Lex.prototype.assertChoicesHaveUniformArity=pexprs.UnicodeChar.prototype.assertChoicesHaveUniformArity=function(ruleName){};pexprs.Alt.prototype.assertChoicesHaveUniformArity=function(ruleName){if(this.terms.length===0){return}var arity=this.terms[0].getArity();for(var idx=0;idx=1};pexprs.end.check=function(grammar,vals){return vals[0]instanceof nodes.Node&&vals[0].isTerminal()&&vals[0].primitiveValue===undefined};pexprs.Terminal.prototype.check=function(grammar,vals){return vals[0]instanceof nodes.Node&&vals[0].isTerminal()&&vals[0].primitiveValue===this.obj};pexprs.Range.prototype.check=function(grammar,vals){return vals[0]instanceof nodes.Node&&vals[0].isTerminal()&&typeof vals[0].primitiveValue===typeof this.from};pexprs.Param.prototype.check=function(grammar,vals){return vals.length>=1};pexprs.Alt.prototype.check=function(grammar,vals){for(var i=0;i0){var i=Math.floor(Math.random()*successfulExamples.length);ans.value=successfulExamples[i]}if(examplesNeeded.length>0){ans.examplesNeeded=examplesNeeded}ans.needHelp=needHelp;return ans};pexprs.Seq.prototype.generateExample=function(grammar,examples,inSyntacticContext,actuals){var factorExamples=this.factors.map(function(factor){return factor.generateExample(grammar,examples,inSyntacticContext,actuals)});var categorizedExamples=categorizeExamples(factorExamples);var examplesNeeded=categorizedExamples.examplesNeeded;var successfulExamples=categorizedExamples.successfulExamples;var needHelp=categorizedExamples.needHelp;var ans={};if(examplesNeeded.length>0||needHelp){ans.examplesNeeded=examplesNeeded;ans.needHelp=needHelp}else{ans.value=successfulExamples.join(inSyntacticContext?" ":"")}return ans};pexprs.Iter.prototype.generateExample=function(grammar,examples,inSyntacticContext,actuals){ -var rangeTimes=Math.min(this.maxNumMatches-this.minNumMatches,3);var numTimes=Math.floor(Math.random()*(rangeTimes+1)+this.minNumMatches);var items=[];for(var i=0;i0){ans.examplesNeeded=examplesNeeded}return ans};pexprs.Not.prototype.generateExample=function(grammar,examples,inSyntacticContext){return{value:""}};pexprs.Lookahead.prototype.generateExample=function(grammar,examples,inSyntacticContext){return{value:""}};pexprs.Lex.prototype.generateExample=function(grammar,examples,inSyntacticContext,actuals){return this.expr.generateExample(grammar,examples,false,actuals)};pexprs.Apply.prototype.generateExample=function(grammar,examples,inSyntacticContext,actuals){var ans={};var ruleName=this.substituteParams(actuals).toString();if(!examples.hasOwnProperty(ruleName)){ans.examplesNeeded=[ruleName]}else{var relevantExamples=examples[ruleName];var i=Math.floor(Math.random()*relevantExamples.length);ans.value=relevantExamples[i]}return ans};pexprs.UnicodeChar.prototype.generateExample=function(grammar,examples,inSyntacticContext,actuals){var char;switch(this.category){case"Lu":char="Á";break;case"Ll":char="ŏ";break;case"Lt":char="Dž";break;case"Lm":char="ˮ";break;case"Lo":char="ƻ";break;case"Nl":char="ↂ";break;case"Nd":char="½";break;case"Mn":char="҇";break;case"Mc":char="ि";break;case"Pc":char="⁀";break;case"Zs":char=" ";break;case"L":char="Á";break;case"Ltmo":char="Dž";break}return{value:char}}},{"./common":41,"./pexprs":61}],52:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");pexprs.PExpr.prototype.getArity=common.abstract("getArity");pexprs.any.getArity=pexprs.end.getArity=pexprs.Terminal.prototype.getArity=pexprs.Range.prototype.getArity=pexprs.Param.prototype.getArity=pexprs.Apply.prototype.getArity=pexprs.UnicodeChar.prototype.getArity=function(){return 1};pexprs.Alt.prototype.getArity=function(){return this.terms.length===0?0:this.terms[0].getArity()};pexprs.Seq.prototype.getArity=function(){var arity=0;for(var idx=0;idx=0){if(this.args.length>0){throw new Error("Parameterized rules cannot be passed as arguments to another rule.")}return new pexprs.Param(index)}else{this.args.forEach(function(arg,idx,args){args[idx]=arg.introduceParams(formals)});return this}}},{"./common":41,"./pexprs":61}],54:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");pexprs.PExpr.prototype.isNullable=function(grammar){return this._isNullable(grammar,Object.create(null))};pexprs.PExpr.prototype._isNullable=common.abstract("_isNullable");pexprs.any._isNullable=pexprs.Range.prototype._isNullable=pexprs.Param.prototype._isNullable=pexprs.Plus.prototype._isNullable=pexprs.UnicodeChar.prototype._isNullable=function(grammar,memo){return false};pexprs.end._isNullable=function(grammar,memo){return true};pexprs.Terminal.prototype._isNullable=function(grammar,memo){if(typeof this.obj==="string"){return this.obj===""}else{return false}};pexprs.Alt.prototype._isNullable=function(grammar,memo){return this.terms.length===0||this.terms.some(function(term){return term._isNullable(grammar,memo)})};pexprs.Seq.prototype._isNullable=function(grammar,memo){return this.factors.every(function(factor){return factor._isNullable(grammar,memo)})};pexprs.Star.prototype._isNullable=pexprs.Opt.prototype._isNullable=pexprs.Not.prototype._isNullable=pexprs.Lookahead.prototype._isNullable=function(grammar,memo){return true};pexprs.Lex.prototype._isNullable=function(grammar,memo){return this.expr._isNullable(grammar,memo)};pexprs.Apply.prototype._isNullable=function(grammar,memo){var key=this.toMemoKey();if(!Object.prototype.hasOwnProperty.call(memo,key)){var body=grammar.rules[this.ruleName].body;var inlined=body.substituteParams(this.args);memo[key]=false;memo[key]=inlined._isNullable(grammar,memo)}return memo[key]}},{"./common":41,"./pexprs":61}],55:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");function getMetaInfo(expr,grammarInterval){var metaInfo={};if(expr.source&&grammarInterval){var adjusted=expr.source.relativeTo(grammarInterval);metaInfo.sourceInterval=[adjusted.startIdx,adjusted.endIdx]}return metaInfo}pexprs.PExpr.prototype.outputRecipe=common.abstract("outputRecipe");pexprs.any.outputRecipe=function(formals,grammarInterval){return["any",getMetaInfo(this,grammarInterval)]};pexprs.end.outputRecipe=function(formals,grammarInterval){return["end",getMetaInfo(this,grammarInterval)]};pexprs.Terminal.prototype.outputRecipe=function(formals,grammarInterval){return["terminal",getMetaInfo(this,grammarInterval),this.obj]};pexprs.Range.prototype.outputRecipe=function(formals,grammarInterval){return["range",getMetaInfo(this,grammarInterval),this.from,this.to]};pexprs.Param.prototype.outputRecipe=function(formals,grammarInterval){return["param",getMetaInfo(this,grammarInterval),this.index]};pexprs.Alt.prototype.outputRecipe=function(formals,grammarInterval){return["alt",getMetaInfo(this,grammarInterval)].concat(this.terms.map(function(term){return term.outputRecipe(formals,grammarInterval)}))};pexprs.Extend.prototype.outputRecipe=function(formals,grammarInterval){var extension=this.terms[0];return extension.outputRecipe(formals,grammarInterval)};pexprs.Seq.prototype.outputRecipe=function(formals,grammarInterval){return["seq",getMetaInfo(this,grammarInterval)].concat(this.factors.map(function(factor){return factor.outputRecipe(formals,grammarInterval)}))};pexprs.Star.prototype.outputRecipe=pexprs.Plus.prototype.outputRecipe=pexprs.Opt.prototype.outputRecipe=pexprs.Not.prototype.outputRecipe=pexprs.Lookahead.prototype.outputRecipe=pexprs.Lex.prototype.outputRecipe=function(formals,grammarInterval){return[this.constructor.name.toLowerCase(),getMetaInfo(this,grammarInterval),this.expr.outputRecipe(formals,grammarInterval)]};pexprs.Apply.prototype.outputRecipe=function(formals,grammarInterval){return["app",getMetaInfo(this,grammarInterval),this.ruleName,this.args.map(function(arg){return arg.outputRecipe(formals,grammarInterval)})]};pexprs.UnicodeChar.prototype.outputRecipe=function(formals,grammarInterval){return["unicodeChar",getMetaInfo(this,grammarInterval),this.category]}},{"./common":41,"./pexprs":61}],56:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");pexprs.PExpr.prototype.substituteParams=common.abstract("substituteParams");pexprs.any.substituteParams=pexprs.end.substituteParams=pexprs.Terminal.prototype.substituteParams=pexprs.Range.prototype.substituteParams=pexprs.UnicodeChar.prototype.substituteParams=function(actuals){return this};pexprs.Param.prototype.substituteParams=function(actuals){return actuals[this.index]};pexprs.Alt.prototype.substituteParams=function(actuals){return new pexprs.Alt(this.terms.map(function(term){return term.substituteParams(actuals)}))};pexprs.Seq.prototype.substituteParams=function(actuals){return new pexprs.Seq(this.factors.map(function(factor){return factor.substituteParams(actuals)}))};pexprs.Iter.prototype.substituteParams=pexprs.Not.prototype.substituteParams=pexprs.Lookahead.prototype.substituteParams=pexprs.Lex.prototype.substituteParams=function(actuals){return new this.constructor(this.expr.substituteParams(actuals))};pexprs.Apply.prototype.substituteParams=function(actuals){if(this.args.length===0){return this}else{var args=this.args.map(function(arg){return arg.substituteParams(actuals)});return new pexprs.Apply(this.ruleName,args)}}},{"./common":41,"./pexprs":61}],57:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");var copyWithoutDuplicates=common.copyWithoutDuplicates;function isRestrictedJSIdentifier(str){return/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(str)}function resolveDuplicatedNames(argumentNameList){var count=Object.create(null);argumentNameList.forEach(function(argName){count[argName]=(count[argName]||0)+1});Object.keys(count).forEach(function(dupArgName){if(count[dupArgName]<=1){return}var subscript=1;argumentNameList.forEach(function(argName,idx){if(argName===dupArgName){argumentNameList[idx]=argName+"_"+subscript++}})})}pexprs.PExpr.prototype.toArgumentNameList=common.abstract("toArgumentNameList");pexprs.any.toArgumentNameList=function(firstArgIndex,noDupCheck){return["any"]};pexprs.end.toArgumentNameList=function(firstArgIndex,noDupCheck){return["end"]};pexprs.Terminal.prototype.toArgumentNameList=function(firstArgIndex,noDupCheck){if(typeof this.obj==="string"&&/^[_a-zA-Z0-9]+$/.test(this.obj)){return["_"+this.obj]}else{return["$"+firstArgIndex]}};pexprs.Range.prototype.toArgumentNameList=function(firstArgIndex,noDupCheck){var argName=this.from+"_to_"+this.to;if(!isRestrictedJSIdentifier(argName)){argName="_"+argName}if(!isRestrictedJSIdentifier(argName)){argName="$"+firstArgIndex}return[argName]};pexprs.Alt.prototype.toArgumentNameList=function(firstArgIndex,noDupCheck){var termArgNameLists=this.terms.map(function(term){return term.toArgumentNameList(firstArgIndex,true)});var argumentNameList=[];var numArgs=termArgNameLists[0].length;for(var colIdx=0;colIdx0){var ps=this.args.map(function(arg){return arg.toString()});return this.ruleName+"<"+ps.join(",")+">"}else{return this.ruleName}};pexprs.UnicodeChar.prototype.toString=function(){return"\\p{"+this.category+"}"}},{"./common":41,"./pexprs":61}],61:[function(require,module,exports){"use strict";var UnicodeCategories=require("../third_party/UnicodeCategories");var common=require("./common");var errors=require("./errors");var inherits=require("inherits");function PExpr(){throw new Error("PExpr cannot be instantiated -- it's abstract")}PExpr.prototype.withSource=function(interval){if(interval){this.source=interval.trimmed()}return this};var any=Object.create(PExpr.prototype);var end=Object.create(PExpr.prototype);function Terminal(obj){this.obj=obj}inherits(Terminal,PExpr);function Range(from,to){this.from=from;this.to=to}inherits(Range,PExpr);function Param(index){this.index=index}inherits(Param,PExpr);function Alt(terms){this.terms=terms}inherits(Alt,PExpr);function Extend(superGrammar,name,body){this.superGrammar=superGrammar;this.name=name;this.body=body;var origBody=superGrammar.rules[name].body;this.terms=[body,origBody]}inherits(Extend,Alt);function Seq(factors){this.factors=factors}inherits(Seq,PExpr);function Iter(expr){this.expr=expr}inherits(Iter,PExpr);function Star(expr){this.expr=expr}inherits(Star,Iter);function Plus(expr){this.expr=expr}inherits(Plus,Iter);function Opt(expr){this.expr=expr}inherits(Opt,Iter);Star.prototype.operator="*";Plus.prototype.operator="+";Opt.prototype.operator="?";Star.prototype.minNumMatches=0;Plus.prototype.minNumMatches=1;Opt.prototype.minNumMatches=0;Star.prototype.maxNumMatches=Number.POSITIVE_INFINITY;Plus.prototype.maxNumMatches=Number.POSITIVE_INFINITY;Opt.prototype.maxNumMatches=1;function Not(expr){this.expr=expr}inherits(Not,PExpr);function Lookahead(expr){this.expr=expr}inherits(Lookahead,PExpr);function Lex(expr){this.expr=expr}inherits(Lex,PExpr);function Arr(expr){this.expr=expr}inherits(Arr,PExpr);function Str(expr){this.expr=expr}inherits(Str,PExpr);function Obj(properties,isLenient){var names=properties.map(function(property){return property.name});var duplicates=common.getDuplicates(names);if(duplicates.length>0){throw errors.duplicatePropertyNames(duplicates)}else{this.properties=properties;this.isLenient=isLenient}}inherits(Obj,PExpr);function Apply(ruleName,optArgs){this.ruleName=ruleName;this.args=optArgs||[]}inherits(Apply,PExpr);Apply.prototype.isSyntactic=function(){return common.isSyntactic(this.ruleName)};Apply.prototype.toMemoKey=function(){if(!this._memoKey){Object.defineProperty(this,"_memoKey",{value:this.toString()})}return this._memoKey};function UnicodeChar(category){this.category=category;this.pattern=UnicodeCategories[category]}inherits(UnicodeChar,PExpr);exports.PExpr=PExpr;exports.any=any;exports.end=end;exports.Terminal=Terminal;exports.Range=Range;exports.Param=Param;exports.Alt=Alt;exports.Extend=Extend;exports.Seq=Seq;exports.Iter=Iter;exports.Star=Star;exports.Plus=Plus;exports.Opt=Opt;exports.Not=Not;exports.Lookahead=Lookahead;exports.Lex=Lex;exports.Arr=Arr;exports.Str=Str;exports.Obj=Obj;exports.Apply=Apply;exports.UnicodeChar=UnicodeChar;require("./pexprs-allowsSkippingPrecedingSpace");require("./pexprs-assertAllApplicationsAreValid");require("./pexprs-assertChoicesHaveUniformArity");require("./pexprs-assertIteratedExprsAreNotNullable");require("./pexprs-check");require("./pexprs-eval");require("./pexprs-getArity");require("./pexprs-generateExample");require("./pexprs-outputRecipe");require("./pexprs-introduceParams");require("./pexprs-isNullable");require("./pexprs-substituteParams");require("./pexprs-toDisplayString");require("./pexprs-toArgumentNameList");require("./pexprs-toFailure");require("./pexprs-toString")},{"../third_party/UnicodeCategories":63,"./common":41,"./errors":42,"./pexprs-allowsSkippingPrecedingSpace":45,"./pexprs-assertAllApplicationsAreValid":46,"./pexprs-assertChoicesHaveUniformArity":47,"./pexprs-assertIteratedExprsAreNotNullable":48,"./pexprs-check":49,"./pexprs-eval":50,"./pexprs-generateExample":51,"./pexprs-getArity":52,"./pexprs-introduceParams":53,"./pexprs-isNullable":54,"./pexprs-outputRecipe":55,"./pexprs-substituteParams":56,"./pexprs-toArgumentNameList":57,"./pexprs-toDisplayString":58,"./pexprs-toFailure":59,"./pexprs-toString":60,inherits:25}],62:[function(require,module,exports){"use strict";var common=require("./common");function padNumbersToEqualLength(arr){var maxLen=0;var strings=arr.map(function(n){var str=n.toString();maxLen=Math.max(maxLen,str.length);return str});return strings.map(function(s){return common.padLeft(s,maxLen)})}function strcpy(dest,src,offset){var origDestLen=dest.length;var start=dest.slice(0,offset);var end=dest.slice(offset+src.length);return(start+src+end).substr(0,origDestLen)}exports.getLineAndColumn=function(str,offset){var lineNum=1;var colNum=1;var currOffset=0;var lineStartOffset=0;var nextLine=null;var prevLine=null;var prevLineStartOffset=-1;while(currOffset=0){prevLine=str.slice(prevLineStartOffset,lineStartOffset).replace(/\r?\n$/,"")}var line=str.slice(lineStartOffset,lineEndOffset).replace(/\r$/,"");return{lineNum:lineNum,colNum:colNum,line:line,prevLine:prevLine,nextLine:nextLine}};exports.getLineAndColumnMessage=function(str,offset){var repeatStr=common.repeatStr;var lineAndCol=exports.getLineAndColumn(str,offset);var sb=new common.StringBuffer;sb.append("Line "+lineAndCol.lineNum+", col "+lineAndCol.colNum+":\n");var lineNumbers=padNumbersToEqualLength([lineAndCol.prevLine==null?0:lineAndCol.lineNum-1,lineAndCol.lineNum,lineAndCol.nextLine==null?0:lineAndCol.lineNum+1]);function appendLine(num,content,prefix){sb.append(prefix+lineNumbers[num]+" | "+content+"\n")}if(lineAndCol.prevLine!=null){appendLine(0,lineAndCol.prevLine," ")}appendLine(1,lineAndCol.line,"> ");var lineLen=lineAndCol.line.length;var indicationLine=repeatStr(" ",lineLen+1);var ranges=Array.prototype.slice.call(arguments,2);for(var i=0;i=0&&startIdx<=endIdx,"range start must be >= 0 and <= end");var lineStartOffset=offset-lineAndCol.colNum+1;startIdx=Math.max(0,startIdx-lineStartOffset);endIdx=Math.min(endIdx-lineStartOffset,lineLen);indicationLine=strcpy(indicationLine,repeatStr("~",endIdx-startIdx),startIdx)}var gutterWidth=2+lineNumbers[1].length+3;sb.append(repeatStr(" ",gutterWidth));indicationLine=strcpy(indicationLine,"^",lineAndCol.colNum-1);sb.append(indicationLine.replace(/ +$/,"")+"\n");if(lineAndCol.nextLine!=null){appendLine(2,lineAndCol.nextLine," ")}return sb.contents()}},{"./common":41}],63:[function(require,module,exports){module.exports={Lu:/[\u0041-\u005A]|[\u00C0-\u00D6]|[\u00D8-\u00DE]|[\u0100-\u0100]|[\u0102-\u0102]|[\u0104-\u0104]|[\u0106-\u0106]|[\u0108-\u0108]|[\u010A-\u010A]|[\u010C-\u010C]|[\u010E-\u010E]|[\u0110-\u0110]|[\u0112-\u0112]|[\u0114-\u0114]|[\u0116-\u0116]|[\u0118-\u0118]|[\u011A-\u011A]|[\u011C-\u011C]|[\u011E-\u011E]|[\u0120-\u0120]|[\u0122-\u0122]|[\u0124-\u0124]|[\u0126-\u0126]|[\u0128-\u0128]|[\u012A-\u012A]|[\u012C-\u012C]|[\u012E-\u012E]|[\u0130-\u0130]|[\u0132-\u0132]|[\u0134-\u0134]|[\u0136-\u0136]|[\u0139-\u0139]|[\u013B-\u013B]|[\u013D-\u013D]|[\u013F-\u013F]|[\u0141-\u0141]|[\u0143-\u0143]|[\u0145-\u0145]|[\u0147-\u0147]|[\u014A-\u014A]|[\u014C-\u014C]|[\u014E-\u014E]|[\u0150-\u0150]|[\u0152-\u0152]|[\u0154-\u0154]|[\u0156-\u0156]|[\u0158-\u0158]|[\u015A-\u015A]|[\u015C-\u015C]|[\u015E-\u015E]|[\u0160-\u0160]|[\u0162-\u0162]|[\u0164-\u0164]|[\u0166-\u0166]|[\u0168-\u0168]|[\u016A-\u016A]|[\u016C-\u016C]|[\u016E-\u016E]|[\u0170-\u0170]|[\u0172-\u0172]|[\u0174-\u0174]|[\u0176-\u0176]|[\u0178-\u0179]|[\u017B-\u017B]|[\u017D-\u017D]|[\u0181-\u0182]|[\u0184-\u0184]|[\u0186-\u0187]|[\u0189-\u018B]|[\u018E-\u0191]|[\u0193-\u0194]|[\u0196-\u0198]|[\u019C-\u019D]|[\u019F-\u01A0]|[\u01A2-\u01A2]|[\u01A4-\u01A4]|[\u01A6-\u01A7]|[\u01A9-\u01A9]|[\u01AC-\u01AC]|[\u01AE-\u01AF]|[\u01B1-\u01B3]|[\u01B5-\u01B5]|[\u01B7-\u01B8]|[\u01BC-\u01BC]|[\u01C4-\u01C4]|[\u01C7-\u01C7]|[\u01CA-\u01CA]|[\u01CD-\u01CD]|[\u01CF-\u01CF]|[\u01D1-\u01D1]|[\u01D3-\u01D3]|[\u01D5-\u01D5]|[\u01D7-\u01D7]|[\u01D9-\u01D9]|[\u01DB-\u01DB]|[\u01DE-\u01DE]|[\u01E0-\u01E0]|[\u01E2-\u01E2]|[\u01E4-\u01E4]|[\u01E6-\u01E6]|[\u01E8-\u01E8]|[\u01EA-\u01EA]|[\u01EC-\u01EC]|[\u01EE-\u01EE]|[\u01F1-\u01F1]|[\u01F4-\u01F4]|[\u01FA-\u01FA]|[\u01FC-\u01FC]|[\u01FE-\u01FE]|[\u0200-\u0200]|[\u0202-\u0202]|[\u0204-\u0204]|[\u0206-\u0206]|[\u0208-\u0208]|[\u020A-\u020A]|[\u020C-\u020C]|[\u020E-\u020E]|[\u0210-\u0210]|[\u0212-\u0212]|[\u0214-\u0214]|[\u0216-\u0216]|[\u0386-\u0386]|[\u0388-\u038A]|[\u038C-\u038C]|[\u038E-\u038F]|[\u0391-\u03A1]|[\u03A3-\u03AB]|[\u03D2-\u03D4]|[\u03DA-\u03DA]|[\u03DC-\u03DC]|[\u03DE-\u03DE]|[\u03E0-\u03E0]|[\u03E2-\u03E2]|[\u03E4-\u03E4]|[\u03E6-\u03E6]|[\u03E8-\u03E8]|[\u03EA-\u03EA]|[\u03EC-\u03EC]|[\u03EE-\u03EE]|[\u0401-\u040C]|[\u040E-\u042F]|[\u0460-\u0460]|[\u0462-\u0462]|[\u0464-\u0464]|[\u0466-\u0466]|[\u0468-\u0468]|[\u046A-\u046A]|[\u046C-\u046C]|[\u046E-\u046E]|[\u0470-\u0470]|[\u0472-\u0472]|[\u0474-\u0474]|[\u0476-\u0476]|[\u0478-\u0478]|[\u047A-\u047A]|[\u047C-\u047C]|[\u047E-\u047E]|[\u0480-\u0480]|[\u0490-\u0490]|[\u0492-\u0492]|[\u0494-\u0494]|[\u0496-\u0496]|[\u0498-\u0498]|[\u049A-\u049A]|[\u049C-\u049C]|[\u049E-\u049E]|[\u04A0-\u04A0]|[\u04A2-\u04A2]|[\u04A4-\u04A4]|[\u04A6-\u04A6]|[\u04A8-\u04A8]|[\u04AA-\u04AA]|[\u04AC-\u04AC]|[\u04AE-\u04AE]|[\u04B0-\u04B0]|[\u04B2-\u04B2]|[\u04B4-\u04B4]|[\u04B6-\u04B6]|[\u04B8-\u04B8]|[\u04BA-\u04BA]|[\u04BC-\u04BC]|[\u04BE-\u04BE]|[\u04C1-\u04C1]|[\u04C3-\u04C3]|[\u04C7-\u04C7]|[\u04CB-\u04CB]|[\u04D0-\u04D0]|[\u04D2-\u04D2]|[\u04D4-\u04D4]|[\u04D6-\u04D6]|[\u04D8-\u04D8]|[\u04DA-\u04DA]|[\u04DC-\u04DC]|[\u04DE-\u04DE]|[\u04E0-\u04E0]|[\u04E2-\u04E2]|[\u04E4-\u04E4]|[\u04E6-\u04E6]|[\u04E8-\u04E8]|[\u04EA-\u04EA]|[\u04EE-\u04EE]|[\u04F0-\u04F0]|[\u04F2-\u04F2]|[\u04F4-\u04F4]|[\u04F8-\u04F8]|[\u0531-\u0556]|[\u10A0-\u10C5]|[\u1E00-\u1E00]|[\u1E02-\u1E02]|[\u1E04-\u1E04]|[\u1E06-\u1E06]|[\u1E08-\u1E08]|[\u1E0A-\u1E0A]|[\u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|[\u2110-\u2112]|[\u2115-\u2115]|[\u2119-\u211D]|[\u2124-\u2124]|[\u2126-\u2126]|[\u2128-\u2128]|[\u212A-\u212D]|[\u2130-\u2131]|[\u2133-\u2133]|[\uFF21-\uFF3A]/,Ll:/[\u0061-\u007A]|[\u00AA-\u00AA]|[\u00B5-\u00B5]|[\u00BA-\u00BA]|[\u00DF-\u00F6]|[\u00F8-\u00FF]|[\u0101-\u0101]|[\u0103-\u0103]|[\u0105-\u0105]|[\u0107-\u0107]|[\u0109-\u0109]|[\u010B-\u010B]|[\u010D-\u010D]|[\u010F-\u010F]|[\u0111-\u0111]|[\u0113-\u0113]|[\u0115-\u0115]|[\u0117-\u0117]|[\u0119-\u0119]|[\u011B-\u011B]|[\u011D-\u011D]|[\u011F-\u011F]|[\u0121-\u0121]|[\u0123-\u0123]|[\u0125-\u0125]|[\u0127-\u0127]|[\u0129-\u0129]|[\u012B-\u012B]|[\u012D-\u012D]|[\u012F-\u012F]|[\u0131-\u0131]|[\u0133-\u0133]|[\u0135-\u0135]|[\u0137-\u0138]|[\u013A-\u013A]|[\u013C-\u013C]|[\u013E-\u013E]|[\u0140-\u0140]|[\u0142-\u0142]|[\u0144-\u0144]|[\u0146-\u0146]|[\u0148-\u0149]|[\u014B-\u014B]|[\u014D-\u014D]|[\u014F-\u014F]|[\u0151-\u0151]|[\u0153-\u0153]|[\u0155-\u0155]|[\u0157-\u0157]|[\u0159-\u0159]|[\u015B-\u015B]|[\u015D-\u015D]|[\u015F-\u015F]|[\u0161-\u0161]|[\u0163-\u0163]|[\u0165-\u0165]|[\u0167-\u0167]|[\u0169-\u0169]|[\u016B-\u016B]|[\u016D-\u016D]|[\u016F-\u016F]|[\u0171-\u0171]|[\u0173-\u0173]|[\u0175-\u0175]|[\u0177-\u0177]|[\u017A-\u017A]|[\u017C-\u017C]|[\u017E-\u0180]|[\u0183-\u0183]|[\u0185-\u0185]|[\u0188-\u0188]|[\u018C-\u018D]|[\u0192-\u0192]|[\u0195-\u0195]|[\u0199-\u019B]|[\u019E-\u019E]|[\u01A1-\u01A1]|[\u01A3-\u01A3]|[\u01A5-\u01A5]|[\u01A8-\u01A8]|[\u01AB-\u01AB]|[\u01AD-\u01AD]|[\u01B0-\u01B0]|[\u01B4-\u01B4]|[\u01B6-\u01B6]|[\u01B9-\u01BA]|[\u01BD-\u01BD]|[\u01C6-\u01C6]|[\u01C9-\u01C9]|[\u01CC-\u01CC]|[\u01CE-\u01CE]|[\u01D0-\u01D0]|[\u01D2-\u01D2]|[\u01D4-\u01D4]|[\u01D6-\u01D6]|[\u01D8-\u01D8]|[\u01DA-\u01DA]|[\u01DC-\u01DD]|[\u01DF-\u01DF]|[\u01E1-\u01E1]|[\u01E3-\u01E3]|[\u01E5-\u01E5]|[\u01E7-\u01E7]|[\u01E9-\u01E9]|[\u01EB-\u01EB]|[\u01ED-\u01ED]|[\u01EF-\u01F0]|[\u01F3-\u01F3]|[\u01F5-\u01F5]|[\u01FB-\u01FB]|[\u01FD-\u01FD]|[\u01FF-\u01FF]|[\u0201-\u0201]|[\u0203-\u0203]|[\u0205-\u0205]|[\u0207-\u0207]|[\u0209-\u0209]|[\u020B-\u020B]|[\u020D-\u020D]|[\u020F-\u020F]|[\u0211-\u0211]|[\u0213-\u0213]|[\u0215-\u0215]|[\u0217-\u0217]|[\u0250-\u02A8]|[\u0390-\u0390]|[\u03AC-\u03CE]|[\u03D0-\u03D1]|[\u03D5-\u03D6]|[\u03E3-\u03E3]|[\u03E5-\u03E5]|[\u03E7-\u03E7]|[\u03E9-\u03E9]|[\u03EB-\u03EB]|[\u03ED-\u03ED]|[\u03EF-\u03F2]|[\u0430-\u044F]|[\u0451-\u045C]|[\u045E-\u045F]|[\u0461-\u0461]|[\u0463-\u0463]|[\u0465-\u0465]|[\u0467-\u0467]|[\u0469-\u0469]|[\u046B-\u046B]|[\u046D-\u046D]|[\u046F-\u046F]|[\u0471-\u0471]|[\u0473-\u0473]|[\u0475-\u0475]|[\u0477-\u0477]|[\u0479-\u0479]|[\u047B-\u047B]|[\u047D-\u047D]|[\u047F-\u047F]|[\u0481-\u0481]|[\u0491-\u0491]|[\u0493-\u0493]|[\u0495-\u0495]|[\u0497-\u0497]|[\u0499-\u0499]|[\u049B-\u049B]|[\u049D-\u049D]|[\u049F-\u049F]|[\u04A1-\u04A1]|[\u04A3-\u04A3]|[\u04A5-\u04A5]|[\u04A7-\u04A7]|[\u04A9-\u04A9]|[\u04AB-\u04AB]|[\u04AD-\u04AD]|[\u04AF-\u04AF]|[\u04B1-\u04B1]|[\u04B3-\u04B3]|[\u04B5-\u04B5]|[\u04B7-\u04B7]|[\u04B9-\u04B9]|[\u04BB-\u04BB]|[\u04BD-\u04BD]|[\u04BF-\u04BF]|[\u04C2-\u04C2]|[\u04C4-\u04C4]|[\u04C8-\u04C8]|[\u04CC-\u04CC]|[\u04D1-\u04D1]|[\u04D3-\u04D3]|[\u04D5-\u04D5]|[\u04D7-\u04D7]|[\u04D9-\u04D9]|[\u04DB-\u04DB]|[\u04DD-\u04DD]|[\u04DF-\u04DF]|[\u04E1-\u04E1]|[\u04E3-\u04E3]|[\u04E5-\u04E5]|[\u04E7-\u04E7]|[\u04E9-\u04E9]|[\u04EB-\u04EB]|[\u04EF-\u04EF]|[\u04F1-\u04F1]|[\u04F3-\u04F3]|[\u04F5-\u04F5]|[\u04F9-\u04F9]|[\u0561-\u0587]|[\u10D0-\u10F6]|[\u1E01-\u1E01]|[\u1E03-\u1E03]|[\u1E05-\u1E05]|[\u1E07-\u1E07]|[\u1E09-\u1E09]|[\u1E0B-\u1E0B]|[\u1E0D-\u1E0D]|[\u1E0F-\u1E0F]|[\u1E11-\u1E11]|[\u1E13-\u1E13]|[\u1E15-\u1E15]|[\u1E17-\u1E17]|[\u1E19-\u1E19]|[\u1E1B-\u1E1B]|[\u1E1D-\u1E1D]|[\u1E1F-\u1E1F]|[\u1E21-\u1E21]|[\u1E23-\u1E23]|[\u1E25-\u1E25]|[\u1E27-\u1E27]|[\u1E29-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1EBB]|[\u1EBD-\u1EBD]|[\u1EBF-\u1EBF]|[\u1EC1-\u1EC1]|[\u1EC3-\u1EC3]|[\u1EC5-\u1EC5]|[\u1EC7-\u1EC7]|[\u1EC9-\u1EC9]|[\u1ECB-\u1ECB]|[\u1ECD-\u1ECD]|[\u1ECF-\u1ECF]|[\u1ED1-\u1ED1]|[\u1ED3-\u1ED3]|[\u1ED5-\u1ED5]|[\u1ED7-\u1ED7]|[\u1ED9-\u1ED9]|[\u1EDB-\u1EDB]|[\u1EDD-\u1EDD]|[\u1EDF-\u1EDF]|[\u1EE1-\u1EE1]|[\u1EE3-\u1EE3]|[\u1EE5-\u1EE5]|[\u1EE7-\u1EE7]|[\u1EE9-\u1EE9]|[\u1EEB-\u1EEB]|[\u1EED-\u1EED]|[\u1EEF-\u1EEF]|[\u1EF1-\u1EF1]|[\u1EF3-\u1EF3]|[\u1EF5-\u1EF5]|[\u1EF7-\u1EF7]|[\u1EF9-\u1EF9]|[\u1F00-\u1F07]|[\u1F10-\u1F15]|[\u1F20-\u1F27]|[\u1F30-\u1F37]|[\u1F40-\u1F45]|[\u1F50-\u1F57]|[\u1F60-\u1F67]|[\u1F70-\u1F7D]|[\u1F80-\u1F87]|[\u1F90-\u1F97]|[\u1FA0-\u1FA7]|[\u1FB0-\u1FB4]|[\u1FB6-\u1FB7]|[\u1FBE-\u1FBE]|[\u1FC2-\u1FC4]|[\u1FC6-\u1FC7]|[\u1FD0-\u1FD3]|[\u1FD6-\u1FD7]|[\u1FE0-\u1FE7]|[\u1FF2-\u1FF4]|[\u1FF6-\u1FF7]|[\u207F-\u207F]|[\u210A-\u210A]|[\u210E-\u210F]|[\u2113-\u2113]|[\u2118-\u2118]|[\u212E-\u212F]|[\u2134-\u2134]|[\uFB00-\uFB06]|[\uFB13-\uFB17]|[\uFF41-\uFF5A]/, +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ohm=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o\n = NonemptyListOf\n | EmptyListOf\n\n NonemptyListOf\n = elem (sep elem)*\n\n EmptyListOf\n = /* nothing */\n\n listOf\n = nonemptyListOf\n | emptyListOf\n\n nonemptyListOf\n = elem (sep elem)*\n\n emptyListOf\n = /* nothing */\n\n}'},"BuiltInRules",null,null,{alnum:["define",{sourceInterval:[18,78]},"an alpha-numeric character",[],["alt",{sourceInterval:[60,78]},["app",{sourceInterval:[60,66]},"letter",[]],["app",{sourceInterval:[73,78]},"digit",[]]]],letter:["define",{sourceInterval:[82,142]},"a letter",[],["alt",{sourceInterval:[107,142]},["app",{sourceInterval:[107,112]},"lower",[]],["app",{sourceInterval:[119,124]},"upper",[]],["app",{sourceInterval:[131,142]},"unicodeLtmo",[]]]],digit:["define",{sourceInterval:[146,177]},"a digit",[],["range",{sourceInterval:[169,177]},"0","9"]],hexDigit:["define",{sourceInterval:[181,254]},"a hexadecimal digit",[],["alt",{sourceInterval:[219,254]},["app",{sourceInterval:[219,224]},"digit",[]],["range",{sourceInterval:[231,239]},"a","f"],["range",{sourceInterval:[246,254]},"A","F"]]],ListOf:["define",{sourceInterval:[258,336]},null,["elem","sep"],["alt",{sourceInterval:[282,336]},["app",{sourceInterval:[282,307]},"NonemptyListOf",[["param",{},0],["param",{},1]]],["app",{sourceInterval:[314,336]},"EmptyListOf",[["param",{},0],["param",{},1]]]]],NonemptyListOf:["define",{sourceInterval:[340,388]},null,["elem","sep"],["seq",{sourceInterval:[372,388]},["param",{},0],["star",{sourceInterval:[377,388]},["seq",{sourceInterval:[378,386]},["param",{},1],["param",{},0]]]]],EmptyListOf:["define",{sourceInterval:[392,434]},null,["elem","sep"],["seq",{sourceInterval:[438,438]}]],listOf:["define",{sourceInterval:[438,516]},null,["elem","sep"],["alt",{sourceInterval:[462,516]},["app",{sourceInterval:[462,487]},"nonemptyListOf",[["param",{},0],["param",{},1]]],["app",{sourceInterval:[494,516]},"emptyListOf",[["param",{},0],["param",{},1]]]]],nonemptyListOf:["define",{sourceInterval:[520,568]},null,["elem","sep"],["seq",{sourceInterval:[552,568]},["param",{},0],["star",{sourceInterval:[557,568]},["seq",{sourceInterval:[558,566]},["param",{},1],["param",{},0]]]]],emptyListOf:["define",{sourceInterval:[572,614]},null,["elem","sep"],["seq",{sourceInterval:[616,616]}]]}])},{"..":43}],2:[function(require,module,exports){var ohm=require("..");module.exports=ohm.makeRecipe(["grammar",{source:'Ohm {\n\n Grammars\n = Grammar*\n\n Grammar\n = ident SuperGrammar? "{" Rule* "}"\n\n SuperGrammar\n = "<:" ident\n\n Rule\n = ident Formals? ruleDescr? "=" RuleBody -- define\n | ident Formals? ":=" RuleBody -- override\n | ident Formals? "+=" RuleBody -- extend\n\n RuleBody\n = "|"? NonemptyListOf\n\n TopLevelTerm\n = Seq caseName -- inline\n | Seq\n\n Formals\n = "<" ListOf ">"\n\n Params\n = "<" ListOf ">"\n\n Alt\n = NonemptyListOf\n\n Seq\n = Iter*\n\n Iter\n = Pred "*" -- star\n | Pred "+" -- plus\n | Pred "?" -- opt\n | Pred\n\n Pred\n = "~" Lex -- not\n | "&" Lex -- lookahead\n | Lex\n\n Lex\n = "#" Base -- lex\n | Base\n\n Base\n = ident Params? ~(ruleDescr? "=" | ":=" | "+=") -- application\n | terminal ".." terminal -- range\n | terminal -- terminal\n | "(" Alt ")" -- paren\n\n ruleDescr (a rule description)\n = "(" ruleDescrText ")"\n\n ruleDescrText\n = (~")" any)*\n\n caseName\n = "--" (~"\\n" space)* name (~"\\n" space)* ("\\n" | &"}")\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = "_"\n | letter\n\n nameRest\n = "_"\n | alnum\n\n ident (an identifier)\n = name\n\n terminal\n = "\\"" terminalChar* "\\""\n\n terminalChar\n = escapeChar\n | ~"\\\\" ~"\\"" ~"\\n" any\n\n escapeChar (an escape sequence)\n = "\\\\\\\\" -- backslash\n | "\\\\\\"" -- doubleQuote\n | "\\\\\\\'" -- singleQuote\n | "\\\\b" -- backspace\n | "\\\\n" -- lineFeed\n | "\\\\r" -- carriageReturn\n | "\\\\t" -- tab\n | "\\\\u" hexDigit hexDigit hexDigit hexDigit -- unicodeEscape\n | "\\\\x" hexDigit hexDigit -- hexEscape\n\n space\n += comment\n\n comment\n = "//" (~"\\n" any)* "\\n" -- singleLine\n | "/*" (~"*/" any)* "*/" -- multiLine\n\n tokens = token*\n\n token = caseName | comment | ident | operator | punctuation | terminal | any\n\n operator = "<:" | "=" | ":=" | "+=" | "*" | "+" | "?" | "~" | "&"\n\n punctuation = "<" | ">" | "," | "--"\n}'},"Ohm",null,"Grammars",{Grammars:["define",{sourceInterval:[9,32]},null,[],["star",{sourceInterval:[24,32]},["app",{sourceInterval:[24,31]},"Grammar",[]]]],Grammar:["define",{sourceInterval:[36,83]},null,[],["seq",{sourceInterval:[50,83]},["app",{sourceInterval:[50,55]},"ident",[]],["opt",{sourceInterval:[56,69]},["app",{sourceInterval:[56,68]},"SuperGrammar",[]]],["terminal",{sourceInterval:[70,73]},"{"],["star",{sourceInterval:[74,79]},["app",{sourceInterval:[74,78]},"Rule",[]]],["terminal",{sourceInterval:[80,83]},"}"]]],SuperGrammar:["define",{sourceInterval:[87,116]},null,[],["seq",{sourceInterval:[106,116]},["terminal",{sourceInterval:[106,110]},"<:"],["app",{sourceInterval:[111,116]},"ident",[]]]],Rule_define:["define",{sourceInterval:[131,181]},null,[],["seq",{sourceInterval:[131,170]},["app",{sourceInterval:[131,136]},"ident",[]],["opt",{sourceInterval:[137,145]},["app",{sourceInterval:[137,144]},"Formals",[]]],["opt",{sourceInterval:[146,156]},["app",{sourceInterval:[146,155]},"ruleDescr",[]]],["terminal",{sourceInterval:[157,160]},"="],["app",{sourceInterval:[162,170]},"RuleBody",[]]]],Rule_override:["define",{sourceInterval:[188,240]},null,[],["seq",{sourceInterval:[188,227]},["app",{sourceInterval:[188,193]},"ident",[]],["opt",{sourceInterval:[194,202]},["app",{sourceInterval:[194,201]},"Formals",[]]],["terminal",{sourceInterval:[214,218]},":="],["app",{sourceInterval:[219,227]},"RuleBody",[]]]],Rule_extend:["define",{sourceInterval:[247,297]},null,[],["seq",{sourceInterval:[247,286]},["app",{sourceInterval:[247,252]},"ident",[]],["opt",{sourceInterval:[253,261]},["app",{sourceInterval:[253,260]},"Formals",[]]],["terminal",{sourceInterval:[273,277]},"+="],["app",{sourceInterval:[278,286]},"RuleBody",[]]]],Rule:["define",{sourceInterval:[120,297]},null,[],["alt",{sourceInterval:[131,297]},["app",{sourceInterval:[131,170]},"Rule_define",[]],["app",{sourceInterval:[188,227]},"Rule_override",[]],["app",{sourceInterval:[247,286]},"Rule_extend",[]]]],RuleBody:["define",{sourceInterval:[301,354]},null,[],["seq",{sourceInterval:[316,354]},["opt",{sourceInterval:[316,320]},["terminal",{sourceInterval:[316,319]},"|"]],["app",{sourceInterval:[321,354]},"NonemptyListOf",[["app",{sourceInterval:[336,348]},"TopLevelTerm",[]],["terminal",{sourceInterval:[350,353]},"|"]]]]],TopLevelTerm_inline:["define",{sourceInterval:[377,400]},null,[],["seq",{sourceInterval:[377,389]},["app",{sourceInterval:[377,380]},"Seq",[]],["app",{sourceInterval:[381,389]},"caseName",[]]]],TopLevelTerm:["define",{sourceInterval:[358,410]},null,[],["alt",{sourceInterval:[377,410]},["app",{sourceInterval:[377,389]},"TopLevelTerm_inline",[]],["app",{sourceInterval:[407,410]},"Seq",[]]]],Formals:["define",{sourceInterval:[414,454]},null,[],["seq",{sourceInterval:[428,454]},["terminal",{sourceInterval:[428,431]},"<"],["app",{sourceInterval:[432,450]},"ListOf",[["app",{sourceInterval:[439,444]},"ident",[]],["terminal",{sourceInterval:[446,449]},","]]],["terminal",{sourceInterval:[451,454]},">"]]],Params:["define",{sourceInterval:[458,495]},null,[],["seq",{sourceInterval:[471,495]},["terminal",{sourceInterval:[471,474]},"<"],["app",{sourceInterval:[475,491]},"ListOf",[["app",{sourceInterval:[482,485]},"Seq",[]],["terminal",{sourceInterval:[487,490]},","]]],["terminal",{sourceInterval:[492,495]},">"]]],Alt:["define",{sourceInterval:[499,533]},null,[],["app",{sourceInterval:[509,533]},"NonemptyListOf",[["app",{sourceInterval:[524,527]},"Seq",[]],["terminal",{sourceInterval:[529,532]},"|"]]]],Seq:["define",{sourceInterval:[537,552]},null,[],["star",{sourceInterval:[547,552]},["app",{sourceInterval:[547,551]},"Iter",[]]]],Iter_star:["define",{sourceInterval:[567,584]},null,[],["seq",{sourceInterval:[567,575]},["app",{sourceInterval:[567,571]},"Pred",[]],["terminal",{sourceInterval:[572,575]},"*"]]],Iter_plus:["define",{sourceInterval:[591,608]},null,[],["seq",{sourceInterval:[591,599]},["app",{sourceInterval:[591,595]},"Pred",[]],["terminal",{sourceInterval:[596,599]},"+"]]],Iter_opt:["define",{sourceInterval:[615,631]},null,[],["seq",{sourceInterval:[615,623]},["app",{sourceInterval:[615,619]},"Pred",[]],["terminal",{sourceInterval:[620,623]},"?"]]],Iter:["define",{sourceInterval:[556,642]},null,[],["alt",{sourceInterval:[567,642]},["app",{sourceInterval:[567,575]},"Iter_star",[]],["app",{sourceInterval:[591,599]},"Iter_plus",[]],["app",{sourceInterval:[615,623]},"Iter_opt",[]],["app",{sourceInterval:[638,642]},"Pred",[]]]],Pred_not:["define",{sourceInterval:[657,672]},null,[],["seq",{sourceInterval:[657,664]},["terminal",{sourceInterval:[657,660]},"~"],["app",{sourceInterval:[661,664]},"Lex",[]]]],Pred_lookahead:["define",{sourceInterval:[679,700]},null,[],["seq",{sourceInterval:[679,686]},["terminal",{sourceInterval:[679,682]},"&"],["app",{sourceInterval:[683,686]},"Lex",[]]]],Pred:["define",{sourceInterval:[646,710]},null,[],["alt",{sourceInterval:[657,710]},["app",{sourceInterval:[657,664]},"Pred_not",[]],["app",{sourceInterval:[679,686]},"Pred_lookahead",[]],["app",{sourceInterval:[707,710]},"Lex",[]]]],Lex_lex:["define",{sourceInterval:[724,740]},null,[],["seq",{sourceInterval:[724,732]},["terminal",{sourceInterval:[724,727]},"#"],["app",{sourceInterval:[728,732]},"Base",[]]]],Lex:["define",{sourceInterval:[714,751]},null,[],["alt",{sourceInterval:[724,751]},["app",{sourceInterval:[724,732]},"Lex_lex",[]],["app",{sourceInterval:[747,751]},"Base",[]]]],Base_application:["define",{sourceInterval:[766,827]},null,[],["seq",{sourceInterval:[766,811]},["app",{sourceInterval:[766,771]},"ident",[]],["opt",{sourceInterval:[772,779]},["app",{sourceInterval:[772,778]},"Params",[]]],["not",{sourceInterval:[780,811]},["alt",{sourceInterval:[782,810]},["seq",{sourceInterval:[782,796]},["opt",{sourceInterval:[782,792]},["app",{sourceInterval:[782,791]},"ruleDescr",[]]],["terminal",{sourceInterval:[793,796]},"="]],["terminal",{sourceInterval:[799,803]},":="],["terminal",{sourceInterval:[806,810]},"+="]]]]],Base_range:["define",{sourceInterval:[834,889]},null,[],["seq",{sourceInterval:[834,856]},["app",{sourceInterval:[834,842]},"terminal",[]],["terminal",{sourceInterval:[843,847]},".."],["app",{sourceInterval:[848,856]},"terminal",[]]]],Base_terminal:["define",{sourceInterval:[896,954]},null,[],["app",{sourceInterval:[896,904]},"terminal",[]]],Base_paren:["define",{sourceInterval:[961,1016]},null,[],["seq",{sourceInterval:[961,972]},["terminal",{sourceInterval:[961,964]},"("],["app",{sourceInterval:[965,968]},"Alt",[]],["terminal",{sourceInterval:[969,972]},")"]]],Base:["define",{sourceInterval:[755,1016]},null,[],["alt",{sourceInterval:[766,1016]},["app",{sourceInterval:[766,811]},"Base_application",[]],["app",{sourceInterval:[834,856]},"Base_range",[]],["app",{sourceInterval:[896,904]},"Base_terminal",[]],["app",{sourceInterval:[961,972]},"Base_paren",[]]]],ruleDescr:["define",{sourceInterval:[1020,1079]},"a rule description",[],["seq",{sourceInterval:[1058,1079]},["terminal",{sourceInterval:[1058,1061]},"("],["app",{sourceInterval:[1062,1075]},"ruleDescrText",[]],["terminal",{sourceInterval:[1076,1079]},")"]]],ruleDescrText:["define",{sourceInterval:[1083,1114]},null,[],["star",{sourceInterval:[1103,1114]},["seq",{sourceInterval:[1104,1112]},["not",{sourceInterval:[1104,1108]},["terminal",{sourceInterval:[1105,1108]},")"]],["app",{sourceInterval:[1109,1112]},"any",[]]]]],caseName:["define",{sourceInterval:[1118,1186]},null,[],["seq",{sourceInterval:[1133,1186]},["terminal",{sourceInterval:[1133,1137]},"--"],["star",{sourceInterval:[1138,1152]},["seq",{sourceInterval:[1139,1150]},["not",{sourceInterval:[1139,1144]},["terminal",{sourceInterval:[1140,1144]},"\n"]],["app",{sourceInterval:[1145,1150]},"space",[]]]],["app",{sourceInterval:[1153,1157]},"name",[]],["star",{sourceInterval:[1158,1172]},["seq",{sourceInterval:[1159,1170]},["not",{sourceInterval:[1159,1164]},["terminal",{sourceInterval:[1160,1164]},"\n"]],["app",{sourceInterval:[1165,1170]},"space",[]]]],["alt",{sourceInterval:[1174,1185]},["terminal",{sourceInterval:[1174,1178]},"\n"],["lookahead",{sourceInterval:[1181,1185]},["terminal",{sourceInterval:[1182,1185]},"}"]]]]],name:["define",{sourceInterval:[1190,1230]},"a name",[],["seq",{sourceInterval:[1211,1230]},["app",{sourceInterval:[1211,1220]},"nameFirst",[]],["star",{sourceInterval:[1221,1230]},["app",{sourceInterval:[1221,1229]},"nameRest",[]]]]],nameFirst:["define",{sourceInterval:[1234,1266]},null,[],["alt",{sourceInterval:[1250,1266]},["terminal",{sourceInterval:[1250,1253]},"_"],["app",{sourceInterval:[1260,1266]},"letter",[]]]],nameRest:["define",{sourceInterval:[1270,1300]},null,[],["alt",{sourceInterval:[1285,1300]},["terminal",{sourceInterval:[1285,1288]},"_"],["app",{sourceInterval:[1295,1300]},"alnum",[]]]],ident:["define",{sourceInterval:[1304,1337]},"an identifier",[],["app",{sourceInterval:[1333,1337]},"name",[]]],terminal:["define",{sourceInterval:[1341,1379]},null,[],["seq",{sourceInterval:[1356,1379]},["terminal",{sourceInterval:[1356,1360]},'"'],["star",{sourceInterval:[1361,1374]},["app",{sourceInterval:[1361,1373]},"terminalChar",[]]],["terminal",{sourceInterval:[1375,1379]},'"']]],terminalChar:["define",{sourceInterval:[1383,1440]},null,[],["alt",{sourceInterval:[1402,1440]},["app",{sourceInterval:[1402,1412]},"escapeChar",[]],["seq",{sourceInterval:[1419,1440]},["not",{sourceInterval:[1419,1424]},["terminal",{sourceInterval:[1420,1424]},"\\"]],["not",{sourceInterval:[1425,1430]},["terminal",{sourceInterval:[1426,1430]},'"']],["not",{sourceInterval:[1431,1436]},["terminal",{sourceInterval:[1432,1436]},"\n"]],["app",{sourceInterval:[1437,1440]},"any",[]]]]],escapeChar_backslash:["define",{sourceInterval:[1483,1538]},null,[],["terminal",{sourceInterval:[1483,1489]},"\\\\"]],escapeChar_doubleQuote:["define",{sourceInterval:[1545,1602]},null,[],["terminal",{sourceInterval:[1545,1551]},'\\"']],escapeChar_singleQuote:["define",{sourceInterval:[1609,1666]},null,[],["terminal",{sourceInterval:[1609,1615]},"\\'"]],escapeChar_backspace:["define",{sourceInterval:[1673,1728]},null,[],["terminal",{sourceInterval:[1673,1678]},"\\b"]],escapeChar_lineFeed:["define",{sourceInterval:[1735,1789]},null,[],["terminal",{sourceInterval:[1735,1740]},"\\n"]],escapeChar_carriageReturn:["define",{sourceInterval:[1796,1856]},null,[],["terminal",{sourceInterval:[1796,1801]},"\\r"]],escapeChar_tab:["define",{sourceInterval:[1863,1912]},null,[],["terminal",{sourceInterval:[1863,1868]},"\\t"]],escapeChar_unicodeEscape:["define",{sourceInterval:[1919,1978]},null,[],["seq",{sourceInterval:[1919,1960]},["terminal",{sourceInterval:[1919,1924]},"\\u"],["app",{sourceInterval:[1925,1933]},"hexDigit",[]],["app",{sourceInterval:[1934,1942]},"hexDigit",[]],["app",{sourceInterval:[1943,1951]},"hexDigit",[]],["app",{sourceInterval:[1952,1960]},"hexDigit",[]]]],escapeChar_hexEscape:["define",{sourceInterval:[1985,2040]},null,[],["seq",{sourceInterval:[1985,2008]},["terminal",{sourceInterval:[1985,1990]},"\\x"],["app",{sourceInterval:[1991,1999]},"hexDigit",[]],["app",{sourceInterval:[2e3,2008]},"hexDigit",[]]]],escapeChar:["define",{sourceInterval:[1444,2040]},"an escape sequence",[],["alt",{sourceInterval:[1483,2040]},["app",{sourceInterval:[1483,1489]},"escapeChar_backslash",[]],["app",{sourceInterval:[1545,1551]},"escapeChar_doubleQuote",[]],["app",{sourceInterval:[1609,1615]},"escapeChar_singleQuote",[]],["app",{sourceInterval:[1673,1678]},"escapeChar_backspace",[]],["app",{sourceInterval:[1735,1740]},"escapeChar_lineFeed",[]],["app",{sourceInterval:[1796,1801]},"escapeChar_carriageReturn",[]],["app",{sourceInterval:[1863,1868]},"escapeChar_tab",[]],["app",{sourceInterval:[1919,1960]},"escapeChar_unicodeEscape",[]],["app",{sourceInterval:[1985,2008]},"escapeChar_hexEscape",[]]]],space:["extend",{sourceInterval:[2044,2063]},null,[],["app",{sourceInterval:[2056,2063]},"comment",[]]],comment_singleLine:["define",{sourceInterval:[2081,2118]},null,[],["seq",{sourceInterval:[2081,2103]},["terminal",{sourceInterval:[2081,2085]},"//"],["star",{sourceInterval:[2086,2098]},["seq",{sourceInterval:[2087,2096]},["not",{sourceInterval:[2087,2092]},["terminal",{sourceInterval:[2088,2092]},"\n"]],["app",{sourceInterval:[2093,2096]},"any",[]]]],["terminal",{sourceInterval:[2099,2103]},"\n"]]],comment_multiLine:["define",{sourceInterval:[2125,2161]},null,[],["seq",{sourceInterval:[2125,2147]},["terminal",{sourceInterval:[2125,2129]},"/*"],["star",{sourceInterval:[2130,2142]},["seq",{sourceInterval:[2131,2140]},["not",{sourceInterval:[2131,2136]},["terminal",{sourceInterval:[2132,2136]},"*/"]],["app",{sourceInterval:[2137,2140]},"any",[]]]],["terminal",{sourceInterval:[2143,2147]},"*/"]]],comment:["define",{sourceInterval:[2067,2161]},null,[],["alt",{sourceInterval:[2081,2161]},["app",{sourceInterval:[2081,2103]},"comment_singleLine",[]],["app",{sourceInterval:[2125,2147]},"comment_multiLine",[]]]],tokens:["define",{sourceInterval:[2165,2180]},null,[],["star",{sourceInterval:[2174,2180]},["app",{sourceInterval:[2174,2179]},"token",[]]]],token:["define",{sourceInterval:[2184,2260]},null,[],["alt",{sourceInterval:[2192,2260]},["app",{sourceInterval:[2192,2200]},"caseName",[]],["app",{sourceInterval:[2203,2210]},"comment",[]],["app",{sourceInterval:[2213,2218]},"ident",[]],["app",{sourceInterval:[2221,2229]},"operator",[]],["app",{sourceInterval:[2232,2243]},"punctuation",[]],["app",{sourceInterval:[2246,2254]},"terminal",[]],["app",{sourceInterval:[2257,2260]},"any",[]]]],operator:["define",{sourceInterval:[2264,2329]},null,[],["alt",{sourceInterval:[2275,2329]},["terminal",{sourceInterval:[2275,2279]},"<:"],["terminal",{sourceInterval:[2282,2285]},"="],["terminal",{sourceInterval:[2288,2292]},":="],["terminal",{sourceInterval:[2295,2299]},"+="],["terminal",{sourceInterval:[2302,2305]},"*"],["terminal",{sourceInterval:[2308,2311]},"+"],["terminal",{sourceInterval:[2314,2317]},"?"],["terminal",{sourceInterval:[2320,2323]},"~"],["terminal",{sourceInterval:[2326,2329]},"&"]]],punctuation:["define",{sourceInterval:[2333,2369]},null,[],["alt",{sourceInterval:[2347,2369]},["terminal",{sourceInterval:[2347,2350]},"<"],["terminal",{sourceInterval:[2353,2356]},">"],["terminal",{sourceInterval:[2359,2362]},","],["terminal",{sourceInterval:[2365,2369]},"--"]]]}])},{"..":43}],3:[function(require,module,exports){var ohm=require("..");module.exports=ohm.makeRecipe(["grammar",{source:'OperationsAndAttributes {\n\n AttributeSignature =\n name\n\n OperationSignature =\n name Formals?\n\n Formals\n = "(" ListOf ")"\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = "_"\n | letter\n\n nameRest\n = "_"\n | alnum\n\n}'},"OperationsAndAttributes",null,"AttributeSignature",{AttributeSignature:["define",{sourceInterval:[29,58]},null,[],["app",{sourceInterval:[54,58]},"name",[]]],OperationSignature:["define",{sourceInterval:[62,100]},null,[],["seq",{sourceInterval:[87,100]},["app",{sourceInterval:[87,91]},"name",[]],["opt",{sourceInterval:[92,100]},["app",{sourceInterval:[92,99]},"Formals",[]]]]],Formals:["define",{sourceInterval:[104,143]},null,[],["seq",{sourceInterval:[118,143]},["terminal",{sourceInterval:[118,121]},"("],["app",{sourceInterval:[122,139]},"ListOf",[["app",{sourceInterval:[129,133]},"name",[]],["terminal",{sourceInterval:[135,138]},","]]],["terminal",{sourceInterval:[140,143]},")"]]],name:["define",{sourceInterval:[147,187]},"a name",[],["seq",{sourceInterval:[168,187]},["app",{sourceInterval:[168,177]},"nameFirst",[]],["star",{sourceInterval:[178,187]},["app",{sourceInterval:[178,186]},"nameRest",[]]]]],nameFirst:["define",{sourceInterval:[191,223]},null,[],["alt",{sourceInterval:[207,223]},["terminal",{sourceInterval:[207,210]},"_"],["app",{sourceInterval:[217,223]},"letter",[]]]],nameRest:["define",{sourceInterval:[227,257]},null,[],["alt",{sourceInterval:[242,257]},["terminal",{sourceInterval:[242,245]},"_"],["app",{sourceInterval:[252,257]},"alnum",[]]]]}])},{"..":43}],4:[function(require,module,exports){"use strict";var assert=require("../src/common").assert;function getProp(name,thing,fn){return fn(thing[name])}function mapProp(name,thing,fn){return thing[name].map(fn)}function getPropWalkFn(descriptor){var parts=descriptor.split(/ ?\[\]/);if(parts.length===2){return mapProp.bind(null,parts[0])}return getProp.bind(null,descriptor)}function getProps(walkFns,thing,fn){return walkFns.map(function(walkFn){return walkFn(thing,fn)})}function getWalkFn(shape){if(typeof shape==="string"){return getProps.bind(null,[getPropWalkFn(shape)])}else if(Array.isArray(shape)){return getProps.bind(null,shape.map(getPropWalkFn))}else{assert(typeof shape==="function","Expected a string, Array, or function");assert(shape.length===2,"Expected a function of arity 2, got "+shape.length);return shape}}function isRestrictedIdentifier(str){return/^[a-zA-Z_][0-9a-zA-Z_]*$/.test(str)}function trim(s){return s.trim()}function parseSignature(sig){var parts=sig.split(/[()]/).map(trim);if(parts.length===3&&parts[2]===""){var name=parts[0];var params=[];if(parts[1].length>0){params=parts[1].split(",").map(trim)}if(isRestrictedIdentifier(name)&¶ms.every(isRestrictedIdentifier)){return{name:name,formals:params}}}throw new Error("Invalid operation signature: "+sig)}function VisitorFamily(config){this._shapes=config.shapes;this._getTag=config.getTag;this.Adapter=function(thing,family){this._adaptee=thing;this._family=family};this.Adapter.prototype.valueOf=function(){throw new Error("heeey!")};this.operations={};this._arities=Object.create(null);this._getChildren=Object.create(null);var self=this;Object.keys(this._shapes).forEach(function(k){var shape=self._shapes[k];self._getChildren[k]=getWalkFn(shape);if(typeof shape!=="function"){self._arities[k]=Array.isArray(shape)?shape.length:1}});this._wrap=function(thing){return new self.Adapter(thing,self)}}VisitorFamily.prototype.wrap=function(thing){return this._wrap(thing)};VisitorFamily.prototype._checkActionDict=function(dict){var self=this;Object.keys(dict).forEach(function(k){assert(k in self._getChildren,"Unrecognized action name '"+k+"'");var action=dict[k];assert(typeof action==="function","Key '"+k+"': expected function, got "+action);if(k in self._arities){var expected=self._arities[k];var actual=dict[k].length;assert(actual===expected,"Action '"+k+"' has the wrong arity: expected "+expected+", got "+actual)}})};VisitorFamily.prototype.addOperation=function(signature,actions){var sig=parseSignature(signature);var name=sig.name;this._checkActionDict(actions);this.operations[name]={name:name,formals:sig.formals,actions:actions};var family=this;this.Adapter.prototype[name]=function(){var tag=family._getTag(this._adaptee);assert(tag in family._getChildren,"getTag returned unrecognized tag '"+tag+"'");assert(tag in actions,"No action for '"+tag+"' in operation '"+name+"'");var args=Object.create(null);for(var i=0;i-1}},{}],20:[function(require,module,exports){"use strict";module.exports=require("./is-implemented")()?Symbol:require("./polyfill")},{"./is-implemented":21,"./polyfill":23}],21:[function(require,module,exports){"use strict";var validTypes={object:true,symbol:true};module.exports=function(){var symbol;if(typeof Symbol!=="function")return false;symbol=Symbol("test symbol");try{String(symbol)}catch(e){return false}if(!validTypes[typeof Symbol.iterator])return false;if(!validTypes[typeof Symbol.toPrimitive])return false;if(!validTypes[typeof Symbol.toStringTag])return false;return true}},{}],22:[function(require,module,exports){"use strict";module.exports=function(x){if(!x)return false;if(typeof x==="symbol")return true;if(!x.constructor)return false;if(x.constructor.name!=="Symbol")return false;return x[x.constructor.toStringTag]==="Symbol"}},{}],23:[function(require,module,exports){"use strict";var d=require("d"),validateSymbol=require("./validate-symbol"),create=Object.create,defineProperties=Object.defineProperties,defineProperty=Object.defineProperty,objPrototype=Object.prototype,NativeSymbol,SymbolPolyfill,HiddenSymbol,globalSymbols=create(null),isNativeSafe;if(typeof Symbol==="function"){NativeSymbol=Symbol;try{String(NativeSymbol());isNativeSafe=true}catch(ignore){}}var generateName=function(){var created=create(null);return function(desc){var postfix=0,name,ie11BugWorkaround;while(created[desc+(postfix||"")])++postfix;desc+=postfix||"";created[desc]=true;name="@@"+desc;defineProperty(objPrototype,name,d.gs(null,function(value){if(ie11BugWorkaround)return;ie11BugWorkaround=true;defineProperty(this,name,d(value));ie11BugWorkaround=false}));return name}}();HiddenSymbol=function Symbol(description){if(this instanceof HiddenSymbol)throw new TypeError("TypeError: Symbol is not a constructor");return SymbolPolyfill(description)};module.exports=SymbolPolyfill=function Symbol(description){var symbol;if(this instanceof Symbol)throw new TypeError("TypeError: Symbol is not a constructor");if(isNativeSafe)return NativeSymbol(description);symbol=create(HiddenSymbol.prototype);description=description===undefined?"":String(description);return defineProperties(symbol,{__description__:d("",description),__name__:d("",generateName(description))})};defineProperties(SymbolPolyfill,{for:d(function(key){if(globalSymbols[key])return globalSymbols[key];return globalSymbols[key]=SymbolPolyfill(String(key))}),keyFor:d(function(s){var key;validateSymbol(s);for(key in globalSymbols)if(globalSymbols[key]===s)return key}),hasInstance:d("",NativeSymbol&&NativeSymbol.hasInstance||SymbolPolyfill("hasInstance")),isConcatSpreadable:d("",NativeSymbol&&NativeSymbol.isConcatSpreadable||SymbolPolyfill("isConcatSpreadable")),iterator:d("",NativeSymbol&&NativeSymbol.iterator||SymbolPolyfill("iterator")),match:d("",NativeSymbol&&NativeSymbol.match||SymbolPolyfill("match")),replace:d("",NativeSymbol&&NativeSymbol.replace||SymbolPolyfill("replace")),search:d("",NativeSymbol&&NativeSymbol.search||SymbolPolyfill("search")),species:d("",NativeSymbol&&NativeSymbol.species||SymbolPolyfill("species")),split:d("",NativeSymbol&&NativeSymbol.split||SymbolPolyfill("split")),toPrimitive:d("",NativeSymbol&&NativeSymbol.toPrimitive||SymbolPolyfill("toPrimitive")),toStringTag:d("",NativeSymbol&&NativeSymbol.toStringTag||SymbolPolyfill("toStringTag")),unscopables:d("",NativeSymbol&&NativeSymbol.unscopables||SymbolPolyfill("unscopables"))});defineProperties(HiddenSymbol.prototype,{constructor:d(SymbolPolyfill),toString:d("",function(){return this.__name__})});defineProperties(SymbolPolyfill.prototype,{toString:d(function(){return"Symbol ("+validateSymbol(this).__description__+")"}),valueOf:d(function(){return validateSymbol(this)})});defineProperty(SymbolPolyfill.prototype,SymbolPolyfill.toPrimitive,d("",function(){var symbol=validateSymbol(this);if(typeof symbol==="symbol")return symbol;return symbol.toString()}));defineProperty(SymbolPolyfill.prototype,SymbolPolyfill.toStringTag,d("c","Symbol"));defineProperty(HiddenSymbol.prototype,SymbolPolyfill.toStringTag,d("c",SymbolPolyfill.prototype[SymbolPolyfill.toStringTag]));defineProperty(HiddenSymbol.prototype,SymbolPolyfill.toPrimitive,d("c",SymbolPolyfill.prototype[SymbolPolyfill.toPrimitive]))},{"./validate-symbol":24,d:7}],24:[function(require,module,exports){"use strict";var isSymbol=require("./is-symbol");module.exports=function(value){if(!isSymbol(value))throw new TypeError(value+" is not a symbol");return value}},{"./is-symbol":22}],25:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],26:[function(require,module,exports){module.exports=function(obj){return obj!=null&&(isBuffer(obj)||isSlowBuffer(obj)||!!obj._isBuffer)};function isBuffer(obj){return!!obj.constructor&&typeof obj.constructor.isBuffer==="function"&&obj.constructor.isBuffer(obj)}function isSlowBuffer(obj){return typeof obj.readFloatLE==="function"&&typeof obj.slice==="function"&&isBuffer(obj.slice(0,0))}},{}],27:[function(require,module,exports){module.exports=extend;function extend(origin,add){if(!add||typeof add!=="object")return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin}},{}],28:[function(require,module,exports){"use strict";var GrammarDecl=require("./GrammarDecl");var pexprs=require("./pexprs");function Builder(){}Builder.prototype={currentDecl:null,newGrammar:function(name){return new GrammarDecl(name)},grammar:function(metaInfo,name,superGrammar,defaultStartRule,rules){var gDecl=new GrammarDecl(name);if(superGrammar){gDecl.withSuperGrammar(this.fromRecipe(superGrammar))}if(defaultStartRule){gDecl.withDefaultStartRule(defaultStartRule)}if(metaInfo&&metaInfo.source){gDecl.withSource(metaInfo.source)}var self=this;this.currentDecl=gDecl;Object.keys(rules).forEach(function(ruleName){var ruleRecipe=rules[ruleName];var action=ruleRecipe[0];var metaInfo=ruleRecipe[1];var description=ruleRecipe[2];var formals=ruleRecipe[3];var body=self.fromRecipe(ruleRecipe[4]);var source;if(gDecl.source&&metaInfo&&metaInfo.sourceInterval){var inputStream=gDecl.source.inputStream;source=inputStream.interval.apply(inputStream,metaInfo.sourceInterval)}gDecl[action](ruleName,formals,body,description,source)});this.currentDecl=null;return gDecl.build()},terminal:function(x){return new pexprs.Terminal(x)},range:function(from,to){return new pexprs.Range(from,to)},param:function(index){return new pexprs.Param(index)},alt:function(){var terms=[];for(var idx=0;idx0){optParams=optParams.map(function(param){return param instanceof pexprs.PExpr?param:this.fromRecipe(param)},this)}return new pexprs.Apply(ruleName,optParams)},fromRecipe:function(recipe){var result=this[recipe[0]].apply(this,recipe[0]==="grammar"?recipe.slice(1):recipe.slice(2));var metaInfo=recipe[1];if(metaInfo){if(metaInfo.sourceInterval&&this.currentDecl){result.withSource(this.currentDecl.sourceInterval.apply(this.currentDecl,metaInfo.sourceInterval))}}return result}};module.exports=Builder},{"./GrammarDecl":32,"./pexprs":61}],29:[function(require,module,exports){"use strict";var Failure=require("./Failure");var TerminalNode=require("./nodes").TerminalNode;var assert=require("./common").assert;var inherits=require("inherits");var pexprs=require("./pexprs");function CaseInsensitiveTerminal(param){this.obj=param}inherits(CaseInsensitiveTerminal,pexprs.PExpr);CaseInsensitiveTerminal.prototype={_getString:function(state){var terminal=state.currentApplication().args[this.obj.index];assert(terminal instanceof pexprs.Terminal,"expected a Terminal expression");return terminal.obj},allowsSkippingPrecedingSpace:function(){return true},eval:function(state){var inputStream=state.inputStream;var origPos=inputStream.pos;var matchStr=this._getString(state);if(!inputStream.matchString(matchStr,true)){state.processFailure(origPos,this);return false}else{state.bindings.push(new TerminalNode(state.grammar,this.obj,inputStream.interval(origPos)));return true}},generateExamples:function(grammar,examples,inSyntacticContext,actuals){var str=this.obj.generateExamples(grammar,examples,inSyntacticContext,actuals).value;var value="";for(var i=0;i0){var prettyProblems=problems.map(function(problem){return"- "+problem});var error=new Error("Found errors in the action dictionary of the '"+name+"' "+what+":\n"+prettyProblems.join("\n"));error.problems=problems;throw error}},_topDownActionArity:function(actionName){if(actionName==="_iter"||actionName==="_nonterminal"||actionName==="_default"){return 1}else if(actionName==="_terminal"){return 0}return this.rules[actionName].body.getArity()},_inheritsFrom:function(grammar){var g=this.superGrammar;while(g){if(g.equals(grammar,true)){return true}g=g.superGrammar}return false},toRecipe:function(optVarName){var metaInfo={};if(this.source){metaInfo.source=this.source.contents}var superGrammar=null;if(this.superGrammar&&!this.superGrammar.isBuiltIn()){superGrammar=JSON.parse(this.superGrammar.toRecipe())}var startRule=null;if(this.defaultStartRule){startRule=this.defaultStartRule}var rules={};var self=this;Object.keys(this.rules).forEach(function(ruleName){var ruleInfo=self.rules[ruleName];var body=ruleInfo.body;var isDefinition=!self.superGrammar||!self.superGrammar.rules[ruleName];var operation;if(isDefinition){operation="define"}else{operation=body instanceof pexprs.Extend?"extend":"override"}var metaInfo={};if(ruleInfo.source&&self.source){var adjusted=ruleInfo.source.relativeTo(self.source);metaInfo.sourceInterval=[adjusted.startIdx,adjusted.endIdx]}var description=isDefinition?ruleInfo.description:null;var bodyRecipe=body.outputRecipe(ruleInfo.formals,self.source);rules[ruleName]=[operation,metaInfo,description,ruleInfo.formals,bodyRecipe]});return JSON.stringify(["grammar",metaInfo,this.name,superGrammar,startRule,rules])},toOperationActionDictionaryTemplate:function(){return this._toOperationOrAttributeActionDictionaryTemplate()},toAttributeActionDictionaryTemplate:function(){return this._toOperationOrAttributeActionDictionaryTemplate()},_toOperationOrAttributeActionDictionaryTemplate:function(){var sb=new common.StringBuffer;sb.append("{");var first=true;for(var ruleName in this.rules){var body=this.rules[ruleName].body;if(first){first=false}else{sb.append(",")}sb.append("\n");sb.append(" ");this.addSemanticActionTemplate(ruleName,body,sb)}sb.append("\n}");return sb.contents()},addSemanticActionTemplate:function(ruleName,body,sb){sb.append(ruleName);sb.append(": function(");var arity=this._topDownActionArity(ruleName);sb.append(common.repeat("_",arity).join(", "));sb.append(") {\n");sb.append(" }")},parseApplication:function(str){var app;if(str.indexOf("<")===-1){app=new pexprs.Apply(str)}else{var cst=ohmGrammar.match(str,"Base_application");app=buildGrammar(cst,{})}if(!(app.ruleName in this.rules)){throw errors.undeclaredRule(app.ruleName,this.name)}var formals=this.rules[app.ruleName].formals;if(formals.length!==app.args.length){var source=this.rules[app.ruleName].source;throw errors.wrongNumberOfParameters(app.ruleName,formals.length,app.args.length,source)}return app}};Grammar.ProtoBuiltInRules=new Grammar("ProtoBuiltInRules",undefined,{any:{body:pexprs.any,formals:[],description:"any object"},end:{body:pexprs.end,formals:[],description:"end of input"},caseInsensitive:{body:new CaseInsensitiveTerminal(new pexprs.Param(0)),formals:["expr"]},spaces:{body:new pexprs.Star(new pexprs.Apply("space")),formals:[]},space:{body:new pexprs.Range("\0"," "),formals:[],description:"a space"},lower:{body:new pexprs.UnicodeChar("Ll"),formals:[],description:"a lowercase letter"},upper:{body:new pexprs.UnicodeChar("Lu"),formals:[],description:"an uppercase letter"},unicodeLtmo:{body:new pexprs.UnicodeChar("Ltmo"),formals:[]}});module.exports=Grammar},{"./CaseInsensitiveTerminal":29,"./MatchResult":35,"./Semantics":38,"./State":39,"./common":41,"./errors":42,"./pexprs":61}],32:[function(require,module,exports){"use strict";var Grammar=require("./Grammar");var InputStream=require("./InputStream");var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");function GrammarDecl(name){this.name=name}GrammarDecl.prototype.sourceInterval=function(startIdx,endIdx){var inputStream=this.source.inputStream;return inputStream.interval(startIdx,endIdx)};GrammarDecl.prototype.ensureSuperGrammar=function(){if(!this.superGrammar){this.withSuperGrammar(this.name==="BuiltInRules"?Grammar.ProtoBuiltInRules:Grammar.BuiltInRules)}return this.superGrammar};GrammarDecl.prototype.installOverriddenOrExtendedRule=function(name,formals,body,source){var duplicateParameterNames=common.getDuplicates(formals);if(duplicateParameterNames.length>0){throw errors.duplicateParameterNames(name,duplicateParameterNames,source)}var ruleInfo=this.ensureSuperGrammar().rules[name];var expectedFormals=ruleInfo.formals;var expectedNumFormals=expectedFormals?expectedFormals.length:0;if(formals.length!==expectedNumFormals){throw errors.wrongNumberOfParameters(name,expectedNumFormals,formals.length,source)}return this.install(name,formals,body,ruleInfo.description,source)};GrammarDecl.prototype.install=function(name,formals,body,description,source){this.rules[name]={body:body.introduceParams(formals),formals:formals,description:description,source:source};return this};GrammarDecl.prototype.withSuperGrammar=function(superGrammar){if(this.superGrammar){throw new Error("the super grammar of a GrammarDecl cannot be set more than once")}this.superGrammar=superGrammar;this.rules=Object.create(superGrammar.rules);if(!superGrammar.isBuiltIn()){this.defaultStartRule=superGrammar.defaultStartRule}return this};GrammarDecl.prototype.withDefaultStartRule=function(ruleName){this.defaultStartRule=ruleName;return this};GrammarDecl.prototype.withSource=function(source){this.source=new InputStream(source).interval(0,source.length);return this};GrammarDecl.prototype.build=function(){var grammar=new Grammar(this.name,this.ensureSuperGrammar(),this.rules,this.defaultStartRule);var grammarErrors=[];var grammarHasInvalidApplications=false;Object.keys(grammar.rules).forEach(function(ruleName){var body=grammar.rules[ruleName].body;try{body.assertChoicesHaveUniformArity(ruleName)}catch(e){grammarErrors.push(e)}try{body.assertAllApplicationsAreValid(ruleName,grammar)}catch(e){grammarErrors.push(e);grammarHasInvalidApplications=true}});if(!grammarHasInvalidApplications){Object.keys(grammar.rules).forEach(function(ruleName){var body=grammar.rules[ruleName].body;try{body.assertIteratedExprsAreNotNullable(grammar,ruleName)}catch(e){grammarErrors.push(e)}})}if(grammarErrors.length>0){errors.throwErrors(grammarErrors)}if(this.source){grammar.source=this.source}return grammar};GrammarDecl.prototype.define=function(name,formals,body,description,source){this.ensureSuperGrammar();if(this.superGrammar.rules[name]){throw errors.duplicateRuleDeclaration(name,this.name,this.superGrammar.name,source)}else if(this.rules[name]){throw errors.duplicateRuleDeclaration(name,this.name,this.name,source)}var duplicateParameterNames=common.getDuplicates(formals);if(duplicateParameterNames.length>0){throw errors.duplicateParameterNames(name,duplicateParameterNames,source)}return this.install(name,formals,body,description,source)};GrammarDecl.prototype.override=function(name,formals,body,descIgnored,source){var ruleInfo=this.ensureSuperGrammar().rules[name];if(!ruleInfo){throw errors.cannotOverrideUndeclaredRule(name,this.superGrammar.name,source)}this.installOverriddenOrExtendedRule(name,formals,body,source);return this};GrammarDecl.prototype.extend=function(name,formals,fragment,descIgnored,source){var ruleInfo=this.ensureSuperGrammar().rules[name];if(!ruleInfo){throw errors.cannotExtendUndeclaredRule(name,this.superGrammar.name,source)}var body=new pexprs.Extend(this.superGrammar,name,fragment);body.source=fragment.source;this.installOverriddenOrExtendedRule(name,formals,body,source);return this};module.exports=GrammarDecl},{"./Grammar":31,"./InputStream":33,"./common":41,"./errors":42,"./pexprs":61}],33:[function(require,module,exports){"use strict";var Interval=require("./Interval");function InputStream(source){this.source=source;this.pos=0;this.posInfos=[]}InputStream.prototype={atEnd:function(){return this.pos===this.source.length},next:function(){return this.source[this.pos++]},matchString:function(s,optIgnoreCase){var idx;if(optIgnoreCase){for(idx=0;idx=that.startIdx&&this.endIdx<=that.endIdx,"other interval does not cover this one");return new Interval(newInputStream,this.startIdx-that.startIdx,this.endIdx-that.startIdx)},trimmed:function(){var contents=this.contents;var startIdx=this.startIdx+contents.match(/^\s*/)[0].length;var endIdx=this.endIdx-contents.match(/\s*$/)[0].length;return new Interval(this.inputStream,startIdx,endIdx)}};Object.defineProperties(Interval.prototype,{contents:{get:function(){if(this._contents===undefined){this._contents=this.inputStream.sourceSlice(this.startIdx,this.endIdx)}return this._contents},enumerable:true},length:{get:function(){return this.endIdx-this.startIdx},enumerable:true}});module.exports=Interval},{"./common":41,"./errors":42,"./util":62}],35:[function(require,module,exports){"use strict";var inherits=require("inherits");var common=require("./common");var nodes=require("./nodes");var util=require("./util");var Interval=require("./Interval");function MatchResult(state){this.state=state;this._cst=state.bindings[0]}MatchResult.newFor=function(state){var succeeded=state.bindings.length>0;return succeeded?new MatchResult(state):new MatchFailure(state)};MatchResult.prototype.failed=function(){return false};MatchResult.prototype.succeeded=function(){return!this.failed()};MatchResult.prototype.getDiscardedSpaces=function(){if(this.failed()){return[]}var state=this.state;var grammar=state.grammar;var inputStream=state.inputStream;var intervals=[new Interval(inputStream,0,inputStream.source.length)];var s=grammar.createSemantics().addOperation("subtractTerminals",{_nonterminal:function(children){children.forEach(function(child){child.subtractTerminals()})},_terminal:function(){var t=this;intervals=intervals.map(function(interval){return interval.minus(t.source)}).reduce(function(xs,ys){return xs.concat(ys)},[])}});s(this).subtractTerminals();s.addOperation("fixIntervals(idxOffset)",{_default:function(children){var idxOffset=this.args.idxOffset;this.source.inputStream=inputStream;this.source.startIdx+=idxOffset;this.source.endIdx+=idxOffset;if(!this.isTerminal()){children.forEach(function(child){child.fixIntervals(idxOffset)})}}});var discardedNodes=intervals.map(function(interval){var r=grammar.match(interval.contents,"spaces");s(r).fixIntervals(interval.startIdx);return r._cst});discardedNodes=new nodes.IterationNode(grammar,discardedNodes,discardedNodes.length===0?new Interval(inputStream,0,0):new Interval(inputStream,discardedNodes[0].source.startIdx,discardedNodes[discardedNodes.length-1].source.endIdx));var r=Object.create(this);r._cst=discardedNodes;r.getDiscardedSpaces=function(){return r};return r};function MatchFailure(state){this.state=state;common.defineLazyProperty(this,"_failures",function(){return this.state.getFailures()});common.defineLazyProperty(this,"message",function(){var source=this.state.inputStream.source;if(typeof source!=="string"){return"match failed at position "+this.getRightmostFailurePosition()}var detail="Expected "+this.getExpectedText();return util.getLineAndColumnMessage(source,this.getRightmostFailurePosition())+detail});common.defineLazyProperty(this,"shortMessage",function(){if(typeof this.state.inputStream.source!=="string"){return"match failed at position "+this.getRightmostFailurePosition()}var detail="expected "+this.getExpectedText();return util.getShortLineAndColumnMessage(this.state.inputStream.source,this.getRightmostFailurePosition())+detail})}inherits(MatchFailure,MatchResult);MatchFailure.prototype.toString=function(){return"[MatchFailure at position "+this.getRightmostFailurePosition()+"]"};MatchFailure.prototype.failed=function(){return true};MatchFailure.prototype.getRightmostFailurePosition=function(){return this.state.getRightmostFailurePosition()};MatchFailure.prototype.getRightmostFailures=function(){return this._failures};MatchFailure.prototype.getExpectedText=function(){var sb=new common.StringBuffer;var failures=this.getRightmostFailures();failures=failures.filter(function(failure){return!failure.isFluffy()});for(var idx=0;idx0){if(idx===failures.length-1){sb.append(failures.length>2?", or ":" or ")}else{sb.append(", ")}}sb.append(failures[idx].toString())}return sb.contents()};MatchFailure.prototype.getInterval=function(){var pos=this.state.getRightmostFailurePosition();return new Interval(this.state.inputStream,pos,pos)};module.exports=MatchResult},{"./Interval":34,"./common":41,"./nodes":44,"./util":62,inherits:25}],36:[function(require,module,exports){"use strict";var extend=require("util-extend");function Namespace(){}Namespace.prototype=Object.create(null);Namespace.asNamespace=function(objOrNamespace){if(objOrNamespace instanceof Namespace){return objOrNamespace}return Namespace.createNamespace(objOrNamespace)};Namespace.createNamespace=function(optProps){return Namespace.extend(Namespace.prototype,optProps)};Namespace.extend=function(namespace,optProps){if(namespace!==Namespace.prototype&&!(namespace instanceof Namespace)){throw new TypeError("not a Namespace object: "+namespace)}var ns=Object.create(namespace,{constructor:{value:Namespace,enumerable:false,writable:true,configurable:true}});return extend(ns,optProps)};Namespace.toString=function(ns){return Object.prototype.toString.call(ns)};module.exports=Namespace},{"util-extend":27}],37:[function(require,module,exports){"use strict";function PosInfo(state){this.state=state;this.applicationMemoKeyStack=[];this.memo={};this.currentLeftRecursion=undefined}PosInfo.prototype={isActive:function(application){return this.applicationMemoKeyStack.indexOf(application.toMemoKey())>=0},enter:function(application){this.state.enter(application);this.applicationMemoKeyStack.push(application.toMemoKey())},exit:function(){this.state.exit();this.applicationMemoKeyStack.pop()},startLeftRecursion:function(headApplication,memoRec){memoRec.isLeftRecursion=true;memoRec.headApplication=headApplication;memoRec.nextLeftRecursion=this.currentLeftRecursion;this.currentLeftRecursion=memoRec;var applicationMemoKeyStack=this.applicationMemoKeyStack;var indexOfFirstInvolvedRule=applicationMemoKeyStack.indexOf(headApplication.toMemoKey())+1;var involvedApplicationMemoKeys=applicationMemoKeyStack.slice(indexOfFirstInvolvedRule);memoRec.isInvolved=function(applicationMemoKey){return involvedApplicationMemoKeys.indexOf(applicationMemoKey)>=0};memoRec.updateInvolvedApplicationMemoKeys=function(){for(var idx=indexOfFirstInvolvedRule;idx0){signature+="("+semanticOperations[name].formals.join(", ")+")"}var method;if(hasSuperSemantics(this)&&this.super[type.toLowerCase()+"s"][name]){method="extend"+type}else{method="add"+type}str+="\n ."+method+"("+JSON.stringify(signature)+", {";var actions=semanticOperations[name].actionDict;var srcArray=[];Object.keys(actions).forEach(function(actionName){if(semanticOperations[name].builtInDefault!==actions[actionName]){srcArray.push("\n "+JSON.stringify(actionName)+": "+actions[actionName].toString())}});str+=srcArray.join(",");str+="\n })"},this)},this);str+=";\n })";if(!semanticsOnly){str="(function() {\n"+" var grammar = this.fromRecipe("+jsonToJS(this.grammar.toRecipe())+");\n"+" var semantics = "+str+"(grammar);\n"+" return semantics;\n"+"});\n"}return str};var prototypeGrammar;var prototypeGrammarSemantics;Semantics.initPrototypeParser=function(grammar){prototypeGrammarSemantics=grammar.createSemantics().addOperation("parse",{AttributeSignature:function(name){return{name:name.parse(),formals:[]}},OperationSignature:function(name,optFormals){return{name:name.parse(),formals:optFormals.parse()[0]||[]}},Formals:function(oparen,fs,cparen){return fs.asIteration().parse()},name:function(first,rest){return this.sourceString}});prototypeGrammar=grammar};function parseSignature(signature,type){if(!prototypeGrammar){common.assert(signature.indexOf("(")===-1);return{name:signature,formals:[]}}var r=prototypeGrammar.match(signature,type==="operation"?"OperationSignature":"AttributeSignature");if(r.failed()){throw new Error(r.message)}return prototypeGrammarSemantics(r).parse()}function newDefaultAction(type,name,doIt){return function(children){var self=this;var thisThing=this._semantics.operations[name]||this._semantics.attributes[name];var args=thisThing.formals.map(function(formal){return self.args[formal]});if(this.isIteration()){return children.map(function(child){return doIt.apply(child,args)})}if(children.length===1){return doIt.apply(children[0],args)}else{throw new Error("Missing semantic action for "+this.ctorName+" in "+name+" "+type)}}}Semantics.prototype.addOperationOrAttribute=function(type,signature,actionDict){var typePlural=type+"s";var parsedNameAndFormalArgs=parseSignature(signature,type);var name=parsedNameAndFormalArgs.name;var formals=parsedNameAndFormalArgs.formals;this.assertNewName(name,type);var builtInDefault=newDefaultAction(type,name,doIt);var realActionDict={_default:builtInDefault};Object.keys(actionDict).forEach(function(name){realActionDict[name]=actionDict[name]});var entry=type==="operation"?new Operation(name,formals,realActionDict,builtInDefault):new Attribute(name,realActionDict,builtInDefault);entry.checkActionDict(this.grammar);this[typePlural][name]=entry;function doIt(){var thisThing=this._semantics[typePlural][name];if(arguments.length!==thisThing.formals.length){throw new Error("Invalid number of arguments passed to "+name+" "+type+" (expected "+thisThing.formals.length+", got "+arguments.length+")")}var args=Object.create(null);for(var idx=0;idxnewLength){this.bindings.pop()}},getCurrentPosInfo:function(){return this.getPosInfo(this.inputStream.pos)},getPosInfo:function(pos){var posInfo=this.posInfos[pos];if(!posInfo){posInfo=this.posInfos[pos]=new PosInfo(this)}return posInfo},processFailure:function(pos,expr){if(this.recordingMode===RM_RIGHTMOST_FAILURE_POSITION){if(pos>this.rightmostFailurePosition){this.rightmostFailurePosition=pos}}else if(pos===this.rightmostFailurePosition){var app=this.currentApplication();if(app){expr=expr.substituteParams(app.args)}else{}this.addRightmostFailure(expr.toFailure(this.grammar),false)}},ensureRightmostFailures:function(){if(!this.rightmostFailures){this.rightmostFailures=Object.create(null)}},addRightmostFailure:function(failure,shouldCloneIfNew){this.ensureRightmostFailures();var key=failure.toKey();if(!this.rightmostFailures[key]){this.rightmostFailures[key]=shouldCloneIfNew?failure.clone():failure}else if(this.rightmostFailures[key].isFluffy()&&!failure.isFluffy()){this.rightmostFailures[key].clearFluffy()}},addRightmostFailures:function(failures,shouldCloneIfNew){var self=this;Object.keys(failures).forEach(function(key){self.addRightmostFailure(failures[key],shouldCloneIfNew)})},cloneRightmostFailures:function(){if(!this.rightmostFailures){return undefined}var ans=Object.create(null);var self=this;Object.keys(this.rightmostFailures).forEach(function(key){ans[key]=self.rightmostFailures[key].clone()});return ans},getRightmostFailurePosition:function(){return this.rightmostFailurePosition},getFailures:function(){if(this.recordingMode===RM_RIGHTMOST_FAILURE_POSITION){this.init(RM_RIGHTMOST_FAILURES);this.evalFromStart()}this.ensureRightmostFailures();var self=this;return Object.keys(this.rightmostFailures).map(function(key){return self.rightmostFailures[key]})},getMemoizedTraceEntry:function(pos,expr){var posInfo=this.posInfos[pos];if(posInfo&&expr.ruleName){var memoRec=posInfo.memo[expr.toMemoKey()];if(memoRec&&memoRec.traceEntry){var entry=memoRec.traceEntry.cloneWithExpr(expr);entry.isMemoized=true;return entry}}return null},getTraceEntry:function(pos,expr,succeeded,bindings){return this.getMemoizedTraceEntry(pos,expr)||new Trace(this.inputStream,pos,expr,succeeded,bindings,this.trace)},isTracing:function(){return this.tracingEnabled},useMemoizedResult:function(memoRec){if(this.isTracing()){this.trace.push(memoRec.traceEntry)}if(this.recordingMode===RM_RIGHTMOST_FAILURES&&memoRec.failuresAtRightmostPosition){this.addRightmostFailures(memoRec.failuresAtRightmostPosition,true)}if(memoRec.value){this.inputStream.pos=memoRec.pos;this.bindings.push(memoRec.value);return true}return false},eval:function(expr){var inputStream=this.inputStream;var origNumBindings=this.bindings.length;var origFailures;if(this.recordingMode===RM_RIGHTMOST_FAILURES){origFailures=this.rightmostFailures;this.rightmostFailures=undefined}var origPos=inputStream.pos;var memoPos=this.maybeSkipSpacesBefore(expr);var origTrace;if(this.isTracing()){origTrace=this.trace;this.trace=[]}var ans=expr.eval(this);if(this.isTracing()){var bindings=this.bindings.slice(origNumBindings);var traceEntry=this.getTraceEntry(memoPos,expr,ans,bindings);traceEntry.isImplicitSpaces=expr===applySpaces;traceEntry.isRootNode=expr===this.startExpr;origTrace.push(traceEntry);this.trace=origTrace}if(ans){if(this.rightmostFailures&&(inputStream.pos===this.rightmostFailurePosition||this.skipSpacesIfInSyntacticContext()===this.rightmostFailurePosition)){var self=this;Object.keys(this.rightmostFailures).forEach(function(key){self.rightmostFailures[key].makeFluffy()})}}else{inputStream.pos=origPos;this.truncateBindings(origNumBindings)}if(this.recordingMode===RM_RIGHTMOST_FAILURES&&origFailures){this.addRightmostFailures(origFailures,false)}return ans},_getStartExpr:function(grammar,optStartApplication){var applicationStr=optStartApplication||grammar.defaultStartRule;if(!applicationStr){throw new Error("Missing start rule argument -- the grammar has no default start rule.")}var startApp=grammar.parseApplication(applicationStr);return new pexprs.Seq([startApp,pexprs.end])},evalFromStart:function(){this.eval(this.startExpr)},getFailuresInfo:function(){if(this.recordingMode===RM_RIGHTMOST_FAILURE_POSITION){return this.rightmostFailurePosition}else{return this.rightmostFailures}},restoreFailuresInfo:function(failuresInfo){if(this.recordingMode===RM_RIGHTMOST_FAILURE_POSITION){this.rightmostFailurePosition=failuresInfo}else{this.rightmostFailures=failuresInfo}}};module.exports=State},{"./InputStream":33,"./PosInfo":37,"./Trace":40,"./pexprs":61}],40:[function(require,module,exports){"use strict";var Interval=require("./Interval");var common=require("./common");var BALLOT_X="✗";var CHECK_MARK="✓";var DOT_OPERATOR="⋅";var RIGHTWARDS_DOUBLE_ARROW="⇒";var SYMBOL_FOR_HORIZONTAL_TABULATION="␉";var SYMBOL_FOR_LINE_FEED="␊";var SYMBOL_FOR_CARRIAGE_RETURN="␍";function spaces(n){return common.repeat(" ",n).join("")}function getInputExcerpt(inputStream,pos,len){var excerpt=asEscapedString(inputStream.sourceSlice(pos,pos+len));if(excerpt.length0){arr.push(fn())}return arr};exports.repeatStr=function(str,n){return new Array(n+1).join(str)};exports.repeat=function(x,n){return exports.repeatFn(function(){return x},n)};exports.getDuplicates=function(array){var duplicates=[];for(var idx=0;idx1){throw multipleErrors(errors)}}}},{"./Namespace":36,"./util":62}],43:[function(require,module,exports){"use strict";var Builder=require("./Builder");var Grammar=require("./Grammar");var Namespace=require("./Namespace");var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");var util=require("./util");var isBuffer=require("is-buffer");var ohmGrammar;var documentInterface={querySelector:function(sel){return document.querySelector(sel)},querySelectorAll:function(sel){return document.querySelectorAll(sel)}};function isElement(obj){return!!(obj&&obj.nodeType===1)}function isUndefined(obj){return obj===void 0}var MAX_ARRAY_INDEX=Math.pow(2,53)-1;function isArrayLike(obj){if(obj==null){return false}var length=obj.length;return typeof length==="number"&&length>=0&&length<=MAX_ARRAY_INDEX}function load(url){var req=new XMLHttpRequest;req.open("GET",url,false);try{req.send();if(req.status===0||req.status===200){return req.responseText}}catch(e){}throw new Error("unable to load url "+url)}function buildGrammar(match,namespace,optOhmGrammarForTesting){var builder=new Builder;var decl;var currentRuleName;var currentRuleFormals;var overriding=false;var metaGrammar=optOhmGrammarForTesting||ohmGrammar;var helpers=metaGrammar.createSemantics().addOperation("visit",{Grammar:function(n,s,open,rs,close){var grammarName=n.visit();decl=builder.newGrammar(grammarName,namespace);s.visit();rs.visit();var g=decl.build();g.source=this.source.trimmed();if(grammarName in namespace){throw errors.duplicateGrammarDeclaration(g,namespace)}namespace[grammarName]=g;return g},SuperGrammar:function(_,n){var superGrammarName=n.visit();if(superGrammarName==="null"){decl.withSuperGrammar(null)}else{if(!namespace||!(superGrammarName in namespace)){throw errors.undeclaredGrammar(superGrammarName,namespace,n.source)}decl.withSuperGrammar(namespace[superGrammarName])}},Rule_define:function(n,fs,d,_,b){currentRuleName=n.visit();currentRuleFormals=fs.visit()[0]||[];if(!decl.defaultStartRule&&decl.ensureSuperGrammar()!==Grammar.ProtoBuiltInRules){decl.withDefaultStartRule(currentRuleName)}var body=b.visit();var description=d.visit()[0];var source=this.source.trimmed();return decl.define(currentRuleName,currentRuleFormals,body,description,source)},Rule_override:function(n,fs,_,b){currentRuleName=n.visit();currentRuleFormals=fs.visit()[0]||[];overriding=true;var body=b.visit();var source=this.source.trimmed();var ans=decl.override(currentRuleName,currentRuleFormals,body,null,source);overriding=false;return ans},Rule_extend:function(n,fs,_,b){currentRuleName=n.visit();currentRuleFormals=fs.visit()[0]||[];var body=b.visit();var source=this.source.trimmed();var ans=decl.extend(currentRuleName,currentRuleFormals,body,null,source);return ans},RuleBody:function(_,terms){var args=terms.visit();return builder.alt.apply(builder,args).withSource(this.source)},Formals:function(opointy,fs,cpointy){return fs.visit()},Params:function(opointy,ps,cpointy){return ps.visit()},Alt:function(seqs){var args=seqs.visit();return builder.alt.apply(builder,args).withSource(this.source)},TopLevelTerm_inline:function(b,n){var inlineRuleName=currentRuleName+"_"+n.visit();var body=b.visit();var source=this.source.trimmed();var isNewRuleDeclaration=!(decl.superGrammar&&decl.superGrammar.rules[inlineRuleName]);if(overriding&&!isNewRuleDeclaration){decl.override(inlineRuleName,currentRuleFormals,body,null,source)}else{decl.define(inlineRuleName,currentRuleFormals,body,null,source)}var params=currentRuleFormals.map(function(formal){return builder.app(formal)});return builder.app(inlineRuleName,params).withSource(body.source)},Seq:function(expr){return builder.seq.apply(builder,expr.visit()).withSource(this.source)},Iter_star:function(x,_){return builder.star(x.visit()).withSource(this.source)},Iter_plus:function(x,_){return builder.plus(x.visit()).withSource(this.source)},Iter_opt:function(x,_){return builder.opt(x.visit()).withSource(this.source)},Pred_not:function(_,x){return builder.not(x.visit()).withSource(this.source)},Pred_lookahead:function(_,x){return builder.lookahead(x.visit()).withSource(this.source)},Lex_lex:function(_,x){return builder.lex(x.visit()).withSource(this.source)},Base_application:function(rule,ps){return builder.app(rule.visit(),ps.visit()[0]||[]).withSource(this.source)},Base_range:function(from,_,to){return builder.range(from.visit(),to.visit()).withSource(this.source)},Base_terminal:function(expr){return builder.terminal(expr.visit()).withSource(this.source)},Base_paren:function(open,x,close){return x.visit()},ruleDescr:function(open,t,close){return t.visit()},ruleDescrText:function(_){return this.sourceString.trim()},caseName:function(_,space1,n,space2,end){return n.visit()},name:function(first,rest){return this.sourceString},nameFirst:function(expr){},nameRest:function(expr){},terminal:function(open,cs,close){return cs.visit().map(function(c){return common.unescapeChar(c)}).join("")},terminalChar:function(_){return this.sourceString},escapeChar:function(_){return this.sourceString},NonemptyListOf:function(x,_,xs){return[x.visit()].concat(xs.visit())},EmptyListOf:function(){return[]},_terminal:function(){return this.primitiveValue}});return helpers(match).visit()}function compileAndLoad(source,namespace){var m=ohmGrammar.match(source,"Grammars");if(m.failed()){throw errors.grammarSyntaxError(m)}return buildGrammar(m,namespace)}function getScriptElementContents(el){if(!isElement(el)){throw new TypeError("Expected a DOM Node, got "+common.unexpectedObjToString(el))}if(el.type!=="text/ohm-js"){throw new Error('Expected a script tag with type="text/ohm-js", got '+el)}return el.getAttribute("src")?load(el.getAttribute("src")):el.innerHTML}function grammar(source,optNamespace){var ns=grammars(source,optNamespace);var grammarNames=Object.keys(ns);if(grammarNames.length===0){throw new Error("Missing grammar definition")}else if(grammarNames.length>1){var secondGrammar=ns[grammarNames[1]];var interval=secondGrammar.source;throw new Error(util.getLineAndColumnMessage(interval.inputStream.source,interval.startIdx)+"Found more than one grammar definition -- use ohm.grammars() instead.")}return ns[grammarNames[0]]}function grammars(source,optNamespace){var ns=Namespace.extend(Namespace.asNamespace(optNamespace));if(typeof source!=="string"){if(isBuffer(source)){source=source.toString()}else{throw new TypeError("Expected string as first argument, got "+common.unexpectedObjToString(source))}}compileAndLoad(source,ns);return ns}function grammarFromScriptElement(optNode){var node=optNode;if(isUndefined(node)){var nodeList=documentInterface.querySelectorAll('script[type="text/ohm-js"]');if(nodeList.length!==1){throw new Error('Expected exactly one script tag with type="text/ohm-js", found '+nodeList.length)}node=nodeList[0]}return grammar(getScriptElementContents(node))}function grammarsFromScriptElements(optNodeOrNodeList){if(isElement(optNodeOrNodeList)){return grammars(optNodeOrNodeList)}var nodeList=optNodeOrNodeList;if(isUndefined(nodeList)){nodeList=documentInterface.querySelectorAll('script[type="text/ohm-js"]')}else if(typeof nodeList==="string"||!isElement(nodeList)&&!isArrayLike(nodeList)){throw new TypeError("Expected a Node, NodeList, or Array, but got "+nodeList)}var ns=Namespace.createNamespace();for(var i=0;i0};Node.prototype.hasNoChildren=function(){return!this.hasChildren()};Node.prototype.onlyChild=function(){if(this.children.length!==1){throw new Error("cannot get only child of a node of type "+this.ctorName+" (it has "+this.numChildren()+" children)")}else{return this.firstChild()}};Node.prototype.firstChild=function(){if(this.hasNoChildren()){throw new Error("cannot get first child of a "+this.ctorName+" node, which has no children")}else{return this.childAt(0)}};Node.prototype.lastChild=function(){if(this.hasNoChildren()){throw new Error("cannot get last child of a "+this.ctorName+" node, which has no children")}else{return this.childAt(this.numChildren()-1)}};Node.prototype.childBefore=function(child){var childIdx=this.indexOfChild(child);if(childIdx<0){throw new Error("Node.childBefore() called w/ an argument that is not a child")}else if(childIdx===0){throw new Error("cannot get child before first child")}else{return this.childAt(childIdx-1)}};Node.prototype.childAfter=function(child){var childIdx=this.indexOfChild(child);if(childIdx<0){throw new Error("Node.childAfter() called w/ an argument that is not a child")}else if(childIdx===this.numChildren()-1){throw new Error("cannot get child after last child")}else{return this.childAt(childIdx+1)}};Node.prototype.isTerminal=function(){return false};Node.prototype.isNonterminal=function(){return false};Node.prototype.isIteration=function(){return false};Node.prototype.isOptional=function(){return false};Node.prototype.toJSON=function(){var r={};r[this.ctorName]=this.children;return r};function TerminalNode(grammar,value,source){Node.call(this,grammar,"_terminal",[],source);this.primitiveValue=value}inherits(TerminalNode,Node);TerminalNode.prototype.isTerminal=function(){return true};TerminalNode.prototype.toJSON=function(){var r={};r[this.ctorName]=this.primitiveValue;return r};function NonterminalNode(grammar,ruleName,children,source){Node.call(this,grammar,ruleName,children,source)}inherits(NonterminalNode,Node);NonterminalNode.prototype.isNonterminal=function(){return true};NonterminalNode.prototype.isLexical=function(){return common.isLexical(this.ctorName)};NonterminalNode.prototype.isSyntactic=function(){return common.isSyntactic(this.ctorName)};function IterationNode(grammar,children,source,optional){Node.call(this,grammar,"_iter",children,source);this.optional=optional}inherits(IterationNode,Node);IterationNode.prototype.isIteration=function(){return true};IterationNode.prototype.isOptional=function(){return this.optional};module.exports={Node:Node,TerminalNode:TerminalNode,NonterminalNode:NonterminalNode,IterationNode:IterationNode}},{"./common":41,inherits:25}],45:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");pexprs.PExpr.prototype.allowsSkippingPrecedingSpace=common.abstract("allowsSkippingPrecedingSpace");pexprs.any.allowsSkippingPrecedingSpace=pexprs.end.allowsSkippingPrecedingSpace=pexprs.Apply.prototype.allowsSkippingPrecedingSpace=pexprs.Terminal.prototype.allowsSkippingPrecedingSpace=pexprs.Range.prototype.allowsSkippingPrecedingSpace=pexprs.UnicodeChar.prototype.allowsSkippingPrecedingSpace=function(){return true};pexprs.Alt.prototype.allowsSkippingPrecedingSpace=pexprs.Iter.prototype.allowsSkippingPrecedingSpace=pexprs.Lex.prototype.allowsSkippingPrecedingSpace=pexprs.Lookahead.prototype.allowsSkippingPrecedingSpace=pexprs.Not.prototype.allowsSkippingPrecedingSpace=pexprs.Param.prototype.allowsSkippingPrecedingSpace=pexprs.Seq.prototype.allowsSkippingPrecedingSpace=function(){return false}},{"./common":41,"./pexprs":61}],46:[function(require,module,exports){"use strict";var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");var lexifyCount;pexprs.PExpr.prototype.assertAllApplicationsAreValid=function(ruleName,grammar){lexifyCount=0;this._assertAllApplicationsAreValid(ruleName,grammar)};pexprs.PExpr.prototype._assertAllApplicationsAreValid=common.abstract("_assertAllApplicationsAreValid");pexprs.any._assertAllApplicationsAreValid=pexprs.end._assertAllApplicationsAreValid=pexprs.Terminal.prototype._assertAllApplicationsAreValid=pexprs.Range.prototype._assertAllApplicationsAreValid=pexprs.Param.prototype._assertAllApplicationsAreValid=pexprs.UnicodeChar.prototype._assertAllApplicationsAreValid=function(ruleName,grammar){};pexprs.Lex.prototype._assertAllApplicationsAreValid=function(ruleName,grammar){lexifyCount++;this.expr._assertAllApplicationsAreValid(ruleName,grammar);lexifyCount--};pexprs.Alt.prototype._assertAllApplicationsAreValid=function(ruleName,grammar){for(var idx=0;idx0)){throw errors.applicationOfSyntacticRuleFromLexicalContext(this.ruleName,this)}var actual=this.args.length;var expected=ruleInfo.formals.length;if(actual!==expected){throw errors.wrongNumberOfArguments(this.ruleName,expected,actual,this.source)}var self=this;this.args.forEach(function(arg){arg._assertAllApplicationsAreValid(ruleName,grammar);if(arg.getArity()!==1){throw errors.invalidParameter(self.ruleName,arg)}})}},{"./common":41,"./errors":42,"./pexprs":61}],47:[function(require,module,exports){"use strict";var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");pexprs.PExpr.prototype.assertChoicesHaveUniformArity=common.abstract("assertChoicesHaveUniformArity");pexprs.any.assertChoicesHaveUniformArity=pexprs.end.assertChoicesHaveUniformArity=pexprs.Terminal.prototype.assertChoicesHaveUniformArity=pexprs.Range.prototype.assertChoicesHaveUniformArity=pexprs.Param.prototype.assertChoicesHaveUniformArity=pexprs.Lex.prototype.assertChoicesHaveUniformArity=pexprs.UnicodeChar.prototype.assertChoicesHaveUniformArity=function(ruleName){};pexprs.Alt.prototype.assertChoicesHaveUniformArity=function(ruleName){if(this.terms.length===0){return}var arity=this.terms[0].getArity();for(var idx=0;idx=1};pexprs.end.check=function(grammar,vals){return vals[0]instanceof nodes.Node&&vals[0].isTerminal()&&vals[0].primitiveValue===undefined};pexprs.Terminal.prototype.check=function(grammar,vals){return vals[0]instanceof nodes.Node&&vals[0].isTerminal()&&vals[0].primitiveValue===this.obj};pexprs.Range.prototype.check=function(grammar,vals){return vals[0]instanceof nodes.Node&&vals[0].isTerminal()&&typeof vals[0].primitiveValue===typeof this.from};pexprs.Param.prototype.check=function(grammar,vals){return vals.length>=1};pexprs.Alt.prototype.check=function(grammar,vals){for(var i=0;i0){var i=Math.floor(Math.random()*successfulExamples.length);ans.value=successfulExamples[i]}if(examplesNeeded.length>0){ans.examplesNeeded=examplesNeeded}ans.needHelp=needHelp;return ans};pexprs.Seq.prototype.generateExample=function(grammar,examples,inSyntacticContext,actuals){var factorExamples=this.factors.map(function(factor){return factor.generateExample(grammar,examples,inSyntacticContext,actuals); +});var categorizedExamples=categorizeExamples(factorExamples);var examplesNeeded=categorizedExamples.examplesNeeded;var successfulExamples=categorizedExamples.successfulExamples;var needHelp=categorizedExamples.needHelp;var ans={};if(examplesNeeded.length>0||needHelp){ans.examplesNeeded=examplesNeeded;ans.needHelp=needHelp}else{ans.value=successfulExamples.join(inSyntacticContext?" ":"")}return ans};pexprs.Iter.prototype.generateExample=function(grammar,examples,inSyntacticContext,actuals){var rangeTimes=Math.min(this.maxNumMatches-this.minNumMatches,3);var numTimes=Math.floor(Math.random()*(rangeTimes+1)+this.minNumMatches);var items=[];for(var i=0;i0){ans.examplesNeeded=examplesNeeded}return ans};pexprs.Not.prototype.generateExample=function(grammar,examples,inSyntacticContext){return{value:""}};pexprs.Lookahead.prototype.generateExample=function(grammar,examples,inSyntacticContext){return{value:""}};pexprs.Lex.prototype.generateExample=function(grammar,examples,inSyntacticContext,actuals){return this.expr.generateExample(grammar,examples,false,actuals)};pexprs.Apply.prototype.generateExample=function(grammar,examples,inSyntacticContext,actuals){var ans={};var ruleName=this.substituteParams(actuals).toString();if(!examples.hasOwnProperty(ruleName)){ans.examplesNeeded=[ruleName]}else{var relevantExamples=examples[ruleName];var i=Math.floor(Math.random()*relevantExamples.length);ans.value=relevantExamples[i]}return ans};pexprs.UnicodeChar.prototype.generateExample=function(grammar,examples,inSyntacticContext,actuals){var char;switch(this.category){case"Lu":char="Á";break;case"Ll":char="ŏ";break;case"Lt":char="Dž";break;case"Lm":char="ˮ";break;case"Lo":char="ƻ";break;case"Nl":char="ↂ";break;case"Nd":char="½";break;case"Mn":char="҇";break;case"Mc":char="ि";break;case"Pc":char="⁀";break;case"Zs":char=" ";break;case"L":char="Á";break;case"Ltmo":char="Dž";break}return{value:char}}},{"./common":41,"./pexprs":61}],52:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");pexprs.PExpr.prototype.getArity=common.abstract("getArity");pexprs.any.getArity=pexprs.end.getArity=pexprs.Terminal.prototype.getArity=pexprs.Range.prototype.getArity=pexprs.Param.prototype.getArity=pexprs.Apply.prototype.getArity=pexprs.UnicodeChar.prototype.getArity=function(){return 1};pexprs.Alt.prototype.getArity=function(){return this.terms.length===0?0:this.terms[0].getArity()};pexprs.Seq.prototype.getArity=function(){var arity=0;for(var idx=0;idx=0){if(this.args.length>0){throw new Error("Parameterized rules cannot be passed as arguments to another rule.")}return new pexprs.Param(index)}else{this.args.forEach(function(arg,idx,args){args[idx]=arg.introduceParams(formals)});return this}}},{"./common":41,"./pexprs":61}],54:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");pexprs.PExpr.prototype.isNullable=function(grammar){return this._isNullable(grammar,Object.create(null))};pexprs.PExpr.prototype._isNullable=common.abstract("_isNullable");pexprs.any._isNullable=pexprs.Range.prototype._isNullable=pexprs.Param.prototype._isNullable=pexprs.Plus.prototype._isNullable=pexprs.UnicodeChar.prototype._isNullable=function(grammar,memo){return false};pexprs.end._isNullable=function(grammar,memo){return true};pexprs.Terminal.prototype._isNullable=function(grammar,memo){if(typeof this.obj==="string"){return this.obj===""}else{return false}};pexprs.Alt.prototype._isNullable=function(grammar,memo){return this.terms.length===0||this.terms.some(function(term){return term._isNullable(grammar,memo)})};pexprs.Seq.prototype._isNullable=function(grammar,memo){return this.factors.every(function(factor){return factor._isNullable(grammar,memo)})};pexprs.Star.prototype._isNullable=pexprs.Opt.prototype._isNullable=pexprs.Not.prototype._isNullable=pexprs.Lookahead.prototype._isNullable=function(grammar,memo){return true};pexprs.Lex.prototype._isNullable=function(grammar,memo){return this.expr._isNullable(grammar,memo)};pexprs.Apply.prototype._isNullable=function(grammar,memo){var key=this.toMemoKey();if(!Object.prototype.hasOwnProperty.call(memo,key)){var body=grammar.rules[this.ruleName].body;var inlined=body.substituteParams(this.args);memo[key]=false;memo[key]=inlined._isNullable(grammar,memo)}return memo[key]}},{"./common":41,"./pexprs":61}],55:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");function getMetaInfo(expr,grammarInterval){var metaInfo={};if(expr.source&&grammarInterval){var adjusted=expr.source.relativeTo(grammarInterval);metaInfo.sourceInterval=[adjusted.startIdx,adjusted.endIdx]}return metaInfo}pexprs.PExpr.prototype.outputRecipe=common.abstract("outputRecipe");pexprs.any.outputRecipe=function(formals,grammarInterval){return["any",getMetaInfo(this,grammarInterval)]};pexprs.end.outputRecipe=function(formals,grammarInterval){return["end",getMetaInfo(this,grammarInterval)]};pexprs.Terminal.prototype.outputRecipe=function(formals,grammarInterval){return["terminal",getMetaInfo(this,grammarInterval),this.obj]};pexprs.Range.prototype.outputRecipe=function(formals,grammarInterval){return["range",getMetaInfo(this,grammarInterval),this.from,this.to]};pexprs.Param.prototype.outputRecipe=function(formals,grammarInterval){return["param",getMetaInfo(this,grammarInterval),this.index]};pexprs.Alt.prototype.outputRecipe=function(formals,grammarInterval){return["alt",getMetaInfo(this,grammarInterval)].concat(this.terms.map(function(term){return term.outputRecipe(formals,grammarInterval)}))};pexprs.Extend.prototype.outputRecipe=function(formals,grammarInterval){var extension=this.terms[0];return extension.outputRecipe(formals,grammarInterval)};pexprs.Seq.prototype.outputRecipe=function(formals,grammarInterval){return["seq",getMetaInfo(this,grammarInterval)].concat(this.factors.map(function(factor){return factor.outputRecipe(formals,grammarInterval)}))};pexprs.Star.prototype.outputRecipe=pexprs.Plus.prototype.outputRecipe=pexprs.Opt.prototype.outputRecipe=pexprs.Not.prototype.outputRecipe=pexprs.Lookahead.prototype.outputRecipe=pexprs.Lex.prototype.outputRecipe=function(formals,grammarInterval){return[this.constructor.name.toLowerCase(),getMetaInfo(this,grammarInterval),this.expr.outputRecipe(formals,grammarInterval)]};pexprs.Apply.prototype.outputRecipe=function(formals,grammarInterval){return["app",getMetaInfo(this,grammarInterval),this.ruleName,this.args.map(function(arg){return arg.outputRecipe(formals,grammarInterval)})]};pexprs.UnicodeChar.prototype.outputRecipe=function(formals,grammarInterval){return["unicodeChar",getMetaInfo(this,grammarInterval),this.category]}},{"./common":41,"./pexprs":61}],56:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");pexprs.PExpr.prototype.substituteParams=common.abstract("substituteParams");pexprs.any.substituteParams=pexprs.end.substituteParams=pexprs.Terminal.prototype.substituteParams=pexprs.Range.prototype.substituteParams=pexprs.UnicodeChar.prototype.substituteParams=function(actuals){return this};pexprs.Param.prototype.substituteParams=function(actuals){return actuals[this.index]};pexprs.Alt.prototype.substituteParams=function(actuals){return new pexprs.Alt(this.terms.map(function(term){return term.substituteParams(actuals)}))};pexprs.Seq.prototype.substituteParams=function(actuals){return new pexprs.Seq(this.factors.map(function(factor){return factor.substituteParams(actuals)}))};pexprs.Iter.prototype.substituteParams=pexprs.Not.prototype.substituteParams=pexprs.Lookahead.prototype.substituteParams=pexprs.Lex.prototype.substituteParams=function(actuals){return new this.constructor(this.expr.substituteParams(actuals))};pexprs.Apply.prototype.substituteParams=function(actuals){if(this.args.length===0){return this}else{var args=this.args.map(function(arg){return arg.substituteParams(actuals)});return new pexprs.Apply(this.ruleName,args)}}},{"./common":41,"./pexprs":61}],57:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");var copyWithoutDuplicates=common.copyWithoutDuplicates;function isRestrictedJSIdentifier(str){return/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(str)}function resolveDuplicatedNames(argumentNameList){var count=Object.create(null);argumentNameList.forEach(function(argName){count[argName]=(count[argName]||0)+1});Object.keys(count).forEach(function(dupArgName){if(count[dupArgName]<=1){return}var subscript=1;argumentNameList.forEach(function(argName,idx){if(argName===dupArgName){argumentNameList[idx]=argName+"_"+subscript++}})})}pexprs.PExpr.prototype.toArgumentNameList=common.abstract("toArgumentNameList");pexprs.any.toArgumentNameList=function(firstArgIndex,noDupCheck){return["any"]};pexprs.end.toArgumentNameList=function(firstArgIndex,noDupCheck){return["end"]};pexprs.Terminal.prototype.toArgumentNameList=function(firstArgIndex,noDupCheck){if(typeof this.obj==="string"&&/^[_a-zA-Z0-9]+$/.test(this.obj)){return["_"+this.obj]}else{return["$"+firstArgIndex]}};pexprs.Range.prototype.toArgumentNameList=function(firstArgIndex,noDupCheck){var argName=this.from+"_to_"+this.to;if(!isRestrictedJSIdentifier(argName)){argName="_"+argName}if(!isRestrictedJSIdentifier(argName)){argName="$"+firstArgIndex}return[argName]};pexprs.Alt.prototype.toArgumentNameList=function(firstArgIndex,noDupCheck){var termArgNameLists=this.terms.map(function(term){return term.toArgumentNameList(firstArgIndex,true)});var argumentNameList=[];var numArgs=termArgNameLists[0].length;for(var colIdx=0;colIdx0){var ps=this.args.map(function(arg){return arg.toString()});return this.ruleName+"<"+ps.join(",")+">"}else{return this.ruleName}};pexprs.UnicodeChar.prototype.toString=function(){return"\\p{"+this.category+"}"}},{"./common":41,"./pexprs":61}],61:[function(require,module,exports){"use strict";var UnicodeCategories=require("../third_party/UnicodeCategories");var common=require("./common");var errors=require("./errors");var inherits=require("inherits");function PExpr(){throw new Error("PExpr cannot be instantiated -- it's abstract")}PExpr.prototype.withSource=function(interval){if(interval){this.source=interval.trimmed()}return this};var any=Object.create(PExpr.prototype);var end=Object.create(PExpr.prototype);function Terminal(obj){this.obj=obj}inherits(Terminal,PExpr);function Range(from,to){this.from=from;this.to=to}inherits(Range,PExpr);function Param(index){this.index=index}inherits(Param,PExpr);function Alt(terms){this.terms=terms}inherits(Alt,PExpr);function Extend(superGrammar,name,body){this.superGrammar=superGrammar;this.name=name;this.body=body;var origBody=superGrammar.rules[name].body;this.terms=[body,origBody]}inherits(Extend,Alt);function Seq(factors){this.factors=factors}inherits(Seq,PExpr);function Iter(expr){this.expr=expr}inherits(Iter,PExpr);function Star(expr){this.expr=expr}inherits(Star,Iter);function Plus(expr){this.expr=expr}inherits(Plus,Iter);function Opt(expr){this.expr=expr}inherits(Opt,Iter);Star.prototype.operator="*";Plus.prototype.operator="+";Opt.prototype.operator="?";Star.prototype.minNumMatches=0;Plus.prototype.minNumMatches=1;Opt.prototype.minNumMatches=0;Star.prototype.maxNumMatches=Number.POSITIVE_INFINITY;Plus.prototype.maxNumMatches=Number.POSITIVE_INFINITY;Opt.prototype.maxNumMatches=1;function Not(expr){this.expr=expr}inherits(Not,PExpr);function Lookahead(expr){this.expr=expr}inherits(Lookahead,PExpr);function Lex(expr){this.expr=expr}inherits(Lex,PExpr);function Arr(expr){this.expr=expr}inherits(Arr,PExpr);function Str(expr){this.expr=expr}inherits(Str,PExpr);function Obj(properties,isLenient){var names=properties.map(function(property){return property.name});var duplicates=common.getDuplicates(names);if(duplicates.length>0){throw errors.duplicatePropertyNames(duplicates)}else{this.properties=properties;this.isLenient=isLenient}}inherits(Obj,PExpr);function Apply(ruleName,optArgs){this.ruleName=ruleName;this.args=optArgs||[]}inherits(Apply,PExpr);Apply.prototype.isSyntactic=function(){return common.isSyntactic(this.ruleName)};Apply.prototype.toMemoKey=function(){if(!this._memoKey){Object.defineProperty(this,"_memoKey",{value:this.toString()})}return this._memoKey};function UnicodeChar(category){this.category=category;this.pattern=UnicodeCategories[category]}inherits(UnicodeChar,PExpr);exports.PExpr=PExpr;exports.any=any;exports.end=end;exports.Terminal=Terminal;exports.Range=Range;exports.Param=Param;exports.Alt=Alt;exports.Extend=Extend;exports.Seq=Seq;exports.Iter=Iter;exports.Star=Star;exports.Plus=Plus;exports.Opt=Opt;exports.Not=Not;exports.Lookahead=Lookahead;exports.Lex=Lex;exports.Arr=Arr;exports.Str=Str;exports.Obj=Obj;exports.Apply=Apply;exports.UnicodeChar=UnicodeChar;require("./pexprs-allowsSkippingPrecedingSpace");require("./pexprs-assertAllApplicationsAreValid");require("./pexprs-assertChoicesHaveUniformArity");require("./pexprs-assertIteratedExprsAreNotNullable");require("./pexprs-check");require("./pexprs-eval");require("./pexprs-getArity");require("./pexprs-generateExample");require("./pexprs-outputRecipe");require("./pexprs-introduceParams");require("./pexprs-isNullable");require("./pexprs-substituteParams");require("./pexprs-toDisplayString");require("./pexprs-toArgumentNameList");require("./pexprs-toFailure");require("./pexprs-toString")},{"../third_party/UnicodeCategories":63,"./common":41,"./errors":42,"./pexprs-allowsSkippingPrecedingSpace":45,"./pexprs-assertAllApplicationsAreValid":46,"./pexprs-assertChoicesHaveUniformArity":47,"./pexprs-assertIteratedExprsAreNotNullable":48,"./pexprs-check":49,"./pexprs-eval":50,"./pexprs-generateExample":51,"./pexprs-getArity":52,"./pexprs-introduceParams":53,"./pexprs-isNullable":54,"./pexprs-outputRecipe":55,"./pexprs-substituteParams":56,"./pexprs-toArgumentNameList":57,"./pexprs-toDisplayString":58,"./pexprs-toFailure":59,"./pexprs-toString":60,inherits:25}],62:[function(require,module,exports){"use strict";var common=require("./common");function padNumbersToEqualLength(arr){var maxLen=0;var strings=arr.map(function(n){var str=n.toString();maxLen=Math.max(maxLen,str.length);return str});return strings.map(function(s){return common.padLeft(s,maxLen)})}function strcpy(dest,src,offset){var origDestLen=dest.length;var start=dest.slice(0,offset);var end=dest.slice(offset+src.length);return(start+src+end).substr(0,origDestLen)}exports.getLineAndColumn=function(str,offset){var lineNum=1;var colNum=1;var currOffset=0;var lineStartOffset=0;var nextLine=null;var prevLine=null;var prevLineStartOffset=-1;while(currOffset=0){prevLine=str.slice(prevLineStartOffset,lineStartOffset).replace(/\r?\n$/,"")}var line=str.slice(lineStartOffset,lineEndOffset).replace(/\r$/,"");return{lineNum:lineNum,colNum:colNum,line:line,prevLine:prevLine,nextLine:nextLine}};exports.getLineAndColumnMessage=function(str,offset){var repeatStr=common.repeatStr;var lineAndCol=exports.getLineAndColumn(str,offset);var sb=new common.StringBuffer;sb.append("Line "+lineAndCol.lineNum+", col "+lineAndCol.colNum+":\n");var lineNumbers=padNumbersToEqualLength([lineAndCol.prevLine==null?0:lineAndCol.lineNum-1,lineAndCol.lineNum,lineAndCol.nextLine==null?0:lineAndCol.lineNum+1]);function appendLine(num,content,prefix){sb.append(prefix+lineNumbers[num]+" | "+content+"\n")}if(lineAndCol.prevLine!=null){appendLine(0,lineAndCol.prevLine," ")}appendLine(1,lineAndCol.line,"> ");var lineLen=lineAndCol.line.length;var indicationLine=repeatStr(" ",lineLen+1);var ranges=Array.prototype.slice.call(arguments,2);for(var i=0;i=0&&startIdx<=endIdx,"range start must be >= 0 and <= end");var lineStartOffset=offset-lineAndCol.colNum+1;startIdx=Math.max(0,startIdx-lineStartOffset);endIdx=Math.min(endIdx-lineStartOffset,lineLen);indicationLine=strcpy(indicationLine,repeatStr("~",endIdx-startIdx),startIdx)}var gutterWidth=2+lineNumbers[1].length+3;sb.append(repeatStr(" ",gutterWidth));indicationLine=strcpy(indicationLine,"^",lineAndCol.colNum-1);sb.append(indicationLine.replace(/ +$/,"")+"\n");if(lineAndCol.nextLine!=null){appendLine(2,lineAndCol.nextLine," ")}return sb.contents()};exports.getShortLineAndColumnMessage=function(str,offset){var errorInfo=exports.getLineAndColumn(str,offset);return"Line "+errorInfo.lineNum+", col "+errorInfo.colNum+": "}},{"./common":41}],63:[function(require,module,exports){module.exports={Lu:/[\u0041-\u005A]|[\u00C0-\u00D6]|[\u00D8-\u00DE]|[\u0100-\u0100]|[\u0102-\u0102]|[\u0104-\u0104]|[\u0106-\u0106]|[\u0108-\u0108]|[\u010A-\u010A]|[\u010C-\u010C]|[\u010E-\u010E]|[\u0110-\u0110]|[\u0112-\u0112]|[\u0114-\u0114]|[\u0116-\u0116]|[\u0118-\u0118]|[\u011A-\u011A]|[\u011C-\u011C]|[\u011E-\u011E]|[\u0120-\u0120]|[\u0122-\u0122]|[\u0124-\u0124]|[\u0126-\u0126]|[\u0128-\u0128]|[\u012A-\u012A]|[\u012C-\u012C]|[\u012E-\u012E]|[\u0130-\u0130]|[\u0132-\u0132]|[\u0134-\u0134]|[\u0136-\u0136]|[\u0139-\u0139]|[\u013B-\u013B]|[\u013D-\u013D]|[\u013F-\u013F]|[\u0141-\u0141]|[\u0143-\u0143]|[\u0145-\u0145]|[\u0147-\u0147]|[\u014A-\u014A]|[\u014C-\u014C]|[\u014E-\u014E]|[\u0150-\u0150]|[\u0152-\u0152]|[\u0154-\u0154]|[\u0156-\u0156]|[\u0158-\u0158]|[\u015A-\u015A]|[\u015C-\u015C]|[\u015E-\u015E]|[\u0160-\u0160]|[\u0162-\u0162]|[\u0164-\u0164]|[\u0166-\u0166]|[\u0168-\u0168]|[\u016A-\u016A]|[\u016C-\u016C]|[\u016E-\u016E]|[\u0170-\u0170]|[\u0172-\u0172]|[\u0174-\u0174]|[\u0176-\u0176]|[\u0178-\u0179]|[\u017B-\u017B]|[\u017D-\u017D]|[\u0181-\u0182]|[\u0184-\u0184]|[\u0186-\u0187]|[\u0189-\u018B]|[\u018E-\u0191]|[\u0193-\u0194]|[\u0196-\u0198]|[\u019C-\u019D]|[\u019F-\u01A0]|[\u01A2-\u01A2]|[\u01A4-\u01A4]|[\u01A6-\u01A7]|[\u01A9-\u01A9]|[\u01AC-\u01AC]|[\u01AE-\u01AF]|[\u01B1-\u01B3]|[\u01B5-\u01B5]|[\u01B7-\u01B8]|[\u01BC-\u01BC]|[\u01C4-\u01C4]|[\u01C7-\u01C7]|[\u01CA-\u01CA]|[\u01CD-\u01CD]|[\u01CF-\u01CF]|[\u01D1-\u01D1]|[\u01D3-\u01D3]|[\u01D5-\u01D5]|[\u01D7-\u01D7]|[\u01D9-\u01D9]|[\u01DB-\u01DB]|[\u01DE-\u01DE]|[\u01E0-\u01E0]|[\u01E2-\u01E2]|[\u01E4-\u01E4]|[\u01E6-\u01E6]|[\u01E8-\u01E8]|[\u01EA-\u01EA]|[\u01EC-\u01EC]|[\u01EE-\u01EE]|[\u01F1-\u01F1]|[\u01F4-\u01F4]|[\u01FA-\u01FA]|[\u01FC-\u01FC]|[\u01FE-\u01FE]|[\u0200-\u0200]|[\u0202-\u0202]|[\u0204-\u0204]|[\u0206-\u0206]|[\u0208-\u0208]|[\u020A-\u020A]|[\u020C-\u020C]|[\u020E-\u020E]|[\u0210-\u0210]|[\u0212-\u0212]|[\u0214-\u0214]|[\u0216-\u0216]|[\u0386-\u0386]|[\u0388-\u038A]|[\u038C-\u038C]|[\u038E-\u038F]|[\u0391-\u03A1]|[\u03A3-\u03AB]|[\u03D2-\u03D4]|[\u03DA-\u03DA]|[\u03DC-\u03DC]|[\u03DE-\u03DE]|[\u03E0-\u03E0]|[\u03E2-\u03E2]|[\u03E4-\u03E4]|[\u03E6-\u03E6]|[\u03E8-\u03E8]|[\u03EA-\u03EA]|[\u03EC-\u03EC]|[\u03EE-\u03EE]|[\u0401-\u040C]|[\u040E-\u042F]|[\u0460-\u0460]|[\u0462-\u0462]|[\u0464-\u0464]|[\u0466-\u0466]|[\u0468-\u0468]|[\u046A-\u046A]|[\u046C-\u046C]|[\u046E-\u046E]|[\u0470-\u0470]|[\u0472-\u0472]|[\u0474-\u0474]|[\u0476-\u0476]|[\u0478-\u0478]|[\u047A-\u047A]|[\u047C-\u047C]|[\u047E-\u047E]|[\u0480-\u0480]|[\u0490-\u0490]|[\u0492-\u0492]|[\u0494-\u0494]|[\u0496-\u0496]|[\u0498-\u0498]|[\u049A-\u049A]|[\u049C-\u049C]|[\u049E-\u049E]|[\u04A0-\u04A0]|[\u04A2-\u04A2]|[\u04A4-\u04A4]|[\u04A6-\u04A6]|[\u04A8-\u04A8]|[\u04AA-\u04AA]|[\u04AC-\u04AC]|[\u04AE-\u04AE]|[\u04B0-\u04B0]|[\u04B2-\u04B2]|[\u04B4-\u04B4]|[\u04B6-\u04B6]|[\u04B8-\u04B8]|[\u04BA-\u04BA]|[\u04BC-\u04BC]|[\u04BE-\u04BE]|[\u04C1-\u04C1]|[\u04C3-\u04C3]|[\u04C7-\u04C7]|[\u04CB-\u04CB]|[\u04D0-\u04D0]|[\u04D2-\u04D2]|[\u04D4-\u04D4]|[\u04D6-\u04D6]|[\u04D8-\u04D8]|[\u04DA-\u04DA]|[\u04DC-\u04DC]|[\u04DE-\u04DE]|[\u04E0-\u04E0]|[\u04E2-\u04E2]|[\u04E4-\u04E4]|[\u04E6-\u04E6]|[\u04E8-\u04E8]|[\u04EA-\u04EA]|[\u04EE-\u04EE]|[\u04F0-\u04F0]|[\u04F2-\u04F2]|[\u04F4-\u04F4]|[\u04F8-\u04F8]|[\u0531-\u0556]|[\u10A0-\u10C5]|[\u1E00-\u1E00]|[\u1E02-\u1E02]|[\u1E04-\u1E04]|[\u1E06-\u1E06]|[\u1E08-\u1E08]|[\u1E0A-\u1E0A]|[\u1E0C-\u1E0C]|[\u1E0E-\u1E0E]|[\u1E10-\u1E10]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-\u2124]|[\u2126-\u2126]|[\u2128-\u2128]|[\u212A-\u212D]|[\u2130-\u2131]|[\u2133-\u2133]|[\uFF21-\uFF3A]/,Ll:/[\u0061-\u007A]|[\u00AA-\u00AA]|[\u00B5-\u00B5]|[\u00BA-\u00BA]|[\u00DF-\u00F6]|[\u00F8-\u00FF]|[\u0101-\u0101]|[\u0103-\u0103]|[\u0105-\u0105]|[\u0107-\u0107]|[\u0109-\u0109]|[\u010B-\u010B]|[\u010D-\u010D]|[\u010F-\u010F]|[\u0111-\u0111]|[\u0113-\u0113]|[\u0115-\u0115]|[\u0117-\u0117]|[\u0119-\u0119]|[\u011B-\u011B]|[\u011D-\u011D]|[\u011F-\u011F]|[\u0121-\u0121]|[\u0123-\u0123]|[\u0125-\u0125]|[\u0127-\u0127]|[\u0129-\u0129]|[\u012B-\u012B]|[\u012D-\u012D]|[\u012F-\u012F]|[\u0131-\u0131]|[\u0133-\u0133]|[\u0135-\u0135]|[\u0137-\u0138]|[\u013A-\u013A]|[\u013C-\u013C]|[\u013E-\u013E]|[\u0140-\u0140]|[\u0142-\u0142]|[\u0144-\u0144]|[\u0146-\u0146]|[\u0148-\u0149]|[\u014B-\u014B]|[\u014D-\u014D]|[\u014F-\u014F]|[\u0151-\u0151]|[\u0153-\u0153]|[\u0155-\u0155]|[\u0157-\u0157]|[\u0159-\u0159]|[\u015B-\u015B]|[\u015D-\u015D]|[\u015F-\u015F]|[\u0161-\u0161]|[\u0163-\u0163]|[\u0165-\u0165]|[\u0167-\u0167]|[\u0169-\u0169]|[\u016B-\u016B]|[\u016D-\u016D]|[\u016F-\u016F]|[\u0171-\u0171]|[\u0173-\u0173]|[\u0175-\u0175]|[\u0177-\u0177]|[\u017A-\u017A]|[\u017C-\u017C]|[\u017E-\u0180]|[\u0183-\u0183]|[\u0185-\u0185]|[\u0188-\u0188]|[\u018C-\u018D]|[\u0192-\u0192]|[\u0195-\u0195]|[\u0199-\u019B]|[\u019E-\u019E]|[\u01A1-\u01A1]|[\u01A3-\u01A3]|[\u01A5-\u01A5]|[\u01A8-\u01A8]|[\u01AB-\u01AB]|[\u01AD-\u01AD]|[\u01B0-\u01B0]|[\u01B4-\u01B4]|[\u01B6-\u01B6]|[\u01B9-\u01BA]|[\u01BD-\u01BD]|[\u01C6-\u01C6]|[\u01C9-\u01C9]|[\u01CC-\u01CC]|[\u01CE-\u01CE]|[\u01D0-\u01D0]|[\u01D2-\u01D2]|[\u01D4-\u01D4]|[\u01D6-\u01D6]|[\u01D8-\u01D8]|[\u01DA-\u01DA]|[\u01DC-\u01DD]|[\u01DF-\u01DF]|[\u01E1-\u01E1]|[\u01E3-\u01E3]|[\u01E5-\u01E5]|[\u01E7-\u01E7]|[\u01E9-\u01E9]|[\u01EB-\u01EB]|[\u01ED-\u01ED]|[\u01EF-\u01F0]|[\u01F3-\u01F3]|[\u01F5-\u01F5]|[\u01FB-\u01FB]|[\u01FD-\u01FD]|[\u01FF-\u01FF]|[\u0201-\u0201]|[\u0203-\u0203]|[\u0205-\u0205]|[\u0207-\u0207]|[\u0209-\u0209]|[\u020B-\u020B]|[\u020D-\u020D]|[\u020F-\u020F]|[\u0211-\u0211]|[\u0213-\u0213]|[\u0215-\u0215]|[\u0217-\u0217]|[\u0250-\u02A8]|[\u0390-\u0390]|[\u03AC-\u03CE]|[\u03D0-\u03D1]|[\u03D5-\u03D6]|[\u03E3-\u03E3]|[\u03E5-\u03E5]|[\u03E7-\u03E7]|[\u03E9-\u03E9]|[\u03EB-\u03EB]|[\u03ED-\u03ED]|[\u03EF-\u03F2]|[\u0430-\u044F]|[\u0451-\u045C]|[\u045E-\u045F]|[\u0461-\u0461]|[\u0463-\u0463]|[\u0465-\u0465]|[\u0467-\u0467]|[\u0469-\u0469]|[\u046B-\u046B]|[\u046D-\u046D]|[\u046F-\u046F]|[\u0471-\u0471]|[\u0473-\u0473]|[\u0475-\u0475]|[\u0477-\u0477]|[\u0479-\u0479]|[\u047B-\u047B]|[\u047D-\u047D]|[\u047F-\u047F]|[\u0481-\u0481]|[\u0491-\u0491]|[\u0493-\u0493]|[\u0495-\u0495]|[\u0497-\u0497]|[\u0499-\u0499]|[\u049B-\u049B]|[\u049D-\u049D]|[\u049F-\u049F]|[\u04A1-\u04A1]|[\u04A3-\u04A3]|[\u04A5-\u04A5]|[\u04A7-\u04A7]|[\u04A9-\u04A9]|[\u04AB-\u04AB]|[\u04AD-\u04AD]|[\u04AF-\u04AF]|[\u04B1-\u04B1]|[\u04B3-\u04B3]|[\u04B5-\u04B5]|[\u04B7-\u04B7]|[\u04B9-\u04B9]|[\u04BB-\u04BB]|[\u04BD-\u04BD]|[\u04BF-\u04BF]|[\u04C2-\u04C2]|[\u04C4-\u04C4]|[\u04C8-\u04C8]|[\u04CC-\u04CC]|[\u04D1-\u04D1]|[\u04D3-\u04D3]|[\u04D5-\u04D5]|[\u04D7-\u04D7]|[\u04D9-\u04D9]|[\u04DB-\u04DB]|[\u04DD-\u04DD]|[\u04DF-\u04DF]|[\u04E1-\u04E1]|[\u04E3-\u04E3]|[\u04E5-\u04E5]|[\u04E7-\u04E7]|[\u04E9-\u04E9]|[\u04EB-\u04EB]|[\u04EF-\u04EF]|[\u04F1-\u04F1]|[\u04F3-\u04F3]|[\u04F5-\u04F5]|[\u04F9-\u04F9]|[\u0561-\u0587]|[\u10D0-\u10F6]|[\u1E01-\u1E01]|[\u1E03-\u1E03]|[\u1E05-\u1E05]|[\u1E07-\u1E07]|[\u1E09-\u1E09]|[\u1E0B-\u1E0B]|[\u1E0D-\u1E0D]|[\u1E0F-\u1E0F]|[\u1E11-\u1E11]|[\u1E13-\u1E13]|[\u1E15-\u1E15]|[\u1E17-\u1E17]|[\u1E19-\u1E19]|[\u1E1B-\u1E1B]|[\u1E1D-\u1E1D]|[\u1E1F-\u1E1F]|[\u1E21-\u1E21]|[\u1E23-\u1E23]|[\u1E25-\u1E25]|[\u1E27-\u1E27]|[\u1E29-\u1E29]|[\u1E2B-\u1E2B]|[\u1E2D-\u1E2D]|[\u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]|[\u037A-\u037A]|[\u0559-\u0559]|[\u0640-\u0640]|[\u06E5-\u06E6]|[\u0E46-\u0E46]|[\u0EC6-\u0EC6]|[\u3005-\u3005]|[\u3031-\u3035]|[\u309D-\u309E]|[\u30FC-\u30FE]|[\uFF70-\uFF70]|[\uFF9E-\uFF9F]/,Lo:/[\u01AA-\u01AA]|[\u01BB-\u01BB]|[\u01BE-\u01C3]|[\u03F3-\u03F3]|[\u04C0-\u04C0]|[\u05D0-\u05EA]|[\u05F0-\u05F2]|[\u0621-\u063A]|[\u0641-\u064A]|[\u0671-\u06B7]|[\u06BA-\u06BE]|[\u06C0-\u06CE]|[\u06D0-\u06D3]|[\u06D5-\u06D5]|[\u0905-\u0939]|[\u093D-\u093D]|[\u0950-\u0950]|[\u0958-\u0961]|[\u0985-\u098C]|[\u098F-\u0990]|[\u0993-\u09A8]|[\u09AA-\u09B0]|[\u09B2-\u09B2]|[\u09B6-\u09B9]|[\u09DC-\u09DD]|[\u09DF-\u09E1]|[\u09F0-\u09F1]|[\u0A05-\u0A0A]|[\u0A0F-\u0A10]|[\u0A13-\u0A28]|[\u0A2A-\u0A30]|[\u0A32-\u0A33]|[\u0A35-\u0A36]|[\u0A38-\u0A39]|[\u0A59-\u0A5C]|[\u0A5E-\u0A5E]|[\u0A72-\u0A74]|[\u0A85-\u0A8B]|[\u0A8D-\u0A8D]|[\u0A8F-\u0A91]|[\u0A93-\u0AA8]|[\u0AAA-\u0AB0]|[\u0AB2-\u0AB3]|[\u0AB5-\u0AB9]|[\u0ABD-\u0ABD]|[\u0AD0-\u0AD0]|[\u0AE0-\u0AE0]|[\u0B05-\u0B0C]|[\u0B0F-\u0B10]|[\u0B13-\u0B28]|[\u0B2A-\u0B30]|[\u0B32-\u0B33]|[\u0B36-\u0B39]|[\u0B3D-\u0B3D]|[\u0B5C-\u0B5D]|[\u0B5F-\u0B61]|[\u0B85-\u0B8A]|[\u0B8E-\u0B90]|[\u0B92-\u0B95]|[\u0B99-\u0B9A]|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0-\uFDFB]|[\uFE70-\uFE72]|[\uFE74-\uFE74]|[\uFE76-\uFEFC]|[\uFF66-\uFF6F]|[\uFF71-\uFF9D]|[\uFFA0-\uFFBE]|[\uFFC2-\uFFC7]|[\uFFCA-\uFFCF]|[\uFFD2-\uFFD7]|[\uFFDA-\uFFDC]/,Nl:/[\u2160-\u2182]|[\u3007-\u3007]|[\u3021-\u3029]/,Nd:/[\u0030-\u0039]|[\u0660-\u0669]|[\u06F0-\u06F9]|[\u0966-\u096F]|[\u09E6-\u09EF]|[\u0A66-\u0A6F]|[\u0AE6-\u0AEF]|[\u0B66-\u0B6F]|[\u0BE7-\u0BEF]|[\u0C66-\u0C6F]|[\u0CE6-\u0CEF]|[\u0D66-\u0D6F]|[\u0E50-\u0E59]|[\u0ED0-\u0ED9]|[\u0F20-\u0F29]|[\uFF10-\uFF19]/,Mn:/[\u0300-\u0345]|[\u0360-\u0361]|[\u0483-\u0486]|[\u0591-\u05A1]|[\u05A3-\u05B9]|[\u05BB-\u05BD]|[\u05BF-\u05BF]|[\u05C1-\u05C2]|[\u05C4-\u05C4]|[\u064B-\u0652]|[\u0670-\u0670]|[\u06D6-\u06DC]|[\u06DF-\u06E4]|[\u06E7-\u06E8]|[\u06EA-\u06ED]|[\u0901-\u0902]|[\u093C-\u093C]|[\u0941-\u0948]|[\u094D-\u094D]|[\u0951-\u0954]|[\u0962-\u0963]|[\u0981-\u0981]|[\u09BC-\u09BC]|[\u09C1-\u09C4]|[\u09CD-\u09CD]|[\u09E2-\u09E3]|[\u0A02-\u0A02]|[\u0A3C-\u0A3C]|[\u0A41-\u0A42]|[\u0A47-\u0A48]|[\u0A4B-\u0A4D]|[\u0A70-\u0A71]|[\u0A81-\u0A82]|[\u0ABC-\u0ABC]|[\u0AC1-\u0AC5]|[\u0AC7-\u0AC8]|[\u0ACD-\u0ACD]|[\u0B01-\u0B01]|[\u0B3C-\u0B3C]|[\u0B3F-\u0B3F]|[\u0B41-\u0B43]|[\u0B4D-\u0B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[\u0CCA-\u0CCB]|[\u0CD5-\u0CD6]|[\u0D02-\u0D03]|[\u0D3E-\u0D40]|[\u0D46-\u0D48]|[\u0D4A-\u0D4C]|[\u0D57-\u0D57]|[\u0F3E-\u0F3F]|[\u0F7F-\u0F7F]/,Pc:/[\u005F-\u005F]|[\u203F-\u2040]|[\u30FB-\u30FB]|[\uFE33-\uFE34]|[\uFE4D-\uFE4F]|[\uFF3F-\uFF3F]|[\uFF65-\uFF65]/,Zs:/[\u2000-\u200B]|[\u3000-\u3000]/,L:/[\u0041-\u005A]|[\u00C0-\u00D6]|[\u00D8-\u00DE]|[\u0100-\u0100]|[\u0102-\u0102]|[\u0104-\u0104]|[\u0106-\u0106]|[\u0108-\u0108]|[\u010A-\u010A]|[\u010C-\u010C]|[\u010E-\u010E]|[\u0110-\u0110]|[\u0112-\u0112]|[\u0114-\u0114]|[\u0116-\u0116]|[\u0118-\u0118]|[\u011A-\u011A]|[\u011C-\u011C]|[\u011E-\u011E]|[\u0120-\u0120]|[\u0122-\u0122]|[\u0124-\u0124]|[\u0126-\u0126]|[\u0128-\u0128]|[\u012A-\u012A]|[\u012C-\u012C]|[\u012E-\u012E]|[\u0130-\u0130]|[\u0132-\u0132]|[\u0134-\u0134]|[\u0136-\u0136]|[\u0139-\u0139]|[\u013B-\u013B]|[\u013D-\u013D]|[\u013F-\u013F]|[\u0141-\u0141]|[\u0143-\u0143]|[\u0145-\u0145]|[\u0147-\u0147]|[\u014A-\u014A]|[\u014C-\u014C]|[\u014E-\u014E]|[\u0150-\u0150]|[\u0152-\u0152]|[\u0154-\u0154]|[\u0156-\u0156]|[\u0158-\u0158]|[\u015A-\u015A]|[\u015C-\u015C]|[\u015E-\u015E]|[\u0160-\u0160]|[\u0162-\u0162]|[\u0164-\u0164]|[\u0166-\u0166]|[\u0168-\u0168]|[\u016A-\u016A]|[\u016C-\u016C]|[\u016E-\u016E]|[\u0170-\u0170]|[\u0172-\u0172]|[\u0174-\u0174]|[\u0176-\u0176]|[\u0178-\u0179]|[\u017B-\u017B]|[\u017D-\u017D]|[\u0181-\u0182]|[\u0184-\u0184]|[\u0186-\u0187]|[\u0189-\u018B]|[\u018E-\u0191]|[\u0193-\u0194]|[\u0196-\u0198]|[\u019C-\u019D]|[\u019F-\u01A0]|[\u01A2-\u01A2]|[\u01A4-\u01A4]|[\u01A6-\u01A7]|[\u01A9-\u01A9]|[\u01AC-\u01AC]|[\u01AE-\u01AF]|[\u01B1-\u01B3]|[\u01B5-\u01B5]|[\u01B7-\u01B8]|[\u01BC-\u01BC]|[\u01C4-\u01C4]|[\u01C7-\u01C7]|[\u01CA-\u01CA]|[\u01CD-\u01CD]|[\u01CF-\u01CF]|[\u01D1-\u01D1]|[\u01D3-\u01D3]|[\u01D5-\u01D5]|[\u01D7-\u01D7]|[\u01D9-\u01D9]|[\u01DB-\u01DB]|[\u01DE-\u01DE]|[\u01E0-\u01E0]|[\u01E2-\u01E2]|[\u01E4-\u01E4]|[\u01E6-\u01E6]|[\u01E8-\u01E8]|[\u01EA-\u01EA]|[\u01EC-\u01EC]|[\u01EE-\u01EE]|[\u01F1-\u01F1]|[\u01F4-\u01F4]|[\u01FA-\u01FA]|[\u01FC-\u01FC]|[\u01FE-\u01FE]|[\u0200-\u0200]|[\u0202-\u0202]|[\u0204-\u0204]|[\u0206-\u0206]|[\u0208-\u0208]|[\u020A-\u020A]|[\u020C-\u020C]|[\u020E-\u020E]|[\u0210-\u0210]|[\u0212-\u0212]|[\u0214-\u0214]|[\u0216-\u0216]|[\u0386-\u0386]|[\u0388-\u038A]|[\u038C-\u038C]|[\u038E-\u038F]|[\u0391-\u03A1]|[\u03A3-\u03AB]|[\u03D2-\u03D4]|[\u03DA-\u03DA]|[\u03DC-\u03DC]|[\u03DE-\u03DE]|[\u03E0-\u03E0]|[\u03E2-\u03E2]|[\u03E4-\u03E4]|[\u03E6-\u03E6]|[\u03E8-\u03E8]|[\u03EA-\u03EA]|[\u03EC-\u03EC]|[\u03EE-\u03EE]|[\u0401-\u040C]|[\u040E-\u042F]|[\u0460-\u0460]|[\u0462-\u0462]|[\u0464-\u0464]|[\u0466-\u0466]|[\u0468-\u0468]|[\u046A-\u046A]|[\u046C-\u046C]|[\u046E-\u046E]|[\u0470-\u0470]|[\u0472-\u0472]|[\u0474-\u0474]|[\u0476-\u0476]|[\u0478-\u0478]|[\u047A-\u047A]|[\u047C-\u047C]|[\u047E-\u047E]|[\u0480-\u0480]|[\u0490-\u0490]|[\u0492-\u0492]|[\u0494-\u0494]|[\u0496-\u0496]|[\u0498-\u0498]|[\u049A-\u049A]|[\u049C-\u049C]|[\u049E-\u049E]|[\u04A0-\u04A0]|[\u04A2-\u04A2]|[\u04A4-\u04A4]|[\u04A6-\u04A6]|[\u04A8-\u04A8]|[\u04AA-\u04AA]|[\u04AC-\u04AC]|[\u04AE-\u04AE]|[\u04B0-\u04B0]|[\u04B2-\u04B2]|[\u04B4-\u04B4]|[\u04B6-\u04B6]|[\u04B8-\u04B8]|[\u04BA-\u04BA]|[\u04BC-\u04BC]|[\u04BE-\u04BE]|[\u04C1-\u04C1]|[\u04C3-\u04C3]|[\u04C7-\u04C7]|[\u04CB-\u04CB]|[\u04D0-\u04D0]|[\u04D2-\u04D2]|[\u04D4-\u04D4]|[\u04D6-\u04D6]|[\u04D8-\u04D8]|[\u04DA-\u04DA]|[\u04DC-\u04DC]|[\u04DE-\u04DE]|[\u04E0-\u04E0]|[\u04E2-\u04E2]|[\u04E4-\u04E4]|[\u04E6-\u04E6]|[\u04E8-\u04E8]|[\u04EA-\u04EA]|[\u04EE-\u04EE]|[\u04F0-\u04F0]|[\u04F2-\u04F2]|[\u04F4-\u04F4]|[\u04F8-\u04F8]|[\u0531-\u0556]|[\u10A0-\u10C5]|[\u1E00-\u1E00]|[\u1E02-\u1E02]|[\u1E04-\u1E04]|[\u1E06-\u1E06]|[\u1E08-\u1E08]|[\u1E0A-\u1E0A]|[\u1E0C-\u1E0C]|[\u1E0E-\u1E0E]|[\u1E10-\u1E10]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-\u2124]|[\u2126-\u2126]|[\u2128-\u2128]|[\u212A-\u212D]|[\u2130-\u2131]|[\u2133-\u2133]|[\uFF21-\uFF3A]|[\u0061-\u007A]|[\u00AA-\u00AA]|[\u00B5-\u00B5]|[\u00BA-\u00BA]|[\u00DF-\u00F6]|[\u00F8-\u00FF]|[\u0101-\u0101]|[\u0103-\u0103]|[\u0105-\u0105]|[\u0107-\u0107]|[\u0109-\u0109]|[\u010B-\u010B]|[\u010D-\u010D]|[\u010F-\u010F]|[\u0111-\u0111]|[\u0113-\u0113]|[\u0115-\u0115]|[\u0117-\u0117]|[\u0119-\u0119]|[\u011B-\u011B]|[\u011D-\u011D]|[\u011F-\u011F]|[\u0121-\u0121]|[\u0123-\u0123]|[\u0125-\u0125]|[\u0127-\u0127]|[\u0129-\u0129]|[\u012B-\u012B]|[\u012D-\u012D]|[\u012F-\u012F]|[\u0131-\u0131]|[\u0133-\u0133]|[\u0135-\u0135]|[\u0137-\u0138]|[\u013A-\u013A]|[\u013C-\u013C]|[\u013E-\u013E]|[\u0140-\u0140]|[\u0142-\u0142]|[\u0144-\u0144]|[\u0146-\u0146]|[\u0148-\u0149]|[\u014B-\u014B]|[\u014D-\u014D]|[\u014F-\u014F]|[\u0151-\u0151]|[\u0153-\u0153]|[\u0155-\u0155]|[\u0157-\u0157]|[\u0159-\u0159]|[\u015B-\u015B]|[\u015D-\u015D]|[\u015F-\u015F]|[\u0161-\u0161]|[\u0163-\u0163]|[\u0165-\u0165]|[\u0167-\u0167]|[\u0169-\u0169]|[\u016B-\u016B]|[\u016D-\u016D]|[\u016F-\u016F]|[\u0171-\u0171]|[\u0173-\u0173]|[\u0175-\u0175]|[\u0177-\u0177]|[\u017A-\u017A]|[\u017C-\u017C]|[\u017E-\u0180]|[\u0183-\u0183]|[\u0185-\u0185]|[\u0188-\u0188]|[\u018C-\u018D]|[\u0192-\u0192]|[\u0195-\u0195]|[\u0199-\u019B]|[\u019E-\u019E]|[\u01A1-\u01A1]|[\u01A3-\u01A3]|[\u01A5-\u01A5]|[\u01A8-\u01A8]|[\u01AB-\u01AB]|[\u01AD-\u01AD]|[\u01B0-\u01B0]|[\u01B4-\u01B4]|[\u01B6-\u01B6]|[\u01B9-\u01BA]|[\u01BD-\u01BD]|[\u01C6-\u01C6]|[\u01C9-\u01C9]|[\u01CC-\u01CC]|[\u01CE-\u01CE]|[\u01D0-\u01D0]|[\u01D2-\u01D2]|[\u01D4-\u01D4]|[\u01D6-\u01D6]|[\u01D8-\u01D8]|[\u01DA-\u01DA]|[\u01DC-\u01DD]|[\u01DF-\u01DF]|[\u01E1-\u01E1]|[\u01E3-\u01E3]|[\u01E5-\u01E5]|[\u01E7-\u01E7]|[\u01E9-\u01E9]|[\u01EB-\u01EB]|[\u01ED-\u01ED]|[\u01EF-\u01F0]|[\u01F3-\u01F3]|[\u01F5-\u01F5]|[\u01FB-\u01FB]|[\u01FD-\u01FD]|[\u01FF-\u01FF]|[\u0201-\u0201]|[\u0203-\u0203]|[\u0205-\u0205]|[\u0207-\u0207]|[\u0209-\u0209]|[\u020B-\u020B]|[\u020D-\u020D]|[\u020F-\u020F]|[\u0211-\u0211]|[\u0213-\u0213]|[\u0215-\u0215]|[\u0217-\u0217]|[\u0250-\u02A8]|[\u0390-\u0390]|[\u03AC-\u03CE]|[\u03D0-\u03D1]|[\u03D5-\u03D6]|[\u03E3-\u03E3]|[\u03E5-\u03E5]|[\u03E7-\u03E7]|[\u03E9-\u03E9]|[\u03EB-\u03EB]|[\u03ED-\u03ED]|[\u03EF-\u03F2]|[\u0430-\u044F]|[\u0451-\u045C]|[\u045E-\u045F]|[\u0461-\u0461]|[\u0463-\u0463]|[\u0465-\u0465]|[\u0467-\u0467]|[\u0469-\u0469]|[\u046B-\u046B]|[\u046D-\u046D]|[\u046F-\u046F]|[\u0471-\u0471]|[\u0473-\u0473]|[\u0475-\u0475]|[\u0477-\u0477]|[\u0479-\u0479]|[\u047B-\u047B]|[\u047D-\u047D]|[\u047F-\u047F]|[\u0481-\u0481]|[\u0491-\u0491]|[\u0493-\u0493]|[\u0495-\u0495]|[\u0497-\u0497]|[\u0499-\u0499]|[\u049B-\u049B]|[\u049D-\u049D]|[\u049F-\u049F]|[\u04A1-\u04A1]|[\u04A3-\u04A3]|[\u04A5-\u04A5]|[\u04A7-\u04A7]|[\u04A9-\u04A9]|[\u04AB-\u04AB]|[\u04AD-\u04AD]|[\u04AF-\u04AF]|[\u04B1-\u04B1]|[\u04B3-\u04B3]|[\u04B5-\u04B5]|[\u04B7-\u04B7]|[\u04B9-\u04B9]|[\u04BB-\u04BB]|[\u04BD-\u04BD]|[\u04BF-\u04BF]|[\u04C2-\u04C2]|[\u04C4-\u04C4]|[\u04C8-\u04C8]|[\u04CC-\u04CC]|[\u04D1-\u04D1]|[\u04D3-\u04D3]|[\u04D5-\u04D5]|[\u04D7-\u04D7]|[\u04D9-\u04D9]|[\u04DB-\u04DB]|[\u04DD-\u04DD]|[\u04DF-\u04DF]|[\u04E1-\u04E1]|[\u04E3-\u04E3]|[\u04E5-\u04E5]|[\u04E7-\u04E7]|[\u04E9-\u04E9]|[\u04EB-\u04EB]|[\u04EF-\u04EF]|[\u04F1-\u04F1]|[\u04F3-\u04F3]|[\u04F5-\u04F5]|[\u04F9-\u04F9]|[\u0561-\u0587]|[\u10D0-\u10F6]|[\u1E01-\u1E01]|[\u1E03-\u1E03]|[\u1E05-\u1E05]|[\u1E07-\u1E07]|[\u1E09-\u1E09]|[\u1E0B-\u1E0B]|[\u1E0D-\u1E0D]|[\u1E0F-\u1E0F]|[\u1E11-\u1E11]|[\u1E13-\u1E13]|[\u1E15-\u1E15]|[\u1E17-\u1E17]|[\u1E19-\u1E19]|[\u1E1B-\u1E1B]|[\u1E1D-\u1E1D]|[\u1E1F-\u1E1F]|[\u1E21-\u1E21]|[\u1E23-\u1E23]|[\u1E25-\u1E25]|[\u1E27-\u1E27]|[\u1E29-\u1E29]|[\u1E2B-\u1E2B]|[\u1E2D-\u1E2D]|[\u1E2F-\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559-\u0559]|[\u0640-\u0640]|[\u06E5-\u06E6]|[\u0E46-\u0E46]|[\u0EC6-\u0EC6]|[\u3005-\u3005]|[\u3031-\u3035]|[\u309D-\u309E]|[\u30FC-\u30FE]|[\uFF70-\uFF70]|[\uFF9E-\uFF9F]|[\u01AA-\u01AA]|[\u01BB-\u01BB]|[\u01BE-\u01C3]|[\u03F3-\u03F3]|[\u04C0-\u04C0]|[\u05D0-\u05EA]|[\u05F0-\u05F2]|[\u0621-\u063A]|[\u0641-\u064A]|[\u0671-\u06B7]|[\u06BA-\u06BE]|[\u06C0-\u06CE]|[\u06D0-\u06D3]|[\u06D5-\u06D5]|[\u0905-\u0939]|[\u093D-\u093D]|[\u0950-\u0950]|[\u0958-\u0961]|[\u0985-\u098C]|[\u098F-\u0990]|[\u0993-\u09A8]|[\u09AA-\u09B0]|[\u09B2-\u09B2]|[\u09B6-\u09B9]|[\u09DC-\u09DD]|[\u09DF-\u09E1]|[\u09F0-\u09F1]|[\u0A05-\u0A0A]|[\u0A0F-\u0A10]|[\u0A13-\u0A28]|[\u0A2A-\u0A30]|[\u0A32-\u0A33]|[\u0A35-\u0A36]|[\u0A38-\u0A39]|[\u0A59-\u0A5C]|[\u0A5E-\u0A5E]|[\u0A72-\u0A74]|[\u0A85-\u0A8B]|[\u0A8D-\u0A8D]|[\u0A8F-\u0A91]|[\u0A93-\u0AA8]|[\u0AAA-\u0AB0]|[\u0AB2-\u0AB3]|[\u0AB5-\u0AB9]|[\u0ABD-\u0ABD]|[\u0AD0-\u0AD0]|[\u0AE0-\u0AE0]|[\u0B05-\u0B0C]|[\u0B0F-\u0B10]|[\u0B13-\u0B28]|[\u0B2A-\u0B30]|[\u0B32-\u0B33]|[\u0B36-\u0B39]|[\u0B3D-\u0B3D]|[\u0B5C-\u0B5D]|[\u0B5F-\u0B61]|[\u0B85-\u0B8A]|[\u0B8E-\u0B90]|[\u0B92-\u0B95]|[\u0B99-\u0B9A]|[\u0B9C-\u0B9C]|[\u0B9E-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[\uFE74-\uFE74]|[\uFE76-\uFEFC]|[\uFF66-\uFF6F]|[\uFF71-\uFF9D]|[\uFFA0-\uFFBE]|[\uFFC2-\uFFC7]|[\uFFCA-\uFFCF]|[\uFFD2-\uFFD7]|[\uFFDA-\uFFDC]/,Ltmo:/[\u01C5-\u01C5]|[\u01C8-\u01C8]|[\u01CB-\u01CB]|[\u01F2-\u01F2][\u02B0-\u02B8]|[\u02BB-\u02C1]|[\u02D0-\u02D1]|[\u02E0-\u02E4]|[\u037A-\u037A]|[\u0559-\u0559]|[\u0640-\u0640]|[\u06E5-\u06E6]|[\u0E46-\u0E46]|[\u0EC6-\u0EC6]|[\u3005-\u3005]|[\u3031-\u3035]|[\u309D-\u309E]|[\u30FC-\u30FE]|[\uFF70-\uFF70]|[\uFF9E-\uFF9F][\u01AA-\u01AA]|[\u01BB-\u01BB]|[\u01BE-\u01C3]|[\u03F3-\u03F3]|[\u04C0-\u04C0]|[\u05D0-\u05EA]|[\u05F0-\u05F2]|[\u0621-\u063A]|[\u0641-\u064A]|[\u0671-\u06B7]|[\u06BA-\u06BE]|[\u06C0-\u06CE]|[\u06D0-\u06D3]|[\u06D5-\u06D5]|[\u0905-\u0939]|[\u093D-\u093D]|[\u0950-\u0950]|[\u0958-\u0961]|[\u0985-\u098C]|[\u098F-\u0990]|[\u0993-\u09A8]|[\u09AA-\u09B0]|[\u09B2-\u09B2]|[\u09B6-\u09B9]|[\u09DC-\u09DD]|[\u09DF-\u09E1]|[\u09F0-\u09F1]|[\u0A05-\u0A0A]|[\u0A0F-\u0A10]|[\u0A13-\u0A28]|[\u0A2A-\u0A30]|[\u0A32-\u0A33]|[\u0A35-\u0A36]|[\u0A38-\u0A39]|[\u0A59-\u0A5C]|[\u0A5E-\u0A5E]|[\u0A72-\u0A74]|[\u0A85-\u0A8B]|[\u0A8D-\u0A8D]|[\u0A8F-\u0A91]|[\u0A93-\u0AA8]|[\u0AAA-\u0AB0]|[\u0AB2-\u0AB3]|[\u0AB5-\u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3041-\u3094]|[\u30A1-\u30FA]|[\u3105-\u312C]|[\u3131-\u318E]|[\u4E00-\u9FA5]|[\uAC00-\uD7A3]|[\uF900-\uFA2D]|[\uFB1F-\uFB28]|[\uFB2A-\uFB36]|[\uFB38-\uFB3C]|[\uFB3E-\uFB3E]|[\uFB40-\uFB41]|[\uFB43-\uFB44]|[\uFB46-\uFBB1]|[\uFBD3-\uFD3D]|[\uFD50-\uFD8F]|[\uFD92-\uFDC7]|[\uFDF0-\uFDFB]|[\uFE70-\uFE72]|[\uFE74-\uFE74]|[\uFE76-\uFEFC]|[\uFF66-\uFF6F]|[\uFF71-\uFF9D]|[\uFFA0-\uFFBE]|[\uFFC2-\uFFC7]|[\uFFCA-\uFFCF]|[\uFFD2-\uFFD7]|[\uFFDA-\uFFDC]/}},{}]},{},[43])(43)}); diff --git a/src/MatchResult.js b/src/MatchResult.js index b0e322f4..4846a04b 100644 --- a/src/MatchResult.js +++ b/src/MatchResult.js @@ -11,16 +11,6 @@ var nodes = require('./nodes'); var util = require('./util'); var Interval = require('./Interval'); -// -------------------------------------------------------------------- -// Private stuff -// -------------------------------------------------------------------- - -// Create a short error message for an error that occurred during matching. -function getShortMatchErrorMessage(pos, source, detail) { - var errorInfo = util.getLineAndColumn(source, pos); - return 'Line ' + errorInfo.lineNum + ', col ' + errorInfo.colNum + ': ' + detail; -} - // ----------------- MatchFailure ----------------- function MatchResult(state) { @@ -147,10 +137,7 @@ function MatchFailure(state) { return 'match failed at position ' + this.getRightmostFailurePosition(); } var detail = 'expected ' + this.getExpectedText(); - return getShortMatchErrorMessage( - this.getRightmostFailurePosition(), - this.state.inputStream.source, - detail); + return util.getShortLineAndColumnMessage(this.state.inputStream.source, this.getRightmostFailurePosition()) + detail; }); } inherits(MatchFailure, MatchResult); diff --git a/src/errors.js b/src/errors.js index 26ad337f..cf732ee1 100644 --- a/src/errors.js +++ b/src/errors.js @@ -5,6 +5,7 @@ // -------------------------------------------------------------------- var Namespace = require('./Namespace'); +var util = require('./util'); // -------------------------------------------------------------------- // Private stuff @@ -34,11 +35,40 @@ function intervalSourcesDontMatch() { function grammarSyntaxError(matchFailure) { var e = new Error(); - Object.defineProperty(e, 'message', {get: function() { return matchFailure.message; }}); - Object.defineProperty(e, 'shortMessage', {get: function() { - return 'Expected ' + matchFailure.getExpectedText(); - }}); + e.interval = matchFailure.getInterval(); + + var message; + var shortMessage; + + var source = matchFailure.state.inputStream.source; + + // Iterate through the failures, in an attempt to produce a more relevant error message + var reason = null; + + var failures = matchFailure.getRightmostFailures(); + for(var i = 0; i < failures.length; i++) { + var failure = failures[i]; + if (failure.getPExpr().ruleName === 'escapeChar'){ + // Failure to match an escape sequence, therefore the grammar contains an invalid escape sequence. + var escapeSequence = source.substr(matchFailure.getRightmostFailurePosition(),2); + var reason = "Invalid escape sequence \"" + escapeSequence + "\""; + break; + } + } + + if (reason) { + // Use the more relevant reason an the error message + message = util.getLineAndColumnMessage(source, matchFailure.getRightmostFailurePosition()) + reason; + shortMessage = util.getShortLineAndColumnMessage(source, matchFailure.getRightmostFailurePosition()) + reason; + } else { + // Use the default parse failure message for the error. This is usually sufficient. + message = matchFailure.message; + shortMessage = 'Expected ' + matchFailure.getExpectedText(); + } + + Object.defineProperty(e, 'message', {get: function() { return message; }}); + Object.defineProperty(e, 'shortMessage', {get: function() { return shortMessage; }}); return e; } diff --git a/src/util.js b/src/util.js index 06be6de2..de2ce606 100644 --- a/src/util.js +++ b/src/util.js @@ -146,3 +146,8 @@ exports.getLineAndColumnMessage = function(str, offset /* ...ranges */) { } return sb.contents(); }; + +exports.getShortLineAndColumnMessage = function(str, offset){ + var errorInfo = exports.getLineAndColumn(str, offset); + return 'Line ' + errorInfo.lineNum + ', col ' + errorInfo.colNum + ': '; +} diff --git a/visualizer/index.js b/visualizer/index.js index 599f77a5..6634f1a6 100644 --- a/visualizer/index.js +++ b/visualizer/index.js @@ -26,6 +26,13 @@ var grammar; var err; + try { + ohm.grammar(source); + } catch (ex) { + err = ex; + } + + /* if (matchResult.succeeded()) { var ns = {}; try { @@ -43,7 +50,7 @@ shortMessage: matchResult.shortMessage, interval: matchResult.getInterval() }; - } + }*/ return { matchResult: matchResult, grammar: grammar,