1
0

parser.js 125 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121
  1. define("amber_vm/parser", ["./smalltalk", "./nil"], function(smalltalk, nil) {
  2. smalltalk.parser = (function(){
  3. /*
  4. * Generated by PEG.js 0.7.0.
  5. *
  6. * http://pegjs.majda.cz/
  7. */
  8. function quote(s) {
  9. /*
  10. * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a
  11. * string literal except for the closing quote character, backslash,
  12. * carriage return, line separator, paragraph separator, and line feed.
  13. * Any character may appear in the form of an escape sequence.
  14. *
  15. * For portability, we also escape escape all control and non-ASCII
  16. * characters. Note that "\0" and "\v" escape sequences are not used
  17. * because JSHint does not like the first and IE the second.
  18. */
  19. return '"' + s
  20. .replace(/\\/g, '\\\\') // backslash
  21. .replace(/"/g, '\\"') // closing quote character
  22. .replace(/\x08/g, '\\b') // backspace
  23. .replace(/\t/g, '\\t') // horizontal tab
  24. .replace(/\n/g, '\\n') // line feed
  25. .replace(/\f/g, '\\f') // form feed
  26. .replace(/\r/g, '\\r') // carriage return
  27. .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape)
  28. + '"';
  29. }
  30. var result = {
  31. /*
  32. * Parses the input with a generated parser. If the parsing is successfull,
  33. * returns a value explicitly or implicitly specified by the grammar from
  34. * which the parser was generated (see |PEG.buildParser|). If the parsing is
  35. * unsuccessful, throws |PEG.parser.SyntaxError| describing the error.
  36. */
  37. parse: function(input, startRule) {
  38. var parseFunctions = {
  39. "separator": parse_separator,
  40. "comments": parse_comments,
  41. "ws": parse_ws,
  42. "identifier": parse_identifier,
  43. "keyword": parse_keyword,
  44. "selector": parse_selector,
  45. "className": parse_className,
  46. "string": parse_string,
  47. "symbol": parse_symbol,
  48. "bareSymbol": parse_bareSymbol,
  49. "number": parse_number,
  50. "numberExp": parse_numberExp,
  51. "hex": parse_hex,
  52. "float": parse_float,
  53. "integer": parse_integer,
  54. "literalArray": parse_literalArray,
  55. "bareLiteralArray": parse_bareLiteralArray,
  56. "literalArrayRest": parse_literalArrayRest,
  57. "dynamicArray": parse_dynamicArray,
  58. "dynamicDictionary": parse_dynamicDictionary,
  59. "pseudoVariable": parse_pseudoVariable,
  60. "parseTimeLiteral": parse_parseTimeLiteral,
  61. "runtimeLiteral": parse_runtimeLiteral,
  62. "literal": parse_literal,
  63. "variable": parse_variable,
  64. "keywordPair": parse_keywordPair,
  65. "binarySelector": parse_binarySelector,
  66. "keywordPattern": parse_keywordPattern,
  67. "binaryPattern": parse_binaryPattern,
  68. "unaryPattern": parse_unaryPattern,
  69. "expression": parse_expression,
  70. "expressionList": parse_expressionList,
  71. "expressions": parse_expressions,
  72. "assignment": parse_assignment,
  73. "ret": parse_ret,
  74. "temps": parse_temps,
  75. "blockParamList": parse_blockParamList,
  76. "subexpression": parse_subexpression,
  77. "statements": parse_statements,
  78. "sequence": parse_sequence,
  79. "stSequence": parse_stSequence,
  80. "block": parse_block,
  81. "operand": parse_operand,
  82. "unaryMessage": parse_unaryMessage,
  83. "unaryTail": parse_unaryTail,
  84. "unarySend": parse_unarySend,
  85. "binaryMessage": parse_binaryMessage,
  86. "binaryTail": parse_binaryTail,
  87. "binarySend": parse_binarySend,
  88. "keywordMessage": parse_keywordMessage,
  89. "keywordSend": parse_keywordSend,
  90. "message": parse_message,
  91. "cascade": parse_cascade,
  92. "jsStatement": parse_jsStatement,
  93. "method": parse_method
  94. };
  95. if (startRule !== undefined) {
  96. if (parseFunctions[startRule] === undefined) {
  97. throw new Error("Invalid rule name: " + quote(startRule) + ".");
  98. }
  99. } else {
  100. startRule = "method";
  101. }
  102. var pos = { offset: 0, line: 1, column: 1, seenCR: false };
  103. var reportFailures = 0;
  104. var rightmostFailuresPos = { offset: 0, line: 1, column: 1, seenCR: false };
  105. var rightmostFailuresExpected = [];
  106. var cache = {};
  107. function padLeft(input, padding, length) {
  108. var result = input;
  109. var padLength = length - input.length;
  110. for (var i = 0; i < padLength; i++) {
  111. result = padding + result;
  112. }
  113. return result;
  114. }
  115. function escape(ch) {
  116. var charCode = ch.charCodeAt(0);
  117. var escapeChar;
  118. var length;
  119. if (charCode <= 0xFF) {
  120. escapeChar = 'x';
  121. length = 2;
  122. } else {
  123. escapeChar = 'u';
  124. length = 4;
  125. }
  126. return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);
  127. }
  128. function clone(object) {
  129. var result = {};
  130. for (var key in object) {
  131. result[key] = object[key];
  132. }
  133. return result;
  134. }
  135. function advance(pos, n) {
  136. var endOffset = pos.offset + n;
  137. for (var offset = pos.offset; offset < endOffset; offset++) {
  138. var ch = input.charAt(offset);
  139. if (ch === "\n") {
  140. if (!pos.seenCR) { pos.line++; }
  141. pos.column = 1;
  142. pos.seenCR = false;
  143. } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
  144. pos.line++;
  145. pos.column = 1;
  146. pos.seenCR = true;
  147. } else {
  148. pos.column++;
  149. pos.seenCR = false;
  150. }
  151. }
  152. pos.offset += n;
  153. }
  154. function matchFailed(failure) {
  155. if (pos.offset < rightmostFailuresPos.offset) {
  156. return;
  157. }
  158. if (pos.offset > rightmostFailuresPos.offset) {
  159. rightmostFailuresPos = clone(pos);
  160. rightmostFailuresExpected = [];
  161. }
  162. rightmostFailuresExpected.push(failure);
  163. }
  164. function parse_separator() {
  165. var cacheKey = "separator@" + pos.offset;
  166. var cachedResult = cache[cacheKey];
  167. if (cachedResult) {
  168. pos = clone(cachedResult.nextPos);
  169. return cachedResult.result;
  170. }
  171. var result0, result1;
  172. if (/^[ \t\x0B\f\xA0\uFEFF\n\r\u2028\u2029]/.test(input.charAt(pos.offset))) {
  173. result1 = input.charAt(pos.offset);
  174. advance(pos, 1);
  175. } else {
  176. result1 = null;
  177. if (reportFailures === 0) {
  178. matchFailed("[ \\t\\x0B\\f\\xA0\\uFEFF\\n\\r\\u2028\\u2029]");
  179. }
  180. }
  181. if (result1 !== null) {
  182. result0 = [];
  183. while (result1 !== null) {
  184. result0.push(result1);
  185. if (/^[ \t\x0B\f\xA0\uFEFF\n\r\u2028\u2029]/.test(input.charAt(pos.offset))) {
  186. result1 = input.charAt(pos.offset);
  187. advance(pos, 1);
  188. } else {
  189. result1 = null;
  190. if (reportFailures === 0) {
  191. matchFailed("[ \\t\\x0B\\f\\xA0\\uFEFF\\n\\r\\u2028\\u2029]");
  192. }
  193. }
  194. }
  195. } else {
  196. result0 = null;
  197. }
  198. cache[cacheKey] = {
  199. nextPos: clone(pos),
  200. result: result0
  201. };
  202. return result0;
  203. }
  204. function parse_comments() {
  205. var cacheKey = "comments@" + pos.offset;
  206. var cachedResult = cache[cacheKey];
  207. if (cachedResult) {
  208. pos = clone(cachedResult.nextPos);
  209. return cachedResult.result;
  210. }
  211. var result0, result1, result2, result3;
  212. var pos0;
  213. pos0 = clone(pos);
  214. if (/^["]/.test(input.charAt(pos.offset))) {
  215. result1 = input.charAt(pos.offset);
  216. advance(pos, 1);
  217. } else {
  218. result1 = null;
  219. if (reportFailures === 0) {
  220. matchFailed("[\"]");
  221. }
  222. }
  223. if (result1 !== null) {
  224. result2 = [];
  225. if (/^[^"]/.test(input.charAt(pos.offset))) {
  226. result3 = input.charAt(pos.offset);
  227. advance(pos, 1);
  228. } else {
  229. result3 = null;
  230. if (reportFailures === 0) {
  231. matchFailed("[^\"]");
  232. }
  233. }
  234. while (result3 !== null) {
  235. result2.push(result3);
  236. if (/^[^"]/.test(input.charAt(pos.offset))) {
  237. result3 = input.charAt(pos.offset);
  238. advance(pos, 1);
  239. } else {
  240. result3 = null;
  241. if (reportFailures === 0) {
  242. matchFailed("[^\"]");
  243. }
  244. }
  245. }
  246. if (result2 !== null) {
  247. if (/^["]/.test(input.charAt(pos.offset))) {
  248. result3 = input.charAt(pos.offset);
  249. advance(pos, 1);
  250. } else {
  251. result3 = null;
  252. if (reportFailures === 0) {
  253. matchFailed("[\"]");
  254. }
  255. }
  256. if (result3 !== null) {
  257. result1 = [result1, result2, result3];
  258. } else {
  259. result1 = null;
  260. pos = clone(pos0);
  261. }
  262. } else {
  263. result1 = null;
  264. pos = clone(pos0);
  265. }
  266. } else {
  267. result1 = null;
  268. pos = clone(pos0);
  269. }
  270. if (result1 !== null) {
  271. result0 = [];
  272. while (result1 !== null) {
  273. result0.push(result1);
  274. pos0 = clone(pos);
  275. if (/^["]/.test(input.charAt(pos.offset))) {
  276. result1 = input.charAt(pos.offset);
  277. advance(pos, 1);
  278. } else {
  279. result1 = null;
  280. if (reportFailures === 0) {
  281. matchFailed("[\"]");
  282. }
  283. }
  284. if (result1 !== null) {
  285. result2 = [];
  286. if (/^[^"]/.test(input.charAt(pos.offset))) {
  287. result3 = input.charAt(pos.offset);
  288. advance(pos, 1);
  289. } else {
  290. result3 = null;
  291. if (reportFailures === 0) {
  292. matchFailed("[^\"]");
  293. }
  294. }
  295. while (result3 !== null) {
  296. result2.push(result3);
  297. if (/^[^"]/.test(input.charAt(pos.offset))) {
  298. result3 = input.charAt(pos.offset);
  299. advance(pos, 1);
  300. } else {
  301. result3 = null;
  302. if (reportFailures === 0) {
  303. matchFailed("[^\"]");
  304. }
  305. }
  306. }
  307. if (result2 !== null) {
  308. if (/^["]/.test(input.charAt(pos.offset))) {
  309. result3 = input.charAt(pos.offset);
  310. advance(pos, 1);
  311. } else {
  312. result3 = null;
  313. if (reportFailures === 0) {
  314. matchFailed("[\"]");
  315. }
  316. }
  317. if (result3 !== null) {
  318. result1 = [result1, result2, result3];
  319. } else {
  320. result1 = null;
  321. pos = clone(pos0);
  322. }
  323. } else {
  324. result1 = null;
  325. pos = clone(pos0);
  326. }
  327. } else {
  328. result1 = null;
  329. pos = clone(pos0);
  330. }
  331. }
  332. } else {
  333. result0 = null;
  334. }
  335. cache[cacheKey] = {
  336. nextPos: clone(pos),
  337. result: result0
  338. };
  339. return result0;
  340. }
  341. function parse_ws() {
  342. var cacheKey = "ws@" + pos.offset;
  343. var cachedResult = cache[cacheKey];
  344. if (cachedResult) {
  345. pos = clone(cachedResult.nextPos);
  346. return cachedResult.result;
  347. }
  348. var result0, result1;
  349. result0 = [];
  350. result1 = parse_separator();
  351. if (result1 === null) {
  352. result1 = parse_comments();
  353. }
  354. while (result1 !== null) {
  355. result0.push(result1);
  356. result1 = parse_separator();
  357. if (result1 === null) {
  358. result1 = parse_comments();
  359. }
  360. }
  361. cache[cacheKey] = {
  362. nextPos: clone(pos),
  363. result: result0
  364. };
  365. return result0;
  366. }
  367. function parse_identifier() {
  368. var cacheKey = "identifier@" + pos.offset;
  369. var cachedResult = cache[cacheKey];
  370. if (cachedResult) {
  371. pos = clone(cachedResult.nextPos);
  372. return cachedResult.result;
  373. }
  374. var result0, result1, result2;
  375. var pos0, pos1;
  376. pos0 = clone(pos);
  377. pos1 = clone(pos);
  378. if (/^[a-zA-Z]/.test(input.charAt(pos.offset))) {
  379. result0 = input.charAt(pos.offset);
  380. advance(pos, 1);
  381. } else {
  382. result0 = null;
  383. if (reportFailures === 0) {
  384. matchFailed("[a-zA-Z]");
  385. }
  386. }
  387. if (result0 !== null) {
  388. result1 = [];
  389. if (/^[a-zA-Z0-9]/.test(input.charAt(pos.offset))) {
  390. result2 = input.charAt(pos.offset);
  391. advance(pos, 1);
  392. } else {
  393. result2 = null;
  394. if (reportFailures === 0) {
  395. matchFailed("[a-zA-Z0-9]");
  396. }
  397. }
  398. while (result2 !== null) {
  399. result1.push(result2);
  400. if (/^[a-zA-Z0-9]/.test(input.charAt(pos.offset))) {
  401. result2 = input.charAt(pos.offset);
  402. advance(pos, 1);
  403. } else {
  404. result2 = null;
  405. if (reportFailures === 0) {
  406. matchFailed("[a-zA-Z0-9]");
  407. }
  408. }
  409. }
  410. if (result1 !== null) {
  411. result0 = [result0, result1];
  412. } else {
  413. result0 = null;
  414. pos = clone(pos1);
  415. }
  416. } else {
  417. result0 = null;
  418. pos = clone(pos1);
  419. }
  420. if (result0 !== null) {
  421. result0 = (function(offset, line, column, first, others) {return first + others.join("");})(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
  422. }
  423. if (result0 === null) {
  424. pos = clone(pos0);
  425. }
  426. cache[cacheKey] = {
  427. nextPos: clone(pos),
  428. result: result0
  429. };
  430. return result0;
  431. }
  432. function parse_keyword() {
  433. var cacheKey = "keyword@" + pos.offset;
  434. var cachedResult = cache[cacheKey];
  435. if (cachedResult) {
  436. pos = clone(cachedResult.nextPos);
  437. return cachedResult.result;
  438. }
  439. var result0, result1;
  440. var pos0, pos1;
  441. pos0 = clone(pos);
  442. pos1 = clone(pos);
  443. result0 = parse_identifier();
  444. if (result0 !== null) {
  445. if (/^[:]/.test(input.charAt(pos.offset))) {
  446. result1 = input.charAt(pos.offset);
  447. advance(pos, 1);
  448. } else {
  449. result1 = null;
  450. if (reportFailures === 0) {
  451. matchFailed("[:]");
  452. }
  453. }
  454. if (result1 !== null) {
  455. result0 = [result0, result1];
  456. } else {
  457. result0 = null;
  458. pos = clone(pos1);
  459. }
  460. } else {
  461. result0 = null;
  462. pos = clone(pos1);
  463. }
  464. if (result0 !== null) {
  465. result0 = (function(offset, line, column, first, last) {return first + last;})(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
  466. }
  467. if (result0 === null) {
  468. pos = clone(pos0);
  469. }
  470. cache[cacheKey] = {
  471. nextPos: clone(pos),
  472. result: result0
  473. };
  474. return result0;
  475. }
  476. function parse_selector() {
  477. var cacheKey = "selector@" + pos.offset;
  478. var cachedResult = cache[cacheKey];
  479. if (cachedResult) {
  480. pos = clone(cachedResult.nextPos);
  481. return cachedResult.result;
  482. }
  483. var result0, result1, result2;
  484. var pos0, pos1;
  485. pos0 = clone(pos);
  486. pos1 = clone(pos);
  487. if (/^[a-zA-Z]/.test(input.charAt(pos.offset))) {
  488. result0 = input.charAt(pos.offset);
  489. advance(pos, 1);
  490. } else {
  491. result0 = null;
  492. if (reportFailures === 0) {
  493. matchFailed("[a-zA-Z]");
  494. }
  495. }
  496. if (result0 !== null) {
  497. result1 = [];
  498. if (/^[a-zA-Z0-9:]/.test(input.charAt(pos.offset))) {
  499. result2 = input.charAt(pos.offset);
  500. advance(pos, 1);
  501. } else {
  502. result2 = null;
  503. if (reportFailures === 0) {
  504. matchFailed("[a-zA-Z0-9:]");
  505. }
  506. }
  507. while (result2 !== null) {
  508. result1.push(result2);
  509. if (/^[a-zA-Z0-9:]/.test(input.charAt(pos.offset))) {
  510. result2 = input.charAt(pos.offset);
  511. advance(pos, 1);
  512. } else {
  513. result2 = null;
  514. if (reportFailures === 0) {
  515. matchFailed("[a-zA-Z0-9:]");
  516. }
  517. }
  518. }
  519. if (result1 !== null) {
  520. result0 = [result0, result1];
  521. } else {
  522. result0 = null;
  523. pos = clone(pos1);
  524. }
  525. } else {
  526. result0 = null;
  527. pos = clone(pos1);
  528. }
  529. if (result0 !== null) {
  530. result0 = (function(offset, line, column, first, others) {return first + others.join("");})(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
  531. }
  532. if (result0 === null) {
  533. pos = clone(pos0);
  534. }
  535. cache[cacheKey] = {
  536. nextPos: clone(pos),
  537. result: result0
  538. };
  539. return result0;
  540. }
  541. function parse_className() {
  542. var cacheKey = "className@" + pos.offset;
  543. var cachedResult = cache[cacheKey];
  544. if (cachedResult) {
  545. pos = clone(cachedResult.nextPos);
  546. return cachedResult.result;
  547. }
  548. var result0, result1, result2;
  549. var pos0, pos1;
  550. pos0 = clone(pos);
  551. pos1 = clone(pos);
  552. if (/^[A-Z]/.test(input.charAt(pos.offset))) {
  553. result0 = input.charAt(pos.offset);
  554. advance(pos, 1);
  555. } else {
  556. result0 = null;
  557. if (reportFailures === 0) {
  558. matchFailed("[A-Z]");
  559. }
  560. }
  561. if (result0 !== null) {
  562. result1 = [];
  563. if (/^[a-zA-Z0-9]/.test(input.charAt(pos.offset))) {
  564. result2 = input.charAt(pos.offset);
  565. advance(pos, 1);
  566. } else {
  567. result2 = null;
  568. if (reportFailures === 0) {
  569. matchFailed("[a-zA-Z0-9]");
  570. }
  571. }
  572. while (result2 !== null) {
  573. result1.push(result2);
  574. if (/^[a-zA-Z0-9]/.test(input.charAt(pos.offset))) {
  575. result2 = input.charAt(pos.offset);
  576. advance(pos, 1);
  577. } else {
  578. result2 = null;
  579. if (reportFailures === 0) {
  580. matchFailed("[a-zA-Z0-9]");
  581. }
  582. }
  583. }
  584. if (result1 !== null) {
  585. result0 = [result0, result1];
  586. } else {
  587. result0 = null;
  588. pos = clone(pos1);
  589. }
  590. } else {
  591. result0 = null;
  592. pos = clone(pos1);
  593. }
  594. if (result0 !== null) {
  595. result0 = (function(offset, line, column, first, others) {return first + others.join("");})(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
  596. }
  597. if (result0 === null) {
  598. pos = clone(pos0);
  599. }
  600. cache[cacheKey] = {
  601. nextPos: clone(pos),
  602. result: result0
  603. };
  604. return result0;
  605. }
  606. function parse_string() {
  607. var cacheKey = "string@" + pos.offset;
  608. var cachedResult = cache[cacheKey];
  609. if (cachedResult) {
  610. pos = clone(cachedResult.nextPos);
  611. return cachedResult.result;
  612. }
  613. var result0, result1, result2;
  614. var pos0, pos1, pos2;
  615. pos0 = clone(pos);
  616. pos1 = clone(pos);
  617. if (/^[']/.test(input.charAt(pos.offset))) {
  618. result0 = input.charAt(pos.offset);
  619. advance(pos, 1);
  620. } else {
  621. result0 = null;
  622. if (reportFailures === 0) {
  623. matchFailed("[']");
  624. }
  625. }
  626. if (result0 !== null) {
  627. result1 = [];
  628. pos2 = clone(pos);
  629. if (input.substr(pos.offset, 2) === "''") {
  630. result2 = "''";
  631. advance(pos, 2);
  632. } else {
  633. result2 = null;
  634. if (reportFailures === 0) {
  635. matchFailed("\"''\"");
  636. }
  637. }
  638. if (result2 !== null) {
  639. result2 = (function(offset, line, column) {return "'";})(pos2.offset, pos2.line, pos2.column);
  640. }
  641. if (result2 === null) {
  642. pos = clone(pos2);
  643. }
  644. if (result2 === null) {
  645. if (/^[^']/.test(input.charAt(pos.offset))) {
  646. result2 = input.charAt(pos.offset);
  647. advance(pos, 1);
  648. } else {
  649. result2 = null;
  650. if (reportFailures === 0) {
  651. matchFailed("[^']");
  652. }
  653. }
  654. }
  655. while (result2 !== null) {
  656. result1.push(result2);
  657. pos2 = clone(pos);
  658. if (input.substr(pos.offset, 2) === "''") {
  659. result2 = "''";
  660. advance(pos, 2);
  661. } else {
  662. result2 = null;
  663. if (reportFailures === 0) {
  664. matchFailed("\"''\"");
  665. }
  666. }
  667. if (result2 !== null) {
  668. result2 = (function(offset, line, column) {return "'";})(pos2.offset, pos2.line, pos2.column);
  669. }
  670. if (result2 === null) {
  671. pos = clone(pos2);
  672. }
  673. if (result2 === null) {
  674. if (/^[^']/.test(input.charAt(pos.offset))) {
  675. result2 = input.charAt(pos.offset);
  676. advance(pos, 1);
  677. } else {
  678. result2 = null;
  679. if (reportFailures === 0) {
  680. matchFailed("[^']");
  681. }
  682. }
  683. }
  684. }
  685. if (result1 !== null) {
  686. if (/^[']/.test(input.charAt(pos.offset))) {
  687. result2 = input.charAt(pos.offset);
  688. advance(pos, 1);
  689. } else {
  690. result2 = null;
  691. if (reportFailures === 0) {
  692. matchFailed("[']");
  693. }
  694. }
  695. if (result2 !== null) {
  696. result0 = [result0, result1, result2];
  697. } else {
  698. result0 = null;
  699. pos = clone(pos1);
  700. }
  701. } else {
  702. result0 = null;
  703. pos = clone(pos1);
  704. }
  705. } else {
  706. result0 = null;
  707. pos = clone(pos1);
  708. }
  709. if (result0 !== null) {
  710. result0 = (function(offset, line, column, val) {
  711. return smalltalk.ValueNode._new()
  712. ._position_((line).__at(column))
  713. ._value_(val.join("").replace(/\"/ig, '"'));
  714. })(pos0.offset, pos0.line, pos0.column, result0[1]);
  715. }
  716. if (result0 === null) {
  717. pos = clone(pos0);
  718. }
  719. cache[cacheKey] = {
  720. nextPos: clone(pos),
  721. result: result0
  722. };
  723. return result0;
  724. }
  725. function parse_symbol() {
  726. var cacheKey = "symbol@" + pos.offset;
  727. var cachedResult = cache[cacheKey];
  728. if (cachedResult) {
  729. pos = clone(cachedResult.nextPos);
  730. return cachedResult.result;
  731. }
  732. var result0, result1;
  733. var pos0, pos1;
  734. pos0 = clone(pos);
  735. pos1 = clone(pos);
  736. if (input.charCodeAt(pos.offset) === 35) {
  737. result0 = "#";
  738. advance(pos, 1);
  739. } else {
  740. result0 = null;
  741. if (reportFailures === 0) {
  742. matchFailed("\"#\"");
  743. }
  744. }
  745. if (result0 !== null) {
  746. result1 = parse_bareSymbol();
  747. if (result1 !== null) {
  748. result0 = [result0, result1];
  749. } else {
  750. result0 = null;
  751. pos = clone(pos1);
  752. }
  753. } else {
  754. result0 = null;
  755. pos = clone(pos1);
  756. }
  757. if (result0 !== null) {
  758. result0 = (function(offset, line, column, rest) {return rest;})(pos0.offset, pos0.line, pos0.column, result0[1]);
  759. }
  760. if (result0 === null) {
  761. pos = clone(pos0);
  762. }
  763. cache[cacheKey] = {
  764. nextPos: clone(pos),
  765. result: result0
  766. };
  767. return result0;
  768. }
  769. function parse_bareSymbol() {
  770. var cacheKey = "bareSymbol@" + pos.offset;
  771. var cachedResult = cache[cacheKey];
  772. if (cachedResult) {
  773. pos = clone(cachedResult.nextPos);
  774. return cachedResult.result;
  775. }
  776. var result0;
  777. var pos0, pos1;
  778. pos0 = clone(pos);
  779. result0 = parse_selector();
  780. if (result0 === null) {
  781. result0 = parse_binarySelector();
  782. if (result0 === null) {
  783. pos1 = clone(pos);
  784. result0 = parse_string();
  785. if (result0 !== null) {
  786. result0 = (function(offset, line, column, node) {return node._value();})(pos1.offset, pos1.line, pos1.column, result0);
  787. }
  788. if (result0 === null) {
  789. pos = clone(pos1);
  790. }
  791. }
  792. }
  793. if (result0 !== null) {
  794. result0 = (function(offset, line, column, val) {
  795. return smalltalk.ValueNode._new()
  796. ._position_((line).__at(column))
  797. ._value_(val);
  798. })(pos0.offset, pos0.line, pos0.column, result0);
  799. }
  800. if (result0 === null) {
  801. pos = clone(pos0);
  802. }
  803. cache[cacheKey] = {
  804. nextPos: clone(pos),
  805. result: result0
  806. };
  807. return result0;
  808. }
  809. function parse_number() {
  810. var cacheKey = "number@" + pos.offset;
  811. var cachedResult = cache[cacheKey];
  812. if (cachedResult) {
  813. pos = clone(cachedResult.nextPos);
  814. return cachedResult.result;
  815. }
  816. var result0;
  817. var pos0;
  818. pos0 = clone(pos);
  819. result0 = parse_numberExp();
  820. if (result0 === null) {
  821. result0 = parse_hex();
  822. if (result0 === null) {
  823. result0 = parse_float();
  824. if (result0 === null) {
  825. result0 = parse_integer();
  826. }
  827. }
  828. }
  829. if (result0 !== null) {
  830. result0 = (function(offset, line, column, n) {
  831. return smalltalk.ValueNode._new()
  832. ._position_((line).__at(column))
  833. ._value_(n);
  834. })(pos0.offset, pos0.line, pos0.column, result0);
  835. }
  836. if (result0 === null) {
  837. pos = clone(pos0);
  838. }
  839. cache[cacheKey] = {
  840. nextPos: clone(pos),
  841. result: result0
  842. };
  843. return result0;
  844. }
  845. function parse_numberExp() {
  846. var cacheKey = "numberExp@" + pos.offset;
  847. var cachedResult = cache[cacheKey];
  848. if (cachedResult) {
  849. pos = clone(cachedResult.nextPos);
  850. return cachedResult.result;
  851. }
  852. var result0, result1, result2;
  853. var pos0, pos1;
  854. pos0 = clone(pos);
  855. pos1 = clone(pos);
  856. result0 = parse_float();
  857. if (result0 === null) {
  858. result0 = parse_integer();
  859. }
  860. if (result0 !== null) {
  861. if (input.charCodeAt(pos.offset) === 101) {
  862. result1 = "e";
  863. advance(pos, 1);
  864. } else {
  865. result1 = null;
  866. if (reportFailures === 0) {
  867. matchFailed("\"e\"");
  868. }
  869. }
  870. if (result1 !== null) {
  871. result2 = parse_integer();
  872. if (result2 !== null) {
  873. result0 = [result0, result1, result2];
  874. } else {
  875. result0 = null;
  876. pos = clone(pos1);
  877. }
  878. } else {
  879. result0 = null;
  880. pos = clone(pos1);
  881. }
  882. } else {
  883. result0 = null;
  884. pos = clone(pos1);
  885. }
  886. if (result0 !== null) {
  887. result0 = (function(offset, line, column, n) {return parseFloat(n.join(""));})(pos0.offset, pos0.line, pos0.column, result0);
  888. }
  889. if (result0 === null) {
  890. pos = clone(pos0);
  891. }
  892. cache[cacheKey] = {
  893. nextPos: clone(pos),
  894. result: result0
  895. };
  896. return result0;
  897. }
  898. function parse_hex() {
  899. var cacheKey = "hex@" + pos.offset;
  900. var cachedResult = cache[cacheKey];
  901. if (cachedResult) {
  902. pos = clone(cachedResult.nextPos);
  903. return cachedResult.result;
  904. }
  905. var result0, result1, result2, result3;
  906. var pos0, pos1;
  907. pos0 = clone(pos);
  908. pos1 = clone(pos);
  909. if (/^[\-]/.test(input.charAt(pos.offset))) {
  910. result0 = input.charAt(pos.offset);
  911. advance(pos, 1);
  912. } else {
  913. result0 = null;
  914. if (reportFailures === 0) {
  915. matchFailed("[\\-]");
  916. }
  917. }
  918. result0 = result0 !== null ? result0 : "";
  919. if (result0 !== null) {
  920. if (input.substr(pos.offset, 3) === "16r") {
  921. result1 = "16r";
  922. advance(pos, 3);
  923. } else {
  924. result1 = null;
  925. if (reportFailures === 0) {
  926. matchFailed("\"16r\"");
  927. }
  928. }
  929. if (result1 !== null) {
  930. if (/^[0-9a-fA-F]/.test(input.charAt(pos.offset))) {
  931. result3 = input.charAt(pos.offset);
  932. advance(pos, 1);
  933. } else {
  934. result3 = null;
  935. if (reportFailures === 0) {
  936. matchFailed("[0-9a-fA-F]");
  937. }
  938. }
  939. if (result3 !== null) {
  940. result2 = [];
  941. while (result3 !== null) {
  942. result2.push(result3);
  943. if (/^[0-9a-fA-F]/.test(input.charAt(pos.offset))) {
  944. result3 = input.charAt(pos.offset);
  945. advance(pos, 1);
  946. } else {
  947. result3 = null;
  948. if (reportFailures === 0) {
  949. matchFailed("[0-9a-fA-F]");
  950. }
  951. }
  952. }
  953. } else {
  954. result2 = null;
  955. }
  956. if (result2 !== null) {
  957. result0 = [result0, result1, result2];
  958. } else {
  959. result0 = null;
  960. pos = clone(pos1);
  961. }
  962. } else {
  963. result0 = null;
  964. pos = clone(pos1);
  965. }
  966. } else {
  967. result0 = null;
  968. pos = clone(pos1);
  969. }
  970. if (result0 !== null) {
  971. result0 = (function(offset, line, column, neg, num) {return parseInt((neg + num.join("")), 16);})(pos0.offset, pos0.line, pos0.column, result0[0], result0[2]);
  972. }
  973. if (result0 === null) {
  974. pos = clone(pos0);
  975. }
  976. cache[cacheKey] = {
  977. nextPos: clone(pos),
  978. result: result0
  979. };
  980. return result0;
  981. }
  982. function parse_float() {
  983. var cacheKey = "float@" + pos.offset;
  984. var cachedResult = cache[cacheKey];
  985. if (cachedResult) {
  986. pos = clone(cachedResult.nextPos);
  987. return cachedResult.result;
  988. }
  989. var result0, result1, result2, result3, result4;
  990. var pos0, pos1;
  991. pos0 = clone(pos);
  992. pos1 = clone(pos);
  993. if (/^[\-]/.test(input.charAt(pos.offset))) {
  994. result0 = input.charAt(pos.offset);
  995. advance(pos, 1);
  996. } else {
  997. result0 = null;
  998. if (reportFailures === 0) {
  999. matchFailed("[\\-]");
  1000. }
  1001. }
  1002. result0 = result0 !== null ? result0 : "";
  1003. if (result0 !== null) {
  1004. if (/^[0-9]/.test(input.charAt(pos.offset))) {
  1005. result2 = input.charAt(pos.offset);
  1006. advance(pos, 1);
  1007. } else {
  1008. result2 = null;
  1009. if (reportFailures === 0) {
  1010. matchFailed("[0-9]");
  1011. }
  1012. }
  1013. if (result2 !== null) {
  1014. result1 = [];
  1015. while (result2 !== null) {
  1016. result1.push(result2);
  1017. if (/^[0-9]/.test(input.charAt(pos.offset))) {
  1018. result2 = input.charAt(pos.offset);
  1019. advance(pos, 1);
  1020. } else {
  1021. result2 = null;
  1022. if (reportFailures === 0) {
  1023. matchFailed("[0-9]");
  1024. }
  1025. }
  1026. }
  1027. } else {
  1028. result1 = null;
  1029. }
  1030. if (result1 !== null) {
  1031. if (input.charCodeAt(pos.offset) === 46) {
  1032. result2 = ".";
  1033. advance(pos, 1);
  1034. } else {
  1035. result2 = null;
  1036. if (reportFailures === 0) {
  1037. matchFailed("\".\"");
  1038. }
  1039. }
  1040. if (result2 !== null) {
  1041. if (/^[0-9]/.test(input.charAt(pos.offset))) {
  1042. result4 = input.charAt(pos.offset);
  1043. advance(pos, 1);
  1044. } else {
  1045. result4 = null;
  1046. if (reportFailures === 0) {
  1047. matchFailed("[0-9]");
  1048. }
  1049. }
  1050. if (result4 !== null) {
  1051. result3 = [];
  1052. while (result4 !== null) {
  1053. result3.push(result4);
  1054. if (/^[0-9]/.test(input.charAt(pos.offset))) {
  1055. result4 = input.charAt(pos.offset);
  1056. advance(pos, 1);
  1057. } else {
  1058. result4 = null;
  1059. if (reportFailures === 0) {
  1060. matchFailed("[0-9]");
  1061. }
  1062. }
  1063. }
  1064. } else {
  1065. result3 = null;
  1066. }
  1067. if (result3 !== null) {
  1068. result0 = [result0, result1, result2, result3];
  1069. } else {
  1070. result0 = null;
  1071. pos = clone(pos1);
  1072. }
  1073. } else {
  1074. result0 = null;
  1075. pos = clone(pos1);
  1076. }
  1077. } else {
  1078. result0 = null;
  1079. pos = clone(pos1);
  1080. }
  1081. } else {
  1082. result0 = null;
  1083. pos = clone(pos1);
  1084. }
  1085. if (result0 !== null) {
  1086. result0 = (function(offset, line, column, neg, digits, dec) {return parseFloat((neg + digits.join("") + "." + dec.join("")), 10);})(pos0.offset, pos0.line, pos0.column, result0[0], result0[1], result0[3]);
  1087. }
  1088. if (result0 === null) {
  1089. pos = clone(pos0);
  1090. }
  1091. cache[cacheKey] = {
  1092. nextPos: clone(pos),
  1093. result: result0
  1094. };
  1095. return result0;
  1096. }
  1097. function parse_integer() {
  1098. var cacheKey = "integer@" + pos.offset;
  1099. var cachedResult = cache[cacheKey];
  1100. if (cachedResult) {
  1101. pos = clone(cachedResult.nextPos);
  1102. return cachedResult.result;
  1103. }
  1104. var result0, result1, result2;
  1105. var pos0, pos1;
  1106. pos0 = clone(pos);
  1107. pos1 = clone(pos);
  1108. if (/^[\-]/.test(input.charAt(pos.offset))) {
  1109. result0 = input.charAt(pos.offset);
  1110. advance(pos, 1);
  1111. } else {
  1112. result0 = null;
  1113. if (reportFailures === 0) {
  1114. matchFailed("[\\-]");
  1115. }
  1116. }
  1117. result0 = result0 !== null ? result0 : "";
  1118. if (result0 !== null) {
  1119. if (/^[0-9]/.test(input.charAt(pos.offset))) {
  1120. result2 = input.charAt(pos.offset);
  1121. advance(pos, 1);
  1122. } else {
  1123. result2 = null;
  1124. if (reportFailures === 0) {
  1125. matchFailed("[0-9]");
  1126. }
  1127. }
  1128. if (result2 !== null) {
  1129. result1 = [];
  1130. while (result2 !== null) {
  1131. result1.push(result2);
  1132. if (/^[0-9]/.test(input.charAt(pos.offset))) {
  1133. result2 = input.charAt(pos.offset);
  1134. advance(pos, 1);
  1135. } else {
  1136. result2 = null;
  1137. if (reportFailures === 0) {
  1138. matchFailed("[0-9]");
  1139. }
  1140. }
  1141. }
  1142. } else {
  1143. result1 = null;
  1144. }
  1145. if (result1 !== null) {
  1146. result0 = [result0, result1];
  1147. } else {
  1148. result0 = null;
  1149. pos = clone(pos1);
  1150. }
  1151. } else {
  1152. result0 = null;
  1153. pos = clone(pos1);
  1154. }
  1155. if (result0 !== null) {
  1156. result0 = (function(offset, line, column, neg, digits) {return (parseInt(neg+digits.join(""), 10));})(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
  1157. }
  1158. if (result0 === null) {
  1159. pos = clone(pos0);
  1160. }
  1161. cache[cacheKey] = {
  1162. nextPos: clone(pos),
  1163. result: result0
  1164. };
  1165. return result0;
  1166. }
  1167. function parse_literalArray() {
  1168. var cacheKey = "literalArray@" + pos.offset;
  1169. var cachedResult = cache[cacheKey];
  1170. if (cachedResult) {
  1171. pos = clone(cachedResult.nextPos);
  1172. return cachedResult.result;
  1173. }
  1174. var result0, result1;
  1175. var pos0, pos1;
  1176. pos0 = clone(pos);
  1177. pos1 = clone(pos);
  1178. if (input.substr(pos.offset, 2) === "#(") {
  1179. result0 = "#(";
  1180. advance(pos, 2);
  1181. } else {
  1182. result0 = null;
  1183. if (reportFailures === 0) {
  1184. matchFailed("\"#(\"");
  1185. }
  1186. }
  1187. if (result0 !== null) {
  1188. result1 = parse_literalArrayRest();
  1189. if (result1 !== null) {
  1190. result0 = [result0, result1];
  1191. } else {
  1192. result0 = null;
  1193. pos = clone(pos1);
  1194. }
  1195. } else {
  1196. result0 = null;
  1197. pos = clone(pos1);
  1198. }
  1199. if (result0 !== null) {
  1200. result0 = (function(offset, line, column, rest) {return rest;})(pos0.offset, pos0.line, pos0.column, result0[1]);
  1201. }
  1202. if (result0 === null) {
  1203. pos = clone(pos0);
  1204. }
  1205. cache[cacheKey] = {
  1206. nextPos: clone(pos),
  1207. result: result0
  1208. };
  1209. return result0;
  1210. }
  1211. function parse_bareLiteralArray() {
  1212. var cacheKey = "bareLiteralArray@" + pos.offset;
  1213. var cachedResult = cache[cacheKey];
  1214. if (cachedResult) {
  1215. pos = clone(cachedResult.nextPos);
  1216. return cachedResult.result;
  1217. }
  1218. var result0, result1;
  1219. var pos0, pos1;
  1220. pos0 = clone(pos);
  1221. pos1 = clone(pos);
  1222. if (input.charCodeAt(pos.offset) === 40) {
  1223. result0 = "(";
  1224. advance(pos, 1);
  1225. } else {
  1226. result0 = null;
  1227. if (reportFailures === 0) {
  1228. matchFailed("\"(\"");
  1229. }
  1230. }
  1231. if (result0 !== null) {
  1232. result1 = parse_literalArrayRest();
  1233. if (result1 !== null) {
  1234. result0 = [result0, result1];
  1235. } else {
  1236. result0 = null;
  1237. pos = clone(pos1);
  1238. }
  1239. } else {
  1240. result0 = null;
  1241. pos = clone(pos1);
  1242. }
  1243. if (result0 !== null) {
  1244. result0 = (function(offset, line, column, rest) {return rest;})(pos0.offset, pos0.line, pos0.column, result0[1]);
  1245. }
  1246. if (result0 === null) {
  1247. pos = clone(pos0);
  1248. }
  1249. cache[cacheKey] = {
  1250. nextPos: clone(pos),
  1251. result: result0
  1252. };
  1253. return result0;
  1254. }
  1255. function parse_literalArrayRest() {
  1256. var cacheKey = "literalArrayRest@" + pos.offset;
  1257. var cachedResult = cache[cacheKey];
  1258. if (cachedResult) {
  1259. pos = clone(cachedResult.nextPos);
  1260. return cachedResult.result;
  1261. }
  1262. var result0, result1, result2, result3;
  1263. var pos0, pos1, pos2, pos3;
  1264. pos0 = clone(pos);
  1265. pos1 = clone(pos);
  1266. result0 = parse_ws();
  1267. if (result0 !== null) {
  1268. result1 = [];
  1269. pos2 = clone(pos);
  1270. pos3 = clone(pos);
  1271. result2 = parse_parseTimeLiteral();
  1272. if (result2 === null) {
  1273. result2 = parse_bareLiteralArray();
  1274. if (result2 === null) {
  1275. result2 = parse_bareSymbol();
  1276. }
  1277. }
  1278. if (result2 !== null) {
  1279. result3 = parse_ws();
  1280. if (result3 !== null) {
  1281. result2 = [result2, result3];
  1282. } else {
  1283. result2 = null;
  1284. pos = clone(pos3);
  1285. }
  1286. } else {
  1287. result2 = null;
  1288. pos = clone(pos3);
  1289. }
  1290. if (result2 !== null) {
  1291. result2 = (function(offset, line, column, lit) {return lit._value();})(pos2.offset, pos2.line, pos2.column, result2[0]);
  1292. }
  1293. if (result2 === null) {
  1294. pos = clone(pos2);
  1295. }
  1296. while (result2 !== null) {
  1297. result1.push(result2);
  1298. pos2 = clone(pos);
  1299. pos3 = clone(pos);
  1300. result2 = parse_parseTimeLiteral();
  1301. if (result2 === null) {
  1302. result2 = parse_bareLiteralArray();
  1303. if (result2 === null) {
  1304. result2 = parse_bareSymbol();
  1305. }
  1306. }
  1307. if (result2 !== null) {
  1308. result3 = parse_ws();
  1309. if (result3 !== null) {
  1310. result2 = [result2, result3];
  1311. } else {
  1312. result2 = null;
  1313. pos = clone(pos3);
  1314. }
  1315. } else {
  1316. result2 = null;
  1317. pos = clone(pos3);
  1318. }
  1319. if (result2 !== null) {
  1320. result2 = (function(offset, line, column, lit) {return lit._value();})(pos2.offset, pos2.line, pos2.column, result2[0]);
  1321. }
  1322. if (result2 === null) {
  1323. pos = clone(pos2);
  1324. }
  1325. }
  1326. if (result1 !== null) {
  1327. result2 = parse_ws();
  1328. if (result2 !== null) {
  1329. if (input.charCodeAt(pos.offset) === 41) {
  1330. result3 = ")";
  1331. advance(pos, 1);
  1332. } else {
  1333. result3 = null;
  1334. if (reportFailures === 0) {
  1335. matchFailed("\")\"");
  1336. }
  1337. }
  1338. if (result3 !== null) {
  1339. result0 = [result0, result1, result2, result3];
  1340. } else {
  1341. result0 = null;
  1342. pos = clone(pos1);
  1343. }
  1344. } else {
  1345. result0 = null;
  1346. pos = clone(pos1);
  1347. }
  1348. } else {
  1349. result0 = null;
  1350. pos = clone(pos1);
  1351. }
  1352. } else {
  1353. result0 = null;
  1354. pos = clone(pos1);
  1355. }
  1356. if (result0 !== null) {
  1357. result0 = (function(offset, line, column, lits) {
  1358. return smalltalk.ValueNode._new()
  1359. ._position_((line).__at(column))
  1360. ._value_(lits);
  1361. })(pos0.offset, pos0.line, pos0.column, result0[1]);
  1362. }
  1363. if (result0 === null) {
  1364. pos = clone(pos0);
  1365. }
  1366. cache[cacheKey] = {
  1367. nextPos: clone(pos),
  1368. result: result0
  1369. };
  1370. return result0;
  1371. }
  1372. function parse_dynamicArray() {
  1373. var cacheKey = "dynamicArray@" + pos.offset;
  1374. var cachedResult = cache[cacheKey];
  1375. if (cachedResult) {
  1376. pos = clone(cachedResult.nextPos);
  1377. return cachedResult.result;
  1378. }
  1379. var result0, result1, result2, result3, result4, result5;
  1380. var pos0, pos1;
  1381. pos0 = clone(pos);
  1382. pos1 = clone(pos);
  1383. if (input.charCodeAt(pos.offset) === 123) {
  1384. result0 = "{";
  1385. advance(pos, 1);
  1386. } else {
  1387. result0 = null;
  1388. if (reportFailures === 0) {
  1389. matchFailed("\"{\"");
  1390. }
  1391. }
  1392. if (result0 !== null) {
  1393. result1 = parse_ws();
  1394. if (result1 !== null) {
  1395. result2 = parse_expressions();
  1396. result2 = result2 !== null ? result2 : "";
  1397. if (result2 !== null) {
  1398. result3 = parse_ws();
  1399. if (result3 !== null) {
  1400. if (input.charCodeAt(pos.offset) === 46) {
  1401. result4 = ".";
  1402. advance(pos, 1);
  1403. } else {
  1404. result4 = null;
  1405. if (reportFailures === 0) {
  1406. matchFailed("\".\"");
  1407. }
  1408. }
  1409. result4 = result4 !== null ? result4 : "";
  1410. if (result4 !== null) {
  1411. if (input.charCodeAt(pos.offset) === 125) {
  1412. result5 = "}";
  1413. advance(pos, 1);
  1414. } else {
  1415. result5 = null;
  1416. if (reportFailures === 0) {
  1417. matchFailed("\"}\"");
  1418. }
  1419. }
  1420. if (result5 !== null) {
  1421. result0 = [result0, result1, result2, result3, result4, result5];
  1422. } else {
  1423. result0 = null;
  1424. pos = clone(pos1);
  1425. }
  1426. } else {
  1427. result0 = null;
  1428. pos = clone(pos1);
  1429. }
  1430. } else {
  1431. result0 = null;
  1432. pos = clone(pos1);
  1433. }
  1434. } else {
  1435. result0 = null;
  1436. pos = clone(pos1);
  1437. }
  1438. } else {
  1439. result0 = null;
  1440. pos = clone(pos1);
  1441. }
  1442. } else {
  1443. result0 = null;
  1444. pos = clone(pos1);
  1445. }
  1446. if (result0 !== null) {
  1447. result0 = (function(offset, line, column, expressions) {
  1448. return smalltalk.DynamicArrayNode._new()
  1449. ._position_((line).__at(column))
  1450. ._nodes_(expressions);
  1451. })(pos0.offset, pos0.line, pos0.column, result0[2]);
  1452. }
  1453. if (result0 === null) {
  1454. pos = clone(pos0);
  1455. }
  1456. cache[cacheKey] = {
  1457. nextPos: clone(pos),
  1458. result: result0
  1459. };
  1460. return result0;
  1461. }
  1462. function parse_dynamicDictionary() {
  1463. var cacheKey = "dynamicDictionary@" + pos.offset;
  1464. var cachedResult = cache[cacheKey];
  1465. if (cachedResult) {
  1466. pos = clone(cachedResult.nextPos);
  1467. return cachedResult.result;
  1468. }
  1469. var result0, result1, result2, result3, result4;
  1470. var pos0, pos1;
  1471. pos0 = clone(pos);
  1472. pos1 = clone(pos);
  1473. if (input.substr(pos.offset, 2) === "#{") {
  1474. result0 = "#{";
  1475. advance(pos, 2);
  1476. } else {
  1477. result0 = null;
  1478. if (reportFailures === 0) {
  1479. matchFailed("\"#{\"");
  1480. }
  1481. }
  1482. if (result0 !== null) {
  1483. result1 = parse_ws();
  1484. if (result1 !== null) {
  1485. result2 = parse_expressions();
  1486. result2 = result2 !== null ? result2 : "";
  1487. if (result2 !== null) {
  1488. result3 = parse_ws();
  1489. if (result3 !== null) {
  1490. if (input.charCodeAt(pos.offset) === 125) {
  1491. result4 = "}";
  1492. advance(pos, 1);
  1493. } else {
  1494. result4 = null;
  1495. if (reportFailures === 0) {
  1496. matchFailed("\"}\"");
  1497. }
  1498. }
  1499. if (result4 !== null) {
  1500. result0 = [result0, result1, result2, result3, result4];
  1501. } else {
  1502. result0 = null;
  1503. pos = clone(pos1);
  1504. }
  1505. } else {
  1506. result0 = null;
  1507. pos = clone(pos1);
  1508. }
  1509. } else {
  1510. result0 = null;
  1511. pos = clone(pos1);
  1512. }
  1513. } else {
  1514. result0 = null;
  1515. pos = clone(pos1);
  1516. }
  1517. } else {
  1518. result0 = null;
  1519. pos = clone(pos1);
  1520. }
  1521. if (result0 !== null) {
  1522. result0 = (function(offset, line, column, expressions) {
  1523. return smalltalk.DynamicDictionaryNode._new()
  1524. ._position_((line).__at(column))
  1525. ._nodes_(expressions);
  1526. })(pos0.offset, pos0.line, pos0.column, result0[2]);
  1527. }
  1528. if (result0 === null) {
  1529. pos = clone(pos0);
  1530. }
  1531. cache[cacheKey] = {
  1532. nextPos: clone(pos),
  1533. result: result0
  1534. };
  1535. return result0;
  1536. }
  1537. function parse_pseudoVariable() {
  1538. var cacheKey = "pseudoVariable@" + pos.offset;
  1539. var cachedResult = cache[cacheKey];
  1540. if (cachedResult) {
  1541. pos = clone(cachedResult.nextPos);
  1542. return cachedResult.result;
  1543. }
  1544. var result0;
  1545. var pos0, pos1;
  1546. pos0 = clone(pos);
  1547. pos1 = clone(pos);
  1548. if (input.substr(pos.offset, 4) === "true") {
  1549. result0 = "true";
  1550. advance(pos, 4);
  1551. } else {
  1552. result0 = null;
  1553. if (reportFailures === 0) {
  1554. matchFailed("\"true\"");
  1555. }
  1556. }
  1557. if (result0 !== null) {
  1558. result0 = (function(offset, line, column) {return true;})(pos1.offset, pos1.line, pos1.column);
  1559. }
  1560. if (result0 === null) {
  1561. pos = clone(pos1);
  1562. }
  1563. if (result0 === null) {
  1564. pos1 = clone(pos);
  1565. if (input.substr(pos.offset, 5) === "false") {
  1566. result0 = "false";
  1567. advance(pos, 5);
  1568. } else {
  1569. result0 = null;
  1570. if (reportFailures === 0) {
  1571. matchFailed("\"false\"");
  1572. }
  1573. }
  1574. if (result0 !== null) {
  1575. result0 = (function(offset, line, column) {return false;})(pos1.offset, pos1.line, pos1.column);
  1576. }
  1577. if (result0 === null) {
  1578. pos = clone(pos1);
  1579. }
  1580. if (result0 === null) {
  1581. pos1 = clone(pos);
  1582. if (input.substr(pos.offset, 3) === "nil") {
  1583. result0 = "nil";
  1584. advance(pos, 3);
  1585. } else {
  1586. result0 = null;
  1587. if (reportFailures === 0) {
  1588. matchFailed("\"nil\"");
  1589. }
  1590. }
  1591. if (result0 !== null) {
  1592. result0 = (function(offset, line, column) {return nil;})(pos1.offset, pos1.line, pos1.column);
  1593. }
  1594. if (result0 === null) {
  1595. pos = clone(pos1);
  1596. }
  1597. }
  1598. }
  1599. if (result0 !== null) {
  1600. result0 = (function(offset, line, column, val) {
  1601. return smalltalk.ValueNode._new()
  1602. ._position_((line).__at(column))
  1603. ._value_(val);
  1604. })(pos0.offset, pos0.line, pos0.column, result0);
  1605. }
  1606. if (result0 === null) {
  1607. pos = clone(pos0);
  1608. }
  1609. cache[cacheKey] = {
  1610. nextPos: clone(pos),
  1611. result: result0
  1612. };
  1613. return result0;
  1614. }
  1615. function parse_parseTimeLiteral() {
  1616. var cacheKey = "parseTimeLiteral@" + pos.offset;
  1617. var cachedResult = cache[cacheKey];
  1618. if (cachedResult) {
  1619. pos = clone(cachedResult.nextPos);
  1620. return cachedResult.result;
  1621. }
  1622. var result0;
  1623. result0 = parse_pseudoVariable();
  1624. if (result0 === null) {
  1625. result0 = parse_number();
  1626. if (result0 === null) {
  1627. result0 = parse_literalArray();
  1628. if (result0 === null) {
  1629. result0 = parse_string();
  1630. if (result0 === null) {
  1631. result0 = parse_symbol();
  1632. }
  1633. }
  1634. }
  1635. }
  1636. cache[cacheKey] = {
  1637. nextPos: clone(pos),
  1638. result: result0
  1639. };
  1640. return result0;
  1641. }
  1642. function parse_runtimeLiteral() {
  1643. var cacheKey = "runtimeLiteral@" + pos.offset;
  1644. var cachedResult = cache[cacheKey];
  1645. if (cachedResult) {
  1646. pos = clone(cachedResult.nextPos);
  1647. return cachedResult.result;
  1648. }
  1649. var result0;
  1650. result0 = parse_dynamicDictionary();
  1651. if (result0 === null) {
  1652. result0 = parse_dynamicArray();
  1653. if (result0 === null) {
  1654. result0 = parse_block();
  1655. }
  1656. }
  1657. cache[cacheKey] = {
  1658. nextPos: clone(pos),
  1659. result: result0
  1660. };
  1661. return result0;
  1662. }
  1663. function parse_literal() {
  1664. var cacheKey = "literal@" + pos.offset;
  1665. var cachedResult = cache[cacheKey];
  1666. if (cachedResult) {
  1667. pos = clone(cachedResult.nextPos);
  1668. return cachedResult.result;
  1669. }
  1670. var result0;
  1671. result0 = parse_runtimeLiteral();
  1672. if (result0 === null) {
  1673. result0 = parse_parseTimeLiteral();
  1674. }
  1675. cache[cacheKey] = {
  1676. nextPos: clone(pos),
  1677. result: result0
  1678. };
  1679. return result0;
  1680. }
  1681. function parse_variable() {
  1682. var cacheKey = "variable@" + pos.offset;
  1683. var cachedResult = cache[cacheKey];
  1684. if (cachedResult) {
  1685. pos = clone(cachedResult.nextPos);
  1686. return cachedResult.result;
  1687. }
  1688. var result0;
  1689. var pos0;
  1690. pos0 = clone(pos);
  1691. result0 = parse_identifier();
  1692. if (result0 !== null) {
  1693. result0 = (function(offset, line, column, identifier) {
  1694. return smalltalk.VariableNode._new()
  1695. ._position_((line).__at(column))
  1696. ._value_(identifier);
  1697. })(pos0.offset, pos0.line, pos0.column, result0);
  1698. }
  1699. if (result0 === null) {
  1700. pos = clone(pos0);
  1701. }
  1702. cache[cacheKey] = {
  1703. nextPos: clone(pos),
  1704. result: result0
  1705. };
  1706. return result0;
  1707. }
  1708. function parse_keywordPair() {
  1709. var cacheKey = "keywordPair@" + pos.offset;
  1710. var cachedResult = cache[cacheKey];
  1711. if (cachedResult) {
  1712. pos = clone(cachedResult.nextPos);
  1713. return cachedResult.result;
  1714. }
  1715. var result0, result1, result2, result3;
  1716. var pos0, pos1;
  1717. pos0 = clone(pos);
  1718. pos1 = clone(pos);
  1719. result0 = parse_keyword();
  1720. if (result0 !== null) {
  1721. result1 = parse_ws();
  1722. if (result1 !== null) {
  1723. result2 = parse_binarySend();
  1724. if (result2 !== null) {
  1725. result3 = parse_ws();
  1726. if (result3 !== null) {
  1727. result0 = [result0, result1, result2, result3];
  1728. } else {
  1729. result0 = null;
  1730. pos = clone(pos1);
  1731. }
  1732. } else {
  1733. result0 = null;
  1734. pos = clone(pos1);
  1735. }
  1736. } else {
  1737. result0 = null;
  1738. pos = clone(pos1);
  1739. }
  1740. } else {
  1741. result0 = null;
  1742. pos = clone(pos1);
  1743. }
  1744. if (result0 !== null) {
  1745. result0 = (function(offset, line, column, key, arg) {return {key:key, arg: arg};})(pos0.offset, pos0.line, pos0.column, result0[0], result0[2]);
  1746. }
  1747. if (result0 === null) {
  1748. pos = clone(pos0);
  1749. }
  1750. cache[cacheKey] = {
  1751. nextPos: clone(pos),
  1752. result: result0
  1753. };
  1754. return result0;
  1755. }
  1756. function parse_binarySelector() {
  1757. var cacheKey = "binarySelector@" + pos.offset;
  1758. var cachedResult = cache[cacheKey];
  1759. if (cachedResult) {
  1760. pos = clone(cachedResult.nextPos);
  1761. return cachedResult.result;
  1762. }
  1763. var result0, result1;
  1764. var pos0;
  1765. pos0 = clone(pos);
  1766. if (/^[\\+*\/=><,@%~|&\-]/.test(input.charAt(pos.offset))) {
  1767. result1 = input.charAt(pos.offset);
  1768. advance(pos, 1);
  1769. } else {
  1770. result1 = null;
  1771. if (reportFailures === 0) {
  1772. matchFailed("[\\\\+*\\/=><,@%~|&\\-]");
  1773. }
  1774. }
  1775. if (result1 !== null) {
  1776. result0 = [];
  1777. while (result1 !== null) {
  1778. result0.push(result1);
  1779. if (/^[\\+*\/=><,@%~|&\-]/.test(input.charAt(pos.offset))) {
  1780. result1 = input.charAt(pos.offset);
  1781. advance(pos, 1);
  1782. } else {
  1783. result1 = null;
  1784. if (reportFailures === 0) {
  1785. matchFailed("[\\\\+*\\/=><,@%~|&\\-]");
  1786. }
  1787. }
  1788. }
  1789. } else {
  1790. result0 = null;
  1791. }
  1792. if (result0 !== null) {
  1793. result0 = (function(offset, line, column, bin) {return bin.join("");})(pos0.offset, pos0.line, pos0.column, result0);
  1794. }
  1795. if (result0 === null) {
  1796. pos = clone(pos0);
  1797. }
  1798. cache[cacheKey] = {
  1799. nextPos: clone(pos),
  1800. result: result0
  1801. };
  1802. return result0;
  1803. }
  1804. function parse_keywordPattern() {
  1805. var cacheKey = "keywordPattern@" + pos.offset;
  1806. var cachedResult = cache[cacheKey];
  1807. if (cachedResult) {
  1808. pos = clone(cachedResult.nextPos);
  1809. return cachedResult.result;
  1810. }
  1811. var result0, result1, result2, result3, result4;
  1812. var pos0, pos1, pos2;
  1813. pos0 = clone(pos);
  1814. pos1 = clone(pos);
  1815. pos2 = clone(pos);
  1816. result1 = parse_ws();
  1817. if (result1 !== null) {
  1818. result2 = parse_keyword();
  1819. if (result2 !== null) {
  1820. result3 = parse_ws();
  1821. if (result3 !== null) {
  1822. result4 = parse_identifier();
  1823. if (result4 !== null) {
  1824. result1 = [result1, result2, result3, result4];
  1825. } else {
  1826. result1 = null;
  1827. pos = clone(pos2);
  1828. }
  1829. } else {
  1830. result1 = null;
  1831. pos = clone(pos2);
  1832. }
  1833. } else {
  1834. result1 = null;
  1835. pos = clone(pos2);
  1836. }
  1837. } else {
  1838. result1 = null;
  1839. pos = clone(pos2);
  1840. }
  1841. if (result1 !== null) {
  1842. result1 = (function(offset, line, column, key, arg) {return {key:key, arg: arg};})(pos1.offset, pos1.line, pos1.column, result1[1], result1[3]);
  1843. }
  1844. if (result1 === null) {
  1845. pos = clone(pos1);
  1846. }
  1847. if (result1 !== null) {
  1848. result0 = [];
  1849. while (result1 !== null) {
  1850. result0.push(result1);
  1851. pos1 = clone(pos);
  1852. pos2 = clone(pos);
  1853. result1 = parse_ws();
  1854. if (result1 !== null) {
  1855. result2 = parse_keyword();
  1856. if (result2 !== null) {
  1857. result3 = parse_ws();
  1858. if (result3 !== null) {
  1859. result4 = parse_identifier();
  1860. if (result4 !== null) {
  1861. result1 = [result1, result2, result3, result4];
  1862. } else {
  1863. result1 = null;
  1864. pos = clone(pos2);
  1865. }
  1866. } else {
  1867. result1 = null;
  1868. pos = clone(pos2);
  1869. }
  1870. } else {
  1871. result1 = null;
  1872. pos = clone(pos2);
  1873. }
  1874. } else {
  1875. result1 = null;
  1876. pos = clone(pos2);
  1877. }
  1878. if (result1 !== null) {
  1879. result1 = (function(offset, line, column, key, arg) {return {key:key, arg: arg};})(pos1.offset, pos1.line, pos1.column, result1[1], result1[3]);
  1880. }
  1881. if (result1 === null) {
  1882. pos = clone(pos1);
  1883. }
  1884. }
  1885. } else {
  1886. result0 = null;
  1887. }
  1888. if (result0 !== null) {
  1889. result0 = (function(offset, line, column, pairs) {
  1890. var keywords = [];
  1891. var params = [];
  1892. var i = 0;
  1893. for(i = 0; i < pairs.length; i++){
  1894. keywords.push(pairs[i].key);
  1895. }
  1896. for(i = 0; i < pairs.length; i++){
  1897. params.push(pairs[i].arg);
  1898. }
  1899. return [keywords.join(""), params];
  1900. })(pos0.offset, pos0.line, pos0.column, result0);
  1901. }
  1902. if (result0 === null) {
  1903. pos = clone(pos0);
  1904. }
  1905. cache[cacheKey] = {
  1906. nextPos: clone(pos),
  1907. result: result0
  1908. };
  1909. return result0;
  1910. }
  1911. function parse_binaryPattern() {
  1912. var cacheKey = "binaryPattern@" + pos.offset;
  1913. var cachedResult = cache[cacheKey];
  1914. if (cachedResult) {
  1915. pos = clone(cachedResult.nextPos);
  1916. return cachedResult.result;
  1917. }
  1918. var result0, result1, result2, result3;
  1919. var pos0, pos1;
  1920. pos0 = clone(pos);
  1921. pos1 = clone(pos);
  1922. result0 = parse_ws();
  1923. if (result0 !== null) {
  1924. result1 = parse_binarySelector();
  1925. if (result1 !== null) {
  1926. result2 = parse_ws();
  1927. if (result2 !== null) {
  1928. result3 = parse_identifier();
  1929. if (result3 !== null) {
  1930. result0 = [result0, result1, result2, result3];
  1931. } else {
  1932. result0 = null;
  1933. pos = clone(pos1);
  1934. }
  1935. } else {
  1936. result0 = null;
  1937. pos = clone(pos1);
  1938. }
  1939. } else {
  1940. result0 = null;
  1941. pos = clone(pos1);
  1942. }
  1943. } else {
  1944. result0 = null;
  1945. pos = clone(pos1);
  1946. }
  1947. if (result0 !== null) {
  1948. result0 = (function(offset, line, column, selector, arg) {return [selector, [arg]];})(pos0.offset, pos0.line, pos0.column, result0[1], result0[3]);
  1949. }
  1950. if (result0 === null) {
  1951. pos = clone(pos0);
  1952. }
  1953. cache[cacheKey] = {
  1954. nextPos: clone(pos),
  1955. result: result0
  1956. };
  1957. return result0;
  1958. }
  1959. function parse_unaryPattern() {
  1960. var cacheKey = "unaryPattern@" + pos.offset;
  1961. var cachedResult = cache[cacheKey];
  1962. if (cachedResult) {
  1963. pos = clone(cachedResult.nextPos);
  1964. return cachedResult.result;
  1965. }
  1966. var result0, result1;
  1967. var pos0, pos1;
  1968. pos0 = clone(pos);
  1969. pos1 = clone(pos);
  1970. result0 = parse_ws();
  1971. if (result0 !== null) {
  1972. result1 = parse_identifier();
  1973. if (result1 !== null) {
  1974. result0 = [result0, result1];
  1975. } else {
  1976. result0 = null;
  1977. pos = clone(pos1);
  1978. }
  1979. } else {
  1980. result0 = null;
  1981. pos = clone(pos1);
  1982. }
  1983. if (result0 !== null) {
  1984. result0 = (function(offset, line, column, selector) {return [selector, []];})(pos0.offset, pos0.line, pos0.column, result0[1]);
  1985. }
  1986. if (result0 === null) {
  1987. pos = clone(pos0);
  1988. }
  1989. cache[cacheKey] = {
  1990. nextPos: clone(pos),
  1991. result: result0
  1992. };
  1993. return result0;
  1994. }
  1995. function parse_expression() {
  1996. var cacheKey = "expression@" + pos.offset;
  1997. var cachedResult = cache[cacheKey];
  1998. if (cachedResult) {
  1999. pos = clone(cachedResult.nextPos);
  2000. return cachedResult.result;
  2001. }
  2002. var result0;
  2003. result0 = parse_assignment();
  2004. if (result0 === null) {
  2005. result0 = parse_cascade();
  2006. if (result0 === null) {
  2007. result0 = parse_keywordSend();
  2008. if (result0 === null) {
  2009. result0 = parse_binarySend();
  2010. }
  2011. }
  2012. }
  2013. cache[cacheKey] = {
  2014. nextPos: clone(pos),
  2015. result: result0
  2016. };
  2017. return result0;
  2018. }
  2019. function parse_expressionList() {
  2020. var cacheKey = "expressionList@" + pos.offset;
  2021. var cachedResult = cache[cacheKey];
  2022. if (cachedResult) {
  2023. pos = clone(cachedResult.nextPos);
  2024. return cachedResult.result;
  2025. }
  2026. var result0, result1, result2, result3;
  2027. var pos0, pos1;
  2028. pos0 = clone(pos);
  2029. pos1 = clone(pos);
  2030. result0 = parse_ws();
  2031. if (result0 !== null) {
  2032. if (input.charCodeAt(pos.offset) === 46) {
  2033. result1 = ".";
  2034. advance(pos, 1);
  2035. } else {
  2036. result1 = null;
  2037. if (reportFailures === 0) {
  2038. matchFailed("\".\"");
  2039. }
  2040. }
  2041. if (result1 !== null) {
  2042. result2 = parse_ws();
  2043. if (result2 !== null) {
  2044. result3 = parse_expression();
  2045. if (result3 !== null) {
  2046. result0 = [result0, result1, result2, result3];
  2047. } else {
  2048. result0 = null;
  2049. pos = clone(pos1);
  2050. }
  2051. } else {
  2052. result0 = null;
  2053. pos = clone(pos1);
  2054. }
  2055. } else {
  2056. result0 = null;
  2057. pos = clone(pos1);
  2058. }
  2059. } else {
  2060. result0 = null;
  2061. pos = clone(pos1);
  2062. }
  2063. if (result0 !== null) {
  2064. result0 = (function(offset, line, column, expression) {return expression;})(pos0.offset, pos0.line, pos0.column, result0[3]);
  2065. }
  2066. if (result0 === null) {
  2067. pos = clone(pos0);
  2068. }
  2069. cache[cacheKey] = {
  2070. nextPos: clone(pos),
  2071. result: result0
  2072. };
  2073. return result0;
  2074. }
  2075. function parse_expressions() {
  2076. var cacheKey = "expressions@" + pos.offset;
  2077. var cachedResult = cache[cacheKey];
  2078. if (cachedResult) {
  2079. pos = clone(cachedResult.nextPos);
  2080. return cachedResult.result;
  2081. }
  2082. var result0, result1, result2;
  2083. var pos0, pos1;
  2084. pos0 = clone(pos);
  2085. pos1 = clone(pos);
  2086. result0 = parse_expression();
  2087. if (result0 !== null) {
  2088. result1 = [];
  2089. result2 = parse_expressionList();
  2090. while (result2 !== null) {
  2091. result1.push(result2);
  2092. result2 = parse_expressionList();
  2093. }
  2094. if (result1 !== null) {
  2095. result0 = [result0, result1];
  2096. } else {
  2097. result0 = null;
  2098. pos = clone(pos1);
  2099. }
  2100. } else {
  2101. result0 = null;
  2102. pos = clone(pos1);
  2103. }
  2104. if (result0 !== null) {
  2105. result0 = (function(offset, line, column, first, others) {
  2106. var result = [first];
  2107. for(var i = 0; i < others.length; i++) {
  2108. result.push(others[i]);
  2109. }
  2110. return result;
  2111. })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
  2112. }
  2113. if (result0 === null) {
  2114. pos = clone(pos0);
  2115. }
  2116. cache[cacheKey] = {
  2117. nextPos: clone(pos),
  2118. result: result0
  2119. };
  2120. return result0;
  2121. }
  2122. function parse_assignment() {
  2123. var cacheKey = "assignment@" + pos.offset;
  2124. var cachedResult = cache[cacheKey];
  2125. if (cachedResult) {
  2126. pos = clone(cachedResult.nextPos);
  2127. return cachedResult.result;
  2128. }
  2129. var result0, result1, result2, result3, result4;
  2130. var pos0, pos1;
  2131. pos0 = clone(pos);
  2132. pos1 = clone(pos);
  2133. result0 = parse_variable();
  2134. if (result0 !== null) {
  2135. result1 = parse_ws();
  2136. if (result1 !== null) {
  2137. if (input.substr(pos.offset, 2) === ":=") {
  2138. result2 = ":=";
  2139. advance(pos, 2);
  2140. } else {
  2141. result2 = null;
  2142. if (reportFailures === 0) {
  2143. matchFailed("\":=\"");
  2144. }
  2145. }
  2146. if (result2 !== null) {
  2147. result3 = parse_ws();
  2148. if (result3 !== null) {
  2149. result4 = parse_expression();
  2150. if (result4 !== null) {
  2151. result0 = [result0, result1, result2, result3, result4];
  2152. } else {
  2153. result0 = null;
  2154. pos = clone(pos1);
  2155. }
  2156. } else {
  2157. result0 = null;
  2158. pos = clone(pos1);
  2159. }
  2160. } else {
  2161. result0 = null;
  2162. pos = clone(pos1);
  2163. }
  2164. } else {
  2165. result0 = null;
  2166. pos = clone(pos1);
  2167. }
  2168. } else {
  2169. result0 = null;
  2170. pos = clone(pos1);
  2171. }
  2172. if (result0 !== null) {
  2173. result0 = (function(offset, line, column, variable, expression) {
  2174. return smalltalk.AssignmentNode._new()
  2175. ._position_((line).__at(column))
  2176. ._left_(variable)
  2177. ._right_(expression);
  2178. })(pos0.offset, pos0.line, pos0.column, result0[0], result0[4]);
  2179. }
  2180. if (result0 === null) {
  2181. pos = clone(pos0);
  2182. }
  2183. cache[cacheKey] = {
  2184. nextPos: clone(pos),
  2185. result: result0
  2186. };
  2187. return result0;
  2188. }
  2189. function parse_ret() {
  2190. var cacheKey = "ret@" + pos.offset;
  2191. var cachedResult = cache[cacheKey];
  2192. if (cachedResult) {
  2193. pos = clone(cachedResult.nextPos);
  2194. return cachedResult.result;
  2195. }
  2196. var result0, result1, result2, result3, result4;
  2197. var pos0, pos1;
  2198. pos0 = clone(pos);
  2199. pos1 = clone(pos);
  2200. if (input.charCodeAt(pos.offset) === 94) {
  2201. result0 = "^";
  2202. advance(pos, 1);
  2203. } else {
  2204. result0 = null;
  2205. if (reportFailures === 0) {
  2206. matchFailed("\"^\"");
  2207. }
  2208. }
  2209. if (result0 !== null) {
  2210. result1 = parse_ws();
  2211. if (result1 !== null) {
  2212. result2 = parse_expression();
  2213. if (result2 !== null) {
  2214. result3 = parse_ws();
  2215. if (result3 !== null) {
  2216. if (input.charCodeAt(pos.offset) === 46) {
  2217. result4 = ".";
  2218. advance(pos, 1);
  2219. } else {
  2220. result4 = null;
  2221. if (reportFailures === 0) {
  2222. matchFailed("\".\"");
  2223. }
  2224. }
  2225. result4 = result4 !== null ? result4 : "";
  2226. if (result4 !== null) {
  2227. result0 = [result0, result1, result2, result3, result4];
  2228. } else {
  2229. result0 = null;
  2230. pos = clone(pos1);
  2231. }
  2232. } else {
  2233. result0 = null;
  2234. pos = clone(pos1);
  2235. }
  2236. } else {
  2237. result0 = null;
  2238. pos = clone(pos1);
  2239. }
  2240. } else {
  2241. result0 = null;
  2242. pos = clone(pos1);
  2243. }
  2244. } else {
  2245. result0 = null;
  2246. pos = clone(pos1);
  2247. }
  2248. if (result0 !== null) {
  2249. result0 = (function(offset, line, column, expression) {
  2250. return smalltalk.ReturnNode._new()
  2251. ._position_((line).__at(column))
  2252. ._nodes_([expression]);
  2253. })(pos0.offset, pos0.line, pos0.column, result0[2]);
  2254. }
  2255. if (result0 === null) {
  2256. pos = clone(pos0);
  2257. }
  2258. cache[cacheKey] = {
  2259. nextPos: clone(pos),
  2260. result: result0
  2261. };
  2262. return result0;
  2263. }
  2264. function parse_temps() {
  2265. var cacheKey = "temps@" + pos.offset;
  2266. var cachedResult = cache[cacheKey];
  2267. if (cachedResult) {
  2268. pos = clone(cachedResult.nextPos);
  2269. return cachedResult.result;
  2270. }
  2271. var result0, result1, result2, result3, result4;
  2272. var pos0, pos1, pos2, pos3;
  2273. pos0 = clone(pos);
  2274. pos1 = clone(pos);
  2275. if (input.charCodeAt(pos.offset) === 124) {
  2276. result0 = "|";
  2277. advance(pos, 1);
  2278. } else {
  2279. result0 = null;
  2280. if (reportFailures === 0) {
  2281. matchFailed("\"|\"");
  2282. }
  2283. }
  2284. if (result0 !== null) {
  2285. result1 = [];
  2286. pos2 = clone(pos);
  2287. pos3 = clone(pos);
  2288. result2 = parse_ws();
  2289. if (result2 !== null) {
  2290. result3 = parse_identifier();
  2291. if (result3 !== null) {
  2292. result4 = parse_ws();
  2293. if (result4 !== null) {
  2294. result2 = [result2, result3, result4];
  2295. } else {
  2296. result2 = null;
  2297. pos = clone(pos3);
  2298. }
  2299. } else {
  2300. result2 = null;
  2301. pos = clone(pos3);
  2302. }
  2303. } else {
  2304. result2 = null;
  2305. pos = clone(pos3);
  2306. }
  2307. if (result2 !== null) {
  2308. result2 = (function(offset, line, column, variable) {return variable;})(pos2.offset, pos2.line, pos2.column, result2[1]);
  2309. }
  2310. if (result2 === null) {
  2311. pos = clone(pos2);
  2312. }
  2313. while (result2 !== null) {
  2314. result1.push(result2);
  2315. pos2 = clone(pos);
  2316. pos3 = clone(pos);
  2317. result2 = parse_ws();
  2318. if (result2 !== null) {
  2319. result3 = parse_identifier();
  2320. if (result3 !== null) {
  2321. result4 = parse_ws();
  2322. if (result4 !== null) {
  2323. result2 = [result2, result3, result4];
  2324. } else {
  2325. result2 = null;
  2326. pos = clone(pos3);
  2327. }
  2328. } else {
  2329. result2 = null;
  2330. pos = clone(pos3);
  2331. }
  2332. } else {
  2333. result2 = null;
  2334. pos = clone(pos3);
  2335. }
  2336. if (result2 !== null) {
  2337. result2 = (function(offset, line, column, variable) {return variable;})(pos2.offset, pos2.line, pos2.column, result2[1]);
  2338. }
  2339. if (result2 === null) {
  2340. pos = clone(pos2);
  2341. }
  2342. }
  2343. if (result1 !== null) {
  2344. if (input.charCodeAt(pos.offset) === 124) {
  2345. result2 = "|";
  2346. advance(pos, 1);
  2347. } else {
  2348. result2 = null;
  2349. if (reportFailures === 0) {
  2350. matchFailed("\"|\"");
  2351. }
  2352. }
  2353. if (result2 !== null) {
  2354. result0 = [result0, result1, result2];
  2355. } else {
  2356. result0 = null;
  2357. pos = clone(pos1);
  2358. }
  2359. } else {
  2360. result0 = null;
  2361. pos = clone(pos1);
  2362. }
  2363. } else {
  2364. result0 = null;
  2365. pos = clone(pos1);
  2366. }
  2367. if (result0 !== null) {
  2368. result0 = (function(offset, line, column, vars) {return vars;})(pos0.offset, pos0.line, pos0.column, result0[1]);
  2369. }
  2370. if (result0 === null) {
  2371. pos = clone(pos0);
  2372. }
  2373. cache[cacheKey] = {
  2374. nextPos: clone(pos),
  2375. result: result0
  2376. };
  2377. return result0;
  2378. }
  2379. function parse_blockParamList() {
  2380. var cacheKey = "blockParamList@" + pos.offset;
  2381. var cachedResult = cache[cacheKey];
  2382. if (cachedResult) {
  2383. pos = clone(cachedResult.nextPos);
  2384. return cachedResult.result;
  2385. }
  2386. var result0, result1, result2, result3, result4;
  2387. var pos0, pos1, pos2, pos3;
  2388. pos0 = clone(pos);
  2389. pos1 = clone(pos);
  2390. pos2 = clone(pos);
  2391. pos3 = clone(pos);
  2392. result1 = parse_ws();
  2393. if (result1 !== null) {
  2394. if (input.charCodeAt(pos.offset) === 58) {
  2395. result2 = ":";
  2396. advance(pos, 1);
  2397. } else {
  2398. result2 = null;
  2399. if (reportFailures === 0) {
  2400. matchFailed("\":\"");
  2401. }
  2402. }
  2403. if (result2 !== null) {
  2404. result3 = parse_ws();
  2405. if (result3 !== null) {
  2406. result4 = parse_identifier();
  2407. if (result4 !== null) {
  2408. result1 = [result1, result2, result3, result4];
  2409. } else {
  2410. result1 = null;
  2411. pos = clone(pos3);
  2412. }
  2413. } else {
  2414. result1 = null;
  2415. pos = clone(pos3);
  2416. }
  2417. } else {
  2418. result1 = null;
  2419. pos = clone(pos3);
  2420. }
  2421. } else {
  2422. result1 = null;
  2423. pos = clone(pos3);
  2424. }
  2425. if (result1 !== null) {
  2426. result1 = (function(offset, line, column, param) {return param;})(pos2.offset, pos2.line, pos2.column, result1[3]);
  2427. }
  2428. if (result1 === null) {
  2429. pos = clone(pos2);
  2430. }
  2431. if (result1 !== null) {
  2432. result0 = [];
  2433. while (result1 !== null) {
  2434. result0.push(result1);
  2435. pos2 = clone(pos);
  2436. pos3 = clone(pos);
  2437. result1 = parse_ws();
  2438. if (result1 !== null) {
  2439. if (input.charCodeAt(pos.offset) === 58) {
  2440. result2 = ":";
  2441. advance(pos, 1);
  2442. } else {
  2443. result2 = null;
  2444. if (reportFailures === 0) {
  2445. matchFailed("\":\"");
  2446. }
  2447. }
  2448. if (result2 !== null) {
  2449. result3 = parse_ws();
  2450. if (result3 !== null) {
  2451. result4 = parse_identifier();
  2452. if (result4 !== null) {
  2453. result1 = [result1, result2, result3, result4];
  2454. } else {
  2455. result1 = null;
  2456. pos = clone(pos3);
  2457. }
  2458. } else {
  2459. result1 = null;
  2460. pos = clone(pos3);
  2461. }
  2462. } else {
  2463. result1 = null;
  2464. pos = clone(pos3);
  2465. }
  2466. } else {
  2467. result1 = null;
  2468. pos = clone(pos3);
  2469. }
  2470. if (result1 !== null) {
  2471. result1 = (function(offset, line, column, param) {return param;})(pos2.offset, pos2.line, pos2.column, result1[3]);
  2472. }
  2473. if (result1 === null) {
  2474. pos = clone(pos2);
  2475. }
  2476. }
  2477. } else {
  2478. result0 = null;
  2479. }
  2480. if (result0 !== null) {
  2481. result1 = parse_ws();
  2482. if (result1 !== null) {
  2483. if (input.charCodeAt(pos.offset) === 124) {
  2484. result2 = "|";
  2485. advance(pos, 1);
  2486. } else {
  2487. result2 = null;
  2488. if (reportFailures === 0) {
  2489. matchFailed("\"|\"");
  2490. }
  2491. }
  2492. if (result2 !== null) {
  2493. result0 = [result0, result1, result2];
  2494. } else {
  2495. result0 = null;
  2496. pos = clone(pos1);
  2497. }
  2498. } else {
  2499. result0 = null;
  2500. pos = clone(pos1);
  2501. }
  2502. } else {
  2503. result0 = null;
  2504. pos = clone(pos1);
  2505. }
  2506. if (result0 !== null) {
  2507. result0 = (function(offset, line, column, params) {return params;})(pos0.offset, pos0.line, pos0.column, result0[0]);
  2508. }
  2509. if (result0 === null) {
  2510. pos = clone(pos0);
  2511. }
  2512. cache[cacheKey] = {
  2513. nextPos: clone(pos),
  2514. result: result0
  2515. };
  2516. return result0;
  2517. }
  2518. function parse_subexpression() {
  2519. var cacheKey = "subexpression@" + pos.offset;
  2520. var cachedResult = cache[cacheKey];
  2521. if (cachedResult) {
  2522. pos = clone(cachedResult.nextPos);
  2523. return cachedResult.result;
  2524. }
  2525. var result0, result1, result2, result3, result4;
  2526. var pos0, pos1;
  2527. pos0 = clone(pos);
  2528. pos1 = clone(pos);
  2529. if (input.charCodeAt(pos.offset) === 40) {
  2530. result0 = "(";
  2531. advance(pos, 1);
  2532. } else {
  2533. result0 = null;
  2534. if (reportFailures === 0) {
  2535. matchFailed("\"(\"");
  2536. }
  2537. }
  2538. if (result0 !== null) {
  2539. result1 = parse_ws();
  2540. if (result1 !== null) {
  2541. result2 = parse_expression();
  2542. if (result2 !== null) {
  2543. result3 = parse_ws();
  2544. if (result3 !== null) {
  2545. if (input.charCodeAt(pos.offset) === 41) {
  2546. result4 = ")";
  2547. advance(pos, 1);
  2548. } else {
  2549. result4 = null;
  2550. if (reportFailures === 0) {
  2551. matchFailed("\")\"");
  2552. }
  2553. }
  2554. if (result4 !== null) {
  2555. result0 = [result0, result1, result2, result3, result4];
  2556. } else {
  2557. result0 = null;
  2558. pos = clone(pos1);
  2559. }
  2560. } else {
  2561. result0 = null;
  2562. pos = clone(pos1);
  2563. }
  2564. } else {
  2565. result0 = null;
  2566. pos = clone(pos1);
  2567. }
  2568. } else {
  2569. result0 = null;
  2570. pos = clone(pos1);
  2571. }
  2572. } else {
  2573. result0 = null;
  2574. pos = clone(pos1);
  2575. }
  2576. if (result0 !== null) {
  2577. result0 = (function(offset, line, column, expression) {return expression;})(pos0.offset, pos0.line, pos0.column, result0[2]);
  2578. }
  2579. if (result0 === null) {
  2580. pos = clone(pos0);
  2581. }
  2582. cache[cacheKey] = {
  2583. nextPos: clone(pos),
  2584. result: result0
  2585. };
  2586. return result0;
  2587. }
  2588. function parse_statements() {
  2589. var cacheKey = "statements@" + pos.offset;
  2590. var cachedResult = cache[cacheKey];
  2591. if (cachedResult) {
  2592. pos = clone(cachedResult.nextPos);
  2593. return cachedResult.result;
  2594. }
  2595. var result0, result1, result2, result3, result4, result5, result6;
  2596. var pos0, pos1;
  2597. pos0 = clone(pos);
  2598. pos1 = clone(pos);
  2599. result0 = parse_ret();
  2600. if (result0 !== null) {
  2601. result1 = [];
  2602. if (/^[.]/.test(input.charAt(pos.offset))) {
  2603. result2 = input.charAt(pos.offset);
  2604. advance(pos, 1);
  2605. } else {
  2606. result2 = null;
  2607. if (reportFailures === 0) {
  2608. matchFailed("[.]");
  2609. }
  2610. }
  2611. while (result2 !== null) {
  2612. result1.push(result2);
  2613. if (/^[.]/.test(input.charAt(pos.offset))) {
  2614. result2 = input.charAt(pos.offset);
  2615. advance(pos, 1);
  2616. } else {
  2617. result2 = null;
  2618. if (reportFailures === 0) {
  2619. matchFailed("[.]");
  2620. }
  2621. }
  2622. }
  2623. if (result1 !== null) {
  2624. result0 = [result0, result1];
  2625. } else {
  2626. result0 = null;
  2627. pos = clone(pos1);
  2628. }
  2629. } else {
  2630. result0 = null;
  2631. pos = clone(pos1);
  2632. }
  2633. if (result0 !== null) {
  2634. result0 = (function(offset, line, column, ret) {return [ret];})(pos0.offset, pos0.line, pos0.column, result0[0]);
  2635. }
  2636. if (result0 === null) {
  2637. pos = clone(pos0);
  2638. }
  2639. if (result0 === null) {
  2640. pos0 = clone(pos);
  2641. pos1 = clone(pos);
  2642. result0 = parse_expressions();
  2643. if (result0 !== null) {
  2644. result1 = parse_ws();
  2645. if (result1 !== null) {
  2646. if (/^[.]/.test(input.charAt(pos.offset))) {
  2647. result3 = input.charAt(pos.offset);
  2648. advance(pos, 1);
  2649. } else {
  2650. result3 = null;
  2651. if (reportFailures === 0) {
  2652. matchFailed("[.]");
  2653. }
  2654. }
  2655. if (result3 !== null) {
  2656. result2 = [];
  2657. while (result3 !== null) {
  2658. result2.push(result3);
  2659. if (/^[.]/.test(input.charAt(pos.offset))) {
  2660. result3 = input.charAt(pos.offset);
  2661. advance(pos, 1);
  2662. } else {
  2663. result3 = null;
  2664. if (reportFailures === 0) {
  2665. matchFailed("[.]");
  2666. }
  2667. }
  2668. }
  2669. } else {
  2670. result2 = null;
  2671. }
  2672. if (result2 !== null) {
  2673. result3 = parse_ws();
  2674. if (result3 !== null) {
  2675. result4 = parse_ret();
  2676. if (result4 !== null) {
  2677. result5 = [];
  2678. if (/^[.]/.test(input.charAt(pos.offset))) {
  2679. result6 = input.charAt(pos.offset);
  2680. advance(pos, 1);
  2681. } else {
  2682. result6 = null;
  2683. if (reportFailures === 0) {
  2684. matchFailed("[.]");
  2685. }
  2686. }
  2687. while (result6 !== null) {
  2688. result5.push(result6);
  2689. if (/^[.]/.test(input.charAt(pos.offset))) {
  2690. result6 = input.charAt(pos.offset);
  2691. advance(pos, 1);
  2692. } else {
  2693. result6 = null;
  2694. if (reportFailures === 0) {
  2695. matchFailed("[.]");
  2696. }
  2697. }
  2698. }
  2699. if (result5 !== null) {
  2700. result0 = [result0, result1, result2, result3, result4, result5];
  2701. } else {
  2702. result0 = null;
  2703. pos = clone(pos1);
  2704. }
  2705. } else {
  2706. result0 = null;
  2707. pos = clone(pos1);
  2708. }
  2709. } else {
  2710. result0 = null;
  2711. pos = clone(pos1);
  2712. }
  2713. } else {
  2714. result0 = null;
  2715. pos = clone(pos1);
  2716. }
  2717. } else {
  2718. result0 = null;
  2719. pos = clone(pos1);
  2720. }
  2721. } else {
  2722. result0 = null;
  2723. pos = clone(pos1);
  2724. }
  2725. if (result0 !== null) {
  2726. result0 = (function(offset, line, column, exps, ret) {
  2727. var expressions = exps;
  2728. expressions.push(ret);
  2729. return expressions;
  2730. })(pos0.offset, pos0.line, pos0.column, result0[0], result0[4]);
  2731. }
  2732. if (result0 === null) {
  2733. pos = clone(pos0);
  2734. }
  2735. if (result0 === null) {
  2736. pos0 = clone(pos);
  2737. pos1 = clone(pos);
  2738. result0 = parse_expressions();
  2739. result0 = result0 !== null ? result0 : "";
  2740. if (result0 !== null) {
  2741. result1 = [];
  2742. if (/^[.]/.test(input.charAt(pos.offset))) {
  2743. result2 = input.charAt(pos.offset);
  2744. advance(pos, 1);
  2745. } else {
  2746. result2 = null;
  2747. if (reportFailures === 0) {
  2748. matchFailed("[.]");
  2749. }
  2750. }
  2751. while (result2 !== null) {
  2752. result1.push(result2);
  2753. if (/^[.]/.test(input.charAt(pos.offset))) {
  2754. result2 = input.charAt(pos.offset);
  2755. advance(pos, 1);
  2756. } else {
  2757. result2 = null;
  2758. if (reportFailures === 0) {
  2759. matchFailed("[.]");
  2760. }
  2761. }
  2762. }
  2763. if (result1 !== null) {
  2764. result0 = [result0, result1];
  2765. } else {
  2766. result0 = null;
  2767. pos = clone(pos1);
  2768. }
  2769. } else {
  2770. result0 = null;
  2771. pos = clone(pos1);
  2772. }
  2773. if (result0 !== null) {
  2774. result0 = (function(offset, line, column, expressions) {
  2775. return expressions || [];
  2776. })(pos0.offset, pos0.line, pos0.column, result0[0]);
  2777. }
  2778. if (result0 === null) {
  2779. pos = clone(pos0);
  2780. }
  2781. }
  2782. }
  2783. cache[cacheKey] = {
  2784. nextPos: clone(pos),
  2785. result: result0
  2786. };
  2787. return result0;
  2788. }
  2789. function parse_sequence() {
  2790. var cacheKey = "sequence@" + pos.offset;
  2791. var cachedResult = cache[cacheKey];
  2792. if (cachedResult) {
  2793. pos = clone(cachedResult.nextPos);
  2794. return cachedResult.result;
  2795. }
  2796. var result0;
  2797. result0 = parse_jsStatement();
  2798. if (result0 === null) {
  2799. result0 = parse_stSequence();
  2800. }
  2801. cache[cacheKey] = {
  2802. nextPos: clone(pos),
  2803. result: result0
  2804. };
  2805. return result0;
  2806. }
  2807. function parse_stSequence() {
  2808. var cacheKey = "stSequence@" + pos.offset;
  2809. var cachedResult = cache[cacheKey];
  2810. if (cachedResult) {
  2811. pos = clone(cachedResult.nextPos);
  2812. return cachedResult.result;
  2813. }
  2814. var result0, result1, result2, result3;
  2815. var pos0, pos1;
  2816. pos0 = clone(pos);
  2817. pos1 = clone(pos);
  2818. result0 = parse_temps();
  2819. result0 = result0 !== null ? result0 : "";
  2820. if (result0 !== null) {
  2821. result1 = parse_ws();
  2822. if (result1 !== null) {
  2823. result2 = parse_statements();
  2824. result2 = result2 !== null ? result2 : "";
  2825. if (result2 !== null) {
  2826. result3 = parse_ws();
  2827. if (result3 !== null) {
  2828. result0 = [result0, result1, result2, result3];
  2829. } else {
  2830. result0 = null;
  2831. pos = clone(pos1);
  2832. }
  2833. } else {
  2834. result0 = null;
  2835. pos = clone(pos1);
  2836. }
  2837. } else {
  2838. result0 = null;
  2839. pos = clone(pos1);
  2840. }
  2841. } else {
  2842. result0 = null;
  2843. pos = clone(pos1);
  2844. }
  2845. if (result0 !== null) {
  2846. result0 = (function(offset, line, column, temps, statements) {
  2847. return smalltalk.SequenceNode._new()
  2848. ._position_((line).__at(column))
  2849. ._temps_(temps || [])
  2850. ._nodes_(statements || []);
  2851. })(pos0.offset, pos0.line, pos0.column, result0[0], result0[2]);
  2852. }
  2853. if (result0 === null) {
  2854. pos = clone(pos0);
  2855. }
  2856. cache[cacheKey] = {
  2857. nextPos: clone(pos),
  2858. result: result0
  2859. };
  2860. return result0;
  2861. }
  2862. function parse_block() {
  2863. var cacheKey = "block@" + pos.offset;
  2864. var cachedResult = cache[cacheKey];
  2865. if (cachedResult) {
  2866. pos = clone(cachedResult.nextPos);
  2867. return cachedResult.result;
  2868. }
  2869. var result0, result1, result2, result3, result4, result5, result6;
  2870. var pos0, pos1;
  2871. pos0 = clone(pos);
  2872. pos1 = clone(pos);
  2873. if (input.charCodeAt(pos.offset) === 91) {
  2874. result0 = "[";
  2875. advance(pos, 1);
  2876. } else {
  2877. result0 = null;
  2878. if (reportFailures === 0) {
  2879. matchFailed("\"[\"");
  2880. }
  2881. }
  2882. if (result0 !== null) {
  2883. result1 = parse_ws();
  2884. if (result1 !== null) {
  2885. result2 = parse_blockParamList();
  2886. result2 = result2 !== null ? result2 : "";
  2887. if (result2 !== null) {
  2888. result3 = parse_ws();
  2889. if (result3 !== null) {
  2890. result4 = parse_sequence();
  2891. result4 = result4 !== null ? result4 : "";
  2892. if (result4 !== null) {
  2893. result5 = parse_ws();
  2894. if (result5 !== null) {
  2895. if (input.charCodeAt(pos.offset) === 93) {
  2896. result6 = "]";
  2897. advance(pos, 1);
  2898. } else {
  2899. result6 = null;
  2900. if (reportFailures === 0) {
  2901. matchFailed("\"]\"");
  2902. }
  2903. }
  2904. if (result6 !== null) {
  2905. result0 = [result0, result1, result2, result3, result4, result5, result6];
  2906. } else {
  2907. result0 = null;
  2908. pos = clone(pos1);
  2909. }
  2910. } else {
  2911. result0 = null;
  2912. pos = clone(pos1);
  2913. }
  2914. } else {
  2915. result0 = null;
  2916. pos = clone(pos1);
  2917. }
  2918. } else {
  2919. result0 = null;
  2920. pos = clone(pos1);
  2921. }
  2922. } else {
  2923. result0 = null;
  2924. pos = clone(pos1);
  2925. }
  2926. } else {
  2927. result0 = null;
  2928. pos = clone(pos1);
  2929. }
  2930. } else {
  2931. result0 = null;
  2932. pos = clone(pos1);
  2933. }
  2934. if (result0 !== null) {
  2935. result0 = (function(offset, line, column, params, sequence) {
  2936. return smalltalk.BlockNode._new()
  2937. ._position_((line).__at(column))
  2938. ._parameters_(params || [])
  2939. ._nodes_([sequence._asBlockSequenceNode()]);
  2940. })(pos0.offset, pos0.line, pos0.column, result0[2], result0[4]);
  2941. }
  2942. if (result0 === null) {
  2943. pos = clone(pos0);
  2944. }
  2945. cache[cacheKey] = {
  2946. nextPos: clone(pos),
  2947. result: result0
  2948. };
  2949. return result0;
  2950. }
  2951. function parse_operand() {
  2952. var cacheKey = "operand@" + pos.offset;
  2953. var cachedResult = cache[cacheKey];
  2954. if (cachedResult) {
  2955. pos = clone(cachedResult.nextPos);
  2956. return cachedResult.result;
  2957. }
  2958. var result0;
  2959. result0 = parse_literal();
  2960. if (result0 === null) {
  2961. result0 = parse_variable();
  2962. if (result0 === null) {
  2963. result0 = parse_subexpression();
  2964. }
  2965. }
  2966. cache[cacheKey] = {
  2967. nextPos: clone(pos),
  2968. result: result0
  2969. };
  2970. return result0;
  2971. }
  2972. function parse_unaryMessage() {
  2973. var cacheKey = "unaryMessage@" + pos.offset;
  2974. var cachedResult = cache[cacheKey];
  2975. if (cachedResult) {
  2976. pos = clone(cachedResult.nextPos);
  2977. return cachedResult.result;
  2978. }
  2979. var result0, result1, result2;
  2980. var pos0, pos1, pos2;
  2981. pos0 = clone(pos);
  2982. pos1 = clone(pos);
  2983. result0 = parse_ws();
  2984. if (result0 !== null) {
  2985. result1 = parse_identifier();
  2986. if (result1 !== null) {
  2987. pos2 = clone(pos);
  2988. reportFailures++;
  2989. if (/^[:]/.test(input.charAt(pos.offset))) {
  2990. result2 = input.charAt(pos.offset);
  2991. advance(pos, 1);
  2992. } else {
  2993. result2 = null;
  2994. if (reportFailures === 0) {
  2995. matchFailed("[:]");
  2996. }
  2997. }
  2998. reportFailures--;
  2999. if (result2 === null) {
  3000. result2 = "";
  3001. } else {
  3002. result2 = null;
  3003. pos = clone(pos2);
  3004. }
  3005. if (result2 !== null) {
  3006. result0 = [result0, result1, result2];
  3007. } else {
  3008. result0 = null;
  3009. pos = clone(pos1);
  3010. }
  3011. } else {
  3012. result0 = null;
  3013. pos = clone(pos1);
  3014. }
  3015. } else {
  3016. result0 = null;
  3017. pos = clone(pos1);
  3018. }
  3019. if (result0 !== null) {
  3020. result0 = (function(offset, line, column, selector) {
  3021. return smalltalk.SendNode._new()
  3022. ._position_((line).__at(column))
  3023. ._selector_(selector);
  3024. })(pos0.offset, pos0.line, pos0.column, result0[1]);
  3025. }
  3026. if (result0 === null) {
  3027. pos = clone(pos0);
  3028. }
  3029. cache[cacheKey] = {
  3030. nextPos: clone(pos),
  3031. result: result0
  3032. };
  3033. return result0;
  3034. }
  3035. function parse_unaryTail() {
  3036. var cacheKey = "unaryTail@" + pos.offset;
  3037. var cachedResult = cache[cacheKey];
  3038. if (cachedResult) {
  3039. pos = clone(cachedResult.nextPos);
  3040. return cachedResult.result;
  3041. }
  3042. var result0, result1, result2, result3;
  3043. var pos0, pos1;
  3044. pos0 = clone(pos);
  3045. pos1 = clone(pos);
  3046. result0 = parse_unaryMessage();
  3047. if (result0 !== null) {
  3048. result1 = parse_ws();
  3049. if (result1 !== null) {
  3050. result2 = parse_unaryTail();
  3051. result2 = result2 !== null ? result2 : "";
  3052. if (result2 !== null) {
  3053. result3 = parse_ws();
  3054. if (result3 !== null) {
  3055. result0 = [result0, result1, result2, result3];
  3056. } else {
  3057. result0 = null;
  3058. pos = clone(pos1);
  3059. }
  3060. } else {
  3061. result0 = null;
  3062. pos = clone(pos1);
  3063. }
  3064. } else {
  3065. result0 = null;
  3066. pos = clone(pos1);
  3067. }
  3068. } else {
  3069. result0 = null;
  3070. pos = clone(pos1);
  3071. }
  3072. if (result0 !== null) {
  3073. result0 = (function(offset, line, column, message, tail) {
  3074. if(tail) {
  3075. return tail._valueForReceiver_(message);
  3076. }
  3077. else {
  3078. return message;
  3079. }
  3080. })(pos0.offset, pos0.line, pos0.column, result0[0], result0[2]);
  3081. }
  3082. if (result0 === null) {
  3083. pos = clone(pos0);
  3084. }
  3085. cache[cacheKey] = {
  3086. nextPos: clone(pos),
  3087. result: result0
  3088. };
  3089. return result0;
  3090. }
  3091. function parse_unarySend() {
  3092. var cacheKey = "unarySend@" + pos.offset;
  3093. var cachedResult = cache[cacheKey];
  3094. if (cachedResult) {
  3095. pos = clone(cachedResult.nextPos);
  3096. return cachedResult.result;
  3097. }
  3098. var result0, result1, result2;
  3099. var pos0, pos1;
  3100. pos0 = clone(pos);
  3101. pos1 = clone(pos);
  3102. result0 = parse_operand();
  3103. if (result0 !== null) {
  3104. result1 = parse_ws();
  3105. if (result1 !== null) {
  3106. result2 = parse_unaryTail();
  3107. result2 = result2 !== null ? result2 : "";
  3108. if (result2 !== null) {
  3109. result0 = [result0, result1, result2];
  3110. } else {
  3111. result0 = null;
  3112. pos = clone(pos1);
  3113. }
  3114. } else {
  3115. result0 = null;
  3116. pos = clone(pos1);
  3117. }
  3118. } else {
  3119. result0 = null;
  3120. pos = clone(pos1);
  3121. }
  3122. if (result0 !== null) {
  3123. result0 = (function(offset, line, column, receiver, tail) {
  3124. if(tail) {
  3125. return tail._valueForReceiver_(receiver);
  3126. }
  3127. else {
  3128. return receiver;
  3129. }
  3130. })(pos0.offset, pos0.line, pos0.column, result0[0], result0[2]);
  3131. }
  3132. if (result0 === null) {
  3133. pos = clone(pos0);
  3134. }
  3135. cache[cacheKey] = {
  3136. nextPos: clone(pos),
  3137. result: result0
  3138. };
  3139. return result0;
  3140. }
  3141. function parse_binaryMessage() {
  3142. var cacheKey = "binaryMessage@" + pos.offset;
  3143. var cachedResult = cache[cacheKey];
  3144. if (cachedResult) {
  3145. pos = clone(cachedResult.nextPos);
  3146. return cachedResult.result;
  3147. }
  3148. var result0, result1, result2, result3;
  3149. var pos0, pos1;
  3150. pos0 = clone(pos);
  3151. pos1 = clone(pos);
  3152. result0 = parse_ws();
  3153. if (result0 !== null) {
  3154. result1 = parse_binarySelector();
  3155. if (result1 !== null) {
  3156. result2 = parse_ws();
  3157. if (result2 !== null) {
  3158. result3 = parse_unarySend();
  3159. if (result3 === null) {
  3160. result3 = parse_operand();
  3161. }
  3162. if (result3 !== null) {
  3163. result0 = [result0, result1, result2, result3];
  3164. } else {
  3165. result0 = null;
  3166. pos = clone(pos1);
  3167. }
  3168. } else {
  3169. result0 = null;
  3170. pos = clone(pos1);
  3171. }
  3172. } else {
  3173. result0 = null;
  3174. pos = clone(pos1);
  3175. }
  3176. } else {
  3177. result0 = null;
  3178. pos = clone(pos1);
  3179. }
  3180. if (result0 !== null) {
  3181. result0 = (function(offset, line, column, selector, arg) {
  3182. return smalltalk.SendNode._new()
  3183. ._position_((line).__at(column))
  3184. ._selector_(selector)
  3185. ._arguments_([arg]);
  3186. })(pos0.offset, pos0.line, pos0.column, result0[1], result0[3]);
  3187. }
  3188. if (result0 === null) {
  3189. pos = clone(pos0);
  3190. }
  3191. cache[cacheKey] = {
  3192. nextPos: clone(pos),
  3193. result: result0
  3194. };
  3195. return result0;
  3196. }
  3197. function parse_binaryTail() {
  3198. var cacheKey = "binaryTail@" + pos.offset;
  3199. var cachedResult = cache[cacheKey];
  3200. if (cachedResult) {
  3201. pos = clone(cachedResult.nextPos);
  3202. return cachedResult.result;
  3203. }
  3204. var result0, result1;
  3205. var pos0, pos1;
  3206. pos0 = clone(pos);
  3207. pos1 = clone(pos);
  3208. result0 = parse_binaryMessage();
  3209. if (result0 !== null) {
  3210. result1 = parse_binaryTail();
  3211. result1 = result1 !== null ? result1 : "";
  3212. if (result1 !== null) {
  3213. result0 = [result0, result1];
  3214. } else {
  3215. result0 = null;
  3216. pos = clone(pos1);
  3217. }
  3218. } else {
  3219. result0 = null;
  3220. pos = clone(pos1);
  3221. }
  3222. if (result0 !== null) {
  3223. result0 = (function(offset, line, column, message, tail) {
  3224. if(tail) {
  3225. return tail._valueForReceiver_(message);
  3226. }
  3227. else {
  3228. return message;
  3229. }
  3230. })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
  3231. }
  3232. if (result0 === null) {
  3233. pos = clone(pos0);
  3234. }
  3235. cache[cacheKey] = {
  3236. nextPos: clone(pos),
  3237. result: result0
  3238. };
  3239. return result0;
  3240. }
  3241. function parse_binarySend() {
  3242. var cacheKey = "binarySend@" + pos.offset;
  3243. var cachedResult = cache[cacheKey];
  3244. if (cachedResult) {
  3245. pos = clone(cachedResult.nextPos);
  3246. return cachedResult.result;
  3247. }
  3248. var result0, result1;
  3249. var pos0, pos1;
  3250. pos0 = clone(pos);
  3251. pos1 = clone(pos);
  3252. result0 = parse_unarySend();
  3253. if (result0 !== null) {
  3254. result1 = parse_binaryTail();
  3255. result1 = result1 !== null ? result1 : "";
  3256. if (result1 !== null) {
  3257. result0 = [result0, result1];
  3258. } else {
  3259. result0 = null;
  3260. pos = clone(pos1);
  3261. }
  3262. } else {
  3263. result0 = null;
  3264. pos = clone(pos1);
  3265. }
  3266. if (result0 !== null) {
  3267. result0 = (function(offset, line, column, receiver, tail) {
  3268. if(tail) {
  3269. return tail._valueForReceiver_(receiver);
  3270. }
  3271. else {
  3272. return receiver;
  3273. }
  3274. })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
  3275. }
  3276. if (result0 === null) {
  3277. pos = clone(pos0);
  3278. }
  3279. cache[cacheKey] = {
  3280. nextPos: clone(pos),
  3281. result: result0
  3282. };
  3283. return result0;
  3284. }
  3285. function parse_keywordMessage() {
  3286. var cacheKey = "keywordMessage@" + pos.offset;
  3287. var cachedResult = cache[cacheKey];
  3288. if (cachedResult) {
  3289. pos = clone(cachedResult.nextPos);
  3290. return cachedResult.result;
  3291. }
  3292. var result0, result1, result2, result3;
  3293. var pos0, pos1, pos2, pos3;
  3294. pos0 = clone(pos);
  3295. pos1 = clone(pos);
  3296. result0 = parse_ws();
  3297. if (result0 !== null) {
  3298. pos2 = clone(pos);
  3299. pos3 = clone(pos);
  3300. result2 = parse_keywordPair();
  3301. if (result2 !== null) {
  3302. result3 = parse_ws();
  3303. if (result3 !== null) {
  3304. result2 = [result2, result3];
  3305. } else {
  3306. result2 = null;
  3307. pos = clone(pos3);
  3308. }
  3309. } else {
  3310. result2 = null;
  3311. pos = clone(pos3);
  3312. }
  3313. if (result2 !== null) {
  3314. result2 = (function(offset, line, column, pair) {return pair;})(pos2.offset, pos2.line, pos2.column, result2[0]);
  3315. }
  3316. if (result2 === null) {
  3317. pos = clone(pos2);
  3318. }
  3319. if (result2 !== null) {
  3320. result1 = [];
  3321. while (result2 !== null) {
  3322. result1.push(result2);
  3323. pos2 = clone(pos);
  3324. pos3 = clone(pos);
  3325. result2 = parse_keywordPair();
  3326. if (result2 !== null) {
  3327. result3 = parse_ws();
  3328. if (result3 !== null) {
  3329. result2 = [result2, result3];
  3330. } else {
  3331. result2 = null;
  3332. pos = clone(pos3);
  3333. }
  3334. } else {
  3335. result2 = null;
  3336. pos = clone(pos3);
  3337. }
  3338. if (result2 !== null) {
  3339. result2 = (function(offset, line, column, pair) {return pair;})(pos2.offset, pos2.line, pos2.column, result2[0]);
  3340. }
  3341. if (result2 === null) {
  3342. pos = clone(pos2);
  3343. }
  3344. }
  3345. } else {
  3346. result1 = null;
  3347. }
  3348. if (result1 !== null) {
  3349. result0 = [result0, result1];
  3350. } else {
  3351. result0 = null;
  3352. pos = clone(pos1);
  3353. }
  3354. } else {
  3355. result0 = null;
  3356. pos = clone(pos1);
  3357. }
  3358. if (result0 !== null) {
  3359. result0 = (function(offset, line, column, pairs) {
  3360. var selector = [];
  3361. var args = [];
  3362. for(var i = 0; i < pairs.length; i++) {
  3363. selector.push(pairs[i].key);
  3364. args.push(pairs[i].arg);
  3365. }
  3366. return smalltalk.SendNode._new()
  3367. ._position_((line).__at(column))
  3368. ._selector_(selector.join(""))
  3369. ._arguments_(args);
  3370. })(pos0.offset, pos0.line, pos0.column, result0[1]);
  3371. }
  3372. if (result0 === null) {
  3373. pos = clone(pos0);
  3374. }
  3375. cache[cacheKey] = {
  3376. nextPos: clone(pos),
  3377. result: result0
  3378. };
  3379. return result0;
  3380. }
  3381. function parse_keywordSend() {
  3382. var cacheKey = "keywordSend@" + pos.offset;
  3383. var cachedResult = cache[cacheKey];
  3384. if (cachedResult) {
  3385. pos = clone(cachedResult.nextPos);
  3386. return cachedResult.result;
  3387. }
  3388. var result0, result1;
  3389. var pos0, pos1;
  3390. pos0 = clone(pos);
  3391. pos1 = clone(pos);
  3392. result0 = parse_binarySend();
  3393. if (result0 !== null) {
  3394. result1 = parse_keywordMessage();
  3395. if (result1 !== null) {
  3396. result0 = [result0, result1];
  3397. } else {
  3398. result0 = null;
  3399. pos = clone(pos1);
  3400. }
  3401. } else {
  3402. result0 = null;
  3403. pos = clone(pos1);
  3404. }
  3405. if (result0 !== null) {
  3406. result0 = (function(offset, line, column, receiver, tail) {
  3407. return tail._valueForReceiver_(receiver);
  3408. })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
  3409. }
  3410. if (result0 === null) {
  3411. pos = clone(pos0);
  3412. }
  3413. cache[cacheKey] = {
  3414. nextPos: clone(pos),
  3415. result: result0
  3416. };
  3417. return result0;
  3418. }
  3419. function parse_message() {
  3420. var cacheKey = "message@" + pos.offset;
  3421. var cachedResult = cache[cacheKey];
  3422. if (cachedResult) {
  3423. pos = clone(cachedResult.nextPos);
  3424. return cachedResult.result;
  3425. }
  3426. var result0;
  3427. result0 = parse_binaryMessage();
  3428. if (result0 === null) {
  3429. result0 = parse_unaryMessage();
  3430. if (result0 === null) {
  3431. result0 = parse_keywordMessage();
  3432. }
  3433. }
  3434. cache[cacheKey] = {
  3435. nextPos: clone(pos),
  3436. result: result0
  3437. };
  3438. return result0;
  3439. }
  3440. function parse_cascade() {
  3441. var cacheKey = "cascade@" + pos.offset;
  3442. var cachedResult = cache[cacheKey];
  3443. if (cachedResult) {
  3444. pos = clone(cachedResult.nextPos);
  3445. return cachedResult.result;
  3446. }
  3447. var result0, result1, result2, result3, result4, result5, result6, result7;
  3448. var pos0, pos1, pos2, pos3;
  3449. pos0 = clone(pos);
  3450. pos1 = clone(pos);
  3451. result0 = parse_ws();
  3452. if (result0 !== null) {
  3453. result1 = parse_keywordSend();
  3454. if (result1 === null) {
  3455. result1 = parse_binarySend();
  3456. }
  3457. if (result1 !== null) {
  3458. pos2 = clone(pos);
  3459. pos3 = clone(pos);
  3460. result3 = parse_ws();
  3461. if (result3 !== null) {
  3462. if (input.charCodeAt(pos.offset) === 59) {
  3463. result4 = ";";
  3464. advance(pos, 1);
  3465. } else {
  3466. result4 = null;
  3467. if (reportFailures === 0) {
  3468. matchFailed("\";\"");
  3469. }
  3470. }
  3471. if (result4 !== null) {
  3472. result5 = parse_ws();
  3473. if (result5 !== null) {
  3474. result6 = parse_message();
  3475. if (result6 !== null) {
  3476. result7 = parse_ws();
  3477. if (result7 !== null) {
  3478. result3 = [result3, result4, result5, result6, result7];
  3479. } else {
  3480. result3 = null;
  3481. pos = clone(pos3);
  3482. }
  3483. } else {
  3484. result3 = null;
  3485. pos = clone(pos3);
  3486. }
  3487. } else {
  3488. result3 = null;
  3489. pos = clone(pos3);
  3490. }
  3491. } else {
  3492. result3 = null;
  3493. pos = clone(pos3);
  3494. }
  3495. } else {
  3496. result3 = null;
  3497. pos = clone(pos3);
  3498. }
  3499. if (result3 !== null) {
  3500. result3 = (function(offset, line, column, mess) {return mess;})(pos2.offset, pos2.line, pos2.column, result3[3]);
  3501. }
  3502. if (result3 === null) {
  3503. pos = clone(pos2);
  3504. }
  3505. if (result3 !== null) {
  3506. result2 = [];
  3507. while (result3 !== null) {
  3508. result2.push(result3);
  3509. pos2 = clone(pos);
  3510. pos3 = clone(pos);
  3511. result3 = parse_ws();
  3512. if (result3 !== null) {
  3513. if (input.charCodeAt(pos.offset) === 59) {
  3514. result4 = ";";
  3515. advance(pos, 1);
  3516. } else {
  3517. result4 = null;
  3518. if (reportFailures === 0) {
  3519. matchFailed("\";\"");
  3520. }
  3521. }
  3522. if (result4 !== null) {
  3523. result5 = parse_ws();
  3524. if (result5 !== null) {
  3525. result6 = parse_message();
  3526. if (result6 !== null) {
  3527. result7 = parse_ws();
  3528. if (result7 !== null) {
  3529. result3 = [result3, result4, result5, result6, result7];
  3530. } else {
  3531. result3 = null;
  3532. pos = clone(pos3);
  3533. }
  3534. } else {
  3535. result3 = null;
  3536. pos = clone(pos3);
  3537. }
  3538. } else {
  3539. result3 = null;
  3540. pos = clone(pos3);
  3541. }
  3542. } else {
  3543. result3 = null;
  3544. pos = clone(pos3);
  3545. }
  3546. } else {
  3547. result3 = null;
  3548. pos = clone(pos3);
  3549. }
  3550. if (result3 !== null) {
  3551. result3 = (function(offset, line, column, mess) {return mess;})(pos2.offset, pos2.line, pos2.column, result3[3]);
  3552. }
  3553. if (result3 === null) {
  3554. pos = clone(pos2);
  3555. }
  3556. }
  3557. } else {
  3558. result2 = null;
  3559. }
  3560. if (result2 !== null) {
  3561. result0 = [result0, result1, result2];
  3562. } else {
  3563. result0 = null;
  3564. pos = clone(pos1);
  3565. }
  3566. } else {
  3567. result0 = null;
  3568. pos = clone(pos1);
  3569. }
  3570. } else {
  3571. result0 = null;
  3572. pos = clone(pos1);
  3573. }
  3574. if (result0 !== null) {
  3575. result0 = (function(offset, line, column, send, messages) {
  3576. var cascade = [];
  3577. cascade.push(send);
  3578. for(var i = 0; i < messages.length; i++) {
  3579. cascade.push(messages[i]);
  3580. }
  3581. return smalltalk.CascadeNode._new()
  3582. ._position_((line).__at(column))
  3583. ._receiver_(send._receiver())
  3584. ._nodes_(cascade);
  3585. })(pos0.offset, pos0.line, pos0.column, result0[1], result0[2]);
  3586. }
  3587. if (result0 === null) {
  3588. pos = clone(pos0);
  3589. }
  3590. cache[cacheKey] = {
  3591. nextPos: clone(pos),
  3592. result: result0
  3593. };
  3594. return result0;
  3595. }
  3596. function parse_jsStatement() {
  3597. var cacheKey = "jsStatement@" + pos.offset;
  3598. var cachedResult = cache[cacheKey];
  3599. if (cachedResult) {
  3600. pos = clone(cachedResult.nextPos);
  3601. return cachedResult.result;
  3602. }
  3603. var result0, result1, result2;
  3604. var pos0, pos1, pos2;
  3605. pos0 = clone(pos);
  3606. pos1 = clone(pos);
  3607. if (input.charCodeAt(pos.offset) === 60) {
  3608. result0 = "<";
  3609. advance(pos, 1);
  3610. } else {
  3611. result0 = null;
  3612. if (reportFailures === 0) {
  3613. matchFailed("\"<\"");
  3614. }
  3615. }
  3616. if (result0 !== null) {
  3617. result1 = [];
  3618. pos2 = clone(pos);
  3619. if (input.substr(pos.offset, 2) === ">>") {
  3620. result2 = ">>";
  3621. advance(pos, 2);
  3622. } else {
  3623. result2 = null;
  3624. if (reportFailures === 0) {
  3625. matchFailed("\">>\"");
  3626. }
  3627. }
  3628. if (result2 !== null) {
  3629. result2 = (function(offset, line, column) {return ">";})(pos2.offset, pos2.line, pos2.column);
  3630. }
  3631. if (result2 === null) {
  3632. pos = clone(pos2);
  3633. }
  3634. if (result2 === null) {
  3635. if (/^[^>]/.test(input.charAt(pos.offset))) {
  3636. result2 = input.charAt(pos.offset);
  3637. advance(pos, 1);
  3638. } else {
  3639. result2 = null;
  3640. if (reportFailures === 0) {
  3641. matchFailed("[^>]");
  3642. }
  3643. }
  3644. }
  3645. while (result2 !== null) {
  3646. result1.push(result2);
  3647. pos2 = clone(pos);
  3648. if (input.substr(pos.offset, 2) === ">>") {
  3649. result2 = ">>";
  3650. advance(pos, 2);
  3651. } else {
  3652. result2 = null;
  3653. if (reportFailures === 0) {
  3654. matchFailed("\">>\"");
  3655. }
  3656. }
  3657. if (result2 !== null) {
  3658. result2 = (function(offset, line, column) {return ">";})(pos2.offset, pos2.line, pos2.column);
  3659. }
  3660. if (result2 === null) {
  3661. pos = clone(pos2);
  3662. }
  3663. if (result2 === null) {
  3664. if (/^[^>]/.test(input.charAt(pos.offset))) {
  3665. result2 = input.charAt(pos.offset);
  3666. advance(pos, 1);
  3667. } else {
  3668. result2 = null;
  3669. if (reportFailures === 0) {
  3670. matchFailed("[^>]");
  3671. }
  3672. }
  3673. }
  3674. }
  3675. if (result1 !== null) {
  3676. if (input.charCodeAt(pos.offset) === 62) {
  3677. result2 = ">";
  3678. advance(pos, 1);
  3679. } else {
  3680. result2 = null;
  3681. if (reportFailures === 0) {
  3682. matchFailed("\">\"");
  3683. }
  3684. }
  3685. if (result2 !== null) {
  3686. result0 = [result0, result1, result2];
  3687. } else {
  3688. result0 = null;
  3689. pos = clone(pos1);
  3690. }
  3691. } else {
  3692. result0 = null;
  3693. pos = clone(pos1);
  3694. }
  3695. } else {
  3696. result0 = null;
  3697. pos = clone(pos1);
  3698. }
  3699. if (result0 !== null) {
  3700. result0 = (function(offset, line, column, val) {
  3701. return smalltalk.JSStatementNode._new()
  3702. ._position_((line).__at(column))
  3703. ._source_(val.join(""));
  3704. })(pos0.offset, pos0.line, pos0.column, result0[1]);
  3705. }
  3706. if (result0 === null) {
  3707. pos = clone(pos0);
  3708. }
  3709. cache[cacheKey] = {
  3710. nextPos: clone(pos),
  3711. result: result0
  3712. };
  3713. return result0;
  3714. }
  3715. function parse_method() {
  3716. var cacheKey = "method@" + pos.offset;
  3717. var cachedResult = cache[cacheKey];
  3718. if (cachedResult) {
  3719. pos = clone(cachedResult.nextPos);
  3720. return cachedResult.result;
  3721. }
  3722. var result0, result1, result2, result3, result4;
  3723. var pos0, pos1;
  3724. pos0 = clone(pos);
  3725. pos1 = clone(pos);
  3726. result0 = parse_ws();
  3727. if (result0 !== null) {
  3728. result1 = parse_keywordPattern();
  3729. if (result1 === null) {
  3730. result1 = parse_binaryPattern();
  3731. if (result1 === null) {
  3732. result1 = parse_unaryPattern();
  3733. }
  3734. }
  3735. if (result1 !== null) {
  3736. result2 = parse_ws();
  3737. if (result2 !== null) {
  3738. result3 = parse_sequence();
  3739. result3 = result3 !== null ? result3 : "";
  3740. if (result3 !== null) {
  3741. result4 = parse_ws();
  3742. if (result4 !== null) {
  3743. result0 = [result0, result1, result2, result3, result4];
  3744. } else {
  3745. result0 = null;
  3746. pos = clone(pos1);
  3747. }
  3748. } else {
  3749. result0 = null;
  3750. pos = clone(pos1);
  3751. }
  3752. } else {
  3753. result0 = null;
  3754. pos = clone(pos1);
  3755. }
  3756. } else {
  3757. result0 = null;
  3758. pos = clone(pos1);
  3759. }
  3760. } else {
  3761. result0 = null;
  3762. pos = clone(pos1);
  3763. }
  3764. if (result0 !== null) {
  3765. result0 = (function(offset, line, column, pattern, sequence) {
  3766. return smalltalk.MethodNode._new()
  3767. ._position_((line).__at(column))
  3768. ._selector_(pattern[0])
  3769. ._arguments_(pattern[1])
  3770. ._nodes_([sequence]);
  3771. })(pos0.offset, pos0.line, pos0.column, result0[1], result0[3]);
  3772. }
  3773. if (result0 === null) {
  3774. pos = clone(pos0);
  3775. }
  3776. cache[cacheKey] = {
  3777. nextPos: clone(pos),
  3778. result: result0
  3779. };
  3780. return result0;
  3781. }
  3782. function cleanupExpected(expected) {
  3783. expected.sort();
  3784. var lastExpected = null;
  3785. var cleanExpected = [];
  3786. for (var i = 0; i < expected.length; i++) {
  3787. if (expected[i] !== lastExpected) {
  3788. cleanExpected.push(expected[i]);
  3789. lastExpected = expected[i];
  3790. }
  3791. }
  3792. return cleanExpected;
  3793. }
  3794. var result = parseFunctions[startRule]();
  3795. /*
  3796. * The parser is now in one of the following three states:
  3797. *
  3798. * 1. The parser successfully parsed the whole input.
  3799. *
  3800. * - |result !== null|
  3801. * - |pos.offset === input.length|
  3802. * - |rightmostFailuresExpected| may or may not contain something
  3803. *
  3804. * 2. The parser successfully parsed only a part of the input.
  3805. *
  3806. * - |result !== null|
  3807. * - |pos.offset < input.length|
  3808. * - |rightmostFailuresExpected| may or may not contain something
  3809. *
  3810. * 3. The parser did not successfully parse any part of the input.
  3811. *
  3812. * - |result === null|
  3813. * - |pos.offset === 0|
  3814. * - |rightmostFailuresExpected| contains at least one failure
  3815. *
  3816. * All code following this comment (including called functions) must
  3817. * handle these states.
  3818. */
  3819. if (result === null || pos.offset !== input.length) {
  3820. var offset = Math.max(pos.offset, rightmostFailuresPos.offset);
  3821. var found = offset < input.length ? input.charAt(offset) : null;
  3822. var errorPosition = pos.offset > rightmostFailuresPos.offset ? pos : rightmostFailuresPos;
  3823. throw new this.SyntaxError(
  3824. cleanupExpected(rightmostFailuresExpected),
  3825. found,
  3826. offset,
  3827. errorPosition.line,
  3828. errorPosition.column
  3829. );
  3830. }
  3831. return result;
  3832. },
  3833. /* Returns the parser source code. */
  3834. toSource: function() { return this._source; }
  3835. };
  3836. /* Thrown when a parser encounters a syntax error. */
  3837. result.SyntaxError = function(expected, found, offset, line, column) {
  3838. function buildMessage(expected, found) {
  3839. var expectedHumanized, foundHumanized;
  3840. switch (expected.length) {
  3841. case 0:
  3842. expectedHumanized = "end of input";
  3843. break;
  3844. case 1:
  3845. expectedHumanized = expected[0];
  3846. break;
  3847. default:
  3848. expectedHumanized = expected.slice(0, expected.length - 1).join(", ")
  3849. + " or "
  3850. + expected[expected.length - 1];
  3851. }
  3852. foundHumanized = found ? quote(found) : "end of input";
  3853. return "Expected " + expectedHumanized + " but " + foundHumanized + " found.";
  3854. }
  3855. this.name = "SyntaxError";
  3856. this.expected = expected;
  3857. this.found = found;
  3858. this.message = buildMessage(expected, found);
  3859. this.offset = offset;
  3860. this.line = line;
  3861. this.column = column;
  3862. };
  3863. result.SyntaxError.prototype = Error.prototype;
  3864. return result;
  3865. })();
  3866. });