From d0d6aae1e56428f597f69f5c9cfb261afe671f5d Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Fri, 23 Feb 2024 16:46:10 -0700 Subject: [PATCH] initial parser --- .gitignore | 175 ++ .prettierrc | 18 + README.md | 2 + bun.lockb | Bin 0 -> 16198 bytes package.json | 18 + src/args.ts | 11 + src/index.ts | 63 + src/interpreter/index.ts | 1 + src/parser/generate.ts | 17 + src/parser/grammar.pegjs | 364 +++ src/parser/index.ts | 6 + src/parser/parser.ts | 5235 ++++++++++++++++++++++++++++++++++++++ src/utils/exception.ts | 1 + src/utils/index.ts | 2 + src/utils/logger.ts | 51 + tsconfig.json | 27 + 16 files changed, 5991 insertions(+) create mode 100644 .gitignore create mode 100644 .prettierrc create mode 100644 README.md create mode 100755 bun.lockb create mode 100644 package.json create mode 100644 src/args.ts create mode 100644 src/index.ts create mode 100644 src/interpreter/index.ts create mode 100644 src/parser/generate.ts create mode 100644 src/parser/grammar.pegjs create mode 100644 src/parser/index.ts create mode 100644 src/parser/parser.ts create mode 100644 src/utils/exception.ts create mode 100644 src/utils/index.ts create mode 100644 src/utils/logger.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..468f82a --- /dev/null +++ b/.gitignore @@ -0,0 +1,175 @@ +# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore + +# Logs + +logs +_.log +npm-debug.log_ +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Caches + +.cache + +# Diagnostic reports (https://nodejs.org/api/report.html) + +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# Runtime data + +pids +_.pid +_.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover + +lib-cov + +# Coverage directory used by tools like istanbul + +coverage +*.lcov + +# nyc test coverage + +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) + +.grunt + +# Bower dependency directory (https://bower.io/) + +bower_components + +# node-waf configuration + +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) + +build/Release + +# Dependency directories + +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) + +web_modules/ + +# TypeScript cache + +*.tsbuildinfo + +# Optional npm cache directory + +.npm + +# Optional eslint cache + +.eslintcache + +# Optional stylelint cache + +.stylelintcache + +# Microbundle cache + +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history + +.node_repl_history + +# Output of 'npm pack' + +*.tgz + +# Yarn Integrity file + +.yarn-integrity + +# dotenv environment variable files + +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) + +.parcel-cache + +# Next.js build output + +.next +out + +# Nuxt.js build / generate output + +.nuxt +dist + +# Gatsby files + +# Comment in the public line in if your project uses Gatsby and not Next.js + +# https://nextjs.org/blog/next-9-1#public-directory-support + +# public + +# vuepress build output + +.vuepress/dist + +# vuepress v2.x temp and cache directory + +.temp + +# Docusaurus cache and generated files + +.docusaurus + +# Serverless directories + +.serverless/ + +# FuseBox cache + +.fusebox/ + +# DynamoDB Local files + +.dynamodb/ + +# TernJS port file + +.tern-port + +# Stores VSCode versions used for testing VSCode extensions + +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..cd5e62a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,18 @@ +{ + "arrowParens": "avoid", + "bracketSpacing": true, + "htmlWhitespaceSensitivity": "css", + "insertPragma": false, + "jsxBracketSameLine": false, + "jsxSingleQuote": true, + "printWidth": 80, + "proseWrap": "always", + "quoteProps": "as-needed", + "requirePragma": false, + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "all", + "useTabs": false, + "plugins": ["prettier-plugin-pegjs"] +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..2d6ca62 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +An interpreter for the CPS intermediate representation as +suggested in "Compiling with Continuations" by Appel. diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..a815dc1d005e1ec773f0d72dc7d5ec073354a022 GIT binary patch literal 16198 zcmeHO2|QHY`yU#T7A<;J>W#DzGsBQlwn`f*RH|1*3?|HIW<-)ylHRl-ifC7_+zyJFAe>$JfopbLw=lMR%Irp6BoO!O6CMQ5F;>_X; zI6T2zjadN#Ww=hHv57a;*-_)e2YSa8?~jS!(T- zWVmv`aGk56&j!`|`E@>Q4viq`N;8Ji4|$mE`RhR04V9@d7-14I%b({pTMR#5^Psc< zE>$SchP;im-cKm<_ueDNV041#M94crJ`Kb|dOsfzzQ~`!mp zK9tE|D8q9YvN^?p2&7mv$eaG<^|JoCjYFJIv-MzEq3 zr#F96 z$M)~JMfu-2s(GQ8E5_|a`o{I_I7H=Hr{gC5YLZY+%4yGA!|yW zM(y60%PjQs>OHgP9^bU5w|u3GeNB!3^t>8{jd!ZGr`lh$b$)&RzJbN|ej!Ub_4vo{ zRN}NJ_7|qOR(<`r#;rDAwM;R);7M<@H~9w(I}Y+@PUB84R!luTkTdpEos;V8w<(=B z%13*yNsh=Fx$AR>l)!M$$Lxs#gOro*mxs50V3?ri>taMiCJ8H7U zI=vai?QF08mH9$vS!3`h|)*xi@PoHfU z*3a8C`wD+kzc4-BrMy`%?EX^;-y%#_a1DX}g5kixvgYCv`beOGVHpO)n@Xfy_V~+; zw7UTb>W&Gf>t-dwXE_iee|$#% zE!DpO=&}Eh78AjhKK=Taw37pYQGV<{OfBVa1N2rvPxNjn{dyoI<3}n%^L~l^SAZV% zN50qxE#p^x;5{_Qz-B-%|PWfga}% zB71Y^P{O}6biARA9{iaW^B)EDs6UaL*x}cjOKS-K`9MF4rau`+&805_dP|!AP0^8h z!e1Q>HkwA?(*AP;dbB^mYpMMEfgaaiq{qI)t2v4AdjbRwH2$Q#DGbtXGB|6Pi>@81!iA0(qk*!ao@3asEPD z97D~0e~=04iWkx#U&JK+K+mxp_D)p79Q&I1YxEp#fIbxFWE^6Svf(}jan#|$ggLfD zdtu&7mj4MkCVGzbz2U-K11?M&a3NkFxUgIcE=-tXc|W+Yygyu+ewJf9ZK_t9V|yLh zGv-*YD|@Er*iKJY&xRbIIdGBm+phl|cKxFA1r7aQoa7i%Tsky!{r-#PiP`akVuMnx z^i^IS+@}~2@hFr#_6AF@WcIRuI>sD-+OgfE)%}hh-M1?2Pu*u8VQDk|u56Q+P&MF@ z->n(9Kt_U#V~8Z?rYy~j{--v3b~+I!S@9+-YpTlrRP(^=ukLT;mL2YW@iS-Tx$z3N ztYOdByX)SJ3!5lnx)!g<=NQEGs>yh}{!|J85nTFv&P+LHAaU1^kLhlBEvu_n^1ZQo zowjPt{-f)|c4syzaLl_VYnpytom#k4x8t9ahu9C8b8HDuc;0$}Tjb2v57XMtUPHsB z&*RJsOEk)_S4C{F^3yzY_HatkCuQw>5!vBuEnaTxbXz}W_=Fx))c5SR&W>8bGn^jn zJ4TYoe-i1uVD)*2ESu`UifkG#&H*Gb2X+u#;SYNIT4{dd-gP4^dU*&FOHY>C--$}= zd?hlVIAwmdVRy#3HEnHL506Z{*-hTk(R!xYOoM58HR4sl1K(@}AYuna0tz{E&$98V z=ci_D51dgl=G=+uufhJVB}3m@KD;`Px49sJKT_Fj)QN)Ke3#Oi+XY?K_ty;79-Y+j zV%+%D0}rem%roj~xb$^^=@9aD+PtL7wFze{d?btGRwVf+P5I--WLCxrmF?XYg)KXf zbZN5X(t11YtNn?W<904O?|&d-c<_{zD+gBU^1Zk?wuroR|AHyZ*>%%0)+A!a#+mOm z%=%?dTE3#TeBmFNr{3py)b~hmbx1La8!@){j8pL4I7J)xK4UI#JO1comRWK_?gK&5 z=hrk`SjHO?^JAw0nuC+XC-XCwe9oD3zMVra|IE3$;`et7SLj7O%(J_7!!Yk!l~eAr zx9*b`f98~Ii=WdgaQBuv&r`X^<|mWuXt?zChmr6bR(wzj81{8Z*FB$h>pir$oJzxmWvd}E zUHp}DRsJ-5CjV?l+p~MwBlNnahg7Y&5$M$O`t83Q$GZ-C>vFhsd@n(MPt_gwbcWyj ztLXTKRa-euttWO3SJm5xYZb9CS+@|Jc_%#CuDXkXOHO!&<%Y~E-Kd1!6RKBfJ`$>q z^msm|WJhk@fcX0vmiz^bP3n@YUQubWd?#iP3;BMUnr)UYH37e}0k=H@$`W(Sf;~s% z>`r{Wm}b%cMQGWhopai^%FtuX|I8l0sbkXkl8VaYMTh!yP5(M>M1B`PqtusME^j}k z)GL!`SGw=?-OOQtL*ymvDnc{c6&>%S#&nu}%**}h2luHt?QcJdh#fmEf7sf+{db;< z&(u18g{`_R+cSN?{|e^|cYEbK7!P)Gy=ypDlCoyvOWnr!_Z6n zve!-fyn05sncw@~Yrn**>Ub2qi#Z?q;zW4~4Hx%5Br$hAH&c5u-of=S>r9er9reJ(4ru3i<;ezng6bAU5-#nEDmw@lP~$uNU=P{MNuPUB7zV;IOKrl4X8ge;4FdK99&6XHi-CDI_?n zPlnOxFJ-RjN%x}qYo_jHoE&@8^dJqFepbYMV7E1N?9lnAUauSIoH^8mHECe3hSgM~ z>WulPtjz0fJooa-Z=YvtbnleS1BtS!iS@e^`;C)V@;oOiI-YTknv+b!C4Lhn@9VVd zom;hWS{#yj_PPZ}#AH-zjAJCH^qH3bIe+w=gZ1mYCR8s|SSI#$uX|Ma zvh?HoqFygNveM^O__i(c@+;W*{_P$^EfcG^x@&yv_?+q6Xt;kgpn`o*KXdTWJbO3A zwaa10h-o=H{OZC>i{lHnnkEpd44ftJsQUi<*K(;FW#uV*P7c|ci(}EC;gT= z4GTRK+G+VSxmMdBkNv~4Iyr6JnC|=IgQ~XBaJ$iQH@k*T>h3!IT*v5k+AqDB>aA0@ z82H_G=kX)he4d1Wdu|Il==i@`nV@}hrB z67yi!k$0x7(+t@Bv}g9KnEA(hnECu==YO}9=@=%TU!Z0(Zq-M{vm-xU$_&WL-MrUf zW`Ff8*V^IP)khbmClq)W#laKdrT^EC^aPT%DiurHbpFIq6w#bzA1^O8`W0(f=lid3@gy z#eJ_6*Pa^Tw^DoH`}6)US6+NE;Y63E9iK!eEzvCx$liLn&Y&huSZp%XNLz5$HDFk9 zg0-hvQDF*OU+rT#01;gJ{)hS4rR(|Fkf($CmKtrfT5ynJSNm4(pO)>YKQip^d>L2#KF1=khu+;-&V_{+cU-RJ&V4+W0eqaNGab;_?f zt{H4r_!fW&F4<=wHgojYiRMX%(l+N?s?c`|3&Z_P$9((Xo2kjS$CdLBWIKTZ}@A&0UP)$2|En((P z)AXknc`;>UCnij})IC=&=S*(?MH;Rq9ry05IG@s0ZAbs9l721pO+;DQlEN-=qw51= zp5GqWC2f|t+pWm0%IjT|9`){Py43m39uJKHM-B*|jR~{M@mXqd`W_9p4;}Z#$IG`S zMSu8sOiT0X;wul^?GLK0s`A4jGx0@HjJI=E__r z9mP$v;yxX^WJ90N$bJvunf>jehCSIL8KInNKPP5uZ^tlIM{mRG)5D4^?!TKW*)w?8 zLCwc@>n0TU<>ZF1pFU4v1}8EkJzDeq{XCnlp3j4~)8y?-mp4?!Tc^COwN`DVyF?%VZKD3=M0D!H($kakk0us4E+2e3XG_Aon-|`v^xU8m<$u@| z*LKoxxF02nX{ccPm!nquVG~w{PK-2v`Zzkn;o#&?k2U<`A4H{f@}6ro{+4_H)SEt~ zW^*r@)~RgzaEF&y6MX$~=(#?-Y=Wp)m*A3pEn+io>4l9cT(qX5EL&~)>;Roa1&Z?WrXdMeoi>-F~c;e8kpu zx8drw)xN6@N_MW@7(QNcW)2OP?6(n~c|tjn6+Zs*@+#*Tg>2)K`@c>*W8d$|w5ssa zw+DEd<=e#8Oo-7rU8_Ara+hzmIq<{{xlf;UT%5C&4vr|wa18UN;gWqjg?rqiv;Eof zxafhGd(WKZZ5*SulvKVPt+n4~GG)uu9h#8`&pK^Z>bxXk zq1o~I%x?D%(&vYP2q;U;9RVBn?Hzxm%F^Z^+Y-4vrgKc;?q$PlgS;lZbvPNi-Kp%T zD)@SzI`DQUW!|~6R;69Q&8c%{$fbMy&7HUT@&G3S^h1t&L<#=mJzI=tS=9f%SVsQy z4Uv^W_P>%)7V^LPK6n7%C+vSkkl##OWC3an$>Iw(!^;hOf}i#qy`2?oB*Dl3X}g~> zr)Xud8vm2ylqnO2sWB%-V4vi@hltnrg%n-=ecH`;^bKr&)_qTZVgXc8(-wEo5Hi?w!Vub=gYDy=R8Eu4eBM;=Q0hb(H$P0Bu zol#%Z8+oD5s1x!-zNl|oxKLM=8+Ae5P)F1obw=G$Z`2X>A$p@OL{Fq8I-#y83!Xcm zuE-nhiREZ(%!6b)nsea+lCr52*Vs8=2#grxhCVd-e#D?0Aa@vvEA1%fGKj6u)|X0w zH6#*MN#55@!V^niFD8rqC9$gVaxMmJE*rLvWXDLNTA{{Bibmp!NgOQH7y`{8sYYO( zFcK*XHC&(p9Y`!Ti5;fUxNHO9BimKb(11Tm05nv5Hi;(&8iOH}2tUdOni@*^WP=T$ z-@-@?F4BMrzz79U1HBeTqLt<4^nnc+he6`LNu090T&O-}b#E{uye3f(;>8B;uSzNFyI$1J)ri=Ojj&qM>R? z6gr8TmeGJhBp#f^FUx447f56|iG-$TxF{QmMJKV-P%{W*0~!*oPNJ(R8n8CR3c-tm zql(07Lk*4)BL;&+z>|n=sFC$g7|>w~V!Bm$kP;bJe47=99S4mDgr zgTeEY_eW-H67Nsq(_vf>Vsnk5gMRjwNXPZB-xBgw0EuFkm%|~-h4=JdWeWw_3=G(Y z24@eUFU0ig}_e?l`5EQ2W$w8eBzmVdu|ig|u>c_Q|xAPG+-aPyrc5%C3H<{Ady zCdDBQlcGfIP9f#jtL_lRu2IDgQm{<4rJ{Lkfj^Y8g(5EyUD}+(YPe+? z;he*kcm<1WLW{b$82YPLmYjo>xN0U!_Jl%Z6%%6$;#i9z518 z^u<_#B0h9hBgp^KmJ;p8+?BW{W;Lh*9X7(V)?s?cmjzZ-(4hZ zO5|^iD1#CTm;-Pj0EYg27~Dv15YJ%P~Zb%W52aFn?;Qb{Rd?0G|(s=OcxmNiZOm}bS zAoOxdFzHMw^^b7Ar2H7!j*#u%xGy7XM#rc2p-l)W^Tv=HkYdJ?x~uRD!#Ds2t~;Ma ziPVU}>CFI!{s?a~c-fT68v*#<6~kA#sVS$yBLaR6_sw%WsPz}!OxaQlx74s|szbkd zu0V+&aijk*7|nzaP1&fSjf|LTPeE{{GlsO^0~_;tWfBC60V7b%l5QU;0Vr=?>cKZ+ aW{L&ng#*C12k0YQs6i2_Z~uSq_dfvD-wU|_ literal 0 HcmV?d00001 diff --git a/package.json b/package.json new file mode 100644 index 0000000..163631d --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "cps-interpreter", + "module": "index.ts", + "type": "module", + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "dependencies": { + "minimist": "^1.2.8", + "peggy": "^4.0.0", + "prettier": "^3.2.5", + "prettier-plugin-pegjs": "^2.0.2", + "ts-pegjs": "^4.2.1" + } +} \ No newline at end of file diff --git a/src/args.ts b/src/args.ts new file mode 100644 index 0000000..c5f66fc --- /dev/null +++ b/src/args.ts @@ -0,0 +1,11 @@ +const argv = require('minimist')(process.argv.slice(2)); + +export type Args = { + devMode: boolean; + repl: boolean; +}; + +export const args: Args = { + repl: argv.repl ?? false, + devMode: argv.dev ?? false, +}; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..29047f2 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,63 @@ +import { args, type Args } from '@/args'; +import { join } from 'path'; +import { watch } from 'fs/promises'; +import { generateParser, GRAMMAR_FILE, GENERATED_PARSER } from '@/parser'; +import { + ConsoleTracingLogger, + type LogLevel, + type TracingLogger, +} from '@/utils'; +import { evaluate } from '@/interpreter'; + +const LOG_LEVELS: LogLevel[] = ['info', 'warn', 'error']; + +const devMode = async (logger: TracingLogger) => { + logger.info('Watching for changes in parser...'); + + const watcher = watch(import.meta.dir, { recursive: true }); + for await (const event of watcher) { + if (event.filename?.endsWith(GRAMMAR_FILE)) { + const grammarFile = join(import.meta.dir, event.filename); + const outputFile = join( + import.meta.dir, + event.filename.replace(GRAMMAR_FILE, GENERATED_PARSER), + ); + logger.info( + `Generating parser at Location=(${grammarFile}) to Source=(${outputFile})...`, + ); + generateParser(grammarFile, outputFile); + } + } +}; + +const doRepl = async (prompt = '~> ') => { + process.stdout.write(prompt); + + for await (const line of console) { + const result = await evaluate(line); + console.log(result); + break; + } + + await doRepl(prompt); +}; + +export const main = async (args: Args) => { + if (args.devMode) { + LOG_LEVELS.push('debug'); + } + + const logger = new ConsoleTracingLogger('main', LOG_LEVELS); + + if (args.devMode) { + logger.info('Starting in dev mode...'); + await devMode(logger); + } + + if (args.repl) { + logger.info('Starting REPL...'); + logger.info('Welcome to the CPS interpreter!'); + } +}; + +main(args); diff --git a/src/interpreter/index.ts b/src/interpreter/index.ts new file mode 100644 index 0000000..4178c19 --- /dev/null +++ b/src/interpreter/index.ts @@ -0,0 +1 @@ +export const evaluate = async (ast: Program) => {}; diff --git a/src/parser/generate.ts b/src/parser/generate.ts new file mode 100644 index 0000000..977077a --- /dev/null +++ b/src/parser/generate.ts @@ -0,0 +1,17 @@ +import peggy from 'peggy'; +const tspegjs: any = require('ts-pegjs'); + +export const GRAMMAR_FILE = 'grammar.pegjs'; +export const GENERATED_PARSER = 'parser.ts'; + +export const generateParser = async (file: string, output: string) => { + const grammar = await Bun.file(file).text(); + + const parserSrc = peggy.generate(grammar, { + format: 'commonjs', + plugins: [tspegjs], + output: 'source', + }); + + await Bun.write(output, parserSrc); +}; diff --git a/src/parser/grammar.pegjs b/src/parser/grammar.pegjs new file mode 100644 index 0000000..b375608 --- /dev/null +++ b/src/parser/grammar.pegjs @@ -0,0 +1,364 @@ +Program + = exprs:(ContinuationExpression / _)* { + return exprs.filter(x => !Array.isArray(x)); + } + +ContinuationExpression + = RecordExpression + / SelectExpression + / OffsetExpression + / ApplicationExpression + / FixExpression + / SwitchExpression + / PrimitiveOperationExpression + +SelectExpression + = SELECT + _? + LPAREN + _? + select:Integer + _? + COMMA + _? + val:Value + _? + COMMA + _? + bind:Identifier + _? + continuation:ContinuationExpression + _? + RPAREN { return { select, val, bind, continuation }; } + +OffsetExpression + = OFFSET + _? + LPAREN + _? + offset:Integer + _? + COMMA + _? + val:Value + _? + COMMA + _? + bind:Identifier + _? + continuation:ContinuationExpression + _? + RPAREN { return { offset, val, bind, continuation }; } + +IdentifierList + = LBRACKET + _? + identifiers:(ident:Identifier _? COMMA _?)* + _? + lastIdent:Identifier? + _? + RBRACKET { + return identifiers.length || lastIdent + ? [...identifiers.map(x => x.ident), lastIdent] + : []; + } + +ValueList + = LBRACKET + _? + values:(value:Value _? COMMA _?)* + _? + lastValue:Value? + _? + RBRACKET { + return values.length || lastValue + ? [...values.map(x => x.value), lastValue] + : []; + } + +SwitchExpression + = SWITCH + _? + LPAREN + _? + switchIndex:Value + _? + COMMA + _? + continuations:ContinuationList + _? + RPAREN { return { switchIndex, continuations }; } + +ApplicationExpression + = APP _? LPAREN _? fn:Value _? COMMA _? args:ValueList _? RPAREN { + return { fn, args }; + } + +FixBinding + = LPAREN + _? + fn:Identifier + _? + COMMA + _? + args:IdentifierList + _? + COMMA + _? + continuation:ContinuationExpression + _? + RPAREN + +FixBindingList + = LBRACKET + _ + bindings:(binding:FixBinding _? COMMA _?)* + _? + lastBinding:FixBinding? + _? + RBRACKET { + return bindings.length || lastBinding + ? [...bindings.map(x => x.binding), lastBinding] + : []; + } + +FixExpression + = FIX + _? + LPAREN + _? + fixBindings:FixBindingList + _? + COMMA + _? + continuation:ContinuationExpression + _? + RPAREN { return { fixBindings, continuation }; } + +ContinuationList + = LBRACKET + _? + continuations:(continuation:ContinuationExpression _? COMMA _?)* + _? + lastContinuation:ContinuationExpression? + _? + RBRACKET { + return lastContinuation || continuations.length + ? [...continuations.map(x => x.continuation), lastContinuation] + : []; + } + +PrimitiveOperationExpression + = PRIMOP + _? + LPAREN + _? + opr:PrimitiveOperation + _? + COMMA + _? + operands:ValueList + _? + COMMA + _? + resultBindings:IdentifierList + _? + COMMA + _? + continuations:ContinuationList + _? + RPAREN { return { opr, operands, resultBindings, continuations }; } + +RecordExpressionTuple + = LPAREN + _? + variable:VarStatement + _? + COMMA + _? + offset:OffsetStatement + _? + RPAREN { return { variable, offset }; } + +RecordExpressionTupleList + = LBRACKET + _? + records:(record:RecordExpressionTuple _? COMMA _?)* + _? + lastRecord:RecordExpressionTuple? + _? + RBRACKET { + return records.length || lastRecord + ? [...records.map(x => x.record), lastRecord] + : []; + } + +RecordExpression + = RECORD + _? + LPAREN + _? + records:RecordExpressionTupleList + _? + COMMA + _? + address:Literal + _? + COMMA + _? + body:ContinuationExpression + _? + RPAREN { + return { + records, + address, + body, + }; + } + +Value + = VarStatement + / LabelStatement + / IntStatement + / RealStatement + / StringStatement + +VarStatement = VAR _ ident:Identifier { return ident; } + +LabelStatement = LABEL _ ident:Identifier { return ident; } + +IntStatement = INT _ int:Integer { return int; } + +RealStatement = REAL _ real:Real { return real; } + +StringStatement = STRING _ string:QuotedString { return string; } + +AccessStatement + = OffsetStatement + / SelectStatement + +OffsetStatement = OFFP _ offset:Integer { return offset; } + +SelectStatement = SELP _ offset:Integer { return offset; } + +Identifier + = name:([A-Za-z] (LETTER / DIGIT / SAFE_SYMBOL)*) { + return { name: name[0] + name[1].join('') }; + } + +PrimitiveOperation + = ArithmeticOperation + / ComparisonOperation + / BitOperation + / StoreOperation + +StoreOperation + = STORE + / UPDATE + / MAKEREF + / MAKEREFUNBOXED + / UNBOXED_UPDATE + / BOXED + / SUBSCRIPT + +ArithmeticOperation + = "+" + / "-" + / "/" + / "*" + / "**" + +BitOperation + = ">>" + / "<<" + / "~" + / "^" + +ComparisonOperation + = "==" + / "<=" + / ">=" + / "!=" + / "!" + / ">" + / "<" + +Integer = digits:[0-9]+ !"." { return parseInt(digits.join(''), 10); } + +QuotedString + = "'" content:[^']* "'" { return content.join(''); } + / "\"" content:[^"]* "\"" { return content.join(''); } + +Real + = value:("-"? [0-9]+ "." [0-9]+) { + return parseFloat( + value.map(x => (Array.isArray(x) ? x.join('') : x)).join(''), + ); + } + +Literal + = Real + / QuotedString + / Integer + +OFFSET = "OFFSET" + +OFFP = "OFFp" + +SELP = "SELp" + +VAR = "VAR" + +INT = "INT" + +REAL = "REAL" + +STRING = "STRING" + +APP = "APP" + +RECORD = "RECORD" + +SELECT = "SELECT" + +FIX = "FIX" + +SWITCH = "SWITCH" + +PRIMOP = "PRIMOP" + +LABEL = "LABEL" + +STORE = "store" + +UPDATE = "update" + +MAKEREF = "makeref" + +MAKEREFUNBOXED = "makerefunboxed" + +UNBOXED_UPDATE = "unboxedupdate" + +SUBSCRIPT = "subscript" + +BOXED = "boxed" + +LETTER = [A-Za-z] + +SAFE_SYMBOL = "_" + +DIGIT = [0-9] + +LBRACKET = "[" + +RBRACKET = "]" + +COMMA = "," + +EQUALS = "=" + +LPAREN = "(" + +RPAREN = ")" + +_ = (" " / "\n" / "\t" / "\r\n")+ diff --git a/src/parser/index.ts b/src/parser/index.ts new file mode 100644 index 0000000..7831c8e --- /dev/null +++ b/src/parser/index.ts @@ -0,0 +1,6 @@ +export * from './generate'; +export * from './parser'; +import * as peggy from './parser'; + +export const peggyParse = (source: string): peggy.FunctionDefinition[] => + peggy.parse(source); diff --git a/src/parser/parser.ts b/src/parser/parser.ts new file mode 100644 index 0000000..6e09c0d --- /dev/null +++ b/src/parser/parser.ts @@ -0,0 +1,5235 @@ +/* eslint-disable */ + + + +const peggyParser: {parse: any, SyntaxError: any, DefaultTracer?: any} = // @generated by Peggy 4.0.0. +// +// https://peggyjs.org/ +// @ts-ignore +(function() { +// @ts-ignore + "use strict"; + +// @ts-ignore +function peg$subclass(child, parent) { +// @ts-ignore + function C() { this.constructor = child; } +// @ts-ignore + C.prototype = parent.prototype; +// @ts-ignore + child.prototype = new C(); +} + +// @ts-ignore +function peg$SyntaxError(message, expected, found, location) { +// @ts-ignore + var self = Error.call(this, message); + // istanbul ignore next Check is a necessary evil to support older environments +// @ts-ignore + if (Object.setPrototypeOf) { +// @ts-ignore + Object.setPrototypeOf(self, peg$SyntaxError.prototype); + } +// @ts-ignore + self.expected = expected; +// @ts-ignore + self.found = found; +// @ts-ignore + self.location = location; +// @ts-ignore + self.name = "SyntaxError"; +// @ts-ignore + return self; +} + +// @ts-ignore +peg$subclass(peg$SyntaxError, Error); + +// @ts-ignore +function peg$padEnd(str, targetLength, padString) { +// @ts-ignore + padString = padString || " "; +// @ts-ignore + if (str.length > targetLength) { return str; } +// @ts-ignore + targetLength -= str.length; +// @ts-ignore + padString += padString.repeat(targetLength); +// @ts-ignore + return str + padString.slice(0, targetLength); +} + +// @ts-ignore +peg$SyntaxError.prototype.format = function(sources) { +// @ts-ignore + var str = "Error: " + this.message; +// @ts-ignore + if (this.location) { +// @ts-ignore + var src = null; +// @ts-ignore + var k; +// @ts-ignore + for (k = 0; k < sources.length; k++) { +// @ts-ignore + if (sources[k].source === this.location.source) { +// @ts-ignore + src = sources[k].text.split(/\r\n|\n|\r/g); +// @ts-ignore + break; + } + } +// @ts-ignore + var s = this.location.start; +// @ts-ignore + var offset_s = (this.location.source && (typeof this.location.source.offset === "function")) +// @ts-ignore + ? this.location.source.offset(s) +// @ts-ignore + : s; +// @ts-ignore + var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; +// @ts-ignore + if (src) { +// @ts-ignore + var e = this.location.end; +// @ts-ignore + var filler = peg$padEnd("", offset_s.line.toString().length, ' '); +// @ts-ignore + var line = src[s.line - 1]; +// @ts-ignore + var last = s.line === e.line ? e.column : line.length + 1; +// @ts-ignore + var hatLen = (last - s.column) || 1; +// @ts-ignore + str += "\n --> " + loc + "\n" +// @ts-ignore + + filler + " |\n" +// @ts-ignore + + offset_s.line + " | " + line + "\n" +// @ts-ignore + + filler + " | " + peg$padEnd("", s.column - 1, ' ') +// @ts-ignore + + peg$padEnd("", hatLen, "^"); +// @ts-ignore + } else { +// @ts-ignore + str += "\n at " + loc; + } + } +// @ts-ignore + return str; +}; + +// @ts-ignore +peg$SyntaxError.buildMessage = function(expected, found) { +// @ts-ignore + var DESCRIBE_EXPECTATION_FNS = { +// @ts-ignore + literal: function(expectation) { +// @ts-ignore + return "\"" + literalEscape(expectation.text) + "\""; + }, + +// @ts-ignore + class: function(expectation) { +// @ts-ignore + var escapedParts = expectation.parts.map(function(part) { +// @ts-ignore + return Array.isArray(part) +// @ts-ignore + ? classEscape(part[0]) + "-" + classEscape(part[1]) +// @ts-ignore + : classEscape(part); + }); + +// @ts-ignore + return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"; + }, + +// @ts-ignore + any: function() { +// @ts-ignore + return "any character"; + }, + +// @ts-ignore + end: function() { +// @ts-ignore + return "end of input"; + }, + +// @ts-ignore + other: function(expectation) { +// @ts-ignore + return expectation.description; + } + }; + +// @ts-ignore + function hex(ch) { +// @ts-ignore + return ch.charCodeAt(0).toString(16).toUpperCase(); + } + +// @ts-ignore + function literalEscape(s) { +// @ts-ignore + return s +// @ts-ignore + .replace(/\\/g, "\\\\") +// @ts-ignore + .replace(/"/g, "\\\"") +// @ts-ignore + .replace(/\0/g, "\\0") +// @ts-ignore + .replace(/\t/g, "\\t") +// @ts-ignore + .replace(/\n/g, "\\n") +// @ts-ignore + .replace(/\r/g, "\\r") +// @ts-ignore + .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) +// @ts-ignore + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); + } + +// @ts-ignore + function classEscape(s) { +// @ts-ignore + return s +// @ts-ignore + .replace(/\\/g, "\\\\") +// @ts-ignore + .replace(/\]/g, "\\]") +// @ts-ignore + .replace(/\^/g, "\\^") +// @ts-ignore + .replace(/-/g, "\\-") +// @ts-ignore + .replace(/\0/g, "\\0") +// @ts-ignore + .replace(/\t/g, "\\t") +// @ts-ignore + .replace(/\n/g, "\\n") +// @ts-ignore + .replace(/\r/g, "\\r") +// @ts-ignore + .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) +// @ts-ignore + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); + } + +// @ts-ignore + function describeExpectation(expectation) { +// @ts-ignore + return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); + } + +// @ts-ignore + function describeExpected(expected) { +// @ts-ignore + var descriptions = expected.map(describeExpectation); +// @ts-ignore + var i, j; + +// @ts-ignore + descriptions.sort(); + +// @ts-ignore + if (descriptions.length > 0) { +// @ts-ignore + for (i = 1, j = 1; i < descriptions.length; i++) { +// @ts-ignore + if (descriptions[i - 1] !== descriptions[i]) { +// @ts-ignore + descriptions[j] = descriptions[i]; +// @ts-ignore + j++; + } + } +// @ts-ignore + descriptions.length = j; + } + +// @ts-ignore + switch (descriptions.length) { +// @ts-ignore + case 1: +// @ts-ignore + return descriptions[0]; + +// @ts-ignore + case 2: +// @ts-ignore + return descriptions[0] + " or " + descriptions[1]; + +// @ts-ignore + default: +// @ts-ignore + return descriptions.slice(0, -1).join(", ") +// @ts-ignore + + ", or " +// @ts-ignore + + descriptions[descriptions.length - 1]; + } + } + +// @ts-ignore + function describeFound(found) { +// @ts-ignore + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + } + +// @ts-ignore + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; +}; + +// @ts-ignore +function peg$parse(input, options) { +// @ts-ignore + options = options !== undefined ? options : {}; + +// @ts-ignore + var peg$FAILED = {}; +// @ts-ignore + var peg$source = options.grammarSource; + +// @ts-ignore + var peg$startRuleFunctions = { Program: peg$parseProgram }; +// @ts-ignore + var peg$startRuleFunction = peg$parseProgram; + +// @ts-ignore + var peg$c0 = "**"; + var peg$c1 = ">>"; + var peg$c2 = "<<"; + var peg$c3 = "=="; + var peg$c4 = "<="; + var peg$c5 = ">="; + var peg$c6 = "!="; + var peg$c7 = "."; + var peg$c8 = "'"; + var peg$c9 = "\""; + var peg$c10 = "-"; + var peg$c11 = "OFFSET"; + var peg$c12 = "OFFp"; + var peg$c13 = "SELp"; + var peg$c14 = "VAR"; + var peg$c15 = "INT"; + var peg$c16 = "REAL"; + var peg$c17 = "STRING"; + var peg$c18 = "APP"; + var peg$c19 = "RECORD"; + var peg$c20 = "SELECT"; + var peg$c21 = "FIX"; + var peg$c22 = "SWITCH"; + var peg$c23 = "PRIMOP"; + var peg$c24 = "LABEL"; + var peg$c25 = "store"; + var peg$c26 = "update"; + var peg$c27 = "makeref"; + var peg$c28 = "makerefunboxed"; + var peg$c29 = "unboxedupdate"; + var peg$c30 = "subscript"; + var peg$c31 = "boxed"; + var peg$c32 = "_"; + var peg$c33 = "["; + var peg$c34 = "]"; + var peg$c35 = ","; + var peg$c36 = "="; + var peg$c37 = "("; + var peg$c38 = ")"; + var peg$c39 = "\r\n"; + + var peg$r0 = /^[A-Za-z]/; + var peg$r1 = /^[0-9A-Z_a-z]/; + var peg$r2 = /^[*-+\-\/]/; + var peg$r3 = /^[\^~]/; + var peg$r4 = /^[!<>]/; + var peg$r5 = /^[0-9]/; + var peg$r6 = /^[^']/; + var peg$r7 = /^[^"]/; + var peg$r8 = /^[\t-\n ]/; + + var peg$e0 = peg$classExpectation([["A", "Z"], ["a", "z"]], false, false); + var peg$e1 = peg$classExpectation([["0", "9"], ["A", "Z"], "_", ["a", "z"]], false, false); + var peg$e2 = peg$classExpectation([["*", "+"], "-", "/"], false, false); + var peg$e3 = peg$literalExpectation("**", false); + var peg$e4 = peg$literalExpectation(">>", false); + var peg$e5 = peg$literalExpectation("<<", false); + var peg$e6 = peg$classExpectation(["^", "~"], false, false); + var peg$e7 = peg$literalExpectation("==", false); + var peg$e8 = peg$literalExpectation("<=", false); + var peg$e9 = peg$literalExpectation(">=", false); + var peg$e10 = peg$literalExpectation("!=", false); + var peg$e11 = peg$classExpectation(["!", "<", ">"], false, false); + var peg$e12 = peg$classExpectation([["0", "9"]], false, false); + var peg$e13 = peg$literalExpectation(".", false); + var peg$e14 = peg$literalExpectation("'", false); + var peg$e15 = peg$classExpectation(["'"], true, false); + var peg$e16 = peg$literalExpectation("\"", false); + var peg$e17 = peg$classExpectation(["\""], true, false); + var peg$e18 = peg$literalExpectation("-", false); + var peg$e19 = peg$literalExpectation("OFFSET", false); + var peg$e20 = peg$literalExpectation("OFFp", false); + var peg$e21 = peg$literalExpectation("SELp", false); + var peg$e22 = peg$literalExpectation("VAR", false); + var peg$e23 = peg$literalExpectation("INT", false); + var peg$e24 = peg$literalExpectation("REAL", false); + var peg$e25 = peg$literalExpectation("STRING", false); + var peg$e26 = peg$literalExpectation("APP", false); + var peg$e27 = peg$literalExpectation("RECORD", false); + var peg$e28 = peg$literalExpectation("SELECT", false); + var peg$e29 = peg$literalExpectation("FIX", false); + var peg$e30 = peg$literalExpectation("SWITCH", false); + var peg$e31 = peg$literalExpectation("PRIMOP", false); + var peg$e32 = peg$literalExpectation("LABEL", false); + var peg$e33 = peg$literalExpectation("store", false); + var peg$e34 = peg$literalExpectation("update", false); + var peg$e35 = peg$literalExpectation("makeref", false); + var peg$e36 = peg$literalExpectation("makerefunboxed", false); + var peg$e37 = peg$literalExpectation("unboxedupdate", false); + var peg$e38 = peg$literalExpectation("subscript", false); + var peg$e39 = peg$literalExpectation("boxed", false); + var peg$e40 = peg$literalExpectation("_", false); + var peg$e41 = peg$literalExpectation("[", false); + var peg$e42 = peg$literalExpectation("]", false); + var peg$e43 = peg$literalExpectation(",", false); + var peg$e44 = peg$literalExpectation("=", false); + var peg$e45 = peg$literalExpectation("(", false); + var peg$e46 = peg$literalExpectation(")", false); + var peg$e47 = peg$classExpectation([["\t", "\n"], " "], false, false); + var peg$e48 = peg$literalExpectation("\r\n", false); +// @ts-ignore + + var peg$f0 = function(exprs) { +// @ts-ignore + return exprs.filter(x => !Array.isArray(x)); + };// @ts-ignore + + var peg$f1 = function(select, val, bind, continuation) {// @ts-ignore + return { select, val, bind, continuation }; };// @ts-ignore + + var peg$f2 = function(offset, val, bind, continuation) {// @ts-ignore + return { offset, val, bind, continuation }; };// @ts-ignore + + var peg$f3 = function(identifiers, lastIdent) { +// @ts-ignore + return identifiers.length || lastIdent +// @ts-ignore + ? [...identifiers.map(x => x.ident), lastIdent] + : []; + };// @ts-ignore + + var peg$f4 = function(values, lastValue) { +// @ts-ignore + return values.length || lastValue +// @ts-ignore + ? [...values.map(x => x.value), lastValue] + : []; + };// @ts-ignore + + var peg$f5 = function(switchIndex, continuations) {// @ts-ignore + return { switchIndex, continuations }; };// @ts-ignore + + var peg$f6 = function(fn, args) { +// @ts-ignore + return { fn, args }; + };// @ts-ignore + + var peg$f7 = function(bindings, lastBinding) { +// @ts-ignore + return bindings.length || lastBinding +// @ts-ignore + ? [...bindings.map(x => x.binding), lastBinding] + : []; + };// @ts-ignore + + var peg$f8 = function(fixBindings, continuation) {// @ts-ignore + return { fixBindings, continuation }; };// @ts-ignore + + var peg$f9 = function(continuations, lastContinuation) { +// @ts-ignore + return lastContinuation || continuations.length +// @ts-ignore + ? [...continuations.map(x => x.continuation), lastContinuation] + : []; + };// @ts-ignore + + var peg$f10 = function(opr, operands, resultBindings, continuations) {// @ts-ignore + return { opr, operands, resultBindings, continuations }; };// @ts-ignore + + var peg$f11 = function(variable, offset) {// @ts-ignore + return { variable, offset }; };// @ts-ignore + + var peg$f12 = function(records, lastRecord) { +// @ts-ignore + return records.length || lastRecord +// @ts-ignore + ? [...records.map(x => x.record), lastRecord] + : []; + };// @ts-ignore + + var peg$f13 = function(records, address, body) { +// @ts-ignore + return { +// @ts-ignore + records, +// @ts-ignore + address, +// @ts-ignore + body, + }; + };// @ts-ignore + + var peg$f14 = function(ident) {// @ts-ignore + return ident; };// @ts-ignore + + var peg$f15 = function(ident) {// @ts-ignore + return ident; };// @ts-ignore + + var peg$f16 = function(int) {// @ts-ignore + return int; };// @ts-ignore + + var peg$f17 = function(real) {// @ts-ignore + return real; };// @ts-ignore + + var peg$f18 = function(string) {// @ts-ignore + return string; };// @ts-ignore + + var peg$f19 = function(offset) {// @ts-ignore + return offset; };// @ts-ignore + + var peg$f20 = function(offset) {// @ts-ignore + return offset; };// @ts-ignore + + var peg$f21 = function(name) { +// @ts-ignore + return { name: name[0] + name[1].join('') }; + };// @ts-ignore + + var peg$f22 = function(digits) {// @ts-ignore + return parseInt(digits.join(''), 10); };// @ts-ignore + + var peg$f23 = function(content) {// @ts-ignore + return content.join(''); };// @ts-ignore + + var peg$f24 = function(content) {// @ts-ignore + return content.join(''); };// @ts-ignore + + var peg$f25 = function(value) { +// @ts-ignore + return parseFloat( +// @ts-ignore + value.map(x => (Array.isArray(x) ? x.join('') : x)).join(''), + ); + }; +// @ts-ignore + var peg$currPos = options.peg$currPos | 0; +// @ts-ignore + var peg$savedPos = peg$currPos; +// @ts-ignore + var peg$posDetailsCache = [{ line: 1, column: 1 }]; +// @ts-ignore + var peg$maxFailPos = peg$currPos; +// @ts-ignore + var peg$maxFailExpected = options.peg$maxFailExpected || []; +// @ts-ignore + var peg$silentFails = options.peg$silentFails | 0; + +// @ts-ignore + var peg$result; + +// @ts-ignore + if (options.startRule) { +// @ts-ignore + if (!(options.startRule in peg$startRuleFunctions)) { +// @ts-ignore + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + } + +// @ts-ignore + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + +// @ts-ignore + function text() { +// @ts-ignore + return input.substring(peg$savedPos, peg$currPos); + } + +// @ts-ignore + function offset() { +// @ts-ignore + return peg$savedPos; + } + +// @ts-ignore + function range() { +// @ts-ignore + return { +// @ts-ignore + source: peg$source, +// @ts-ignore + start: peg$savedPos, +// @ts-ignore + end: peg$currPos + }; + } + +// @ts-ignore + function location() { +// @ts-ignore + return peg$computeLocation(peg$savedPos, peg$currPos); + } + +// @ts-ignore + function expected(description, location) { +// @ts-ignore + location = location !== undefined +// @ts-ignore + ? location +// @ts-ignore + : peg$computeLocation(peg$savedPos, peg$currPos); + +// @ts-ignore + throw peg$buildStructuredError( +// @ts-ignore + [peg$otherExpectation(description)], +// @ts-ignore + input.substring(peg$savedPos, peg$currPos), +// @ts-ignore + location + ); + } + +// @ts-ignore + function error(message, location) { +// @ts-ignore + location = location !== undefined +// @ts-ignore + ? location +// @ts-ignore + : peg$computeLocation(peg$savedPos, peg$currPos); + +// @ts-ignore + throw peg$buildSimpleError(message, location); + } + +// @ts-ignore + function peg$literalExpectation(text, ignoreCase) { +// @ts-ignore + return { type: "literal", text: text, ignoreCase: ignoreCase }; + } + +// @ts-ignore + function peg$classExpectation(parts, inverted, ignoreCase) { +// @ts-ignore + return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; + } + +// @ts-ignore + function peg$anyExpectation() { +// @ts-ignore + return { type: "any" }; + } + +// @ts-ignore + function peg$endExpectation() { +// @ts-ignore + return { type: "end" }; + } + +// @ts-ignore + function peg$otherExpectation(description) { +// @ts-ignore + return { type: "other", description: description }; + } + +// @ts-ignore + function peg$computePosDetails(pos) { +// @ts-ignore + var details = peg$posDetailsCache[pos]; +// @ts-ignore + var p; + +// @ts-ignore + if (details) { +// @ts-ignore + return details; +// @ts-ignore + } else { +// @ts-ignore + if (pos >= peg$posDetailsCache.length) { +// @ts-ignore + p = peg$posDetailsCache.length - 1; +// @ts-ignore + } else { +// @ts-ignore + p = pos; +// @ts-ignore + while (!peg$posDetailsCache[--p]) {} + } + +// @ts-ignore + details = peg$posDetailsCache[p]; +// @ts-ignore + details = { +// @ts-ignore + line: details.line, +// @ts-ignore + column: details.column + }; + +// @ts-ignore + while (p < pos) { +// @ts-ignore + if (input.charCodeAt(p) === 10) { +// @ts-ignore + details.line++; +// @ts-ignore + details.column = 1; +// @ts-ignore + } else { +// @ts-ignore + details.column++; + } + +// @ts-ignore + p++; + } + +// @ts-ignore + peg$posDetailsCache[pos] = details; + +// @ts-ignore + return details; + } + } + +// @ts-ignore + function peg$computeLocation(startPos, endPos, offset) { +// @ts-ignore + var startPosDetails = peg$computePosDetails(startPos); +// @ts-ignore + var endPosDetails = peg$computePosDetails(endPos); + +// @ts-ignore + var res = { +// @ts-ignore + source: peg$source, +// @ts-ignore + start: { +// @ts-ignore + offset: startPos, +// @ts-ignore + line: startPosDetails.line, +// @ts-ignore + column: startPosDetails.column + }, +// @ts-ignore + end: { +// @ts-ignore + offset: endPos, +// @ts-ignore + line: endPosDetails.line, +// @ts-ignore + column: endPosDetails.column + } + }; +// @ts-ignore + if (offset && peg$source && (typeof peg$source.offset === "function")) { +// @ts-ignore + res.start = peg$source.offset(res.start); +// @ts-ignore + res.end = peg$source.offset(res.end); + } +// @ts-ignore + return res; + } + +// @ts-ignore + function peg$fail(expected) { +// @ts-ignore + if (peg$currPos < peg$maxFailPos) { return; } + +// @ts-ignore + if (peg$currPos > peg$maxFailPos) { +// @ts-ignore + peg$maxFailPos = peg$currPos; +// @ts-ignore + peg$maxFailExpected = []; + } + +// @ts-ignore + peg$maxFailExpected.push(expected); + } + +// @ts-ignore + function peg$buildSimpleError(message, location) { +// @ts-ignore + return new peg$SyntaxError(message, null, null, location); + } + +// @ts-ignore + function peg$buildStructuredError(expected, found, location) { +// @ts-ignore + return new peg$SyntaxError( +// @ts-ignore + peg$SyntaxError.buildMessage(expected, found), +// @ts-ignore + expected, +// @ts-ignore + found, +// @ts-ignore + location + ); + } + +// @ts-ignore + function // @ts-ignore +peg$parseProgram() { +// @ts-ignore + var s0, s1, s2; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = []; +// @ts-ignore + s2 = peg$parseContinuationExpression(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); + } +// @ts-ignore + while (s2 !== peg$FAILED) { +// @ts-ignore + s1.push(s2); +// @ts-ignore + s2 = peg$parseContinuationExpression(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); + } + } +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s1 = peg$f0(s1); +// @ts-ignore + s0 = s1; + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseContinuationExpression() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseRecordExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseSelectExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseOffsetExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseApplicationExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseFixExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseSwitchExpression(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parsePrimitiveOperationExpression(); + } + } + } + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSelectExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseSELECT(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseInteger(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseValue(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseCOMMA(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + s12 = peg$parse_(); +// @ts-ignore + if (s12 === peg$FAILED) { +// @ts-ignore + s12 = null; + } +// @ts-ignore + s13 = peg$parseIdentifier(); +// @ts-ignore + if (s13 !== peg$FAILED) { +// @ts-ignore + s14 = peg$parse_(); +// @ts-ignore + if (s14 === peg$FAILED) { +// @ts-ignore + s14 = null; + } +// @ts-ignore + s15 = peg$parseContinuationExpression(); +// @ts-ignore + if (s15 !== peg$FAILED) { +// @ts-ignore + s16 = peg$parse_(); +// @ts-ignore + if (s16 === peg$FAILED) { +// @ts-ignore + s16 = null; + } +// @ts-ignore + s17 = peg$parseRPAREN(); +// @ts-ignore + if (s17 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f1(s5, s9, s13, s15); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseOffsetExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseOFFSET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseInteger(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseValue(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseCOMMA(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + s12 = peg$parse_(); +// @ts-ignore + if (s12 === peg$FAILED) { +// @ts-ignore + s12 = null; + } +// @ts-ignore + s13 = peg$parseIdentifier(); +// @ts-ignore + if (s13 !== peg$FAILED) { +// @ts-ignore + s14 = peg$parse_(); +// @ts-ignore + if (s14 === peg$FAILED) { +// @ts-ignore + s14 = null; + } +// @ts-ignore + s15 = peg$parseContinuationExpression(); +// @ts-ignore + if (s15 !== peg$FAILED) { +// @ts-ignore + s16 = peg$parse_(); +// @ts-ignore + if (s16 === peg$FAILED) { +// @ts-ignore + s16 = null; + } +// @ts-ignore + s17 = peg$parseRPAREN(); +// @ts-ignore + if (s17 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f2(s5, s9, s13, s15); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseIdentifierList() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLBRACKET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseIdentifier(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseIdentifier(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } + } +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseIdentifier(); +// @ts-ignore + if (s5 === peg$FAILED) { +// @ts-ignore + s5 = null; + } +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseRBRACKET(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f3(s3, s5); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseValueList() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLBRACKET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseValue(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseValue(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } + } +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseValue(); +// @ts-ignore + if (s5 === peg$FAILED) { +// @ts-ignore + s5 = null; + } +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseRBRACKET(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f4(s3, s5); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSwitchExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseSWITCH(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseValue(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseContinuationList(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseRPAREN(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f5(s5, s9); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseApplicationExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseAPP(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseValue(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseValueList(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseRPAREN(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f6(s5, s9); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseFixBinding() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLPAREN(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseIdentifier(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseCOMMA(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseIdentifierList(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseCOMMA(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseContinuationExpression(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + s12 = peg$parse_(); +// @ts-ignore + if (s12 === peg$FAILED) { +// @ts-ignore + s12 = null; + } +// @ts-ignore + s13 = peg$parseRPAREN(); +// @ts-ignore + if (s13 !== peg$FAILED) { +// @ts-ignore + s1 = [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13]; +// @ts-ignore + s0 = s1; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseFixBindingList() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLBRACKET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseFixBinding(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseFixBinding(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } + } +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseFixBinding(); +// @ts-ignore + if (s5 === peg$FAILED) { +// @ts-ignore + s5 = null; + } +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseRBRACKET(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f7(s3, s5); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseFixExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseFIX(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseFixBindingList(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseContinuationExpression(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseRPAREN(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f8(s5, s9); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseContinuationList() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLBRACKET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseContinuationExpression(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseContinuationExpression(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } + } +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseContinuationExpression(); +// @ts-ignore + if (s5 === peg$FAILED) { +// @ts-ignore + s5 = null; + } +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseRBRACKET(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f9(s3, s5); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parsePrimitiveOperationExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parsePRIMOP(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parsePrimitiveOperation(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseValueList(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseCOMMA(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + s12 = peg$parse_(); +// @ts-ignore + if (s12 === peg$FAILED) { +// @ts-ignore + s12 = null; + } +// @ts-ignore + s13 = peg$parseIdentifierList(); +// @ts-ignore + if (s13 !== peg$FAILED) { +// @ts-ignore + s14 = peg$parse_(); +// @ts-ignore + if (s14 === peg$FAILED) { +// @ts-ignore + s14 = null; + } +// @ts-ignore + s15 = peg$parseCOMMA(); +// @ts-ignore + if (s15 !== peg$FAILED) { +// @ts-ignore + s16 = peg$parse_(); +// @ts-ignore + if (s16 === peg$FAILED) { +// @ts-ignore + s16 = null; + } +// @ts-ignore + s17 = peg$parseContinuationList(); +// @ts-ignore + if (s17 !== peg$FAILED) { +// @ts-ignore + s18 = peg$parse_(); +// @ts-ignore + if (s18 === peg$FAILED) { +// @ts-ignore + s18 = null; + } +// @ts-ignore + s19 = peg$parseRPAREN(); +// @ts-ignore + if (s19 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f10(s5, s9, s13, s17); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRecordExpressionTuple() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLPAREN(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseVarStatement(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseCOMMA(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseOffsetStatement(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseRPAREN(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f11(s3, s7); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRecordExpressionTupleList() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLBRACKET(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseRecordExpressionTuple(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = peg$currPos; +// @ts-ignore + s5 = peg$parseRecordExpressionTuple(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s5 = [s5, s6, s7, s8]; +// @ts-ignore + s4 = s5; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s4; +// @ts-ignore + s4 = peg$FAILED; + } + } +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseRecordExpressionTuple(); +// @ts-ignore + if (s5 === peg$FAILED) { +// @ts-ignore + s5 = null; + } +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseRBRACKET(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f12(s3, s5); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRecordExpression() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseRECORD(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = peg$parseLPAREN(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + s4 = peg$parse_(); +// @ts-ignore + if (s4 === peg$FAILED) { +// @ts-ignore + s4 = null; + } +// @ts-ignore + s5 = peg$parseRecordExpressionTupleList(); +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s6 = peg$parse_(); +// @ts-ignore + if (s6 === peg$FAILED) { +// @ts-ignore + s6 = null; + } +// @ts-ignore + s7 = peg$parseCOMMA(); +// @ts-ignore + if (s7 !== peg$FAILED) { +// @ts-ignore + s8 = peg$parse_(); +// @ts-ignore + if (s8 === peg$FAILED) { +// @ts-ignore + s8 = null; + } +// @ts-ignore + s9 = peg$parseLiteral(); +// @ts-ignore + if (s9 !== peg$FAILED) { +// @ts-ignore + s10 = peg$parse_(); +// @ts-ignore + if (s10 === peg$FAILED) { +// @ts-ignore + s10 = null; + } +// @ts-ignore + s11 = peg$parseCOMMA(); +// @ts-ignore + if (s11 !== peg$FAILED) { +// @ts-ignore + s12 = peg$parse_(); +// @ts-ignore + if (s12 === peg$FAILED) { +// @ts-ignore + s12 = null; + } +// @ts-ignore + s13 = peg$parseContinuationExpression(); +// @ts-ignore + if (s13 !== peg$FAILED) { +// @ts-ignore + s14 = peg$parse_(); +// @ts-ignore + if (s14 === peg$FAILED) { +// @ts-ignore + s14 = null; + } +// @ts-ignore + s15 = peg$parseRPAREN(); +// @ts-ignore + if (s15 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f13(s5, s9, s13); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseValue() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseVarStatement(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseLabelStatement(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseIntStatement(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseRealStatement(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseStringStatement(); + } + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseVarStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseVAR(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseIdentifier(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f14(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLabelStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseLABEL(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseIdentifier(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f15(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseIntStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseINT(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseInteger(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f16(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRealStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseREAL(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseReal(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f17(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseStringStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseSTRING(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseQuotedString(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f18(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseAccessStatement() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseOffsetStatement(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseSelectStatement(); + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseOffsetStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseOFFP(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseInteger(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f19(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSelectStatement() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$parseSELP(); +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$parse_(); +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = peg$parseInteger(); +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f20(s3); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseIdentifier() { +// @ts-ignore + var s0, s1, s2, s3, s4; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$currPos; +// @ts-ignore + s2 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r0.test(s2)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s2 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r1.test(s4)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s4 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r1.test(s4)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s4 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + } +// @ts-ignore + s2 = [s2, s3]; +// @ts-ignore + s1 = s2; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s1; +// @ts-ignore + s1 = peg$FAILED; + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s1 = peg$f21(s1); + } +// @ts-ignore + s0 = s1; + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parsePrimitiveOperation() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseArithmeticOperation(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseComparisonOperation(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseBitOperation(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseStoreOperation(); + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseStoreOperation() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseSTORE(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseUPDATE(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseMAKEREF(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseMAKEREFUNBOXED(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseUNBOXED_UPDATE(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseBOXED(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseSUBSCRIPT(); + } + } + } + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseArithmeticOperation() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r2.test(s0)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e2); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c0) { +// @ts-ignore + s0 = peg$c0; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseBitOperation() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c1) { +// @ts-ignore + s0 = peg$c1; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c2) { +// @ts-ignore + s0 = peg$c2; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e5); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r3.test(s0)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e6); } + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseComparisonOperation() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c3) { +// @ts-ignore + s0 = peg$c3; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c4) { +// @ts-ignore + s0 = peg$c4; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c5) { +// @ts-ignore + s0 = peg$c5; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e9); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c6) { +// @ts-ignore + s0 = peg$c6; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r4.test(s0)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + } + } + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseInteger() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = []; +// @ts-ignore + s2 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s2)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s2 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + while (s2 !== peg$FAILED) { +// @ts-ignore + s1.push(s2); +// @ts-ignore + s2 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s2)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s2 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } + } +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = peg$currPos; +// @ts-ignore + peg$silentFails++; +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 46) { +// @ts-ignore + s3 = peg$c7; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e13); } + } +// @ts-ignore + peg$silentFails--; +// @ts-ignore + if (s3 === peg$FAILED) { +// @ts-ignore + s2 = undefined; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s2; +// @ts-ignore + s2 = peg$FAILED; + } +// @ts-ignore + if (s2 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f22(s1); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseQuotedString() { +// @ts-ignore + var s0, s1, s2, s3; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 39) { +// @ts-ignore + s1 = peg$c8; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e14); } + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = []; +// @ts-ignore + s3 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r6.test(s3)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } +// @ts-ignore + while (s3 !== peg$FAILED) { +// @ts-ignore + s2.push(s3); +// @ts-ignore + s3 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r6.test(s3)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } + } +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 39) { +// @ts-ignore + s3 = peg$c8; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e14); } + } +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f23(s2); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 34) { +// @ts-ignore + s1 = peg$c9; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e16); } + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + s2 = []; +// @ts-ignore + s3 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r7.test(s3)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } +// @ts-ignore + while (s3 !== peg$FAILED) { +// @ts-ignore + s2.push(s3); +// @ts-ignore + s3 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r7.test(s3)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + } +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 34) { +// @ts-ignore + s3 = peg$c9; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e16); } + } +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s0 = peg$f24(s2); +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s0; +// @ts-ignore + s0 = peg$FAILED; + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseReal() { +// @ts-ignore + var s0, s1, s2, s3, s4, s5, s6; + +// @ts-ignore + s0 = peg$currPos; +// @ts-ignore + s1 = peg$currPos; +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 45) { +// @ts-ignore + s2 = peg$c10; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s2 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } +// @ts-ignore + if (s2 === peg$FAILED) { +// @ts-ignore + s2 = null; + } +// @ts-ignore + s3 = []; +// @ts-ignore + s4 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s4)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s4 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } +// @ts-ignore + if (s4 !== peg$FAILED) { +// @ts-ignore + while (s4 !== peg$FAILED) { +// @ts-ignore + s3.push(s4); +// @ts-ignore + s4 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s4)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s4 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } + } +// @ts-ignore + } else { +// @ts-ignore + s3 = peg$FAILED; + } +// @ts-ignore + if (s3 !== peg$FAILED) { +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 46) { +// @ts-ignore + s4 = peg$c7; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s4 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e13); } + } +// @ts-ignore + if (s4 !== peg$FAILED) { +// @ts-ignore + s5 = []; +// @ts-ignore + s6 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s6)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s6 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } +// @ts-ignore + if (s6 !== peg$FAILED) { +// @ts-ignore + while (s6 !== peg$FAILED) { +// @ts-ignore + s5.push(s6); +// @ts-ignore + s6 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s6)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s6 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } + } +// @ts-ignore + } else { +// @ts-ignore + s5 = peg$FAILED; + } +// @ts-ignore + if (s5 !== peg$FAILED) { +// @ts-ignore + s2 = [s2, s3, s4, s5]; +// @ts-ignore + s1 = s2; +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s1; +// @ts-ignore + s1 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s1; +// @ts-ignore + s1 = peg$FAILED; + } +// @ts-ignore + } else { +// @ts-ignore + peg$currPos = s1; +// @ts-ignore + s1 = peg$FAILED; + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + peg$savedPos = s0; +// @ts-ignore + s1 = peg$f25(s1); + } +// @ts-ignore + s0 = s1; + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLiteral() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = peg$parseReal(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseQuotedString(); +// @ts-ignore + if (s0 === peg$FAILED) { +// @ts-ignore + s0 = peg$parseInteger(); + } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseOFFSET() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c11) { +// @ts-ignore + s0 = peg$c11; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e19); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseOFFP() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 4) === peg$c12) { +// @ts-ignore + s0 = peg$c12; +// @ts-ignore + peg$currPos += 4; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSELP() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 4) === peg$c13) { +// @ts-ignore + s0 = peg$c13; +// @ts-ignore + peg$currPos += 4; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseVAR() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 3) === peg$c14) { +// @ts-ignore + s0 = peg$c14; +// @ts-ignore + peg$currPos += 3; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e22); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseINT() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 3) === peg$c15) { +// @ts-ignore + s0 = peg$c15; +// @ts-ignore + peg$currPos += 3; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e23); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseREAL() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 4) === peg$c16) { +// @ts-ignore + s0 = peg$c16; +// @ts-ignore + peg$currPos += 4; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e24); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSTRING() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c17) { +// @ts-ignore + s0 = peg$c17; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e25); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseAPP() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 3) === peg$c18) { +// @ts-ignore + s0 = peg$c18; +// @ts-ignore + peg$currPos += 3; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e26); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRECORD() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c19) { +// @ts-ignore + s0 = peg$c19; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e27); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSELECT() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c20) { +// @ts-ignore + s0 = peg$c20; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e28); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseFIX() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 3) === peg$c21) { +// @ts-ignore + s0 = peg$c21; +// @ts-ignore + peg$currPos += 3; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e29); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSWITCH() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c22) { +// @ts-ignore + s0 = peg$c22; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e30); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parsePRIMOP() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c23) { +// @ts-ignore + s0 = peg$c23; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e31); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLABEL() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 5) === peg$c24) { +// @ts-ignore + s0 = peg$c24; +// @ts-ignore + peg$currPos += 5; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e32); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSTORE() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 5) === peg$c25) { +// @ts-ignore + s0 = peg$c25; +// @ts-ignore + peg$currPos += 5; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e33); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseUPDATE() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 6) === peg$c26) { +// @ts-ignore + s0 = peg$c26; +// @ts-ignore + peg$currPos += 6; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e34); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseMAKEREF() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 7) === peg$c27) { +// @ts-ignore + s0 = peg$c27; +// @ts-ignore + peg$currPos += 7; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e35); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseMAKEREFUNBOXED() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 14) === peg$c28) { +// @ts-ignore + s0 = peg$c28; +// @ts-ignore + peg$currPos += 14; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e36); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseUNBOXED_UPDATE() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 13) === peg$c29) { +// @ts-ignore + s0 = peg$c29; +// @ts-ignore + peg$currPos += 13; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e37); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSUBSCRIPT() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 9) === peg$c30) { +// @ts-ignore + s0 = peg$c30; +// @ts-ignore + peg$currPos += 9; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e38); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseBOXED() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.substr(peg$currPos, 5) === peg$c31) { +// @ts-ignore + s0 = peg$c31; +// @ts-ignore + peg$currPos += 5; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e39); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLETTER() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r0.test(s0)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseSAFE_SYMBOL() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 95) { +// @ts-ignore + s0 = peg$c32; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e40); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseDIGIT() { +// @ts-ignore + var s0; + +// @ts-ignore + s0 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r5.test(s0)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLBRACKET() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 91) { +// @ts-ignore + s0 = peg$c33; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e41); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRBRACKET() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 93) { +// @ts-ignore + s0 = peg$c34; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e42); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseCOMMA() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 44) { +// @ts-ignore + s0 = peg$c35; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e43); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseEQUALS() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 61) { +// @ts-ignore + s0 = peg$c36; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e44); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseLPAREN() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 40) { +// @ts-ignore + s0 = peg$c37; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e45); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parseRPAREN() { +// @ts-ignore + var s0; + +// @ts-ignore + if (input.charCodeAt(peg$currPos) === 41) { +// @ts-ignore + s0 = peg$c38; +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e46); } + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + function // @ts-ignore +peg$parse_() { +// @ts-ignore + var s0, s1; + +// @ts-ignore + s0 = []; +// @ts-ignore + s1 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r8.test(s1)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e47); } + } +// @ts-ignore + if (s1 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c39) { +// @ts-ignore + s1 = peg$c39; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e48); } + } + } +// @ts-ignore + if (s1 !== peg$FAILED) { +// @ts-ignore + while (s1 !== peg$FAILED) { +// @ts-ignore + s0.push(s1); +// @ts-ignore + s1 = input.charAt(peg$currPos); +// @ts-ignore + if (peg$r8.test(s1)) { +// @ts-ignore + peg$currPos++; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e47); } + } +// @ts-ignore + if (s1 === peg$FAILED) { +// @ts-ignore + if (input.substr(peg$currPos, 2) === peg$c39) { +// @ts-ignore + s1 = peg$c39; +// @ts-ignore + peg$currPos += 2; +// @ts-ignore + } else { +// @ts-ignore + s1 = peg$FAILED; +// @ts-ignore + if (peg$silentFails === 0) { peg$fail(peg$e48); } + } + } + } +// @ts-ignore + } else { +// @ts-ignore + s0 = peg$FAILED; + } + +// @ts-ignore + return s0; + } + +// @ts-ignore + peg$result = peg$startRuleFunction(); + +// @ts-ignore + if (options.peg$library) { +// @ts-ignore + return /** @type {any} */ ({ +// @ts-ignore + peg$result, +// @ts-ignore + peg$currPos, +// @ts-ignore + peg$FAILED, +// @ts-ignore + peg$maxFailExpected, +// @ts-ignore + peg$maxFailPos + }); + } +// @ts-ignore + if (peg$result !== peg$FAILED && peg$currPos === input.length) { +// @ts-ignore + return peg$result; +// @ts-ignore + } else { +// @ts-ignore + if (peg$result !== peg$FAILED && peg$currPos < input.length) { +// @ts-ignore + peg$fail(peg$endExpectation()); + } + +// @ts-ignore + throw peg$buildStructuredError( +// @ts-ignore + peg$maxFailExpected, +// @ts-ignore + peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, +// @ts-ignore + peg$maxFailPos < input.length +// @ts-ignore + ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) +// @ts-ignore + : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) + ); + } +} + +// @ts-ignore + return { + StartRules: ["Program"], + SyntaxError: peg$SyntaxError, + parse: peg$parse + }; +})() + +export interface FilePosition { + offset: number; + line: number; + column: number; +} + +export interface FileRange { + start: FilePosition; + end: FilePosition; + source: string; +} + +export interface LiteralExpectation { + type: "literal"; + text: string; + ignoreCase: boolean; +} + +export interface ClassParts extends Array {} + +export interface ClassExpectation { + type: "class"; + parts: ClassParts; + inverted: boolean; + ignoreCase: boolean; +} + +export interface AnyExpectation { + type: "any"; +} + +export interface EndExpectation { + type: "end"; +} + +export interface OtherExpectation { + type: "other"; + description: string; +} + +export type Expectation = LiteralExpectation | ClassExpectation | AnyExpectation | EndExpectation | OtherExpectation; + +declare class _PeggySyntaxError extends Error { + public static buildMessage(expected: Expectation[], found: string | null): string; + public message: string; + public expected: Expectation[]; + public found: string | null; + public location: FileRange; + public name: string; + constructor(message: string, expected: Expectation[], found: string | null, location: FileRange); + format(sources: { + source?: any; + text: string; + }[]): string; +} + +export interface TraceEvent { + type: string; + rule: string; + result?: any; + location: FileRange; + } + +declare class _DefaultTracer { + private indentLevel: number; + public trace(event: TraceEvent): void; +} + +peggyParser.SyntaxError.prototype.name = "PeggySyntaxError"; + +export interface ParseOptions { + filename?: string; + startRule?: "Program"; + tracer?: any; + [key: string]: any; +} +export type ParseFunction = ( + input: string, + options?: Options + ) => Options extends { startRule: infer StartRule } ? + StartRule extends "Program" ? Program : Program + : Program; +export const parse: ParseFunction = peggyParser.parse; + +export const PeggySyntaxError = peggyParser.SyntaxError as typeof _PeggySyntaxError; + +export type PeggySyntaxError = _PeggySyntaxError; + +// These types were autogenerated by ts-pegjs +export type Program = any[]; +export type ContinuationExpression = + | RecordExpression + | SelectExpression + | OffsetExpression + | ApplicationExpression + | FixExpression + | SwitchExpression + | PrimitiveOperationExpression; +export type SelectExpression = { + select: Integer; + val: Value; + bind: Identifier; + continuation: ContinuationExpression; +}; +export type OffsetExpression = { + offset: Integer; + val: Value; + bind: Identifier; + continuation: ContinuationExpression; +}; +export type IdentifierList = any[]; +export type ValueList = any[]; +export type SwitchExpression = { + switchIndex: Value; + continuations: ContinuationList; +}; +export type ApplicationExpression = { fn: Value; args: ValueList }; +export type FixBinding = [ + LPAREN, + _ | null, + Identifier, + _ | null, + COMMA, + _ | null, + IdentifierList, + _ | null, + COMMA, + _ | null, + ContinuationExpression, + _ | null, + RPAREN +]; +export type FixBindingList = any[]; +export type FixExpression = { + fixBindings: FixBindingList; + continuation: ContinuationExpression; +}; +export type ContinuationList = any[]; +export type PrimitiveOperationExpression = { + opr: PrimitiveOperation; + operands: ValueList; + resultBindings: IdentifierList; + continuations: ContinuationList; +}; +export type RecordExpressionTuple = { + variable: VarStatement; + offset: OffsetStatement; +}; +export type RecordExpressionTupleList = any[]; +export type RecordExpression = { + records: RecordExpressionTupleList; + address: Literal; + body: ContinuationExpression; +}; +export type Value = + | VarStatement + | LabelStatement + | IntStatement + | RealStatement + | StringStatement; +export type VarStatement = Identifier; +export type LabelStatement = Identifier; +export type IntStatement = Integer; +export type RealStatement = Real; +export type StringStatement = QuotedString; +export type AccessStatement = OffsetStatement | SelectStatement; +export type OffsetStatement = Integer; +export type SelectStatement = Integer; +export type Identifier = { name: string }; +export type PrimitiveOperation = + | ArithmeticOperation + | ComparisonOperation + | BitOperation + | StoreOperation; +export type StoreOperation = + | STORE + | UPDATE + | MAKEREF + | MAKEREFUNBOXED + | UNBOXEDUPDATE + | BOXED + | SUBSCRIPT; +export type ArithmeticOperation = string | "**"; +export type BitOperation = ">>" | "<<" | string; +export type ComparisonOperation = "==" | "<=" | ">=" | "!=" | string; +export type Integer = number; +export type QuotedString = string; +export type Real = number; +export type Literal = Real | QuotedString | Integer; +export type OFFSET = "OFFSET"; +export type OFFP = "OFFp"; +export type SELP = "SELp"; +export type VAR = "VAR"; +export type INT = "INT"; +export type REAL = "REAL"; +export type STRING = "STRING"; +export type APP = "APP"; +export type RECORD = "RECORD"; +export type SELECT = "SELECT"; +export type FIX = "FIX"; +export type SWITCH = "SWITCH"; +export type PRIMOP = "PRIMOP"; +export type LABEL = "LABEL"; +export type STORE = "store"; +export type UPDATE = "update"; +export type MAKEREF = "makeref"; +export type MAKEREFUNBOXED = "makerefunboxed"; +export type UNBOXEDUPDATE = "unboxedupdate"; +export type SUBSCRIPT = "subscript"; +export type BOXED = "boxed"; +export type LETTER = string; +export type SAFESYMBOL = "_"; +export type DIGIT = string; +export type LBRACKET = "["; +export type RBRACKET = "]"; +export type COMMA = ","; +export type EQUALS = "="; +export type LPAREN = "("; +export type RPAREN = ")"; +export type _ = (string | "\r\n")[]; diff --git a/src/utils/exception.ts b/src/utils/exception.ts new file mode 100644 index 0000000..625c32a --- /dev/null +++ b/src/utils/exception.ts @@ -0,0 +1 @@ +export class NotImplementedException extends Error {} diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..f44ed5a --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,2 @@ +export * from './logger'; +export * from './exception'; diff --git a/src/utils/logger.ts b/src/utils/logger.ts new file mode 100644 index 0000000..80126c3 --- /dev/null +++ b/src/utils/logger.ts @@ -0,0 +1,51 @@ +export interface TracingLogger { + info(log: string): void; + warn(log: string): void; + error(log: string): void; + debug(log: string): void; + + createChild(prefix: string): TracingLogger; +} + +export type LogLevel = 'debug' | 'info' | 'warn' | 'error'; + +export class ConsoleTracingLogger implements TracingLogger { + protected prefix: string; + private levels: LogLevel[]; + + constructor(prefix: string, levels: LogLevel[] = ['warn', 'error']) { + this.prefix = prefix; + this.levels = levels; + } + + private makePrefix(level: LogLevel): string { + return `[${new Date().toISOString()}] ${level} (${this.prefix}) > `; + } + + public info(log: string) { + if (this.levels.includes('info')) + console.log(this.makePrefix('info') + log); + } + + public warn(log: string) { + if (this.levels.includes('warn')) + console.warn(this.makePrefix('warn') + log); + } + + public error(log: string) { + if (this.levels.includes('error')) + console.error(this.makePrefix('error') + log); + } + + public debug(log: string) { + if (this.levels.includes('debug')) + console.debug(this.makePrefix('debug') + log); + } + + public createChild(prefix: string, levels?: LogLevel[]) { + return new ConsoleTracingLogger( + `${this.prefix} -> ${prefix}`, + levels ?? this.levels, + ); + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..544b2b5 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "lib": ["ESNext"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + /* Linting */ + "skipLibCheck": true, + "strict": true, + "noFallthroughCasesInSwitch": true, + "forceConsistentCasingInFileNames": true, + + "paths": { + "@/*": ["./src/*"], + "@t/*": ["./test/*"] + } + } +}