2
0

parser.js 94 KB

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