Repository: downpoured/vipercard Branch: main Commit: d65d29a08242 Files: 821 Total size: 25.2 MB Directory structure: gitextract_cc7lxjo_/ ├── README.md └── vipercard/ ├── .gitignore ├── LICENSE ├── building.md ├── doc/ │ ├── gendocs.py │ ├── gendocs_to_md.py │ ├── gendocs_tovipercard.py │ ├── libraries.txt │ ├── page_404.md │ ├── page_terms.md │ ├── page_video.md │ ├── page_video1.md │ ├── page_video2.md │ ├── page_video3.md │ ├── page_why.md │ ├── readme.md │ ├── reference_01_overview │ ├── reference_01_overview.md │ ├── reference_02_commands │ ├── reference_02_commands.md │ ├── reference_03_syntax │ ├── reference_03_syntax.md │ ├── reference_04_properties │ ├── reference_04_properties.md │ ├── reference_05_functions │ ├── reference_05_functions.md │ ├── reference_06_events │ ├── reference_06_events.md │ ├── reference_07_compatibility │ └── reference_07_compatibility.md └── vipercard/ ├── .eslintrc.js ├── .gitignore ├── .prettierrc.js ├── .prettierrc_longer.js ├── .vscode/ │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── 0.3/ │ ├── html/ │ │ ├── 404.html │ │ ├── script_reference/ │ │ │ ├── github-markdown.css │ │ │ ├── reference_01_overview.html │ │ │ ├── reference_02_commands.html │ │ │ ├── reference_03_syntax.html │ │ │ ├── reference_04_properties.html │ │ │ ├── reference_05_functions.html │ │ │ ├── reference_06_events.html │ │ │ ├── reference_07_compatibility.html │ │ │ └── smalltheme.css │ │ ├── terms.html │ │ ├── video.html │ │ ├── video1.html │ │ ├── video2.html │ │ ├── video3.html │ │ └── why.html │ ├── index.dev.html │ └── style.css ├── BingSiteAuth.xml ├── external/ │ ├── FileSaver.js-2.0.2/ │ │ ├── CHANGELOG.md │ │ ├── FileSaver.d.ts │ │ ├── FileSaver.js │ │ ├── LICENSE.md │ │ └── README.md │ ├── base64-js-1.3.1/ │ │ ├── LICENSE │ │ ├── README.md │ │ └── base64js.js │ ├── bowser-2.9/ │ │ ├── LICENSE │ │ ├── README.md │ │ ├── bowser-2.9-bundled.js │ │ └── bowser.d.ts │ ├── chevrotain-6.5.0/ │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── chevrotain.js │ │ └── chevrotaintyping.d.ts │ ├── clipboard.js-2.0.6-notbundled/ │ │ ├── LICENSE │ │ ├── clipboard.js │ │ └── readme.md │ ├── easyfilter-notbundled/ │ │ ├── (already in typescript) │ │ ├── LICENSE │ │ └── bresenham.js │ ├── externaldelaybundlebig.js │ ├── externaldelaybundlemin.js │ ├── externalmanualbundlebig.js │ ├── externalmanualbundlemin.js │ ├── golly/ │ │ ├── golly.js │ │ ├── golly.txt │ │ └── license.txt │ ├── js-lru/ │ │ ├── js-lru.d.ts │ │ ├── js-lru.js │ │ └── license.txt │ ├── jsgif-dynamic/ │ │ ├── (loaded dynamically) │ │ ├── LICENSE │ │ ├── jsgif.txt │ │ ├── jsgifcombined.js │ │ └── modified_to_expose_getblob.txt │ ├── lz-string-1.4.4/ │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── base64-string.js │ │ ├── lz-string.js │ │ └── lzstring.d.ts │ ├── manualbundle.py │ ├── pbkdf2/ │ │ └── pbkdf2.txt │ ├── pizzicato-dynamic/ │ │ ├── LICENSE │ │ ├── Pizzicato.js │ │ └── README.md │ └── text-encoding-types-notbundled/ │ ├── index.d.ts │ └── license.txt ├── index.html ├── package.json ├── resources03a/ │ ├── docs/ │ │ ├── demo_anim.json │ │ ├── demo_game.json │ │ ├── demo_glider.json │ │ ├── demo_graphics.json │ │ ├── demo_spacegame.json │ │ ├── refcommands.json │ │ ├── refcompatibility.json │ │ ├── refevents.json │ │ ├── reffunctions.json │ │ ├── refoverview.json │ │ ├── refproperties.json │ │ └── refsyntax.json │ ├── fonts/ │ │ ├── 00_10_+b+iu+osdce.json │ │ ├── 00_10_+b+iuosdce.json │ │ ├── 00_10_+biu+osdce.json │ │ ├── 00_10_+biuosdce.json │ │ ├── 00_10_b+iu+osdce.json │ │ ├── 00_10_b+iuosdce.json │ │ ├── 00_10_biu+osdce.json │ │ ├── 00_10_biuosdce.json │ │ ├── 00_12_+b+iu+osdce.json │ │ ├── 00_12_+b+iuosdce.json │ │ ├── 00_12_+biu+osdce.json │ │ ├── 00_12_+biuosdce.json │ │ ├── 00_12_b+iu+osdce.json │ │ ├── 00_12_b+iuosdce.json │ │ ├── 00_12_biu+osdce.json │ │ ├── 00_12_biuos+dce.json │ │ ├── 00_12_biuosdce.json │ │ ├── 00_14_+b+iu+osdce.json │ │ ├── 00_14_+b+iuosdce.json │ │ ├── 00_14_+biu+osdce.json │ │ ├── 00_14_+biuosdce.json │ │ ├── 00_14_b+iu+osdce.json │ │ ├── 00_14_b+iuosdce.json │ │ ├── 00_14_biu+osdce.json │ │ ├── 00_14_biuosdce.json │ │ ├── 00_18_+b+iu+osdce.json │ │ ├── 00_18_+b+iuosdce.json │ │ ├── 00_18_+biu+osdce.json │ │ ├── 00_18_+biuosdce.json │ │ ├── 00_18_b+iu+osdce.json │ │ ├── 00_18_b+iuosdce.json │ │ ├── 00_18_biu+osdce.json │ │ ├── 00_18_biuosdce.json │ │ ├── 00_24_+b+iu+osdce.json │ │ ├── 00_24_+b+iuosdce.json │ │ ├── 00_24_+biu+osdce.json │ │ ├── 00_24_+biuosdce.json │ │ ├── 00_24_b+iu+osdce.json │ │ ├── 00_24_b+iuosdce.json │ │ ├── 00_24_biu+osdce.json │ │ ├── 00_24_biuosdce.json │ │ ├── 00_9_+b+iu+osdce.json │ │ ├── 00_9_+b+iuosdce.json │ │ ├── 00_9_+biu+osdce.json │ │ ├── 00_9_+biuosdce.json │ │ ├── 00_9_b+iu+osdce.json │ │ ├── 00_9_b+iuosdce.json │ │ ├── 00_9_biu+osdce.json │ │ ├── 00_9_biuosdce.json │ │ ├── 01_10_+b+iu+osdce.json │ │ ├── 01_10_+b+iuosdce.json │ │ ├── 01_10_+biu+osdce.json │ │ ├── 01_10_+biuosdce.json │ │ ├── 01_10_b+iu+osdce.json │ │ ├── 01_10_b+iuosdce.json │ │ ├── 01_10_biu+osdce.json │ │ ├── 01_10_biuosdce.json │ │ ├── 01_12_+b+iu+osdce.json │ │ ├── 01_12_+b+iuosdce.json │ │ ├── 01_12_+biu+osdce.json │ │ ├── 01_12_+biuosdce.json │ │ ├── 01_12_b+iu+osdce.json │ │ ├── 01_12_b+iuosdce.json │ │ ├── 01_12_biu+osdce.json │ │ ├── 01_12_biuosdce.json │ │ ├── 01_14_+b+iu+osdce.json │ │ ├── 01_14_+b+iuosdce.json │ │ ├── 01_14_+biu+osdce.json │ │ ├── 01_14_+biuosdce.json │ │ ├── 01_14_b+iu+osdce.json │ │ ├── 01_14_b+iuosdce.json │ │ ├── 01_14_biu+osdce.json │ │ ├── 01_14_biuosdce.json │ │ ├── 01_18_+b+iu+osdce.json │ │ ├── 01_18_+b+iuosdce.json │ │ ├── 01_18_+biu+osdce.json │ │ ├── 01_18_+biuosdce.json │ │ ├── 01_18_b+iu+osdce.json │ │ ├── 01_18_b+iuosdce.json │ │ ├── 01_18_biu+osdce.json │ │ ├── 01_18_biuosdce.json │ │ ├── 01_24_+b+iu+osdce.json │ │ ├── 01_24_+b+iuosdce.json │ │ ├── 01_24_+biu+osdce.json │ │ ├── 01_24_+biuosdce.json │ │ ├── 01_24_b+iu+osdce.json │ │ ├── 01_24_b+iuosdce.json │ │ ├── 01_24_biu+osdce.json │ │ ├── 01_24_biuosdce.json │ │ ├── 01_9_+b+iu+osdce.json │ │ ├── 01_9_+b+iuosdce.json │ │ ├── 01_9_+biu+osdce.json │ │ ├── 01_9_+biuosdce.json │ │ ├── 01_9_b+iu+osdce.json │ │ ├── 01_9_b+iuosdce.json │ │ ├── 01_9_biu+osdce.json │ │ ├── 01_9_biuosdce.json │ │ ├── 02_10_+b+iu+osdce.json │ │ ├── 02_10_+b+iuosdce.json │ │ ├── 02_10_+biu+osdce.json │ │ ├── 02_10_+biuosdce.json │ │ ├── 02_10_b+iu+osdce.json │ │ ├── 02_10_b+iuosdce.json │ │ ├── 02_10_biu+osdce.json │ │ ├── 02_10_biuosdce.json │ │ ├── 02_12_+b+iu+osdce.json │ │ ├── 02_12_+b+iuosdce.json │ │ ├── 02_12_+biu+osdce.json │ │ ├── 02_12_+biuosdce.json │ │ ├── 02_12_b+iu+osdce.json │ │ ├── 02_12_b+iuosdce.json │ │ ├── 02_12_biu+osdce.json │ │ ├── 02_12_biuosdce.json │ │ ├── 02_14_+b+iu+osdce.json │ │ ├── 02_14_+b+iuosdce.json │ │ ├── 02_14_+biu+osdce.json │ │ ├── 02_14_+biuosdce.json │ │ ├── 02_14_b+iu+osdce.json │ │ ├── 02_14_b+iuosdce.json │ │ ├── 02_14_biu+osdce.json │ │ ├── 02_14_biuosdce.json │ │ ├── 02_18_+b+iu+osdce.json │ │ ├── 02_18_+b+iuosdce.json │ │ ├── 02_18_+biu+osdce.json │ │ ├── 02_18_+biuosdce.json │ │ ├── 02_18_b+iu+osdce.json │ │ ├── 02_18_b+iuosdce.json │ │ ├── 02_18_biu+osdce.json │ │ ├── 02_18_biuosdce.json │ │ ├── 02_24_+b+iu+osdce.json │ │ ├── 02_24_+b+iuosdce.json │ │ ├── 02_24_+biu+osdce.json │ │ ├── 02_24_+biuosdce.json │ │ ├── 02_24_b+iu+osdce.json │ │ ├── 02_24_b+iuosdce.json │ │ ├── 02_24_biu+osdce.json │ │ ├── 02_24_biuosdce.json │ │ ├── 02_9_+b+iu+osdce.json │ │ ├── 02_9_+b+iuosdce.json │ │ ├── 02_9_+biu+osdce.json │ │ ├── 02_9_+biuosdce.json │ │ ├── 02_9_b+iu+osdce.json │ │ ├── 02_9_b+iuosdce.json │ │ ├── 02_9_biu+osdce.json │ │ ├── 02_9_biuos+dce.json │ │ ├── 02_9_biuosdce.json │ │ ├── 03_10_+b+iu+osdce.json │ │ ├── 03_10_+b+iuosdce.json │ │ ├── 03_10_+biu+osdce.json │ │ ├── 03_10_+biuosdce.json │ │ ├── 03_10_b+iu+osdce.json │ │ ├── 03_10_b+iuosdce.json │ │ ├── 03_10_biu+osdce.json │ │ ├── 03_10_biuosdce.json │ │ ├── 03_12_+b+iu+osdce.json │ │ ├── 03_12_+b+iuosdce.json │ │ ├── 03_12_+biu+osdce.json │ │ ├── 03_12_+biuosdce.json │ │ ├── 03_12_b+iu+osdce.json │ │ ├── 03_12_b+iuosdce.json │ │ ├── 03_12_biu+osdce.json │ │ ├── 03_12_biuosdce.json │ │ ├── 03_14_+b+iu+osdce.json │ │ ├── 03_14_+b+iuosdce.json │ │ ├── 03_14_+biu+osdce.json │ │ ├── 03_14_+biuosdce.json │ │ ├── 03_14_b+iu+osdce.json │ │ ├── 03_14_b+iuosdce.json │ │ ├── 03_14_biu+osdce.json │ │ ├── 03_14_biuosdce.json │ │ ├── 03_18_+b+iu+osdce.json │ │ ├── 03_18_+b+iuosdce.json │ │ ├── 03_18_+biu+osdce.json │ │ ├── 03_18_+biuosdce.json │ │ ├── 03_18_b+iu+osdce.json │ │ ├── 03_18_b+iuosdce.json │ │ ├── 03_18_biu+osdce.json │ │ ├── 03_18_biuosdce.json │ │ ├── 03_24_+b+iu+osdce.json │ │ ├── 03_24_+b+iuosdce.json │ │ ├── 03_24_+biu+osdce.json │ │ ├── 03_24_+biuosdce.json │ │ ├── 03_24_b+iu+osdce.json │ │ ├── 03_24_b+iuosdce.json │ │ ├── 03_24_biu+osdce.json │ │ ├── 03_24_biuosdce.json │ │ ├── 03_9_+b+iu+osdce.json │ │ ├── 03_9_+b+iuosdce.json │ │ ├── 03_9_+biu+osdce.json │ │ ├── 03_9_+biuosdce.json │ │ ├── 03_9_b+iu+osdce.json │ │ ├── 03_9_b+iuosdce.json │ │ ├── 03_9_biu+osdce.json │ │ ├── 03_9_biuosdce.json │ │ ├── 04_10_+b+iu+osdce.json │ │ ├── 04_10_+b+iuosdce.json │ │ ├── 04_10_+biu+osdce.json │ │ ├── 04_10_+biuosdce.json │ │ ├── 04_10_b+iu+osdce.json │ │ ├── 04_10_b+iuosdce.json │ │ ├── 04_10_biu+osdce.json │ │ ├── 04_10_biuosdce.json │ │ ├── 04_12_+b+iu+osdce.json │ │ ├── 04_12_+b+iuosdce.json │ │ ├── 04_12_+biu+osdce.json │ │ ├── 04_12_+biuosdce.json │ │ ├── 04_12_b+iu+osdce.json │ │ ├── 04_12_b+iuosdce.json │ │ ├── 04_12_biu+osdce.json │ │ ├── 04_12_biuosdce.json │ │ ├── 04_14_+b+iu+osdce.json │ │ ├── 04_14_+b+iuosdce.json │ │ ├── 04_14_+biu+osdce.json │ │ ├── 04_14_+biuosdce.json │ │ ├── 04_14_b+iu+osdce.json │ │ ├── 04_14_b+iuosdce.json │ │ ├── 04_14_biu+osdce.json │ │ ├── 04_14_biuosdce.json │ │ ├── 04_18_+b+iu+osdce.json │ │ ├── 04_18_+b+iuosdce.json │ │ ├── 04_18_+biu+osdce.json │ │ ├── 04_18_+biuosdce.json │ │ ├── 04_18_b+iu+osdce.json │ │ ├── 04_18_b+iuosdce.json │ │ ├── 04_18_biu+osdce.json │ │ ├── 04_18_biuosdce.json │ │ ├── 04_24_+b+iu+osdce.json │ │ ├── 04_24_+b+iuosdce.json │ │ ├── 04_24_+biu+osdce.json │ │ ├── 04_24_+biuosdce.json │ │ ├── 04_24_b+iu+osdce.json │ │ ├── 04_24_b+iuosdce.json │ │ ├── 04_24_biu+osdce.json │ │ ├── 04_24_biuosdce.json │ │ ├── 04_9_+b+iu+osdce.json │ │ ├── 04_9_+b+iuosdce.json │ │ ├── 04_9_+biu+osdce.json │ │ ├── 04_9_+biuosdce.json │ │ ├── 04_9_b+iu+osdce.json │ │ ├── 04_9_b+iuosdce.json │ │ ├── 04_9_biu+osdce.json │ │ ├── 04_9_biuosdce.json │ │ ├── 05_10_+b+iu+osdce.json │ │ ├── 05_10_+b+iuosdce.json │ │ ├── 05_10_+biu+osdce.json │ │ ├── 05_10_+biuosdce.json │ │ ├── 05_10_b+iu+osdce.json │ │ ├── 05_10_b+iuosdce.json │ │ ├── 05_10_biu+osdce.json │ │ ├── 05_10_biuosdce.json │ │ ├── 05_12_+b+iu+osdce.json │ │ ├── 05_12_+b+iuosdce.json │ │ ├── 05_12_+biu+osdce.json │ │ ├── 05_12_+biuosdce.json │ │ ├── 05_12_b+iu+osdce.json │ │ ├── 05_12_b+iuosdce.json │ │ ├── 05_12_biu+osdce.json │ │ ├── 05_12_biuosdce.json │ │ ├── 05_14_+b+iu+osdce.json │ │ ├── 05_14_+b+iuosdce.json │ │ ├── 05_14_+biu+osdce.json │ │ ├── 05_14_+biuosdce.json │ │ ├── 05_14_b+iu+osdce.json │ │ ├── 05_14_b+iuosdce.json │ │ ├── 05_14_biu+osdce.json │ │ ├── 05_14_biuosdce.json │ │ ├── 05_18_+b+iu+osdce.json │ │ ├── 05_18_+b+iuosdce.json │ │ ├── 05_18_+biu+osdce.json │ │ ├── 05_18_+biuosdce.json │ │ ├── 05_18_b+iu+osdce.json │ │ ├── 05_18_b+iuosdce.json │ │ ├── 05_18_biu+osdce.json │ │ ├── 05_18_biuosdce.json │ │ ├── 05_24_+b+iu+osdce.json │ │ ├── 05_24_+b+iuosdce.json │ │ ├── 05_24_+biu+osdce.json │ │ ├── 05_24_+biuosdce.json │ │ ├── 05_24_b+iu+osdce.json │ │ ├── 05_24_b+iuosdce.json │ │ ├── 05_24_biu+osdce.json │ │ ├── 05_24_biuosdce.json │ │ ├── 05_9_+b+iu+osdce.json │ │ ├── 05_9_+b+iuosdce.json │ │ ├── 05_9_+biu+osdce.json │ │ ├── 05_9_+biuosdce.json │ │ ├── 05_9_b+iu+osdce.json │ │ ├── 05_9_b+iuosdce.json │ │ ├── 05_9_biu+osdce.json │ │ ├── 05_9_biuosdce.json │ │ ├── 06_10_+b+iu+osdce.json │ │ ├── 06_10_+b+iuosdce.json │ │ ├── 06_10_+biu+osdce.json │ │ ├── 06_10_+biuosdce.json │ │ ├── 06_10_b+iu+osdce.json │ │ ├── 06_10_b+iuosdce.json │ │ ├── 06_10_biu+osdce.json │ │ ├── 06_10_biuosdce.json │ │ ├── 06_12_+b+iu+osdce.json │ │ ├── 06_12_+b+iuosdce.json │ │ ├── 06_12_+biu+osdce.json │ │ ├── 06_12_+biuosdce.json │ │ ├── 06_12_b+iu+osdce.json │ │ ├── 06_12_b+iuosdce.json │ │ ├── 06_12_biu+osdce.json │ │ ├── 06_12_biuosdce.json │ │ ├── 06_14_+b+iu+osdce.json │ │ ├── 06_14_+b+iuosdce.json │ │ ├── 06_14_+biu+osdce.json │ │ ├── 06_14_+biuosdce.json │ │ ├── 06_14_b+iu+osdce.json │ │ ├── 06_14_b+iuosdce.json │ │ ├── 06_14_biu+osdce.json │ │ ├── 06_14_biuosdce.json │ │ ├── 06_18_+b+iu+osdce.json │ │ ├── 06_18_+b+iuosdce.json │ │ ├── 06_18_+biu+osdce.json │ │ ├── 06_18_+biuosdce.json │ │ ├── 06_18_b+iu+osdce.json │ │ ├── 06_18_b+iuosdce.json │ │ ├── 06_18_biu+osdce.json │ │ ├── 06_18_biuosdce.json │ │ ├── 06_24_+b+iu+osdce.json │ │ ├── 06_24_+b+iuosdce.json │ │ ├── 06_24_+biu+osdce.json │ │ ├── 06_24_+biuosdce.json │ │ ├── 06_24_b+iu+osdce.json │ │ ├── 06_24_b+iuosdce.json │ │ ├── 06_24_biu+osdce.json │ │ ├── 06_24_biuosdce.json │ │ ├── 06_9_+b+iu+osdce.json │ │ ├── 06_9_+b+iuosdce.json │ │ ├── 06_9_+biu+osdce.json │ │ ├── 06_9_+biuosdce.json │ │ ├── 06_9_b+iu+osdce.json │ │ ├── 06_9_b+iuosdce.json │ │ ├── 06_9_biu+osdce.json │ │ ├── 06_9_biuosdce.json │ │ ├── 07_10_+b+iu+osdce.json │ │ ├── 07_10_+b+iuosdce.json │ │ ├── 07_10_+biu+osdce.json │ │ ├── 07_10_+biuosdce.json │ │ ├── 07_10_b+iu+osdce.json │ │ ├── 07_10_b+iuosdce.json │ │ ├── 07_10_biu+osdce.json │ │ ├── 07_10_biuosdce.json │ │ ├── 07_12_+b+iu+osdce.json │ │ ├── 07_12_+b+iuosdce.json │ │ ├── 07_12_+biu+osdce.json │ │ ├── 07_12_+biuosdce.json │ │ ├── 07_12_b+iu+osdce.json │ │ ├── 07_12_b+iuosdce.json │ │ ├── 07_12_biu+osdce.json │ │ ├── 07_12_biuosdce.json │ │ ├── 07_14_+b+iu+osdce.json │ │ ├── 07_14_+b+iuosdce.json │ │ ├── 07_14_+biu+osdce.json │ │ ├── 07_14_+biuosdce.json │ │ ├── 07_14_b+iu+osdce.json │ │ ├── 07_14_b+iuosdce.json │ │ ├── 07_14_biu+osdce.json │ │ ├── 07_14_biuosdce.json │ │ ├── 07_18_+b+iu+osdce.json │ │ ├── 07_18_+b+iuosdce.json │ │ ├── 07_18_+biu+osdce.json │ │ ├── 07_18_+biuosdce.json │ │ ├── 07_18_b+iu+osdce.json │ │ ├── 07_18_b+iuosdce.json │ │ ├── 07_18_biu+osdce.json │ │ ├── 07_18_biuosdce.json │ │ ├── 07_1_biuosdce.json │ │ ├── 07_24_+b+iu+osdce.json │ │ ├── 07_24_+b+iuosdce.json │ │ ├── 07_24_+biu+osdce.json │ │ ├── 07_24_+biuosdce.json │ │ ├── 07_24_b+iu+osdce.json │ │ ├── 07_24_b+iuosdce.json │ │ ├── 07_24_biu+osdce.json │ │ ├── 07_24_biuosdce.json │ │ ├── 07_9_+b+iu+osdce.json │ │ ├── 07_9_+b+iuosdce.json │ │ ├── 07_9_+biu+osdce.json │ │ ├── 07_9_+biuosdce.json │ │ ├── 07_9_b+iu+osdce.json │ │ ├── 07_9_b+iuosdce.json │ │ ├── 07_9_biu+osdce.json │ │ └── 07_9_biuosdce.json │ ├── intro/ │ │ ├── introjs.js │ │ ├── script_reference/ │ │ │ └── github-markdown.css │ │ └── style.css │ ├── sound/ │ │ ├── sound.m4a │ │ └── sound.ogg │ └── test/ │ ├── prevVersionStacks/ │ │ ├── demo_anim.json │ │ ├── demo_game.json │ │ ├── demo_glider.json │ │ ├── demo_graphics.json │ │ ├── demo_spacegame.json │ │ ├── ref_commands.json │ │ ├── ref_event_handlers.json │ │ ├── ref_functions.json │ │ ├── ref_fundamentals.json │ │ └── ref_properties.json │ ├── testScriptExtensiveChunkTests.txt │ ├── testScriptExtensiveConditionalsCollateral.txt │ └── testScriptExtensiveConditionalsExpected.txt ├── src/ │ ├── bridge/ │ │ ├── bridgeBase64Js.ts │ │ ├── bridgeBrowserInfo.ts │ │ ├── bridgeChevrotain.ts │ │ ├── bridgeFileSaver.ts │ │ ├── bridgeJsGif.ts │ │ ├── bridgeJsLru.ts │ │ ├── bridgeLzString.ts │ │ ├── bridgePbkdf2.ts │ │ ├── bridgePizzicato.ts │ │ └── bridgeTextEncoding.ts │ ├── internaldocs.md │ ├── layers.cfg │ ├── test/ │ │ ├── in-app-tests/ │ │ │ ├── card1.script │ │ │ ├── card4.script │ │ │ ├── card4btn.script │ │ │ ├── inapptest.json │ │ │ ├── stackscript.script │ │ │ └── undotest.script │ │ ├── testUtils/ │ │ │ ├── testTop.ts │ │ │ ├── testUtils.ts │ │ │ └── testUtilsCanvas.ts │ │ ├── ui512demo/ │ │ │ ├── uiDemoBasic.ts │ │ │ ├── uiDemoButtons.ts │ │ │ ├── uiDemoComposites.ts │ │ │ ├── uiDemoMenus.ts │ │ │ ├── uiDemoPaint.ts │ │ │ ├── uiDemoText.ts │ │ │ └── uiDemoTextEdit.ts │ │ ├── util512/ │ │ │ ├── testExternalLibs.ts │ │ │ ├── testUtil512.ts │ │ │ ├── testUtil512Assert.ts │ │ │ ├── testUtil512Class.ts │ │ │ ├── testUtil512Higher.ts │ │ │ ├── testUtilsCanvasWrapper.ts │ │ │ └── testUtilsDraw.ts │ │ ├── util512ui/ │ │ │ ├── testUI512CodeEditor.ts │ │ │ ├── testUI512Composites.ts │ │ │ ├── testUI512DrawText.ts │ │ │ ├── testUI512Elements.ts │ │ │ ├── testUI512ElementsViewButtons.ts │ │ │ ├── testUI512FormattedText.ts │ │ │ ├── testUI512MenuRender.ts │ │ │ ├── testUI512Paint.ts │ │ │ ├── testUI512PaintFlood.ts │ │ │ ├── testUI512TextEdit.ts │ │ │ ├── testUI512TextEditInteractions.ts │ │ │ ├── testUI512TextModify.ts │ │ │ └── testUI512TextSelectEvents.ts │ │ ├── vpc/ │ │ │ ├── vpcTestChunkResolution.ts │ │ │ ├── vpcTestElements.ts │ │ │ ├── vpcTestScriptEval.ts │ │ │ ├── vpcTestScriptExprLvl.ts │ │ │ ├── vpcTestScriptExtensiveChunk.ts │ │ │ ├── vpcTestScriptExtensiveIf.ts │ │ │ ├── vpcTestScriptParseCmd.ts │ │ │ ├── vpcTestScriptParseExpr.ts │ │ │ ├── vpcTestScriptRewrites.ts │ │ │ ├── vpcTestScriptRunBase.ts │ │ │ ├── vpcTestScriptRunCmd.ts │ │ │ ├── vpcTestScriptRunCustomFns.ts │ │ │ ├── vpcTestScriptRunSyntax.ts │ │ │ ├── vpcTestVpcVal.ts │ │ │ ├── vpcuiTestIntroProvider.ts │ │ │ └── vpcuiTestMsgBox.ts │ │ └── vpc03/ │ │ ├── cmds/ │ │ │ └── test03go.ts │ │ ├── fns/ │ │ │ └── test03standalone.ts │ │ ├── props/ │ │ │ ├── test03chunk.ts │ │ │ └── test03computed.ts │ │ ├── test03chunkAdditional.ts │ │ ├── test03chunkBasic.ts │ │ ├── test03exprObjectRef.ts │ │ ├── test03exprPseudoObjects.ts │ │ ├── test03lexer.ts │ │ └── test03objectRenderName.ts │ ├── ui512/ │ │ ├── composites/ │ │ │ ├── ui512ButtonGroup.ts │ │ │ ├── ui512CodeEditor.ts │ │ │ ├── ui512CodeEditorAutoIndent.ts │ │ │ ├── ui512Composites.ts │ │ │ ├── ui512ModalDialog.ts │ │ │ └── ui512Toolbox.ts │ │ ├── draw/ │ │ │ ├── ui512DrawBorders.ts │ │ │ ├── ui512DrawIconClasses.ts │ │ │ ├── ui512DrawIconManager.ts │ │ │ ├── ui512DrawPaintDispatch.ts │ │ │ ├── ui512DrawPainter.ts │ │ │ ├── ui512DrawPainterClasses.ts │ │ │ ├── ui512DrawPatterns.ts │ │ │ ├── ui512ImageCollection.ts │ │ │ ├── ui512ImageDissolve.ts │ │ │ ├── ui512ImageSerialization.ts │ │ │ └── ui512Interfaces.ts │ │ ├── drawtext/ │ │ │ ├── ui512ComplexFontChanges.ts │ │ │ ├── ui512DrawText.ts │ │ │ ├── ui512DrawTextArgs.ts │ │ │ ├── ui512DrawTextChar.ts │ │ │ ├── ui512DrawTextCharGrayed.ts │ │ │ ├── ui512DrawTextClasses.ts │ │ │ ├── ui512DrawTextFontRequest.ts │ │ │ ├── ui512FormattedText.ts │ │ │ └── ui512TranslateCharset.ts │ │ ├── elements/ │ │ │ ├── ui512Element.ts │ │ │ ├── ui512ElementApp.ts │ │ │ ├── ui512ElementButton.ts │ │ │ ├── ui512ElementCanvasPiece.ts │ │ │ ├── ui512ElementGettable.ts │ │ │ ├── ui512ElementGroup.ts │ │ │ ├── ui512ElementLabel.ts │ │ │ ├── ui512ElementMenu.ts │ │ │ ├── ui512ElementTextField.ts │ │ │ └── ui512ElementView.ts │ │ ├── lang/ │ │ │ └── langBase.ts │ │ ├── menu/ │ │ │ ├── ui512Events.ts │ │ │ ├── ui512MenuAnimation.ts │ │ │ ├── ui512MenuListeners.ts │ │ │ ├── ui512MenuPositioning.ts │ │ │ ├── ui512PresenterWithMenu.ts │ │ │ └── ui512SuspendEvents.ts │ │ ├── presentation/ │ │ │ ├── ui512Presenter.ts │ │ │ └── ui512PresenterBase.ts │ │ ├── root/ │ │ │ ├── rootSetupHelpers.ts │ │ │ ├── rootStartCanvas.ts │ │ │ └── rootUI512.ts │ │ ├── textedit/ │ │ │ ├── ui512BasicHandlers.ts │ │ │ ├── ui512ClipManager.ts │ │ │ ├── ui512GenericField.ts │ │ │ ├── ui512Scrollbar.ts │ │ │ ├── ui512TextEvents.ts │ │ │ ├── ui512TextLines.ts │ │ │ ├── ui512TextSelModify.ts │ │ │ └── ui512TextSelModifyImpl.ts │ │ └── utils/ │ │ ├── util512.ts │ │ ├── util512Assert.ts │ │ ├── util512Base.ts │ │ ├── util512Higher.ts │ │ ├── util512Serialize.ts │ │ ├── utilsCanvasDraw.ts │ │ ├── utilsCursors.ts │ │ ├── utilsDrawConstants.ts │ │ └── utilsKeypressHelpers.ts │ ├── vpc/ │ │ ├── codeexec/ │ │ │ ├── vpcScriptCaches.ts │ │ │ ├── vpcScriptExecAsync.ts │ │ │ ├── vpcScriptExecFrame.ts │ │ │ ├── vpcScriptExecFrameStack.ts │ │ │ ├── vpcScriptExecInternalDirective.ts │ │ │ ├── vpcScriptExecStatement.ts │ │ │ ├── vpcScriptExecStatementHelpers.ts │ │ │ └── vpcScriptExecTop.ts │ │ ├── codeparse/ │ │ │ ├── vpcParser.ts │ │ │ ├── vpcTokens.ts │ │ │ ├── vpcVisitor.ts │ │ │ ├── vpcVisitorInterface.ts │ │ │ └── vpcVisitorMixin.ts │ │ ├── codepreparse/ │ │ │ ├── vpcBuiltinFunctions.ts │ │ │ ├── vpcBuiltinFunctionsUtils.ts │ │ │ ├── vpcCheckReserved.ts │ │ │ ├── vpcLineToCodeObj.ts │ │ │ ├── vpcPreparseCommon.ts │ │ │ ├── vpcProcessBranchAndLoops.ts │ │ │ ├── vpcRewritesCommands.ts │ │ │ ├── vpcRewritesConditions.ts │ │ │ ├── vpcRewritesCustomFunctions.ts │ │ │ ├── vpcRewritesGlobal.ts │ │ │ ├── vpcRewritesLoops.ts │ │ │ └── vpcTopPreparse.ts │ │ ├── request/ │ │ │ ├── vpcRequest.ts │ │ │ ├── vpcRequestBase.ts │ │ │ └── vpcSigned.ts │ │ ├── vel/ │ │ │ ├── velBase.ts │ │ │ ├── velBg.ts │ │ │ ├── velButton.ts │ │ │ ├── velCard.ts │ │ │ ├── velField.ts │ │ │ ├── velFieldChangeFont.ts │ │ │ ├── velModelTop.ts │ │ │ ├── velOutsideInterfaces.ts │ │ │ ├── velProductOpts.ts │ │ │ ├── velRenderName.ts │ │ │ ├── velResolveContainer.ts │ │ │ ├── velResolveReference.ts │ │ │ ├── velSerialization.ts │ │ │ ├── velStack.ts │ │ │ └── velStackOrderHelpers.ts │ │ └── vpcutils/ │ │ ├── vpcAudio.ts │ │ ├── vpcChunkResolution.ts │ │ ├── vpcChunkResolutionSort.ts │ │ ├── vpcChunkResolutionUtils.ts │ │ ├── vpcEnums.ts │ │ ├── vpcInitIcons.ts │ │ ├── vpcRequestedReference.ts │ │ ├── vpcStandardLibDoMenu.ts │ │ ├── vpcStandardLibScript.ts │ │ ├── vpcTables.ts │ │ ├── vpcUtils.ts │ │ ├── vpcVal.ts │ │ ├── vpcValEval.ts │ │ └── vpcVarCollection.ts │ └── vpcui/ │ ├── intro/ │ │ ├── vpcInterfaceImpl.ts │ │ ├── vpcIntro.ts │ │ ├── vpcIntroInterface.ts │ │ ├── vpcIntroPageBase.ts │ │ ├── vpcIntroPageFirst.ts │ │ ├── vpcIntroPageLoading.ts │ │ ├── vpcIntroPageOpen.ts │ │ ├── vpcIntroPagePickFile.ts │ │ └── vpcIntroProvider.ts │ ├── menu/ │ │ ├── vpcAboutDialog.ts │ │ ├── vpcAppMenuActions.ts │ │ ├── vpcMenu.ts │ │ └── vpcMenuStructure.ts │ ├── modelrender/ │ │ ├── vpcGifExport.ts │ │ ├── vpcModelRender.ts │ │ └── vpcPaintRender.ts │ ├── nonmodaldialogs/ │ │ ├── vpcDocViewer.ts │ │ ├── vpcFormLogin.ts │ │ ├── vpcFormNewUser.ts │ │ ├── vpcFormSendReport.ts │ │ ├── vpcLyrNonModalHolder.ts │ │ └── vpcReplMessageBox.ts │ ├── panels/ │ │ ├── vpcEditPanelsBase.ts │ │ ├── vpcEditPanelsBtn.ts │ │ ├── vpcEditPanelsCard.ts │ │ ├── vpcEditPanelsEmpty.ts │ │ ├── vpcEditPanelsFld.ts │ │ ├── vpcEditPanelsStack.ts │ │ ├── vpcLyrDragHandles.ts │ │ ├── vpcLyrNotification.ts │ │ ├── vpcLyrPanels.ts │ │ ├── vpcLyrToolbox.ts │ │ ├── vpcPanelsInterface.ts │ │ ├── vpcScriptEditor.ts │ │ ├── vpcToolboxMain.ts │ │ ├── vpcToolboxNav.ts │ │ └── vpcToolboxPatterns.ts │ ├── presentation/ │ │ ├── vpcInternalDirectiveImpl.ts │ │ ├── vpcPresenter.ts │ │ ├── vpcPresenterEvents.ts │ │ ├── vpcPresenterInit.ts │ │ ├── vpcPresenterInterface.ts │ │ └── vpcSave.ts │ ├── state/ │ │ ├── vpcCreateOrDelVel.ts │ │ ├── vpcInterface.ts │ │ ├── vpcOutsideImpl.ts │ │ ├── vpcState.ts │ │ ├── vpcStateSerialize.ts │ │ └── vpcUndo.ts │ └── tools/ │ ├── vpcToolBase.ts │ ├── vpcToolBrowse.ts │ ├── vpcToolBucket.ts │ ├── vpcToolCurve.ts │ ├── vpcToolEdit.ts │ ├── vpcToolLasso.ts │ ├── vpcToolSelect.ts │ ├── vpcToolSelectBase.ts │ ├── vpcToolShape.ts │ ├── vpcToolSmear.ts │ └── vpcToolStamp.ts ├── tools/ │ ├── add-assert-markers/ │ │ ├── assertmarkerutils.py │ │ ├── base90.py │ │ ├── config.cfg │ │ ├── current_assert_id.txt │ │ ├── main.py │ │ └── readconfig.py │ ├── genparse/ │ │ ├── bgrammar_01.ccc │ │ ├── bgrammarcmds_01.ccc │ │ ├── list-all.ccc │ │ ├── main.py │ │ ├── produceparser.py │ │ ├── producetokens.py │ │ ├── producevisitor.py │ │ └── readgrammarinput.py │ ├── prettier-except-long-imports/ │ │ ├── check_for_long_lines.py │ │ ├── check_for_null_coalesce.py │ │ ├── check_more.py │ │ ├── check_tests_referenced.py │ │ ├── config.cfg │ │ ├── find_missing_comments.py │ │ ├── help_fix_long_lines.py │ │ ├── main.py │ │ ├── place_imports_one_line.py │ │ └── readconfig.py │ ├── readme.md │ ├── releasetools/ │ │ ├── minify.txt │ │ └── release steps.txt │ ├── set_tsconfig_flavor.js │ └── typescript-super-auto-import/ │ ├── README.md │ ├── config.cfg │ ├── main.py │ ├── readconfig.py │ ├── ts_add_copyright.py │ ├── ts_exports_read.py │ ├── ts_layers_read.py │ └── ts_parsing.py ├── tsconfig.development.json ├── tsconfig.json ├── tsconfig.production.json ├── webpack.config.development.js └── webpack.config.production.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: README.md ================================================ ViperCard is an open source rewrite of 1987's HyperCard. You can use it to make animations, games, and interactive art! This is a community project, all source code is released to the public. * Try it now at [vipercard.net](https://www.vipercard.net) * Follow on [twitter](https://twitter.com/vipercarddotnet) and talk about your projects on [google groups](https://groups.google.com/forum/#!forum/vipercard) * Donate at [donorbox.org](https://donorbox.org/vipercard) Enjoy! ViperCard Copyright (C) 2020 Ben Fisher This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ================================================ FILE: vipercard/.gitignore ================================================ # python *.pyc __pycache__/ # Logs logs *.log npm-debug.log* # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # node-waf configuration .lock-wscript # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules jspm_packages # Optional npm cache directory .npm # Optional REPL history .node_repl_history ================================================ FILE: vipercard/LICENSE ================================================ The following files are released under the MIT License: Copyright 2019 moltenform (Ben Fisher) src/ui512/utils/util512.ts src/ui512/utils/util512Base.ts src/ui512/utils/util512Assert.ts src/ui512/utils/util512Higher.ts src/test/testUtils/testTop.ts src/test/testUtils/testUtils.ts src/test/util512/testUtil512.ts src/test/util512/testUtil512Assert.ts src/test/util512/testUtil512Class.ts src/test/util512/testUtil512Higher.ts All other files are released under the GPLv3 license: Copyright 2019 moltenform (Ben Fisher) GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. {one line to give the program's name and a brief idea of what it does.} Copyright (C) {year} {name of author} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: {project} Copyright (C) {year} {fullname} This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: vipercard/building.md ================================================ ### How to build ViperCard: - install node.js - download vipercard source - cd to `vipercard/vipercard` - run `npm install` - run `npm run start` - webpack will do its thing, after ~30s of compiling, a browser and vipercard will open ### Running tests - open the JavaScript console, usually in the brower's 'show development tools' - click on any button in ViperCard, then press Option+Shift+T - the test status should be shown, and finally a message like '261/261. all tests pass.' ### Build for production - Production builds have minified js and fewer breakpoints - cd to `vipercard/vipercard` - run `npm run build` - an output .js file will be written to `./dist` - make a copy of `index.dev.html` with a new `

================================================ FILE: vipercard/vipercard/0.3/style.css ================================================ canvas { image-rendering: optimizeSpeed; image-rendering: -moz-crisp-edges; image-rendering: -webkit-optimize-contrast; image-rendering: -o-crisp-edges; image-rendering: pixelated; -ms-interpolation-mode: nearest-neighbor; margin: 0px; border: 0px solid black; padding: 0px; } .messageBelow { color: white; font-family: sans-serif; font-size: 60%; margin-left: 90px; margin-top: 200px; } body { /* we never want a scrollbar on this page */ position: fixed; background-color: rgb(0, 0, 0); } .notvisible { display: none; } #idOpeningMsg { /* we'll wait a bit before showing it */ display: none; position: fixed; top: 0px; left: 0px; z-index: -999; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -o-user-select: none; user-select: none; } ================================================ FILE: vipercard/vipercard/BingSiteAuth.xml ================================================ 8A1E5D2B537BBA3E6ADDC00E6B7B2E7C ================================================ FILE: vipercard/vipercard/external/FileSaver.js-2.0.2/CHANGELOG.md ================================================ # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [2.0.2] - 2019-05-14 - Catching an exception on Send (HEAD) ([#534]) ## [2.0.0] - 2018-10-17 - Removed eval to resolve CSP ([#465]) ## [2.0.0-rc.4] - 2018-10-17 - Don’t throw on module.exports ## [2.0.0-rc.3] - 2018-09-27 - Switch export method ## [2.0.0-rc.2] - 2018-09-26 - Added a changelog.md - Reverted `a.click()` to use dispatch with a try-catch ([#465], [#382]) - Made third argument to an object where you have to pass `{ autoBom: true }` - boolean are depricated but still works ## [2.0.0-rc.1] - 2018-09-26 - saveAs don't return anything - The object that dispatched `writestart progress write writeend` are gone - detecting such features was never possible and nobody seems to use it. - Removed the demo folder - Removed date/version from top of the file - Dosen't crash in web workers ([#449]) - Support saving urls ([#260] with workarounds for cross origin) - Uses babel universal module pattern (UMD) to export the package - Provides source map now as well. - use a[download] before msSaveAs ([#193], [#294]) - removed dist from .gitignore (npm uses it if it don't find a .npmignore) - autoBom is now reversed so you have to tell when you want to use autoBom ([#432]) - `a.click()` since there are new and depricated event constructors that works differently ([#382]) - opens up a new popup (tab) directly for the fallback method since the FileReader is async - removed the explicitly MSIE [1-9] check - Uses new anchor link for each save (might solve multiple download problems) [#382]: https://github.com/eligrey/FileSaver.js/issues/382 [#449]: https://github.com/eligrey/FileSaver.js/issues/449 [#260]: https://github.com/eligrey/FileSaver.js/issues/260 [#193]: https://github.com/eligrey/FileSaver.js/issues/193 [#294]: https://github.com/eligrey/FileSaver.js/issues/294 [#432]: https://github.com/eligrey/FileSaver.js/issues/432 [#382]: https://github.com/eligrey/FileSaver.js/issues/382 [#465]: https://github.com/eligrey/FileSaver.js/issues/465 [#469]: https://github.com/eligrey/FileSaver.js/issues/469 [#470]: https://github.com/eligrey/FileSaver.js/issues/470 [#491]: https://github.com/eligrey/FileSaver.js/issues/491 [#534]: https://github.com/eligrey/FileSaver.js/issues/534 ================================================ FILE: vipercard/vipercard/external/FileSaver.js-2.0.2/FileSaver.d.ts ================================================ // Type definitions for FileSaver.js // Project: https://github.com/eligrey/FileSaver.js/ // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** * @summary Interface for "saveAs" function. * @author Cyril Schumacher * @version 1.0 */ export interface FileSaver { ( /** * @summary Data. * @type {Blob} */ data: Blob, /** * @summary File name. * @type {DOMString} */ filename: string, /** * @summary Disable Unicode text encoding hints or not. * @type {boolean} */ disableAutoBOM?: boolean ): void } ================================================ FILE: vipercard/vipercard/external/FileSaver.js-2.0.2/FileSaver.js ================================================ (function (global, factory) { if (typeof define === "function" && define.amd) { define([], factory); } else if (typeof exports !== "undefined") { factory(); } else { var mod = { exports: {} }; factory(); global.FileSaver = mod.exports; } })(this, function () { "use strict"; /* * FileSaver.js * A saveAs() FileSaver implementation. * * By Eli Grey, http://eligrey.com * * License : https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md (MIT) * source : http://purl.eligrey.com/github/FileSaver.js */ // The one and only way of getting global scope in all environments // https://stackoverflow.com/q/3277182/1008999 var _global = typeof window === 'object' && window.window === window ? window : typeof self === 'object' && self.self === self ? self : typeof global === 'object' && global.global === global ? global : void 0; function bom(blob, opts) { if (typeof opts === 'undefined') opts = { autoBom: false };else if (typeof opts !== 'object') { console.warn('Deprecated: Expected third argument to be a object'); opts = { autoBom: !opts }; } // prepend BOM for UTF-8 XML and text/* types (including HTML) // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { return new Blob([String.fromCharCode(0xFEFF), blob], { type: blob.type }); } return blob; } function download(url, name, opts) { var xhr = new XMLHttpRequest(); xhr.open('GET', url); xhr.responseType = 'blob'; xhr.onload = function () { saveAs(xhr.response, name, opts); }; xhr.onerror = function () { console.error('could not download file'); }; xhr.send(); } function corsEnabled(url) { var xhr = new XMLHttpRequest(); // use sync to avoid popup blocker xhr.open('HEAD', url, false); try { xhr.send(); } catch (e) {} return xhr.status >= 200 && xhr.status <= 299; } // `a.click()` doesn't work for all browsers (#465) function click(node) { try { node.dispatchEvent(new MouseEvent('click')); } catch (e) { var evt = document.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null); node.dispatchEvent(evt); } } var saveAs = _global.saveAs || ( // probably in some web worker typeof window !== 'object' || window !== _global ? function saveAs() {} /* noop */ // Use download attribute first if possible (#193 Lumia mobile) : 'download' in HTMLAnchorElement.prototype ? function saveAs(blob, name, opts) { var URL = _global.URL || _global.webkitURL; var a = document.createElement('a'); name = name || blob.name || 'download'; a.download = name; a.rel = 'noopener'; // tabnabbing // TODO: detect chrome extensions & packaged apps // a.target = '_blank' if (typeof blob === 'string') { // Support regular links a.href = blob; if (a.origin !== location.origin) { corsEnabled(a.href) ? download(blob, name, opts) : click(a, a.target = '_blank'); } else { click(a); } } else { // Support blobs a.href = URL.createObjectURL(blob); setTimeout(function () { URL.revokeObjectURL(a.href); }, 4E4); // 40s setTimeout(function () { click(a); }, 0); } } // Use msSaveOrOpenBlob as a second approach : 'msSaveOrOpenBlob' in navigator ? function saveAs(blob, name, opts) { name = name || blob.name || 'download'; if (typeof blob === 'string') { if (corsEnabled(blob)) { download(blob, name, opts); } else { var a = document.createElement('a'); a.href = blob; a.target = '_blank'; setTimeout(function () { click(a); }); } } else { navigator.msSaveOrOpenBlob(bom(blob, opts), name); } } // Fallback to using FileReader and a popup : function saveAs(blob, name, opts, popup) { // Open a popup immediately do go around popup blocker // Mostly only available on user interaction and the fileReader is async so... popup = popup || open('', '_blank'); if (popup) { popup.document.title = popup.document.body.innerText = 'downloading...'; } if (typeof blob === 'string') return download(blob, name, opts); var force = blob.type === 'application/octet-stream'; var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari; var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent); if ((isChromeIOS || force && isSafari) && typeof FileReader === 'object') { // Safari doesn't allow downloading of blob URLs var reader = new FileReader(); reader.onloadend = function () { var url = reader.result; url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;'); if (popup) popup.location.href = url;else location = url; popup = null; // reverse-tabnabbing #460 }; reader.readAsDataURL(blob); } else { var URL = _global.URL || _global.webkitURL; var url = URL.createObjectURL(blob); if (popup) popup.location = url;else location.href = url; popup = null; // reverse-tabnabbing #460 setTimeout(function () { URL.revokeObjectURL(url); }, 4E4); // 40s } }); _global.saveAs = saveAs.saveAs = saveAs; if (typeof module !== 'undefined') { module.exports = saveAs; } }); ================================================ FILE: vipercard/vipercard/external/FileSaver.js-2.0.2/LICENSE.md ================================================ The MIT License Copyright © 2016 [Eli Grey][1]. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. [1]: http://eligrey.com ================================================ FILE: vipercard/vipercard/external/FileSaver.js-2.0.2/README.md ================================================ If you need to save really large files bigger then the blob's size limitation or don't have enough RAM, then have a look at the more advanced [StreamSaver.js][7] that can save data directly to the hard drive asynchronously with the power of the new streams API. That will have support for progress, cancelation and knowing when it's done writing FileSaver.js ============ FileSaver.js is the solution to saving files on the client-side, and is perfect for web apps that generates files on the client, However if the file is coming from the server we recommend you to first try to use [Content-Disposition][8] attachment response header as it has more cross-browser compatiblity. Looking for `canvas.toBlob()` for saving canvases? Check out [canvas-toBlob.js][2] for a cross-browser implementation. Supported Browsers ------------------ | Browser | Constructs as | Filenames | Max Blob Size | Dependencies | | -------------- | ------------- | ------------ | ------------- | ------------ | | Firefox 20+ | Blob | Yes | 800 MiB | None | | Firefox < 20 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) | | Chrome | Blob | Yes | [2GB][3] | None | | Chrome for Android | Blob | Yes | [RAM/5][3] | None | | Edge | Blob | Yes | ? | None | | IE 10+ | Blob | Yes | 600 MiB | None | | Opera 15+ | Blob | Yes | 500 MiB | None | | Opera < 15 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) | | Safari 6.1+* | Blob | No | ? | None | | Safari < 6 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) | | Safari 10.1+   | Blob         | Yes         | n/a           | None | Feature detection is possible: ```js try { var isFileSaverSupported = !!new Blob; } catch (e) {} ``` ### IE < 10 It is possible to save text files in IE < 10 without Flash-based polyfills. See [ChenWenBrian and koffsyrup's `saveTextAs()`](https://github.com/koffsyrup/FileSaver.js#examples) for more details. ### Safari 6.1+ Blobs may be opened instead of saved sometimes—you may have to direct your Safari users to manually press +S to save the file after it is opened. Using the `application/octet-stream` MIME type to force downloads [can cause issues in Safari](https://github.com/eligrey/FileSaver.js/issues/12#issuecomment-47247096). ### iOS saveAs must be run within a user interaction event such as onTouchDown or onClick; setTimeout will prevent saveAs from triggering. Due to restrictions in iOS saveAs opens in a new window instead of downloading, if you want this fixed please [tell Apple how this WebKit bug is affecting you](https://bugs.webkit.org/show_bug.cgi?id=167341). Syntax ------ ### Import `saveAs()` from file-saver ```js import { saveAs } from 'file-saver'; ``` ```js FileSaver saveAs(Blob/File/Url, optional DOMString filename, optional Object { autoBom }) ``` Pass `{ autoBom: true }` if you want FileSaver.js to automatically provide Unicode text encoding hints (see: [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark)). Note that this is only done if your blob type has `charset=utf-8` set. Examples -------- ### Saving text using `require()` ```js var FileSaver = require('file-saver'); var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); FileSaver.saveAs(blob, "hello world.txt"); ``` ### Saving text ```js var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); FileSaver.saveAs(blob, "hello world.txt"); ``` ### Saving URLs ```js FileSaver.saveAs("https://httpbin.org/image", "image.jpg"); ``` Using URLs within the same origin will just use `a[download]`. Otherwise, it will first check if it supports cors header with a synchronous head request. If it does, it will download the data and save using blob URLs. If not, it will try to download it using `a[download]`. The standard W3C File API [`Blob`][4] interface is not available in all browsers. [Blob.js][5] is a cross-browser `Blob` implementation that solves this. ### Saving a canvas ```js var canvas = document.getElementById("my-canvas"); canvas.toBlob(function(blob) { saveAs(blob, "pretty image.png"); }); ``` Note: The standard HTML5 `canvas.toBlob()` method is not available in all browsers. [canvas-toBlob.js][6] is a cross-browser `canvas.toBlob()` that polyfills this. ### Saving File You can save a File constructor without specifying a filename. If the file itself already contains a name, there is a hand full of ways to get a file instance (from storage, file input, new constructor, clipboard event). If you still want to change the name, then you can change it in the 2nd argument. ```js // Note: Ie and Edge don't support the new File constructor, // so it's better to construct blobs and use saveAs(blob, filename) var file = new File(["Hello, world!"], "hello world.txt", {type: "text/plain;charset=utf-8"}); FileSaver.saveAs(file); ``` ![Tracking image](https://in.getclicky.com/212712ns.gif) [1]: http://eligrey.com/demos/FileSaver.js/ [2]: https://github.com/eligrey/canvas-toBlob.js [3]: https://bugs.chromium.org/p/chromium/issues/detail?id=375297#c107 [4]: https://developer.mozilla.org/en-US/docs/DOM/Blob [5]: https://github.com/eligrey/Blob.js [6]: https://github.com/eligrey/canvas-toBlob.js [7]: https://github.com/jimmywarting/StreamSaver.js [8]: https://github.com/eligrey/FileSaver.js/wiki/Saving-a-remote-file#using-http-header Installation ------------------ ```bash # Basic Node.JS installation npm install file-saver --save bower install file-saver ``` Additionally, TypeScript definitions can be installed via: ```bash # Additional typescript definitions npm install @types/file-saver --save-dev ``` ================================================ FILE: vipercard/vipercard/external/base64-js-1.3.1/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2014 Jameson Little Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: vipercard/vipercard/external/base64-js-1.3.1/README.md ================================================ base64-js ========= `base64-js` does basic base64 encoding/decoding in pure JS. [![build status](https://secure.travis-ci.org/beatgammit/base64-js.png)](http://travis-ci.org/beatgammit/base64-js) Many browsers already have base64 encoding/decoding functionality, but it is for text data, not all-purpose binary data. Sometimes encoding/decoding binary data in the browser is useful, and that is what this module does. ## install With [npm](https://npmjs.org) do: `npm install base64-js` and `var base64js = require('base64-js')` For use in web browsers do: `` ## methods `base64js` has three exposed functions, `byteLength`, `toByteArray` and `fromByteArray`, which both take a single argument. * `byteLength` - Takes a base64 string and returns length of byte array * `toByteArray` - Takes a base64 string and returns a byte array * `fromByteArray` - Takes a byte array and returns a base64 string ## license MIT ================================================ FILE: vipercard/vipercard/external/base64-js-1.3.1/base64js.js ================================================ 'use strict' exports.byteLength = byteLength exports.toByteArray = toByteArray exports.fromByteArray = fromByteArray var lookup = [] var revLookup = [] var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' for (var i = 0, len = code.length; i < len; ++i) { lookup[i] = code[i] revLookup[code.charCodeAt(i)] = i } // Support decoding URL-safe base64 strings, as Node.js does. // See: https://en.wikipedia.org/wiki/Base64#URL_applications revLookup['-'.charCodeAt(0)] = 62 revLookup['_'.charCodeAt(0)] = 63 function getLens (b64) { var len = b64.length if (len % 4 > 0) { throw new Error('Invalid string. Length must be a multiple of 4') } // Trim off extra bytes after placeholder bytes are found // See: https://github.com/beatgammit/base64-js/issues/42 var validLen = b64.indexOf('=') if (validLen === -1) validLen = len var placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4) return [validLen, placeHoldersLen] } // base64 is 4/3 + up to two characters of the original data function byteLength (b64) { var lens = getLens(b64) var validLen = lens[0] var placeHoldersLen = lens[1] return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function _byteLength (b64, validLen, placeHoldersLen) { return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function toByteArray (b64) { var tmp var lens = getLens(b64) var validLen = lens[0] var placeHoldersLen = lens[1] var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) var curByte = 0 // if there are placeholders, only get up to the last complete 4 chars var len = placeHoldersLen > 0 ? validLen - 4 : validLen var i for (i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] arr[curByte++] = (tmp >> 16) & 0xFF arr[curByte++] = (tmp >> 8) & 0xFF arr[curByte++] = tmp & 0xFF } if (placeHoldersLen === 2) { tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) arr[curByte++] = tmp & 0xFF } if (placeHoldersLen === 1) { tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) arr[curByte++] = (tmp >> 8) & 0xFF arr[curByte++] = tmp & 0xFF } return arr } function tripletToBase64 (num) { return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] } function encodeChunk (uint8, start, end) { var tmp var output = [] for (var i = start; i < end; i += 3) { tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) output.push(tripletToBase64(tmp)) } return output.join('') } function fromByteArray (uint8) { var tmp var len = uint8.length var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes var parts = [] var maxChunkLength = 16383 // must be multiple of 3 // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { parts.push(encodeChunk( uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) )) } // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1] parts.push( lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3F] + '==' ) } else if (extraBytes === 2) { tmp = (uint8[len - 2] << 8) + uint8[len - 1] parts.push( lookup[tmp >> 10] + lookup[(tmp >> 4) & 0x3F] + lookup[(tmp << 2) & 0x3F] + '=' ) } return parts.join('') } ================================================ FILE: vipercard/vipercard/external/bowser-2.9/LICENSE ================================================ Copyright 2015, Dustin Diaz (the "Original Author") All rights reserved. MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Distributions of all or part of the Software intended to be used by the recipients as they would use the unmodified Software, containing modifications that substantially alter, remove, or disable functionality of the Software, outside of the documented configuration mechanisms provided by the Software, shall be modified such that the Original Author's bug reporting email addresses and urls are either replaced with the contact information of the parties responsible for the changes, or removed entirely. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except where noted, this license applies to any and all software programs and associated documentation files created by the Original Author, when distributed with the Software. ================================================ FILE: vipercard/vipercard/external/bowser-2.9/README.md ================================================ ## Bowser A small, fast and rich-API browser/platform/engine detector for both browser and node. - **Small.** Use plain ES5-version which is ~4.8kB gzipped. - **Optimized.** Use only those parsers you need — it doesn't do useless work. - **Multi-platform.** It's browser- and node-ready, so you can use it in any environment. Don't hesitate to support the project on Github or [OpenCollective](https://opencollective.com/bowser) if you like it ❤️ Also, contributors are always welcome! [![Financial Contributors on Open Collective](https://opencollective.com/bowser/all/badge.svg?label=financial+contributors)](https://opencollective.com/bowser) [![Build Status](https://travis-ci.org/lancedikson/bowser.svg?branch=master)](https://travis-ci.org/lancedikson/bowser/) [![Greenkeeper badge](https://badges.greenkeeper.io/lancedikson/bowser.svg)](https://greenkeeper.io/) [![Coverage Status](https://coveralls.io/repos/github/lancedikson/bowser/badge.svg?branch=master)](https://coveralls.io/github/lancedikson/bowser?branch=master) ![Downloads](https://img.shields.io/npm/dm/bowser) # Contents - [Overview](#overview) - [Use cases](#use-cases) - [Advanced usage](#advanced-usage) - [How can I help?](#contributing) # Overview The library is made to help to detect what browser your user has and gives you a convenient API to filter the users somehow depending on their browsers. ### ⚠️ Version 2.0 breaking changes ⚠️ Version 2.0 has drastically changed the API. All available methods are on the [docs page](https://lancedikson.github.io/bowser/docs). _For legacy code, check out the [1.x](https://github.com/lancedikson/bowser/tree/v1.x) branch and install it through `npm install bowser@1.9.4`._ # Use cases First of all, require the library. This is a UMD Module, so it will work for AMD, TypeScript, ES6, and CommonJS module systems. ```javascript const Bowser = require("bowser"); // CommonJS import * as Bowser from "bowser"; // TypeScript import Bowser from "bowser"; // ES6 (and TypeScript with --esModuleInterop enabled) ``` By default, the exported version is the *ES5 transpiled version*, which **do not** include any polyfills. In case you don't use your own `babel-polyfill` you may need to have pre-built bundle with all needed polyfills. So, for you it's suitable to require bowser like this: `require('bowser/bundled')`. As the result, you get a ES5 version of bowser with `babel-polyfill` bundled together. You may need to use the source files, so they will be available in the package as well. ## Browser props detection Often we need to pick users' browser properties such as the name, the version, the rendering engine and so on. Here is an example how to do it with Bowser: ```javascript const browser = Bowser.getParser(window.navigator.userAgent); console.log(`The current browser name is "${browser.getBrowserName()}"`); // The current browser name is "Internet Explorer" ``` or ```javascript const browser = Bowser.getParser(window.navigator.userAgent); console.log(browser.getBrowser()); // outputs { name: "Internet Explorer" version: "11.0" } ``` or ```javascript console.log(Bowser.parse(window.navigator.userAgent)); // outputs { browser: { name: "Internet Explorer" version: "11.0" }, os: { name: "Windows" version: "NT 6.3" versionName: "8.1" }, platform: { type: "desktop" }, engine: { name: "Trident" version: "7.0" } } ``` ## Filtering browsers You could want to filter some particular browsers to provide any special support for them or make any workarounds. It could look like this: ```javascript const browser = Bowser.getParser(window.navigator.userAgent); const isValidBrowser = browser.satisfies({ // declare browsers per OS windows: { "internet explorer": ">10", }, macos: { safari: ">10.1" }, // per platform (mobile, desktop or tablet) mobile: { safari: '>=9', 'android browser': '>3.10' }, // or in general chrome: "~20.1.1432", firefox: ">31", opera: ">=22", // also supports equality operator chrome: "=20.1.1432", // will match particular build only // and loose-equality operator chrome: "~20", // will match any 20.* sub-version chrome: "~20.1" // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1) }); ``` Settings for any particular OS or platform has more priority and redefines settings of standalone browsers. Thus, you can define OS or platform specific rules and they will have more priority in the end. More of API and possibilities you will find in the `docs` folder. ### Browser names for `.satisfies()` By default you are supposed to use the full browser name for `.satisfies`. But, there's a short way to define a browser using short aliases. The full list of aliases can be found in [the file](src/constants.js). ## Similar Projects * [Kong](https://github.com/BigBadBleuCheese/Kong) - A C# port of Bowser. ## Contributors ### Code Contributors This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. ### Financial Contributors Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/bowser/contribute)] #### Individuals #### Organizations Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/bowser/contribute)] ## License Licensed as MIT. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. ================================================ FILE: vipercard/vipercard/external/bowser-2.9/bowser-2.9-bundled.js ================================================ !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.bowser=n():t.bowser=n()}(this,(function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var i in t)e.d(r,i,function(n){return t[n]}.bind(null,i));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=129)}([function(t,n,e){var r=e(1),i=e(7),o=e(14),u=e(11),a=e(19),c=function(t,n,e){var s,f,l,h,d=t&c.F,p=t&c.G,v=t&c.S,g=t&c.P,y=t&c.B,m=p?r:v?r[n]||(r[n]={}):(r[n]||{}).prototype,b=p?i:i[n]||(i[n]={}),S=b.prototype||(b.prototype={});for(s in p&&(e=n),e)l=((f=!d&&m&&void 0!==m[s])?m:e)[s],h=y&&f?a(l,r):g&&"function"==typeof l?a(Function.call,l):l,m&&u(m,s,l,t&c.U),b[s]!=l&&o(b,s,h),g&&S[s]!=l&&(S[s]=l)};r.core=i,c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,t.exports=c},function(t,n){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n,e){var r=e(4);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,e){var r=e(50)("wks"),i=e(31),o=e(1).Symbol,u="function"==typeof o;(t.exports=function(t){return r[t]||(r[t]=u&&o[t]||(u?o:i)("Symbol."+t))}).store=r},function(t,n,e){var r=e(21),i=Math.min;t.exports=function(t){return t>0?i(r(t),9007199254740991):0}},function(t,n){var e=t.exports={version:"2.6.9"};"number"==typeof __e&&(__e=e)},function(t,n,e){t.exports=!e(2)((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},function(t,n,e){var r=e(3),i=e(96),o=e(28),u=Object.defineProperty;n.f=e(8)?Object.defineProperty:function(t,n,e){if(r(t),n=o(n,!0),r(e),i)try{return u(t,n,e)}catch(t){}if("get"in e||"set"in e)throw TypeError("Accessors not supported!");return"value"in e&&(t[n]=e.value),t}},function(t,n,e){var r=e(26);t.exports=function(t){return Object(r(t))}},function(t,n,e){var r=e(1),i=e(14),o=e(13),u=e(31)("src"),a=e(134),c=(""+a).split("toString");e(7).inspectSource=function(t){return a.call(t)},(t.exports=function(t,n,e,a){var s="function"==typeof e;s&&(o(e,"name")||i(e,"name",n)),t[n]!==e&&(s&&(o(e,u)||i(e,u,t[n]?""+t[n]:c.join(String(n)))),t===r?t[n]=e:a?t[n]?t[n]=e:i(t,n,e):(delete t[n],i(t,n,e)))})(Function.prototype,"toString",(function(){return"function"==typeof this&&this[u]||a.call(this)}))},function(t,n,e){var r=e(0),i=e(2),o=e(26),u=/"/g,a=function(t,n,e,r){var i=String(o(t)),a="<"+n;return""!==e&&(a+=" "+e+'="'+String(r).replace(u,""")+'"'),a+">"+i+""};t.exports=function(t,n){var e={};e[t]=n(a),r(r.P+r.F*i((function(){var n=""[t]('"');return n!==n.toLowerCase()||n.split('"').length>3})),"String",e)}},function(t,n){var e={}.hasOwnProperty;t.exports=function(t,n){return e.call(t,n)}},function(t,n,e){var r=e(9),i=e(30);t.exports=e(8)?function(t,n,e){return r.f(t,n,i(1,e))}:function(t,n,e){return t[n]=e,t}},function(t,n,e){var r=e(46),i=e(26);t.exports=function(t){return r(i(t))}},function(t,n,e){"use strict";var r=e(2);t.exports=function(t,n){return!!t&&r((function(){n?t.call(null,(function(){}),1):t.call(null)}))}},function(t,n,e){"use strict";n.__esModule=!0,n.default=void 0;var r=e(18),i=function(){function t(){}return t.getFirstMatch=function(t,n){var e=n.match(t);return e&&e.length>0&&e[1]||""},t.getSecondMatch=function(t,n){var e=n.match(t);return e&&e.length>1&&e[2]||""},t.matchAndReturnConst=function(t,n,e){if(t.test(n))return e},t.getWindowsVersionName=function(t){switch(t){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},t.getMacOSVersionName=function(t){var n=t.split(".").splice(0,2).map((function(t){return parseInt(t,10)||0}));if(n.push(0),10===n[0])switch(n[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},t.getAndroidVersionName=function(t){var n=t.split(".").splice(0,2).map((function(t){return parseInt(t,10)||0}));if(n.push(0),!(1===n[0]&&n[1]<5))return 1===n[0]&&n[1]<6?"Cupcake":1===n[0]&&n[1]>=6?"Donut":2===n[0]&&n[1]<2?"Eclair":2===n[0]&&2===n[1]?"Froyo":2===n[0]&&n[1]>2?"Gingerbread":3===n[0]?"Honeycomb":4===n[0]&&n[1]<1?"Ice Cream Sandwich":4===n[0]&&n[1]<4?"Jelly Bean":4===n[0]&&n[1]>=4?"KitKat":5===n[0]?"Lollipop":6===n[0]?"Marshmallow":7===n[0]?"Nougat":8===n[0]?"Oreo":9===n[0]?"Pie":void 0},t.getVersionPrecision=function(t){return t.split(".").length},t.compareVersions=function(n,e,r){void 0===r&&(r=!1);var i=t.getVersionPrecision(n),o=t.getVersionPrecision(e),u=Math.max(i,o),a=0,c=t.map([n,e],(function(n){var e=u-t.getVersionPrecision(n),r=n+new Array(e+1).join(".0");return t.map(r.split("."),(function(t){return new Array(20-t.length).join("0")+t})).reverse()}));for(r&&(a=u-Math.min(i,o)),u-=1;u>=a;){if(c[0][u]>c[1][u])return 1;if(c[0][u]===c[1][u]){if(u===a)return 0;u-=1}else if(c[0][u]1?i-1:0),u=1;u0?r:e)(t)}},function(t,n,e){var r=e(47),i=e(30),o=e(15),u=e(28),a=e(13),c=e(96),s=Object.getOwnPropertyDescriptor;n.f=e(8)?s:function(t,n){if(t=o(t),n=u(n,!0),c)try{return s(t,n)}catch(t){}if(a(t,n))return i(!r.f.call(t,n),t[n])}},function(t,n,e){var r=e(0),i=e(7),o=e(2);t.exports=function(t,n){var e=(i.Object||{})[t]||Object[t],u={};u[t]=n(e),r(r.S+r.F*o((function(){e(1)})),"Object",u)}},function(t,n,e){var r=e(19),i=e(46),o=e(10),u=e(6),a=e(112);t.exports=function(t,n){var e=1==t,c=2==t,s=3==t,f=4==t,l=6==t,h=5==t||l,d=n||a;return function(n,a,p){for(var v,g,y=o(n),m=i(y),b=r(a,p,3),S=u(m.length),w=0,_=e?d(n,S):c?d(n,0):void 0;S>w;w++)if((h||w in m)&&(g=b(v=m[w],w,y),t))if(e)_[w]=g;else if(g)switch(t){case 3:return!0;case 5:return v;case 6:return w;case 2:_.push(v)}else if(f)return!1;return l?-1:s||f?f:_}}},function(t,n){var e={}.toString;t.exports=function(t){return e.call(t).slice(8,-1)}},function(t,n){t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},function(t,n,e){"use strict";if(e(8)){var r=e(32),i=e(1),o=e(2),u=e(0),a=e(61),c=e(86),s=e(19),f=e(44),l=e(30),h=e(14),d=e(45),p=e(21),v=e(6),g=e(123),y=e(34),m=e(28),b=e(13),S=e(48),w=e(4),_=e(10),M=e(78),x=e(35),P=e(37),O=e(36).f,A=e(80),F=e(31),E=e(5),N=e(24),R=e(51),k=e(49),T=e(82),I=e(42),j=e(54),L=e(43),B=e(81),C=e(114),W=e(9),V=e(22),G=W.f,D=V.f,U=i.RangeError,z=i.TypeError,q=i.Uint8Array,K=Array.prototype,Y=c.ArrayBuffer,Q=c.DataView,H=N(0),J=N(2),X=N(3),Z=N(4),$=N(5),tt=N(6),nt=R(!0),et=R(!1),rt=T.values,it=T.keys,ot=T.entries,ut=K.lastIndexOf,at=K.reduce,ct=K.reduceRight,st=K.join,ft=K.sort,lt=K.slice,ht=K.toString,dt=K.toLocaleString,pt=E("iterator"),vt=E("toStringTag"),gt=F("typed_constructor"),yt=F("def_constructor"),mt=a.CONSTR,bt=a.TYPED,St=a.VIEW,wt=N(1,(function(t,n){return Ot(k(t,t[yt]),n)})),_t=o((function(){return 1===new q(new Uint16Array([1]).buffer)[0]})),Mt=!!q&&!!q.prototype.set&&o((function(){new q(1).set({})})),xt=function(t,n){var e=p(t);if(e<0||e%n)throw U("Wrong offset!");return e},Pt=function(t){if(w(t)&&bt in t)return t;throw z(t+" is not a typed array!")},Ot=function(t,n){if(!(w(t)&> in t))throw z("It is not a typed array constructor!");return new t(n)},At=function(t,n){return Ft(k(t,t[yt]),n)},Ft=function(t,n){for(var e=0,r=n.length,i=Ot(t,r);r>e;)i[e]=n[e++];return i},Et=function(t,n,e){G(t,n,{get:function(){return this._d[e]}})},Nt=function(t){var n,e,r,i,o,u,a=_(t),c=arguments.length,f=c>1?arguments[1]:void 0,l=void 0!==f,h=A(a);if(null!=h&&!M(h)){for(u=h.call(a),r=[],n=0;!(o=u.next()).done;n++)r.push(o.value);a=r}for(l&&c>2&&(f=s(f,arguments[2],2)),n=0,e=v(a.length),i=Ot(this,e);e>n;n++)i[n]=l?f(a[n],n):a[n];return i},Rt=function(){for(var t=0,n=arguments.length,e=Ot(this,n);n>t;)e[t]=arguments[t++];return e},kt=!!q&&o((function(){dt.call(new q(1))})),Tt=function(){return dt.apply(kt?lt.call(Pt(this)):Pt(this),arguments)},It={copyWithin:function(t,n){return C.call(Pt(this),t,n,arguments.length>2?arguments[2]:void 0)},every:function(t){return Z(Pt(this),t,arguments.length>1?arguments[1]:void 0)},fill:function(t){return B.apply(Pt(this),arguments)},filter:function(t){return At(this,J(Pt(this),t,arguments.length>1?arguments[1]:void 0))},find:function(t){return $(Pt(this),t,arguments.length>1?arguments[1]:void 0)},findIndex:function(t){return tt(Pt(this),t,arguments.length>1?arguments[1]:void 0)},forEach:function(t){H(Pt(this),t,arguments.length>1?arguments[1]:void 0)},indexOf:function(t){return et(Pt(this),t,arguments.length>1?arguments[1]:void 0)},includes:function(t){return nt(Pt(this),t,arguments.length>1?arguments[1]:void 0)},join:function(t){return st.apply(Pt(this),arguments)},lastIndexOf:function(t){return ut.apply(Pt(this),arguments)},map:function(t){return wt(Pt(this),t,arguments.length>1?arguments[1]:void 0)},reduce:function(t){return at.apply(Pt(this),arguments)},reduceRight:function(t){return ct.apply(Pt(this),arguments)},reverse:function(){for(var t,n=Pt(this).length,e=Math.floor(n/2),r=0;r1?arguments[1]:void 0)},sort:function(t){return ft.call(Pt(this),t)},subarray:function(t,n){var e=Pt(this),r=e.length,i=y(t,r);return new(k(e,e[yt]))(e.buffer,e.byteOffset+i*e.BYTES_PER_ELEMENT,v((void 0===n?r:y(n,r))-i))}},jt=function(t,n){return At(this,lt.call(Pt(this),t,n))},Lt=function(t){Pt(this);var n=xt(arguments[1],1),e=this.length,r=_(t),i=v(r.length),o=0;if(i+n>e)throw U("Wrong length!");for(;o255?255:255&r),i.v[d](e*n+i.o,r,_t)}(this,e,t)},enumerable:!0})};b?(p=e((function(t,e,r,i){f(t,p,s,"_d");var o,u,a,c,l=0,d=0;if(w(e)){if(!(e instanceof Y||"ArrayBuffer"==(c=S(e))||"SharedArrayBuffer"==c))return bt in e?Ft(p,e):Nt.call(p,e);o=e,d=xt(r,n);var y=e.byteLength;if(void 0===i){if(y%n)throw U("Wrong length!");if((u=y-d)<0)throw U("Wrong length!")}else if((u=v(i)*n)+d>y)throw U("Wrong length!");a=u/n}else a=g(e),o=new Y(u=a*n);for(h(t,"_d",{b:o,o:d,l:u,e:a,v:new Q(o)});ldocument.F=Object<\/script>"),t.close(),c=t.F;r--;)delete c.prototype[o[r]];return c()};t.exports=Object.create||function(t,n){var e;return null!==t?(a.prototype=r(t),e=new a,a.prototype=null,e[u]=t):e=c(),void 0===n?e:i(e,n)}},function(t,n,e){var r=e(98),i=e(65).concat("length","prototype");n.f=Object.getOwnPropertyNames||function(t){return r(t,i)}},function(t,n,e){var r=e(13),i=e(10),o=e(64)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=i(t),r(t,o)?t[o]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n,e){var r=e(5)("unscopables"),i=Array.prototype;null==i[r]&&e(14)(i,r,{}),t.exports=function(t){i[r][t]=!0}},function(t,n,e){var r=e(4);t.exports=function(t,n){if(!r(t)||t._t!==n)throw TypeError("Incompatible receiver, "+n+" required!");return t}},function(t,n,e){var r=e(9).f,i=e(13),o=e(5)("toStringTag");t.exports=function(t,n,e){t&&!i(t=e?t:t.prototype,o)&&r(t,o,{configurable:!0,value:n})}},function(t,n,e){var r=e(0),i=e(26),o=e(2),u=e(68),a="["+u+"]",c=RegExp("^"+a+a+"*"),s=RegExp(a+a+"*$"),f=function(t,n,e){var i={},a=o((function(){return!!u[t]()||"​…"!="​…"[t]()})),c=i[t]=a?n(l):u[t];e&&(i[e]=c),r(r.P+r.F*a,"String",i)},l=f.trim=function(t,n){return t=String(i(t)),1&n&&(t=t.replace(c,"")),2&n&&(t=t.replace(s,"")),t};t.exports=f},function(t,n){t.exports={}},function(t,n,e){"use strict";var r=e(1),i=e(9),o=e(8),u=e(5)("species");t.exports=function(t){var n=r[t];o&&n&&!n[u]&&i.f(n,u,{configurable:!0,get:function(){return this}})}},function(t,n){t.exports=function(t,n,e,r){if(!(t instanceof n)||void 0!==r&&r in t)throw TypeError(e+": incorrect invocation!");return t}},function(t,n,e){var r=e(11);t.exports=function(t,n,e){for(var i in n)r(t,i,n[i],e);return t}},function(t,n,e){var r=e(25);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,e){var r=e(25),i=e(5)("toStringTag"),o="Arguments"==r(function(){return arguments}());t.exports=function(t){var n,e,u;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=function(t,n){try{return t[n]}catch(t){}}(n=Object(t),i))?e:o?r(n):"Object"==(u=r(n))&&"function"==typeof n.callee?"Arguments":u}},function(t,n,e){var r=e(3),i=e(20),o=e(5)("species");t.exports=function(t,n){var e,u=r(t).constructor;return void 0===u||null==(e=r(u)[o])?n:i(e)}},function(t,n,e){var r=e(7),i=e(1),o=i["__core-js_shared__"]||(i["__core-js_shared__"]={});(t.exports=function(t,n){return o[t]||(o[t]=void 0!==n?n:{})})("versions",[]).push({version:r.version,mode:e(32)?"pure":"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})},function(t,n,e){var r=e(15),i=e(6),o=e(34);t.exports=function(t){return function(n,e,u){var a,c=r(n),s=i(c.length),f=o(u,s);if(t&&e!=e){for(;s>f;)if((a=c[f++])!=a)return!0}else for(;s>f;f++)if((t||f in c)&&c[f]===e)return t||f||0;return!t&&-1}}},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n,e){var r=e(25);t.exports=Array.isArray||function(t){return"Array"==r(t)}},function(t,n,e){var r=e(5)("iterator"),i=!1;try{var o=[7][r]();o.return=function(){i=!0},Array.from(o,(function(){throw 2}))}catch(t){}t.exports=function(t,n){if(!n&&!i)return!1;var e=!1;try{var o=[7],u=o[r]();u.next=function(){return{done:e=!0}},o[r]=function(){return u},t(o)}catch(t){}return e}},function(t,n,e){"use strict";var r=e(3);t.exports=function(){var t=r(this),n="";return t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.unicode&&(n+="u"),t.sticky&&(n+="y"),n}},function(t,n,e){"use strict";var r=e(48),i=RegExp.prototype.exec;t.exports=function(t,n){var e=t.exec;if("function"==typeof e){var o=e.call(t,n);if("object"!=typeof o)throw new TypeError("RegExp exec method returned something other than an Object or null");return o}if("RegExp"!==r(t))throw new TypeError("RegExp#exec called on incompatible receiver");return i.call(t,n)}},function(t,n,e){"use strict";e(116);var r=e(11),i=e(14),o=e(2),u=e(26),a=e(5),c=e(83),s=a("species"),f=!o((function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$")})),l=function(){var t=/(?:)/,n=t.exec;t.exec=function(){return n.apply(this,arguments)};var e="ab".split(t);return 2===e.length&&"a"===e[0]&&"b"===e[1]}();t.exports=function(t,n,e){var h=a(t),d=!o((function(){var n={};return n[h]=function(){return 7},7!=""[t](n)})),p=d?!o((function(){var n=!1,e=/a/;return e.exec=function(){return n=!0,null},"split"===t&&(e.constructor={},e.constructor[s]=function(){return e}),e[h](""),!n})):void 0;if(!d||!p||"replace"===t&&!f||"split"===t&&!l){var v=/./[h],g=e(u,h,""[t],(function(t,n,e,r,i){return n.exec===c?d&&!i?{done:!0,value:v.call(n,e,r)}:{done:!0,value:t.call(e,n,r)}:{done:!1}})),y=g[0],m=g[1];r(String.prototype,t,y),i(RegExp.prototype,h,2==n?function(t,n){return m.call(t,this,n)}:function(t){return m.call(t,this)})}}},function(t,n,e){var r=e(19),i=e(111),o=e(78),u=e(3),a=e(6),c=e(80),s={},f={};(n=t.exports=function(t,n,e,l,h){var d,p,v,g,y=h?function(){return t}:c(t),m=r(e,l,n?2:1),b=0;if("function"!=typeof y)throw TypeError(t+" is not iterable!");if(o(y)){for(d=a(t.length);d>b;b++)if((g=n?m(u(p=t[b])[0],p[1]):m(t[b]))===s||g===f)return g}else for(v=y.call(t);!(p=v.next()).done;)if((g=i(v,m,p.value,n))===s||g===f)return g}).BREAK=s,n.RETURN=f},function(t,n,e){var r=e(1).navigator;t.exports=r&&r.userAgent||""},function(t,n,e){"use strict";var r=e(1),i=e(0),o=e(11),u=e(45),a=e(29),c=e(58),s=e(44),f=e(4),l=e(2),h=e(54),d=e(40),p=e(69);t.exports=function(t,n,e,v,g,y){var m=r[t],b=m,S=g?"set":"add",w=b&&b.prototype,_={},M=function(t){var n=w[t];o(w,t,"delete"==t?function(t){return!(y&&!f(t))&&n.call(this,0===t?0:t)}:"has"==t?function(t){return!(y&&!f(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return y&&!f(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function(t){return n.call(this,0===t?0:t),this}:function(t,e){return n.call(this,0===t?0:t,e),this})};if("function"==typeof b&&(y||w.forEach&&!l((function(){(new b).entries().next()})))){var x=new b,P=x[S](y?{}:-0,1)!=x,O=l((function(){x.has(1)})),A=h((function(t){new b(t)})),F=!y&&l((function(){for(var t=new b,n=5;n--;)t[S](n,n);return!t.has(-0)}));A||((b=n((function(n,e){s(n,b,t);var r=p(new m,n,b);return null!=e&&c(e,g,r[S],r),r}))).prototype=w,w.constructor=b),(O||F)&&(M("delete"),M("has"),g&&M("get")),(F||P)&&M(S),y&&w.clear&&delete w.clear}else b=v.getConstructor(n,t,g,S),u(b.prototype,e),a.NEED=!0;return d(b,t),_[t]=b,i(i.G+i.W+i.F*(b!=m),_),y||v.setStrong(b,t,g),b}},function(t,n,e){for(var r,i=e(1),o=e(14),u=e(31),a=u("typed_array"),c=u("view"),s=!(!i.ArrayBuffer||!i.DataView),f=s,l=0,h="Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array".split(",");l<9;)(r=i[h[l++]])?(o(r.prototype,a,!0),o(r.prototype,c,!0)):f=!1;t.exports={ABV:s,CONSTR:f,TYPED:a,VIEW:c}},function(t,n,e){var r=e(4),i=e(1).document,o=r(i)&&r(i.createElement);t.exports=function(t){return o?i.createElement(t):{}}},function(t,n,e){n.f=e(5)},function(t,n,e){var r=e(50)("keys"),i=e(31);t.exports=function(t){return r[t]||(r[t]=i(t))}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,e){var r=e(1).document;t.exports=r&&r.documentElement},function(t,n,e){var r=e(4),i=e(3),o=function(t,n){if(i(t),!r(n)&&null!==n)throw TypeError(n+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n,r){try{(r=e(19)(Function.call,e(22).f(Object.prototype,"__proto__").set,2))(t,[]),n=!(t instanceof Array)}catch(t){n=!0}return function(t,e){return o(t,e),n?t.__proto__=e:r(t,e),t}}({},!1):void 0),check:o}},function(t,n){t.exports="\t\n\v\f\r   ᠎              \u2028\u2029\ufeff"},function(t,n,e){var r=e(4),i=e(67).set;t.exports=function(t,n,e){var o,u=n.constructor;return u!==e&&"function"==typeof u&&(o=u.prototype)!==e.prototype&&r(o)&&i&&i(t,o),t}},function(t,n,e){"use strict";var r=e(21),i=e(26);t.exports=function(t){var n=String(i(this)),e="",o=r(t);if(o<0||o==1/0)throw RangeError("Count can't be negative");for(;o>0;(o>>>=1)&&(n+=n))1&o&&(e+=n);return e}},function(t,n){t.exports=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1}},function(t,n){var e=Math.expm1;t.exports=!e||e(10)>22025.465794806718||e(10)<22025.465794806718||-2e-17!=e(-2e-17)?function(t){return 0==(t=+t)?t:t>-1e-6&&t<1e-6?t+t*t/2:Math.exp(t)-1}:e},function(t,n,e){var r=e(21),i=e(26);t.exports=function(t){return function(n,e){var o,u,a=String(i(n)),c=r(e),s=a.length;return c<0||c>=s?t?"":void 0:(o=a.charCodeAt(c))<55296||o>56319||c+1===s||(u=a.charCodeAt(c+1))<56320||u>57343?t?a.charAt(c):o:t?a.slice(c,c+2):u-56320+(o-55296<<10)+65536}}},function(t,n,e){"use strict";var r=e(32),i=e(0),o=e(11),u=e(14),a=e(42),c=e(110),s=e(40),f=e(37),l=e(5)("iterator"),h=!([].keys&&"next"in[].keys()),d=function(){return this};t.exports=function(t,n,e,p,v,g,y){c(e,n,p);var m,b,S,w=function(t){if(!h&&t in P)return P[t];switch(t){case"keys":case"values":return function(){return new e(this,t)}}return function(){return new e(this,t)}},_=n+" Iterator",M="values"==v,x=!1,P=t.prototype,O=P[l]||P["@@iterator"]||v&&P[v],A=O||w(v),F=v?M?w("entries"):A:void 0,E="Array"==n&&P.entries||O;if(E&&(S=f(E.call(new t)))!==Object.prototype&&S.next&&(s(S,_,!0),r||"function"==typeof S[l]||u(S,l,d)),M&&O&&"values"!==O.name&&(x=!0,A=function(){return O.call(this)}),r&&!y||!h&&!x&&P[l]||u(P,l,A),a[n]=A,a[_]=d,v)if(m={values:M?A:w("values"),keys:g?A:w("keys"),entries:F},y)for(b in m)b in P||o(P,b,m[b]);else i(i.P+i.F*(h||x),n,m);return m}},function(t,n,e){var r=e(76),i=e(26);t.exports=function(t,n,e){if(r(n))throw TypeError("String#"+e+" doesn't accept regex!");return String(i(t))}},function(t,n,e){var r=e(4),i=e(25),o=e(5)("match");t.exports=function(t){var n;return r(t)&&(void 0!==(n=t[o])?!!n:"RegExp"==i(t))}},function(t,n,e){var r=e(5)("match");t.exports=function(t){var n=/./;try{"/./"[t](n)}catch(e){try{return n[r]=!1,!"/./"[t](n)}catch(t){}}return!0}},function(t,n,e){var r=e(42),i=e(5)("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(r.Array===t||o[i]===t)}},function(t,n,e){"use strict";var r=e(9),i=e(30);t.exports=function(t,n,e){n in t?r.f(t,n,i(0,e)):t[n]=e}},function(t,n,e){var r=e(48),i=e(5)("iterator"),o=e(42);t.exports=e(7).getIteratorMethod=function(t){if(null!=t)return t[i]||t["@@iterator"]||o[r(t)]}},function(t,n,e){"use strict";var r=e(10),i=e(34),o=e(6);t.exports=function(t){for(var n=r(this),e=o(n.length),u=arguments.length,a=i(u>1?arguments[1]:void 0,e),c=u>2?arguments[2]:void 0,s=void 0===c?e:i(c,e);s>a;)n[a++]=t;return n}},function(t,n,e){"use strict";var r=e(38),i=e(115),o=e(42),u=e(15);t.exports=e(74)(Array,"Array",(function(t,n){this._t=u(t),this._i=0,this._k=n}),(function(){var t=this._t,n=this._k,e=this._i++;return!t||e>=t.length?(this._t=void 0,i(1)):i(0,"keys"==n?e:"values"==n?t[e]:[e,t[e]])}),"values"),o.Arguments=o.Array,r("keys"),r("values"),r("entries")},function(t,n,e){"use strict";var r,i,o=e(55),u=RegExp.prototype.exec,a=String.prototype.replace,c=u,s=(r=/a/,i=/b*/g,u.call(r,"a"),u.call(i,"a"),0!==r.lastIndex||0!==i.lastIndex),f=void 0!==/()??/.exec("")[1];(s||f)&&(c=function(t){var n,e,r,i,c=this;return f&&(e=new RegExp("^"+c.source+"$(?!\\s)",o.call(c))),s&&(n=c.lastIndex),r=u.call(c,t),s&&r&&(c.lastIndex=c.global?r.index+r[0].length:n),f&&r&&r.length>1&&a.call(r[0],e,(function(){for(i=1;ie;)n.push(arguments[e++]);return y[++g]=function(){a("function"==typeof t?t:Function(t),n)},r(g),g},d=function(t){delete y[t]},"process"==e(25)(l)?r=function(t){l.nextTick(u(m,t,1))}:v&&v.now?r=function(t){v.now(u(m,t,1))}:p?(o=(i=new p).port2,i.port1.onmessage=b,r=u(o.postMessage,o,1)):f.addEventListener&&"function"==typeof postMessage&&!f.importScripts?(r=function(t){f.postMessage(t+"","*")},f.addEventListener("message",b,!1)):r="onreadystatechange"in s("script")?function(t){c.appendChild(s("script")).onreadystatechange=function(){c.removeChild(this),m.call(t)}}:function(t){setTimeout(u(m,t,1),0)}),t.exports={set:h,clear:d}},function(t,n,e){"use strict";var r=e(1),i=e(8),o=e(32),u=e(61),a=e(14),c=e(45),s=e(2),f=e(44),l=e(21),h=e(6),d=e(123),p=e(36).f,v=e(9).f,g=e(81),y=e(40),m="prototype",b="Wrong index!",S=r.ArrayBuffer,w=r.DataView,_=r.Math,M=r.RangeError,x=r.Infinity,P=S,O=_.abs,A=_.pow,F=_.floor,E=_.log,N=_.LN2,R=i?"_b":"buffer",k=i?"_l":"byteLength",T=i?"_o":"byteOffset";function I(t,n,e){var r,i,o,u=new Array(e),a=8*e-n-1,c=(1<>1,f=23===n?A(2,-24)-A(2,-77):0,l=0,h=t<0||0===t&&1/t<0?1:0;for((t=O(t))!=t||t===x?(i=t!=t?1:0,r=c):(r=F(E(t)/N),t*(o=A(2,-r))<1&&(r--,o*=2),(t+=r+s>=1?f/o:f*A(2,1-s))*o>=2&&(r++,o/=2),r+s>=c?(i=0,r=c):r+s>=1?(i=(t*o-1)*A(2,n),r+=s):(i=t*A(2,s-1)*A(2,n),r=0));n>=8;u[l++]=255&i,i/=256,n-=8);for(r=r<0;u[l++]=255&r,r/=256,a-=8);return u[--l]|=128*h,u}function j(t,n,e){var r,i=8*e-n-1,o=(1<>1,a=i-7,c=e-1,s=t[c--],f=127&s;for(s>>=7;a>0;f=256*f+t[c],c--,a-=8);for(r=f&(1<<-a)-1,f>>=-a,a+=n;a>0;r=256*r+t[c],c--,a-=8);if(0===f)f=1-u;else{if(f===o)return r?NaN:s?-x:x;r+=A(2,n),f-=u}return(s?-1:1)*r*A(2,f-n)}function L(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]}function B(t){return[255&t]}function C(t){return[255&t,t>>8&255]}function W(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]}function V(t){return I(t,52,8)}function G(t){return I(t,23,4)}function D(t,n,e){v(t[m],n,{get:function(){return this[e]}})}function U(t,n,e,r){var i=d(+e);if(i+n>t[k])throw M(b);var o=t[R]._b,u=i+t[T],a=o.slice(u,u+n);return r?a:a.reverse()}function z(t,n,e,r,i,o){var u=d(+e);if(u+n>t[k])throw M(b);for(var a=t[R]._b,c=u+t[T],s=r(+i),f=0;fQ;)(q=Y[Q++])in S||a(S,q,P[q]);o||(K.constructor=S)}var H=new w(new S(2)),J=w[m].setInt8;H.setInt8(0,2147483648),H.setInt8(1,2147483649),!H.getInt8(0)&&H.getInt8(1)||c(w[m],{setInt8:function(t,n){J.call(this,t,n<<24>>24)},setUint8:function(t,n){J.call(this,t,n<<24>>24)}},!0)}else S=function(t){f(this,S,"ArrayBuffer");var n=d(t);this._b=g.call(new Array(n),0),this[k]=n},w=function(t,n,e){f(this,w,"DataView"),f(t,S,"DataView");var r=t[k],i=l(n);if(i<0||i>r)throw M("Wrong offset!");if(i+(e=void 0===e?r-i:h(e))>r)throw M("Wrong length!");this[R]=t,this[T]=i,this[k]=e},i&&(D(S,"byteLength","_l"),D(w,"buffer","_b"),D(w,"byteLength","_l"),D(w,"byteOffset","_o")),c(w[m],{getInt8:function(t){return U(this,1,t)[0]<<24>>24},getUint8:function(t){return U(this,1,t)[0]},getInt16:function(t){var n=U(this,2,t,arguments[1]);return(n[1]<<8|n[0])<<16>>16},getUint16:function(t){var n=U(this,2,t,arguments[1]);return n[1]<<8|n[0]},getInt32:function(t){return L(U(this,4,t,arguments[1]))},getUint32:function(t){return L(U(this,4,t,arguments[1]))>>>0},getFloat32:function(t){return j(U(this,4,t,arguments[1]),23,4)},getFloat64:function(t){return j(U(this,8,t,arguments[1]),52,8)},setInt8:function(t,n){z(this,1,t,B,n)},setUint8:function(t,n){z(this,1,t,B,n)},setInt16:function(t,n){z(this,2,t,C,n,arguments[2])},setUint16:function(t,n){z(this,2,t,C,n,arguments[2])},setInt32:function(t,n){z(this,4,t,W,n,arguments[2])},setUint32:function(t,n){z(this,4,t,W,n,arguments[2])},setFloat32:function(t,n){z(this,4,t,G,n,arguments[2])},setFloat64:function(t,n){z(this,8,t,V,n,arguments[2])}});y(S,"ArrayBuffer"),y(w,"DataView"),a(w[m],u.VIEW,!0),n.ArrayBuffer=S,n.DataView=w},function(t,n){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,e){t.exports=!e(128)((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},function(t,n,e){"use strict";n.__esModule=!0,n.default=void 0;var r,i=(r=e(91))&&r.__esModule?r:{default:r},o=e(18);function u(t,n){for(var e=0;e0){var u=Object.keys(e),c=a.default.find(u,(function(t){return n.isOS(t)}));if(c){var s=this.satisfies(e[c]);if(void 0!==s)return s}var f=a.default.find(u,(function(t){return n.isPlatform(t)}));if(f){var l=this.satisfies(e[f]);if(void 0!==l)return l}}if(o>0){var h=Object.keys(i),d=a.default.find(h,(function(t){return n.isBrowser(t,!0)}));if(void 0!==d)return this.compareVersion(i[d])}},n.isBrowser=function(t,n){void 0===n&&(n=!1);var e=this.getBrowserName().toLowerCase(),r=t.toLowerCase(),i=a.default.getBrowserTypeByAlias(r);return n&&i&&(r=i.toLowerCase()),r===e},n.compareVersion=function(t){var n=[0],e=t,r=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===t[0]||"<"===t[0]?(e=t.substr(1),"="===t[1]?(r=!0,e=t.substr(2)):n=[],">"===t[0]?n.push(1):n.push(-1)):"="===t[0]?e=t.substr(1):"~"===t[0]&&(r=!0,e=t.substr(1)),n.indexOf(a.default.compareVersions(i,e,r))>-1},n.isOS=function(t){return this.getOSName(!0)===String(t).toLowerCase()},n.isPlatform=function(t){return this.getPlatformType(!0)===String(t).toLowerCase()},n.isEngine=function(t){return this.getEngineName(!0)===String(t).toLowerCase()},n.is=function(t){return this.isBrowser(t)||this.isOS(t)||this.isPlatform(t)},n.some=function(t){var n=this;return void 0===t&&(t=[]),t.some((function(t){return n.is(t)}))},t}();n.default=s,t.exports=n.default},function(t,n,e){"use strict";n.__esModule=!0,n.default=void 0;var r,i=(r=e(17))&&r.__esModule?r:{default:r};var o=/version\/(\d+(\.?_?\d+)+)/i,u=[{test:[/googlebot/i],describe:function(t){var n={name:"Googlebot"},e=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,t)||i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/opera/i],describe:function(t){var n={name:"Opera"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/opr\/|opios/i],describe:function(t){var n={name:"Opera"},e=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,t)||i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/SamsungBrowser/i],describe:function(t){var n={name:"Samsung Internet for Android"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/Whale/i],describe:function(t){var n={name:"NAVER Whale Browser"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/MZBrowser/i],describe:function(t){var n={name:"MZ Browser"},e=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,t)||i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/focus/i],describe:function(t){var n={name:"Focus"},e=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,t)||i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/swing/i],describe:function(t){var n={name:"Swing"},e=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,t)||i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/coast/i],describe:function(t){var n={name:"Opera Coast"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/yabrowser/i],describe:function(t){var n={name:"Yandex Browser"},e=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,t)||i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/ucbrowser/i],describe:function(t){var n={name:"UC Browser"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/Maxthon|mxios/i],describe:function(t){var n={name:"Maxthon"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/epiphany/i],describe:function(t){var n={name:"Epiphany"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/puffin/i],describe:function(t){var n={name:"Puffin"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/sleipnir/i],describe:function(t){var n={name:"Sleipnir"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/k-meleon/i],describe:function(t){var n={name:"K-Meleon"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/micromessenger/i],describe:function(t){var n={name:"WeChat"},e=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,t)||i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/qqbrowser/i],describe:function(t){var n={name:/qqbrowserlite/i.test(t)?"QQ Browser Lite":"QQ Browser"},e=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,t)||i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/msie|trident/i],describe:function(t){var n={name:"Internet Explorer"},e=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/\sedg\//i],describe:function(t){var n={name:"Microsoft Edge"},e=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/edg([ea]|ios)/i],describe:function(t){var n={name:"Microsoft Edge"},e=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/vivaldi/i],describe:function(t){var n={name:"Vivaldi"},e=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/seamonkey/i],describe:function(t){var n={name:"SeaMonkey"},e=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/sailfish/i],describe:function(t){var n={name:"Sailfish"},e=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,t);return e&&(n.version=e),n}},{test:[/silk/i],describe:function(t){var n={name:"Amazon Silk"},e=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/phantom/i],describe:function(t){var n={name:"PhantomJS"},e=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/slimerjs/i],describe:function(t){var n={name:"SlimerJS"},e=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(t){var n={name:"BlackBerry"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/(web|hpw)[o0]s/i],describe:function(t){var n={name:"WebOS Browser"},e=i.default.getFirstMatch(o,t)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/bada/i],describe:function(t){var n={name:"Bada"},e=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/tizen/i],describe:function(t){var n={name:"Tizen"},e=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,t)||i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/qupzilla/i],describe:function(t){var n={name:"QupZilla"},e=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,t)||i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var n={name:"Firefox"},e=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/electron/i],describe:function(t){var n={name:"Electron"},e=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/chromium/i],describe:function(t){var n={name:"Chromium"},e=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/chrome|crios|crmo/i],describe:function(t){var n={name:"Chrome"},e=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/GSA/i],describe:function(t){var n={name:"Google Search"},e=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:function(t){var n=!t.test(/like android/i),e=t.test(/android/i);return n&&e},describe:function(t){var n={name:"Android Browser"},e=i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/playstation 4/i],describe:function(t){var n={name:"PlayStation 4"},e=i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/safari|applewebkit/i],describe:function(t){var n={name:"Safari"},e=i.default.getFirstMatch(o,t);return e&&(n.version=e),n}},{test:[/.*/i],describe:function(t){var n=-1!==t.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(n,t),version:i.default.getSecondMatch(n,t)}}}];n.default=u,t.exports=n.default},function(t,n,e){"use strict";n.__esModule=!0,n.default=void 0;var r,i=(r=e(17))&&r.__esModule?r:{default:r},o=e(18);var u=[{test:[/Roku\/DVP/],describe:function(t){var n=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,t);return{name:o.OS_MAP.Roku,version:n}}},{test:[/windows phone/i],describe:function(t){var n=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,t);return{name:o.OS_MAP.WindowsPhone,version:n}}},{test:[/windows /i],describe:function(t){var n=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,t),e=i.default.getWindowsVersionName(n);return{name:o.OS_MAP.Windows,version:n,versionName:e}}},{test:[/Macintosh(.*?) FxiOS(.*?) Version\//],describe:function(t){var n=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,t);return{name:o.OS_MAP.iOS,version:n}}},{test:[/macintosh/i],describe:function(t){var n=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,t).replace(/[_\s]/g,"."),e=i.default.getMacOSVersionName(n),r={name:o.OS_MAP.MacOS,version:n};return e&&(r.versionName=e),r}},{test:[/(ipod|iphone|ipad)/i],describe:function(t){var n=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,t).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:n}}},{test:function(t){var n=!t.test(/like android/i),e=t.test(/android/i);return n&&e},describe:function(t){var n=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,t),e=i.default.getAndroidVersionName(n),r={name:o.OS_MAP.Android,version:n};return e&&(r.versionName=e),r}},{test:[/(web|hpw)[o0]s/i],describe:function(t){var n=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,t),e={name:o.OS_MAP.WebOS};return n&&n.length&&(e.version=n),e}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(t){var n=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,t)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,t)||i.default.getFirstMatch(/\bbb(\d+)/i,t);return{name:o.OS_MAP.BlackBerry,version:n}}},{test:[/bada/i],describe:function(t){var n=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,t);return{name:o.OS_MAP.Bada,version:n}}},{test:[/tizen/i],describe:function(t){var n=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,t);return{name:o.OS_MAP.Tizen,version:n}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(t){var n=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,t);return{name:o.OS_MAP.PlayStation4,version:n}}}];n.default=u,t.exports=n.default},function(t,n,e){"use strict";n.__esModule=!0,n.default=void 0;var r,i=(r=e(17))&&r.__esModule?r:{default:r},o=e(18);var u=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(t){var n=i.default.getFirstMatch(/(can-l01)/i,t)&&"Nova",e={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return n&&(e.model=n),e}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?) Version\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(t){var n=t.test(/ipod|iphone/i),e=t.test(/like (ipod|iphone)/i);return n&&!e},describe:function(t){var n=i.default.getFirstMatch(/(ipod|iphone)/i,t);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:n}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(t){return"blackberry"===t.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(t){return"bada"===t.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(t){return"windows phone"===t.getBrowserName()},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(t){var n=Number(String(t.getOSVersion()).split(".")[0]);return"android"===t.getOSName(!0)&&n>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(t){return"android"===t.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(t){return"macos"===t.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(t){return"windows"===t.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(t){return"linux"===t.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(t){return"playstation 4"===t.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(t){return"roku"===t.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];n.default=u,t.exports=n.default},function(t,n,e){"use strict";n.__esModule=!0,n.default=void 0;var r,i=(r=e(17))&&r.__esModule?r:{default:r},o=e(18);var u=[{test:function(t){return"microsoft edge"===t.getBrowserName(!0)},describe:function(t){if(/\sedg\//i.test(t))return{name:o.ENGINE_MAP.Blink};var n=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,t);return{name:o.ENGINE_MAP.EdgeHTML,version:n}}},{test:[/trident/i],describe:function(t){var n={name:o.ENGINE_MAP.Trident},e=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:function(t){return t.test(/presto/i)},describe:function(t){var n={name:o.ENGINE_MAP.Presto},e=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:function(t){var n=t.test(/gecko/i),e=t.test(/like gecko/i);return n&&!e},describe:function(t){var n={name:o.ENGINE_MAP.Gecko},e=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(t){var n={name:o.ENGINE_MAP.WebKit},e=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,t);return e&&(n.version=e),n}}];n.default=u,t.exports=n.default},function(t,n,e){t.exports=!e(8)&&!e(2)((function(){return 7!=Object.defineProperty(e(62)("div"),"a",{get:function(){return 7}}).a}))},function(t,n,e){var r=e(1),i=e(7),o=e(32),u=e(63),a=e(9).f;t.exports=function(t){var n=i.Symbol||(i.Symbol=o?{}:r.Symbol||{});"_"==t.charAt(0)||t in n||a(n,t,{value:u.f(t)})}},function(t,n,e){var r=e(13),i=e(15),o=e(51)(!1),u=e(64)("IE_PROTO");t.exports=function(t,n){var e,a=i(t),c=0,s=[];for(e in a)e!=u&&r(a,e)&&s.push(e);for(;n.length>c;)r(a,e=n[c++])&&(~o(s,e)||s.push(e));return s}},function(t,n,e){var r=e(9),i=e(3),o=e(33);t.exports=e(8)?Object.defineProperties:function(t,n){i(t);for(var e,u=o(n),a=u.length,c=0;a>c;)r.f(t,e=u[c++],n[e]);return t}},function(t,n,e){var r=e(15),i=e(36).f,o={}.toString,u="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(t){return u&&"[object Window]"==o.call(t)?function(t){try{return i(t)}catch(t){return u.slice()}}(t):i(r(t))}},function(t,n,e){"use strict";var r=e(8),i=e(33),o=e(52),u=e(47),a=e(10),c=e(46),s=Object.assign;t.exports=!s||e(2)((function(){var t={},n={},e=Symbol(),r="abcdefghijklmnopqrst";return t[e]=7,r.split("").forEach((function(t){n[t]=t})),7!=s({},t)[e]||Object.keys(s({},n)).join("")!=r}))?function(t,n){for(var e=a(t),s=arguments.length,f=1,l=o.f,h=u.f;s>f;)for(var d,p=c(arguments[f++]),v=l?i(p).concat(l(p)):i(p),g=v.length,y=0;g>y;)d=v[y++],r&&!h.call(p,d)||(e[d]=p[d]);return e}:s},function(t,n){t.exports=Object.is||function(t,n){return t===n?0!==t||1/t==1/n:t!=t&&n!=n}},function(t,n,e){"use strict";var r=e(20),i=e(4),o=e(104),u=[].slice,a={},c=function(t,n,e){if(!(n in a)){for(var r=[],i=0;i>>0||(u.test(e)?16:10))}:r},function(t,n,e){var r=e(1).parseFloat,i=e(41).trim;t.exports=1/r(e(68)+"-0")!=-1/0?function(t){var n=i(String(t),3),e=r(n);return 0===e&&"-"==n.charAt(0)?-0:e}:r},function(t,n,e){var r=e(25);t.exports=function(t,n){if("number"!=typeof t&&"Number"!=r(t))throw TypeError(n);return+t}},function(t,n,e){var r=e(4),i=Math.floor;t.exports=function(t){return!r(t)&&isFinite(t)&&i(t)===t}},function(t,n){t.exports=Math.log1p||function(t){return(t=+t)>-1e-8&&t<1e-8?t-t*t/2:Math.log(1+t)}},function(t,n,e){"use strict";var r=e(35),i=e(30),o=e(40),u={};e(14)(u,e(5)("iterator"),(function(){return this})),t.exports=function(t,n,e){t.prototype=r(u,{next:i(1,e)}),o(t,n+" Iterator")}},function(t,n,e){var r=e(3);t.exports=function(t,n,e,i){try{return i?n(r(e)[0],e[1]):n(e)}catch(n){var o=t.return;throw void 0!==o&&r(o.call(t)),n}}},function(t,n,e){var r=e(224);t.exports=function(t,n){return new(r(t))(n)}},function(t,n,e){var r=e(20),i=e(10),o=e(46),u=e(6);t.exports=function(t,n,e,a,c){r(n);var s=i(t),f=o(s),l=u(s.length),h=c?l-1:0,d=c?-1:1;if(e<2)for(;;){if(h in f){a=f[h],h+=d;break}if(h+=d,c?h<0:l<=h)throw TypeError("Reduce of empty array with no initial value")}for(;c?h>=0:l>h;h+=d)h in f&&(a=n(a,f[h],h,s));return a}},function(t,n,e){"use strict";var r=e(10),i=e(34),o=e(6);t.exports=[].copyWithin||function(t,n){var e=r(this),u=o(e.length),a=i(t,u),c=i(n,u),s=arguments.length>2?arguments[2]:void 0,f=Math.min((void 0===s?u:i(s,u))-c,u-a),l=1;for(c0;)c in e?e[a]=e[c]:delete e[a],a+=l,c+=l;return e}},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},function(t,n,e){"use strict";var r=e(83);e(0)({target:"RegExp",proto:!0,forced:r!==/./.exec},{exec:r})},function(t,n,e){e(8)&&"g"!=/./g.flags&&e(9).f(RegExp.prototype,"flags",{configurable:!0,get:e(55)})},function(t,n,e){"use strict";var r,i,o,u,a=e(32),c=e(1),s=e(19),f=e(48),l=e(0),h=e(4),d=e(20),p=e(44),v=e(58),g=e(49),y=e(85).set,m=e(244)(),b=e(119),S=e(245),w=e(59),_=e(120),M=c.TypeError,x=c.process,P=x&&x.versions,O=P&&P.v8||"",A=c.Promise,F="process"==f(x),E=function(){},N=i=b.f,R=!!function(){try{var t=A.resolve(1),n=(t.constructor={})[e(5)("species")]=function(t){t(E,E)};return(F||"function"==typeof PromiseRejectionEvent)&&t.then(E)instanceof n&&0!==O.indexOf("6.6")&&-1===w.indexOf("Chrome/66")}catch(t){}}(),k=function(t){var n;return!(!h(t)||"function"!=typeof(n=t.then))&&n},T=function(t,n){if(!t._n){t._n=!0;var e=t._c;m((function(){for(var r=t._v,i=1==t._s,o=0,u=function(n){var e,o,u,a=i?n.ok:n.fail,c=n.resolve,s=n.reject,f=n.domain;try{a?(i||(2==t._h&&L(t),t._h=1),!0===a?e=r:(f&&f.enter(),e=a(r),f&&(f.exit(),u=!0)),e===n.promise?s(M("Promise-chain cycle")):(o=k(e))?o.call(e,c,s):c(e)):s(r)}catch(t){f&&!u&&f.exit(),s(t)}};e.length>o;)u(e[o++]);t._c=[],t._n=!1,n&&!t._h&&I(t)}))}},I=function(t){y.call(c,(function(){var n,e,r,i=t._v,o=j(t);if(o&&(n=S((function(){F?x.emit("unhandledRejection",i,t):(e=c.onunhandledrejection)?e({promise:t,reason:i}):(r=c.console)&&r.error&&r.error("Unhandled promise rejection",i)})),t._h=F||j(t)?2:1),t._a=void 0,o&&n.e)throw n.v}))},j=function(t){return 1!==t._h&&0===(t._a||t._c).length},L=function(t){y.call(c,(function(){var n;F?x.emit("rejectionHandled",t):(n=c.onrejectionhandled)&&n({promise:t,reason:t._v})}))},B=function(t){var n=this;n._d||(n._d=!0,(n=n._w||n)._v=t,n._s=2,n._a||(n._a=n._c.slice()),T(n,!0))},C=function(t){var n,e=this;if(!e._d){e._d=!0,e=e._w||e;try{if(e===t)throw M("Promise can't be resolved itself");(n=k(t))?m((function(){var r={_w:e,_d:!1};try{n.call(t,s(C,r,1),s(B,r,1))}catch(t){B.call(r,t)}})):(e._v=t,e._s=1,T(e,!1))}catch(t){B.call({_w:e,_d:!1},t)}}};R||(A=function(t){p(this,A,"Promise","_h"),d(t),r.call(this);try{t(s(C,this,1),s(B,this,1))}catch(t){B.call(this,t)}},(r=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=e(45)(A.prototype,{then:function(t,n){var e=N(g(this,A));return e.ok="function"!=typeof t||t,e.fail="function"==typeof n&&n,e.domain=F?x.domain:void 0,this._c.push(e),this._a&&this._a.push(e),this._s&&T(this,!1),e.promise},catch:function(t){return this.then(void 0,t)}}),o=function(){var t=new r;this.promise=t,this.resolve=s(C,t,1),this.reject=s(B,t,1)},b.f=N=function(t){return t===A||t===u?new o(t):i(t)}),l(l.G+l.W+l.F*!R,{Promise:A}),e(40)(A,"Promise"),e(43)("Promise"),u=e(7).Promise,l(l.S+l.F*!R,"Promise",{reject:function(t){var n=N(this);return(0,n.reject)(t),n.promise}}),l(l.S+l.F*(a||!R),"Promise",{resolve:function(t){return _(a&&this===u?A:this,t)}}),l(l.S+l.F*!(R&&e(54)((function(t){A.all(t).catch(E)}))),"Promise",{all:function(t){var n=this,e=N(n),r=e.resolve,i=e.reject,o=S((function(){var e=[],o=0,u=1;v(t,!1,(function(t){var a=o++,c=!1;e.push(void 0),u++,n.resolve(t).then((function(t){c||(c=!0,e[a]=t,--u||r(e))}),i)})),--u||r(e)}));return o.e&&i(o.v),e.promise},race:function(t){var n=this,e=N(n),r=e.reject,i=S((function(){v(t,!1,(function(t){n.resolve(t).then(e.resolve,r)}))}));return i.e&&r(i.v),e.promise}})},function(t,n,e){"use strict";var r=e(20);function i(t){var n,e;this.promise=new t((function(t,r){if(void 0!==n||void 0!==e)throw TypeError("Bad Promise constructor");n=t,e=r})),this.resolve=r(n),this.reject=r(e)}t.exports.f=function(t){return new i(t)}},function(t,n,e){var r=e(3),i=e(4),o=e(119);t.exports=function(t,n){if(r(t),i(n)&&n.constructor===t)return n;var e=o.f(t);return(0,e.resolve)(n),e.promise}},function(t,n,e){"use strict";var r=e(9).f,i=e(35),o=e(45),u=e(19),a=e(44),c=e(58),s=e(74),f=e(115),l=e(43),h=e(8),d=e(29).fastKey,p=e(39),v=h?"_s":"size",g=function(t,n){var e,r=d(n);if("F"!==r)return t._i[r];for(e=t._f;e;e=e.n)if(e.k==n)return e};t.exports={getConstructor:function(t,n,e,s){var f=t((function(t,r){a(t,f,n,"_i"),t._t=n,t._i=i(null),t._f=void 0,t._l=void 0,t[v]=0,null!=r&&c(r,e,t[s],t)}));return o(f.prototype,{clear:function(){for(var t=p(this,n),e=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete e[r.i];t._f=t._l=void 0,t[v]=0},delete:function(t){var e=p(this,n),r=g(e,t);if(r){var i=r.n,o=r.p;delete e._i[r.i],r.r=!0,o&&(o.n=i),i&&(i.p=o),e._f==r&&(e._f=i),e._l==r&&(e._l=o),e[v]--}return!!r},forEach:function(t){p(this,n);for(var e,r=u(t,arguments.length>1?arguments[1]:void 0,3);e=e?e.n:this._f;)for(r(e.v,e.k,this);e&&e.r;)e=e.p},has:function(t){return!!g(p(this,n),t)}}),h&&r(f.prototype,"size",{get:function(){return p(this,n)[v]}}),f},def:function(t,n,e){var r,i,o=g(t,n);return o?o.v=e:(t._l=o={i:i=d(n,!0),k:n,v:e,p:r=t._l,n:void 0,r:!1},t._f||(t._f=o),r&&(r.n=o),t[v]++,"F"!==i&&(t._i[i]=o)),t},getEntry:g,setStrong:function(t,n,e){s(t,n,(function(t,e){this._t=p(t,n),this._k=e,this._l=void 0}),(function(){for(var t=this._k,n=this._l;n&&n.r;)n=n.p;return this._t&&(this._l=n=n?n.n:this._t._f)?f(0,"keys"==t?n.k:"values"==t?n.v:[n.k,n.v]):(this._t=void 0,f(1))}),e?"entries":"values",!e,!0),l(n)}}},function(t,n,e){"use strict";var r=e(45),i=e(29).getWeak,o=e(3),u=e(4),a=e(44),c=e(58),s=e(24),f=e(13),l=e(39),h=s(5),d=s(6),p=0,v=function(t){return t._l||(t._l=new g)},g=function(){this.a=[]},y=function(t,n){return h(t.a,(function(t){return t[0]===n}))};g.prototype={get:function(t){var n=y(this,t);if(n)return n[1]},has:function(t){return!!y(this,t)},set:function(t,n){var e=y(this,t);e?e[1]=n:this.a.push([t,n])},delete:function(t){var n=d(this.a,(function(n){return n[0]===t}));return~n&&this.a.splice(n,1),!!~n}},t.exports={getConstructor:function(t,n,e,o){var s=t((function(t,r){a(t,s,n,"_i"),t._t=n,t._i=p++,t._l=void 0,null!=r&&c(r,e,t[o],t)}));return r(s.prototype,{delete:function(t){if(!u(t))return!1;var e=i(t);return!0===e?v(l(this,n)).delete(t):e&&f(e,this._i)&&delete e[this._i]},has:function(t){if(!u(t))return!1;var e=i(t);return!0===e?v(l(this,n)).has(t):e&&f(e,this._i)}}),s},def:function(t,n,e){var r=i(o(n),!0);return!0===r?v(t).set(n,e):r[t._i]=e,t},ufstore:v}},function(t,n,e){var r=e(21),i=e(6);t.exports=function(t){if(void 0===t)return 0;var n=r(t),e=i(n);if(n!==e)throw RangeError("Wrong length!");return e}},function(t,n,e){var r=e(36),i=e(52),o=e(3),u=e(1).Reflect;t.exports=u&&u.ownKeys||function(t){var n=r.f(o(t)),e=i.f;return e?n.concat(e(t)):n}},function(t,n,e){var r=e(6),i=e(70),o=e(26);t.exports=function(t,n,e,u){var a=String(o(t)),c=a.length,s=void 0===e?" ":String(e),f=r(n);if(f<=c||""==s)return a;var l=f-c,h=i.call(s,Math.ceil(l/s.length));return h.length>l&&(h=h.slice(0,l)),u?h+a:a+h}},function(t,n,e){var r=e(8),i=e(33),o=e(15),u=e(47).f;t.exports=function(t){return function(n){for(var e,a=o(n),c=i(a),s=c.length,f=0,l=[];s>f;)e=c[f++],r&&!u.call(a,e)||l.push(t?[e,a[e]]:a[e]);return l}}},function(t,n){var e=t.exports={version:"2.6.9"};"number"==typeof __e&&(__e=e)},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n,e){e(130),t.exports=e(90)},function(t,n,e){"use strict";e(131);var r,i=(r=e(303))&&r.__esModule?r:{default:r};i.default._babelPolyfill&&"undefined"!=typeof console&&console.warn&&console.warn("@babel/polyfill is loaded more than once on this page. This is probably not desirable/intended and may have consequences if different versions of the polyfills are applied sequentially. If you do need to load the polyfill more than once, use @babel/polyfill/noConflict instead to bypass the warning."),i.default._babelPolyfill=!0},function(t,n,e){"use strict";e(132),e(275),e(277),e(280),e(282),e(284),e(286),e(288),e(290),e(292),e(294),e(296),e(298),e(302)},function(t,n,e){e(133),e(136),e(137),e(138),e(139),e(140),e(141),e(142),e(143),e(144),e(145),e(146),e(147),e(148),e(149),e(150),e(151),e(152),e(153),e(154),e(155),e(156),e(157),e(158),e(159),e(160),e(161),e(162),e(163),e(164),e(165),e(166),e(167),e(168),e(169),e(170),e(171),e(172),e(173),e(174),e(175),e(176),e(177),e(179),e(180),e(181),e(182),e(183),e(184),e(185),e(186),e(187),e(188),e(189),e(190),e(191),e(192),e(193),e(194),e(195),e(196),e(197),e(198),e(199),e(200),e(201),e(202),e(203),e(204),e(205),e(206),e(207),e(208),e(209),e(210),e(211),e(212),e(214),e(215),e(217),e(218),e(219),e(220),e(221),e(222),e(223),e(225),e(226),e(227),e(228),e(229),e(230),e(231),e(232),e(233),e(234),e(235),e(236),e(237),e(82),e(238),e(116),e(239),e(117),e(240),e(241),e(242),e(243),e(118),e(246),e(247),e(248),e(249),e(250),e(251),e(252),e(253),e(254),e(255),e(256),e(257),e(258),e(259),e(260),e(261),e(262),e(263),e(264),e(265),e(266),e(267),e(268),e(269),e(270),e(271),e(272),e(273),e(274),t.exports=e(7)},function(t,n,e){"use strict";var r=e(1),i=e(13),o=e(8),u=e(0),a=e(11),c=e(29).KEY,s=e(2),f=e(50),l=e(40),h=e(31),d=e(5),p=e(63),v=e(97),g=e(135),y=e(53),m=e(3),b=e(4),S=e(10),w=e(15),_=e(28),M=e(30),x=e(35),P=e(100),O=e(22),A=e(52),F=e(9),E=e(33),N=O.f,R=F.f,k=P.f,T=r.Symbol,I=r.JSON,j=I&&I.stringify,L=d("_hidden"),B=d("toPrimitive"),C={}.propertyIsEnumerable,W=f("symbol-registry"),V=f("symbols"),G=f("op-symbols"),D=Object.prototype,U="function"==typeof T&&!!A.f,z=r.QObject,q=!z||!z.prototype||!z.prototype.findChild,K=o&&s((function(){return 7!=x(R({},"a",{get:function(){return R(this,"a",{value:7}).a}})).a}))?function(t,n,e){var r=N(D,n);r&&delete D[n],R(t,n,e),r&&t!==D&&R(D,n,r)}:R,Y=function(t){var n=V[t]=x(T.prototype);return n._k=t,n},Q=U&&"symbol"==typeof T.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof T},H=function(t,n,e){return t===D&&H(G,n,e),m(t),n=_(n,!0),m(e),i(V,n)?(e.enumerable?(i(t,L)&&t[L][n]&&(t[L][n]=!1),e=x(e,{enumerable:M(0,!1)})):(i(t,L)||R(t,L,M(1,{})),t[L][n]=!0),K(t,n,e)):R(t,n,e)},J=function(t,n){m(t);for(var e,r=g(n=w(n)),i=0,o=r.length;o>i;)H(t,e=r[i++],n[e]);return t},X=function(t){var n=C.call(this,t=_(t,!0));return!(this===D&&i(V,t)&&!i(G,t))&&(!(n||!i(this,t)||!i(V,t)||i(this,L)&&this[L][t])||n)},Z=function(t,n){if(t=w(t),n=_(n,!0),t!==D||!i(V,n)||i(G,n)){var e=N(t,n);return!e||!i(V,n)||i(t,L)&&t[L][n]||(e.enumerable=!0),e}},$=function(t){for(var n,e=k(w(t)),r=[],o=0;e.length>o;)i(V,n=e[o++])||n==L||n==c||r.push(n);return r},tt=function(t){for(var n,e=t===D,r=k(e?G:w(t)),o=[],u=0;r.length>u;)!i(V,n=r[u++])||e&&!i(D,n)||o.push(V[n]);return o};U||(a((T=function(){if(this instanceof T)throw TypeError("Symbol is not a constructor!");var t=h(arguments.length>0?arguments[0]:void 0),n=function(e){this===D&&n.call(G,e),i(this,L)&&i(this[L],t)&&(this[L][t]=!1),K(this,t,M(1,e))};return o&&q&&K(D,t,{configurable:!0,set:n}),Y(t)}).prototype,"toString",(function(){return this._k})),O.f=Z,F.f=H,e(36).f=P.f=$,e(47).f=X,A.f=tt,o&&!e(32)&&a(D,"propertyIsEnumerable",X,!0),p.f=function(t){return Y(d(t))}),u(u.G+u.W+u.F*!U,{Symbol:T});for(var nt="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),et=0;nt.length>et;)d(nt[et++]);for(var rt=E(d.store),it=0;rt.length>it;)v(rt[it++]);u(u.S+u.F*!U,"Symbol",{for:function(t){return i(W,t+="")?W[t]:W[t]=T(t)},keyFor:function(t){if(!Q(t))throw TypeError(t+" is not a symbol!");for(var n in W)if(W[n]===t)return n},useSetter:function(){q=!0},useSimple:function(){q=!1}}),u(u.S+u.F*!U,"Object",{create:function(t,n){return void 0===n?x(t):J(x(t),n)},defineProperty:H,defineProperties:J,getOwnPropertyDescriptor:Z,getOwnPropertyNames:$,getOwnPropertySymbols:tt});var ot=s((function(){A.f(1)}));u(u.S+u.F*ot,"Object",{getOwnPropertySymbols:function(t){return A.f(S(t))}}),I&&u(u.S+u.F*(!U||s((function(){var t=T();return"[null]"!=j([t])||"{}"!=j({a:t})||"{}"!=j(Object(t))}))),"JSON",{stringify:function(t){for(var n,e,r=[t],i=1;arguments.length>i;)r.push(arguments[i++]);if(e=n=r[1],(b(n)||void 0!==t)&&!Q(t))return y(n)||(n=function(t,n){if("function"==typeof e&&(n=e.call(this,t,n)),!Q(n))return n}),r[1]=n,j.apply(I,r)}}),T.prototype[B]||e(14)(T.prototype,B,T.prototype.valueOf),l(T,"Symbol"),l(Math,"Math",!0),l(r.JSON,"JSON",!0)},function(t,n,e){t.exports=e(50)("native-function-to-string",Function.toString)},function(t,n,e){var r=e(33),i=e(52),o=e(47);t.exports=function(t){var n=r(t),e=i.f;if(e)for(var u,a=e(t),c=o.f,s=0;a.length>s;)c.call(t,u=a[s++])&&n.push(u);return n}},function(t,n,e){var r=e(0);r(r.S,"Object",{create:e(35)})},function(t,n,e){var r=e(0);r(r.S+r.F*!e(8),"Object",{defineProperty:e(9).f})},function(t,n,e){var r=e(0);r(r.S+r.F*!e(8),"Object",{defineProperties:e(99)})},function(t,n,e){var r=e(15),i=e(22).f;e(23)("getOwnPropertyDescriptor",(function(){return function(t,n){return i(r(t),n)}}))},function(t,n,e){var r=e(10),i=e(37);e(23)("getPrototypeOf",(function(){return function(t){return i(r(t))}}))},function(t,n,e){var r=e(10),i=e(33);e(23)("keys",(function(){return function(t){return i(r(t))}}))},function(t,n,e){e(23)("getOwnPropertyNames",(function(){return e(100).f}))},function(t,n,e){var r=e(4),i=e(29).onFreeze;e(23)("freeze",(function(t){return function(n){return t&&r(n)?t(i(n)):n}}))},function(t,n,e){var r=e(4),i=e(29).onFreeze;e(23)("seal",(function(t){return function(n){return t&&r(n)?t(i(n)):n}}))},function(t,n,e){var r=e(4),i=e(29).onFreeze;e(23)("preventExtensions",(function(t){return function(n){return t&&r(n)?t(i(n)):n}}))},function(t,n,e){var r=e(4);e(23)("isFrozen",(function(t){return function(n){return!r(n)||!!t&&t(n)}}))},function(t,n,e){var r=e(4);e(23)("isSealed",(function(t){return function(n){return!r(n)||!!t&&t(n)}}))},function(t,n,e){var r=e(4);e(23)("isExtensible",(function(t){return function(n){return!!r(n)&&(!t||t(n))}}))},function(t,n,e){var r=e(0);r(r.S+r.F,"Object",{assign:e(101)})},function(t,n,e){var r=e(0);r(r.S,"Object",{is:e(102)})},function(t,n,e){var r=e(0);r(r.S,"Object",{setPrototypeOf:e(67).set})},function(t,n,e){"use strict";var r=e(48),i={};i[e(5)("toStringTag")]="z",i+""!="[object z]"&&e(11)(Object.prototype,"toString",(function(){return"[object "+r(this)+"]"}),!0)},function(t,n,e){var r=e(0);r(r.P,"Function",{bind:e(103)})},function(t,n,e){var r=e(9).f,i=Function.prototype,o=/^\s*function ([^ (]*)/;"name"in i||e(8)&&r(i,"name",{configurable:!0,get:function(){try{return(""+this).match(o)[1]}catch(t){return""}}})},function(t,n,e){"use strict";var r=e(4),i=e(37),o=e(5)("hasInstance"),u=Function.prototype;o in u||e(9).f(u,o,{value:function(t){if("function"!=typeof this||!r(t))return!1;if(!r(this.prototype))return t instanceof this;for(;t=i(t);)if(this.prototype===t)return!0;return!1}})},function(t,n,e){var r=e(0),i=e(105);r(r.G+r.F*(parseInt!=i),{parseInt:i})},function(t,n,e){var r=e(0),i=e(106);r(r.G+r.F*(parseFloat!=i),{parseFloat:i})},function(t,n,e){"use strict";var r=e(1),i=e(13),o=e(25),u=e(69),a=e(28),c=e(2),s=e(36).f,f=e(22).f,l=e(9).f,h=e(41).trim,d=r.Number,p=d,v=d.prototype,g="Number"==o(e(35)(v)),y="trim"in String.prototype,m=function(t){var n=a(t,!1);if("string"==typeof n&&n.length>2){var e,r,i,o=(n=y?n.trim():h(n,3)).charCodeAt(0);if(43===o||45===o){if(88===(e=n.charCodeAt(2))||120===e)return NaN}else if(48===o){switch(n.charCodeAt(1)){case 66:case 98:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return+n}for(var u,c=n.slice(2),s=0,f=c.length;si)return NaN;return parseInt(c,r)}}return+n};if(!d(" 0o1")||!d("0b1")||d("+0x1")){d=function(t){var n=arguments.length<1?0:t,e=this;return e instanceof d&&(g?c((function(){v.valueOf.call(e)})):"Number"!=o(e))?u(new p(m(n)),e,d):m(n)};for(var b,S=e(8)?s(p):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),w=0;S.length>w;w++)i(p,b=S[w])&&!i(d,b)&&l(d,b,f(p,b));d.prototype=v,v.constructor=d,e(11)(r,"Number",d)}},function(t,n,e){"use strict";var r=e(0),i=e(21),o=e(107),u=e(70),a=1..toFixed,c=Math.floor,s=[0,0,0,0,0,0],f="Number.toFixed: incorrect invocation!",l=function(t,n){for(var e=-1,r=n;++e<6;)r+=t*s[e],s[e]=r%1e7,r=c(r/1e7)},h=function(t){for(var n=6,e=0;--n>=0;)e+=s[n],s[n]=c(e/t),e=e%t*1e7},d=function(){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==s[t]){var e=String(s[t]);n=""===n?e:n+u.call("0",7-e.length)+e}return n},p=function(t,n,e){return 0===n?e:n%2==1?p(t,n-1,e*t):p(t*t,n/2,e)};r(r.P+r.F*(!!a&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==(0xde0b6b3a7640080).toFixed(0))||!e(2)((function(){a.call({})}))),"Number",{toFixed:function(t){var n,e,r,a,c=o(this,f),s=i(t),v="",g="0";if(s<0||s>20)throw RangeError(f);if(c!=c)return"NaN";if(c<=-1e21||c>=1e21)return String(c);if(c<0&&(v="-",c=-c),c>1e-21)if(e=(n=function(t){for(var n=0,e=t;e>=4096;)n+=12,e/=4096;for(;e>=2;)n+=1,e/=2;return n}(c*p(2,69,1))-69)<0?c*p(2,-n,1):c/p(2,n,1),e*=4503599627370496,(n=52-n)>0){for(l(0,e),r=s;r>=7;)l(1e7,0),r-=7;for(l(p(10,r,1),0),r=n-1;r>=23;)h(1<<23),r-=23;h(1<0?v+((a=g.length)<=s?"0."+u.call("0",s-a)+g:g.slice(0,a-s)+"."+g.slice(a-s)):v+g}})},function(t,n,e){"use strict";var r=e(0),i=e(2),o=e(107),u=1..toPrecision;r(r.P+r.F*(i((function(){return"1"!==u.call(1,void 0)}))||!i((function(){u.call({})}))),"Number",{toPrecision:function(t){var n=o(this,"Number#toPrecision: incorrect invocation!");return void 0===t?u.call(n):u.call(n,t)}})},function(t,n,e){var r=e(0);r(r.S,"Number",{EPSILON:Math.pow(2,-52)})},function(t,n,e){var r=e(0),i=e(1).isFinite;r(r.S,"Number",{isFinite:function(t){return"number"==typeof t&&i(t)}})},function(t,n,e){var r=e(0);r(r.S,"Number",{isInteger:e(108)})},function(t,n,e){var r=e(0);r(r.S,"Number",{isNaN:function(t){return t!=t}})},function(t,n,e){var r=e(0),i=e(108),o=Math.abs;r(r.S,"Number",{isSafeInteger:function(t){return i(t)&&o(t)<=9007199254740991}})},function(t,n,e){var r=e(0);r(r.S,"Number",{MAX_SAFE_INTEGER:9007199254740991})},function(t,n,e){var r=e(0);r(r.S,"Number",{MIN_SAFE_INTEGER:-9007199254740991})},function(t,n,e){var r=e(0),i=e(106);r(r.S+r.F*(Number.parseFloat!=i),"Number",{parseFloat:i})},function(t,n,e){var r=e(0),i=e(105);r(r.S+r.F*(Number.parseInt!=i),"Number",{parseInt:i})},function(t,n,e){var r=e(0),i=e(109),o=Math.sqrt,u=Math.acosh;r(r.S+r.F*!(u&&710==Math.floor(u(Number.MAX_VALUE))&&u(1/0)==1/0),"Math",{acosh:function(t){return(t=+t)<1?NaN:t>94906265.62425156?Math.log(t)+Math.LN2:i(t-1+o(t-1)*o(t+1))}})},function(t,n,e){var r=e(0),i=Math.asinh;r(r.S+r.F*!(i&&1/i(0)>0),"Math",{asinh:function t(n){return isFinite(n=+n)&&0!=n?n<0?-t(-n):Math.log(n+Math.sqrt(n*n+1)):n}})},function(t,n,e){var r=e(0),i=Math.atanh;r(r.S+r.F*!(i&&1/i(-0)<0),"Math",{atanh:function(t){return 0==(t=+t)?t:Math.log((1+t)/(1-t))/2}})},function(t,n,e){var r=e(0),i=e(71);r(r.S,"Math",{cbrt:function(t){return i(t=+t)*Math.pow(Math.abs(t),1/3)}})},function(t,n,e){var r=e(0);r(r.S,"Math",{clz32:function(t){return(t>>>=0)?31-Math.floor(Math.log(t+.5)*Math.LOG2E):32}})},function(t,n,e){var r=e(0),i=Math.exp;r(r.S,"Math",{cosh:function(t){return(i(t=+t)+i(-t))/2}})},function(t,n,e){var r=e(0),i=e(72);r(r.S+r.F*(i!=Math.expm1),"Math",{expm1:i})},function(t,n,e){var r=e(0);r(r.S,"Math",{fround:e(178)})},function(t,n,e){var r=e(71),i=Math.pow,o=i(2,-52),u=i(2,-23),a=i(2,127)*(2-u),c=i(2,-126);t.exports=Math.fround||function(t){var n,e,i=Math.abs(t),s=r(t);return ia||e!=e?s*(1/0):s*e}},function(t,n,e){var r=e(0),i=Math.abs;r(r.S,"Math",{hypot:function(t,n){for(var e,r,o=0,u=0,a=arguments.length,c=0;u0?(r=e/c)*r:e;return c===1/0?1/0:c*Math.sqrt(o)}})},function(t,n,e){var r=e(0),i=Math.imul;r(r.S+r.F*e(2)((function(){return-5!=i(4294967295,5)||2!=i.length})),"Math",{imul:function(t,n){var e=+t,r=+n,i=65535&e,o=65535&r;return 0|i*o+((65535&e>>>16)*o+i*(65535&r>>>16)<<16>>>0)}})},function(t,n,e){var r=e(0);r(r.S,"Math",{log10:function(t){return Math.log(t)*Math.LOG10E}})},function(t,n,e){var r=e(0);r(r.S,"Math",{log1p:e(109)})},function(t,n,e){var r=e(0);r(r.S,"Math",{log2:function(t){return Math.log(t)/Math.LN2}})},function(t,n,e){var r=e(0);r(r.S,"Math",{sign:e(71)})},function(t,n,e){var r=e(0),i=e(72),o=Math.exp;r(r.S+r.F*e(2)((function(){return-2e-17!=!Math.sinh(-2e-17)})),"Math",{sinh:function(t){return Math.abs(t=+t)<1?(i(t)-i(-t))/2:(o(t-1)-o(-t-1))*(Math.E/2)}})},function(t,n,e){var r=e(0),i=e(72),o=Math.exp;r(r.S,"Math",{tanh:function(t){var n=i(t=+t),e=i(-t);return n==1/0?1:e==1/0?-1:(n-e)/(o(t)+o(-t))}})},function(t,n,e){var r=e(0);r(r.S,"Math",{trunc:function(t){return(t>0?Math.floor:Math.ceil)(t)}})},function(t,n,e){var r=e(0),i=e(34),o=String.fromCharCode,u=String.fromCodePoint;r(r.S+r.F*(!!u&&1!=u.length),"String",{fromCodePoint:function(t){for(var n,e=[],r=arguments.length,u=0;r>u;){if(n=+arguments[u++],i(n,1114111)!==n)throw RangeError(n+" is not a valid code point");e.push(n<65536?o(n):o(55296+((n-=65536)>>10),n%1024+56320))}return e.join("")}})},function(t,n,e){var r=e(0),i=e(15),o=e(6);r(r.S,"String",{raw:function(t){for(var n=i(t.raw),e=o(n.length),r=arguments.length,u=[],a=0;e>a;)u.push(String(n[a++])),a=n.length?{value:void 0,done:!0}:(t=r(n,e),this._i+=t.length,{value:t,done:!1})}))},function(t,n,e){"use strict";var r=e(0),i=e(73)(!1);r(r.P,"String",{codePointAt:function(t){return i(this,t)}})},function(t,n,e){"use strict";var r=e(0),i=e(6),o=e(75),u="".endsWith;r(r.P+r.F*e(77)("endsWith"),"String",{endsWith:function(t){var n=o(this,t,"endsWith"),e=arguments.length>1?arguments[1]:void 0,r=i(n.length),a=void 0===e?r:Math.min(i(e),r),c=String(t);return u?u.call(n,c,a):n.slice(a-c.length,a)===c}})},function(t,n,e){"use strict";var r=e(0),i=e(75);r(r.P+r.F*e(77)("includes"),"String",{includes:function(t){return!!~i(this,t,"includes").indexOf(t,arguments.length>1?arguments[1]:void 0)}})},function(t,n,e){var r=e(0);r(r.P,"String",{repeat:e(70)})},function(t,n,e){"use strict";var r=e(0),i=e(6),o=e(75),u="".startsWith;r(r.P+r.F*e(77)("startsWith"),"String",{startsWith:function(t){var n=o(this,t,"startsWith"),e=i(Math.min(arguments.length>1?arguments[1]:void 0,n.length)),r=String(t);return u?u.call(n,r,e):n.slice(e,e+r.length)===r}})},function(t,n,e){"use strict";e(12)("anchor",(function(t){return function(n){return t(this,"a","name",n)}}))},function(t,n,e){"use strict";e(12)("big",(function(t){return function(){return t(this,"big","","")}}))},function(t,n,e){"use strict";e(12)("blink",(function(t){return function(){return t(this,"blink","","")}}))},function(t,n,e){"use strict";e(12)("bold",(function(t){return function(){return t(this,"b","","")}}))},function(t,n,e){"use strict";e(12)("fixed",(function(t){return function(){return t(this,"tt","","")}}))},function(t,n,e){"use strict";e(12)("fontcolor",(function(t){return function(n){return t(this,"font","color",n)}}))},function(t,n,e){"use strict";e(12)("fontsize",(function(t){return function(n){return t(this,"font","size",n)}}))},function(t,n,e){"use strict";e(12)("italics",(function(t){return function(){return t(this,"i","","")}}))},function(t,n,e){"use strict";e(12)("link",(function(t){return function(n){return t(this,"a","href",n)}}))},function(t,n,e){"use strict";e(12)("small",(function(t){return function(){return t(this,"small","","")}}))},function(t,n,e){"use strict";e(12)("strike",(function(t){return function(){return t(this,"strike","","")}}))},function(t,n,e){"use strict";e(12)("sub",(function(t){return function(){return t(this,"sub","","")}}))},function(t,n,e){"use strict";e(12)("sup",(function(t){return function(){return t(this,"sup","","")}}))},function(t,n,e){var r=e(0);r(r.S,"Date",{now:function(){return(new Date).getTime()}})},function(t,n,e){"use strict";var r=e(0),i=e(10),o=e(28);r(r.P+r.F*e(2)((function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})})),"Date",{toJSON:function(t){var n=i(this),e=o(n);return"number"!=typeof e||isFinite(e)?n.toISOString():null}})},function(t,n,e){var r=e(0),i=e(213);r(r.P+r.F*(Date.prototype.toISOString!==i),"Date",{toISOString:i})},function(t,n,e){"use strict";var r=e(2),i=Date.prototype.getTime,o=Date.prototype.toISOString,u=function(t){return t>9?t:"0"+t};t.exports=r((function(){return"0385-07-25T07:06:39.999Z"!=o.call(new Date(-5e13-1))}))||!r((function(){o.call(new Date(NaN))}))?function(){if(!isFinite(i.call(this)))throw RangeError("Invalid time value");var t=this,n=t.getUTCFullYear(),e=t.getUTCMilliseconds(),r=n<0?"-":n>9999?"+":"";return r+("00000"+Math.abs(n)).slice(r?-6:-4)+"-"+u(t.getUTCMonth()+1)+"-"+u(t.getUTCDate())+"T"+u(t.getUTCHours())+":"+u(t.getUTCMinutes())+":"+u(t.getUTCSeconds())+"."+(e>99?e:"0"+u(e))+"Z"}:o},function(t,n,e){var r=Date.prototype,i=r.toString,o=r.getTime;new Date(NaN)+""!="Invalid Date"&&e(11)(r,"toString",(function(){var t=o.call(this);return t==t?i.call(this):"Invalid Date"}))},function(t,n,e){var r=e(5)("toPrimitive"),i=Date.prototype;r in i||e(14)(i,r,e(216))},function(t,n,e){"use strict";var r=e(3),i=e(28);t.exports=function(t){if("string"!==t&&"number"!==t&&"default"!==t)throw TypeError("Incorrect hint");return i(r(this),"number"!=t)}},function(t,n,e){var r=e(0);r(r.S,"Array",{isArray:e(53)})},function(t,n,e){"use strict";var r=e(19),i=e(0),o=e(10),u=e(111),a=e(78),c=e(6),s=e(79),f=e(80);i(i.S+i.F*!e(54)((function(t){Array.from(t)})),"Array",{from:function(t){var n,e,i,l,h=o(t),d="function"==typeof this?this:Array,p=arguments.length,v=p>1?arguments[1]:void 0,g=void 0!==v,y=0,m=f(h);if(g&&(v=r(v,p>2?arguments[2]:void 0,2)),null==m||d==Array&&a(m))for(e=new d(n=c(h.length));n>y;y++)s(e,y,g?v(h[y],y):h[y]);else for(l=m.call(h),e=new d;!(i=l.next()).done;y++)s(e,y,g?u(l,v,[i.value,y],!0):i.value);return e.length=y,e}})},function(t,n,e){"use strict";var r=e(0),i=e(79);r(r.S+r.F*e(2)((function(){function t(){}return!(Array.of.call(t)instanceof t)})),"Array",{of:function(){for(var t=0,n=arguments.length,e=new("function"==typeof this?this:Array)(n);n>t;)i(e,t,arguments[t++]);return e.length=n,e}})},function(t,n,e){"use strict";var r=e(0),i=e(15),o=[].join;r(r.P+r.F*(e(46)!=Object||!e(16)(o)),"Array",{join:function(t){return o.call(i(this),void 0===t?",":t)}})},function(t,n,e){"use strict";var r=e(0),i=e(66),o=e(25),u=e(34),a=e(6),c=[].slice;r(r.P+r.F*e(2)((function(){i&&c.call(i)})),"Array",{slice:function(t,n){var e=a(this.length),r=o(this);if(n=void 0===n?e:n,"Array"==r)return c.call(this,t,n);for(var i=u(t,e),s=u(n,e),f=a(s-i),l=new Array(f),h=0;h1&&(r=Math.min(r,o(arguments[1]))),r<0&&(r=e+r);r>=0;r--)if(r in n&&n[r]===t)return r||0;return-1}})},function(t,n,e){var r=e(0);r(r.P,"Array",{copyWithin:e(114)}),e(38)("copyWithin")},function(t,n,e){var r=e(0);r(r.P,"Array",{fill:e(81)}),e(38)("fill")},function(t,n,e){"use strict";var r=e(0),i=e(24)(5),o=!0;"find"in[]&&Array(1).find((function(){o=!1})),r(r.P+r.F*o,"Array",{find:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),e(38)("find")},function(t,n,e){"use strict";var r=e(0),i=e(24)(6),o="findIndex",u=!0;o in[]&&Array(1)[o]((function(){u=!1})),r(r.P+r.F*u,"Array",{findIndex:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),e(38)(o)},function(t,n,e){e(43)("Array")},function(t,n,e){var r=e(1),i=e(69),o=e(9).f,u=e(36).f,a=e(76),c=e(55),s=r.RegExp,f=s,l=s.prototype,h=/a/g,d=/a/g,p=new s(h)!==h;if(e(8)&&(!p||e(2)((function(){return d[e(5)("match")]=!1,s(h)!=h||s(d)==d||"/a/i"!=s(h,"i")})))){s=function(t,n){var e=this instanceof s,r=a(t),o=void 0===n;return!e&&r&&t.constructor===s&&o?t:i(p?new f(r&&!o?t.source:t,n):f((r=t instanceof s)?t.source:t,r&&o?c.call(t):n),e?this:l,s)};for(var v=function(t){t in s||o(s,t,{configurable:!0,get:function(){return f[t]},set:function(n){f[t]=n}})},g=u(f),y=0;g.length>y;)v(g[y++]);l.constructor=s,s.prototype=l,e(11)(r,"RegExp",s)}e(43)("RegExp")},function(t,n,e){"use strict";e(117);var r=e(3),i=e(55),o=e(8),u=/./.toString,a=function(t){e(11)(RegExp.prototype,"toString",t,!0)};e(2)((function(){return"/a/b"!=u.call({source:"a",flags:"b"})}))?a((function(){var t=r(this);return"/".concat(t.source,"/","flags"in t?t.flags:!o&&t instanceof RegExp?i.call(t):void 0)})):"toString"!=u.name&&a((function(){return u.call(this)}))},function(t,n,e){"use strict";var r=e(3),i=e(6),o=e(84),u=e(56);e(57)("match",1,(function(t,n,e,a){return[function(e){var r=t(this),i=null==e?void 0:e[n];return void 0!==i?i.call(e,r):new RegExp(e)[n](String(r))},function(t){var n=a(e,t,this);if(n.done)return n.value;var c=r(t),s=String(this);if(!c.global)return u(c,s);var f=c.unicode;c.lastIndex=0;for(var l,h=[],d=0;null!==(l=u(c,s));){var p=String(l[0]);h[d]=p,""===p&&(c.lastIndex=o(s,i(c.lastIndex),f)),d++}return 0===d?null:h}]}))},function(t,n,e){"use strict";var r=e(3),i=e(10),o=e(6),u=e(21),a=e(84),c=e(56),s=Math.max,f=Math.min,l=Math.floor,h=/\$([$&`']|\d\d?|<[^>]*>)/g,d=/\$([$&`']|\d\d?)/g;e(57)("replace",2,(function(t,n,e,p){return[function(r,i){var o=t(this),u=null==r?void 0:r[n];return void 0!==u?u.call(r,o,i):e.call(String(o),r,i)},function(t,n){var i=p(e,t,this,n);if(i.done)return i.value;var l=r(t),h=String(this),d="function"==typeof n;d||(n=String(n));var g=l.global;if(g){var y=l.unicode;l.lastIndex=0}for(var m=[];;){var b=c(l,h);if(null===b)break;if(m.push(b),!g)break;""===String(b[0])&&(l.lastIndex=a(h,o(l.lastIndex),y))}for(var S,w="",_=0,M=0;M=_&&(w+=h.slice(_,P)+N,_=P+x.length)}return w+h.slice(_)}];function v(t,n,r,o,u,a){var c=r+t.length,s=o.length,f=d;return void 0!==u&&(u=i(u),f=h),e.call(a,f,(function(e,i){var a;switch(i.charAt(0)){case"$":return"$";case"&":return t;case"`":return n.slice(0,r);case"'":return n.slice(c);case"<":a=u[i.slice(1,-1)];break;default:var f=+i;if(0===f)return e;if(f>s){var h=l(f/10);return 0===h?e:h<=s?void 0===o[h-1]?i.charAt(1):o[h-1]+i.charAt(1):e}a=o[f-1]}return void 0===a?"":a}))}}))},function(t,n,e){"use strict";var r=e(3),i=e(102),o=e(56);e(57)("search",1,(function(t,n,e,u){return[function(e){var r=t(this),i=null==e?void 0:e[n];return void 0!==i?i.call(e,r):new RegExp(e)[n](String(r))},function(t){var n=u(e,t,this);if(n.done)return n.value;var a=r(t),c=String(this),s=a.lastIndex;i(s,0)||(a.lastIndex=0);var f=o(a,c);return i(a.lastIndex,s)||(a.lastIndex=s),null===f?-1:f.index}]}))},function(t,n,e){"use strict";var r=e(76),i=e(3),o=e(49),u=e(84),a=e(6),c=e(56),s=e(83),f=e(2),l=Math.min,h=[].push,d=!f((function(){RegExp(4294967295,"y")}));e(57)("split",2,(function(t,n,e,f){var p;return p="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(t,n){var i=String(this);if(void 0===t&&0===n)return[];if(!r(t))return e.call(i,t,n);for(var o,u,a,c=[],f=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),l=0,d=void 0===n?4294967295:n>>>0,p=new RegExp(t.source,f+"g");(o=s.call(p,i))&&!((u=p.lastIndex)>l&&(c.push(i.slice(l,o.index)),o.length>1&&o.index=d));)p.lastIndex===o.index&&p.lastIndex++;return l===i.length?!a&&p.test("")||c.push(""):c.push(i.slice(l)),c.length>d?c.slice(0,d):c}:"0".split(void 0,0).length?function(t,n){return void 0===t&&0===n?[]:e.call(this,t,n)}:e,[function(e,r){var i=t(this),o=null==e?void 0:e[n];return void 0!==o?o.call(e,i,r):p.call(String(i),e,r)},function(t,n){var r=f(p,t,this,n,p!==e);if(r.done)return r.value;var s=i(t),h=String(this),v=o(s,RegExp),g=s.unicode,y=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(d?"y":"g"),m=new v(d?s:"^(?:"+s.source+")",y),b=void 0===n?4294967295:n>>>0;if(0===b)return[];if(0===h.length)return null===c(m,h)?[h]:[];for(var S=0,w=0,_=[];w0?arguments[0]:void 0)}}),{get:function(t){var n=r.getEntry(i(this,"Map"),t);return n&&n.v},set:function(t,n){return r.def(i(this,"Map"),0===t?0:t,n)}},r,!0)},function(t,n,e){"use strict";var r=e(121),i=e(39);t.exports=e(60)("Set",(function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}}),{add:function(t){return r.def(i(this,"Set"),t=0===t?0:t,t)}},r)},function(t,n,e){"use strict";var r,i=e(1),o=e(24)(0),u=e(11),a=e(29),c=e(101),s=e(122),f=e(4),l=e(39),h=e(39),d=!i.ActiveXObject&&"ActiveXObject"in i,p=a.getWeak,v=Object.isExtensible,g=s.ufstore,y=function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},m={get:function(t){if(f(t)){var n=p(t);return!0===n?g(l(this,"WeakMap")).get(t):n?n[this._i]:void 0}},set:function(t,n){return s.def(l(this,"WeakMap"),t,n)}},b=t.exports=e(60)("WeakMap",y,m,s,!0,!0);h&&d&&(c((r=s.getConstructor(y,"WeakMap")).prototype,m),a.NEED=!0,o(["delete","has","get","set"],(function(t){var n=b.prototype,e=n[t];u(n,t,(function(n,i){if(f(n)&&!v(n)){this._f||(this._f=new r);var o=this._f[t](n,i);return"set"==t?this:o}return e.call(this,n,i)}))})))},function(t,n,e){"use strict";var r=e(122),i=e(39);e(60)("WeakSet",(function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}}),{add:function(t){return r.def(i(this,"WeakSet"),t,!0)}},r,!1,!0)},function(t,n,e){"use strict";var r=e(0),i=e(61),o=e(86),u=e(3),a=e(34),c=e(6),s=e(4),f=e(1).ArrayBuffer,l=e(49),h=o.ArrayBuffer,d=o.DataView,p=i.ABV&&f.isView,v=h.prototype.slice,g=i.VIEW;r(r.G+r.W+r.F*(f!==h),{ArrayBuffer:h}),r(r.S+r.F*!i.CONSTR,"ArrayBuffer",{isView:function(t){return p&&p(t)||s(t)&&g in t}}),r(r.P+r.U+r.F*e(2)((function(){return!new h(2).slice(1,void 0).byteLength})),"ArrayBuffer",{slice:function(t,n){if(void 0!==v&&void 0===n)return v.call(u(this),t);for(var e=u(this).byteLength,r=a(t,e),i=a(void 0===n?e:n,e),o=new(l(this,h))(c(i-r)),s=new d(this),f=new d(o),p=0;r=n.length)return{value:void 0,done:!0}}while(!((t=n[this._i++])in this._t));return{value:t,done:!1}})),r(r.S,"Reflect",{enumerate:function(t){return new o(t)}})},function(t,n,e){var r=e(22),i=e(37),o=e(13),u=e(0),a=e(4),c=e(3);u(u.S,"Reflect",{get:function t(n,e){var u,s,f=arguments.length<3?n:arguments[2];return c(n)===f?n[e]:(u=r.f(n,e))?o(u,"value")?u.value:void 0!==u.get?u.get.call(f):void 0:a(s=i(n))?t(s,e,f):void 0}})},function(t,n,e){var r=e(22),i=e(0),o=e(3);i(i.S,"Reflect",{getOwnPropertyDescriptor:function(t,n){return r.f(o(t),n)}})},function(t,n,e){var r=e(0),i=e(37),o=e(3);r(r.S,"Reflect",{getPrototypeOf:function(t){return i(o(t))}})},function(t,n,e){var r=e(0);r(r.S,"Reflect",{has:function(t,n){return n in t}})},function(t,n,e){var r=e(0),i=e(3),o=Object.isExtensible;r(r.S,"Reflect",{isExtensible:function(t){return i(t),!o||o(t)}})},function(t,n,e){var r=e(0);r(r.S,"Reflect",{ownKeys:e(124)})},function(t,n,e){var r=e(0),i=e(3),o=Object.preventExtensions;r(r.S,"Reflect",{preventExtensions:function(t){i(t);try{return o&&o(t),!0}catch(t){return!1}}})},function(t,n,e){var r=e(9),i=e(22),o=e(37),u=e(13),a=e(0),c=e(30),s=e(3),f=e(4);a(a.S,"Reflect",{set:function t(n,e,a){var l,h,d=arguments.length<4?n:arguments[3],p=i.f(s(n),e);if(!p){if(f(h=o(n)))return t(h,e,a,d);p=c(0)}if(u(p,"value")){if(!1===p.writable||!f(d))return!1;if(l=i.f(d,e)){if(l.get||l.set||!1===l.writable)return!1;l.value=a,r.f(d,e,l)}else r.f(d,e,c(0,a));return!0}return void 0!==p.set&&(p.set.call(d,a),!0)}})},function(t,n,e){var r=e(0),i=e(67);i&&r(r.S,"Reflect",{setPrototypeOf:function(t,n){i.check(t,n);try{return i.set(t,n),!0}catch(t){return!1}}})},function(t,n,e){e(276),t.exports=e(7).Array.includes},function(t,n,e){"use strict";var r=e(0),i=e(51)(!0);r(r.P,"Array",{includes:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),e(38)("includes")},function(t,n,e){e(278),t.exports=e(7).Array.flatMap},function(t,n,e){"use strict";var r=e(0),i=e(279),o=e(10),u=e(6),a=e(20),c=e(112);r(r.P,"Array",{flatMap:function(t){var n,e,r=o(this);return a(t),n=u(r.length),e=c(r,0),i(e,r,r,n,0,1,t,arguments[1]),e}}),e(38)("flatMap")},function(t,n,e){"use strict";var r=e(53),i=e(4),o=e(6),u=e(19),a=e(5)("isConcatSpreadable");t.exports=function t(n,e,c,s,f,l,h,d){for(var p,v,g=f,y=0,m=!!h&&u(h,d,3);y0)g=t(n,e,p,o(p.length),g,l-1)-1;else{if(g>=9007199254740991)throw TypeError();n[g]=p}g++}y++}return g}},function(t,n,e){e(281),t.exports=e(7).String.padStart},function(t,n,e){"use strict";var r=e(0),i=e(125),o=e(59),u=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(o);r(r.P+r.F*u,"String",{padStart:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!0)}})},function(t,n,e){e(283),t.exports=e(7).String.padEnd},function(t,n,e){"use strict";var r=e(0),i=e(125),o=e(59),u=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(o);r(r.P+r.F*u,"String",{padEnd:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!1)}})},function(t,n,e){e(285),t.exports=e(7).String.trimLeft},function(t,n,e){"use strict";e(41)("trimLeft",(function(t){return function(){return t(this,1)}}),"trimStart")},function(t,n,e){e(287),t.exports=e(7).String.trimRight},function(t,n,e){"use strict";e(41)("trimRight",(function(t){return function(){return t(this,2)}}),"trimEnd")},function(t,n,e){e(289),t.exports=e(63).f("asyncIterator")},function(t,n,e){e(97)("asyncIterator")},function(t,n,e){e(291),t.exports=e(7).Object.getOwnPropertyDescriptors},function(t,n,e){var r=e(0),i=e(124),o=e(15),u=e(22),a=e(79);r(r.S,"Object",{getOwnPropertyDescriptors:function(t){for(var n,e,r=o(t),c=u.f,s=i(r),f={},l=0;s.length>l;)void 0!==(e=c(r,n=s[l++]))&&a(f,n,e);return f}})},function(t,n,e){e(293),t.exports=e(7).Object.values},function(t,n,e){var r=e(0),i=e(126)(!1);r(r.S,"Object",{values:function(t){return i(t)}})},function(t,n,e){e(295),t.exports=e(7).Object.entries},function(t,n,e){var r=e(0),i=e(126)(!0);r(r.S,"Object",{entries:function(t){return i(t)}})},function(t,n,e){"use strict";e(118),e(297),t.exports=e(7).Promise.finally},function(t,n,e){"use strict";var r=e(0),i=e(7),o=e(1),u=e(49),a=e(120);r(r.P+r.R,"Promise",{finally:function(t){var n=u(this,i.Promise||o.Promise),e="function"==typeof t;return this.then(e?function(e){return a(n,t()).then((function(){return e}))}:t,e?function(e){return a(n,t()).then((function(){throw e}))}:t)}})},function(t,n,e){e(299),e(300),e(301),t.exports=e(7)},function(t,n,e){var r=e(1),i=e(0),o=e(59),u=[].slice,a=/MSIE .\./.test(o),c=function(t){return function(n,e){var r=arguments.length>2,i=!!r&&u.call(arguments,2);return t(r?function(){("function"==typeof n?n:Function(n)).apply(this,i)}:n,e)}};i(i.G+i.B+i.F*a,{setTimeout:c(r.setTimeout),setInterval:c(r.setInterval)})},function(t,n,e){var r=e(0),i=e(85);r(r.G+r.B,{setImmediate:i.set,clearImmediate:i.clear})},function(t,n,e){for(var r=e(82),i=e(33),o=e(11),u=e(1),a=e(14),c=e(42),s=e(5),f=s("iterator"),l=s("toStringTag"),h=c.Array,d={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},p=i(d),v=0;v=0;--o){var u=this.tryEntries[o],a=u.completion;if("root"===u.tryLoc)return i("end");if(u.tryLoc<=this.prev){var c=r.call(u,"catchLoc"),s=r.call(u,"finallyLoc");if(c&&s){if(this.prev=0;--e){var i=this.tryEntries[e];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--n){var e=this.tryEntries[n];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),O(e),p}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.tryLoc===t){var r=e.completion;if("throw"===r.type){var i=r.arg;O(e)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:F(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),p}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}},function(t,n,e){e(304),t.exports=e(127).global},function(t,n,e){var r=e(305);r(r.G,{global:e(87)})},function(t,n,e){var r=e(87),i=e(127),o=e(306),u=e(308),a=e(315),c=function(t,n,e){var s,f,l,h=t&c.F,d=t&c.G,p=t&c.S,v=t&c.P,g=t&c.B,y=t&c.W,m=d?i:i[n]||(i[n]={}),b=m.prototype,S=d?r:p?r[n]:(r[n]||{}).prototype;for(s in d&&(e=n),e)(f=!h&&S&&void 0!==S[s])&&a(m,s)||(l=f?S[s]:e[s],m[s]=d&&"function"!=typeof S[s]?e[s]:g&&f?o(l,r):y&&S[s]==l?function(t){var n=function(n,e,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(n);case 2:return new t(n,e)}return new t(n,e,r)}return t.apply(this,arguments)};return n.prototype=t.prototype,n}(l):v&&"function"==typeof l?o(Function.call,l):l,v&&((m.virtual||(m.virtual={}))[s]=l,t&c.R&&b&&!b[s]&&u(b,s,l)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,t.exports=c},function(t,n,e){var r=e(307);t.exports=function(t,n,e){if(r(t),void 0===n)return t;switch(e){case 1:return function(e){return t.call(n,e)};case 2:return function(e,r){return t.call(n,e,r)};case 3:return function(e,r,i){return t.call(n,e,r,i)}}return function(){return t.apply(n,arguments)}}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,e){var r=e(309),i=e(314);t.exports=e(89)?function(t,n,e){return r.f(t,n,i(1,e))}:function(t,n,e){return t[n]=e,t}},function(t,n,e){var r=e(310),i=e(311),o=e(313),u=Object.defineProperty;n.f=e(89)?Object.defineProperty:function(t,n,e){if(r(t),n=o(n,!0),r(e),i)try{return u(t,n,e)}catch(t){}if("get"in e||"set"in e)throw TypeError("Accessors not supported!");return"value"in e&&(t[n]=e.value),t}},function(t,n,e){var r=e(88);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},function(t,n,e){t.exports=!e(89)&&!e(128)((function(){return 7!=Object.defineProperty(e(312)("div"),"a",{get:function(){return 7}}).a}))},function(t,n,e){var r=e(88),i=e(87).document,o=r(i)&&r(i.createElement);t.exports=function(t){return o?i.createElement(t):{}}},function(t,n,e){var r=e(88);t.exports=function(t,n){if(!r(t))return t;var e,i;if(n&&"function"==typeof(e=t.toString)&&!r(i=e.call(t)))return i;if("function"==typeof(e=t.valueOf)&&!r(i=e.call(t)))return i;if(!n&&"function"==typeof(e=t.toString)&&!r(i=e.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n){var e={}.hasOwnProperty;t.exports=function(t,n){return e.call(t,n)}}])})); ================================================ FILE: vipercard/vipercard/external/bowser-2.9/bowser.d.ts ================================================ // Type definitions for Bowser v2 // Project: https://github.com/lancedikson/bowser // Definitions by: Alexander P. Cerutti , export = Bowser; export as namespace Bowser; export declare namespace Bowser { /** * Creates a Parser instance * @param {string} UA - User agent string * @param {boolean} skipParsing */ function getParser(UA: string, skipParsing?: boolean): Parser.Parser; /** * Creates a Parser instance and runs Parser.getResult immediately * @param UA - User agent string * @returns {Parser.ParsedResult} */ function parse(UA: string): Parser.ParsedResult; /** * Constants exposed via bowser getters */ const BROWSER_MAP: Record; const ENGINE_MAP: Record; const OS_MAP: Record; const PLATFORMS_MAP: Record; namespace Parser { interface Parser { constructor(UA: string, skipParsing?: boolean): Parser.Parser; /** * Get parsed browser object * @return {BrowserDetails} Browser's details */ getBrowser(): BrowserDetails; /** * Get browser's name * @return {String} Browser's name or an empty string */ getBrowserName(): string; /** * Get browser's version * @return {String} version of browser */ getBrowserVersion(): string; /** * Get OS * @return {OSDetails} - OS Details * * @example * this.getOS(); // { * // name: 'macOS', * // version: '10.11.12', * // } */ getOS(): OSDetails; /** * Get OS name * @param {Boolean} [toLowerCase] return lower-cased value * @return {String} name of the OS — macOS, Windows, Linux, etc. */ getOSName(toLowerCase?: boolean): string; /** * Get OS version * @return {String} full version with dots ('10.11.12', '5.6', etc) */ getOSVersion(): string; /** * Get parsed platform * @returns {PlatformDetails} */ getPlatform(): PlatformDetails; /** * Get platform name * @param {boolean} toLowerCase */ getPlatformType(toLowerCase?: boolean): string; /** * Get parsed engine * @returns {EngineDetails} */ getEngine(): EngineDetails; /** * Get parsed result * @return {ParsedResult} */ getResult(): ParsedResult; /** * Get UserAgent string of current Parser instance * @return {String} User-Agent String of the current object */ getUA(): string; /** * Is anything? Check if the browser is called "anything", * the OS called "anything" or the platform called "anything" * @param {String} anything * @returns {Boolean} */ is(anything: any): boolean; /** * Parse full information about the browser */ parse(): void; /** * Get parsed browser object * @returns {BrowserDetails} */ parseBrowser(): BrowserDetails; /** * Get parsed engine * @returns {EngineDetails} */ parseEngine(): EngineDetails; /** * Parse OS and save it to this.parsedResult.os * @returns {OSDetails} */ parseOS(): OSDetails; /** * Get parsed platform * @returns {PlatformDetails} */ parsePlatform(): PlatformDetails; /** * Check if parsed browser matches certain conditions * * @param {checkTree} checkTree It's one or two layered object, * which can include a platform or an OS on the first layer * and should have browsers specs on the bottom-laying layer * * @returns {Boolean|undefined} Whether the browser satisfies the set conditions or not. * Returns `undefined` when the browser is no described in the checkTree object. * * @example * const browser = new Bowser(UA); * if (browser.check({chrome: '>118.01.1322' })) * // or with os * if (browser.check({windows: { chrome: '>118.01.1322' } })) * // or with platforms * if (browser.check({desktop: { chrome: '>118.01.1322' } })) */ satisfies(checkTree: checkTree): boolean | undefined; /** * Check if the browser name equals the passed string * @param browserName The string to compare with the browser name * @param [includingAlias=false] The flag showing whether alias will be included into comparison * @returns {boolean} */ isBrowser(browserName: string, includingAlias?: boolean): boolean; /** * Check if any of the given values satifies `.is(anything)` * @param {string[]} anythings * @returns {boolean} true if at least one condition is satisfied, false otherwise. */ some(anythings: string[]): boolean | undefined; /** * Test a UA string for a regexp * @param regex * @returns {boolean} true if the regex matches the UA, false otherwise. */ test(regex: RegExp): boolean; } interface ParsedResult { browser: BrowserDetails; os: OSDetails; platform: PlatformDetails; engine: EngineDetails; } interface Details { name?: string; version?: string; } interface OSDetails extends Details { versionName?: string; } interface PlatformDetails { type?: string; vendor?: string; model?: string; } type BrowserDetails = Details; type EngineDetails = Details; interface checkTree { [key: string]: any; } } } ================================================ FILE: vipercard/vipercard/external/chevrotain-6.5.0/LICENSE.txt ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: vipercard/vipercard/external/chevrotain-6.5.0/README.md ================================================ # Chevrotain For details see: - Chevrotain's [website](https://sap.github.io/chevrotain/docs/). - Chevrotain's root [README](https://github.com/SAP/chevrotain). ## Install Using npm: ```sh npm install chevrotain ``` or using yarn: ```sh yarn add chevrotain ``` ================================================ FILE: vipercard/vipercard/external/chevrotain-6.5.0/chevrotain.js ================================================ /*! chevrotain - v6.5.0 */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define("chevrotain", [], factory); else if(typeof exports === 'object') exports["chevrotain"] = factory(); else root["chevrotain"] = factory(); })(typeof self !== 'undefined' ? self : this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 18); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* Utils using lodash style API. (not necessarily 100% compliant) for functional and other utils. These utils should replace usage of lodash in the production code base. not because they are any better... but for the purpose of being a dependency free library. The hotspots in the code are already written in imperative style for performance reasons. so writing several dozen utils which may be slower than the original lodash, does not matter as much considering they will not be invoked in hotspots... */ Object.defineProperty(exports, "__esModule", { value: true }); function isEmpty(arr) { return arr && arr.length === 0; } exports.isEmpty = isEmpty; function keys(obj) { if (obj === undefined || obj === null) { return []; } return Object.keys(obj); } exports.keys = keys; function values(obj) { var vals = []; var keys = Object.keys(obj); for (var i = 0; i < keys.length; i++) { vals.push(obj[keys[i]]); } return vals; } exports.values = values; function mapValues(obj, callback) { var result = []; var objKeys = keys(obj); for (var idx = 0; idx < objKeys.length; idx++) { var currKey = objKeys[idx]; result.push(callback.call(null, obj[currKey], currKey)); } return result; } exports.mapValues = mapValues; function map(arr, callback) { var result = []; for (var idx = 0; idx < arr.length; idx++) { result.push(callback.call(null, arr[idx], idx)); } return result; } exports.map = map; function flatten(arr) { var result = []; for (var idx = 0; idx < arr.length; idx++) { var currItem = arr[idx]; if (Array.isArray(currItem)) { result = result.concat(flatten(currItem)); } else { result.push(currItem); } } return result; } exports.flatten = flatten; function first(arr) { return isEmpty(arr) ? undefined : arr[0]; } exports.first = first; function last(arr) { var len = arr && arr.length; return len ? arr[len - 1] : undefined; } exports.last = last; function forEach(collection, iteratorCallback) { /* istanbul ignore else */ if (Array.isArray(collection)) { for (var i = 0; i < collection.length; i++) { iteratorCallback.call(null, collection[i], i); } } else if (isObject(collection)) { var colKeys = keys(collection); for (var i = 0; i < colKeys.length; i++) { var key = colKeys[i]; var value = collection[key]; iteratorCallback.call(null, value, key); } } else { throw Error("non exhaustive match"); } } exports.forEach = forEach; function isString(item) { return typeof item === "string"; } exports.isString = isString; function isUndefined(item) { return item === undefined; } exports.isUndefined = isUndefined; function isFunction(item) { return item instanceof Function; } exports.isFunction = isFunction; function drop(arr, howMuch) { if (howMuch === void 0) { howMuch = 1; } return arr.slice(howMuch, arr.length); } exports.drop = drop; function dropRight(arr, howMuch) { if (howMuch === void 0) { howMuch = 1; } return arr.slice(0, arr.length - howMuch); } exports.dropRight = dropRight; function filter(arr, predicate) { var result = []; if (Array.isArray(arr)) { for (var i = 0; i < arr.length; i++) { var item = arr[i]; if (predicate.call(null, item)) { result.push(item); } } } return result; } exports.filter = filter; function reject(arr, predicate) { return filter(arr, function (item) { return !predicate(item); }); } exports.reject = reject; function pick(obj, predicate) { var keys = Object.keys(obj); var result = {}; for (var i = 0; i < keys.length; i++) { var currKey = keys[i]; var currItem = obj[currKey]; if (predicate(currItem)) { result[currKey] = currItem; } } return result; } exports.pick = pick; function has(obj, prop) { if (isObject(obj)) { return obj.hasOwnProperty(prop); } return false; } exports.has = has; function contains(arr, item) { return find(arr, function (currItem) { return currItem === item; }) !== undefined ? true : false; } exports.contains = contains; /** * shallow clone */ function cloneArr(arr) { var newArr = []; for (var i = 0; i < arr.length; i++) { newArr.push(arr[i]); } return newArr; } exports.cloneArr = cloneArr; /** * shallow clone */ function cloneObj(obj) { var clonedObj = {}; for (var key in obj) { /* istanbul ignore else */ if (Object.prototype.hasOwnProperty.call(obj, key)) { clonedObj[key] = obj[key]; } } return clonedObj; } exports.cloneObj = cloneObj; function find(arr, predicate) { for (var i = 0; i < arr.length; i++) { var item = arr[i]; if (predicate.call(null, item)) { return item; } } return undefined; } exports.find = find; function findAll(arr, predicate) { var found = []; for (var i = 0; i < arr.length; i++) { var item = arr[i]; if (predicate.call(null, item)) { found.push(item); } } return found; } exports.findAll = findAll; function reduce(arrOrObj, iterator, initial) { var isArr = Array.isArray(arrOrObj); var vals = isArr ? arrOrObj : values(arrOrObj); var objKeys = isArr ? [] : keys(arrOrObj); var accumulator = initial; for (var i = 0; i < vals.length; i++) { accumulator = iterator.call(null, accumulator, vals[i], isArr ? i : objKeys[i]); } return accumulator; } exports.reduce = reduce; function compact(arr) { return reject(arr, function (item) { return item === null || item === undefined; }); } exports.compact = compact; function uniq(arr, identity) { if (identity === void 0) { identity = function (item) { return item; }; } var identities = []; return reduce(arr, function (result, currItem) { var currIdentity = identity(currItem); if (contains(identities, currIdentity)) { return result; } else { identities.push(currIdentity); return result.concat(currItem); } }, []); } exports.uniq = uniq; function partial(func) { var restArgs = []; for (var _i = 1; _i < arguments.length; _i++) { restArgs[_i - 1] = arguments[_i]; } var firstArg = [null]; var allArgs = firstArg.concat(restArgs); return Function.bind.apply(func, allArgs); } exports.partial = partial; function isArray(obj) { return Array.isArray(obj); } exports.isArray = isArray; function isRegExp(obj) { return obj instanceof RegExp; } exports.isRegExp = isRegExp; function isObject(obj) { return obj instanceof Object; } exports.isObject = isObject; function every(arr, predicate) { for (var i = 0; i < arr.length; i++) { if (!predicate(arr[i], i)) { return false; } } return true; } exports.every = every; function difference(arr, values) { return reject(arr, function (item) { return contains(values, item); }); } exports.difference = difference; function some(arr, predicate) { for (var i = 0; i < arr.length; i++) { if (predicate(arr[i])) { return true; } } return false; } exports.some = some; function indexOf(arr, value) { for (var i = 0; i < arr.length; i++) { if (arr[i] === value) { return i; } } return -1; } exports.indexOf = indexOf; function sortBy(arr, orderFunc) { var result = cloneArr(arr); result.sort(function (a, b) { return orderFunc(a) - orderFunc(b); }); return result; } exports.sortBy = sortBy; function zipObject(keys, values) { if (keys.length !== values.length) { throw Error("can't zipObject with different number of keys and values!"); } var result = {}; for (var i = 0; i < keys.length; i++) { result[keys[i]] = values[i]; } return result; } exports.zipObject = zipObject; /** * mutates! (and returns) target */ function assign(target) { var sources = []; for (var _i = 1; _i < arguments.length; _i++) { sources[_i - 1] = arguments[_i]; } for (var i = 0; i < sources.length; i++) { var curSource = sources[i]; var currSourceKeys = keys(curSource); for (var j = 0; j < currSourceKeys.length; j++) { var currKey = currSourceKeys[j]; target[currKey] = curSource[currKey]; } } return target; } exports.assign = assign; /** * mutates! (and returns) target */ function assignNoOverwrite(target) { var sources = []; for (var _i = 1; _i < arguments.length; _i++) { sources[_i - 1] = arguments[_i]; } for (var i = 0; i < sources.length; i++) { var curSource = sources[i]; if (isUndefined(curSource)) { continue; } var currSourceKeys = keys(curSource); for (var j = 0; j < currSourceKeys.length; j++) { var currKey = currSourceKeys[j]; if (!has(target, currKey)) { target[currKey] = curSource[currKey]; } } } return target; } exports.assignNoOverwrite = assignNoOverwrite; function defaults() { var sources = []; for (var _i = 0; _i < arguments.length; _i++) { sources[_i] = arguments[_i]; } return assignNoOverwrite.apply(null, [{}].concat(sources)); } exports.defaults = defaults; function groupBy(arr, groupKeyFunc) { var result = {}; forEach(arr, function (item) { var currGroupKey = groupKeyFunc(item); var currGroupArr = result[currGroupKey]; if (currGroupArr) { currGroupArr.push(item); } else { result[currGroupKey] = [item]; } }); return result; } exports.groupBy = groupBy; /** * Merge obj2 into obj1. * Will overwrite existing properties with the same name */ function merge(obj1, obj2) { var result = cloneObj(obj1); var keys2 = keys(obj2); for (var i = 0; i < keys2.length; i++) { var key = keys2[i]; var value = obj2[key]; result[key] = value; } return result; } exports.merge = merge; function NOOP() { } exports.NOOP = NOOP; function IDENTITY(item) { return item; } exports.IDENTITY = IDENTITY; /** * Will return a new packed array with same values. */ function packArray(holeyArr) { var result = []; for (var i = 0; i < holeyArr.length; i++) { var orgValue = holeyArr[i]; result.push(orgValue !== undefined ? orgValue : undefined); } return result; } exports.packArray = packArray; function PRINT_ERROR(msg) { /* istanbul ignore else - can't override global.console in node.js */ if (console && console.error) { console.error("Error: " + msg); } } exports.PRINT_ERROR = PRINT_ERROR; function PRINT_WARNING(msg) { /* istanbul ignore else - can't override global.console in node.js*/ if (console && console.warn) { // TODO: modify docs accordingly console.warn("Warning: " + msg); } } exports.PRINT_WARNING = PRINT_WARNING; function isES2015MapSupported() { return typeof Map === "function"; } exports.isES2015MapSupported = isES2015MapSupported; function applyMixins(derivedCtor, baseCtors) { baseCtors.forEach(function (baseCtor) { var baseProto = baseCtor.prototype; Object.getOwnPropertyNames(baseProto).forEach(function (propName) { if (propName === "constructor") { return; } var basePropDescriptor = Object.getOwnPropertyDescriptor(baseProto, propName); // Handle Accessors if (basePropDescriptor && (basePropDescriptor.get || basePropDescriptor.set)) { Object.defineProperty(derivedCtor.prototype, propName, basePropDescriptor); } else { derivedCtor.prototype[propName] = baseCtor.prototype[propName]; } }); }); } exports.applyMixins = applyMixins; // base on: https://github.com/petkaantonov/bluebird/blob/b97c0d2d487e8c5076e8bd897e0dcd4622d31846/src/util.js#L201-L216 function toFastProperties(toBecomeFast) { function FakeConstructor() { } // If our object is used as a constructor it would receive FakeConstructor.prototype = toBecomeFast; var fakeInstance = new FakeConstructor(); function fakeAccess() { return typeof fakeInstance.bar; } // help V8 understand this is a "real" prototype by actually using // the fake instance. fakeAccess(); fakeAccess(); return toBecomeFast; // Eval prevents optimization of this method (even though this is dead code) /* istanbul ignore next */ // tslint:disable-next-line eval(toBecomeFast); } exports.toFastProperties = toFastProperties; function peek(arr) { return arr[arr.length - 1]; } exports.peek = peek; /* istanbul ignore next - for performance tracing*/ function timer(func) { var start = new Date().getTime(); var val = func(); var end = new Date().getTime(); var total = end - start; return { time: total, value: val }; } exports.timer = timer; //# sourceMappingURL=utils.js.map /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var tokens_public_1 = __webpack_require__(3); var AbstractProduction = /** @class */ (function () { function AbstractProduction(definition) { this.definition = definition; } AbstractProduction.prototype.accept = function (visitor) { visitor.visit(this); utils_1.forEach(this.definition, function (prod) { prod.accept(visitor); }); }; return AbstractProduction; }()); exports.AbstractProduction = AbstractProduction; var NonTerminal = /** @class */ (function (_super) { __extends(NonTerminal, _super); function NonTerminal(options) { var _this = _super.call(this, []) || this; _this.idx = 1; utils_1.assign(_this, utils_1.pick(options, function (v) { return v !== undefined; })); return _this; } Object.defineProperty(NonTerminal.prototype, "definition", { get: function () { if (this.referencedRule !== undefined) { return this.referencedRule.definition; } return []; }, set: function (definition) { // immutable }, enumerable: true, configurable: true }); NonTerminal.prototype.accept = function (visitor) { visitor.visit(this); // don't visit children of a reference, we will get cyclic infinite loops if we do so }; return NonTerminal; }(AbstractProduction)); exports.NonTerminal = NonTerminal; var Rule = /** @class */ (function (_super) { __extends(Rule, _super); function Rule(options) { var _this = _super.call(this, options.definition) || this; _this.orgText = ""; utils_1.assign(_this, utils_1.pick(options, function (v) { return v !== undefined; })); return _this; } return Rule; }(AbstractProduction)); exports.Rule = Rule; // TODO: is this only used in an Alternation? // Perhaps `Flat` should be renamed to `Alternative`? var Flat = /** @class */ (function (_super) { __extends(Flat, _super); // A named Flat production is used to indicate a Nested Rule in an alternation function Flat(options) { var _this = _super.call(this, options.definition) || this; _this.ignoreAmbiguities = false; utils_1.assign(_this, utils_1.pick(options, function (v) { return v !== undefined; })); return _this; } return Flat; }(AbstractProduction)); exports.Flat = Flat; var Option = /** @class */ (function (_super) { __extends(Option, _super); function Option(options) { var _this = _super.call(this, options.definition) || this; _this.idx = 1; utils_1.assign(_this, utils_1.pick(options, function (v) { return v !== undefined; })); return _this; } return Option; }(AbstractProduction)); exports.Option = Option; var RepetitionMandatory = /** @class */ (function (_super) { __extends(RepetitionMandatory, _super); function RepetitionMandatory(options) { var _this = _super.call(this, options.definition) || this; _this.idx = 1; utils_1.assign(_this, utils_1.pick(options, function (v) { return v !== undefined; })); return _this; } return RepetitionMandatory; }(AbstractProduction)); exports.RepetitionMandatory = RepetitionMandatory; var RepetitionMandatoryWithSeparator = /** @class */ (function (_super) { __extends(RepetitionMandatoryWithSeparator, _super); function RepetitionMandatoryWithSeparator(options) { var _this = _super.call(this, options.definition) || this; _this.idx = 1; utils_1.assign(_this, utils_1.pick(options, function (v) { return v !== undefined; })); return _this; } return RepetitionMandatoryWithSeparator; }(AbstractProduction)); exports.RepetitionMandatoryWithSeparator = RepetitionMandatoryWithSeparator; var Repetition = /** @class */ (function (_super) { __extends(Repetition, _super); function Repetition(options) { var _this = _super.call(this, options.definition) || this; _this.idx = 1; utils_1.assign(_this, utils_1.pick(options, function (v) { return v !== undefined; })); return _this; } return Repetition; }(AbstractProduction)); exports.Repetition = Repetition; var RepetitionWithSeparator = /** @class */ (function (_super) { __extends(RepetitionWithSeparator, _super); function RepetitionWithSeparator(options) { var _this = _super.call(this, options.definition) || this; _this.idx = 1; utils_1.assign(_this, utils_1.pick(options, function (v) { return v !== undefined; })); return _this; } return RepetitionWithSeparator; }(AbstractProduction)); exports.RepetitionWithSeparator = RepetitionWithSeparator; var Alternation = /** @class */ (function (_super) { __extends(Alternation, _super); function Alternation(options) { var _this = _super.call(this, options.definition) || this; _this.idx = 1; _this.ignoreAmbiguities = false; _this.hasPredicates = false; utils_1.assign(_this, utils_1.pick(options, function (v) { return v !== undefined; })); return _this; } return Alternation; }(AbstractProduction)); exports.Alternation = Alternation; var Terminal = /** @class */ (function () { function Terminal(options) { this.idx = 1; utils_1.assign(this, utils_1.pick(options, function (v) { return v !== undefined; })); } Terminal.prototype.accept = function (visitor) { visitor.visit(this); }; return Terminal; }()); exports.Terminal = Terminal; function serializeGrammar(topRules) { return utils_1.map(topRules, serializeProduction); } exports.serializeGrammar = serializeGrammar; function serializeProduction(node) { function convertDefinition(definition) { return utils_1.map(definition, serializeProduction); } /* istanbul ignore else */ if (node instanceof NonTerminal) { return { type: "NonTerminal", name: node.nonTerminalName, idx: node.idx }; } else if (node instanceof Flat) { return { type: "Flat", definition: convertDefinition(node.definition) }; } else if (node instanceof Option) { return { type: "Option", idx: node.idx, definition: convertDefinition(node.definition) }; } else if (node instanceof RepetitionMandatory) { return { type: "RepetitionMandatory", name: node.name, idx: node.idx, definition: convertDefinition(node.definition) }; } else if (node instanceof RepetitionMandatoryWithSeparator) { return { type: "RepetitionMandatoryWithSeparator", name: node.name, idx: node.idx, separator: (serializeProduction(new Terminal({ terminalType: node.separator }))), definition: convertDefinition(node.definition) }; } else if (node instanceof RepetitionWithSeparator) { return { type: "RepetitionWithSeparator", name: node.name, idx: node.idx, separator: (serializeProduction(new Terminal({ terminalType: node.separator }))), definition: convertDefinition(node.definition) }; } else if (node instanceof Repetition) { return { type: "Repetition", name: node.name, idx: node.idx, definition: convertDefinition(node.definition) }; } else if (node instanceof Alternation) { return { type: "Alternation", name: node.name, idx: node.idx, definition: convertDefinition(node.definition) }; } else if (node instanceof Terminal) { var serializedTerminal = { type: "Terminal", name: node.terminalType.name, label: tokens_public_1.tokenLabel(node.terminalType), idx: node.idx }; var pattern = node.terminalType.PATTERN; if (node.terminalType.PATTERN) { serializedTerminal.pattern = utils_1.isRegExp(pattern) ? pattern.source : pattern; } return serializedTerminal; } else if (node instanceof Rule) { return { type: "Rule", name: node.name, orgText: node.orgText, definition: convertDefinition(node.definition) }; } else { throw Error("non exhaustive match"); } } exports.serializeProduction = serializeProduction; //# sourceMappingURL=gast_public.js.map /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var follow_1 = __webpack_require__(27); var tokens_public_1 = __webpack_require__(3); var cst_1 = __webpack_require__(17); var errors_public_1 = __webpack_require__(10); var gast_resolver_public_1 = __webpack_require__(24); var recoverable_1 = __webpack_require__(25); var looksahead_1 = __webpack_require__(30); var tree_builder_1 = __webpack_require__(31); var lexer_adapter_1 = __webpack_require__(33); var recognizer_api_1 = __webpack_require__(34); var recognizer_engine_1 = __webpack_require__(35); var error_handler_1 = __webpack_require__(36); var context_assist_1 = __webpack_require__(37); var gast_recorder_1 = __webpack_require__(38); var perf_tracer_1 = __webpack_require__(39); exports.END_OF_FILE = tokens_public_1.createTokenInstance(tokens_public_1.EOF, "", NaN, NaN, NaN, NaN, NaN, NaN); Object.freeze(exports.END_OF_FILE); exports.DEFAULT_PARSER_CONFIG = Object.freeze({ recoveryEnabled: false, maxLookahead: 4, ignoredIssues: {}, dynamicTokensEnabled: false, outputCst: true, errorMessageProvider: errors_public_1.defaultParserErrorProvider, nodeLocationTracking: "none", traceInitPerf: false, skipValidations: false }); exports.DEFAULT_RULE_CONFIG = Object.freeze({ recoveryValueFunc: function () { return undefined; }, resyncEnabled: true }); var ParserDefinitionErrorType; (function (ParserDefinitionErrorType) { ParserDefinitionErrorType[ParserDefinitionErrorType["INVALID_RULE_NAME"] = 0] = "INVALID_RULE_NAME"; ParserDefinitionErrorType[ParserDefinitionErrorType["DUPLICATE_RULE_NAME"] = 1] = "DUPLICATE_RULE_NAME"; ParserDefinitionErrorType[ParserDefinitionErrorType["INVALID_RULE_OVERRIDE"] = 2] = "INVALID_RULE_OVERRIDE"; ParserDefinitionErrorType[ParserDefinitionErrorType["DUPLICATE_PRODUCTIONS"] = 3] = "DUPLICATE_PRODUCTIONS"; ParserDefinitionErrorType[ParserDefinitionErrorType["UNRESOLVED_SUBRULE_REF"] = 4] = "UNRESOLVED_SUBRULE_REF"; ParserDefinitionErrorType[ParserDefinitionErrorType["LEFT_RECURSION"] = 5] = "LEFT_RECURSION"; ParserDefinitionErrorType[ParserDefinitionErrorType["NONE_LAST_EMPTY_ALT"] = 6] = "NONE_LAST_EMPTY_ALT"; ParserDefinitionErrorType[ParserDefinitionErrorType["AMBIGUOUS_ALTS"] = 7] = "AMBIGUOUS_ALTS"; ParserDefinitionErrorType[ParserDefinitionErrorType["CONFLICT_TOKENS_RULES_NAMESPACE"] = 8] = "CONFLICT_TOKENS_RULES_NAMESPACE"; ParserDefinitionErrorType[ParserDefinitionErrorType["INVALID_TOKEN_NAME"] = 9] = "INVALID_TOKEN_NAME"; ParserDefinitionErrorType[ParserDefinitionErrorType["INVALID_NESTED_RULE_NAME"] = 10] = "INVALID_NESTED_RULE_NAME"; ParserDefinitionErrorType[ParserDefinitionErrorType["DUPLICATE_NESTED_NAME"] = 11] = "DUPLICATE_NESTED_NAME"; ParserDefinitionErrorType[ParserDefinitionErrorType["NO_NON_EMPTY_LOOKAHEAD"] = 12] = "NO_NON_EMPTY_LOOKAHEAD"; ParserDefinitionErrorType[ParserDefinitionErrorType["AMBIGUOUS_PREFIX_ALTS"] = 13] = "AMBIGUOUS_PREFIX_ALTS"; ParserDefinitionErrorType[ParserDefinitionErrorType["TOO_MANY_ALTS"] = 14] = "TOO_MANY_ALTS"; })(ParserDefinitionErrorType = exports.ParserDefinitionErrorType || (exports.ParserDefinitionErrorType = {})); function EMPTY_ALT(value) { if (value === void 0) { value = undefined; } return function () { return value; }; } exports.EMPTY_ALT = EMPTY_ALT; var Parser = /** @class */ (function () { function Parser(tokenVocabulary, config) { if (config === void 0) { config = exports.DEFAULT_PARSER_CONFIG; } this.ignoredIssues = exports.DEFAULT_PARSER_CONFIG.ignoredIssues; this.definitionErrors = []; this.selfAnalysisDone = false; var that = this; that.initErrorHandler(config); that.initLexerAdapter(); that.initLooksAhead(config); that.initRecognizerEngine(tokenVocabulary, config); that.initRecoverable(config); that.initTreeBuilder(config); that.initContentAssist(); that.initGastRecorder(config); that.initPerformanceTracer(config); /* istanbul ignore if - complete over-kill to test this, we should only add a test when we actually hard deprecate it and throw an error... */ if (utils_1.has(config, "ignoredIssues") && config.ignoredIssues !== exports.DEFAULT_PARSER_CONFIG.ignoredIssues) { utils_1.PRINT_WARNING("The IParserConfig property is soft-deprecated and will be removed in future versions.\n\t" + "Please use the flag on the relevant DSL method instead."); } this.ignoredIssues = utils_1.has(config, "ignoredIssues") ? config.ignoredIssues : exports.DEFAULT_PARSER_CONFIG.ignoredIssues; this.skipValidations = utils_1.has(config, "skipValidations") ? config.skipValidations : exports.DEFAULT_PARSER_CONFIG.skipValidations; } /** * @deprecated use the **instance** method with the same name instead */ Parser.performSelfAnalysis = function (parserInstance) { ; parserInstance.performSelfAnalysis(); }; Parser.prototype.performSelfAnalysis = function () { var _this = this; this.TRACE_INIT("performSelfAnalysis", function () { var defErrorsMsgs; _this.selfAnalysisDone = true; var className = _this.className; _this.TRACE_INIT("toFastProps", function () { // Without this voodoo magic the parser would be x3-x4 slower // It seems it is better to invoke `toFastProperties` **before** // Any manipulations of the `this` object done during the recording phase. utils_1.toFastProperties(_this); }); _this.TRACE_INIT("Grammar Recording", function () { try { _this.enableRecording(); // Building the GAST utils_1.forEach(_this.definedRulesNames, function (currRuleName) { var wrappedRule = _this[currRuleName]; var originalGrammarAction = wrappedRule["originalGrammarAction"]; var recordedRuleGast = undefined; _this.TRACE_INIT(currRuleName + " Rule", function () { recordedRuleGast = _this.topLevelRuleRecord(currRuleName, originalGrammarAction); }); _this.gastProductionsCache[currRuleName] = recordedRuleGast; }); } finally { _this.disableRecording(); } }); var resolverErrors = []; _this.TRACE_INIT("Grammar Resolving", function () { resolverErrors = gast_resolver_public_1.resolveGrammar({ rules: utils_1.values(_this.gastProductionsCache) }); _this.definitionErrors.push.apply(_this.definitionErrors, resolverErrors); // mutability for the win? }); _this.TRACE_INIT("Grammar Validations", function () { // only perform additional grammar validations IFF no resolving errors have occurred. // as unresolved grammar may lead to unhandled runtime exceptions in the follow up validations. if (utils_1.isEmpty(resolverErrors) && _this.skipValidations === false) { var validationErrors = gast_resolver_public_1.validateGrammar({ rules: utils_1.values(_this.gastProductionsCache), maxLookahead: _this.maxLookahead, tokenTypes: utils_1.values(_this.tokensMap), ignoredIssues: _this.ignoredIssues, errMsgProvider: errors_public_1.defaultGrammarValidatorErrorProvider, grammarName: className }); _this.definitionErrors.push.apply(_this.definitionErrors, validationErrors); // mutability for the win? } }); // this analysis may fail if the grammar is not perfectly valid if (utils_1.isEmpty(_this.definitionErrors)) { // The results of these computations are not needed unless error recovery is enabled. if (_this.recoveryEnabled) { _this.TRACE_INIT("computeAllProdsFollows", function () { var allFollows = follow_1.computeAllProdsFollows(utils_1.values(_this.gastProductionsCache)); _this.resyncFollows = allFollows; }); } _this.TRACE_INIT("ComputeLookaheadFunctions", function () { _this.preComputeLookaheadFunctions(utils_1.values(_this.gastProductionsCache)); }); } _this.TRACE_INIT("expandAllNestedRuleNames", function () { // TODO: is this needed for EmbeddedActionsParser? var cstAnalysisResult = cst_1.expandAllNestedRuleNames(utils_1.values(_this.gastProductionsCache), _this.fullRuleNameToShort); _this.allRuleNames = cstAnalysisResult.allRuleNames; }); if (!Parser.DEFER_DEFINITION_ERRORS_HANDLING && !utils_1.isEmpty(_this.definitionErrors)) { defErrorsMsgs = utils_1.map(_this.definitionErrors, function (defError) { return defError.message; }); throw new Error("Parser Definition Errors detected:\n " + defErrorsMsgs.join("\n-------------------------------\n")); } }); }; // Set this flag to true if you don't want the Parser to throw error when problems in it's definition are detected. // (normally during the parser's constructor). // This is a design time flag, it will not affect the runtime error handling of the parser, just design time errors, // for example: duplicate rule names, referencing an unresolved subrule, ect... // This flag should not be enabled during normal usage, it is used in special situations, for example when // needing to display the parser definition errors in some GUI(online playground). Parser.DEFER_DEFINITION_ERRORS_HANDLING = false; return Parser; }()); exports.Parser = Parser; utils_1.applyMixins(Parser, [ recoverable_1.Recoverable, looksahead_1.LooksAhead, tree_builder_1.TreeBuilder, lexer_adapter_1.LexerAdapter, recognizer_engine_1.RecognizerEngine, recognizer_api_1.RecognizerApi, error_handler_1.ErrorHandler, context_assist_1.ContentAssist, gast_recorder_1.GastRecorder, perf_tracer_1.PerformanceTracer ]); var CstParser = /** @class */ (function (_super) { __extends(CstParser, _super); function CstParser(tokenVocabulary, config) { if (config === void 0) { config = exports.DEFAULT_PARSER_CONFIG; } var _this = this; var configClone = utils_1.cloneObj(config); configClone.outputCst = true; _this = _super.call(this, tokenVocabulary, configClone) || this; return _this; } return CstParser; }(Parser)); exports.CstParser = CstParser; var EmbeddedActionsParser = /** @class */ (function (_super) { __extends(EmbeddedActionsParser, _super); function EmbeddedActionsParser(tokenVocabulary, config) { if (config === void 0) { config = exports.DEFAULT_PARSER_CONFIG; } var _this = this; var configClone = utils_1.cloneObj(config); configClone.outputCst = false; _this = _super.call(this, tokenVocabulary, configClone) || this; return _this; } return EmbeddedActionsParser; }(Parser)); exports.EmbeddedActionsParser = EmbeddedActionsParser; //# sourceMappingURL=parser.js.map /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var lexer_public_1 = __webpack_require__(9); var tokens_1 = __webpack_require__(5); function tokenLabel(tokType) { if (hasTokenLabel(tokType)) { return tokType.LABEL; } else { return tokType.name; } } exports.tokenLabel = tokenLabel; function tokenName(tokType) { return tokType.name; } exports.tokenName = tokenName; function hasTokenLabel(obj) { return utils_1.isString(obj.LABEL) && obj.LABEL !== ""; } exports.hasTokenLabel = hasTokenLabel; var PARENT = "parent"; var CATEGORIES = "categories"; var LABEL = "label"; var GROUP = "group"; var PUSH_MODE = "push_mode"; var POP_MODE = "pop_mode"; var LONGER_ALT = "longer_alt"; var LINE_BREAKS = "line_breaks"; var START_CHARS_HINT = "start_chars_hint"; function createToken(config) { return createTokenInternal(config); } exports.createToken = createToken; function createTokenInternal(config) { var pattern = config.pattern; var tokenType = {}; tokenType.name = config.name; if (!utils_1.isUndefined(pattern)) { tokenType.PATTERN = pattern; } if (utils_1.has(config, PARENT)) { throw "The parent property is no longer supported.\n" + "See: https://github.com/SAP/chevrotain/issues/564#issuecomment-349062346 for details."; } if (utils_1.has(config, CATEGORIES)) { // casting to ANY as this will be fixed inside `augmentTokenTypes`` tokenType.CATEGORIES = config[CATEGORIES]; } tokens_1.augmentTokenTypes([tokenType]); if (utils_1.has(config, LABEL)) { tokenType.LABEL = config[LABEL]; } if (utils_1.has(config, GROUP)) { tokenType.GROUP = config[GROUP]; } if (utils_1.has(config, POP_MODE)) { tokenType.POP_MODE = config[POP_MODE]; } if (utils_1.has(config, PUSH_MODE)) { tokenType.PUSH_MODE = config[PUSH_MODE]; } if (utils_1.has(config, LONGER_ALT)) { tokenType.LONGER_ALT = config[LONGER_ALT]; } if (utils_1.has(config, LINE_BREAKS)) { tokenType.LINE_BREAKS = config[LINE_BREAKS]; } if (utils_1.has(config, START_CHARS_HINT)) { tokenType.START_CHARS_HINT = config[START_CHARS_HINT]; } return tokenType; } exports.EOF = createToken({ name: "EOF", pattern: lexer_public_1.Lexer.NA }); tokens_1.augmentTokenTypes([exports.EOF]); function createTokenInstance(tokType, image, startOffset, endOffset, startLine, endLine, startColumn, endColumn) { return { image: image, startOffset: startOffset, endOffset: endOffset, startLine: startLine, endLine: endLine, startColumn: startColumn, endColumn: endColumn, tokenTypeIdx: tokType.tokenTypeIdx, tokenType: tokType }; } exports.createTokenInstance = createTokenInstance; function tokenMatcher(token, tokType) { return tokens_1.tokenStructuredMatcher(token, tokType); } exports.tokenMatcher = tokenMatcher; //# sourceMappingURL=tokens_public.js.map /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var gast_public_1 = __webpack_require__(1); var GAstVisitor = /** @class */ (function () { function GAstVisitor() { } GAstVisitor.prototype.visit = function (node) { var nodeAny = node; switch (nodeAny.constructor) { case gast_public_1.NonTerminal: return this.visitNonTerminal(nodeAny); case gast_public_1.Flat: return this.visitFlat(nodeAny); case gast_public_1.Option: return this.visitOption(nodeAny); case gast_public_1.RepetitionMandatory: return this.visitRepetitionMandatory(nodeAny); case gast_public_1.RepetitionMandatoryWithSeparator: return this.visitRepetitionMandatoryWithSeparator(nodeAny); case gast_public_1.RepetitionWithSeparator: return this.visitRepetitionWithSeparator(nodeAny); case gast_public_1.Repetition: return this.visitRepetition(nodeAny); case gast_public_1.Alternation: return this.visitAlternation(nodeAny); case gast_public_1.Terminal: return this.visitTerminal(nodeAny); case gast_public_1.Rule: return this.visitRule(nodeAny); /* istanbul ignore next */ default: throw Error("non exhaustive match"); } }; GAstVisitor.prototype.visitNonTerminal = function (node) { }; GAstVisitor.prototype.visitFlat = function (node) { }; GAstVisitor.prototype.visitOption = function (node) { }; GAstVisitor.prototype.visitRepetition = function (node) { }; GAstVisitor.prototype.visitRepetitionMandatory = function (node) { }; GAstVisitor.prototype.visitRepetitionMandatoryWithSeparator = function (node) { }; GAstVisitor.prototype.visitRepetitionWithSeparator = function (node) { }; GAstVisitor.prototype.visitAlternation = function (node) { }; GAstVisitor.prototype.visitTerminal = function (node) { }; GAstVisitor.prototype.visitRule = function (node) { }; return GAstVisitor; }()); exports.GAstVisitor = GAstVisitor; //# sourceMappingURL=gast_visitor_public.js.map /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); function tokenStructuredMatcher(tokInstance, tokConstructor) { var instanceType = tokInstance.tokenTypeIdx; if (instanceType === tokConstructor.tokenTypeIdx) { return true; } else { return (tokConstructor.isParent === true && tokConstructor.categoryMatchesMap[instanceType] === true); } } exports.tokenStructuredMatcher = tokenStructuredMatcher; // Optimized tokenMatcher in case our grammar does not use token categories // Being so tiny it is much more likely to be in-lined and this avoid the function call overhead function tokenStructuredMatcherNoCategories(token, tokType) { return token.tokenTypeIdx === tokType.tokenTypeIdx; } exports.tokenStructuredMatcherNoCategories = tokenStructuredMatcherNoCategories; exports.tokenShortNameIdx = 1; exports.tokenIdxToClass = {}; function augmentTokenTypes(tokenTypes) { // collect the parent Token Types as well. var tokenTypesAndParents = expandCategories(tokenTypes); // add required tokenType and categoryMatches properties assignTokenDefaultProps(tokenTypesAndParents); // fill up the categoryMatches assignCategoriesMapProp(tokenTypesAndParents); assignCategoriesTokensProp(tokenTypesAndParents); utils_1.forEach(tokenTypesAndParents, function (tokType) { tokType.isParent = tokType.categoryMatches.length > 0; }); } exports.augmentTokenTypes = augmentTokenTypes; function expandCategories(tokenTypes) { var result = utils_1.cloneArr(tokenTypes); var categories = tokenTypes; var searching = true; while (searching) { categories = utils_1.compact(utils_1.flatten(utils_1.map(categories, function (currTokType) { return currTokType.CATEGORIES; }))); var newCategories = utils_1.difference(categories, result); result = result.concat(newCategories); if (utils_1.isEmpty(newCategories)) { searching = false; } else { categories = newCategories; } } return result; } exports.expandCategories = expandCategories; function assignTokenDefaultProps(tokenTypes) { utils_1.forEach(tokenTypes, function (currTokType) { if (!hasShortKeyProperty(currTokType)) { exports.tokenIdxToClass[exports.tokenShortNameIdx] = currTokType; currTokType.tokenTypeIdx = exports.tokenShortNameIdx++; } // CATEGORIES? : TokenType | TokenType[] if (hasCategoriesProperty(currTokType) && !utils_1.isArray(currTokType.CATEGORIES) // && // !isUndefined(currTokType.CATEGORIES.PATTERN) ) { currTokType.CATEGORIES = [currTokType.CATEGORIES]; } if (!hasCategoriesProperty(currTokType)) { currTokType.CATEGORIES = []; } if (!hasExtendingTokensTypesProperty(currTokType)) { currTokType.categoryMatches = []; } if (!hasExtendingTokensTypesMapProperty(currTokType)) { currTokType.categoryMatchesMap = {}; } }); } exports.assignTokenDefaultProps = assignTokenDefaultProps; function assignCategoriesTokensProp(tokenTypes) { utils_1.forEach(tokenTypes, function (currTokType) { // avoid duplications currTokType.categoryMatches = []; utils_1.forEach(currTokType.categoryMatchesMap, function (val, key) { currTokType.categoryMatches.push(exports.tokenIdxToClass[key].tokenTypeIdx); }); }); } exports.assignCategoriesTokensProp = assignCategoriesTokensProp; function assignCategoriesMapProp(tokenTypes) { utils_1.forEach(tokenTypes, function (currTokType) { singleAssignCategoriesToksMap([], currTokType); }); } exports.assignCategoriesMapProp = assignCategoriesMapProp; function singleAssignCategoriesToksMap(path, nextNode) { utils_1.forEach(path, function (pathNode) { nextNode.categoryMatchesMap[pathNode.tokenTypeIdx] = true; }); utils_1.forEach(nextNode.CATEGORIES, function (nextCategory) { var newPath = path.concat(nextNode); // avoids infinite loops due to cyclic categories. if (!utils_1.contains(newPath, nextCategory)) { singleAssignCategoriesToksMap(newPath, nextCategory); } }); } exports.singleAssignCategoriesToksMap = singleAssignCategoriesToksMap; function hasShortKeyProperty(tokType) { return utils_1.has(tokType, "tokenTypeIdx"); } exports.hasShortKeyProperty = hasShortKeyProperty; function hasCategoriesProperty(tokType) { return utils_1.has(tokType, "CATEGORIES"); } exports.hasCategoriesProperty = hasCategoriesProperty; function hasExtendingTokensTypesProperty(tokType) { return utils_1.has(tokType, "categoryMatches"); } exports.hasExtendingTokensTypesProperty = hasExtendingTokensTypesProperty; function hasExtendingTokensTypesMapProperty(tokType) { return utils_1.has(tokType, "categoryMatchesMap"); } exports.hasExtendingTokensTypesMapProperty = hasExtendingTokensTypesMapProperty; function isTokenType(tokType) { return utils_1.has(tokType, "tokenTypeIdx"); } exports.isTokenType = isTokenType; //# sourceMappingURL=tokens.js.map /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var gast_public_1 = __webpack_require__(1); var gast_visitor_public_1 = __webpack_require__(4); function isSequenceProd(prod) { return (prod instanceof gast_public_1.Flat || prod instanceof gast_public_1.Option || prod instanceof gast_public_1.Repetition || prod instanceof gast_public_1.RepetitionMandatory || prod instanceof gast_public_1.RepetitionMandatoryWithSeparator || prod instanceof gast_public_1.RepetitionWithSeparator || prod instanceof gast_public_1.Terminal || prod instanceof gast_public_1.Rule); } exports.isSequenceProd = isSequenceProd; function isOptionalProd(prod, alreadyVisited) { if (alreadyVisited === void 0) { alreadyVisited = []; } var isDirectlyOptional = prod instanceof gast_public_1.Option || prod instanceof gast_public_1.Repetition || prod instanceof gast_public_1.RepetitionWithSeparator; if (isDirectlyOptional) { return true; } // note that this can cause infinite loop if one optional empty TOP production has a cyclic dependency with another // empty optional top rule // may be indirectly optional ((A?B?C?) | (D?E?F?)) if (prod instanceof gast_public_1.Alternation) { // for OR its enough for just one of the alternatives to be optional return utils_1.some(prod.definition, function (subProd) { return isOptionalProd(subProd, alreadyVisited); }); } else if (prod instanceof gast_public_1.NonTerminal && utils_1.contains(alreadyVisited, prod)) { // avoiding stack overflow due to infinite recursion return false; } else if (prod instanceof gast_public_1.AbstractProduction) { if (prod instanceof gast_public_1.NonTerminal) { alreadyVisited.push(prod); } return utils_1.every(prod.definition, function (subProd) { return isOptionalProd(subProd, alreadyVisited); }); } else { return false; } } exports.isOptionalProd = isOptionalProd; function isBranchingProd(prod) { return prod instanceof gast_public_1.Alternation; } exports.isBranchingProd = isBranchingProd; function getProductionDslName(prod) { /* istanbul ignore else */ if (prod instanceof gast_public_1.NonTerminal) { return "SUBRULE"; } else if (prod instanceof gast_public_1.Option) { return "OPTION"; } else if (prod instanceof gast_public_1.Alternation) { return "OR"; } else if (prod instanceof gast_public_1.RepetitionMandatory) { return "AT_LEAST_ONE"; } else if (prod instanceof gast_public_1.RepetitionMandatoryWithSeparator) { return "AT_LEAST_ONE_SEP"; } else if (prod instanceof gast_public_1.RepetitionWithSeparator) { return "MANY_SEP"; } else if (prod instanceof gast_public_1.Repetition) { return "MANY"; } else if (prod instanceof gast_public_1.Terminal) { return "CONSUME"; } else { throw Error("non exhaustive match"); } } exports.getProductionDslName = getProductionDslName; var DslMethodsCollectorVisitor = /** @class */ (function (_super) { __extends(DslMethodsCollectorVisitor, _super); function DslMethodsCollectorVisitor() { var _this = _super !== null && _super.apply(this, arguments) || this; // A minus is never valid in an identifier name _this.separator = "-"; _this.dslMethods = { option: [], alternation: [], repetition: [], repetitionWithSeparator: [], repetitionMandatory: [], repetitionMandatoryWithSeparator: [] }; return _this; } DslMethodsCollectorVisitor.prototype.reset = function () { this.dslMethods = { option: [], alternation: [], repetition: [], repetitionWithSeparator: [], repetitionMandatory: [], repetitionMandatoryWithSeparator: [] }; }; DslMethodsCollectorVisitor.prototype.visitTerminal = function (terminal) { var key = terminal.terminalType.name + this.separator + "Terminal"; if (!utils_1.has(this.dslMethods, key)) { this.dslMethods[key] = []; } this.dslMethods[key].push(terminal); }; DslMethodsCollectorVisitor.prototype.visitNonTerminal = function (subrule) { var key = subrule.nonTerminalName + this.separator + "Terminal"; if (!utils_1.has(this.dslMethods, key)) { this.dslMethods[key] = []; } this.dslMethods[key].push(subrule); }; DslMethodsCollectorVisitor.prototype.visitOption = function (option) { this.dslMethods.option.push(option); }; DslMethodsCollectorVisitor.prototype.visitRepetitionWithSeparator = function (manySep) { this.dslMethods.repetitionWithSeparator.push(manySep); }; DslMethodsCollectorVisitor.prototype.visitRepetitionMandatory = function (atLeastOne) { this.dslMethods.repetitionMandatory.push(atLeastOne); }; DslMethodsCollectorVisitor.prototype.visitRepetitionMandatoryWithSeparator = function (atLeastOneSep) { this.dslMethods.repetitionMandatoryWithSeparator.push(atLeastOneSep); }; DslMethodsCollectorVisitor.prototype.visitRepetition = function (many) { this.dslMethods.repetition.push(many); }; DslMethodsCollectorVisitor.prototype.visitAlternation = function (or) { this.dslMethods.alternation.push(or); }; return DslMethodsCollectorVisitor; }(gast_visitor_public_1.GAstVisitor)); exports.DslMethodsCollectorVisitor = DslMethodsCollectorVisitor; var collectorVisitor = new DslMethodsCollectorVisitor(); function collectMethods(rule) { collectorVisitor.reset(); rule.accept(collectorVisitor); var dslMethods = collectorVisitor.dslMethods; // avoid uncleaned references collectorVisitor.reset(); return dslMethods; } exports.collectMethods = collectMethods; //# sourceMappingURL=gast.js.map /***/ }), /* 7 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // Lookahead keys are 32Bit integers in the form // TTTTTTTT-ZZZZZZZZZZZZ-YYYY-XXXXXXXX // XXXX -> Occurrence Index bitmap. // YYYY -> DSL Method Type bitmap. // ZZZZZZZZZZZZZZZ -> Rule short Index bitmap. // TTTTTTTTT -> alternation alternative index bitmap Object.defineProperty(exports, "__esModule", { value: true }); exports.BITS_FOR_METHOD_TYPE = 4; exports.BITS_FOR_OCCURRENCE_IDX = 8; exports.BITS_FOR_RULE_IDX = 12; // TODO: validation, this means that there may at most 2^8 --> 256 alternatives for an alternation. exports.BITS_FOR_ALT_IDX = 8; // short string used as part of mapping keys. // being short improves the performance when composing KEYS for maps out of these // The 5 - 8 bits (16 possible values, are reserved for the DSL method indices) /* tslint:disable */ exports.OR_IDX = 1 << exports.BITS_FOR_OCCURRENCE_IDX; exports.OPTION_IDX = 2 << exports.BITS_FOR_OCCURRENCE_IDX; exports.MANY_IDX = 3 << exports.BITS_FOR_OCCURRENCE_IDX; exports.AT_LEAST_ONE_IDX = 4 << exports.BITS_FOR_OCCURRENCE_IDX; exports.MANY_SEP_IDX = 5 << exports.BITS_FOR_OCCURRENCE_IDX; exports.AT_LEAST_ONE_SEP_IDX = 6 << exports.BITS_FOR_OCCURRENCE_IDX; /* tslint:enable */ // this actually returns a number, but it is always used as a string (object prop key) function getKeyForAutomaticLookahead(ruleIdx, dslMethodIdx, occurrence) { /* tslint:disable */ return occurrence | dslMethodIdx | ruleIdx; /* tslint:enable */ } exports.getKeyForAutomaticLookahead = getKeyForAutomaticLookahead; var BITS_START_FOR_ALT_IDX = 32 - exports.BITS_FOR_ALT_IDX; function getKeyForAltIndex(ruleIdx, dslMethodIdx, occurrence, altIdx) { /* tslint:disable */ // alternative indices are zero based, thus must always add one (turn on one bit) to guarantee uniqueness. var altIdxBitMap = (altIdx + 1) << BITS_START_FOR_ALT_IDX; return (getKeyForAutomaticLookahead(ruleIdx, dslMethodIdx, occurrence) | altIdxBitMap); /* tslint:enable */ } exports.getKeyForAltIndex = getKeyForAltIndex; //# sourceMappingURL=keys.js.map /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var MISMATCHED_TOKEN_EXCEPTION = "MismatchedTokenException"; var NO_VIABLE_ALT_EXCEPTION = "NoViableAltException"; var EARLY_EXIT_EXCEPTION = "EarlyExitException"; var NOT_ALL_INPUT_PARSED_EXCEPTION = "NotAllInputParsedException"; var RECOGNITION_EXCEPTION_NAMES = [ MISMATCHED_TOKEN_EXCEPTION, NO_VIABLE_ALT_EXCEPTION, EARLY_EXIT_EXCEPTION, NOT_ALL_INPUT_PARSED_EXCEPTION ]; Object.freeze(RECOGNITION_EXCEPTION_NAMES); // hacks to bypass no support for custom Errors in javascript/typescript function isRecognitionException(error) { // can't do instanceof on hacked custom js exceptions return utils_1.contains(RECOGNITION_EXCEPTION_NAMES, error.name); } exports.isRecognitionException = isRecognitionException; function MismatchedTokenException(message, token, previousToken) { this.name = MISMATCHED_TOKEN_EXCEPTION; this.message = message; this.token = token; this.previousToken = previousToken; this.resyncedTokens = []; } exports.MismatchedTokenException = MismatchedTokenException; // must use the "Error.prototype" instead of "new Error" // because the stack trace points to where "new Error" was invoked" MismatchedTokenException.prototype = Error.prototype; function NoViableAltException(message, token, previousToken) { this.name = NO_VIABLE_ALT_EXCEPTION; this.message = message; this.token = token; this.previousToken = previousToken; this.resyncedTokens = []; } exports.NoViableAltException = NoViableAltException; NoViableAltException.prototype = Error.prototype; function NotAllInputParsedException(message, token) { this.name = NOT_ALL_INPUT_PARSED_EXCEPTION; this.message = message; this.token = token; this.resyncedTokens = []; } exports.NotAllInputParsedException = NotAllInputParsedException; NotAllInputParsedException.prototype = Error.prototype; function EarlyExitException(message, token, previousToken) { this.name = EARLY_EXIT_EXCEPTION; this.message = message; this.token = token; this.previousToken = previousToken; this.resyncedTokens = []; } exports.EarlyExitException = EarlyExitException; EarlyExitException.prototype = Error.prototype; //# sourceMappingURL=exceptions_public.js.map /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var lexer_1 = __webpack_require__(20); var utils_1 = __webpack_require__(0); var tokens_1 = __webpack_require__(5); var lexer_errors_public_1 = __webpack_require__(21); var reg_exp_parser_1 = __webpack_require__(16); var LexerDefinitionErrorType; (function (LexerDefinitionErrorType) { LexerDefinitionErrorType[LexerDefinitionErrorType["MISSING_PATTERN"] = 0] = "MISSING_PATTERN"; LexerDefinitionErrorType[LexerDefinitionErrorType["INVALID_PATTERN"] = 1] = "INVALID_PATTERN"; LexerDefinitionErrorType[LexerDefinitionErrorType["EOI_ANCHOR_FOUND"] = 2] = "EOI_ANCHOR_FOUND"; LexerDefinitionErrorType[LexerDefinitionErrorType["UNSUPPORTED_FLAGS_FOUND"] = 3] = "UNSUPPORTED_FLAGS_FOUND"; LexerDefinitionErrorType[LexerDefinitionErrorType["DUPLICATE_PATTERNS_FOUND"] = 4] = "DUPLICATE_PATTERNS_FOUND"; LexerDefinitionErrorType[LexerDefinitionErrorType["INVALID_GROUP_TYPE_FOUND"] = 5] = "INVALID_GROUP_TYPE_FOUND"; LexerDefinitionErrorType[LexerDefinitionErrorType["PUSH_MODE_DOES_NOT_EXIST"] = 6] = "PUSH_MODE_DOES_NOT_EXIST"; LexerDefinitionErrorType[LexerDefinitionErrorType["MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE"] = 7] = "MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE"; LexerDefinitionErrorType[LexerDefinitionErrorType["MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY"] = 8] = "MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY"; LexerDefinitionErrorType[LexerDefinitionErrorType["MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST"] = 9] = "MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST"; LexerDefinitionErrorType[LexerDefinitionErrorType["LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED"] = 10] = "LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED"; LexerDefinitionErrorType[LexerDefinitionErrorType["SOI_ANCHOR_FOUND"] = 11] = "SOI_ANCHOR_FOUND"; LexerDefinitionErrorType[LexerDefinitionErrorType["EMPTY_MATCH_PATTERN"] = 12] = "EMPTY_MATCH_PATTERN"; LexerDefinitionErrorType[LexerDefinitionErrorType["NO_LINE_BREAKS_FLAGS"] = 13] = "NO_LINE_BREAKS_FLAGS"; LexerDefinitionErrorType[LexerDefinitionErrorType["UNREACHABLE_PATTERN"] = 14] = "UNREACHABLE_PATTERN"; LexerDefinitionErrorType[LexerDefinitionErrorType["IDENTIFY_TERMINATOR"] = 15] = "IDENTIFY_TERMINATOR"; LexerDefinitionErrorType[LexerDefinitionErrorType["CUSTOM_LINE_BREAK"] = 16] = "CUSTOM_LINE_BREAK"; })(LexerDefinitionErrorType = exports.LexerDefinitionErrorType || (exports.LexerDefinitionErrorType = {})); var DEFAULT_LEXER_CONFIG = { deferDefinitionErrorsHandling: false, positionTracking: "full", lineTerminatorsPattern: /\n|\r\n?/g, lineTerminatorCharacters: ["\n", "\r"], ensureOptimizations: false, safeMode: false, errorMessageProvider: lexer_errors_public_1.defaultLexerErrorProvider, traceInitPerf: false, skipValidations: false }; Object.freeze(DEFAULT_LEXER_CONFIG); var Lexer = /** @class */ (function () { function Lexer(lexerDefinition, config) { var _this = this; if (config === void 0) { config = DEFAULT_LEXER_CONFIG; } this.lexerDefinition = lexerDefinition; this.lexerDefinitionErrors = []; this.lexerDefinitionWarning = []; this.patternIdxToConfig = {}; this.charCodeToPatternIdxToConfig = {}; this.modes = []; this.emptyGroups = {}; this.config = undefined; this.trackStartLines = true; this.trackEndLines = true; this.hasCustom = false; this.canModeBeOptimized = {}; if (typeof config === "boolean") { throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\n" + "a boolean 2nd argument is no longer supported"); } // todo: defaults func? this.config = utils_1.merge(DEFAULT_LEXER_CONFIG, config); var traceInitVal = this.config.traceInitPerf; if (traceInitVal === true) { this.traceInitMaxIdent = Infinity; this.traceInitPerf = true; } else if (typeof traceInitVal === "number") { this.traceInitMaxIdent = traceInitVal; this.traceInitPerf = true; } this.traceInitIndent = -1; this.TRACE_INIT("Lexer Constructor", function () { var actualDefinition; var hasOnlySingleMode = true; _this.TRACE_INIT("Lexer Config handling", function () { if (_this.config.lineTerminatorsPattern === DEFAULT_LEXER_CONFIG.lineTerminatorsPattern) { // optimized built-in implementation for the defaults definition of lineTerminators _this.config.lineTerminatorsPattern = lexer_1.LineTerminatorOptimizedTester; } else { if (_this.config.lineTerminatorCharacters === DEFAULT_LEXER_CONFIG.lineTerminatorCharacters) { throw Error("Error: Missing property on the Lexer config.\n" + "\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS"); } } if (config.safeMode && config.ensureOptimizations) { throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.'); } _this.trackStartLines = /full|onlyStart/i.test(_this.config.positionTracking); _this.trackEndLines = /full/i.test(_this.config.positionTracking); // Convert SingleModeLexerDefinition into a IMultiModeLexerDefinition. if (utils_1.isArray(lexerDefinition)) { actualDefinition = { modes: {} }; actualDefinition.modes[lexer_1.DEFAULT_MODE] = utils_1.cloneArr(lexerDefinition); actualDefinition[lexer_1.DEFAULT_MODE] = lexer_1.DEFAULT_MODE; } else { // no conversion needed, input should already be a IMultiModeLexerDefinition hasOnlySingleMode = false; actualDefinition = utils_1.cloneObj((lexerDefinition)); } }); if (_this.config.skipValidations === false) { _this.TRACE_INIT("performRuntimeChecks", function () { _this.lexerDefinitionErrors = _this.lexerDefinitionErrors.concat(lexer_1.performRuntimeChecks(actualDefinition, _this.trackStartLines, _this.config.lineTerminatorCharacters)); }); _this.TRACE_INIT("performWarningRuntimeChecks", function () { _this.lexerDefinitionWarning = _this.lexerDefinitionWarning.concat(lexer_1.performWarningRuntimeChecks(actualDefinition, _this.trackStartLines, _this.config.lineTerminatorCharacters)); }); } // for extra robustness to avoid throwing an none informative error message actualDefinition.modes = actualDefinition.modes ? actualDefinition.modes : {}; // an error of undefined TokenTypes will be detected in "performRuntimeChecks" above. // this transformation is to increase robustness in the case of partially invalid lexer definition. utils_1.forEach(actualDefinition.modes, function (currModeValue, currModeName) { actualDefinition.modes[currModeName] = utils_1.reject(currModeValue, function (currTokType) { return utils_1.isUndefined(currTokType); }); }); var allModeNames = utils_1.keys(actualDefinition.modes); utils_1.forEach(actualDefinition.modes, function (currModDef, currModName) { _this.TRACE_INIT("Mode: <" + currModName + "> processing", function () { _this.modes.push(currModName); if (_this.config.skipValidations === false) { _this.TRACE_INIT("validatePatterns", function () { _this.lexerDefinitionErrors = _this.lexerDefinitionErrors.concat(lexer_1.validatePatterns(currModDef, allModeNames)); }); } // If definition errors were encountered, the analysis phase may fail unexpectedly/ // Considering a lexer with definition errors may never be used, there is no point // to performing the analysis anyhow... if (utils_1.isEmpty(_this.lexerDefinitionErrors)) { tokens_1.augmentTokenTypes(currModDef); var currAnalyzeResult_1; _this.TRACE_INIT("analyzeTokenTypes", function () { currAnalyzeResult_1 = lexer_1.analyzeTokenTypes(currModDef, { lineTerminatorCharacters: _this.config .lineTerminatorCharacters, positionTracking: config.positionTracking, ensureOptimizations: config.ensureOptimizations, safeMode: config.safeMode, tracer: _this.TRACE_INIT.bind(_this) }); }); _this.patternIdxToConfig[currModName] = currAnalyzeResult_1.patternIdxToConfig; _this.charCodeToPatternIdxToConfig[currModName] = currAnalyzeResult_1.charCodeToPatternIdxToConfig; _this.emptyGroups = utils_1.merge(_this.emptyGroups, currAnalyzeResult_1.emptyGroups); _this.hasCustom = currAnalyzeResult_1.hasCustom || _this.hasCustom; _this.canModeBeOptimized[currModName] = currAnalyzeResult_1.canBeOptimized; } }); }); _this.defaultMode = actualDefinition.defaultMode; if (!utils_1.isEmpty(_this.lexerDefinitionErrors) && !_this.config.deferDefinitionErrorsHandling) { var allErrMessages = utils_1.map(_this.lexerDefinitionErrors, function (error) { return error.message; }); var allErrMessagesString = allErrMessages.join("-----------------------\n"); throw new Error("Errors detected in definition of Lexer:\n" + allErrMessagesString); } // Only print warning if there are no errors, This will avoid pl utils_1.forEach(_this.lexerDefinitionWarning, function (warningDescriptor) { utils_1.PRINT_WARNING(warningDescriptor.message); }); _this.TRACE_INIT("Choosing sub-methods implementations", function () { // Choose the relevant internal implementations for this specific parser. // These implementations should be in-lined by the JavaScript engine // to provide optimal performance in each scenario. if (lexer_1.SUPPORT_STICKY) { _this.chopInput = utils_1.IDENTITY; _this.match = _this.matchWithTest; } else { _this.updateLastIndex = utils_1.NOOP; _this.match = _this.matchWithExec; } if (hasOnlySingleMode) { _this.handleModes = utils_1.NOOP; } if (_this.trackStartLines === false) { _this.computeNewColumn = utils_1.IDENTITY; } if (_this.trackEndLines === false) { _this.updateTokenEndLineColumnLocation = utils_1.NOOP; } if (/full/i.test(_this.config.positionTracking)) { _this.createTokenInstance = _this.createFullToken; } else if (/onlyStart/i.test(_this.config.positionTracking)) { _this.createTokenInstance = _this.createStartOnlyToken; } else if (/onlyOffset/i.test(_this.config.positionTracking)) { _this.createTokenInstance = _this.createOffsetOnlyToken; } else { throw Error("Invalid config option: \"" + _this.config.positionTracking + "\""); } if (_this.hasCustom) { _this.addToken = _this.addTokenUsingPush; _this.handlePayload = _this.handlePayloadWithCustom; } else { _this.addToken = _this.addTokenUsingMemberAccess; _this.handlePayload = _this.handlePayloadNoCustom; } }); _this.TRACE_INIT("Failed Optimization Warnings", function () { var unOptimizedModes = utils_1.reduce(_this.canModeBeOptimized, function (cannotBeOptimized, canBeOptimized, modeName) { if (canBeOptimized === false) { cannotBeOptimized.push(modeName); } return cannotBeOptimized; }, []); if (config.ensureOptimizations && !utils_1.isEmpty(unOptimizedModes)) { throw Error("Lexer Modes: < " + unOptimizedModes.join(", ") + " > cannot be optimized.\n" + '\t Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\n' + "\t Or inspect the console log for details on how to resolve these issues."); } }); _this.TRACE_INIT("clearRegExpParserCache", function () { reg_exp_parser_1.clearRegExpParserCache(); }); _this.TRACE_INIT("toFastProperties", function () { utils_1.toFastProperties(_this); }); }); } Lexer.prototype.tokenize = function (text, initialMode) { if (initialMode === void 0) { initialMode = this.defaultMode; } if (!utils_1.isEmpty(this.lexerDefinitionErrors)) { var allErrMessages = utils_1.map(this.lexerDefinitionErrors, function (error) { return error.message; }); var allErrMessagesString = allErrMessages.join("-----------------------\n"); throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n" + allErrMessagesString); } var lexResult = this.tokenizeInternal(text, initialMode); return lexResult; }; // There is quite a bit of duplication between this and "tokenizeInternalLazy" // This is intentional due to performance considerations. Lexer.prototype.tokenizeInternal = function (text, initialMode) { var _this = this; var i, j, matchAltImage, longerAltIdx, matchedImage, payload, altPayload, imageLength, group, tokType, newToken, errLength, droppedChar, msg, match; var orgText = text; var orgLength = orgText.length; var offset = 0; var matchedTokensIndex = 0; // initializing the tokensArray to the "guessed" size. // guessing too little will still reduce the number of array re-sizes on pushes. // guessing too large (Tested by guessing x4 too large) may cost a bit more of memory // but would still have a faster runtime by avoiding (All but one) array resizing. var guessedNumberOfTokens = this.hasCustom ? 0 // will break custom token pattern APIs the matchedTokens array will contain undefined elements. : Math.floor(text.length / 10); var matchedTokens = new Array(guessedNumberOfTokens); var errors = []; var line = this.trackStartLines ? 1 : undefined; var column = this.trackStartLines ? 1 : undefined; var groups = lexer_1.cloneEmptyGroups(this.emptyGroups); var trackLines = this.trackStartLines; var lineTerminatorPattern = this.config.lineTerminatorsPattern; var currModePatternsLength = 0; var patternIdxToConfig = []; var currCharCodeToPatternIdxToConfig = []; var modeStack = []; var emptyArray = []; Object.freeze(emptyArray); var getPossiblePatterns = undefined; function getPossiblePatternsSlow() { return patternIdxToConfig; } function getPossiblePatternsOptimized(charCode) { var optimizedCharIdx = lexer_1.charCodeToOptimizedIndex(charCode); var possiblePatterns = currCharCodeToPatternIdxToConfig[optimizedCharIdx]; if (possiblePatterns === undefined) { return emptyArray; } else { return possiblePatterns; } } var pop_mode = function (popToken) { // TODO: perhaps avoid this error in the edge case there is no more input? if (modeStack.length === 1 && // if we have both a POP_MODE and a PUSH_MODE this is in-fact a "transition" // So no error should occur. popToken.tokenType.PUSH_MODE === undefined) { // if we try to pop the last mode there lexer will no longer have ANY mode. // thus the pop is ignored, an error will be created and the lexer will continue parsing in the previous mode. var msg_1 = _this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(popToken); errors.push({ offset: popToken.startOffset, line: popToken.startLine !== undefined ? popToken.startLine : undefined, column: popToken.startColumn !== undefined ? popToken.startColumn : undefined, length: popToken.image.length, message: msg_1 }); } else { modeStack.pop(); var newMode = utils_1.last(modeStack); patternIdxToConfig = _this.patternIdxToConfig[newMode]; currCharCodeToPatternIdxToConfig = _this .charCodeToPatternIdxToConfig[newMode]; currModePatternsLength = patternIdxToConfig.length; var modeCanBeOptimized = _this.canModeBeOptimized[newMode] && _this.config.safeMode === false; if (currCharCodeToPatternIdxToConfig && modeCanBeOptimized) { getPossiblePatterns = getPossiblePatternsOptimized; } else { getPossiblePatterns = getPossiblePatternsSlow; } } }; function push_mode(newMode) { modeStack.push(newMode); currCharCodeToPatternIdxToConfig = this .charCodeToPatternIdxToConfig[newMode]; patternIdxToConfig = this.patternIdxToConfig[newMode]; currModePatternsLength = patternIdxToConfig.length; currModePatternsLength = patternIdxToConfig.length; var modeCanBeOptimized = this.canModeBeOptimized[newMode] && this.config.safeMode === false; if (currCharCodeToPatternIdxToConfig && modeCanBeOptimized) { getPossiblePatterns = getPossiblePatternsOptimized; } else { getPossiblePatterns = getPossiblePatternsSlow; } } // this pattern seems to avoid a V8 de-optimization, although that de-optimization does not // seem to matter performance wise. push_mode.call(this, initialMode); var currConfig; while (offset < orgLength) { matchedImage = null; var nextCharCode = orgText.charCodeAt(offset); var chosenPatternIdxToConfig = getPossiblePatterns(nextCharCode); var chosenPatternsLength = chosenPatternIdxToConfig.length; for (i = 0; i < chosenPatternsLength; i++) { currConfig = chosenPatternIdxToConfig[i]; var currPattern = currConfig.pattern; payload = null; // manually in-lined because > 600 chars won't be in-lined in V8 var singleCharCode = currConfig.short; if (singleCharCode !== false) { if (nextCharCode === singleCharCode) { // single character string matchedImage = currPattern; } } else if (currConfig.isCustom === true) { match = currPattern.exec(orgText, offset, matchedTokens, groups); if (match !== null) { matchedImage = match[0]; if (match.payload !== undefined) { payload = match.payload; } } else { matchedImage = null; } } else { this.updateLastIndex(currPattern, offset); matchedImage = this.match(currPattern, text, offset); } if (matchedImage !== null) { // even though this pattern matched we must try a another longer alternative. // this can be used to prioritize keywords over identifiers longerAltIdx = currConfig.longerAlt; if (longerAltIdx !== undefined) { // TODO: micro optimize, avoid extra prop access // by saving/linking longerAlt on the original config? var longerAltConfig = patternIdxToConfig[longerAltIdx]; var longerAltPattern = longerAltConfig.pattern; altPayload = null; // single Char can never be a longer alt so no need to test it. // manually in-lined because > 600 chars won't be in-lined in V8 if (longerAltConfig.isCustom === true) { match = longerAltPattern.exec(orgText, offset, matchedTokens, groups); if (match !== null) { matchAltImage = match[0]; if (match.payload !== undefined) { altPayload = match.payload; } } else { matchAltImage = null; } } else { this.updateLastIndex(longerAltPattern, offset); matchAltImage = this.match(longerAltPattern, text, offset); } if (matchAltImage && matchAltImage.length > matchedImage.length) { matchedImage = matchAltImage; payload = altPayload; currConfig = longerAltConfig; } } break; } } // successful match if (matchedImage !== null) { imageLength = matchedImage.length; group = currConfig.group; if (group !== undefined) { tokType = currConfig.tokenTypeIdx; // TODO: "offset + imageLength" and the new column may be computed twice in case of "full" location information inside // createFullToken method newToken = this.createTokenInstance(matchedImage, offset, tokType, currConfig.tokenType, line, column, imageLength); this.handlePayload(newToken, payload); // TODO: optimize NOOP in case there are no special groups? if (group === false) { matchedTokensIndex = this.addToken(matchedTokens, matchedTokensIndex, newToken); } else { groups[group].push(newToken); } } text = this.chopInput(text, imageLength); offset = offset + imageLength; // TODO: with newlines the column may be assigned twice column = this.computeNewColumn(column, imageLength); if (trackLines === true && currConfig.canLineTerminator === true) { var numOfLTsInMatch = 0; var foundTerminator = void 0; var lastLTEndOffset = void 0; lineTerminatorPattern.lastIndex = 0; do { foundTerminator = lineTerminatorPattern.test(matchedImage); if (foundTerminator === true) { lastLTEndOffset = lineTerminatorPattern.lastIndex - 1; numOfLTsInMatch++; } } while (foundTerminator === true); if (numOfLTsInMatch !== 0) { line = line + numOfLTsInMatch; column = imageLength - lastLTEndOffset; this.updateTokenEndLineColumnLocation(newToken, group, lastLTEndOffset, numOfLTsInMatch, line, column, imageLength); } } // will be NOOP if no modes present this.handleModes(currConfig, pop_mode, push_mode, newToken); } else { // error recovery, drop characters until we identify a valid token's start point var errorStartOffset = offset; var errorLine = line; var errorColumn = column; var foundResyncPoint = false; while (!foundResyncPoint && offset < orgLength) { // drop chars until we succeed in matching something droppedChar = orgText.charCodeAt(offset); // Identity Func (when sticky flag is enabled) text = this.chopInput(text, 1); offset++; for (j = 0; j < currModePatternsLength; j++) { var currConfig_1 = patternIdxToConfig[j]; var currPattern = currConfig_1.pattern; // manually in-lined because > 600 chars won't be in-lined in V8 var singleCharCode = currConfig_1.short; if (singleCharCode !== false) { if (orgText.charCodeAt(offset) === singleCharCode) { // single character string foundResyncPoint = true; } } else if (currConfig_1.isCustom === true) { foundResyncPoint = currPattern.exec(orgText, offset, matchedTokens, groups) !== null; } else { this.updateLastIndex(currPattern, offset); foundResyncPoint = currPattern.exec(text) !== null; } if (foundResyncPoint === true) { break; } } } errLength = offset - errorStartOffset; // at this point we either re-synced or reached the end of the input text msg = this.config.errorMessageProvider.buildUnexpectedCharactersMessage(orgText, errorStartOffset, errLength, errorLine, errorColumn); errors.push({ offset: errorStartOffset, line: errorLine, column: errorColumn, length: errLength, message: msg }); } } // if we do have custom patterns which push directly into the // TODO: custom tokens should not push directly?? if (!this.hasCustom) { // if we guessed a too large size for the tokens array this will shrink it to the right size. matchedTokens.length = matchedTokensIndex; } return { tokens: matchedTokens, groups: groups, errors: errors }; }; Lexer.prototype.handleModes = function (config, pop_mode, push_mode, newToken) { if (config.pop === true) { // need to save the PUSH_MODE property as if the mode is popped // patternIdxToPopMode is updated to reflect the new mode after popping the stack var pushMode = config.push; pop_mode(newToken); if (pushMode !== undefined) { push_mode.call(this, pushMode); } } else if (config.push !== undefined) { push_mode.call(this, config.push); } }; Lexer.prototype.chopInput = function (text, length) { return text.substring(length); }; Lexer.prototype.updateLastIndex = function (regExp, newLastIndex) { regExp.lastIndex = newLastIndex; }; // TODO: decrease this under 600 characters? inspect stripping comments option in TSC compiler Lexer.prototype.updateTokenEndLineColumnLocation = function (newToken, group, lastLTIdx, numOfLTsInMatch, line, column, imageLength) { var lastCharIsLT, fixForEndingInLT; if (group !== undefined) { // a none skipped multi line Token, need to update endLine/endColumn lastCharIsLT = lastLTIdx === imageLength - 1; fixForEndingInLT = lastCharIsLT ? -1 : 0; if (!(numOfLTsInMatch === 1 && lastCharIsLT === true)) { // if a token ends in a LT that last LT only affects the line numbering of following Tokens newToken.endLine = line + fixForEndingInLT; // the last LT in a token does not affect the endColumn either as the [columnStart ... columnEnd) // inclusive to exclusive range. newToken.endColumn = column - 1 + -fixForEndingInLT; } // else single LT in the last character of a token, no need to modify the endLine/EndColumn } }; Lexer.prototype.computeNewColumn = function (oldColumn, imageLength) { return oldColumn + imageLength; }; // Place holder, will be replaced by the correct variant according to the locationTracking option at runtime. /* istanbul ignore next - place holder */ Lexer.prototype.createTokenInstance = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return null; }; Lexer.prototype.createOffsetOnlyToken = function (image, startOffset, tokenTypeIdx, tokenType) { return { image: image, startOffset: startOffset, tokenTypeIdx: tokenTypeIdx, tokenType: tokenType }; }; Lexer.prototype.createStartOnlyToken = function (image, startOffset, tokenTypeIdx, tokenType, startLine, startColumn) { return { image: image, startOffset: startOffset, startLine: startLine, startColumn: startColumn, tokenTypeIdx: tokenTypeIdx, tokenType: tokenType }; }; Lexer.prototype.createFullToken = function (image, startOffset, tokenTypeIdx, tokenType, startLine, startColumn, imageLength) { return { image: image, startOffset: startOffset, endOffset: startOffset + imageLength - 1, startLine: startLine, endLine: startLine, startColumn: startColumn, endColumn: startColumn + imageLength - 1, tokenTypeIdx: tokenTypeIdx, tokenType: tokenType }; }; // Place holder, will be replaced by the correct variant according to the locationTracking option at runtime. /* istanbul ignore next - place holder */ Lexer.prototype.addToken = function (tokenVector, index, tokenToAdd) { return 666; }; Lexer.prototype.addTokenUsingPush = function (tokenVector, index, tokenToAdd) { tokenVector.push(tokenToAdd); return index; }; Lexer.prototype.addTokenUsingMemberAccess = function (tokenVector, index, tokenToAdd) { tokenVector[index] = tokenToAdd; index++; return index; }; // Place holder, will be replaced by the correct variant according to the hasCustom flag option at runtime. /* istanbul ignore next - place holder */ Lexer.prototype.handlePayload = function (token, payload) { }; Lexer.prototype.handlePayloadNoCustom = function (token, payload) { }; Lexer.prototype.handlePayloadWithCustom = function (token, payload) { if (payload !== null) { token.payload = payload; } }; /* istanbul ignore next - place holder to be replaced with chosen alternative at runtime */ Lexer.prototype.match = function (pattern, text, offset) { return null; }; Lexer.prototype.matchWithTest = function (pattern, text, offset) { var found = pattern.test(text); if (found === true) { return text.substring(offset, pattern.lastIndex); } return null; }; Lexer.prototype.matchWithExec = function (pattern, text) { var regExpArray = pattern.exec(text); return regExpArray !== null ? regExpArray[0] : regExpArray; }; // Duplicated from the parser's perf trace trait to allow future extraction // of the lexer to a separate package. Lexer.prototype.TRACE_INIT = function (phaseDesc, phaseImpl) { // No need to optimize this using NOOP pattern because // It is not called in a hot spot... if (this.traceInitPerf === true) { this.traceInitIndent++; var indent = new Array(this.traceInitIndent + 1).join("\t"); if (this.traceInitIndent < this.traceInitMaxIdent) { console.log(indent + "--> <" + phaseDesc + ">"); } var _a = utils_1.timer(phaseImpl), time = _a.time, value = _a.value; /* istanbul ignore next - Difficult to reproduce specific performance behavior (>10ms) in tests */ var traceMethod = time > 10 ? console.warn : console.log; if (this.traceInitIndent < this.traceInitMaxIdent) { traceMethod(indent + "<-- <" + phaseDesc + "> time: " + time + "ms"); } this.traceInitIndent--; return value; } else { return phaseImpl(); } }; Lexer.SKIPPED = "This marks a skipped Token pattern, this means each token identified by it will" + "be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace."; Lexer.NA = /NOT_APPLICABLE/; return Lexer; }()); exports.Lexer = Lexer; //# sourceMappingURL=lexer_public.js.map /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tokens_public_1 = __webpack_require__(3); var utils = __webpack_require__(0); var utils_1 = __webpack_require__(0); var gast_public_1 = __webpack_require__(1); var gast_1 = __webpack_require__(6); var checks_1 = __webpack_require__(11); exports.defaultParserErrorProvider = { buildMismatchTokenMessage: function (_a) { var expected = _a.expected, actual = _a.actual, previous = _a.previous, ruleName = _a.ruleName; var hasLabel = tokens_public_1.hasTokenLabel(expected); var expectedMsg = hasLabel ? "--> " + tokens_public_1.tokenLabel(expected) + " <--" : "token of type --> " + expected.name + " <--"; var msg = "Expecting " + expectedMsg + " but found --> '" + actual.image + "' <--"; return msg; }, buildNotAllInputParsedMessage: function (_a) { var firstRedundant = _a.firstRedundant, ruleName = _a.ruleName; return ("Redundant input, expecting EOF but found: " + firstRedundant.image); }, buildNoViableAltMessage: function (_a) { var expectedPathsPerAlt = _a.expectedPathsPerAlt, actual = _a.actual, previous = _a.previous, customUserDescription = _a.customUserDescription, ruleName = _a.ruleName; var errPrefix = "Expecting: "; // TODO: issue: No Viable Alternative Error may have incomplete details. #502 var actualText = utils_1.first(actual).image; var errSuffix = "\nbut found: '" + actualText + "'"; if (customUserDescription) { return errPrefix + customUserDescription + errSuffix; } else { var allLookAheadPaths = utils_1.reduce(expectedPathsPerAlt, function (result, currAltPaths) { return result.concat(currAltPaths); }, []); var nextValidTokenSequences = utils_1.map(allLookAheadPaths, function (currPath) { return "[" + utils_1.map(currPath, function (currTokenType) { return tokens_public_1.tokenLabel(currTokenType); }).join(", ") + "]"; }); var nextValidSequenceItems = utils_1.map(nextValidTokenSequences, function (itemMsg, idx) { return " " + (idx + 1) + ". " + itemMsg; }); var calculatedDescription = "one of these possible Token sequences:\n" + nextValidSequenceItems.join("\n"); return errPrefix + calculatedDescription + errSuffix; } }, buildEarlyExitMessage: function (_a) { var expectedIterationPaths = _a.expectedIterationPaths, actual = _a.actual, customUserDescription = _a.customUserDescription, ruleName = _a.ruleName; var errPrefix = "Expecting: "; // TODO: issue: No Viable Alternative Error may have incomplete details. #502 var actualText = utils_1.first(actual).image; var errSuffix = "\nbut found: '" + actualText + "'"; if (customUserDescription) { return errPrefix + customUserDescription + errSuffix; } else { var nextValidTokenSequences = utils_1.map(expectedIterationPaths, function (currPath) { return "[" + utils_1.map(currPath, function (currTokenType) { return tokens_public_1.tokenLabel(currTokenType); }).join(",") + "]"; }); var calculatedDescription = "expecting at least one iteration which starts with one of these possible Token sequences::\n " + ("<" + nextValidTokenSequences.join(" ,") + ">"); return errPrefix + calculatedDescription + errSuffix; } } }; Object.freeze(exports.defaultParserErrorProvider); exports.defaultGrammarResolverErrorProvider = { buildRuleNotFoundError: function (topLevelRule, undefinedRule) { var msg = "Invalid grammar, reference to a rule which is not defined: ->" + undefinedRule.nonTerminalName + "<-\n" + "inside top level rule: ->" + topLevelRule.name + "<-"; return msg; } }; exports.defaultGrammarValidatorErrorProvider = { buildDuplicateFoundError: function (topLevelRule, duplicateProds) { function getExtraProductionArgument(prod) { if (prod instanceof gast_public_1.Terminal) { return prod.terminalType.name; } else if (prod instanceof gast_public_1.NonTerminal) { return prod.nonTerminalName; } else { return ""; } } var topLevelName = topLevelRule.name; var duplicateProd = utils_1.first(duplicateProds); var index = duplicateProd.idx; var dslName = gast_1.getProductionDslName(duplicateProd); var extraArgument = getExtraProductionArgument(duplicateProd); var hasExplicitIndex = index > 0; var msg = "->" + dslName + (hasExplicitIndex ? index : "") + "<- " + (extraArgument ? "with argument: ->" + extraArgument + "<-" : "") + "\n appears more than once (" + duplicateProds.length + " times) in the top level rule: ->" + topLevelName + "<-. \n For further details see: https://sap.github.io/chevrotain/docs/FAQ.html#NUMERICAL_SUFFIXES \n "; // white space trimming time! better to trim afterwards as it allows to use WELL formatted multi line template strings... msg = msg.replace(/[ \t]+/g, " "); msg = msg.replace(/\s\s+/g, "\n"); return msg; }, buildInvalidNestedRuleNameError: function (topLevelRule, nestedProd) { var msg = "Invalid nested rule name: ->" + nestedProd.name + "<- inside rule: ->" + topLevelRule.name + "<-\n" + ("it must match the pattern: ->" + checks_1.validNestedRuleName.toString() + "<-.\n") + "Note that this means a nested rule name must start with the '$'(dollar) sign."; return msg; }, buildDuplicateNestedRuleNameError: function (topLevelRule, nestedProd) { var duplicateName = utils_1.first(nestedProd).name; var errMsg = "Duplicate nested rule name: ->" + duplicateName + "<- inside rule: ->" + topLevelRule.name + "<-\n" + "A nested name must be unique in the scope of a top level grammar rule."; return errMsg; }, buildNamespaceConflictError: function (rule) { var errMsg = "Namespace conflict found in grammar.\n" + ("The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <" + rule.name + ">.\n") + "To resolve this make sure each Terminal and Non-Terminal names are unique\n" + "This is easy to accomplish by using the convention that Terminal names start with an uppercase letter\n" + "and Non-Terminal names start with a lower case letter."; return errMsg; }, buildAlternationPrefixAmbiguityError: function (options) { var pathMsg = utils_1.map(options.prefixPath, function (currTok) { return tokens_public_1.tokenLabel(currTok); }).join(", "); var occurrence = options.alternation.idx === 0 ? "" : options.alternation.idx; var errMsg = "Ambiguous alternatives: <" + options.ambiguityIndices.join(" ,") + "> due to common lookahead prefix\n" + ("in inside <" + options.topLevelRule.name + "> Rule,\n") + ("<" + pathMsg + "> may appears as a prefix path in all these alternatives.\n") + "See: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\n" + "For Further details."; return errMsg; }, buildAlternationAmbiguityError: function (options) { var pathMsg = utils_1.map(options.prefixPath, function (currtok) { return tokens_public_1.tokenLabel(currtok); }).join(", "); var occurrence = options.alternation.idx === 0 ? "" : options.alternation.idx; var currMessage = "Ambiguous Alternatives Detected: <" + options.ambiguityIndices.join(" ,") + "> in " + (" inside <" + options.topLevelRule.name + "> Rule,\n") + ("<" + pathMsg + "> may appears as a prefix path in all these alternatives.\n"); currMessage = currMessage + "See: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\n" + "For Further details."; return currMessage; }, buildEmptyRepetitionError: function (options) { var dslName = gast_1.getProductionDslName(options.repetition); if (options.repetition.idx !== 0) { dslName += options.repetition.idx; } var errMsg = "The repetition <" + dslName + "> within Rule <" + options.topLevelRule.name + "> can never consume any tokens.\n" + "This could lead to an infinite loop."; return errMsg; }, buildTokenNameError: function (options) { var tokTypeName = options.tokenType.name; var errMsg = "Invalid Grammar Token name: ->" + tokTypeName + "<- it must match the pattern: ->" + options.expectedPattern.toString() + "<-"; return errMsg; }, buildEmptyAlternationError: function (options) { var errMsg = "Ambiguous empty alternative: <" + (options.emptyChoiceIdx + 1) + ">" + (" in inside <" + options.topLevelRule.name + "> Rule.\n") + "Only the last alternative may be an empty alternative."; return errMsg; }, buildTooManyAlternativesError: function (options) { var errMsg = "An Alternation cannot have more than 256 alternatives:\n" + (" inside <" + options.topLevelRule.name + "> Rule.\n has " + (options.alternation.definition.length + 1) + " alternatives."); return errMsg; }, buildLeftRecursionError: function (options) { var ruleName = options.topLevelRule.name; var pathNames = utils.map(options.leftRecursionPath, function (currRule) { return currRule.name; }); var leftRecursivePath = ruleName + " --> " + pathNames .concat([ruleName]) .join(" --> "); var errMsg = "Left Recursion found in grammar.\n" + ("rule: <" + ruleName + "> can be invoked from itself (directly or indirectly)\n") + ("without consuming any Tokens. The grammar path that causes this is: \n " + leftRecursivePath + "\n") + " To fix this refactor your grammar to remove the left recursion.\n" + "see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring."; return errMsg; }, buildInvalidRuleNameError: function (options) { var ruleName = options.topLevelRule.name; var expectedPatternString = options.expectedPattern.toString(); var errMsg = "Invalid grammar rule name: ->" + ruleName + "<- it must match the pattern: ->" + expectedPatternString + "<-"; return errMsg; }, buildDuplicateRuleNameError: function (options) { var ruleName; if (options.topLevelRule instanceof gast_public_1.Rule) { ruleName = options.topLevelRule.name; } else { ruleName = options.topLevelRule; } var errMsg = "Duplicate definition, rule: ->" + ruleName + "<- is already defined in the grammar: ->" + options.grammarName + "<-"; return errMsg; } }; //# sourceMappingURL=errors_public.js.map /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var utils = __webpack_require__(0); var utils_1 = __webpack_require__(0); var parser_1 = __webpack_require__(2); var gast_1 = __webpack_require__(6); var lookahead_1 = __webpack_require__(12); var cst_1 = __webpack_require__(17); var interpreter_1 = __webpack_require__(13); var gast_public_1 = __webpack_require__(1); var gast_visitor_public_1 = __webpack_require__(4); function validateGrammar(topLevels, globalMaxLookahead, tokenTypes, ignoredIssues, errMsgProvider, grammarName) { var duplicateErrors = utils.map(topLevels, function (currTopLevel) { return validateDuplicateProductions(currTopLevel, errMsgProvider); }); var leftRecursionErrors = utils.map(topLevels, function (currTopRule) { return validateNoLeftRecursion(currTopRule, currTopRule, errMsgProvider); }); var emptyAltErrors = []; var ambiguousAltsErrors = []; var emptyRepetitionErrors = []; // left recursion could cause infinite loops in the following validations. // It is safest to first have the user fix the left recursion errors first and only then examine Further issues. if (utils_1.every(leftRecursionErrors, utils_1.isEmpty)) { emptyAltErrors = utils_1.map(topLevels, function (currTopRule) { return validateEmptyOrAlternative(currTopRule, errMsgProvider); }); ambiguousAltsErrors = utils_1.map(topLevels, function (currTopRule) { return validateAmbiguousAlternationAlternatives(currTopRule, globalMaxLookahead, ignoredIssues, errMsgProvider); }); emptyRepetitionErrors = validateSomeNonEmptyLookaheadPath(topLevels, globalMaxLookahead, errMsgProvider); } var termsNamespaceConflictErrors = checkTerminalAndNoneTerminalsNameSpace(topLevels, tokenTypes, errMsgProvider); var tokenNameErrors = utils.map(tokenTypes, function (currTokType) { return validateTokenName(currTokType, errMsgProvider); }); var nestedRulesNameErrors = validateNestedRulesNames(topLevels, errMsgProvider); var nestedRulesDuplicateErrors = validateDuplicateNestedRules(topLevels, errMsgProvider); var tooManyAltsErrors = utils_1.map(topLevels, function (curRule) { return validateTooManyAlts(curRule, errMsgProvider); }); var ruleNameErrors = utils_1.map(topLevels, function (curRule) { return validateRuleName(curRule, errMsgProvider); }); var duplicateRulesError = utils_1.map(topLevels, function (curRule) { return validateRuleDoesNotAlreadyExist(curRule, topLevels, grammarName, errMsgProvider); }); return (utils.flatten(duplicateErrors.concat(tokenNameErrors, nestedRulesNameErrors, nestedRulesDuplicateErrors, emptyRepetitionErrors, leftRecursionErrors, emptyAltErrors, ambiguousAltsErrors, termsNamespaceConflictErrors, tooManyAltsErrors, ruleNameErrors, duplicateRulesError))); } exports.validateGrammar = validateGrammar; function validateNestedRulesNames(topLevels, errMsgProvider) { var result = []; utils_1.forEach(topLevels, function (curTopLevel) { var namedCollectorVisitor = new cst_1.NamedDSLMethodsCollectorVisitor(""); curTopLevel.accept(namedCollectorVisitor); var nestedProds = utils_1.map(namedCollectorVisitor.result, function (currItem) { return currItem.orgProd; }); result.push(utils_1.map(nestedProds, function (currNestedProd) { return validateNestedRuleName(curTopLevel, currNestedProd, errMsgProvider); })); }); return utils_1.flatten(result); } function validateDuplicateProductions(topLevelRule, errMsgProvider) { var collectorVisitor = new OccurrenceValidationCollector(); topLevelRule.accept(collectorVisitor); var allRuleProductions = collectorVisitor.allProductions; var productionGroups = utils.groupBy(allRuleProductions, identifyProductionForDuplicates); var duplicates = utils.pick(productionGroups, function (currGroup) { return currGroup.length > 1; }); var errors = utils.map(utils.values(duplicates), function (currDuplicates) { var firstProd = utils.first(currDuplicates); var msg = errMsgProvider.buildDuplicateFoundError(topLevelRule, currDuplicates); var dslName = gast_1.getProductionDslName(firstProd); var defError = { message: msg, type: parser_1.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS, ruleName: topLevelRule.name, dslName: dslName, occurrence: firstProd.idx }; var param = getExtraProductionArgument(firstProd); if (param) { defError.parameter = param; } return defError; }); return errors; } function identifyProductionForDuplicates(prod) { return gast_1.getProductionDslName(prod) + "_#_" + prod.idx + "_#_" + getExtraProductionArgument(prod); } exports.identifyProductionForDuplicates = identifyProductionForDuplicates; function getExtraProductionArgument(prod) { if (prod instanceof gast_public_1.Terminal) { return prod.terminalType.name; } else if (prod instanceof gast_public_1.NonTerminal) { return prod.nonTerminalName; } else { return ""; } } var OccurrenceValidationCollector = /** @class */ (function (_super) { __extends(OccurrenceValidationCollector, _super); function OccurrenceValidationCollector() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.allProductions = []; return _this; } OccurrenceValidationCollector.prototype.visitNonTerminal = function (subrule) { this.allProductions.push(subrule); }; OccurrenceValidationCollector.prototype.visitOption = function (option) { this.allProductions.push(option); }; OccurrenceValidationCollector.prototype.visitRepetitionWithSeparator = function (manySep) { this.allProductions.push(manySep); }; OccurrenceValidationCollector.prototype.visitRepetitionMandatory = function (atLeastOne) { this.allProductions.push(atLeastOne); }; OccurrenceValidationCollector.prototype.visitRepetitionMandatoryWithSeparator = function (atLeastOneSep) { this.allProductions.push(atLeastOneSep); }; OccurrenceValidationCollector.prototype.visitRepetition = function (many) { this.allProductions.push(many); }; OccurrenceValidationCollector.prototype.visitAlternation = function (or) { this.allProductions.push(or); }; OccurrenceValidationCollector.prototype.visitTerminal = function (terminal) { this.allProductions.push(terminal); }; return OccurrenceValidationCollector; }(gast_visitor_public_1.GAstVisitor)); exports.OccurrenceValidationCollector = OccurrenceValidationCollector; exports.validTermsPattern = /^[a-zA-Z_]\w*$/; exports.validNestedRuleName = new RegExp(exports.validTermsPattern.source.replace("^", "^\\$")); // TODO: remove this limitation now that we use recorders function validateRuleName(rule, errMsgProvider) { var errors = []; var ruleName = rule.name; if (!ruleName.match(exports.validTermsPattern)) { errors.push({ message: errMsgProvider.buildInvalidRuleNameError({ topLevelRule: rule, expectedPattern: exports.validTermsPattern }), type: parser_1.ParserDefinitionErrorType.INVALID_RULE_NAME, ruleName: ruleName }); } return errors; } exports.validateRuleName = validateRuleName; // TODO: did the nested rule name regExp now change? function validateNestedRuleName(topLevel, nestedProd, errMsgProvider) { var errors = []; var errMsg; if (!nestedProd.name.match(exports.validNestedRuleName)) { errMsg = errMsgProvider.buildInvalidNestedRuleNameError(topLevel, nestedProd); errors.push({ message: errMsg, type: parser_1.ParserDefinitionErrorType.INVALID_NESTED_RULE_NAME, ruleName: topLevel.name }); } return errors; } exports.validateNestedRuleName = validateNestedRuleName; // TODO: remove this limitation now that we use recorders function validateTokenName(tokenType, errMsgProvider) { var errors = []; var tokTypeName = tokenType.name; if (!tokTypeName.match(exports.validTermsPattern)) { errors.push({ message: errMsgProvider.buildTokenNameError({ tokenType: tokenType, expectedPattern: exports.validTermsPattern }), type: parser_1.ParserDefinitionErrorType.INVALID_TOKEN_NAME }); } return errors; } exports.validateTokenName = validateTokenName; function validateRuleDoesNotAlreadyExist(rule, allRules, className, errMsgProvider) { var errors = []; var occurrences = utils_1.reduce(allRules, function (result, curRule) { if (curRule.name === rule.name) { return result + 1; } return result; }, 0); if (occurrences > 1) { var errMsg = errMsgProvider.buildDuplicateRuleNameError({ topLevelRule: rule, grammarName: className }); errors.push({ message: errMsg, type: parser_1.ParserDefinitionErrorType.DUPLICATE_RULE_NAME, ruleName: rule.name }); } return errors; } exports.validateRuleDoesNotAlreadyExist = validateRuleDoesNotAlreadyExist; // TODO: is there anyway to get only the rule names of rules inherited from the super grammars? // This is not part of the IGrammarErrorProvider because the validation cannot be performed on // The grammar structure, only at runtime. function validateRuleIsOverridden(ruleName, definedRulesNames, className) { var errors = []; var errMsg; if (!utils.contains(definedRulesNames, ruleName)) { errMsg = "Invalid rule override, rule: ->" + ruleName + "<- cannot be overridden in the grammar: ->" + className + "<-" + "as it is not defined in any of the super grammars "; errors.push({ message: errMsg, type: parser_1.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE, ruleName: ruleName }); } return errors; } exports.validateRuleIsOverridden = validateRuleIsOverridden; function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path) { if (path === void 0) { path = []; } var errors = []; var nextNonTerminals = getFirstNoneTerminal(currRule.definition); if (utils.isEmpty(nextNonTerminals)) { return []; } else { var ruleName = topRule.name; var foundLeftRecursion = utils.contains(nextNonTerminals, topRule); if (foundLeftRecursion) { errors.push({ message: errMsgProvider.buildLeftRecursionError({ topLevelRule: topRule, leftRecursionPath: path }), type: parser_1.ParserDefinitionErrorType.LEFT_RECURSION, ruleName: ruleName }); } // we are only looking for cyclic paths leading back to the specific topRule // other cyclic paths are ignored, we still need this difference to avoid infinite loops... var validNextSteps = utils.difference(nextNonTerminals, path.concat([topRule])); var errorsFromNextSteps = utils.map(validNextSteps, function (currRefRule) { var newPath = utils.cloneArr(path); newPath.push(currRefRule); return validateNoLeftRecursion(topRule, currRefRule, errMsgProvider, newPath); }); return errors.concat(utils.flatten(errorsFromNextSteps)); } } exports.validateNoLeftRecursion = validateNoLeftRecursion; function getFirstNoneTerminal(definition) { var result = []; if (utils.isEmpty(definition)) { return result; } var firstProd = utils.first(definition); /* istanbul ignore else */ if (firstProd instanceof gast_public_1.NonTerminal) { result.push(firstProd.referencedRule); } else if (firstProd instanceof gast_public_1.Flat || firstProd instanceof gast_public_1.Option || firstProd instanceof gast_public_1.RepetitionMandatory || firstProd instanceof gast_public_1.RepetitionMandatoryWithSeparator || firstProd instanceof gast_public_1.RepetitionWithSeparator || firstProd instanceof gast_public_1.Repetition) { result = result.concat(getFirstNoneTerminal(firstProd.definition)); } else if (firstProd instanceof gast_public_1.Alternation) { // each sub definition in alternation is a FLAT result = utils.flatten(utils.map(firstProd.definition, function (currSubDef) { return getFirstNoneTerminal(currSubDef.definition); })); } else if (firstProd instanceof gast_public_1.Terminal) { // nothing to see, move along } else { throw Error("non exhaustive match"); } var isFirstOptional = gast_1.isOptionalProd(firstProd); var hasMore = definition.length > 1; if (isFirstOptional && hasMore) { var rest = utils.drop(definition); return result.concat(getFirstNoneTerminal(rest)); } else { return result; } } exports.getFirstNoneTerminal = getFirstNoneTerminal; var OrCollector = /** @class */ (function (_super) { __extends(OrCollector, _super); function OrCollector() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.alternations = []; return _this; } OrCollector.prototype.visitAlternation = function (node) { this.alternations.push(node); }; return OrCollector; }(gast_visitor_public_1.GAstVisitor)); function validateEmptyOrAlternative(topLevelRule, errMsgProvider) { var orCollector = new OrCollector(); topLevelRule.accept(orCollector); var ors = orCollector.alternations; var errors = utils.reduce(ors, function (errors, currOr) { var exceptLast = utils.dropRight(currOr.definition); var currErrors = utils.map(exceptLast, function (currAlternative, currAltIdx) { var possibleFirstInAlt = interpreter_1.nextPossibleTokensAfter([currAlternative], [], null, 1); if (utils.isEmpty(possibleFirstInAlt)) { return { message: errMsgProvider.buildEmptyAlternationError({ topLevelRule: topLevelRule, alternation: currOr, emptyChoiceIdx: currAltIdx }), type: parser_1.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT, ruleName: topLevelRule.name, occurrence: currOr.idx, alternative: currAltIdx + 1 }; } else { return null; } }); return errors.concat(utils.compact(currErrors)); }, []); return errors; } exports.validateEmptyOrAlternative = validateEmptyOrAlternative; function validateAmbiguousAlternationAlternatives(topLevelRule, globalMaxLookahead, ignoredIssues, errMsgProvider) { var orCollector = new OrCollector(); topLevelRule.accept(orCollector); var ors = orCollector.alternations; // TODO: this filtering should be deprecated once we remove the ignoredIssues // IParserConfig property var ignoredIssuesForCurrentRule = ignoredIssues[topLevelRule.name]; if (ignoredIssuesForCurrentRule) { ors = utils_1.reject(ors, function (currOr) { return ignoredIssuesForCurrentRule[gast_1.getProductionDslName(currOr) + (currOr.idx === 0 ? "" : currOr.idx)]; }); } // New Handling of ignoring ambiguities // - https://github.com/SAP/chevrotain/issues/869 ors = utils_1.reject(ors, function (currOr) { return currOr.ignoreAmbiguities === true; }); var errors = utils.reduce(ors, function (result, currOr) { var currOccurrence = currOr.idx; var actualMaxLookahead = currOr.maxLookahead || globalMaxLookahead; var alternatives = lookahead_1.getLookaheadPathsForOr(currOccurrence, topLevelRule, actualMaxLookahead, currOr); var altsAmbiguityErrors = checkAlternativesAmbiguities(alternatives, currOr, topLevelRule, errMsgProvider); var altsPrefixAmbiguityErrors = checkPrefixAlternativesAmbiguities(alternatives, currOr, topLevelRule, errMsgProvider); return result.concat(altsAmbiguityErrors, altsPrefixAmbiguityErrors); }, []); return errors; } exports.validateAmbiguousAlternationAlternatives = validateAmbiguousAlternationAlternatives; var RepetionCollector = /** @class */ (function (_super) { __extends(RepetionCollector, _super); function RepetionCollector() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.allProductions = []; return _this; } RepetionCollector.prototype.visitRepetitionWithSeparator = function (manySep) { this.allProductions.push(manySep); }; RepetionCollector.prototype.visitRepetitionMandatory = function (atLeastOne) { this.allProductions.push(atLeastOne); }; RepetionCollector.prototype.visitRepetitionMandatoryWithSeparator = function (atLeastOneSep) { this.allProductions.push(atLeastOneSep); }; RepetionCollector.prototype.visitRepetition = function (many) { this.allProductions.push(many); }; return RepetionCollector; }(gast_visitor_public_1.GAstVisitor)); exports.RepetionCollector = RepetionCollector; function validateTooManyAlts(topLevelRule, errMsgProvider) { var orCollector = new OrCollector(); topLevelRule.accept(orCollector); var ors = orCollector.alternations; var errors = utils.reduce(ors, function (errors, currOr) { if (currOr.definition.length > 255) { errors.push({ message: errMsgProvider.buildTooManyAlternativesError({ topLevelRule: topLevelRule, alternation: currOr }), type: parser_1.ParserDefinitionErrorType.TOO_MANY_ALTS, ruleName: topLevelRule.name, occurrence: currOr.idx }); } return errors; }, []); return errors; } exports.validateTooManyAlts = validateTooManyAlts; function validateSomeNonEmptyLookaheadPath(topLevelRules, maxLookahead, errMsgProvider) { var errors = []; utils_1.forEach(topLevelRules, function (currTopRule) { var collectorVisitor = new RepetionCollector(); currTopRule.accept(collectorVisitor); var allRuleProductions = collectorVisitor.allProductions; utils_1.forEach(allRuleProductions, function (currProd) { var prodType = lookahead_1.getProdType(currProd); var actualMaxLookahead = currProd.maxLookahead || maxLookahead; var currOccurrence = currProd.idx; var paths = lookahead_1.getLookaheadPathsForOptionalProd(currOccurrence, currTopRule, prodType, actualMaxLookahead); var pathsInsideProduction = paths[0]; if (utils_1.isEmpty(utils_1.flatten(pathsInsideProduction))) { var errMsg = errMsgProvider.buildEmptyRepetitionError({ topLevelRule: currTopRule, repetition: currProd }); errors.push({ message: errMsg, type: parser_1.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD, ruleName: currTopRule.name }); } }); }); return errors; } exports.validateSomeNonEmptyLookaheadPath = validateSomeNonEmptyLookaheadPath; function checkAlternativesAmbiguities(alternatives, alternation, rule, errMsgProvider) { var foundAmbiguousPaths = []; var identicalAmbiguities = utils_1.reduce(alternatives, function (result, currAlt, currAltIdx) { // ignore (skip) ambiguities with this alternative if (alternation.definition[currAltIdx].ignoreAmbiguities === true) { return result; } utils_1.forEach(currAlt, function (currPath) { var altsCurrPathAppearsIn = [currAltIdx]; utils_1.forEach(alternatives, function (currOtherAlt, currOtherAltIdx) { if (currAltIdx !== currOtherAltIdx && lookahead_1.containsPath(currOtherAlt, currPath) && // ignore (skip) ambiguities with this "other" alternative alternation.definition[currOtherAltIdx] .ignoreAmbiguities !== true) { altsCurrPathAppearsIn.push(currOtherAltIdx); } }); if (altsCurrPathAppearsIn.length > 1 && !lookahead_1.containsPath(foundAmbiguousPaths, currPath)) { foundAmbiguousPaths.push(currPath); result.push({ alts: altsCurrPathAppearsIn, path: currPath }); } }); return result; }, []); var currErrors = utils.map(identicalAmbiguities, function (currAmbDescriptor) { var ambgIndices = utils_1.map(currAmbDescriptor.alts, function (currAltIdx) { return currAltIdx + 1; }); var currMessage = errMsgProvider.buildAlternationAmbiguityError({ topLevelRule: rule, alternation: alternation, ambiguityIndices: ambgIndices, prefixPath: currAmbDescriptor.path }); return { message: currMessage, type: parser_1.ParserDefinitionErrorType.AMBIGUOUS_ALTS, ruleName: rule.name, occurrence: alternation.idx, alternatives: [currAmbDescriptor.alts] }; }); return currErrors; } function checkPrefixAlternativesAmbiguities(alternatives, alternation, rule, errMsgProvider) { var errors = []; // flatten var pathsAndIndices = utils_1.reduce(alternatives, function (result, currAlt, idx) { var currPathsAndIdx = utils_1.map(currAlt, function (currPath) { return { idx: idx, path: currPath }; }); return result.concat(currPathsAndIdx); }, []); utils_1.forEach(pathsAndIndices, function (currPathAndIdx) { var alternativeGast = alternation.definition[currPathAndIdx.idx]; // ignore (skip) ambiguities with this alternative if (alternativeGast.ignoreAmbiguities === true) { return; } var targetIdx = currPathAndIdx.idx; var targetPath = currPathAndIdx.path; var prefixAmbiguitiesPathsAndIndices = utils_1.findAll(pathsAndIndices, function (searchPathAndIdx) { // prefix ambiguity can only be created from lower idx (higher priority) path return ( // ignore (skip) ambiguities with this "other" alternative alternation.definition[searchPathAndIdx.idx] .ignoreAmbiguities !== true && searchPathAndIdx.idx < targetIdx && // checking for strict prefix because identical lookaheads // will be be detected using a different validation. lookahead_1.isStrictPrefixOfPath(searchPathAndIdx.path, targetPath)); }); var currPathPrefixErrors = utils_1.map(prefixAmbiguitiesPathsAndIndices, function (currAmbPathAndIdx) { var ambgIndices = [currAmbPathAndIdx.idx + 1, targetIdx + 1]; var occurrence = alternation.idx === 0 ? "" : alternation.idx; var message = errMsgProvider.buildAlternationPrefixAmbiguityError({ topLevelRule: rule, alternation: alternation, ambiguityIndices: ambgIndices, prefixPath: currAmbPathAndIdx.path }); return { message: message, type: parser_1.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS, ruleName: rule.name, occurrence: occurrence, alternatives: ambgIndices }; }); errors = errors.concat(currPathPrefixErrors); }); return errors; } exports.checkPrefixAlternativesAmbiguities = checkPrefixAlternativesAmbiguities; function checkTerminalAndNoneTerminalsNameSpace(topLevels, tokenTypes, errMsgProvider) { var errors = []; var tokenNames = utils_1.map(tokenTypes, function (currToken) { return currToken.name; }); utils_1.forEach(topLevels, function (currRule) { var currRuleName = currRule.name; if (utils_1.contains(tokenNames, currRuleName)) { var errMsg = errMsgProvider.buildNamespaceConflictError(currRule); errors.push({ message: errMsg, type: parser_1.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE, ruleName: currRuleName }); } }); return errors; } function validateDuplicateNestedRules(topLevelRules, errMsgProvider) { var errors = []; utils_1.forEach(topLevelRules, function (currTopRule) { var namedCollectorVisitor = new cst_1.NamedDSLMethodsCollectorVisitor(""); currTopRule.accept(namedCollectorVisitor); var prodsByGroup = utils_1.groupBy(namedCollectorVisitor.result, function (item) { return item.name; }); var duplicates = utils_1.pick(prodsByGroup, function (currGroup) { return currGroup.length > 1; }); utils_1.forEach(utils_1.values(duplicates), function (currDupGroup) { var currDupProds = utils_1.map(currDupGroup, function (dupGroup) { return dupGroup.orgProd; }); var errMsg = errMsgProvider.buildDuplicateNestedRuleNameError(currTopRule, currDupProds); errors.push({ message: errMsg, type: parser_1.ParserDefinitionErrorType.DUPLICATE_NESTED_NAME, ruleName: currTopRule.name }); }); }); return errors; } //# sourceMappingURL=checks.js.map /***/ }), /* 12 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var interpreter_1 = __webpack_require__(13); var rest_1 = __webpack_require__(14); var tokens_1 = __webpack_require__(5); var gast_public_1 = __webpack_require__(1); var gast_visitor_public_1 = __webpack_require__(4); var PROD_TYPE; (function (PROD_TYPE) { PROD_TYPE[PROD_TYPE["OPTION"] = 0] = "OPTION"; PROD_TYPE[PROD_TYPE["REPETITION"] = 1] = "REPETITION"; PROD_TYPE[PROD_TYPE["REPETITION_MANDATORY"] = 2] = "REPETITION_MANDATORY"; PROD_TYPE[PROD_TYPE["REPETITION_MANDATORY_WITH_SEPARATOR"] = 3] = "REPETITION_MANDATORY_WITH_SEPARATOR"; PROD_TYPE[PROD_TYPE["REPETITION_WITH_SEPARATOR"] = 4] = "REPETITION_WITH_SEPARATOR"; PROD_TYPE[PROD_TYPE["ALTERNATION"] = 5] = "ALTERNATION"; })(PROD_TYPE = exports.PROD_TYPE || (exports.PROD_TYPE = {})); function getProdType(prod) { /* istanbul ignore else */ if (prod instanceof gast_public_1.Option) { return PROD_TYPE.OPTION; } else if (prod instanceof gast_public_1.Repetition) { return PROD_TYPE.REPETITION; } else if (prod instanceof gast_public_1.RepetitionMandatory) { return PROD_TYPE.REPETITION_MANDATORY; } else if (prod instanceof gast_public_1.RepetitionMandatoryWithSeparator) { return PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR; } else if (prod instanceof gast_public_1.RepetitionWithSeparator) { return PROD_TYPE.REPETITION_WITH_SEPARATOR; } else if (prod instanceof gast_public_1.Alternation) { return PROD_TYPE.ALTERNATION; } else { throw Error("non exhaustive match"); } } exports.getProdType = getProdType; function buildLookaheadFuncForOr(occurrence, ruleGrammar, maxLookahead, hasPredicates, dynamicTokensEnabled, laFuncBuilder) { var lookAheadPaths = getLookaheadPathsForOr(occurrence, ruleGrammar, maxLookahead); var tokenMatcher = areTokenCategoriesNotUsed(lookAheadPaths) ? tokens_1.tokenStructuredMatcherNoCategories : tokens_1.tokenStructuredMatcher; return laFuncBuilder(lookAheadPaths, hasPredicates, tokenMatcher, dynamicTokensEnabled); } exports.buildLookaheadFuncForOr = buildLookaheadFuncForOr; /** * When dealing with an Optional production (OPTION/MANY/2nd iteration of AT_LEAST_ONE/...) we need to compare * the lookahead "inside" the production and the lookahead immediately "after" it in the same top level rule (context free). * * Example: given a production: * ABC(DE)?DF * * The optional '(DE)?' should only be entered if we see 'DE'. a single Token 'D' is not sufficient to distinguish between the two * alternatives. * * @returns A Lookahead function which will return true IFF the parser should parse the Optional production. */ function buildLookaheadFuncForOptionalProd(occurrence, ruleGrammar, k, dynamicTokensEnabled, prodType, lookaheadBuilder) { var lookAheadPaths = getLookaheadPathsForOptionalProd(occurrence, ruleGrammar, prodType, k); var tokenMatcher = areTokenCategoriesNotUsed(lookAheadPaths) ? tokens_1.tokenStructuredMatcherNoCategories : tokens_1.tokenStructuredMatcher; return lookaheadBuilder(lookAheadPaths[0], tokenMatcher, dynamicTokensEnabled); } exports.buildLookaheadFuncForOptionalProd = buildLookaheadFuncForOptionalProd; function buildAlternativesLookAheadFunc(alts, hasPredicates, tokenMatcher, dynamicTokensEnabled) { var numOfAlts = alts.length; var areAllOneTokenLookahead = utils_1.every(alts, function (currAlt) { return utils_1.every(currAlt, function (currPath) { return currPath.length === 1; }); }); // This version takes into account the predicates as well. if (hasPredicates) { /** * @returns {number} - The chosen alternative index */ return function (orAlts) { // unfortunately the predicates must be extracted every single time // as they cannot be cached due to references to parameters(vars) which are no longer valid. // note that in the common case of no predicates, no cpu time will be wasted on this (see else block) var predicates = utils_1.map(orAlts, function (currAlt) { return currAlt.GATE; }); for (var t = 0; t < numOfAlts; t++) { var currAlt = alts[t]; var currNumOfPaths = currAlt.length; var currPredicate = predicates[t]; if (currPredicate !== undefined && currPredicate.call(this) === false) { // if the predicate does not match there is no point in checking the paths continue; } nextPath: for (var j = 0; j < currNumOfPaths; j++) { var currPath = currAlt[j]; var currPathLength = currPath.length; for (var i = 0; i < currPathLength; i++) { var nextToken = this.LA(i + 1); if (tokenMatcher(nextToken, currPath[i]) === false) { // mismatch in current path // try the next pth continue nextPath; } } // found a full path that matches. // this will also work for an empty ALT as the loop will be skipped return t; } // none of the paths for the current alternative matched // try the next alternative } // none of the alternatives could be matched return undefined; }; } else if (areAllOneTokenLookahead && !dynamicTokensEnabled) { // optimized (common) case of all the lookaheads paths requiring only // a single token lookahead. These Optimizations cannot work if dynamically defined Tokens are used. var singleTokenAlts = utils_1.map(alts, function (currAlt) { return utils_1.flatten(currAlt); }); var choiceToAlt_1 = utils_1.reduce(singleTokenAlts, function (result, currAlt, idx) { utils_1.forEach(currAlt, function (currTokType) { if (!utils_1.has(result, currTokType.tokenTypeIdx)) { result[currTokType.tokenTypeIdx] = idx; } utils_1.forEach(currTokType.categoryMatches, function (currExtendingType) { if (!utils_1.has(result, currExtendingType)) { result[currExtendingType] = idx; } }); }); return result; }, []); /** * @returns {number} - The chosen alternative index */ return function () { var nextToken = this.LA(1); return choiceToAlt_1[nextToken.tokenTypeIdx]; }; } else { // optimized lookahead without needing to check the predicates at all. // this causes code duplication which is intentional to improve performance. /** * @returns {number} - The chosen alternative index */ return function () { for (var t = 0; t < numOfAlts; t++) { var currAlt = alts[t]; var currNumOfPaths = currAlt.length; nextPath: for (var j = 0; j < currNumOfPaths; j++) { var currPath = currAlt[j]; var currPathLength = currPath.length; for (var i = 0; i < currPathLength; i++) { var nextToken = this.LA(i + 1); if (tokenMatcher(nextToken, currPath[i]) === false) { // mismatch in current path // try the next pth continue nextPath; } } // found a full path that matches. // this will also work for an empty ALT as the loop will be skipped return t; } // none of the paths for the current alternative matched // try the next alternative } // none of the alternatives could be matched return undefined; }; } } exports.buildAlternativesLookAheadFunc = buildAlternativesLookAheadFunc; function buildSingleAlternativeLookaheadFunction(alt, tokenMatcher, dynamicTokensEnabled) { var areAllOneTokenLookahead = utils_1.every(alt, function (currPath) { return currPath.length === 1; }); var numOfPaths = alt.length; // optimized (common) case of all the lookaheads paths requiring only // a single token lookahead. if (areAllOneTokenLookahead && !dynamicTokensEnabled) { var singleTokensTypes = utils_1.flatten(alt); if (singleTokensTypes.length === 1 && utils_1.isEmpty(singleTokensTypes[0].categoryMatches)) { var expectedTokenType = singleTokensTypes[0]; var expectedTokenUniqueKey_1 = expectedTokenType.tokenTypeIdx; return function () { return this.LA(1).tokenTypeIdx === expectedTokenUniqueKey_1; }; } else { var choiceToAlt_2 = utils_1.reduce(singleTokensTypes, function (result, currTokType, idx) { result[currTokType.tokenTypeIdx] = true; utils_1.forEach(currTokType.categoryMatches, function (currExtendingType) { result[currExtendingType] = true; }); return result; }, []); return function () { var nextToken = this.LA(1); return choiceToAlt_2[nextToken.tokenTypeIdx] === true; }; } } else { return function () { nextPath: for (var j = 0; j < numOfPaths; j++) { var currPath = alt[j]; var currPathLength = currPath.length; for (var i = 0; i < currPathLength; i++) { var nextToken = this.LA(i + 1); if (tokenMatcher(nextToken, currPath[i]) === false) { // mismatch in current path // try the next pth continue nextPath; } } // found a full path that matches. return true; } // none of the paths matched return false; }; } } exports.buildSingleAlternativeLookaheadFunction = buildSingleAlternativeLookaheadFunction; var RestDefinitionFinderWalker = /** @class */ (function (_super) { __extends(RestDefinitionFinderWalker, _super); function RestDefinitionFinderWalker(topProd, targetOccurrence, targetProdType) { var _this = _super.call(this) || this; _this.topProd = topProd; _this.targetOccurrence = targetOccurrence; _this.targetProdType = targetProdType; return _this; } RestDefinitionFinderWalker.prototype.startWalking = function () { this.walk(this.topProd); return this.restDef; }; RestDefinitionFinderWalker.prototype.checkIsTarget = function (node, expectedProdType, currRest, prevRest) { if (node.idx === this.targetOccurrence && this.targetProdType === expectedProdType) { this.restDef = currRest.concat(prevRest); return true; } // performance optimization, do not iterate over the entire Grammar ast after we have found the target return false; }; RestDefinitionFinderWalker.prototype.walkOption = function (optionProd, currRest, prevRest) { if (!this.checkIsTarget(optionProd, PROD_TYPE.OPTION, currRest, prevRest)) { _super.prototype.walkOption.call(this, optionProd, currRest, prevRest); } }; RestDefinitionFinderWalker.prototype.walkAtLeastOne = function (atLeastOneProd, currRest, prevRest) { if (!this.checkIsTarget(atLeastOneProd, PROD_TYPE.REPETITION_MANDATORY, currRest, prevRest)) { _super.prototype.walkOption.call(this, atLeastOneProd, currRest, prevRest); } }; RestDefinitionFinderWalker.prototype.walkAtLeastOneSep = function (atLeastOneSepProd, currRest, prevRest) { if (!this.checkIsTarget(atLeastOneSepProd, PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR, currRest, prevRest)) { _super.prototype.walkOption.call(this, atLeastOneSepProd, currRest, prevRest); } }; RestDefinitionFinderWalker.prototype.walkMany = function (manyProd, currRest, prevRest) { if (!this.checkIsTarget(manyProd, PROD_TYPE.REPETITION, currRest, prevRest)) { _super.prototype.walkOption.call(this, manyProd, currRest, prevRest); } }; RestDefinitionFinderWalker.prototype.walkManySep = function (manySepProd, currRest, prevRest) { if (!this.checkIsTarget(manySepProd, PROD_TYPE.REPETITION_WITH_SEPARATOR, currRest, prevRest)) { _super.prototype.walkOption.call(this, manySepProd, currRest, prevRest); } }; return RestDefinitionFinderWalker; }(rest_1.RestWalker)); /** * Returns the definition of a target production in a top level level rule. */ var InsideDefinitionFinderVisitor = /** @class */ (function (_super) { __extends(InsideDefinitionFinderVisitor, _super); function InsideDefinitionFinderVisitor(targetOccurrence, targetProdType, targetRef) { var _this = _super.call(this) || this; _this.targetOccurrence = targetOccurrence; _this.targetProdType = targetProdType; _this.targetRef = targetRef; _this.result = []; return _this; } InsideDefinitionFinderVisitor.prototype.checkIsTarget = function (node, expectedProdName) { if (node.idx === this.targetOccurrence && this.targetProdType === expectedProdName && (this.targetRef === undefined || node === this.targetRef)) { this.result = node.definition; } }; InsideDefinitionFinderVisitor.prototype.visitOption = function (node) { this.checkIsTarget(node, PROD_TYPE.OPTION); }; InsideDefinitionFinderVisitor.prototype.visitRepetition = function (node) { this.checkIsTarget(node, PROD_TYPE.REPETITION); }; InsideDefinitionFinderVisitor.prototype.visitRepetitionMandatory = function (node) { this.checkIsTarget(node, PROD_TYPE.REPETITION_MANDATORY); }; InsideDefinitionFinderVisitor.prototype.visitRepetitionMandatoryWithSeparator = function (node) { this.checkIsTarget(node, PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR); }; InsideDefinitionFinderVisitor.prototype.visitRepetitionWithSeparator = function (node) { this.checkIsTarget(node, PROD_TYPE.REPETITION_WITH_SEPARATOR); }; InsideDefinitionFinderVisitor.prototype.visitAlternation = function (node) { this.checkIsTarget(node, PROD_TYPE.ALTERNATION); }; return InsideDefinitionFinderVisitor; }(gast_visitor_public_1.GAstVisitor)); function initializeArrayOfArrays(size) { var result = new Array(size); for (var i = 0; i < size; i++) { result[i] = []; } return result; } /** * A sort of hash function between a Path in the grammar and a string. * Note that this returns multiple "hashes" to support the scenario of token categories. * - A single path with categories may match multiple **actual** paths. */ function pathToHashKeys(path) { var keys = [""]; for (var i = 0; i < path.length; i++) { var tokType = path[i]; var longerKeys = []; for (var j = 0; j < keys.length; j++) { var currShorterKey = keys[j]; longerKeys.push(currShorterKey + "_" + tokType.tokenTypeIdx); for (var t = 0; t < tokType.categoryMatches.length; t++) { var categoriesKeySuffix = "_" + tokType.categoryMatches[t]; longerKeys.push(currShorterKey + categoriesKeySuffix); } } keys = longerKeys; } return keys; } /** * Imperative style due to being called from a hot spot */ function isUniquePrefixHash(altKnownPathsKeys, searchPathKeys, idx) { for (var currAltIdx = 0; currAltIdx < altKnownPathsKeys.length; currAltIdx++) { // We only want to test vs the other alternatives if (currAltIdx === idx) { continue; } var otherAltKnownPathsKeys = altKnownPathsKeys[currAltIdx]; for (var searchIdx = 0; searchIdx < searchPathKeys.length; searchIdx++) { var searchKey = searchPathKeys[searchIdx]; if (otherAltKnownPathsKeys[searchKey] === true) { return false; } } } // None of the SearchPathKeys were found in any of the other alternatives return true; } function lookAheadSequenceFromAlternatives(altsDefs, k) { var partialAlts = utils_1.map(altsDefs, function (currAlt) { return interpreter_1.possiblePathsFrom([currAlt], 1); }); var finalResult = initializeArrayOfArrays(partialAlts.length); var altsHashes = utils_1.map(partialAlts, function (currAltPaths) { var dict = {}; utils_1.forEach(currAltPaths, function (item) { var keys = pathToHashKeys(item.partialPath); utils_1.forEach(keys, function (currKey) { dict[currKey] = true; }); }); return dict; }); var newData = partialAlts; // maxLookahead loop for (var pathLength = 1; pathLength <= k; pathLength++) { var currDataset = newData; newData = initializeArrayOfArrays(currDataset.length); var _loop_1 = function (altIdx) { var currAltPathsAndSuffixes = currDataset[altIdx]; // paths in current alternative loop for (var currPathIdx = 0; currPathIdx < currAltPathsAndSuffixes.length; currPathIdx++) { var currPathPrefix = currAltPathsAndSuffixes[currPathIdx].partialPath; var suffixDef = currAltPathsAndSuffixes[currPathIdx].suffixDef; var prefixKeys = pathToHashKeys(currPathPrefix); var isUnique = isUniquePrefixHash(altsHashes, prefixKeys, altIdx); // End of the line for this path. if (isUnique || utils_1.isEmpty(suffixDef) || currPathPrefix.length === k) { var currAltResult = finalResult[altIdx]; // TODO: Can we implement a containsPath using Maps/Dictionaries? if (containsPath(currAltResult, currPathPrefix) === false) { currAltResult.push(currPathPrefix); // Update all new keys for the current path. for (var j = 0; j < prefixKeys.length; j++) { var currKey = prefixKeys[j]; altsHashes[altIdx][currKey] = true; } } } // Expand longer paths else { var newPartialPathsAndSuffixes = interpreter_1.possiblePathsFrom(suffixDef, pathLength + 1, currPathPrefix); newData[altIdx] = newData[altIdx].concat(newPartialPathsAndSuffixes); // Update keys for new known paths utils_1.forEach(newPartialPathsAndSuffixes, function (item) { var prefixKeys = pathToHashKeys(item.partialPath); utils_1.forEach(prefixKeys, function (key) { altsHashes[altIdx][key] = true; }); }); } } }; // alternatives loop for (var altIdx = 0; altIdx < currDataset.length; altIdx++) { _loop_1(altIdx); } } return finalResult; } exports.lookAheadSequenceFromAlternatives = lookAheadSequenceFromAlternatives; function getLookaheadPathsForOr(occurrence, ruleGrammar, k, orProd) { var visitor = new InsideDefinitionFinderVisitor(occurrence, PROD_TYPE.ALTERNATION, orProd); ruleGrammar.accept(visitor); return lookAheadSequenceFromAlternatives(visitor.result, k); } exports.getLookaheadPathsForOr = getLookaheadPathsForOr; function getLookaheadPathsForOptionalProd(occurrence, ruleGrammar, prodType, k) { var insideDefVisitor = new InsideDefinitionFinderVisitor(occurrence, prodType); ruleGrammar.accept(insideDefVisitor); var insideDef = insideDefVisitor.result; var afterDefWalker = new RestDefinitionFinderWalker(ruleGrammar, occurrence, prodType); var afterDef = afterDefWalker.startWalking(); var insideFlat = new gast_public_1.Flat({ definition: insideDef }); var afterFlat = new gast_public_1.Flat({ definition: afterDef }); return lookAheadSequenceFromAlternatives([insideFlat, afterFlat], k); } exports.getLookaheadPathsForOptionalProd = getLookaheadPathsForOptionalProd; function containsPath(alternative, searchPath) { compareOtherPath: for (var i = 0; i < alternative.length; i++) { var otherPath = alternative[i]; if (otherPath.length !== searchPath.length) { continue; } for (var j = 0; j < otherPath.length; j++) { var searchTok = searchPath[j]; var otherTok = otherPath[j]; var matchingTokens = searchTok === otherTok || otherTok.categoryMatchesMap[searchTok.tokenTypeIdx] !== undefined; if (matchingTokens === false) { continue compareOtherPath; } } return true; } return false; } exports.containsPath = containsPath; function isStrictPrefixOfPath(prefix, other) { return (prefix.length < other.length && utils_1.every(prefix, function (tokType, idx) { var otherTokType = other[idx]; return (tokType === otherTokType || otherTokType.categoryMatchesMap[tokType.tokenTypeIdx]); })); } exports.isStrictPrefixOfPath = isStrictPrefixOfPath; function areTokenCategoriesNotUsed(lookAheadPaths) { return utils_1.every(lookAheadPaths, function (singleAltPaths) { return utils_1.every(singleAltPaths, function (singlePath) { return utils_1.every(singlePath, function (token) { return utils_1.isEmpty(token.categoryMatches); }); }); }); } exports.areTokenCategoriesNotUsed = areTokenCategoriesNotUsed; //# sourceMappingURL=lookahead.js.map /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* istanbul ignore next */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var rest_1 = __webpack_require__(14); var utils_1 = __webpack_require__(0); var first_1 = __webpack_require__(22); var gast_public_1 = __webpack_require__(1); var AbstractNextPossibleTokensWalker = /** @class */ (function (_super) { __extends(AbstractNextPossibleTokensWalker, _super); function AbstractNextPossibleTokensWalker(topProd, path) { var _this = _super.call(this) /* istanbul ignore next */ || this; _this.topProd = topProd; _this.path = path; _this.possibleTokTypes = []; _this.nextProductionName = ""; _this.nextProductionOccurrence = 0; _this.found = false; _this.isAtEndOfPath = false; return _this; } AbstractNextPossibleTokensWalker.prototype.startWalking = function () { this.found = false; if (this.path.ruleStack[0] !== this.topProd.name) { throw Error("The path does not start with the walker's top Rule!"); } // immutable for the win this.ruleStack = utils_1.cloneArr(this.path.ruleStack).reverse(); // intelij bug requires assertion this.occurrenceStack = utils_1.cloneArr(this.path.occurrenceStack).reverse(); // intelij bug requires assertion // already verified that the first production is valid, we now seek the 2nd production this.ruleStack.pop(); this.occurrenceStack.pop(); this.updateExpectedNext(); this.walk(this.topProd); return this.possibleTokTypes; }; AbstractNextPossibleTokensWalker.prototype.walk = function (prod, prevRest) { if (prevRest === void 0) { prevRest = []; } // stop scanning once we found the path if (!this.found) { _super.prototype.walk.call(this, prod, prevRest); } }; AbstractNextPossibleTokensWalker.prototype.walkProdRef = function (refProd, currRest, prevRest) { // found the next production, need to keep walking in it if (refProd.referencedRule.name === this.nextProductionName && refProd.idx === this.nextProductionOccurrence) { var fullRest = currRest.concat(prevRest); this.updateExpectedNext(); this.walk(refProd.referencedRule, fullRest); } }; AbstractNextPossibleTokensWalker.prototype.updateExpectedNext = function () { // need to consume the Terminal if (utils_1.isEmpty(this.ruleStack)) { // must reset nextProductionXXX to avoid walking down another Top Level production while what we are // really seeking is the last Terminal... this.nextProductionName = ""; this.nextProductionOccurrence = 0; this.isAtEndOfPath = true; } else { this.nextProductionName = this.ruleStack.pop(); this.nextProductionOccurrence = this.occurrenceStack.pop(); } }; return AbstractNextPossibleTokensWalker; }(rest_1.RestWalker)); exports.AbstractNextPossibleTokensWalker = AbstractNextPossibleTokensWalker; var NextAfterTokenWalker = /** @class */ (function (_super) { __extends(NextAfterTokenWalker, _super); function NextAfterTokenWalker(topProd, path) { var _this = _super.call(this, topProd, path) /* istanbul ignore next */ || this; _this.path = path; _this.nextTerminalName = ""; _this.nextTerminalOccurrence = 0; _this.nextTerminalName = _this.path.lastTok.name; _this.nextTerminalOccurrence = _this.path.lastTokOccurrence; return _this; } NextAfterTokenWalker.prototype.walkTerminal = function (terminal, currRest, prevRest) { if (this.isAtEndOfPath && terminal.terminalType.name === this.nextTerminalName && terminal.idx === this.nextTerminalOccurrence && !this.found) { var fullRest = currRest.concat(prevRest); var restProd = new gast_public_1.Flat({ definition: fullRest }); this.possibleTokTypes = first_1.first(restProd); this.found = true; } }; return NextAfterTokenWalker; }(AbstractNextPossibleTokensWalker)); exports.NextAfterTokenWalker = NextAfterTokenWalker; /** * This walker only "walks" a single "TOP" level in the Grammar Ast, this means * it never "follows" production refs */ var AbstractNextTerminalAfterProductionWalker = /** @class */ (function (_super) { __extends(AbstractNextTerminalAfterProductionWalker, _super); function AbstractNextTerminalAfterProductionWalker(topRule, occurrence) { var _this = _super.call(this) /* istanbul ignore next */ || this; _this.topRule = topRule; _this.occurrence = occurrence; _this.result = { token: undefined, occurrence: undefined, isEndOfRule: undefined }; return _this; } AbstractNextTerminalAfterProductionWalker.prototype.startWalking = function () { this.walk(this.topRule); return this.result; }; return AbstractNextTerminalAfterProductionWalker; }(rest_1.RestWalker)); exports.AbstractNextTerminalAfterProductionWalker = AbstractNextTerminalAfterProductionWalker; var NextTerminalAfterManyWalker = /** @class */ (function (_super) { __extends(NextTerminalAfterManyWalker, _super); function NextTerminalAfterManyWalker() { return _super !== null && _super.apply(this, arguments) /* istanbul ignore next */ || this; } NextTerminalAfterManyWalker.prototype.walkMany = function (manyProd, currRest, prevRest) { if (manyProd.idx === this.occurrence) { var firstAfterMany = utils_1.first(currRest.concat(prevRest)); this.result.isEndOfRule = firstAfterMany === undefined; if (firstAfterMany instanceof gast_public_1.Terminal) { this.result.token = firstAfterMany.terminalType; this.result.occurrence = firstAfterMany.idx; } } else { _super.prototype.walkMany.call(this, manyProd, currRest, prevRest); } }; return NextTerminalAfterManyWalker; }(AbstractNextTerminalAfterProductionWalker)); exports.NextTerminalAfterManyWalker = NextTerminalAfterManyWalker; var NextTerminalAfterManySepWalker = /** @class */ (function (_super) { __extends(NextTerminalAfterManySepWalker, _super); function NextTerminalAfterManySepWalker() { return _super !== null && _super.apply(this, arguments) /* istanbul ignore next */ || this; } NextTerminalAfterManySepWalker.prototype.walkManySep = function (manySepProd, currRest, prevRest) { if (manySepProd.idx === this.occurrence) { var firstAfterManySep = utils_1.first(currRest.concat(prevRest)); this.result.isEndOfRule = firstAfterManySep === undefined; if (firstAfterManySep instanceof gast_public_1.Terminal) { this.result.token = firstAfterManySep.terminalType; this.result.occurrence = firstAfterManySep.idx; } } else { _super.prototype.walkManySep.call(this, manySepProd, currRest, prevRest); } }; return NextTerminalAfterManySepWalker; }(AbstractNextTerminalAfterProductionWalker)); exports.NextTerminalAfterManySepWalker = NextTerminalAfterManySepWalker; var NextTerminalAfterAtLeastOneWalker = /** @class */ (function (_super) { __extends(NextTerminalAfterAtLeastOneWalker, _super); function NextTerminalAfterAtLeastOneWalker() { return _super !== null && _super.apply(this, arguments) /* istanbul ignore next */ || this; } NextTerminalAfterAtLeastOneWalker.prototype.walkAtLeastOne = function (atLeastOneProd, currRest, prevRest) { if (atLeastOneProd.idx === this.occurrence) { var firstAfterAtLeastOne = utils_1.first(currRest.concat(prevRest)); this.result.isEndOfRule = firstAfterAtLeastOne === undefined; if (firstAfterAtLeastOne instanceof gast_public_1.Terminal) { this.result.token = firstAfterAtLeastOne.terminalType; this.result.occurrence = firstAfterAtLeastOne.idx; } } else { _super.prototype.walkAtLeastOne.call(this, atLeastOneProd, currRest, prevRest); } }; return NextTerminalAfterAtLeastOneWalker; }(AbstractNextTerminalAfterProductionWalker)); exports.NextTerminalAfterAtLeastOneWalker = NextTerminalAfterAtLeastOneWalker; // TODO: reduce code duplication in the AfterWalkers var NextTerminalAfterAtLeastOneSepWalker = /** @class */ (function (_super) { __extends(NextTerminalAfterAtLeastOneSepWalker, _super); function NextTerminalAfterAtLeastOneSepWalker() { return _super !== null && _super.apply(this, arguments) /* istanbul ignore next */ || this; } NextTerminalAfterAtLeastOneSepWalker.prototype.walkAtLeastOneSep = function (atleastOneSepProd, currRest, prevRest) { if (atleastOneSepProd.idx === this.occurrence) { var firstAfterfirstAfterAtLeastOneSep = utils_1.first(currRest.concat(prevRest)); this.result.isEndOfRule = firstAfterfirstAfterAtLeastOneSep === undefined; if (firstAfterfirstAfterAtLeastOneSep instanceof gast_public_1.Terminal) { this.result.token = firstAfterfirstAfterAtLeastOneSep.terminalType; this.result.occurrence = firstAfterfirstAfterAtLeastOneSep.idx; } } else { _super.prototype.walkAtLeastOneSep.call(this, atleastOneSepProd, currRest, prevRest); } }; return NextTerminalAfterAtLeastOneSepWalker; }(AbstractNextTerminalAfterProductionWalker)); exports.NextTerminalAfterAtLeastOneSepWalker = NextTerminalAfterAtLeastOneSepWalker; function possiblePathsFrom(targetDef, maxLength, currPath) { if (currPath === void 0) { currPath = []; } // avoid side effects currPath = utils_1.cloneArr(currPath); var result = []; var i = 0; // TODO: avoid inner funcs function remainingPathWith(nextDef) { return nextDef.concat(utils_1.drop(targetDef, i + 1)); } // TODO: avoid inner funcs function getAlternativesForProd(definition) { var alternatives = possiblePathsFrom(remainingPathWith(definition), maxLength, currPath); return result.concat(alternatives); } /** * Mandatory productions will halt the loop as the paths computed from their recursive calls will already contain the * following (rest) of the targetDef. * * For optional productions (Option/Repetition/...) the loop will continue to represent the paths that do not include the * the optional production. */ while (currPath.length < maxLength && i < targetDef.length) { var prod = targetDef[i]; /* istanbul ignore else */ if (prod instanceof gast_public_1.Flat) { return getAlternativesForProd(prod.definition); } else if (prod instanceof gast_public_1.NonTerminal) { return getAlternativesForProd(prod.definition); } else if (prod instanceof gast_public_1.Option) { result = getAlternativesForProd(prod.definition); } else if (prod instanceof gast_public_1.RepetitionMandatory) { var newDef = prod.definition.concat([ new gast_public_1.Repetition({ definition: prod.definition }) ]); return getAlternativesForProd(newDef); } else if (prod instanceof gast_public_1.RepetitionMandatoryWithSeparator) { var newDef = [ new gast_public_1.Flat({ definition: prod.definition }), new gast_public_1.Repetition({ definition: [ new gast_public_1.Terminal({ terminalType: prod.separator }) ].concat(prod.definition) }) ]; return getAlternativesForProd(newDef); } else if (prod instanceof gast_public_1.RepetitionWithSeparator) { var newDef = prod.definition.concat([ new gast_public_1.Repetition({ definition: [ new gast_public_1.Terminal({ terminalType: prod.separator }) ].concat(prod.definition) }) ]); result = getAlternativesForProd(newDef); } else if (prod instanceof gast_public_1.Repetition) { var newDef = prod.definition.concat([ new gast_public_1.Repetition({ definition: prod.definition }) ]); result = getAlternativesForProd(newDef); } else if (prod instanceof gast_public_1.Alternation) { utils_1.forEach(prod.definition, function (currAlt) { result = getAlternativesForProd(currAlt.definition); }); return result; } else if (prod instanceof gast_public_1.Terminal) { currPath.push(prod.terminalType); } else { throw Error("non exhaustive match"); } i++; } result.push({ partialPath: currPath, suffixDef: utils_1.drop(targetDef, i) }); return result; } exports.possiblePathsFrom = possiblePathsFrom; function nextPossibleTokensAfter(initialDef, tokenVector, tokMatcher, maxLookAhead) { var EXIT_NON_TERMINAL = "EXIT_NONE_TERMINAL"; // to avoid creating a new Array each time. var EXIT_NON_TERMINAL_ARR = [EXIT_NON_TERMINAL]; var EXIT_ALTERNATIVE = "EXIT_ALTERNATIVE"; var foundCompletePath = false; var tokenVectorLength = tokenVector.length; var minimalAlternativesIndex = tokenVectorLength - maxLookAhead - 1; var result = []; var possiblePaths = []; possiblePaths.push({ idx: -1, def: initialDef, ruleStack: [], occurrenceStack: [] }); while (!utils_1.isEmpty(possiblePaths)) { var currPath = possiblePaths.pop(); // skip alternatives if no more results can be found (assuming deterministic grammar with fixed lookahead) if (currPath === EXIT_ALTERNATIVE) { if (foundCompletePath && utils_1.last(possiblePaths).idx <= minimalAlternativesIndex) { // remove irrelevant alternative possiblePaths.pop(); } continue; } var currDef = currPath.def; var currIdx = currPath.idx; var currRuleStack = currPath.ruleStack; var currOccurrenceStack = currPath.occurrenceStack; // For Example: an empty path could exist in a valid grammar in the case of an EMPTY_ALT if (utils_1.isEmpty(currDef)) { continue; } var prod = currDef[0]; /* istanbul ignore else */ if (prod === EXIT_NON_TERMINAL) { var nextPath = { idx: currIdx, def: utils_1.drop(currDef), ruleStack: utils_1.dropRight(currRuleStack), occurrenceStack: utils_1.dropRight(currOccurrenceStack) }; possiblePaths.push(nextPath); } else if (prod instanceof gast_public_1.Terminal) { /* istanbul ignore else */ if (currIdx < tokenVectorLength - 1) { var nextIdx = currIdx + 1; var actualToken = tokenVector[nextIdx]; if (tokMatcher(actualToken, prod.terminalType)) { var nextPath = { idx: nextIdx, def: utils_1.drop(currDef), ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }; possiblePaths.push(nextPath); } // end of the line } else if (currIdx === tokenVectorLength - 1) { // IGNORE ABOVE ELSE result.push({ nextTokenType: prod.terminalType, nextTokenOccurrence: prod.idx, ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }); foundCompletePath = true; } else { throw Error("non exhaustive match"); } } else if (prod instanceof gast_public_1.NonTerminal) { var newRuleStack = utils_1.cloneArr(currRuleStack); newRuleStack.push(prod.nonTerminalName); var newOccurrenceStack = utils_1.cloneArr(currOccurrenceStack); newOccurrenceStack.push(prod.idx); var nextPath = { idx: currIdx, def: prod.definition.concat(EXIT_NON_TERMINAL_ARR, utils_1.drop(currDef)), ruleStack: newRuleStack, occurrenceStack: newOccurrenceStack }; possiblePaths.push(nextPath); } else if (prod instanceof gast_public_1.Option) { // the order of alternatives is meaningful, FILO (Last path will be traversed first). var nextPathWithout = { idx: currIdx, def: utils_1.drop(currDef), ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }; possiblePaths.push(nextPathWithout); // required marker to avoid backtracking paths whose higher priority alternatives already matched possiblePaths.push(EXIT_ALTERNATIVE); var nextPathWith = { idx: currIdx, def: prod.definition.concat(utils_1.drop(currDef)), ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }; possiblePaths.push(nextPathWith); } else if (prod instanceof gast_public_1.RepetitionMandatory) { // TODO:(THE NEW operators here take a while...) (convert once?) var secondIteration = new gast_public_1.Repetition({ definition: prod.definition, idx: prod.idx }); var nextDef = prod.definition.concat([secondIteration], utils_1.drop(currDef)); var nextPath = { idx: currIdx, def: nextDef, ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }; possiblePaths.push(nextPath); } else if (prod instanceof gast_public_1.RepetitionMandatoryWithSeparator) { // TODO:(THE NEW operators here take a while...) (convert once?) var separatorGast = new gast_public_1.Terminal({ terminalType: prod.separator }); var secondIteration = new gast_public_1.Repetition({ definition: [separatorGast].concat(prod.definition), idx: prod.idx }); var nextDef = prod.definition.concat([secondIteration], utils_1.drop(currDef)); var nextPath = { idx: currIdx, def: nextDef, ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }; possiblePaths.push(nextPath); } else if (prod instanceof gast_public_1.RepetitionWithSeparator) { // the order of alternatives is meaningful, FILO (Last path will be traversed first). var nextPathWithout = { idx: currIdx, def: utils_1.drop(currDef), ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }; possiblePaths.push(nextPathWithout); // required marker to avoid backtracking paths whose higher priority alternatives already matched possiblePaths.push(EXIT_ALTERNATIVE); var separatorGast = new gast_public_1.Terminal({ terminalType: prod.separator }); var nthRepetition = new gast_public_1.Repetition({ definition: [separatorGast].concat(prod.definition), idx: prod.idx }); var nextDef = prod.definition.concat([nthRepetition], utils_1.drop(currDef)); var nextPathWith = { idx: currIdx, def: nextDef, ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }; possiblePaths.push(nextPathWith); } else if (prod instanceof gast_public_1.Repetition) { // the order of alternatives is meaningful, FILO (Last path will be traversed first). var nextPathWithout = { idx: currIdx, def: utils_1.drop(currDef), ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }; possiblePaths.push(nextPathWithout); // required marker to avoid backtracking paths whose higher priority alternatives already matched possiblePaths.push(EXIT_ALTERNATIVE); // TODO: an empty repetition will cause infinite loops here, will the parser detect this in selfAnalysis? var nthRepetition = new gast_public_1.Repetition({ definition: prod.definition, idx: prod.idx }); var nextDef = prod.definition.concat([nthRepetition], utils_1.drop(currDef)); var nextPathWith = { idx: currIdx, def: nextDef, ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }; possiblePaths.push(nextPathWith); } else if (prod instanceof gast_public_1.Alternation) { // the order of alternatives is meaningful, FILO (Last path will be traversed first). for (var i = prod.definition.length - 1; i >= 0; i--) { var currAlt = prod.definition[i]; var currAltPath = { idx: currIdx, def: currAlt.definition.concat(utils_1.drop(currDef)), ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }; possiblePaths.push(currAltPath); possiblePaths.push(EXIT_ALTERNATIVE); } } else if (prod instanceof gast_public_1.Flat) { possiblePaths.push({ idx: currIdx, def: prod.definition.concat(utils_1.drop(currDef)), ruleStack: currRuleStack, occurrenceStack: currOccurrenceStack }); } else if (prod instanceof gast_public_1.Rule) { // last because we should only encounter at most a single one of these per invocation. possiblePaths.push(expandTopLevelRule(prod, currIdx, currRuleStack, currOccurrenceStack)); } else { throw Error("non exhaustive match"); } } return result; } exports.nextPossibleTokensAfter = nextPossibleTokensAfter; function expandTopLevelRule(topRule, currIdx, currRuleStack, currOccurrenceStack) { var newRuleStack = utils_1.cloneArr(currRuleStack); newRuleStack.push(topRule.name); var newCurrOccurrenceStack = utils_1.cloneArr(currOccurrenceStack); // top rule is always assumed to have been called with occurrence index 1 newCurrOccurrenceStack.push(1); return { idx: currIdx, def: topRule.definition, ruleStack: newRuleStack, occurrenceStack: newCurrOccurrenceStack }; } //# sourceMappingURL=interpreter.js.map /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var gast_public_1 = __webpack_require__(1); /** * A Grammar Walker that computes the "remaining" grammar "after" a productions in the grammar. */ var RestWalker = /** @class */ (function () { function RestWalker() { } RestWalker.prototype.walk = function (prod, prevRest) { var _this = this; if (prevRest === void 0) { prevRest = []; } utils_1.forEach(prod.definition, function (subProd, index) { var currRest = utils_1.drop(prod.definition, index + 1); /* istanbul ignore else */ if (subProd instanceof gast_public_1.NonTerminal) { _this.walkProdRef(subProd, currRest, prevRest); } else if (subProd instanceof gast_public_1.Terminal) { _this.walkTerminal(subProd, currRest, prevRest); } else if (subProd instanceof gast_public_1.Flat) { _this.walkFlat(subProd, currRest, prevRest); } else if (subProd instanceof gast_public_1.Option) { _this.walkOption(subProd, currRest, prevRest); } else if (subProd instanceof gast_public_1.RepetitionMandatory) { _this.walkAtLeastOne(subProd, currRest, prevRest); } else if (subProd instanceof gast_public_1.RepetitionMandatoryWithSeparator) { _this.walkAtLeastOneSep(subProd, currRest, prevRest); } else if (subProd instanceof gast_public_1.RepetitionWithSeparator) { _this.walkManySep(subProd, currRest, prevRest); } else if (subProd instanceof gast_public_1.Repetition) { _this.walkMany(subProd, currRest, prevRest); } else if (subProd instanceof gast_public_1.Alternation) { _this.walkOr(subProd, currRest, prevRest); } else { throw Error("non exhaustive match"); } }); }; RestWalker.prototype.walkTerminal = function (terminal, currRest, prevRest) { }; RestWalker.prototype.walkProdRef = function (refProd, currRest, prevRest) { }; RestWalker.prototype.walkFlat = function (flatProd, currRest, prevRest) { // ABCDEF => after the D the rest is EF var fullOrRest = currRest.concat(prevRest); this.walk(flatProd, fullOrRest); }; RestWalker.prototype.walkOption = function (optionProd, currRest, prevRest) { // ABC(DE)?F => after the (DE)? the rest is F var fullOrRest = currRest.concat(prevRest); this.walk(optionProd, fullOrRest); }; RestWalker.prototype.walkAtLeastOne = function (atLeastOneProd, currRest, prevRest) { // ABC(DE)+F => after the (DE)+ the rest is (DE)?F var fullAtLeastOneRest = [ new gast_public_1.Option({ definition: atLeastOneProd.definition }) ].concat(currRest, prevRest); this.walk(atLeastOneProd, fullAtLeastOneRest); }; RestWalker.prototype.walkAtLeastOneSep = function (atLeastOneSepProd, currRest, prevRest) { // ABC DE(,DE)* F => after the (,DE)+ the rest is (,DE)?F var fullAtLeastOneSepRest = restForRepetitionWithSeparator(atLeastOneSepProd, currRest, prevRest); this.walk(atLeastOneSepProd, fullAtLeastOneSepRest); }; RestWalker.prototype.walkMany = function (manyProd, currRest, prevRest) { // ABC(DE)*F => after the (DE)* the rest is (DE)?F var fullManyRest = [ new gast_public_1.Option({ definition: manyProd.definition }) ].concat(currRest, prevRest); this.walk(manyProd, fullManyRest); }; RestWalker.prototype.walkManySep = function (manySepProd, currRest, prevRest) { // ABC (DE(,DE)*)? F => after the (,DE)* the rest is (,DE)?F var fullManySepRest = restForRepetitionWithSeparator(manySepProd, currRest, prevRest); this.walk(manySepProd, fullManySepRest); }; RestWalker.prototype.walkOr = function (orProd, currRest, prevRest) { var _this = this; // ABC(D|E|F)G => when finding the (D|E|F) the rest is G var fullOrRest = currRest.concat(prevRest); // walk all different alternatives utils_1.forEach(orProd.definition, function (alt) { // wrapping each alternative in a single definition wrapper // to avoid errors in computing the rest of that alternative in the invocation to computeInProdFollows // (otherwise for OR([alt1,alt2]) alt2 will be considered in 'rest' of alt1 var prodWrapper = new gast_public_1.Flat({ definition: [alt] }); _this.walk(prodWrapper, fullOrRest); }); }; return RestWalker; }()); exports.RestWalker = RestWalker; function restForRepetitionWithSeparator(repSepProd, currRest, prevRest) { var repSepRest = [ new gast_public_1.Option({ definition: [ new gast_public_1.Terminal({ terminalType: repSepProd.separator }) ].concat(repSepProd.definition) }) ]; var fullRepSepRest = repSepRest.concat(currRest, prevRest); return fullRepSepRest; } //# sourceMappingURL=rest.js.map /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;;(function(root, factory) { // istanbul ignore next if (true) { // istanbul ignore next !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) } else {} })( typeof self !== "undefined" ? // istanbul ignore next self : this, function() { // references // https://hackernoon.com/the-madness-of-parsing-real-world-javascript-regexps-d9ee336df983 // https://www.ecma-international.org/ecma-262/8.0/index.html#prod-Pattern function RegExpParser() {} RegExpParser.prototype.saveState = function() { return { idx: this.idx, input: this.input, groupIdx: this.groupIdx } } RegExpParser.prototype.restoreState = function(newState) { this.idx = newState.idx this.input = newState.input this.groupIdx = newState.groupIdx } RegExpParser.prototype.pattern = function(input) { // parser state this.idx = 0 this.input = input this.groupIdx = 0 this.consumeChar("/") var value = this.disjunction() this.consumeChar("/") var flags = { type: "Flags", global: false, ignoreCase: false, multiLine: false, unicode: false, sticky: false } while (this.isRegExpFlag()) { switch (this.popChar()) { case "g": addFlag(flags, "global") break case "i": addFlag(flags, "ignoreCase") break case "m": addFlag(flags, "multiLine") break case "u": addFlag(flags, "unicode") break case "y": addFlag(flags, "sticky") break } } if (this.idx !== this.input.length) { throw Error( "Redundant input: " + this.input.substring(this.idx) ) } return { type: "Pattern", flags: flags, value: value } } RegExpParser.prototype.disjunction = function() { var alts = [] alts.push(this.alternative()) while (this.peekChar() === "|") { this.consumeChar("|") alts.push(this.alternative()) } return { type: "Disjunction", value: alts } } RegExpParser.prototype.alternative = function() { var terms = [] while (this.isTerm()) { terms.push(this.term()) } return { type: "Alternative", value: terms } } RegExpParser.prototype.term = function() { if (this.isAssertion()) { return this.assertion() } else { return this.atom() } } RegExpParser.prototype.assertion = function() { switch (this.popChar()) { case "^": return { type: "StartAnchor" } case "$": return { type: "EndAnchor" } // '\b' or '\B' case "\\": switch (this.popChar()) { case "b": return { type: "WordBoundary" } case "B": return { type: "NonWordBoundary" } } // istanbul ignore next throw Error("Invalid Assertion Escape") // '(?=' or '(?!' case "(": this.consumeChar("?") var type switch (this.popChar()) { case "=": type = "Lookahead" break case "!": type = "NegativeLookahead" break } ASSERT_EXISTS(type) var disjunction = this.disjunction() this.consumeChar(")") return { type: type, value: disjunction } } // istanbul ignore next ASSERT_NEVER_REACH_HERE() } RegExpParser.prototype.quantifier = function(isBacktracking) { var range switch (this.popChar()) { case "*": range = { atLeast: 0, atMost: Infinity } break case "+": range = { atLeast: 1, atMost: Infinity } break case "?": range = { atLeast: 0, atMost: 1 } break case "{": var atLeast = this.integerIncludingZero() switch (this.popChar()) { case "}": range = { atLeast: atLeast, atMost: atLeast } break case ",": var atMost if (this.isDigit()) { atMost = this.integerIncludingZero() range = { atLeast: atLeast, atMost: atMost } } else { range = { atLeast: atLeast, atMost: Infinity } } this.consumeChar("}") break } // throwing exceptions from "ASSERT_EXISTS" during backtracking // causes severe performance degradations if (isBacktracking === true && range === undefined) { return undefined } ASSERT_EXISTS(range) break } // throwing exceptions from "ASSERT_EXISTS" during backtracking // causes severe performance degradations if (isBacktracking === true && range === undefined) { return undefined } ASSERT_EXISTS(range) if (this.peekChar(0) === "?") { this.consumeChar("?") range.greedy = false } else { range.greedy = true } range.type = "Quantifier" return range } RegExpParser.prototype.atom = function() { var atom switch (this.peekChar()) { case ".": atom = this.dotAll() break case "\\": atom = this.atomEscape() break case "[": atom = this.characterClass() break case "(": atom = this.group() break } if (atom === undefined && this.isPatternCharacter()) { atom = this.patternCharacter() } ASSERT_EXISTS(atom) if (this.isQuantifier()) { atom.quantifier = this.quantifier() } return atom } RegExpParser.prototype.dotAll = function() { this.consumeChar(".") return { type: "Set", complement: true, value: [cc("\n"), cc("\r"), cc("\u2028"), cc("\u2029")] } } RegExpParser.prototype.atomEscape = function() { this.consumeChar("\\") switch (this.peekChar()) { case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": return this.decimalEscapeAtom() case "d": case "D": case "s": case "S": case "w": case "W": return this.characterClassEscape() case "f": case "n": case "r": case "t": case "v": return this.controlEscapeAtom() case "c": return this.controlLetterEscapeAtom() case "0": return this.nulCharacterAtom() case "x": return this.hexEscapeSequenceAtom() case "u": return this.regExpUnicodeEscapeSequenceAtom() default: return this.identityEscapeAtom() } } RegExpParser.prototype.decimalEscapeAtom = function() { var value = this.positiveInteger() return { type: "GroupBackReference", value: value } } RegExpParser.prototype.characterClassEscape = function() { var set var complement = false switch (this.popChar()) { case "d": set = digitsCharCodes break case "D": set = digitsCharCodes complement = true break case "s": set = whitespaceCodes break case "S": set = whitespaceCodes complement = true break case "w": set = wordCharCodes break case "W": set = wordCharCodes complement = true break } ASSERT_EXISTS(set) return { type: "Set", value: set, complement: complement } } RegExpParser.prototype.controlEscapeAtom = function() { var escapeCode switch (this.popChar()) { case "f": escapeCode = cc("\f") break case "n": escapeCode = cc("\n") break case "r": escapeCode = cc("\r") break case "t": escapeCode = cc("\t") break case "v": escapeCode = cc("\v") break } ASSERT_EXISTS(escapeCode) return { type: "Character", value: escapeCode } } RegExpParser.prototype.controlLetterEscapeAtom = function() { this.consumeChar("c") var letter = this.popChar() if (/[a-zA-Z]/.test(letter) === false) { throw Error("Invalid ") } var letterCode = letter.toUpperCase().charCodeAt(0) - 64 return { type: "Character", value: letterCode } } RegExpParser.prototype.nulCharacterAtom = function() { // TODO implement '[lookahead ∉ DecimalDigit]' // TODO: for the deprecated octal escape sequence this.consumeChar("0") return { type: "Character", value: cc("\0") } } RegExpParser.prototype.hexEscapeSequenceAtom = function() { this.consumeChar("x") return this.parseHexDigits(2) } RegExpParser.prototype.regExpUnicodeEscapeSequenceAtom = function() { this.consumeChar("u") return this.parseHexDigits(4) } RegExpParser.prototype.identityEscapeAtom = function() { // TODO: implement "SourceCharacter but not UnicodeIDContinue" // // http://unicode.org/reports/tr31/#Specific_Character_Adjustments var escapedChar = this.popChar() return { type: "Character", value: cc(escapedChar) } } RegExpParser.prototype.classPatternCharacterAtom = function() { switch (this.peekChar()) { // istanbul ignore next case "\n": // istanbul ignore next case "\r": // istanbul ignore next case "\u2028": // istanbul ignore next case "\u2029": // istanbul ignore next case "\\": // istanbul ignore next case "]": throw Error("TBD") default: var nextChar = this.popChar() return { type: "Character", value: cc(nextChar) } } } RegExpParser.prototype.characterClass = function() { var set = [] var complement = false this.consumeChar("[") if (this.peekChar(0) === "^") { this.consumeChar("^") complement = true } while (this.isClassAtom()) { var from = this.classAtom() var isFromSingleChar = from.type === "Character" if (isFromSingleChar && this.isRangeDash()) { this.consumeChar("-") var to = this.classAtom() var isToSingleChar = to.type === "Character" // a range can only be used when both sides are single characters if (isToSingleChar) { if (to.value < from.value) { throw Error("Range out of order in character class") } set.push({ from: from.value, to: to.value }) } else { // literal dash insertToSet(from.value, set) set.push(cc("-")) insertToSet(to.value, set) } } else { insertToSet(from.value, set) } } this.consumeChar("]") return { type: "Set", complement: complement, value: set } } RegExpParser.prototype.classAtom = function() { switch (this.peekChar()) { // istanbul ignore next case "]": // istanbul ignore next case "\n": // istanbul ignore next case "\r": // istanbul ignore next case "\u2028": // istanbul ignore next case "\u2029": throw Error("TBD") case "\\": return this.classEscape() default: return this.classPatternCharacterAtom() } } RegExpParser.prototype.classEscape = function() { this.consumeChar("\\") switch (this.peekChar()) { // Matches a backspace. // (Not to be confused with \b word boundary outside characterClass) case "b": this.consumeChar("b") return { type: "Character", value: cc("\u0008") } case "d": case "D": case "s": case "S": case "w": case "W": return this.characterClassEscape() case "f": case "n": case "r": case "t": case "v": return this.controlEscapeAtom() case "c": return this.controlLetterEscapeAtom() case "0": return this.nulCharacterAtom() case "x": return this.hexEscapeSequenceAtom() case "u": return this.regExpUnicodeEscapeSequenceAtom() default: return this.identityEscapeAtom() } } RegExpParser.prototype.group = function() { var capturing = true this.consumeChar("(") switch (this.peekChar(0)) { case "?": this.consumeChar("?") this.consumeChar(":") capturing = false break default: this.groupIdx++ break } var value = this.disjunction() this.consumeChar(")") var groupAst = { type: "Group", capturing: capturing, value: value } if (capturing) { groupAst.idx = this.groupIdx } return groupAst } RegExpParser.prototype.positiveInteger = function() { var number = this.popChar() // istanbul ignore next - can't ever get here due to previous lookahead checks // still implementing this error checking in case this ever changes. if (decimalPatternNoZero.test(number) === false) { throw Error("Expecting a positive integer") } while (decimalPattern.test(this.peekChar(0))) { number += this.popChar() } return parseInt(number, 10) } RegExpParser.prototype.integerIncludingZero = function() { var number = this.popChar() if (decimalPattern.test(number) === false) { throw Error("Expecting an integer") } while (decimalPattern.test(this.peekChar(0))) { number += this.popChar() } return parseInt(number, 10) } RegExpParser.prototype.patternCharacter = function() { var nextChar = this.popChar() switch (nextChar) { // istanbul ignore next case "\n": // istanbul ignore next case "\r": // istanbul ignore next case "\u2028": // istanbul ignore next case "\u2029": // istanbul ignore next case "^": // istanbul ignore next case "$": // istanbul ignore next case "\\": // istanbul ignore next case ".": // istanbul ignore next case "*": // istanbul ignore next case "+": // istanbul ignore next case "?": // istanbul ignore next case "(": // istanbul ignore next case ")": // istanbul ignore next case "[": // istanbul ignore next case "|": // istanbul ignore next throw Error("TBD") default: return { type: "Character", value: cc(nextChar) } } } RegExpParser.prototype.isRegExpFlag = function() { switch (this.peekChar(0)) { case "g": case "i": case "m": case "u": case "y": return true default: return false } } RegExpParser.prototype.isRangeDash = function() { return this.peekChar() === "-" && this.isClassAtom(1) } RegExpParser.prototype.isDigit = function() { return decimalPattern.test(this.peekChar(0)) } RegExpParser.prototype.isClassAtom = function(howMuch) { if (howMuch === undefined) { howMuch = 0 } switch (this.peekChar(howMuch)) { case "]": case "\n": case "\r": case "\u2028": case "\u2029": return false default: return true } } RegExpParser.prototype.isTerm = function() { return this.isAtom() || this.isAssertion() } RegExpParser.prototype.isAtom = function() { if (this.isPatternCharacter()) { return true } switch (this.peekChar(0)) { case ".": case "\\": // atomEscape case "[": // characterClass // TODO: isAtom must be called before isAssertion - disambiguate case "(": // group return true default: return false } } RegExpParser.prototype.isAssertion = function() { switch (this.peekChar(0)) { case "^": case "$": return true // '\b' or '\B' case "\\": switch (this.peekChar(1)) { case "b": case "B": return true default: return false } // '(?=' or '(?!' case "(": return ( this.peekChar(1) === "?" && (this.peekChar(2) === "=" || this.peekChar(2) === "!") ) default: return false } } RegExpParser.prototype.isQuantifier = function() { var prevState = this.saveState() try { return this.quantifier(true) !== undefined } catch (e) { return false } finally { this.restoreState(prevState) } } RegExpParser.prototype.isPatternCharacter = function() { switch (this.peekChar()) { case "^": case "$": case "\\": case ".": case "*": case "+": case "?": case "(": case ")": case "[": case "|": case "/": case "\n": case "\r": case "\u2028": case "\u2029": return false default: return true } } RegExpParser.prototype.parseHexDigits = function(howMany) { var hexString = "" for (var i = 0; i < howMany; i++) { var hexChar = this.popChar() if (hexDigitPattern.test(hexChar) === false) { throw Error("Expecting a HexDecimal digits") } hexString += hexChar } var charCode = parseInt(hexString, 16) return { type: "Character", value: charCode } } RegExpParser.prototype.peekChar = function(howMuch) { if (howMuch === undefined) { howMuch = 0 } return this.input[this.idx + howMuch] } RegExpParser.prototype.popChar = function() { var nextChar = this.peekChar(0) this.consumeChar() return nextChar } RegExpParser.prototype.consumeChar = function(char) { if (char !== undefined && this.input[this.idx] !== char) { throw Error( "Expected: '" + char + "' but found: '" + this.input[this.idx] + "' at offset: " + this.idx ) } if (this.idx >= this.input.length) { throw Error("Unexpected end of input") } this.idx++ } // consts and utilities var hexDigitPattern = /[0-9a-fA-F]/ var decimalPattern = /[0-9]/ var decimalPatternNoZero = /[1-9]/ function cc(char) { return char.charCodeAt(0) } function insertToSet(item, set) { if (item.length !== undefined) { item.forEach(function(subItem) { set.push(subItem) }) } else { set.push(item) } } function addFlag(flagObj, flagKey) { if (flagObj[flagKey] === true) { throw "duplicate flag " + flagKey } flagObj[flagKey] = true } function ASSERT_EXISTS(obj) { // istanbul ignore next if (obj === undefined) { throw Error("Internal Error - Should never get here!") } } // istanbul ignore next function ASSERT_NEVER_REACH_HERE() { throw Error("Internal Error - Should never get here!") } var i var digitsCharCodes = [] for (i = cc("0"); i <= cc("9"); i++) { digitsCharCodes.push(i) } var wordCharCodes = [cc("_")].concat(digitsCharCodes) for (i = cc("a"); i <= cc("z"); i++) { wordCharCodes.push(i) } for (i = cc("A"); i <= cc("Z"); i++) { wordCharCodes.push(i) } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#character-classes var whitespaceCodes = [ cc(" "), cc("\f"), cc("\n"), cc("\r"), cc("\t"), cc("\v"), cc("\t"), cc("\u00a0"), cc("\u1680"), cc("\u2000"), cc("\u2001"), cc("\u2002"), cc("\u2003"), cc("\u2004"), cc("\u2005"), cc("\u2006"), cc("\u2007"), cc("\u2008"), cc("\u2009"), cc("\u200a"), cc("\u2028"), cc("\u2029"), cc("\u202f"), cc("\u205f"), cc("\u3000"), cc("\ufeff") ] function BaseRegExpVisitor() {} BaseRegExpVisitor.prototype.visitChildren = function(node) { for (var key in node) { var child = node[key] /* istanbul ignore else */ if (node.hasOwnProperty(key)) { if (child.type !== undefined) { this.visit(child) } else if (Array.isArray(child)) { child.forEach(function(subChild) { this.visit(subChild) }, this) } } } } BaseRegExpVisitor.prototype.visit = function(node) { switch (node.type) { case "Pattern": this.visitPattern(node) break case "Flags": this.visitFlags(node) break case "Disjunction": this.visitDisjunction(node) break case "Alternative": this.visitAlternative(node) break case "StartAnchor": this.visitStartAnchor(node) break case "EndAnchor": this.visitEndAnchor(node) break case "WordBoundary": this.visitWordBoundary(node) break case "NonWordBoundary": this.visitNonWordBoundary(node) break case "Lookahead": this.visitLookahead(node) break case "NegativeLookahead": this.visitNegativeLookahead(node) break case "Character": this.visitCharacter(node) break case "Set": this.visitSet(node) break case "Group": this.visitGroup(node) break case "GroupBackReference": this.visitGroupBackReference(node) break case "Quantifier": this.visitQuantifier(node) break } this.visitChildren(node) } BaseRegExpVisitor.prototype.visitPattern = function(node) {} BaseRegExpVisitor.prototype.visitFlags = function(node) {} BaseRegExpVisitor.prototype.visitDisjunction = function(node) {} BaseRegExpVisitor.prototype.visitAlternative = function(node) {} // Assertion BaseRegExpVisitor.prototype.visitStartAnchor = function(node) {} BaseRegExpVisitor.prototype.visitEndAnchor = function(node) {} BaseRegExpVisitor.prototype.visitWordBoundary = function(node) {} BaseRegExpVisitor.prototype.visitNonWordBoundary = function(node) {} BaseRegExpVisitor.prototype.visitLookahead = function(node) {} BaseRegExpVisitor.prototype.visitNegativeLookahead = function(node) {} // atoms BaseRegExpVisitor.prototype.visitCharacter = function(node) {} BaseRegExpVisitor.prototype.visitSet = function(node) {} BaseRegExpVisitor.prototype.visitGroup = function(node) {} BaseRegExpVisitor.prototype.visitGroupBackReference = function(node) {} BaseRegExpVisitor.prototype.visitQuantifier = function(node) {} return { RegExpParser: RegExpParser, BaseRegExpVisitor: BaseRegExpVisitor, VERSION: "0.4.0" } } ) /***/ }), /* 16 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var regexp_to_ast_1 = __webpack_require__(15); var regExpAstCache = {}; var regExpParser = new regexp_to_ast_1.RegExpParser(); function getRegExpAst(regExp) { var regExpStr = regExp.toString(); if (regExpAstCache.hasOwnProperty(regExpStr)) { return regExpAstCache[regExpStr]; } else { var regExpAst = regExpParser.pattern(regExpStr); regExpAstCache[regExpStr] = regExpAst; return regExpAst; } } exports.getRegExpAst = getRegExpAst; function clearRegExpParserCache() { regExpAstCache = {}; } exports.clearRegExpParserCache = clearRegExpParserCache; //# sourceMappingURL=reg_exp_parser.js.map /***/ }), /* 17 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var keys_1 = __webpack_require__(7); var gast_public_1 = __webpack_require__(1); var gast_visitor_public_1 = __webpack_require__(4); /** * This nodeLocation tracking is not efficient and should only be used * when error recovery is enabled or the Token Vector contains virtual Tokens * (e.g, Python Indent/Outdent) * As it executes the calculation for every single terminal/nonTerminal * and does not rely on the fact the token vector is **sorted** */ function setNodeLocationOnlyOffset(currNodeLocation, newLocationInfo) { // First (valid) update for this cst node if (isNaN(currNodeLocation.startOffset) === true) { // assumption1: Token location information is either NaN or a valid number // assumption2: Token location information is fully valid if it exist // (both start/end offsets exist and are numbers). currNodeLocation.startOffset = newLocationInfo.startOffset; currNodeLocation.endOffset = newLocationInfo.endOffset; } // Once the startOffset has been updated with a valid number it should never receive // any farther updates as the Token vector is sorted. // We still have to check this this condition for every new possible location info // because with error recovery enabled we may encounter invalid tokens (NaN location props) else if (currNodeLocation.endOffset < newLocationInfo.endOffset === true) { currNodeLocation.endOffset = newLocationInfo.endOffset; } } exports.setNodeLocationOnlyOffset = setNodeLocationOnlyOffset; /** * This nodeLocation tracking is not efficient and should only be used * when error recovery is enabled or the Token Vector contains virtual Tokens * (e.g, Python Indent/Outdent) * As it executes the calculation for every single terminal/nonTerminal * and does not rely on the fact the token vector is **sorted** */ function setNodeLocationFull(currNodeLocation, newLocationInfo) { // First (valid) update for this cst node if (isNaN(currNodeLocation.startOffset) === true) { // assumption1: Token location information is either NaN or a valid number // assumption2: Token location information is fully valid if it exist // (all start/end props exist and are numbers). currNodeLocation.startOffset = newLocationInfo.startOffset; currNodeLocation.startColumn = newLocationInfo.startColumn; currNodeLocation.startLine = newLocationInfo.startLine; currNodeLocation.endOffset = newLocationInfo.endOffset; currNodeLocation.endColumn = newLocationInfo.endColumn; currNodeLocation.endLine = newLocationInfo.endLine; } // Once the start props has been updated with a valid number it should never receive // any farther updates as the Token vector is sorted. // We still have to check this this condition for every new possible location info // because with error recovery enabled we may encounter invalid tokens (NaN location props) else if (currNodeLocation.endOffset < newLocationInfo.endOffset === true) { currNodeLocation.endOffset = newLocationInfo.endOffset; currNodeLocation.endColumn = newLocationInfo.endColumn; currNodeLocation.endLine = newLocationInfo.endLine; } } exports.setNodeLocationFull = setNodeLocationFull; function addTerminalToCst(node, token, tokenTypeName) { if (node.children[tokenTypeName] === undefined) { node.children[tokenTypeName] = [token]; } else { node.children[tokenTypeName].push(token); } } exports.addTerminalToCst = addTerminalToCst; function addNoneTerminalToCst(node, ruleName, ruleResult) { if (node.children[ruleName] === undefined) { node.children[ruleName] = [ruleResult]; } else { node.children[ruleName].push(ruleResult); } } exports.addNoneTerminalToCst = addNoneTerminalToCst; var NamedDSLMethodsCollectorVisitor = /** @class */ (function (_super) { __extends(NamedDSLMethodsCollectorVisitor, _super); function NamedDSLMethodsCollectorVisitor(ruleIdx) { var _this = _super.call(this) || this; _this.result = []; _this.ruleIdx = ruleIdx; return _this; } NamedDSLMethodsCollectorVisitor.prototype.collectNamedDSLMethod = function (node, newNodeConstructor, methodIdx) { // TODO: better hack to copy what we need here... if (!utils_1.isUndefined(node.name)) { // copy without name so this will indeed be processed later. var nameLessNode /* istanbul ignore else */ = void 0; /* istanbul ignore else */ if (node instanceof gast_public_1.Option || node instanceof gast_public_1.Repetition || node instanceof gast_public_1.RepetitionMandatory || node instanceof gast_public_1.Alternation) { nameLessNode = new newNodeConstructor({ definition: node.definition, idx: node.idx }); } else if (node instanceof gast_public_1.RepetitionMandatoryWithSeparator || node instanceof gast_public_1.RepetitionWithSeparator) { nameLessNode = new newNodeConstructor({ definition: node.definition, idx: node.idx, separator: node.separator }); } else { throw Error("non exhaustive match"); } var def = [nameLessNode]; var key = keys_1.getKeyForAutomaticLookahead(this.ruleIdx, methodIdx, node.idx); this.result.push({ def: def, key: key, name: node.name, orgProd: node }); } }; NamedDSLMethodsCollectorVisitor.prototype.visitOption = function (node) { this.collectNamedDSLMethod(node, gast_public_1.Option, keys_1.OPTION_IDX); }; NamedDSLMethodsCollectorVisitor.prototype.visitRepetition = function (node) { this.collectNamedDSLMethod(node, gast_public_1.Repetition, keys_1.MANY_IDX); }; NamedDSLMethodsCollectorVisitor.prototype.visitRepetitionMandatory = function (node) { this.collectNamedDSLMethod(node, gast_public_1.RepetitionMandatory, keys_1.AT_LEAST_ONE_IDX); }; NamedDSLMethodsCollectorVisitor.prototype.visitRepetitionMandatoryWithSeparator = function (node) { this.collectNamedDSLMethod(node, gast_public_1.RepetitionMandatoryWithSeparator, keys_1.AT_LEAST_ONE_SEP_IDX); }; NamedDSLMethodsCollectorVisitor.prototype.visitRepetitionWithSeparator = function (node) { this.collectNamedDSLMethod(node, gast_public_1.RepetitionWithSeparator, keys_1.MANY_SEP_IDX); }; NamedDSLMethodsCollectorVisitor.prototype.visitAlternation = function (node) { var _this = this; this.collectNamedDSLMethod(node, gast_public_1.Alternation, keys_1.OR_IDX); var hasMoreThanOneAlternative = node.definition.length > 1; utils_1.forEach(node.definition, function (currFlatAlt, altIdx) { if (!utils_1.isUndefined(currFlatAlt.name)) { var def = currFlatAlt.definition; if (hasMoreThanOneAlternative) { def = [new gast_public_1.Option({ definition: currFlatAlt.definition })]; } else { // mandatory def = currFlatAlt.definition; } var key = keys_1.getKeyForAltIndex(_this.ruleIdx, keys_1.OR_IDX, node.idx, altIdx); _this.result.push({ def: def, key: key, name: currFlatAlt.name, orgProd: currFlatAlt }); } }); }; return NamedDSLMethodsCollectorVisitor; }(gast_visitor_public_1.GAstVisitor)); exports.NamedDSLMethodsCollectorVisitor = NamedDSLMethodsCollectorVisitor; function expandAllNestedRuleNames(topRules, fullToShortName) { var result = { allRuleNames: [] }; utils_1.forEach(topRules, function (currTopRule) { var currTopRuleShortName = fullToShortName[currTopRule.name]; result.allRuleNames.push(currTopRule.name); var namedCollectorVisitor = new NamedDSLMethodsCollectorVisitor(currTopRuleShortName); currTopRule.accept(namedCollectorVisitor); utils_1.forEach(namedCollectorVisitor.result, function (_a) { var def = _a.def, key = _a.key, name = _a.name; result.allRuleNames.push(currTopRule.name + name); }); }); return result; } exports.expandAllNestedRuleNames = expandAllNestedRuleNames; //# sourceMappingURL=cst.js.map /***/ }), /* 18 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // semantic version var version_1 = __webpack_require__(19); exports.VERSION = version_1.VERSION; var parser_1 = __webpack_require__(2); exports.Parser = parser_1.Parser; exports.CstParser = parser_1.CstParser; exports.EmbeddedActionsParser = parser_1.EmbeddedActionsParser; exports.ParserDefinitionErrorType = parser_1.ParserDefinitionErrorType; exports.EMPTY_ALT = parser_1.EMPTY_ALT; var lexer_public_1 = __webpack_require__(9); exports.Lexer = lexer_public_1.Lexer; exports.LexerDefinitionErrorType = lexer_public_1.LexerDefinitionErrorType; // Tokens utilities var tokens_public_1 = __webpack_require__(3); exports.createToken = tokens_public_1.createToken; exports.createTokenInstance = tokens_public_1.createTokenInstance; exports.EOF = tokens_public_1.EOF; exports.tokenLabel = tokens_public_1.tokenLabel; exports.tokenMatcher = tokens_public_1.tokenMatcher; exports.tokenName = tokens_public_1.tokenName; // Other Utilities var errors_public_1 = __webpack_require__(10); exports.defaultGrammarResolverErrorProvider = errors_public_1.defaultGrammarResolverErrorProvider; exports.defaultGrammarValidatorErrorProvider = errors_public_1.defaultGrammarValidatorErrorProvider; exports.defaultParserErrorProvider = errors_public_1.defaultParserErrorProvider; var exceptions_public_1 = __webpack_require__(8); exports.EarlyExitException = exceptions_public_1.EarlyExitException; exports.isRecognitionException = exceptions_public_1.isRecognitionException; exports.MismatchedTokenException = exceptions_public_1.MismatchedTokenException; exports.NotAllInputParsedException = exceptions_public_1.NotAllInputParsedException; exports.NoViableAltException = exceptions_public_1.NoViableAltException; var lexer_errors_public_1 = __webpack_require__(21); exports.defaultLexerErrorProvider = lexer_errors_public_1.defaultLexerErrorProvider; // grammar reflection API var gast_public_1 = __webpack_require__(1); exports.Alternation = gast_public_1.Alternation; exports.Flat = gast_public_1.Flat; exports.NonTerminal = gast_public_1.NonTerminal; exports.Option = gast_public_1.Option; exports.Repetition = gast_public_1.Repetition; exports.RepetitionMandatory = gast_public_1.RepetitionMandatory; exports.RepetitionMandatoryWithSeparator = gast_public_1.RepetitionMandatoryWithSeparator; exports.RepetitionWithSeparator = gast_public_1.RepetitionWithSeparator; exports.Rule = gast_public_1.Rule; exports.Terminal = gast_public_1.Terminal; // GAST Utilities var gast_public_2 = __webpack_require__(1); exports.serializeGrammar = gast_public_2.serializeGrammar; exports.serializeProduction = gast_public_2.serializeProduction; var gast_visitor_public_1 = __webpack_require__(4); exports.GAstVisitor = gast_visitor_public_1.GAstVisitor; var gast_resolver_public_1 = __webpack_require__(24); exports.assignOccurrenceIndices = gast_resolver_public_1.assignOccurrenceIndices; exports.resolveGrammar = gast_resolver_public_1.resolveGrammar; exports.validateGrammar = gast_resolver_public_1.validateGrammar; /* istanbul ignore next */ function clearCache() { console.warn("The clearCache function was 'soft' removed from the Chevrotain API." + "\n\t It performs no action other than printing this message." + "\n\t Please avoid using it as it will be completely removed in the future"); } exports.clearCache = clearCache; var render_public_1 = __webpack_require__(40); exports.createSyntaxDiagramsCode = render_public_1.createSyntaxDiagramsCode; var generate_public_1 = __webpack_require__(41); exports.generateParserFactory = generate_public_1.generateParserFactory; exports.generateParserModule = generate_public_1.generateParserModule; //# sourceMappingURL=api.js.map /***/ }), /* 19 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // needs a separate module as this is required inside chevrotain productive code // and also in the entry point for webpack(api.ts). // A separate file avoids cyclic dependencies and webpack errors. exports.VERSION = "6.5.0"; //# sourceMappingURL=version.js.map /***/ }), /* 20 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var regexp_to_ast_1 = __webpack_require__(15); var lexer_public_1 = __webpack_require__(9); var utils_1 = __webpack_require__(0); var reg_exp_1 = __webpack_require__(28); var reg_exp_parser_1 = __webpack_require__(16); var PATTERN = "PATTERN"; exports.DEFAULT_MODE = "defaultMode"; exports.MODES = "modes"; exports.SUPPORT_STICKY = typeof new RegExp("(?:)").sticky === "boolean"; function disableSticky() { exports.SUPPORT_STICKY = false; } exports.disableSticky = disableSticky; function enableSticky() { exports.SUPPORT_STICKY = true; } exports.enableSticky = enableSticky; function analyzeTokenTypes(tokenTypes, options) { options = utils_1.defaults(options, { useSticky: exports.SUPPORT_STICKY, debug: false, safeMode: false, positionTracking: "full", lineTerminatorCharacters: ["\r", "\n"], tracer: function (msg, action) { return action(); } }); var tracer = options.tracer; tracer("initCharCodeToOptimizedIndexMap", function () { initCharCodeToOptimizedIndexMap(); }); var onlyRelevantTypes; tracer("Reject Lexer.NA", function () { onlyRelevantTypes = utils_1.reject(tokenTypes, function (currType) { return currType[PATTERN] === lexer_public_1.Lexer.NA; }); }); var hasCustom = false; var allTransformedPatterns; tracer("Transform Patterns", function () { hasCustom = false; allTransformedPatterns = utils_1.map(onlyRelevantTypes, function (currType) { var currPattern = currType[PATTERN]; /* istanbul ignore else */ if (utils_1.isRegExp(currPattern)) { var regExpSource = currPattern.source; if (regExpSource.length === 1 && // only these regExp meta characters which can appear in a length one regExp regExpSource !== "^" && regExpSource !== "$" && regExpSource !== ".") { return regExpSource; } else if (regExpSource.length === 2 && regExpSource[0] === "\\" && // not a meta character !utils_1.contains([ "d", "D", "s", "S", "t", "r", "n", "t", "0", "c", "b", "B", "f", "v", "w", "W" ], regExpSource[1])) { // escaped meta Characters: /\+/ /\[/ // or redundant escaping: /\a/ // without the escaping "\" return regExpSource[1]; } else { return options.useSticky ? addStickyFlag(currPattern) : addStartOfInput(currPattern); } } else if (utils_1.isFunction(currPattern)) { hasCustom = true; // CustomPatternMatcherFunc - custom patterns do not require any transformations, only wrapping in a RegExp Like object return { exec: currPattern }; } else if (utils_1.has(currPattern, "exec")) { hasCustom = true; // ICustomPattern return currPattern; } else if (typeof currPattern === "string") { if (currPattern.length === 1) { return currPattern; } else { var escapedRegExpString = currPattern.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&"); var wrappedRegExp = new RegExp(escapedRegExpString); return options.useSticky ? addStickyFlag(wrappedRegExp) : addStartOfInput(wrappedRegExp); } } else { throw Error("non exhaustive match"); } }); }); var patternIdxToType; var patternIdxToGroup; var patternIdxToLongerAltIdx; var patternIdxToPushMode; var patternIdxToPopMode; tracer("misc mapping", function () { patternIdxToType = utils_1.map(onlyRelevantTypes, function (currType) { return currType.tokenTypeIdx; }); patternIdxToGroup = utils_1.map(onlyRelevantTypes, function (clazz) { var groupName = clazz.GROUP; /* istanbul ignore next */ if (groupName === lexer_public_1.Lexer.SKIPPED) { return undefined; } else if (utils_1.isString(groupName)) { return groupName; } else if (utils_1.isUndefined(groupName)) { return false; } else { throw Error("non exhaustive match"); } }); patternIdxToLongerAltIdx = utils_1.map(onlyRelevantTypes, function (clazz) { var longerAltType = clazz.LONGER_ALT; if (longerAltType) { var longerAltIdx = utils_1.indexOf(onlyRelevantTypes, longerAltType); return longerAltIdx; } }); patternIdxToPushMode = utils_1.map(onlyRelevantTypes, function (clazz) { return clazz.PUSH_MODE; }); patternIdxToPopMode = utils_1.map(onlyRelevantTypes, function (clazz) { return utils_1.has(clazz, "POP_MODE"); }); }); var patternIdxToCanLineTerminator; tracer("Line Terminator Handling", function () { var lineTerminatorCharCodes = getCharCodes(options.lineTerminatorCharacters); patternIdxToCanLineTerminator = utils_1.map(onlyRelevantTypes, function (tokType) { return false; }); if (options.positionTracking !== "onlyOffset") { patternIdxToCanLineTerminator = utils_1.map(onlyRelevantTypes, function (tokType) { if (utils_1.has(tokType, "LINE_BREAKS")) { return tokType.LINE_BREAKS; } else { if (checkLineBreaksIssues(tokType, lineTerminatorCharCodes) === false) { return reg_exp_1.canMatchCharCode(lineTerminatorCharCodes, tokType.PATTERN); } } }); } }); var patternIdxToIsCustom; var patternIdxToShort; var emptyGroups; var patternIdxToConfig; tracer("Misc Mapping #2", function () { patternIdxToIsCustom = utils_1.map(onlyRelevantTypes, isCustomPattern); patternIdxToShort = utils_1.map(allTransformedPatterns, isShortPattern); emptyGroups = utils_1.reduce(onlyRelevantTypes, function (acc, clazz) { var groupName = clazz.GROUP; if (utils_1.isString(groupName) && !(groupName === lexer_public_1.Lexer.SKIPPED)) { acc[groupName] = []; } return acc; }, {}); patternIdxToConfig = utils_1.map(allTransformedPatterns, function (x, idx) { return { pattern: allTransformedPatterns[idx], longerAlt: patternIdxToLongerAltIdx[idx], canLineTerminator: patternIdxToCanLineTerminator[idx], isCustom: patternIdxToIsCustom[idx], short: patternIdxToShort[idx], group: patternIdxToGroup[idx], push: patternIdxToPushMode[idx], pop: patternIdxToPopMode[idx], tokenTypeIdx: patternIdxToType[idx], tokenType: onlyRelevantTypes[idx] }; }); }); var canBeOptimized = true; var charCodeToPatternIdxToConfig = []; if (!options.safeMode) { tracer("First Char Optimization", function () { charCodeToPatternIdxToConfig = utils_1.reduce(onlyRelevantTypes, function (result, currTokType, idx) { if (typeof currTokType.PATTERN === "string") { var charCode = currTokType.PATTERN.charCodeAt(0); var optimizedIdx = charCodeToOptimizedIndex(charCode); addToMapOfArrays(result, optimizedIdx, patternIdxToConfig[idx]); } else if (utils_1.isArray(currTokType.START_CHARS_HINT)) { var lastOptimizedIdx_1; utils_1.forEach(currTokType.START_CHARS_HINT, function (charOrInt) { var charCode = typeof charOrInt === "string" ? charOrInt.charCodeAt(0) : charOrInt; var currOptimizedIdx = charCodeToOptimizedIndex(charCode); // Avoid adding the config multiple times if (lastOptimizedIdx_1 !== currOptimizedIdx) { lastOptimizedIdx_1 = currOptimizedIdx; addToMapOfArrays(result, currOptimizedIdx, patternIdxToConfig[idx]); } }); } else if (utils_1.isRegExp(currTokType.PATTERN)) { if (currTokType.PATTERN.unicode) { canBeOptimized = false; if (options.ensureOptimizations) { utils_1.PRINT_ERROR("" + reg_exp_1.failedOptimizationPrefixMsg + ("\tUnable to analyze < " + currTokType.PATTERN.toString() + " > pattern.\n") + "\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n" + "\tThis will disable the lexer's first char optimizations.\n" + "\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE"); } } else { var optimizedCodes = reg_exp_1.getOptimizedStartCodesIndices(currTokType.PATTERN, options.ensureOptimizations); /* istanbul ignore if */ // start code will only be empty given an empty regExp or failure of regexp-to-ast library // the first should be a different validation and the second cannot be tested. if (utils_1.isEmpty(optimizedCodes)) { // we cannot understand what codes may start possible matches // The optimization correctness requires knowing start codes for ALL patterns. // Not actually sure this is an error, no debug message canBeOptimized = false; } utils_1.forEach(optimizedCodes, function (code) { addToMapOfArrays(result, code, patternIdxToConfig[idx]); }); } } else { if (options.ensureOptimizations) { utils_1.PRINT_ERROR("" + reg_exp_1.failedOptimizationPrefixMsg + ("\tTokenType: <" + currTokType.name + "> is using a custom token pattern without providing parameter.\n") + "\tThis will disable the lexer's first char optimizations.\n" + "\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE"); } canBeOptimized = false; } return result; }, []); }); } tracer("ArrayPacking", function () { charCodeToPatternIdxToConfig = utils_1.packArray(charCodeToPatternIdxToConfig); }); return { emptyGroups: emptyGroups, patternIdxToConfig: patternIdxToConfig, charCodeToPatternIdxToConfig: charCodeToPatternIdxToConfig, hasCustom: hasCustom, canBeOptimized: canBeOptimized }; } exports.analyzeTokenTypes = analyzeTokenTypes; function validatePatterns(tokenTypes, validModesNames) { var errors = []; var missingResult = findMissingPatterns(tokenTypes); errors = errors.concat(missingResult.errors); var invalidResult = findInvalidPatterns(missingResult.valid); var validTokenTypes = invalidResult.valid; errors = errors.concat(invalidResult.errors); errors = errors.concat(validateRegExpPattern(validTokenTypes)); errors = errors.concat(findInvalidGroupType(validTokenTypes)); errors = errors.concat(findModesThatDoNotExist(validTokenTypes, validModesNames)); errors = errors.concat(findUnreachablePatterns(validTokenTypes)); return errors; } exports.validatePatterns = validatePatterns; function validateRegExpPattern(tokenTypes) { var errors = []; var withRegExpPatterns = utils_1.filter(tokenTypes, function (currTokType) { return utils_1.isRegExp(currTokType[PATTERN]); }); errors = errors.concat(findEndOfInputAnchor(withRegExpPatterns)); errors = errors.concat(findStartOfInputAnchor(withRegExpPatterns)); errors = errors.concat(findUnsupportedFlags(withRegExpPatterns)); errors = errors.concat(findDuplicatePatterns(withRegExpPatterns)); errors = errors.concat(findEmptyMatchRegExps(withRegExpPatterns)); return errors; } function findMissingPatterns(tokenTypes) { var tokenTypesWithMissingPattern = utils_1.filter(tokenTypes, function (currType) { return !utils_1.has(currType, PATTERN); }); var errors = utils_1.map(tokenTypesWithMissingPattern, function (currType) { return { message: "Token Type: ->" + currType.name + "<- missing static 'PATTERN' property", type: lexer_public_1.LexerDefinitionErrorType.MISSING_PATTERN, tokenTypes: [currType] }; }); var valid = utils_1.difference(tokenTypes, tokenTypesWithMissingPattern); return { errors: errors, valid: valid }; } exports.findMissingPatterns = findMissingPatterns; function findInvalidPatterns(tokenTypes) { var tokenTypesWithInvalidPattern = utils_1.filter(tokenTypes, function (currType) { var pattern = currType[PATTERN]; return (!utils_1.isRegExp(pattern) && !utils_1.isFunction(pattern) && !utils_1.has(pattern, "exec") && !utils_1.isString(pattern)); }); var errors = utils_1.map(tokenTypesWithInvalidPattern, function (currType) { return { message: "Token Type: ->" + currType.name + "<- static 'PATTERN' can only be a RegExp, a" + " Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.", type: lexer_public_1.LexerDefinitionErrorType.INVALID_PATTERN, tokenTypes: [currType] }; }); var valid = utils_1.difference(tokenTypes, tokenTypesWithInvalidPattern); return { errors: errors, valid: valid }; } exports.findInvalidPatterns = findInvalidPatterns; var end_of_input = /[^\\][\$]/; function findEndOfInputAnchor(tokenTypes) { var EndAnchorFinder = /** @class */ (function (_super) { __extends(EndAnchorFinder, _super); function EndAnchorFinder() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.found = false; return _this; } EndAnchorFinder.prototype.visitEndAnchor = function (node) { this.found = true; }; return EndAnchorFinder; }(regexp_to_ast_1.BaseRegExpVisitor)); var invalidRegex = utils_1.filter(tokenTypes, function (currType) { var pattern = currType[PATTERN]; try { var regexpAst = reg_exp_parser_1.getRegExpAst(pattern); var endAnchorVisitor = new EndAnchorFinder(); endAnchorVisitor.visit(regexpAst); return endAnchorVisitor.found; } catch (e) { // old behavior in case of runtime exceptions with regexp-to-ast. /* istanbul ignore next - cannot ensure an error in regexp-to-ast*/ return end_of_input.test(pattern.source); } }); var errors = utils_1.map(invalidRegex, function (currType) { return { message: "Unexpected RegExp Anchor Error:\n" + "\tToken Type: ->" + currType.name + "<- static 'PATTERN' cannot contain end of input anchor '$'\n" + "\tSee sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#ANCHORS" + "\tfor details.", type: lexer_public_1.LexerDefinitionErrorType.EOI_ANCHOR_FOUND, tokenTypes: [currType] }; }); return errors; } exports.findEndOfInputAnchor = findEndOfInputAnchor; function findEmptyMatchRegExps(tokenTypes) { var matchesEmptyString = utils_1.filter(tokenTypes, function (currType) { var pattern = currType[PATTERN]; return pattern.test(""); }); var errors = utils_1.map(matchesEmptyString, function (currType) { return { message: "Token Type: ->" + currType.name + "<- static 'PATTERN' must not match an empty string", type: lexer_public_1.LexerDefinitionErrorType.EMPTY_MATCH_PATTERN, tokenTypes: [currType] }; }); return errors; } exports.findEmptyMatchRegExps = findEmptyMatchRegExps; var start_of_input = /[^\\[][\^]|^\^/; function findStartOfInputAnchor(tokenTypes) { var StartAnchorFinder = /** @class */ (function (_super) { __extends(StartAnchorFinder, _super); function StartAnchorFinder() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.found = false; return _this; } StartAnchorFinder.prototype.visitStartAnchor = function (node) { this.found = true; }; return StartAnchorFinder; }(regexp_to_ast_1.BaseRegExpVisitor)); var invalidRegex = utils_1.filter(tokenTypes, function (currType) { var pattern = currType[PATTERN]; try { var regexpAst = reg_exp_parser_1.getRegExpAst(pattern); var startAnchorVisitor = new StartAnchorFinder(); startAnchorVisitor.visit(regexpAst); return startAnchorVisitor.found; } catch (e) { // old behavior in case of runtime exceptions with regexp-to-ast. /* istanbul ignore next - cannot ensure an error in regexp-to-ast*/ return start_of_input.test(pattern.source); } }); var errors = utils_1.map(invalidRegex, function (currType) { return { message: "Unexpected RegExp Anchor Error:\n" + "\tToken Type: ->" + currType.name + "<- static 'PATTERN' cannot contain start of input anchor '^'\n" + "\tSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#ANCHORS" + "\tfor details.", type: lexer_public_1.LexerDefinitionErrorType.SOI_ANCHOR_FOUND, tokenTypes: [currType] }; }); return errors; } exports.findStartOfInputAnchor = findStartOfInputAnchor; function findUnsupportedFlags(tokenTypes) { var invalidFlags = utils_1.filter(tokenTypes, function (currType) { var pattern = currType[PATTERN]; return (pattern instanceof RegExp && (pattern.multiline || pattern.global)); }); var errors = utils_1.map(invalidFlags, function (currType) { return { message: "Token Type: ->" + currType.name + "<- static 'PATTERN' may NOT contain global('g') or multiline('m')", type: lexer_public_1.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND, tokenTypes: [currType] }; }); return errors; } exports.findUnsupportedFlags = findUnsupportedFlags; // This can only test for identical duplicate RegExps, not semantically equivalent ones. function findDuplicatePatterns(tokenTypes) { var found = []; var identicalPatterns = utils_1.map(tokenTypes, function (outerType) { return utils_1.reduce(tokenTypes, function (result, innerType) { if (outerType.PATTERN.source === innerType.PATTERN.source && !utils_1.contains(found, innerType) && innerType.PATTERN !== lexer_public_1.Lexer.NA) { // this avoids duplicates in the result, each Token Type may only appear in one "set" // in essence we are creating Equivalence classes on equality relation. found.push(innerType); result.push(innerType); return result; } return result; }, []); }); identicalPatterns = utils_1.compact(identicalPatterns); var duplicatePatterns = utils_1.filter(identicalPatterns, function (currIdenticalSet) { return currIdenticalSet.length > 1; }); var errors = utils_1.map(duplicatePatterns, function (setOfIdentical) { var tokenTypeNames = utils_1.map(setOfIdentical, function (currType) { return currType.name; }); var dupPatternSrc = utils_1.first(setOfIdentical).PATTERN; return { message: "The same RegExp pattern ->" + dupPatternSrc + "<-" + ("has been used in all of the following Token Types: " + tokenTypeNames.join(", ") + " <-"), type: lexer_public_1.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND, tokenTypes: setOfIdentical }; }); return errors; } exports.findDuplicatePatterns = findDuplicatePatterns; function findInvalidGroupType(tokenTypes) { var invalidTypes = utils_1.filter(tokenTypes, function (clazz) { if (!utils_1.has(clazz, "GROUP")) { return false; } var group = clazz.GROUP; return group !== lexer_public_1.Lexer.SKIPPED && group !== lexer_public_1.Lexer.NA && !utils_1.isString(group); }); var errors = utils_1.map(invalidTypes, function (currType) { return { message: "Token Type: ->" + currType.name + "<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String", type: lexer_public_1.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND, tokenTypes: [currType] }; }); return errors; } exports.findInvalidGroupType = findInvalidGroupType; function findModesThatDoNotExist(tokenTypes, validModes) { var invalidModes = utils_1.filter(tokenTypes, function (clazz) { return (clazz.PUSH_MODE !== undefined && !utils_1.contains(validModes, clazz.PUSH_MODE)); }); var errors = utils_1.map(invalidModes, function (tokType) { var msg = "Token Type: ->" + tokType.name + "<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->" + tokType.PUSH_MODE + "<-" + "which does not exist"; return { message: msg, type: lexer_public_1.LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST, tokenTypes: [tokType] }; }); return errors; } exports.findModesThatDoNotExist = findModesThatDoNotExist; function findUnreachablePatterns(tokenTypes) { var errors = []; var canBeTested = utils_1.reduce(tokenTypes, function (result, tokType, idx) { var pattern = tokType.PATTERN; if (pattern === lexer_public_1.Lexer.NA) { return result; } // a more comprehensive validation for all forms of regExps would require // deeper regExp analysis capabilities if (utils_1.isString(pattern)) { result.push({ str: pattern, idx: idx, tokenType: tokType }); } else if (utils_1.isRegExp(pattern) && noMetaChar(pattern)) { result.push({ str: pattern.source, idx: idx, tokenType: tokType }); } return result; }, []); utils_1.forEach(tokenTypes, function (tokType, testIdx) { utils_1.forEach(canBeTested, function (_a) { var str = _a.str, idx = _a.idx, tokenType = _a.tokenType; if (testIdx < idx && testTokenType(str, tokType.PATTERN)) { var msg = "Token: ->" + tokenType.name + "<- can never be matched.\n" + ("Because it appears AFTER the Token Type ->" + tokType.name + "<-") + "in the lexer's definition.\n" + "See https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#UNREACHABLE"; errors.push({ message: msg, type: lexer_public_1.LexerDefinitionErrorType.UNREACHABLE_PATTERN, tokenTypes: [tokType, tokenType] }); } }); }); return errors; } exports.findUnreachablePatterns = findUnreachablePatterns; function testTokenType(str, pattern) { /* istanbul ignore else */ if (utils_1.isRegExp(pattern)) { var regExpArray = pattern.exec(str); return regExpArray !== null && regExpArray.index === 0; } else if (utils_1.isFunction(pattern)) { // maintain the API of custom patterns return pattern(str, 0, [], {}); } else if (utils_1.has(pattern, "exec")) { // maintain the API of custom patterns return pattern.exec(str, 0, [], {}); } else if (typeof pattern === "string") { return pattern === str; } else { throw Error("non exhaustive match"); } } function noMetaChar(regExp) { //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp var metaChars = [ ".", "\\", "[", "]", "|", "^", "$", "(", ")", "?", "*", "+", "{" ]; return (utils_1.find(metaChars, function (char) { return regExp.source.indexOf(char) !== -1; }) === undefined); } function addStartOfInput(pattern) { var flags = pattern.ignoreCase ? "i" : ""; // always wrapping in a none capturing group preceded by '^' to make sure matching can only work on start of input. // duplicate/redundant start of input markers have no meaning (/^^^^A/ === /^A/) return new RegExp("^(?:" + pattern.source + ")", flags); } exports.addStartOfInput = addStartOfInput; function addStickyFlag(pattern) { var flags = pattern.ignoreCase ? "iy" : "y"; // always wrapping in a none capturing group preceded by '^' to make sure matching can only work on start of input. // duplicate/redundant start of input markers have no meaning (/^^^^A/ === /^A/) return new RegExp("" + pattern.source, flags); } exports.addStickyFlag = addStickyFlag; function performRuntimeChecks(lexerDefinition, trackLines, lineTerminatorCharacters) { var errors = []; // some run time checks to help the end users. if (!utils_1.has(lexerDefinition, exports.DEFAULT_MODE)) { errors.push({ message: "A MultiMode Lexer cannot be initialized without a <" + exports.DEFAULT_MODE + "> property in its definition\n", type: lexer_public_1.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE }); } if (!utils_1.has(lexerDefinition, exports.MODES)) { errors.push({ message: "A MultiMode Lexer cannot be initialized without a <" + exports.MODES + "> property in its definition\n", type: lexer_public_1.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY }); } if (utils_1.has(lexerDefinition, exports.MODES) && utils_1.has(lexerDefinition, exports.DEFAULT_MODE) && !utils_1.has(lexerDefinition.modes, lexerDefinition.defaultMode)) { errors.push({ message: "A MultiMode Lexer cannot be initialized with a " + exports.DEFAULT_MODE + ": <" + lexerDefinition.defaultMode + ">" + "which does not exist\n", type: lexer_public_1.LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST }); } if (utils_1.has(lexerDefinition, exports.MODES)) { utils_1.forEach(lexerDefinition.modes, function (currModeValue, currModeName) { utils_1.forEach(currModeValue, function (currTokType, currIdx) { if (utils_1.isUndefined(currTokType)) { errors.push({ message: "A Lexer cannot be initialized using an undefined Token Type. Mode:" + ("<" + currModeName + "> at index: <" + currIdx + ">\n"), type: lexer_public_1.LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED }); } }); }); } return errors; } exports.performRuntimeChecks = performRuntimeChecks; function performWarningRuntimeChecks(lexerDefinition, trackLines, lineTerminatorCharacters) { var warnings = []; var hasAnyLineBreak = false; var allTokenTypes = utils_1.compact(utils_1.flatten(utils_1.mapValues(lexerDefinition.modes, function (tokTypes) { return tokTypes; }))); var concreteTokenTypes = utils_1.reject(allTokenTypes, function (currType) { return currType[PATTERN] === lexer_public_1.Lexer.NA; }); var terminatorCharCodes = getCharCodes(lineTerminatorCharacters); if (trackLines) { utils_1.forEach(concreteTokenTypes, function (tokType) { var currIssue = checkLineBreaksIssues(tokType, terminatorCharCodes); if (currIssue !== false) { var message = buildLineBreakIssueMessage(tokType, currIssue); var warningDescriptor = { message: message, type: currIssue.issue, tokenType: tokType }; warnings.push(warningDescriptor); } else { // we don't want to attempt to scan if the user explicitly specified the line_breaks option. if (utils_1.has(tokType, "LINE_BREAKS")) { if (tokType.LINE_BREAKS === true) { hasAnyLineBreak = true; } } else { if (reg_exp_1.canMatchCharCode(terminatorCharCodes, tokType.PATTERN)) { hasAnyLineBreak = true; } } } }); } if (trackLines && !hasAnyLineBreak) { warnings.push({ message: "Warning: No LINE_BREAKS Found.\n" + "\tThis Lexer has been defined to track line and column information,\n" + "\tBut none of the Token Types can be identified as matching a line terminator.\n" + "\tSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n" + "\tfor details.", type: lexer_public_1.LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS }); } return warnings; } exports.performWarningRuntimeChecks = performWarningRuntimeChecks; function cloneEmptyGroups(emptyGroups) { var clonedResult = {}; var groupKeys = utils_1.keys(emptyGroups); utils_1.forEach(groupKeys, function (currKey) { var currGroupValue = emptyGroups[currKey]; /* istanbul ignore else */ if (utils_1.isArray(currGroupValue)) { clonedResult[currKey] = []; } else { throw Error("non exhaustive match"); } }); return clonedResult; } exports.cloneEmptyGroups = cloneEmptyGroups; // TODO: refactor to avoid duplication function isCustomPattern(tokenType) { var pattern = tokenType.PATTERN; /* istanbul ignore else */ if (utils_1.isRegExp(pattern)) { return false; } else if (utils_1.isFunction(pattern)) { // CustomPatternMatcherFunc - custom patterns do not require any transformations, only wrapping in a RegExp Like object return true; } else if (utils_1.has(pattern, "exec")) { // ICustomPattern return true; } else if (utils_1.isString(pattern)) { return false; } else { throw Error("non exhaustive match"); } } exports.isCustomPattern = isCustomPattern; function isShortPattern(pattern) { if (utils_1.isString(pattern) && pattern.length === 1) { return pattern.charCodeAt(0); } else { return false; } } exports.isShortPattern = isShortPattern; /** * Faster than using a RegExp for default newline detection during lexing. */ exports.LineTerminatorOptimizedTester = { // implements /\n|\r\n?/g.test test: function (text) { var len = text.length; for (var i = this.lastIndex; i < len; i++) { var c = text.charCodeAt(i); if (c === 10) { this.lastIndex = i + 1; return true; } else if (c === 13) { if (text.charCodeAt(i + 1) === 10) { this.lastIndex = i + 2; } else { this.lastIndex = i + 1; } return true; } } return false; }, lastIndex: 0 }; function checkLineBreaksIssues(tokType, lineTerminatorCharCodes) { if (utils_1.has(tokType, "LINE_BREAKS")) { // if the user explicitly declared the line_breaks option we will respect their choice // and assume it is correct. return false; } else { /* istanbul ignore else */ if (utils_1.isRegExp(tokType.PATTERN)) { try { reg_exp_1.canMatchCharCode(lineTerminatorCharCodes, tokType.PATTERN); } catch (e) { /* istanbul ignore next - to test this we would have to mock to throw an error */ return { issue: lexer_public_1.LexerDefinitionErrorType.IDENTIFY_TERMINATOR, errMsg: e.message }; } return false; } else if (utils_1.isString(tokType.PATTERN)) { // string literal patterns can always be analyzed to detect line terminator usage return false; } else if (isCustomPattern(tokType)) { // custom token types return { issue: lexer_public_1.LexerDefinitionErrorType.CUSTOM_LINE_BREAK }; } else { throw Error("non exhaustive match"); } } } function buildLineBreakIssueMessage(tokType, details) { /* istanbul ignore else */ if (details.issue === lexer_public_1.LexerDefinitionErrorType.IDENTIFY_TERMINATOR) { return ("Warning: unable to identify line terminator usage in pattern.\n" + ("\tThe problem is in the <" + tokType.name + "> Token Type\n") + ("\t Root cause: " + details.errMsg + ".\n") + "\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR"); } else if (details.issue === lexer_public_1.LexerDefinitionErrorType.CUSTOM_LINE_BREAK) { return ("Warning: A Custom Token Pattern should specify the option.\n" + ("\tThe problem is in the <" + tokType.name + "> Token Type\n") + "\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK"); } else { throw Error("non exhaustive match"); } } exports.buildLineBreakIssueMessage = buildLineBreakIssueMessage; function getCharCodes(charsOrCodes) { var charCodes = utils_1.map(charsOrCodes, function (numOrString) { if (utils_1.isString(numOrString) && numOrString.length > 0) { return numOrString.charCodeAt(0); } else { return numOrString; } }); return charCodes; } function addToMapOfArrays(map, key, value) { if (map[key] === undefined) { map[key] = [value]; } else { map[key].push(value); } } exports.minOptimizationVal = 256; /** * We ae mapping charCode above ASCI (256) into buckets each in the size of 256. * This is because ASCI are the most common start chars so each one of those will get its own * possible token configs vector. * * Tokens starting with charCodes "above" ASCI are uncommon, so we can "afford" * to place these into buckets of possible token configs, What we gain from * this is avoiding the case of creating an optimization 'charCodeToPatternIdxToConfig' * which would contain 10,000+ arrays of small size (e.g unicode Identifiers scenario). * Our 'charCodeToPatternIdxToConfig' max size will now be: * 256 + (2^16 / 2^8) - 1 === 511 * * note the hack for fast division integer part extraction * See: https://stackoverflow.com/a/4228528 */ function charCodeToOptimizedIndex(charCode) { return charCode < exports.minOptimizationVal ? charCode : charCodeToOptimizedIdxMap[charCode]; } exports.charCodeToOptimizedIndex = charCodeToOptimizedIndex; /** * This is a compromise between cold start / hot running performance * Creating this array takes ~3ms on a modern machine, * But if we perform the computation at runtime as needed the CSS Lexer benchmark * performance degrades by ~10% * * TODO: Perhaps it should be lazy initialized only if a charCode > 255 is used. */ var charCodeToOptimizedIdxMap = []; function initCharCodeToOptimizedIndexMap() { if (utils_1.isEmpty(charCodeToOptimizedIdxMap)) { charCodeToOptimizedIdxMap = new Array(65536); for (var i = 0; i < 65536; i++) { /* tslint:disable */ charCodeToOptimizedIdxMap[i] = i > 255 ? 255 + ~~(i / 255) : i; /* tslint:enable */ } } } //# sourceMappingURL=lexer.js.map /***/ }), /* 21 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defaultLexerErrorProvider = { buildUnableToPopLexerModeMessage: function (token) { return "Unable to pop Lexer Mode after encountering Token ->" + token.image + "<- The Mode Stack is empty"; }, buildUnexpectedCharactersMessage: function (fullText, startOffset, length, line, column) { return ("unexpected character: ->" + fullText.charAt(startOffset) + "<- at offset: " + startOffset + "," + (" skipped " + length + " characters.")); } }; //# sourceMappingURL=lexer_errors_public.js.map /***/ }), /* 22 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var gast_public_1 = __webpack_require__(1); var gast_1 = __webpack_require__(6); function first(prod) { /* istanbul ignore else */ if (prod instanceof gast_public_1.NonTerminal) { // this could in theory cause infinite loops if // (1) prod A refs prod B. // (2) prod B refs prod A // (3) AB can match the empty set // in other words a cycle where everything is optional so the first will keep // looking ahead for the next optional part and will never exit // currently there is no safeguard for this unique edge case because // (1) not sure a grammar in which this can happen is useful for anything (productive) return first(prod.referencedRule); } else if (prod instanceof gast_public_1.Terminal) { return firstForTerminal(prod); } else if (gast_1.isSequenceProd(prod)) { return firstForSequence(prod); } else if (gast_1.isBranchingProd(prod)) { return firstForBranching(prod); } else { throw Error("non exhaustive match"); } } exports.first = first; function firstForSequence(prod) { var firstSet = []; var seq = prod.definition; var nextSubProdIdx = 0; var hasInnerProdsRemaining = seq.length > nextSubProdIdx; var currSubProd; // so we enter the loop at least once (if the definition is not empty var isLastInnerProdOptional = true; // scan a sequence until it's end or until we have found a NONE optional production in it while (hasInnerProdsRemaining && isLastInnerProdOptional) { currSubProd = seq[nextSubProdIdx]; isLastInnerProdOptional = gast_1.isOptionalProd(currSubProd); firstSet = firstSet.concat(first(currSubProd)); nextSubProdIdx = nextSubProdIdx + 1; hasInnerProdsRemaining = seq.length > nextSubProdIdx; } return utils_1.uniq(firstSet); } exports.firstForSequence = firstForSequence; function firstForBranching(prod) { var allAlternativesFirsts = utils_1.map(prod.definition, function (innerProd) { return first(innerProd); }); return utils_1.uniq(utils_1.flatten(allAlternativesFirsts)); } exports.firstForBranching = firstForBranching; function firstForTerminal(terminal) { return [terminal.terminalType]; } exports.firstForTerminal = firstForTerminal; //# sourceMappingURL=first.js.map /***/ }), /* 23 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // TODO: can this be removed? where is it used? exports.IN = "_~IN~_"; //# sourceMappingURL=constants.js.map /***/ }), /* 24 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var resolver_1 = __webpack_require__(29); var checks_1 = __webpack_require__(11); var errors_public_1 = __webpack_require__(10); var gast_1 = __webpack_require__(6); function resolveGrammar(options) { options = utils_1.defaults(options, { errMsgProvider: errors_public_1.defaultGrammarResolverErrorProvider }); var topRulesTable = {}; utils_1.forEach(options.rules, function (rule) { topRulesTable[rule.name] = rule; }); return resolver_1.resolveGrammar(topRulesTable, options.errMsgProvider); } exports.resolveGrammar = resolveGrammar; function validateGrammar(options) { options = utils_1.defaults(options, { errMsgProvider: errors_public_1.defaultGrammarValidatorErrorProvider, ignoredIssues: {} }); return checks_1.validateGrammar(options.rules, options.maxLookahead, options.tokenTypes, options.ignoredIssues, options.errMsgProvider, options.grammarName); } exports.validateGrammar = validateGrammar; function assignOccurrenceIndices(options) { utils_1.forEach(options.rules, function (currRule) { var methodsCollector = new gast_1.DslMethodsCollectorVisitor(); currRule.accept(methodsCollector); utils_1.forEach(methodsCollector.dslMethods, function (methods) { utils_1.forEach(methods, function (currMethod, arrIdx) { currMethod.idx = arrIdx + 1; }); }); }); } exports.assignOccurrenceIndices = assignOccurrenceIndices; //# sourceMappingURL=gast_resolver_public.js.map /***/ }), /* 25 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tokens_public_1 = __webpack_require__(3); var utils_1 = __webpack_require__(0); var exceptions_public_1 = __webpack_require__(8); var constants_1 = __webpack_require__(23); var parser_1 = __webpack_require__(2); exports.EOF_FOLLOW_KEY = {}; exports.IN_RULE_RECOVERY_EXCEPTION = "InRuleRecoveryException"; function InRuleRecoveryException(message) { this.name = exports.IN_RULE_RECOVERY_EXCEPTION; this.message = message; } exports.InRuleRecoveryException = InRuleRecoveryException; InRuleRecoveryException.prototype = Error.prototype; /** * This trait is responsible for the error recovery and fault tolerant logic */ var Recoverable = /** @class */ (function () { function Recoverable() { } Recoverable.prototype.initRecoverable = function (config) { this.firstAfterRepMap = {}; this.resyncFollows = {}; this.recoveryEnabled = utils_1.has(config, "recoveryEnabled") ? config.recoveryEnabled : parser_1.DEFAULT_PARSER_CONFIG.recoveryEnabled; // performance optimization, NOOP will be inlined which // effectively means that this optional feature does not exist // when not used. if (this.recoveryEnabled) { this.attemptInRepetitionRecovery = attemptInRepetitionRecovery; } }; Recoverable.prototype.getTokenToInsert = function (tokType) { var tokToInsert = tokens_public_1.createTokenInstance(tokType, "", NaN, NaN, NaN, NaN, NaN, NaN); tokToInsert.isInsertedInRecovery = true; return tokToInsert; }; Recoverable.prototype.canTokenTypeBeInsertedInRecovery = function (tokType) { return true; }; Recoverable.prototype.tryInRepetitionRecovery = function (grammarRule, grammarRuleArgs, lookAheadFunc, expectedTokType) { var _this = this; // TODO: can the resyncTokenType be cached? var reSyncTokType = this.findReSyncTokenType(); var savedLexerState = this.exportLexerState(); var resyncedTokens = []; var passedResyncPoint = false; var nextTokenWithoutResync = this.LA(1); var currToken = this.LA(1); var generateErrorMessage = function () { var previousToken = _this.LA(0); // we are preemptively re-syncing before an error has been detected, therefor we must reproduce // the error that would have been thrown var msg = _this.errorMessageProvider.buildMismatchTokenMessage({ expected: expectedTokType, actual: nextTokenWithoutResync, previous: previousToken, ruleName: _this.getCurrRuleFullName() }); var error = new exceptions_public_1.MismatchedTokenException(msg, nextTokenWithoutResync, _this.LA(0)); // the first token here will be the original cause of the error, this is not part of the resyncedTokens property. error.resyncedTokens = utils_1.dropRight(resyncedTokens); _this.SAVE_ERROR(error); }; while (!passedResyncPoint) { // re-synced to a point where we can safely exit the repetition/ if (this.tokenMatcher(currToken, expectedTokType)) { generateErrorMessage(); return; // must return here to avoid reverting the inputIdx } else if (lookAheadFunc.call(this)) { // we skipped enough tokens so we can resync right back into another iteration of the repetition grammar rule generateErrorMessage(); // recursive invocation in other to support multiple re-syncs in the same top level repetition grammar rule grammarRule.apply(this, grammarRuleArgs); return; // must return here to avoid reverting the inputIdx } else if (this.tokenMatcher(currToken, reSyncTokType)) { passedResyncPoint = true; } else { currToken = this.SKIP_TOKEN(); this.addToResyncTokens(currToken, resyncedTokens); } } // we were unable to find a CLOSER point to resync inside the Repetition, reset the state. // The parsing exception we were trying to prevent will happen in the NEXT parsing step. it may be handled by // "between rules" resync recovery later in the flow. this.importLexerState(savedLexerState); }; Recoverable.prototype.shouldInRepetitionRecoveryBeTried = function (expectTokAfterLastMatch, nextTokIdx, notStuck) { // Edge case of arriving from a MANY repetition which is stuck // Attempting recovery in this case could cause an infinite loop if (notStuck === false) { return false; } // arguments to try and perform resync into the next iteration of the many are missing if (expectTokAfterLastMatch === undefined || nextTokIdx === undefined) { return false; } // no need to recover, next token is what we expect... if (this.tokenMatcher(this.LA(1), expectTokAfterLastMatch)) { return false; } // error recovery is disabled during backtracking as it can make the parser ignore a valid grammar path // and prefer some backtracking path that includes recovered errors. if (this.isBackTracking()) { return false; } // if we can perform inRule recovery (single token insertion or deletion) we always prefer that recovery algorithm // because if it works, it makes the least amount of changes to the input stream (greedy algorithm) //noinspection RedundantIfStatementJS if (this.canPerformInRuleRecovery(expectTokAfterLastMatch, this.getFollowsForInRuleRecovery(expectTokAfterLastMatch, nextTokIdx))) { return false; } return true; }; // Error Recovery functionality Recoverable.prototype.getFollowsForInRuleRecovery = function (tokType, tokIdxInRule) { var grammarPath = this.getCurrentGrammarPath(tokType, tokIdxInRule); var follows = this.getNextPossibleTokenTypes(grammarPath); return follows; }; Recoverable.prototype.tryInRuleRecovery = function (expectedTokType, follows) { if (this.canRecoverWithSingleTokenInsertion(expectedTokType, follows)) { var tokToInsert = this.getTokenToInsert(expectedTokType); return tokToInsert; } if (this.canRecoverWithSingleTokenDeletion(expectedTokType)) { var nextTok = this.SKIP_TOKEN(); this.consumeToken(); return nextTok; } throw new InRuleRecoveryException("sad sad panda"); }; Recoverable.prototype.canPerformInRuleRecovery = function (expectedToken, follows) { return (this.canRecoverWithSingleTokenInsertion(expectedToken, follows) || this.canRecoverWithSingleTokenDeletion(expectedToken)); }; Recoverable.prototype.canRecoverWithSingleTokenInsertion = function (expectedTokType, follows) { var _this = this; if (!this.canTokenTypeBeInsertedInRecovery(expectedTokType)) { return false; } // must know the possible following tokens to perform single token insertion if (utils_1.isEmpty(follows)) { return false; } var mismatchedTok = this.LA(1); var isMisMatchedTokInFollows = utils_1.find(follows, function (possibleFollowsTokType) { return _this.tokenMatcher(mismatchedTok, possibleFollowsTokType); }) !== undefined; return isMisMatchedTokInFollows; }; Recoverable.prototype.canRecoverWithSingleTokenDeletion = function (expectedTokType) { var isNextTokenWhatIsExpected = this.tokenMatcher(this.LA(2), expectedTokType); return isNextTokenWhatIsExpected; }; Recoverable.prototype.isInCurrentRuleReSyncSet = function (tokenTypeIdx) { var followKey = this.getCurrFollowKey(); var currentRuleReSyncSet = this.getFollowSetFromFollowKey(followKey); return utils_1.contains(currentRuleReSyncSet, tokenTypeIdx); }; Recoverable.prototype.findReSyncTokenType = function () { var allPossibleReSyncTokTypes = this.flattenFollowSet(); // this loop will always terminate as EOF is always in the follow stack and also always (virtually) in the input var nextToken = this.LA(1); var k = 2; while (true) { var nextTokenType = nextToken.tokenType; if (utils_1.contains(allPossibleReSyncTokTypes, nextTokenType)) { return nextTokenType; } nextToken = this.LA(k); k++; } }; Recoverable.prototype.getCurrFollowKey = function () { // the length is at least one as we always add the ruleName to the stack before invoking the rule. if (this.RULE_STACK.length === 1) { return exports.EOF_FOLLOW_KEY; } var currRuleShortName = this.getLastExplicitRuleShortName(); var currRuleIdx = this.getLastExplicitRuleOccurrenceIndex(); var prevRuleShortName = this.getPreviousExplicitRuleShortName(); return { ruleName: this.shortRuleNameToFullName(currRuleShortName), idxInCallingRule: currRuleIdx, inRule: this.shortRuleNameToFullName(prevRuleShortName) }; }; Recoverable.prototype.buildFullFollowKeyStack = function () { var _this = this; var explicitRuleStack = this.RULE_STACK; var explicitOccurrenceStack = this.RULE_OCCURRENCE_STACK; if (!utils_1.isEmpty(this.LAST_EXPLICIT_RULE_STACK)) { explicitRuleStack = utils_1.map(this.LAST_EXPLICIT_RULE_STACK, function (idx) { return _this.RULE_STACK[idx]; }); explicitOccurrenceStack = utils_1.map(this.LAST_EXPLICIT_RULE_STACK, function (idx) { return _this.RULE_OCCURRENCE_STACK[idx]; }); } // TODO: only iterate over explicit rules here return utils_1.map(explicitRuleStack, function (ruleName, idx) { if (idx === 0) { return exports.EOF_FOLLOW_KEY; } return { ruleName: _this.shortRuleNameToFullName(ruleName), idxInCallingRule: explicitOccurrenceStack[idx], inRule: _this.shortRuleNameToFullName(explicitRuleStack[idx - 1]) }; }); }; Recoverable.prototype.flattenFollowSet = function () { var _this = this; var followStack = utils_1.map(this.buildFullFollowKeyStack(), function (currKey) { return _this.getFollowSetFromFollowKey(currKey); }); return utils_1.flatten(followStack); }; Recoverable.prototype.getFollowSetFromFollowKey = function (followKey) { if (followKey === exports.EOF_FOLLOW_KEY) { return [tokens_public_1.EOF]; } var followName = followKey.ruleName + followKey.idxInCallingRule + constants_1.IN + followKey.inRule; return this.resyncFollows[followName]; }; // It does not make any sense to include a virtual EOF token in the list of resynced tokens // as EOF does not really exist and thus does not contain any useful information (line/column numbers) Recoverable.prototype.addToResyncTokens = function (token, resyncTokens) { if (!this.tokenMatcher(token, tokens_public_1.EOF)) { resyncTokens.push(token); } return resyncTokens; }; Recoverable.prototype.reSyncTo = function (tokType) { var resyncedTokens = []; var nextTok = this.LA(1); while (this.tokenMatcher(nextTok, tokType) === false) { nextTok = this.SKIP_TOKEN(); this.addToResyncTokens(nextTok, resyncedTokens); } // the last token is not part of the error. return utils_1.dropRight(resyncedTokens); }; Recoverable.prototype.attemptInRepetitionRecovery = function (prodFunc, args, lookaheadFunc, dslMethodIdx, prodOccurrence, nextToksWalker, notStuck) { // by default this is a NO-OP // The actual implementation is with the function(not method) below }; Recoverable.prototype.getCurrentGrammarPath = function (tokType, tokIdxInRule) { var pathRuleStack = this.getHumanReadableRuleStack(); var pathOccurrenceStack = utils_1.cloneArr(this.RULE_OCCURRENCE_STACK); var grammarPath = { ruleStack: pathRuleStack, occurrenceStack: pathOccurrenceStack, lastTok: tokType, lastTokOccurrence: tokIdxInRule }; return grammarPath; }; Recoverable.prototype.getHumanReadableRuleStack = function () { var _this = this; if (!utils_1.isEmpty(this.LAST_EXPLICIT_RULE_STACK)) { return utils_1.map(this.LAST_EXPLICIT_RULE_STACK, function (currIdx) { return _this.shortRuleNameToFullName(_this.RULE_STACK[currIdx]); }); } else { return utils_1.map(this.RULE_STACK, function (currShortName) { return _this.shortRuleNameToFullName(currShortName); }); } }; return Recoverable; }()); exports.Recoverable = Recoverable; function attemptInRepetitionRecovery(prodFunc, args, lookaheadFunc, dslMethodIdx, prodOccurrence, nextToksWalker, notStuck) { var key = this.getKeyForAutomaticLookahead(dslMethodIdx, prodOccurrence); var firstAfterRepInfo = this.firstAfterRepMap[key]; if (firstAfterRepInfo === undefined) { var currRuleName = this.getCurrRuleFullName(); var ruleGrammar = this.getGAstProductions()[currRuleName]; var walker = new nextToksWalker(ruleGrammar, prodOccurrence); firstAfterRepInfo = walker.startWalking(); this.firstAfterRepMap[key] = firstAfterRepInfo; } var expectTokAfterLastMatch = firstAfterRepInfo.token; var nextTokIdx = firstAfterRepInfo.occurrence; var isEndOfRule = firstAfterRepInfo.isEndOfRule; // special edge case of a TOP most repetition after which the input should END. // this will force an attempt for inRule recovery in that scenario. if (this.RULE_STACK.length === 1 && isEndOfRule && expectTokAfterLastMatch === undefined) { expectTokAfterLastMatch = tokens_public_1.EOF; nextTokIdx = 1; } if (this.shouldInRepetitionRecoveryBeTried(expectTokAfterLastMatch, nextTokIdx, notStuck)) { // TODO: performance optimization: instead of passing the original args here, we modify // the args param (or create a new one) and make sure the lookahead func is explicitly provided // to avoid searching the cache for it once more. this.tryInRepetitionRecovery(prodFunc, args, lookaheadFunc, expectTokAfterLastMatch); } } exports.attemptInRepetitionRecovery = attemptInRepetitionRecovery; //# sourceMappingURL=recoverable.js.map /***/ }), /* 26 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); function classNameFromInstance(instance) { return functionName(instance.constructor); } exports.classNameFromInstance = classNameFromInstance; var FUNC_NAME_REGEXP = /^\s*function\s*(\S*)\s*\(/; var NAME = "name"; /* istanbul ignore next too many hacks for IE/old versions of node.js here*/ function functionName(func) { // Engines that support Function.prototype.name OR the nth (n>1) time after // the name has been computed in the following else block. var existingNameProp = func.name; if (existingNameProp) { return existingNameProp; } // hack for IE and engines that do not support Object.defineProperty on function.name (Node.js 0.10 && 0.12) var computedName = func.toString().match(FUNC_NAME_REGEXP)[1]; return computedName; } exports.functionName = functionName; /** * @returns {boolean} - has the property been successfully defined */ function defineNameProp(obj, nameValue) { var namePropDescriptor = Object.getOwnPropertyDescriptor(obj, NAME); /* istanbul ignore else -> will only run in old versions of node.js */ if (utils_1.isUndefined(namePropDescriptor) || namePropDescriptor.configurable) { Object.defineProperty(obj, NAME, { enumerable: false, configurable: true, writable: false, value: nameValue }); return true; } /* istanbul ignore next -> will only run in old versions of node.js */ return false; } exports.defineNameProp = defineNameProp; //# sourceMappingURL=lang_extensions.js.map /***/ }), /* 27 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var rest_1 = __webpack_require__(14); var first_1 = __webpack_require__(22); var utils_1 = __webpack_require__(0); var constants_1 = __webpack_require__(23); var gast_public_1 = __webpack_require__(1); // This ResyncFollowsWalker computes all of the follows required for RESYNC // (skipping reference production). var ResyncFollowsWalker = /** @class */ (function (_super) { __extends(ResyncFollowsWalker, _super); function ResyncFollowsWalker(topProd) { var _this = _super.call(this) || this; _this.topProd = topProd; _this.follows = {}; return _this; } ResyncFollowsWalker.prototype.startWalking = function () { this.walk(this.topProd); return this.follows; }; ResyncFollowsWalker.prototype.walkTerminal = function (terminal, currRest, prevRest) { // do nothing! just like in the public sector after 13:00 }; ResyncFollowsWalker.prototype.walkProdRef = function (refProd, currRest, prevRest) { var followName = buildBetweenProdsFollowPrefix(refProd.referencedRule, refProd.idx) + this.topProd.name; var fullRest = currRest.concat(prevRest); var restProd = new gast_public_1.Flat({ definition: fullRest }); var t_in_topProd_follows = first_1.first(restProd); this.follows[followName] = t_in_topProd_follows; }; return ResyncFollowsWalker; }(rest_1.RestWalker)); exports.ResyncFollowsWalker = ResyncFollowsWalker; function computeAllProdsFollows(topProductions) { var reSyncFollows = {}; utils_1.forEach(topProductions, function (topProd) { var currRefsFollow = new ResyncFollowsWalker(topProd).startWalking(); utils_1.assign(reSyncFollows, currRefsFollow); }); return reSyncFollows; } exports.computeAllProdsFollows = computeAllProdsFollows; function buildBetweenProdsFollowPrefix(inner, occurenceInParent) { return inner.name + occurenceInParent + constants_1.IN; } exports.buildBetweenProdsFollowPrefix = buildBetweenProdsFollowPrefix; function buildInProdFollowPrefix(terminal) { var terminalName = terminal.terminalType.name; return terminalName + terminal.idx + constants_1.IN; } exports.buildInProdFollowPrefix = buildInProdFollowPrefix; //# sourceMappingURL=follow.js.map /***/ }), /* 28 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var regexp_to_ast_1 = __webpack_require__(15); var utils_1 = __webpack_require__(0); var reg_exp_parser_1 = __webpack_require__(16); var lexer_1 = __webpack_require__(20); var complementErrorMessage = "Complement Sets are not supported for first char optimization"; exports.failedOptimizationPrefixMsg = 'Unable to use "first char" lexer optimizations:\n'; function getOptimizedStartCodesIndices(regExp, ensureOptimizations) { if (ensureOptimizations === void 0) { ensureOptimizations = false; } try { var ast = reg_exp_parser_1.getRegExpAst(regExp); var firstChars = firstCharOptimizedIndices(ast.value, {}, ast.flags.ignoreCase); return firstChars; } catch (e) { /* istanbul ignore next */ // Testing this relies on the regexp-to-ast library having a bug... */ // TODO: only the else branch needs to be ignored, try to fix with newer prettier / tsc if (e.message === complementErrorMessage) { if (ensureOptimizations) { utils_1.PRINT_WARNING("" + exports.failedOptimizationPrefixMsg + ("\tUnable to optimize: < " + regExp.toString() + " >\n") + "\tComplement Sets cannot be automatically optimized.\n" + "\tThis will disable the lexer's first char optimizations.\n" + "\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details."); } } else { var msgSuffix = ""; if (ensureOptimizations) { msgSuffix = "\n\tThis will disable the lexer's first char optimizations.\n" + "\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."; } utils_1.PRINT_ERROR(exports.failedOptimizationPrefixMsg + "\n" + ("\tFailed parsing: < " + regExp.toString() + " >\n") + ("\tUsing the regexp-to-ast library version: " + regexp_to_ast_1.VERSION + "\n") + "\tPlease open an issue at: https://github.com/bd82/regexp-to-ast/issues" + msgSuffix); } } return []; } exports.getOptimizedStartCodesIndices = getOptimizedStartCodesIndices; function firstCharOptimizedIndices(ast, result, ignoreCase) { switch (ast.type) { case "Disjunction": for (var i = 0; i < ast.value.length; i++) { firstCharOptimizedIndices(ast.value[i], result, ignoreCase); } break; case "Alternative": var terms = ast.value; for (var i = 0; i < terms.length; i++) { var term = terms[i]; // skip terms that cannot effect the first char results switch (term.type) { case "EndAnchor": // A group back reference cannot affect potential starting char. // because if a back reference is the first production than automatically // the group being referenced has had to come BEFORE so its codes have already been added case "GroupBackReference": // assertions do not affect potential starting codes case "Lookahead": case "NegativeLookahead": case "StartAnchor": case "WordBoundary": case "NonWordBoundary": continue; } var atom = term; switch (atom.type) { case "Character": addOptimizedIdxToResult(atom.value, result, ignoreCase); break; case "Set": if (atom.complement === true) { throw Error(complementErrorMessage); } utils_1.forEach(atom.value, function (code) { if (typeof code === "number") { addOptimizedIdxToResult(code, result, ignoreCase); } else { // range var range = code; // cannot optimize when ignoreCase is if (ignoreCase === true) { for (var rangeCode = range.from; rangeCode <= range.to; rangeCode++) { addOptimizedIdxToResult(rangeCode, result, ignoreCase); } } // Optimization (2 orders of magnitude less work for very large ranges) else { // handle unoptimized values for (var rangeCode = range.from; rangeCode <= range.to && rangeCode < lexer_1.minOptimizationVal; rangeCode++) { addOptimizedIdxToResult(rangeCode, result, ignoreCase); } // Less common charCode where we optimize for faster init time, by using larger "buckets" if (range.to >= lexer_1.minOptimizationVal) { var minUnOptVal = range.from >= lexer_1.minOptimizationVal ? range.from : lexer_1.minOptimizationVal; var maxUnOptVal = range.to; var minOptIdx = lexer_1.charCodeToOptimizedIndex(minUnOptVal); var maxOptIdx = lexer_1.charCodeToOptimizedIndex(maxUnOptVal); for (var currOptIdx = minOptIdx; currOptIdx <= maxOptIdx; currOptIdx++) { result[currOptIdx] = currOptIdx; } } } } }); break; case "Group": firstCharOptimizedIndices(atom.value, result, ignoreCase); break; /* istanbul ignore next */ default: throw Error("Non Exhaustive Match"); } // reached a mandatory production, no more **start** codes can be found on this alternative var isOptionalQuantifier = atom.quantifier !== undefined && atom.quantifier.atLeast === 0; if ( // A group may be optional due to empty contents /(?:)/ // or if everything inside it is optional /((a)?)/ (atom.type === "Group" && isWholeOptional(atom) === false) || // If this term is not a group it may only be optional if it has an optional quantifier (atom.type !== "Group" && isOptionalQuantifier === false)) { break; } } break; /* istanbul ignore next */ default: throw Error("non exhaustive match!"); } // console.log(Object.keys(result).length) return utils_1.values(result); } exports.firstCharOptimizedIndices = firstCharOptimizedIndices; function addOptimizedIdxToResult(code, result, ignoreCase) { var optimizedCharIdx = lexer_1.charCodeToOptimizedIndex(code); result[optimizedCharIdx] = optimizedCharIdx; if (ignoreCase === true) { handleIgnoreCase(code, result); } } function handleIgnoreCase(code, result) { var char = String.fromCharCode(code); var upperChar = char.toUpperCase(); /* istanbul ignore else */ if (upperChar !== char) { var optimizedCharIdx = lexer_1.charCodeToOptimizedIndex(upperChar.charCodeAt(0)); result[optimizedCharIdx] = optimizedCharIdx; } else { var lowerChar = char.toLowerCase(); if (lowerChar !== char) { var optimizedCharIdx = lexer_1.charCodeToOptimizedIndex(lowerChar.charCodeAt(0)); result[optimizedCharIdx] = optimizedCharIdx; } } } function findCode(setNode, targetCharCodes) { return utils_1.find(setNode.value, function (codeOrRange) { if (typeof codeOrRange === "number") { return utils_1.contains(targetCharCodes, codeOrRange); } else { // range var range_1 = codeOrRange; return (utils_1.find(targetCharCodes, function (targetCode) { return range_1.from <= targetCode && targetCode <= range_1.to; }) !== undefined); } }); } function isWholeOptional(ast) { if (ast.quantifier && ast.quantifier.atLeast === 0) { return true; } if (!ast.value) { return false; } return utils_1.isArray(ast.value) ? utils_1.every(ast.value, isWholeOptional) : isWholeOptional(ast.value); } var CharCodeFinder = /** @class */ (function (_super) { __extends(CharCodeFinder, _super); function CharCodeFinder(targetCharCodes) { var _this = _super.call(this) || this; _this.targetCharCodes = targetCharCodes; _this.found = false; return _this; } CharCodeFinder.prototype.visitChildren = function (node) { // No need to keep looking... if (this.found === true) { return; } // switch lookaheads as they do not actually consume any characters thus // finding a charCode at lookahead context does not mean that regexp can actually contain it in a match. switch (node.type) { case "Lookahead": this.visitLookahead(node); return; case "NegativeLookahead": this.visitNegativeLookahead(node); return; } _super.prototype.visitChildren.call(this, node); }; CharCodeFinder.prototype.visitCharacter = function (node) { if (utils_1.contains(this.targetCharCodes, node.value)) { this.found = true; } }; CharCodeFinder.prototype.visitSet = function (node) { if (node.complement) { if (findCode(node, this.targetCharCodes) === undefined) { this.found = true; } } else { if (findCode(node, this.targetCharCodes) !== undefined) { this.found = true; } } }; return CharCodeFinder; }(regexp_to_ast_1.BaseRegExpVisitor)); function canMatchCharCode(charCodes, pattern) { if (pattern instanceof RegExp) { var ast = reg_exp_parser_1.getRegExpAst(pattern); var charCodeFinder = new CharCodeFinder(charCodes); charCodeFinder.visit(ast); return charCodeFinder.found; } else { return (utils_1.find(pattern, function (char) { return utils_1.contains(charCodes, char.charCodeAt(0)); }) !== undefined); } } exports.canMatchCharCode = canMatchCharCode; //# sourceMappingURL=reg_exp.js.map /***/ }), /* 29 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var parser_1 = __webpack_require__(2); var utils_1 = __webpack_require__(0); var gast_visitor_public_1 = __webpack_require__(4); function resolveGrammar(topLevels, errMsgProvider) { var refResolver = new GastRefResolverVisitor(topLevels, errMsgProvider); refResolver.resolveRefs(); return refResolver.errors; } exports.resolveGrammar = resolveGrammar; var GastRefResolverVisitor = /** @class */ (function (_super) { __extends(GastRefResolverVisitor, _super); function GastRefResolverVisitor(nameToTopRule, errMsgProvider) { var _this = _super.call(this) || this; _this.nameToTopRule = nameToTopRule; _this.errMsgProvider = errMsgProvider; _this.errors = []; return _this; } GastRefResolverVisitor.prototype.resolveRefs = function () { var _this = this; utils_1.forEach(utils_1.values(this.nameToTopRule), function (prod) { _this.currTopLevel = prod; prod.accept(_this); }); }; GastRefResolverVisitor.prototype.visitNonTerminal = function (node) { var ref = this.nameToTopRule[node.nonTerminalName]; if (!ref) { var msg = this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel, node); this.errors.push({ message: msg, type: parser_1.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF, ruleName: this.currTopLevel.name, unresolvedRefName: node.nonTerminalName }); } else { node.referencedRule = ref; } }; return GastRefResolverVisitor; }(gast_visitor_public_1.GAstVisitor)); exports.GastRefResolverVisitor = GastRefResolverVisitor; //# sourceMappingURL=resolver.js.map /***/ }), /* 30 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var lookahead_1 = __webpack_require__(12); var utils_1 = __webpack_require__(0); var parser_1 = __webpack_require__(2); var keys_1 = __webpack_require__(7); var gast_1 = __webpack_require__(6); /** * Trait responsible for the lookahead related utilities and optimizations. */ var LooksAhead = /** @class */ (function () { function LooksAhead() { } LooksAhead.prototype.initLooksAhead = function (config) { this.dynamicTokensEnabled = utils_1.has(config, "dynamicTokensEnabled") ? config.dynamicTokensEnabled : parser_1.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled; this.maxLookahead = utils_1.has(config, "maxLookahead") ? config.maxLookahead : parser_1.DEFAULT_PARSER_CONFIG.maxLookahead; /* istanbul ignore next - Using plain array as dictionary will be tested on older node.js versions and IE11 */ this.lookAheadFuncsCache = utils_1.isES2015MapSupported() ? new Map() : []; // Performance optimization on newer engines that support ES6 Map // For larger Maps this is slightly faster than using a plain object (array in our case). /* istanbul ignore else - The else branch will be tested on older node.js versions and IE11 */ if (utils_1.isES2015MapSupported()) { this.getLaFuncFromCache = this.getLaFuncFromMap; this.setLaFuncCache = this.setLaFuncCacheUsingMap; } else { this.getLaFuncFromCache = this.getLaFuncFromObj; this.setLaFuncCache = this.setLaFuncUsingObj; } }; LooksAhead.prototype.preComputeLookaheadFunctions = function (rules) { var _this = this; utils_1.forEach(rules, function (currRule) { _this.TRACE_INIT(currRule.name + " Rule Lookahead", function () { var _a = gast_1.collectMethods(currRule), alternation = _a.alternation, repetition = _a.repetition, option = _a.option, repetitionMandatory = _a.repetitionMandatory, repetitionMandatoryWithSeparator = _a.repetitionMandatoryWithSeparator, repetitionWithSeparator = _a.repetitionWithSeparator; utils_1.forEach(alternation, function (currProd) { var prodIdx = currProd.idx === 0 ? "" : currProd.idx; _this.TRACE_INIT("" + gast_1.getProductionDslName(currProd) + prodIdx, function () { var laFunc = lookahead_1.buildLookaheadFuncForOr(currProd.idx, currRule, currProd.maxLookahead || _this.maxLookahead, currProd.hasPredicates, _this.dynamicTokensEnabled, _this.lookAheadBuilderForAlternatives); var key = keys_1.getKeyForAutomaticLookahead(_this.fullRuleNameToShort[currRule.name], keys_1.OR_IDX, currProd.idx); _this.setLaFuncCache(key, laFunc); }); }); utils_1.forEach(repetition, function (currProd) { _this.computeLookaheadFunc(currRule, currProd.idx, keys_1.MANY_IDX, lookahead_1.PROD_TYPE.REPETITION, currProd.maxLookahead, gast_1.getProductionDslName(currProd)); }); utils_1.forEach(option, function (currProd) { _this.computeLookaheadFunc(currRule, currProd.idx, keys_1.OPTION_IDX, lookahead_1.PROD_TYPE.OPTION, currProd.maxLookahead, gast_1.getProductionDslName(currProd)); }); utils_1.forEach(repetitionMandatory, function (currProd) { _this.computeLookaheadFunc(currRule, currProd.idx, keys_1.AT_LEAST_ONE_IDX, lookahead_1.PROD_TYPE.REPETITION_MANDATORY, currProd.maxLookahead, gast_1.getProductionDslName(currProd)); }); utils_1.forEach(repetitionMandatoryWithSeparator, function (currProd) { _this.computeLookaheadFunc(currRule, currProd.idx, keys_1.AT_LEAST_ONE_SEP_IDX, lookahead_1.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR, currProd.maxLookahead, gast_1.getProductionDslName(currProd)); }); utils_1.forEach(repetitionWithSeparator, function (currProd) { _this.computeLookaheadFunc(currRule, currProd.idx, keys_1.MANY_SEP_IDX, lookahead_1.PROD_TYPE.REPETITION_WITH_SEPARATOR, currProd.maxLookahead, gast_1.getProductionDslName(currProd)); }); }); }); }; LooksAhead.prototype.computeLookaheadFunc = function (rule, prodOccurrence, prodKey, prodType, prodMaxLookahead, dslMethodName) { var _this = this; this.TRACE_INIT("" + dslMethodName + (prodOccurrence === 0 ? "" : prodOccurrence), function () { var laFunc = lookahead_1.buildLookaheadFuncForOptionalProd(prodOccurrence, rule, prodMaxLookahead || _this.maxLookahead, _this.dynamicTokensEnabled, prodType, _this.lookAheadBuilderForOptional); var key = keys_1.getKeyForAutomaticLookahead(_this.fullRuleNameToShort[rule.name], prodKey, prodOccurrence); _this.setLaFuncCache(key, laFunc); }); }; LooksAhead.prototype.lookAheadBuilderForOptional = function (alt, tokenMatcher, dynamicTokensEnabled) { return lookahead_1.buildSingleAlternativeLookaheadFunction(alt, tokenMatcher, dynamicTokensEnabled); }; LooksAhead.prototype.lookAheadBuilderForAlternatives = function (alts, hasPredicates, tokenMatcher, dynamicTokensEnabled) { return lookahead_1.buildAlternativesLookAheadFunc(alts, hasPredicates, tokenMatcher, dynamicTokensEnabled); }; // this actually returns a number, but it is always used as a string (object prop key) LooksAhead.prototype.getKeyForAutomaticLookahead = function (dslMethodIdx, occurrence) { var currRuleShortName = this.getLastExplicitRuleShortName(); return keys_1.getKeyForAutomaticLookahead(currRuleShortName, dslMethodIdx, occurrence); }; /* istanbul ignore next */ LooksAhead.prototype.getLaFuncFromCache = function (key) { return undefined; }; LooksAhead.prototype.getLaFuncFromMap = function (key) { return this.lookAheadFuncsCache.get(key); }; /* istanbul ignore next - Using plain array as dictionary will be tested on older node.js versions and IE11 */ LooksAhead.prototype.getLaFuncFromObj = function (key) { return this.lookAheadFuncsCache[key]; }; /* istanbul ignore next */ LooksAhead.prototype.setLaFuncCache = function (key, value) { }; LooksAhead.prototype.setLaFuncCacheUsingMap = function (key, value) { this.lookAheadFuncsCache.set(key, value); }; /* istanbul ignore next - Using plain array as dictionary will be tested on older node.js versions and IE11 */ LooksAhead.prototype.setLaFuncUsingObj = function (key, value) { this.lookAheadFuncsCache[key] = value; }; return LooksAhead; }()); exports.LooksAhead = LooksAhead; //# sourceMappingURL=looksahead.js.map /***/ }), /* 31 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var cst_1 = __webpack_require__(17); var utils_1 = __webpack_require__(0); var cst_visitor_1 = __webpack_require__(32); var keys_1 = __webpack_require__(7); var parser_1 = __webpack_require__(2); /** * This trait is responsible for the CST building logic. */ var TreeBuilder = /** @class */ (function () { function TreeBuilder() { } TreeBuilder.prototype.initTreeBuilder = function (config) { this.LAST_EXPLICIT_RULE_STACK = []; this.CST_STACK = []; this.outputCst = utils_1.has(config, "outputCst") ? config.outputCst : parser_1.DEFAULT_PARSER_CONFIG.outputCst; this.nodeLocationTracking = utils_1.has(config, "nodeLocationTracking") ? config.nodeLocationTracking : parser_1.DEFAULT_PARSER_CONFIG.nodeLocationTracking; if (!this.outputCst) { this.cstInvocationStateUpdate = utils_1.NOOP; this.cstFinallyStateUpdate = utils_1.NOOP; this.cstPostTerminal = utils_1.NOOP; this.cstPostNonTerminal = utils_1.NOOP; this.cstPostRule = utils_1.NOOP; this.getLastExplicitRuleShortName = this.getLastExplicitRuleShortNameNoCst; this.getPreviousExplicitRuleShortName = this.getPreviousExplicitRuleShortNameNoCst; this.getLastExplicitRuleOccurrenceIndex = this.getLastExplicitRuleOccurrenceIndexNoCst; this.manyInternal = this.manyInternalNoCst; this.orInternal = this.orInternalNoCst; this.optionInternal = this.optionInternalNoCst; this.atLeastOneInternal = this.atLeastOneInternalNoCst; this.manySepFirstInternal = this.manySepFirstInternalNoCst; this.atLeastOneSepFirstInternal = this.atLeastOneSepFirstInternalNoCst; } else { if (/full/i.test(this.nodeLocationTracking)) { if (this.recoveryEnabled) { this.setNodeLocationFromToken = cst_1.setNodeLocationFull; this.setNodeLocationFromNode = cst_1.setNodeLocationFull; this.cstPostRule = utils_1.NOOP; this.setInitialNodeLocation = this.setInitialNodeLocationFullRecovery; } else { this.setNodeLocationFromToken = utils_1.NOOP; this.setNodeLocationFromNode = utils_1.NOOP; this.cstPostRule = this.cstPostRuleFull; this.setInitialNodeLocation = this.setInitialNodeLocationFullRegular; } } else if (/onlyOffset/i.test(this.nodeLocationTracking)) { if (this.recoveryEnabled) { this.setNodeLocationFromToken = (cst_1.setNodeLocationOnlyOffset); this.setNodeLocationFromNode = (cst_1.setNodeLocationOnlyOffset); this.cstPostRule = utils_1.NOOP; this.setInitialNodeLocation = this.setInitialNodeLocationOnlyOffsetRecovery; } else { this.setNodeLocationFromToken = utils_1.NOOP; this.setNodeLocationFromNode = utils_1.NOOP; this.cstPostRule = this.cstPostRuleOnlyOffset; this.setInitialNodeLocation = this.setInitialNodeLocationOnlyOffsetRegular; } } else if (/none/i.test(this.nodeLocationTracking)) { this.setNodeLocationFromToken = utils_1.NOOP; this.setNodeLocationFromNode = utils_1.NOOP; this.cstPostRule = utils_1.NOOP; this.setInitialNodeLocation = utils_1.NOOP; } else { throw Error("Invalid config option: \"" + config.nodeLocationTracking + "\""); } } }; TreeBuilder.prototype.setInitialNodeLocationOnlyOffsetRecovery = function (cstNode) { cstNode.location = { startOffset: NaN, endOffset: NaN }; }; TreeBuilder.prototype.setInitialNodeLocationOnlyOffsetRegular = function (cstNode) { cstNode.location = { // without error recovery the starting Location of a new CstNode is guaranteed // To be the next Token's startOffset (for valid inputs). // For invalid inputs there won't be any CSTOutput so this potential // inaccuracy does not matter startOffset: this.LA(1).startOffset, endOffset: NaN }; }; TreeBuilder.prototype.setInitialNodeLocationFullRecovery = function (cstNode) { cstNode.location = { startOffset: NaN, startLine: NaN, startColumn: NaN, endOffset: NaN, endLine: NaN, endColumn: NaN }; }; /** * @see setInitialNodeLocationOnlyOffsetRegular for explanation why this work * @param cstNode */ TreeBuilder.prototype.setInitialNodeLocationFullRegular = function (cstNode) { var nextToken = this.LA(1); cstNode.location = { startOffset: nextToken.startOffset, startLine: nextToken.startLine, startColumn: nextToken.startColumn, endOffset: NaN, endLine: NaN, endColumn: NaN }; }; // CST TreeBuilder.prototype.cstNestedInvocationStateUpdate = function (nestedName, shortName) { var cstNode = { name: nestedName, fullName: this.shortRuleNameToFull[this.getLastExplicitRuleShortName()] + nestedName, children: {} }; this.setInitialNodeLocation(cstNode); this.CST_STACK.push(cstNode); }; TreeBuilder.prototype.cstInvocationStateUpdate = function (fullRuleName, shortName) { this.LAST_EXPLICIT_RULE_STACK.push(this.RULE_STACK.length - 1); var cstNode = { name: fullRuleName, children: {} }; this.setInitialNodeLocation(cstNode); this.CST_STACK.push(cstNode); }; TreeBuilder.prototype.cstFinallyStateUpdate = function () { this.LAST_EXPLICIT_RULE_STACK.pop(); this.CST_STACK.pop(); }; TreeBuilder.prototype.cstNestedFinallyStateUpdate = function () { var lastCstNode = this.CST_STACK.pop(); // TODO: the naming is bad, this should go directly to the // (correct) cstLocation update method // e.g if we put other logic in postRule... this.cstPostRule(lastCstNode); }; TreeBuilder.prototype.cstPostRuleFull = function (ruleCstNode) { var prevToken = this.LA(0); var loc = ruleCstNode.location; // If this condition is true it means we consumed at least one Token // In this CstNode or its nested children. if (loc.startOffset <= prevToken.startOffset === true) { loc.endOffset = prevToken.endOffset; loc.endLine = prevToken.endLine; loc.endColumn = prevToken.endColumn; } // "empty" CstNode edge case else { loc.startOffset = NaN; loc.startLine = NaN; loc.startColumn = NaN; } }; TreeBuilder.prototype.cstPostRuleOnlyOffset = function (ruleCstNode) { var prevToken = this.LA(0); var loc = ruleCstNode.location; // If this condition is true it means we consumed at least one Token // In this CstNode or its nested children. if (loc.startOffset <= prevToken.startOffset === true) { loc.endOffset = prevToken.endOffset; } // "empty" CstNode edge case else { loc.startOffset = NaN; } }; TreeBuilder.prototype.cstPostTerminal = function (key, consumedToken) { var rootCst = this.CST_STACK[this.CST_STACK.length - 1]; cst_1.addTerminalToCst(rootCst, consumedToken, key); // This is only used when **both** error recovery and CST Output are enabled. this.setNodeLocationFromToken(rootCst.location, consumedToken); }; TreeBuilder.prototype.cstPostNonTerminal = function (ruleCstResult, ruleName) { // Avoid side effects due to back tracking // TODO: This costs a 2-3% in performance, A flag on IParserConfig // could be used to get rid of this conditional, but not sure its worth the effort // and API complexity. if (this.isBackTracking() !== true) { var preCstNode = this.CST_STACK[this.CST_STACK.length - 1]; cst_1.addNoneTerminalToCst(preCstNode, ruleName, ruleCstResult); // This is only used when **both** error recovery and CST Output are enabled. this.setNodeLocationFromNode(preCstNode.location, ruleCstResult.location); } }; TreeBuilder.prototype.getBaseCstVisitorConstructor = function () { if (utils_1.isUndefined(this.baseCstVisitorConstructor)) { var newBaseCstVisitorConstructor = cst_visitor_1.createBaseSemanticVisitorConstructor(this.className, this.allRuleNames); this.baseCstVisitorConstructor = newBaseCstVisitorConstructor; return newBaseCstVisitorConstructor; } return this.baseCstVisitorConstructor; }; TreeBuilder.prototype.getBaseCstVisitorConstructorWithDefaults = function () { if (utils_1.isUndefined(this.baseCstVisitorWithDefaultsConstructor)) { var newConstructor = cst_visitor_1.createBaseVisitorConstructorWithDefaults(this.className, this.allRuleNames, this.getBaseCstVisitorConstructor()); this.baseCstVisitorWithDefaultsConstructor = newConstructor; return newConstructor; } return this.baseCstVisitorWithDefaultsConstructor; }; TreeBuilder.prototype.nestedRuleBeforeClause = function (methodOpts, laKey) { var nestedName; if (methodOpts.NAME !== undefined) { nestedName = methodOpts.NAME; this.nestedRuleInvocationStateUpdate(nestedName, laKey); return nestedName; } else { return undefined; } }; TreeBuilder.prototype.nestedAltBeforeClause = function (methodOpts, occurrence, methodKeyIdx, altIdx) { var ruleIdx = this.getLastExplicitRuleShortName(); var shortName = keys_1.getKeyForAltIndex(ruleIdx, methodKeyIdx, occurrence, altIdx); var nestedName; if (methodOpts.NAME !== undefined) { nestedName = methodOpts.NAME; this.nestedRuleInvocationStateUpdate(nestedName, shortName); return { shortName: shortName, nestedName: nestedName }; } else { return undefined; } }; TreeBuilder.prototype.nestedRuleFinallyClause = function (laKey, nestedName) { var cstStack = this.CST_STACK; var nestedRuleCst = cstStack[cstStack.length - 1]; this.nestedRuleFinallyStateUpdate(); // this return a different result than the previous invocation because "nestedRuleFinallyStateUpdate" pops the cst stack var parentCstNode = cstStack[cstStack.length - 1]; cst_1.addNoneTerminalToCst(parentCstNode, nestedName, nestedRuleCst); this.setNodeLocationFromNode(parentCstNode.location, nestedRuleCst.location); }; TreeBuilder.prototype.getLastExplicitRuleShortName = function () { var lastExplictIndex = this.LAST_EXPLICIT_RULE_STACK[this.LAST_EXPLICIT_RULE_STACK.length - 1]; return this.RULE_STACK[lastExplictIndex]; }; TreeBuilder.prototype.getLastExplicitRuleShortNameNoCst = function () { var ruleStack = this.RULE_STACK; return ruleStack[ruleStack.length - 1]; }; TreeBuilder.prototype.getPreviousExplicitRuleShortName = function () { var lastExplicitIndex = this.LAST_EXPLICIT_RULE_STACK[this.LAST_EXPLICIT_RULE_STACK.length - 2]; return this.RULE_STACK[lastExplicitIndex]; }; TreeBuilder.prototype.getPreviousExplicitRuleShortNameNoCst = function () { var ruleStack = this.RULE_STACK; return ruleStack[ruleStack.length - 2]; }; TreeBuilder.prototype.getLastExplicitRuleOccurrenceIndex = function () { var lastExplicitIndex = this.LAST_EXPLICIT_RULE_STACK[this.LAST_EXPLICIT_RULE_STACK.length - 1]; return this.RULE_OCCURRENCE_STACK[lastExplicitIndex]; }; TreeBuilder.prototype.getLastExplicitRuleOccurrenceIndexNoCst = function () { var occurrenceStack = this.RULE_OCCURRENCE_STACK; return occurrenceStack[occurrenceStack.length - 1]; }; TreeBuilder.prototype.nestedRuleInvocationStateUpdate = function (nestedRuleName, shortNameKey) { this.RULE_OCCURRENCE_STACK.push(1); this.RULE_STACK.push(shortNameKey); this.cstNestedInvocationStateUpdate(nestedRuleName, shortNameKey); }; TreeBuilder.prototype.nestedRuleFinallyStateUpdate = function () { this.RULE_STACK.pop(); this.RULE_OCCURRENCE_STACK.pop(); // NOOP when cst is disabled this.cstNestedFinallyStateUpdate(); }; return TreeBuilder; }()); exports.TreeBuilder = TreeBuilder; //# sourceMappingURL=tree_builder.js.map /***/ }), /* 32 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var lang_extensions_1 = __webpack_require__(26); var checks_1 = __webpack_require__(11); function defaultVisit(ctx, param) { var childrenNames = utils_1.keys(ctx); var childrenNamesLength = childrenNames.length; for (var i = 0; i < childrenNamesLength; i++) { var currChildName = childrenNames[i]; var currChildArray = ctx[currChildName]; var currChildArrayLength = currChildArray.length; for (var j = 0; j < currChildArrayLength; j++) { var currChild = currChildArray[j]; // distinction between Tokens Children and CstNode children if (currChild.tokenTypeIdx === undefined) { if (currChild.fullName !== undefined) { this[currChild.fullName](currChild.children, param); } else { this[currChild.name](currChild.children, param); } } } } // defaultVisit does not support generic out param return undefined; } exports.defaultVisit = defaultVisit; function createBaseSemanticVisitorConstructor(grammarName, ruleNames) { var derivedConstructor = function () { }; // can be overwritten according to: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/ // name?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FFunction%2Fname lang_extensions_1.defineNameProp(derivedConstructor, grammarName + "BaseSemantics"); var semanticProto = { visit: function (cstNode, param) { // enables writing more concise visitor methods when CstNode has only a single child if (utils_1.isArray(cstNode)) { // A CST Node's children dictionary can never have empty arrays as values // If a key is defined there will be at least one element in the corresponding value array. cstNode = cstNode[0]; } // enables passing optional CstNodes concisely. if (utils_1.isUndefined(cstNode)) { return undefined; } if (cstNode.fullName !== undefined) { return this[cstNode.fullName](cstNode.children, param); } else { return this[cstNode.name](cstNode.children, param); } }, validateVisitor: function () { var semanticDefinitionErrors = validateVisitor(this, ruleNames); if (!utils_1.isEmpty(semanticDefinitionErrors)) { var errorMessages = utils_1.map(semanticDefinitionErrors, function (currDefError) { return currDefError.msg; }); throw Error("Errors Detected in CST Visitor <" + lang_extensions_1.functionName(this.constructor) + ">:\n\t" + ("" + errorMessages.join("\n\n").replace(/\n/g, "\n\t"))); } } }; derivedConstructor.prototype = semanticProto; derivedConstructor.prototype.constructor = derivedConstructor; derivedConstructor._RULE_NAMES = ruleNames; return derivedConstructor; } exports.createBaseSemanticVisitorConstructor = createBaseSemanticVisitorConstructor; function createBaseVisitorConstructorWithDefaults(grammarName, ruleNames, baseConstructor) { var derivedConstructor = function () { }; // can be overwritten according to: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/ // name?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FFunction%2Fname lang_extensions_1.defineNameProp(derivedConstructor, grammarName + "BaseSemanticsWithDefaults"); var withDefaultsProto = Object.create(baseConstructor.prototype); utils_1.forEach(ruleNames, function (ruleName) { withDefaultsProto[ruleName] = defaultVisit; }); derivedConstructor.prototype = withDefaultsProto; derivedConstructor.prototype.constructor = derivedConstructor; return derivedConstructor; } exports.createBaseVisitorConstructorWithDefaults = createBaseVisitorConstructorWithDefaults; var CstVisitorDefinitionError; (function (CstVisitorDefinitionError) { CstVisitorDefinitionError[CstVisitorDefinitionError["REDUNDANT_METHOD"] = 0] = "REDUNDANT_METHOD"; CstVisitorDefinitionError[CstVisitorDefinitionError["MISSING_METHOD"] = 1] = "MISSING_METHOD"; })(CstVisitorDefinitionError = exports.CstVisitorDefinitionError || (exports.CstVisitorDefinitionError = {})); function validateVisitor(visitorInstance, ruleNames) { var missingErrors = validateMissingCstMethods(visitorInstance, ruleNames); var redundantErrors = validateRedundantMethods(visitorInstance, ruleNames); return missingErrors.concat(redundantErrors); } exports.validateVisitor = validateVisitor; function validateMissingCstMethods(visitorInstance, ruleNames) { var errors = utils_1.map(ruleNames, function (currRuleName) { if (!utils_1.isFunction(visitorInstance[currRuleName])) { return { msg: "Missing visitor method: <" + currRuleName + "> on " + lang_extensions_1.functionName(visitorInstance.constructor) + " CST Visitor.", type: CstVisitorDefinitionError.MISSING_METHOD, methodName: currRuleName }; } }); return utils_1.compact(errors); } exports.validateMissingCstMethods = validateMissingCstMethods; var VALID_PROP_NAMES = ["constructor", "visit", "validateVisitor"]; function validateRedundantMethods(visitorInstance, ruleNames) { var errors = []; for (var prop in visitorInstance) { if (checks_1.validTermsPattern.test(prop) && utils_1.isFunction(visitorInstance[prop]) && !utils_1.contains(VALID_PROP_NAMES, prop) && !utils_1.contains(ruleNames, prop)) { errors.push({ msg: "Redundant visitor method: <" + prop + "> on " + lang_extensions_1.functionName(visitorInstance.constructor) + " CST Visitor\n" + "There is no Grammar Rule corresponding to this method's name.\n" + ("For utility methods on visitor classes use methods names that do not match /" + checks_1.validTermsPattern.source + "/."), type: CstVisitorDefinitionError.REDUNDANT_METHOD, methodName: prop }); } } return errors; } exports.validateRedundantMethods = validateRedundantMethods; //# sourceMappingURL=cst_visitor.js.map /***/ }), /* 33 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var parser_1 = __webpack_require__(2); /** * Trait responsible abstracting over the interaction with Lexer output (Token vector). * * This could be generalized to support other kinds of lexers, e.g. * - Just in Time Lexing / Lexer-Less parsing. * - Streaming Lexer. */ var LexerAdapter = /** @class */ (function () { function LexerAdapter() { } LexerAdapter.prototype.initLexerAdapter = function () { this.tokVector = []; this.tokVectorLength = 0; this.currIdx = -1; }; Object.defineProperty(LexerAdapter.prototype, "input", { get: function () { return this.tokVector; }, set: function (newInput) { if (this.selfAnalysisDone !== true) { throw Error("Missing invocation at the end of the Parser's constructor."); } this.reset(); this.tokVector = newInput; this.tokVectorLength = newInput.length; }, enumerable: true, configurable: true }); // skips a token and returns the next token LexerAdapter.prototype.SKIP_TOKEN = function () { if (this.currIdx <= this.tokVector.length - 2) { this.consumeToken(); return this.LA(1); } else { return parser_1.END_OF_FILE; } }; // Lexer (accessing Token vector) related methods which can be overridden to implement lazy lexers // or lexers dependent on parser context. LexerAdapter.prototype.LA = function (howMuch) { var soughtIdx = this.currIdx + howMuch; if (soughtIdx < 0 || this.tokVectorLength <= soughtIdx) { return parser_1.END_OF_FILE; } else { return this.tokVector[soughtIdx]; } }; LexerAdapter.prototype.consumeToken = function () { this.currIdx++; }; LexerAdapter.prototype.exportLexerState = function () { return this.currIdx; }; LexerAdapter.prototype.importLexerState = function (newState) { this.currIdx = newState; }; LexerAdapter.prototype.resetLexerState = function () { this.currIdx = -1; }; LexerAdapter.prototype.moveToTerminatedState = function () { this.currIdx = this.tokVector.length - 1; }; LexerAdapter.prototype.getLexerPosition = function () { return this.exportLexerState(); }; return LexerAdapter; }()); exports.LexerAdapter = LexerAdapter; //# sourceMappingURL=lexer_adapter.js.map /***/ }), /* 34 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var exceptions_public_1 = __webpack_require__(8); var parser_1 = __webpack_require__(2); var errors_public_1 = __webpack_require__(10); var checks_1 = __webpack_require__(11); var gast_public_1 = __webpack_require__(1); /** * This trait is responsible for implementing the public API * for defining Chevrotain parsers, i.e: * - CONSUME * - RULE * - OPTION * - ... */ var RecognizerApi = /** @class */ (function () { function RecognizerApi() { } RecognizerApi.prototype.ACTION = function (impl) { return impl.call(this); }; RecognizerApi.prototype.consume = function (idx, tokType, options) { return this.consumeInternal(tokType, idx, options); }; RecognizerApi.prototype.subrule = function (idx, ruleToCall, options) { return this.subruleInternal(ruleToCall, idx, options); }; RecognizerApi.prototype.option = function (idx, actionORMethodDef) { return this.optionInternal(actionORMethodDef, idx); }; RecognizerApi.prototype.or = function (idx, altsOrOpts) { return this.orInternal(altsOrOpts, idx); }; RecognizerApi.prototype.many = function (idx, actionORMethodDef) { return this.manyInternal(idx, actionORMethodDef); }; RecognizerApi.prototype.atLeastOne = function (idx, actionORMethodDef) { return this.atLeastOneInternal(idx, actionORMethodDef); }; RecognizerApi.prototype.CONSUME = function (tokType, options) { return this.consumeInternal(tokType, 0, options); }; RecognizerApi.prototype.CONSUME1 = function (tokType, options) { return this.consumeInternal(tokType, 1, options); }; RecognizerApi.prototype.CONSUME2 = function (tokType, options) { return this.consumeInternal(tokType, 2, options); }; RecognizerApi.prototype.CONSUME3 = function (tokType, options) { return this.consumeInternal(tokType, 3, options); }; RecognizerApi.prototype.CONSUME4 = function (tokType, options) { return this.consumeInternal(tokType, 4, options); }; RecognizerApi.prototype.CONSUME5 = function (tokType, options) { return this.consumeInternal(tokType, 5, options); }; RecognizerApi.prototype.CONSUME6 = function (tokType, options) { return this.consumeInternal(tokType, 6, options); }; RecognizerApi.prototype.CONSUME7 = function (tokType, options) { return this.consumeInternal(tokType, 7, options); }; RecognizerApi.prototype.CONSUME8 = function (tokType, options) { return this.consumeInternal(tokType, 8, options); }; RecognizerApi.prototype.CONSUME9 = function (tokType, options) { return this.consumeInternal(tokType, 9, options); }; RecognizerApi.prototype.SUBRULE = function (ruleToCall, options) { return this.subruleInternal(ruleToCall, 0, options); }; RecognizerApi.prototype.SUBRULE1 = function (ruleToCall, options) { return this.subruleInternal(ruleToCall, 1, options); }; RecognizerApi.prototype.SUBRULE2 = function (ruleToCall, options) { return this.subruleInternal(ruleToCall, 2, options); }; RecognizerApi.prototype.SUBRULE3 = function (ruleToCall, options) { return this.subruleInternal(ruleToCall, 3, options); }; RecognizerApi.prototype.SUBRULE4 = function (ruleToCall, options) { return this.subruleInternal(ruleToCall, 4, options); }; RecognizerApi.prototype.SUBRULE5 = function (ruleToCall, options) { return this.subruleInternal(ruleToCall, 5, options); }; RecognizerApi.prototype.SUBRULE6 = function (ruleToCall, options) { return this.subruleInternal(ruleToCall, 6, options); }; RecognizerApi.prototype.SUBRULE7 = function (ruleToCall, options) { return this.subruleInternal(ruleToCall, 7, options); }; RecognizerApi.prototype.SUBRULE8 = function (ruleToCall, options) { return this.subruleInternal(ruleToCall, 8, options); }; RecognizerApi.prototype.SUBRULE9 = function (ruleToCall, options) { return this.subruleInternal(ruleToCall, 9, options); }; RecognizerApi.prototype.OPTION = function (actionORMethodDef) { return this.optionInternal(actionORMethodDef, 0); }; RecognizerApi.prototype.OPTION1 = function (actionORMethodDef) { return this.optionInternal(actionORMethodDef, 1); }; RecognizerApi.prototype.OPTION2 = function (actionORMethodDef) { return this.optionInternal(actionORMethodDef, 2); }; RecognizerApi.prototype.OPTION3 = function (actionORMethodDef) { return this.optionInternal(actionORMethodDef, 3); }; RecognizerApi.prototype.OPTION4 = function (actionORMethodDef) { return this.optionInternal(actionORMethodDef, 4); }; RecognizerApi.prototype.OPTION5 = function (actionORMethodDef) { return this.optionInternal(actionORMethodDef, 5); }; RecognizerApi.prototype.OPTION6 = function (actionORMethodDef) { return this.optionInternal(actionORMethodDef, 6); }; RecognizerApi.prototype.OPTION7 = function (actionORMethodDef) { return this.optionInternal(actionORMethodDef, 7); }; RecognizerApi.prototype.OPTION8 = function (actionORMethodDef) { return this.optionInternal(actionORMethodDef, 8); }; RecognizerApi.prototype.OPTION9 = function (actionORMethodDef) { return this.optionInternal(actionORMethodDef, 9); }; RecognizerApi.prototype.OR = function (altsOrOpts) { return this.orInternal(altsOrOpts, 0); }; RecognizerApi.prototype.OR1 = function (altsOrOpts) { return this.orInternal(altsOrOpts, 1); }; RecognizerApi.prototype.OR2 = function (altsOrOpts) { return this.orInternal(altsOrOpts, 2); }; RecognizerApi.prototype.OR3 = function (altsOrOpts) { return this.orInternal(altsOrOpts, 3); }; RecognizerApi.prototype.OR4 = function (altsOrOpts) { return this.orInternal(altsOrOpts, 4); }; RecognizerApi.prototype.OR5 = function (altsOrOpts) { return this.orInternal(altsOrOpts, 5); }; RecognizerApi.prototype.OR6 = function (altsOrOpts) { return this.orInternal(altsOrOpts, 6); }; RecognizerApi.prototype.OR7 = function (altsOrOpts) { return this.orInternal(altsOrOpts, 7); }; RecognizerApi.prototype.OR8 = function (altsOrOpts) { return this.orInternal(altsOrOpts, 8); }; RecognizerApi.prototype.OR9 = function (altsOrOpts) { return this.orInternal(altsOrOpts, 9); }; RecognizerApi.prototype.MANY = function (actionORMethodDef) { this.manyInternal(0, actionORMethodDef); }; RecognizerApi.prototype.MANY1 = function (actionORMethodDef) { this.manyInternal(1, actionORMethodDef); }; RecognizerApi.prototype.MANY2 = function (actionORMethodDef) { this.manyInternal(2, actionORMethodDef); }; RecognizerApi.prototype.MANY3 = function (actionORMethodDef) { this.manyInternal(3, actionORMethodDef); }; RecognizerApi.prototype.MANY4 = function (actionORMethodDef) { this.manyInternal(4, actionORMethodDef); }; RecognizerApi.prototype.MANY5 = function (actionORMethodDef) { this.manyInternal(5, actionORMethodDef); }; RecognizerApi.prototype.MANY6 = function (actionORMethodDef) { this.manyInternal(6, actionORMethodDef); }; RecognizerApi.prototype.MANY7 = function (actionORMethodDef) { this.manyInternal(7, actionORMethodDef); }; RecognizerApi.prototype.MANY8 = function (actionORMethodDef) { this.manyInternal(8, actionORMethodDef); }; RecognizerApi.prototype.MANY9 = function (actionORMethodDef) { this.manyInternal(9, actionORMethodDef); }; RecognizerApi.prototype.MANY_SEP = function (options) { this.manySepFirstInternal(0, options); }; RecognizerApi.prototype.MANY_SEP1 = function (options) { this.manySepFirstInternal(1, options); }; RecognizerApi.prototype.MANY_SEP2 = function (options) { this.manySepFirstInternal(2, options); }; RecognizerApi.prototype.MANY_SEP3 = function (options) { this.manySepFirstInternal(3, options); }; RecognizerApi.prototype.MANY_SEP4 = function (options) { this.manySepFirstInternal(4, options); }; RecognizerApi.prototype.MANY_SEP5 = function (options) { this.manySepFirstInternal(5, options); }; RecognizerApi.prototype.MANY_SEP6 = function (options) { this.manySepFirstInternal(6, options); }; RecognizerApi.prototype.MANY_SEP7 = function (options) { this.manySepFirstInternal(7, options); }; RecognizerApi.prototype.MANY_SEP8 = function (options) { this.manySepFirstInternal(8, options); }; RecognizerApi.prototype.MANY_SEP9 = function (options) { this.manySepFirstInternal(9, options); }; RecognizerApi.prototype.AT_LEAST_ONE = function (actionORMethodDef) { this.atLeastOneInternal(0, actionORMethodDef); }; RecognizerApi.prototype.AT_LEAST_ONE1 = function (actionORMethodDef) { return this.atLeastOneInternal(1, actionORMethodDef); }; RecognizerApi.prototype.AT_LEAST_ONE2 = function (actionORMethodDef) { this.atLeastOneInternal(2, actionORMethodDef); }; RecognizerApi.prototype.AT_LEAST_ONE3 = function (actionORMethodDef) { this.atLeastOneInternal(3, actionORMethodDef); }; RecognizerApi.prototype.AT_LEAST_ONE4 = function (actionORMethodDef) { this.atLeastOneInternal(4, actionORMethodDef); }; RecognizerApi.prototype.AT_LEAST_ONE5 = function (actionORMethodDef) { this.atLeastOneInternal(5, actionORMethodDef); }; RecognizerApi.prototype.AT_LEAST_ONE6 = function (actionORMethodDef) { this.atLeastOneInternal(6, actionORMethodDef); }; RecognizerApi.prototype.AT_LEAST_ONE7 = function (actionORMethodDef) { this.atLeastOneInternal(7, actionORMethodDef); }; RecognizerApi.prototype.AT_LEAST_ONE8 = function (actionORMethodDef) { this.atLeastOneInternal(8, actionORMethodDef); }; RecognizerApi.prototype.AT_LEAST_ONE9 = function (actionORMethodDef) { this.atLeastOneInternal(9, actionORMethodDef); }; RecognizerApi.prototype.AT_LEAST_ONE_SEP = function (options) { this.atLeastOneSepFirstInternal(0, options); }; RecognizerApi.prototype.AT_LEAST_ONE_SEP1 = function (options) { this.atLeastOneSepFirstInternal(1, options); }; RecognizerApi.prototype.AT_LEAST_ONE_SEP2 = function (options) { this.atLeastOneSepFirstInternal(2, options); }; RecognizerApi.prototype.AT_LEAST_ONE_SEP3 = function (options) { this.atLeastOneSepFirstInternal(3, options); }; RecognizerApi.prototype.AT_LEAST_ONE_SEP4 = function (options) { this.atLeastOneSepFirstInternal(4, options); }; RecognizerApi.prototype.AT_LEAST_ONE_SEP5 = function (options) { this.atLeastOneSepFirstInternal(5, options); }; RecognizerApi.prototype.AT_LEAST_ONE_SEP6 = function (options) { this.atLeastOneSepFirstInternal(6, options); }; RecognizerApi.prototype.AT_LEAST_ONE_SEP7 = function (options) { this.atLeastOneSepFirstInternal(7, options); }; RecognizerApi.prototype.AT_LEAST_ONE_SEP8 = function (options) { this.atLeastOneSepFirstInternal(8, options); }; RecognizerApi.prototype.AT_LEAST_ONE_SEP9 = function (options) { this.atLeastOneSepFirstInternal(9, options); }; RecognizerApi.prototype.RULE = function (name, implementation, config) { if (config === void 0) { config = parser_1.DEFAULT_RULE_CONFIG; } if (utils_1.contains(this.definedRulesNames, name)) { var errMsg = errors_public_1.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({ topLevelRule: name, grammarName: this.className }); var error = { message: errMsg, type: parser_1.ParserDefinitionErrorType.DUPLICATE_RULE_NAME, ruleName: name }; this.definitionErrors.push(error); } this.definedRulesNames.push(name); var ruleImplementation = this.defineRule(name, implementation, config); this[name] = ruleImplementation; return ruleImplementation; }; RecognizerApi.prototype.OVERRIDE_RULE = function (name, impl, config) { if (config === void 0) { config = parser_1.DEFAULT_RULE_CONFIG; } var ruleErrors = []; ruleErrors = ruleErrors.concat(checks_1.validateRuleIsOverridden(name, this.definedRulesNames, this.className)); this.definitionErrors.push.apply(this.definitionErrors, ruleErrors); // mutability for the win var ruleImplementation = this.defineRule(name, impl, config); this[name] = ruleImplementation; return ruleImplementation; }; RecognizerApi.prototype.BACKTRACK = function (grammarRule, args) { return function () { // save org state this.isBackTrackingStack.push(1); var orgState = this.saveRecogState(); try { grammarRule.apply(this, args); // if no exception was thrown we have succeed parsing the rule. return true; } catch (e) { if (exceptions_public_1.isRecognitionException(e)) { return false; } else { throw e; } } finally { this.reloadRecogState(orgState); this.isBackTrackingStack.pop(); } }; }; // GAST export APIs RecognizerApi.prototype.getGAstProductions = function () { return this.gastProductionsCache; }; RecognizerApi.prototype.getSerializedGastProductions = function () { return gast_public_1.serializeGrammar(utils_1.values(this.gastProductionsCache)); }; return RecognizerApi; }()); exports.RecognizerApi = RecognizerApi; //# sourceMappingURL=recognizer_api.js.map /***/ }), /* 35 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var keys_1 = __webpack_require__(7); var exceptions_public_1 = __webpack_require__(8); var lookahead_1 = __webpack_require__(12); var interpreter_1 = __webpack_require__(13); var parser_1 = __webpack_require__(2); var recoverable_1 = __webpack_require__(25); var tokens_public_1 = __webpack_require__(3); var tokens_1 = __webpack_require__(5); var lang_extensions_1 = __webpack_require__(26); /** * This trait is responsible for the runtime parsing engine * Used by the official API (recognizer_api.ts) */ var RecognizerEngine = /** @class */ (function () { function RecognizerEngine() { } RecognizerEngine.prototype.initRecognizerEngine = function (tokenVocabulary, config) { this.className = lang_extensions_1.classNameFromInstance(this); // TODO: would using an ES6 Map or plain object be faster (CST building scenario) this.shortRuleNameToFull = {}; this.fullRuleNameToShort = {}; this.ruleShortNameIdx = 256; this.tokenMatcher = tokens_1.tokenStructuredMatcherNoCategories; this.definedRulesNames = []; this.tokensMap = {}; this.allRuleNames = []; this.isBackTrackingStack = []; this.RULE_STACK = []; this.RULE_OCCURRENCE_STACK = []; this.gastProductionsCache = {}; if (utils_1.has(config, "serializedGrammar")) { throw Error("The Parser's configuration can no longer contain a property.\n" + "\tSee: https://sap.github.io/chevrotain/docs/changes/BREAKING_CHANGES.html#_6-0-0\n" + "\tFor Further details."); } if (utils_1.isArray(tokenVocabulary)) { // This only checks for Token vocabularies provided as arrays. // That is good enough because the main objective is to detect users of pre-V4.0 APIs // rather than all edge cases of empty Token vocabularies. if (utils_1.isEmpty(tokenVocabulary)) { throw Error("A Token Vocabulary cannot be empty.\n" + "\tNote that the first argument for the parser constructor\n" + "\tis no longer a Token vector (since v4.0)."); } if (typeof tokenVocabulary[0].startOffset === "number") { throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n" + "\tSee: https://sap.github.io/chevrotain/docs/changes/BREAKING_CHANGES.html#_4-0-0\n" + "\tFor Further details."); } } if (utils_1.isArray(tokenVocabulary)) { this.tokensMap = utils_1.reduce(tokenVocabulary, function (acc, tokType) { acc[tokType.name] = tokType; return acc; }, {}); } else if (utils_1.has(tokenVocabulary, "modes") && utils_1.every(utils_1.flatten(utils_1.values(tokenVocabulary.modes)), tokens_1.isTokenType)) { var allTokenTypes = utils_1.flatten(utils_1.values(tokenVocabulary.modes)); var uniqueTokens = utils_1.uniq(allTokenTypes); this.tokensMap = utils_1.reduce(uniqueTokens, function (acc, tokType) { acc[tokType.name] = tokType; return acc; }, {}); } else if (utils_1.isObject(tokenVocabulary)) { this.tokensMap = utils_1.cloneObj(tokenVocabulary); } else { throw new Error(" argument must be An Array of Token constructors," + " A dictionary of Token constructors or an IMultiModeLexerDefinition"); } // always add EOF to the tokenNames -> constructors map. it is useful to assure all the input has been // parsed with a clear error message ("expecting EOF but found ...") /* tslint:disable */ this.tokensMap["EOF"] = tokens_public_1.EOF; // TODO: This check may not be accurate for multi mode lexers var noTokenCategoriesUsed = utils_1.every(utils_1.values(tokenVocabulary), function (tokenConstructor) { return utils_1.isEmpty(tokenConstructor.categoryMatches); }); this.tokenMatcher = noTokenCategoriesUsed ? tokens_1.tokenStructuredMatcherNoCategories : tokens_1.tokenStructuredMatcher; // Because ES2015+ syntax should be supported for creating Token classes // We cannot assume that the Token classes were created using the "extendToken" utilities // Therefore we must augment the Token classes both on Lexer initialization and on Parser initialization tokens_1.augmentTokenTypes(utils_1.values(this.tokensMap)); }; RecognizerEngine.prototype.defineRule = function (ruleName, impl, config) { if (this.selfAnalysisDone) { throw Error("Grammar rule <" + ruleName + "> may not be defined after the 'performSelfAnalysis' method has been called'\n" + "Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called."); } var resyncEnabled = utils_1.has(config, "resyncEnabled") ? config.resyncEnabled : parser_1.DEFAULT_RULE_CONFIG.resyncEnabled; var recoveryValueFunc = utils_1.has(config, "recoveryValueFunc") ? config.recoveryValueFunc : parser_1.DEFAULT_RULE_CONFIG.recoveryValueFunc; // performance optimization: Use small integers as keys for the longer human readable "full" rule names. // this greatly improves Map access time (as much as 8% for some performance benchmarks). /* tslint:disable */ var shortName = this.ruleShortNameIdx << (keys_1.BITS_FOR_METHOD_TYPE + keys_1.BITS_FOR_OCCURRENCE_IDX); /* tslint:enable */ this.ruleShortNameIdx++; this.shortRuleNameToFull[shortName] = ruleName; this.fullRuleNameToShort[ruleName] = shortName; function invokeRuleWithTry(args) { try { if (this.outputCst === true) { impl.apply(this, args); var cst = this.CST_STACK[this.CST_STACK.length - 1]; this.cstPostRule(cst); return cst; } else { return impl.apply(this, args); } } catch (e) { return this.invokeRuleCatch(e, resyncEnabled, recoveryValueFunc); } finally { this.ruleFinallyStateUpdate(); } } var wrappedGrammarRule; wrappedGrammarRule = function (idxInCallingRule, args) { if (idxInCallingRule === void 0) { idxInCallingRule = 0; } this.ruleInvocationStateUpdate(shortName, ruleName, idxInCallingRule); return invokeRuleWithTry.call(this, args); }; var ruleNamePropName = "ruleName"; wrappedGrammarRule[ruleNamePropName] = ruleName; wrappedGrammarRule["originalGrammarAction"] = impl; return wrappedGrammarRule; }; RecognizerEngine.prototype.invokeRuleCatch = function (e, resyncEnabledConfig, recoveryValueFunc) { var isFirstInvokedRule = this.RULE_STACK.length === 1; // note the reSync is always enabled for the first rule invocation, because we must always be able to // reSync with EOF and just output some INVALID ParseTree // during backtracking reSync recovery is disabled, otherwise we can't be certain the backtracking // path is really the most valid one var reSyncEnabled = resyncEnabledConfig && !this.isBackTracking() && this.recoveryEnabled; if (exceptions_public_1.isRecognitionException(e)) { var recogError = e; if (reSyncEnabled) { var reSyncTokType = this.findReSyncTokenType(); if (this.isInCurrentRuleReSyncSet(reSyncTokType)) { recogError.resyncedTokens = this.reSyncTo(reSyncTokType); if (this.outputCst) { var partialCstResult = this.CST_STACK[this.CST_STACK.length - 1]; partialCstResult.recoveredNode = true; return partialCstResult; } else { return recoveryValueFunc(); } } else { if (this.outputCst) { var partialCstResult = this.CST_STACK[this.CST_STACK.length - 1]; partialCstResult.recoveredNode = true; recogError.partialCstResult = partialCstResult; } // to be handled Further up the call stack throw recogError; } } else if (isFirstInvokedRule) { // otherwise a Redundant input error will be created as well and we cannot guarantee that this is indeed the case this.moveToTerminatedState(); // the parser should never throw one of its own errors outside its flow. // even if error recovery is disabled return recoveryValueFunc(); } else { // to be recovered Further up the call stack throw recogError; } } else { // some other Error type which we don't know how to handle (for example a built in JavaScript Error) throw e; } }; // Implementation of parsing DSL RecognizerEngine.prototype.optionInternal = function (actionORMethodDef, occurrence) { var key = this.getKeyForAutomaticLookahead(keys_1.OPTION_IDX, occurrence); var nestedName = this.nestedRuleBeforeClause(actionORMethodDef, key); try { return this.optionInternalLogic(actionORMethodDef, occurrence, key); } finally { if (nestedName !== undefined) { this.nestedRuleFinallyClause(key, nestedName); } } }; RecognizerEngine.prototype.optionInternalNoCst = function (actionORMethodDef, occurrence) { var key = this.getKeyForAutomaticLookahead(keys_1.OPTION_IDX, occurrence); return this.optionInternalLogic(actionORMethodDef, occurrence, key); }; RecognizerEngine.prototype.optionInternalLogic = function (actionORMethodDef, occurrence, key) { var _this = this; var lookAheadFunc = this.getLaFuncFromCache(key); var action; var predicate; if (actionORMethodDef.DEF !== undefined) { action = actionORMethodDef.DEF; predicate = actionORMethodDef.GATE; // predicate present if (predicate !== undefined) { var orgLookaheadFunction_1 = lookAheadFunc; lookAheadFunc = function () { return (predicate.call(_this) && orgLookaheadFunction_1.call(_this)); }; } } else { action = actionORMethodDef; } if (lookAheadFunc.call(this) === true) { return action.call(this); } return undefined; }; RecognizerEngine.prototype.atLeastOneInternal = function (prodOccurrence, actionORMethodDef) { var laKey = this.getKeyForAutomaticLookahead(keys_1.AT_LEAST_ONE_IDX, prodOccurrence); var nestedName = this.nestedRuleBeforeClause(actionORMethodDef, laKey); try { return this.atLeastOneInternalLogic(prodOccurrence, actionORMethodDef, laKey); } finally { if (nestedName !== undefined) { this.nestedRuleFinallyClause(laKey, nestedName); } } }; RecognizerEngine.prototype.atLeastOneInternalNoCst = function (prodOccurrence, actionORMethodDef) { var key = this.getKeyForAutomaticLookahead(keys_1.AT_LEAST_ONE_IDX, prodOccurrence); this.atLeastOneInternalLogic(prodOccurrence, actionORMethodDef, key); }; RecognizerEngine.prototype.atLeastOneInternalLogic = function (prodOccurrence, actionORMethodDef, key) { var _this = this; var lookAheadFunc = this.getLaFuncFromCache(key); var action; var predicate; if (actionORMethodDef.DEF !== undefined) { action = actionORMethodDef.DEF; predicate = actionORMethodDef.GATE; // predicate present if (predicate !== undefined) { var orgLookaheadFunction_2 = lookAheadFunc; lookAheadFunc = function () { return (predicate.call(_this) && orgLookaheadFunction_2.call(_this)); }; } } else { action = actionORMethodDef; } if (lookAheadFunc.call(this) === true) { var notStuck = this.doSingleRepetition(action); while (lookAheadFunc.call(this) === true && notStuck === true) { notStuck = this.doSingleRepetition(action); } } else { throw this.raiseEarlyExitException(prodOccurrence, lookahead_1.PROD_TYPE.REPETITION_MANDATORY, actionORMethodDef.ERR_MSG); } // note that while it may seem that this can cause an error because by using a recursive call to // AT_LEAST_ONE we change the grammar to AT_LEAST_TWO, AT_LEAST_THREE ... , the possible recursive call // from the tryInRepetitionRecovery(...) will only happen IFF there really are TWO/THREE/.... items. // Performance optimization: "attemptInRepetitionRecovery" will be defined as NOOP unless recovery is enabled this.attemptInRepetitionRecovery(this.atLeastOneInternal, [prodOccurrence, actionORMethodDef], lookAheadFunc, keys_1.AT_LEAST_ONE_IDX, prodOccurrence, interpreter_1.NextTerminalAfterAtLeastOneWalker); }; RecognizerEngine.prototype.atLeastOneSepFirstInternal = function (prodOccurrence, options) { var laKey = this.getKeyForAutomaticLookahead(keys_1.AT_LEAST_ONE_SEP_IDX, prodOccurrence); var nestedName = this.nestedRuleBeforeClause(options, laKey); try { this.atLeastOneSepFirstInternalLogic(prodOccurrence, options, laKey); } finally { if (nestedName !== undefined) { this.nestedRuleFinallyClause(laKey, nestedName); } } }; RecognizerEngine.prototype.atLeastOneSepFirstInternalNoCst = function (prodOccurrence, options) { var laKey = this.getKeyForAutomaticLookahead(keys_1.AT_LEAST_ONE_SEP_IDX, prodOccurrence); this.atLeastOneSepFirstInternalLogic(prodOccurrence, options, laKey); }; RecognizerEngine.prototype.atLeastOneSepFirstInternalLogic = function (prodOccurrence, options, key) { var _this = this; var action = options.DEF; var separator = options.SEP; var firstIterationLookaheadFunc = this.getLaFuncFromCache(key); // 1st iteration if (firstIterationLookaheadFunc.call(this) === true) { ; action.call(this); // TODO: Optimization can move this function construction into "attemptInRepetitionRecovery" // because it is only needed in error recovery scenarios. var separatorLookAheadFunc = function () { return _this.tokenMatcher(_this.LA(1), separator); }; // 2nd..nth iterations while (this.tokenMatcher(this.LA(1), separator) === true) { // note that this CONSUME will never enter recovery because // the separatorLookAheadFunc checks that the separator really does exist. this.CONSUME(separator); action.call(this); } // Performance optimization: "attemptInRepetitionRecovery" will be defined as NOOP unless recovery is enabled this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal, [ prodOccurrence, separator, separatorLookAheadFunc, action, interpreter_1.NextTerminalAfterAtLeastOneSepWalker ], separatorLookAheadFunc, keys_1.AT_LEAST_ONE_SEP_IDX, prodOccurrence, interpreter_1.NextTerminalAfterAtLeastOneSepWalker); } else { throw this.raiseEarlyExitException(prodOccurrence, lookahead_1.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR, options.ERR_MSG); } }; RecognizerEngine.prototype.manyInternal = function (prodOccurrence, actionORMethodDef) { var laKey = this.getKeyForAutomaticLookahead(keys_1.MANY_IDX, prodOccurrence); var nestedName = this.nestedRuleBeforeClause(actionORMethodDef, laKey); try { return this.manyInternalLogic(prodOccurrence, actionORMethodDef, laKey); } finally { if (nestedName !== undefined) { this.nestedRuleFinallyClause(laKey, nestedName); } } }; RecognizerEngine.prototype.manyInternalNoCst = function (prodOccurrence, actionORMethodDef) { var laKey = this.getKeyForAutomaticLookahead(keys_1.MANY_IDX, prodOccurrence); return this.manyInternalLogic(prodOccurrence, actionORMethodDef, laKey); }; RecognizerEngine.prototype.manyInternalLogic = function (prodOccurrence, actionORMethodDef, key) { var _this = this; var lookaheadFunction = this.getLaFuncFromCache(key); var action; var predicate; if (actionORMethodDef.DEF !== undefined) { action = actionORMethodDef.DEF; predicate = actionORMethodDef.GATE; // predicate present if (predicate !== undefined) { var orgLookaheadFunction_3 = lookaheadFunction; lookaheadFunction = function () { return (predicate.call(_this) && orgLookaheadFunction_3.call(_this)); }; } } else { action = actionORMethodDef; } var notStuck = true; while (lookaheadFunction.call(this) === true && notStuck === true) { notStuck = this.doSingleRepetition(action); } // Performance optimization: "attemptInRepetitionRecovery" will be defined as NOOP unless recovery is enabled this.attemptInRepetitionRecovery(this.manyInternal, [prodOccurrence, actionORMethodDef], lookaheadFunction, keys_1.MANY_IDX, prodOccurrence, interpreter_1.NextTerminalAfterManyWalker, // The notStuck parameter is only relevant when "attemptInRepetitionRecovery" // is invoked from manyInternal, in the MANY_SEP case and AT_LEAST_ONE[_SEP] // An infinite loop cannot occur as: // - Either the lookahead is guaranteed to consume something (Single Token Separator) // - AT_LEAST_ONE by definition is guaranteed to consume something (or error out). notStuck); }; RecognizerEngine.prototype.manySepFirstInternal = function (prodOccurrence, options) { var laKey = this.getKeyForAutomaticLookahead(keys_1.MANY_SEP_IDX, prodOccurrence); var nestedName = this.nestedRuleBeforeClause(options, laKey); try { this.manySepFirstInternalLogic(prodOccurrence, options, laKey); } finally { if (nestedName !== undefined) { this.nestedRuleFinallyClause(laKey, nestedName); } } }; RecognizerEngine.prototype.manySepFirstInternalNoCst = function (prodOccurrence, options) { var laKey = this.getKeyForAutomaticLookahead(keys_1.MANY_SEP_IDX, prodOccurrence); this.manySepFirstInternalLogic(prodOccurrence, options, laKey); }; RecognizerEngine.prototype.manySepFirstInternalLogic = function (prodOccurrence, options, key) { var _this = this; var action = options.DEF; var separator = options.SEP; var firstIterationLaFunc = this.getLaFuncFromCache(key); // 1st iteration if (firstIterationLaFunc.call(this) === true) { action.call(this); var separatorLookAheadFunc = function () { return _this.tokenMatcher(_this.LA(1), separator); }; // 2nd..nth iterations while (this.tokenMatcher(this.LA(1), separator) === true) { // note that this CONSUME will never enter recovery because // the separatorLookAheadFunc checks that the separator really does exist. this.CONSUME(separator); // No need for checking infinite loop here due to consuming the separator. action.call(this); } // Performance optimization: "attemptInRepetitionRecovery" will be defined as NOOP unless recovery is enabled this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal, [ prodOccurrence, separator, separatorLookAheadFunc, action, interpreter_1.NextTerminalAfterManySepWalker ], separatorLookAheadFunc, keys_1.MANY_SEP_IDX, prodOccurrence, interpreter_1.NextTerminalAfterManySepWalker); } }; RecognizerEngine.prototype.repetitionSepSecondInternal = function (prodOccurrence, separator, separatorLookAheadFunc, action, nextTerminalAfterWalker) { while (separatorLookAheadFunc()) { // note that this CONSUME will never enter recovery because // the separatorLookAheadFunc checks that the separator really does exist. this.CONSUME(separator); action.call(this); } // we can only arrive to this function after an error // has occurred (hence the name 'second') so the following // IF will always be entered, its possible to remove it... // however it is kept to avoid confusion and be consistent. // Performance optimization: "attemptInRepetitionRecovery" will be defined as NOOP unless recovery is enabled /* istanbul ignore else */ this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal, [ prodOccurrence, separator, separatorLookAheadFunc, action, nextTerminalAfterWalker ], separatorLookAheadFunc, keys_1.AT_LEAST_ONE_SEP_IDX, prodOccurrence, nextTerminalAfterWalker); }; RecognizerEngine.prototype.doSingleRepetition = function (action) { var beforeIteration = this.getLexerPosition(); action.call(this); var afterIteration = this.getLexerPosition(); // This boolean will indicate if this repetition progressed // or if we are "stuck" (potential infinite loop in the repetition). return afterIteration > beforeIteration; }; RecognizerEngine.prototype.orInternalNoCst = function (altsOrOpts, occurrence) { var alts = utils_1.isArray(altsOrOpts) ? altsOrOpts : altsOrOpts.DEF; var laKey = this.getKeyForAutomaticLookahead(keys_1.OR_IDX, occurrence); var laFunc = this.getLaFuncFromCache(laKey); var altIdxToTake = laFunc.call(this, alts); if (altIdxToTake !== undefined) { var chosenAlternative = alts[altIdxToTake]; return chosenAlternative.ALT.call(this); } this.raiseNoAltException(occurrence, altsOrOpts.ERR_MSG); }; RecognizerEngine.prototype.orInternal = function (altsOrOpts, occurrence) { var laKey = this.getKeyForAutomaticLookahead(keys_1.OR_IDX, occurrence); var nestedName = this.nestedRuleBeforeClause(altsOrOpts, laKey); try { var alts = utils_1.isArray(altsOrOpts) ? altsOrOpts : altsOrOpts.DEF; var laFunc = this.getLaFuncFromCache(laKey); var altIdxToTake = laFunc.call(this, alts); if (altIdxToTake !== undefined) { var chosenAlternative = alts[altIdxToTake]; var nestedAltBeforeClauseResult = this.nestedAltBeforeClause(chosenAlternative, occurrence, keys_1.OR_IDX, altIdxToTake); try { return chosenAlternative.ALT.call(this); } finally { if (nestedAltBeforeClauseResult !== undefined) { this.nestedRuleFinallyClause(nestedAltBeforeClauseResult.shortName, nestedAltBeforeClauseResult.nestedName); } } } this.raiseNoAltException(occurrence, altsOrOpts.ERR_MSG); } finally { if (nestedName !== undefined) { this.nestedRuleFinallyClause(laKey, nestedName); } } }; RecognizerEngine.prototype.ruleFinallyStateUpdate = function () { this.RULE_STACK.pop(); this.RULE_OCCURRENCE_STACK.pop(); // NOOP when cst is disabled this.cstFinallyStateUpdate(); if (this.RULE_STACK.length === 0 && this.isAtEndOfInput() === false) { var firstRedundantTok = this.LA(1); var errMsg = this.errorMessageProvider.buildNotAllInputParsedMessage({ firstRedundant: firstRedundantTok, ruleName: this.getCurrRuleFullName() }); this.SAVE_ERROR(new exceptions_public_1.NotAllInputParsedException(errMsg, firstRedundantTok)); } }; RecognizerEngine.prototype.subruleInternal = function (ruleToCall, idx, options) { var ruleResult; try { var args = options !== undefined ? options.ARGS : undefined; ruleResult = ruleToCall.call(this, idx, args); this.cstPostNonTerminal(ruleResult, options !== undefined && options.LABEL !== undefined ? options.LABEL : ruleToCall.ruleName); return ruleResult; } catch (e) { this.subruleInternalError(e, options, ruleToCall.ruleName); } }; RecognizerEngine.prototype.subruleInternalError = function (e, options, ruleName) { if (exceptions_public_1.isRecognitionException(e) && e.partialCstResult !== undefined) { this.cstPostNonTerminal(e.partialCstResult, options !== undefined && options.LABEL !== undefined ? options.LABEL : ruleName); delete e.partialCstResult; } throw e; }; RecognizerEngine.prototype.consumeInternal = function (tokType, idx, options) { var consumedToken; try { var nextToken = this.LA(1); if (this.tokenMatcher(nextToken, tokType) === true) { this.consumeToken(); consumedToken = nextToken; } else { this.consumeInternalError(tokType, nextToken, options); } } catch (eFromConsumption) { consumedToken = this.consumeInternalRecovery(tokType, idx, eFromConsumption); } this.cstPostTerminal(options !== undefined && options.LABEL !== undefined ? options.LABEL : tokType.name, consumedToken); return consumedToken; }; RecognizerEngine.prototype.consumeInternalError = function (tokType, nextToken, options) { var msg; var previousToken = this.LA(0); if (options !== undefined && options.ERR_MSG) { msg = options.ERR_MSG; } else { msg = this.errorMessageProvider.buildMismatchTokenMessage({ expected: tokType, actual: nextToken, previous: previousToken, ruleName: this.getCurrRuleFullName() }); } throw this.SAVE_ERROR(new exceptions_public_1.MismatchedTokenException(msg, nextToken, previousToken)); }; RecognizerEngine.prototype.consumeInternalRecovery = function (tokType, idx, eFromConsumption) { // no recovery allowed during backtracking, otherwise backtracking may recover invalid syntax and accept it // but the original syntax could have been parsed successfully without any backtracking + recovery if (this.recoveryEnabled && // TODO: more robust checking of the exception type. Perhaps Typescript extending expressions? eFromConsumption.name === "MismatchedTokenException" && !this.isBackTracking()) { var follows = this.getFollowsForInRuleRecovery(tokType, idx); try { return this.tryInRuleRecovery(tokType, follows); } catch (eFromInRuleRecovery) { if (eFromInRuleRecovery.name === recoverable_1.IN_RULE_RECOVERY_EXCEPTION) { // failed in RuleRecovery. // throw the original error in order to trigger reSync error recovery throw eFromConsumption; } else { throw eFromInRuleRecovery; } } } else { throw eFromConsumption; } }; RecognizerEngine.prototype.saveRecogState = function () { // errors is a getter which will clone the errors array var savedErrors = this.errors; var savedRuleStack = utils_1.cloneArr(this.RULE_STACK); return { errors: savedErrors, lexerState: this.exportLexerState(), RULE_STACK: savedRuleStack, CST_STACK: this.CST_STACK, LAST_EXPLICIT_RULE_STACK: this.LAST_EXPLICIT_RULE_STACK }; }; RecognizerEngine.prototype.reloadRecogState = function (newState) { this.errors = newState.errors; this.importLexerState(newState.lexerState); this.RULE_STACK = newState.RULE_STACK; }; RecognizerEngine.prototype.ruleInvocationStateUpdate = function (shortName, fullName, idxInCallingRule) { this.RULE_OCCURRENCE_STACK.push(idxInCallingRule); this.RULE_STACK.push(shortName); // NOOP when cst is disabled this.cstInvocationStateUpdate(fullName, shortName); }; RecognizerEngine.prototype.isBackTracking = function () { return this.isBackTrackingStack.length !== 0; }; RecognizerEngine.prototype.getCurrRuleFullName = function () { var shortName = this.getLastExplicitRuleShortName(); return this.shortRuleNameToFull[shortName]; }; RecognizerEngine.prototype.shortRuleNameToFullName = function (shortName) { return this.shortRuleNameToFull[shortName]; }; RecognizerEngine.prototype.isAtEndOfInput = function () { return this.tokenMatcher(this.LA(1), tokens_public_1.EOF); }; RecognizerEngine.prototype.reset = function () { this.resetLexerState(); this.isBackTrackingStack = []; this.errors = []; this.RULE_STACK = []; this.LAST_EXPLICIT_RULE_STACK = []; // TODO: extract a specific rest for TreeBuilder trait this.CST_STACK = []; this.RULE_OCCURRENCE_STACK = []; }; return RecognizerEngine; }()); exports.RecognizerEngine = RecognizerEngine; //# sourceMappingURL=recognizer_engine.js.map /***/ }), /* 36 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var exceptions_public_1 = __webpack_require__(8); var utils_1 = __webpack_require__(0); var lookahead_1 = __webpack_require__(12); var parser_1 = __webpack_require__(2); /** * Trait responsible for runtime parsing errors. */ var ErrorHandler = /** @class */ (function () { function ErrorHandler() { } ErrorHandler.prototype.initErrorHandler = function (config) { this._errors = []; this.errorMessageProvider = utils_1.defaults(config.errorMessageProvider, parser_1.DEFAULT_PARSER_CONFIG.errorMessageProvider); }; ErrorHandler.prototype.SAVE_ERROR = function (error) { if (exceptions_public_1.isRecognitionException(error)) { error.context = { ruleStack: this.getHumanReadableRuleStack(), ruleOccurrenceStack: utils_1.cloneArr(this.RULE_OCCURRENCE_STACK) }; this._errors.push(error); return error; } else { throw Error("Trying to save an Error which is not a RecognitionException"); } }; Object.defineProperty(ErrorHandler.prototype, "errors", { // TODO: extract these methods to ErrorHandler Trait? get: function () { return utils_1.cloneArr(this._errors); }, set: function (newErrors) { this._errors = newErrors; }, enumerable: true, configurable: true }); // TODO: consider caching the error message computed information ErrorHandler.prototype.raiseEarlyExitException = function (occurrence, prodType, userDefinedErrMsg) { var ruleName = this.getCurrRuleFullName(); var ruleGrammar = this.getGAstProductions()[ruleName]; var lookAheadPathsPerAlternative = lookahead_1.getLookaheadPathsForOptionalProd(occurrence, ruleGrammar, prodType, this.maxLookahead); var insideProdPaths = lookAheadPathsPerAlternative[0]; var actualTokens = []; for (var i = 1; i <= this.maxLookahead; i++) { actualTokens.push(this.LA(i)); } var msg = this.errorMessageProvider.buildEarlyExitMessage({ expectedIterationPaths: insideProdPaths, actual: actualTokens, previous: this.LA(0), customUserDescription: userDefinedErrMsg, ruleName: ruleName }); throw this.SAVE_ERROR(new exceptions_public_1.EarlyExitException(msg, this.LA(1), this.LA(0))); }; // TODO: consider caching the error message computed information ErrorHandler.prototype.raiseNoAltException = function (occurrence, errMsgTypes) { var ruleName = this.getCurrRuleFullName(); var ruleGrammar = this.getGAstProductions()[ruleName]; // TODO: getLookaheadPathsForOr can be slow for large enough maxLookahead and certain grammars, consider caching ? var lookAheadPathsPerAlternative = lookahead_1.getLookaheadPathsForOr(occurrence, ruleGrammar, this.maxLookahead); var actualTokens = []; for (var i = 1; i <= this.maxLookahead; i++) { actualTokens.push(this.LA(i)); } var previousToken = this.LA(0); var errMsg = this.errorMessageProvider.buildNoViableAltMessage({ expectedPathsPerAlt: lookAheadPathsPerAlternative, actual: actualTokens, previous: previousToken, customUserDescription: errMsgTypes, ruleName: this.getCurrRuleFullName() }); throw this.SAVE_ERROR(new exceptions_public_1.NoViableAltException(errMsg, this.LA(1), previousToken)); }; return ErrorHandler; }()); exports.ErrorHandler = ErrorHandler; //# sourceMappingURL=error_handler.js.map /***/ }), /* 37 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var interpreter_1 = __webpack_require__(13); var utils_1 = __webpack_require__(0); var ContentAssist = /** @class */ (function () { function ContentAssist() { } ContentAssist.prototype.initContentAssist = function () { }; ContentAssist.prototype.computeContentAssist = function (startRuleName, precedingInput) { var startRuleGast = this.gastProductionsCache[startRuleName]; if (utils_1.isUndefined(startRuleGast)) { throw Error("Rule ->" + startRuleName + "<- does not exist in this grammar."); } return interpreter_1.nextPossibleTokensAfter([startRuleGast], precedingInput, this.tokenMatcher, this.maxLookahead); }; // TODO: should this be a member method or a utility? it does not have any state or usage of 'this'... // TODO: should this be more explicitly part of the public API? ContentAssist.prototype.getNextPossibleTokenTypes = function (grammarPath) { var topRuleName = utils_1.first(grammarPath.ruleStack); var gastProductions = this.getGAstProductions(); var topProduction = gastProductions[topRuleName]; var nextPossibleTokenTypes = new interpreter_1.NextAfterTokenWalker(topProduction, grammarPath).startWalking(); return nextPossibleTokenTypes; }; return ContentAssist; }()); exports.ContentAssist = ContentAssist; //# sourceMappingURL=context_assist.js.map /***/ }), /* 38 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var gast_public_1 = __webpack_require__(1); var lexer_public_1 = __webpack_require__(9); var tokens_1 = __webpack_require__(5); var tokens_public_1 = __webpack_require__(3); var parser_1 = __webpack_require__(2); var keys_1 = __webpack_require__(7); var RECORDING_NULL_OBJECT = { description: "This Object indicates the Parser is during Recording Phase" }; Object.freeze(RECORDING_NULL_OBJECT); var HANDLE_SEPARATOR = true; var MAX_METHOD_IDX = Math.pow(2, keys_1.BITS_FOR_OCCURRENCE_IDX) - 1; var RFT = tokens_public_1.createToken({ name: "RECORDING_PHASE_TOKEN", pattern: lexer_public_1.Lexer.NA }); tokens_1.augmentTokenTypes([RFT]); var RECORDING_PHASE_TOKEN = tokens_public_1.createTokenInstance(RFT, "This IToken indicates the Parser is in Recording Phase\n\t" + "" + "See: https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording for details", // Using "-1" instead of NaN (as in EOF) because an actual number is less likely to // cause errors if the output of LA or CONSUME would be (incorrectly) used during the recording phase. -1, -1, -1, -1, -1, -1); Object.freeze(RECORDING_PHASE_TOKEN); var RECORDING_PHASE_CSTNODE = { name: "This CSTNode indicates the Parser is in Recording Phase\n\t" + "See: https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording for details", children: {} }; /** * This trait handles the creation of the GAST structure for Chevrotain Grammars */ var GastRecorder = /** @class */ (function () { function GastRecorder() { } GastRecorder.prototype.initGastRecorder = function (config) { this.recordingProdStack = []; this.RECORDING_PHASE = false; }; GastRecorder.prototype.enableRecording = function () { var _this = this; this.RECORDING_PHASE = true; this.TRACE_INIT("Enable Recording", function () { var _loop_1 = function (i) { var idx = i > 0 ? i : ""; _this["CONSUME" + idx] = function (arg1, arg2) { return this.consumeInternalRecord(arg1, i, arg2); }; _this["SUBRULE" + idx] = function (arg1, arg2) { return this.subruleInternalRecord(arg1, i, arg2); }; _this["OPTION" + idx] = function (arg1) { return this.optionInternalRecord(arg1, i); }; _this["OR" + idx] = function (arg1) { return this.orInternalRecord(arg1, i); }; _this["MANY" + idx] = function (arg1) { this.manyInternalRecord(i, arg1); }; _this["MANY_SEP" + idx] = function (arg1) { this.manySepFirstInternalRecord(i, arg1); }; _this["AT_LEAST_ONE" + idx] = function (arg1) { this.atLeastOneInternalRecord(i, arg1); }; _this["AT_LEAST_ONE_SEP" + idx] = function (arg1) { this.atLeastOneSepFirstInternalRecord(i, arg1); }; }; /** * Warning Dark Voodoo Magic upcoming! * We are "replacing" the public parsing DSL methods API * With **new** alternative implementations on the Parser **instance** * * So far this is the only way I've found to avoid performance regressions during parsing time. * - Approx 30% performance regression was measured on Chrome 75 Canary when attempting to replace the "internal" * implementations directly instead. */ for (var i = 0; i < 10; i++) { _loop_1(i); } // DSL methods with the idx(suffix) as an argument _this["consume"] = function (idx, arg1, arg2) { return this.consumeInternalRecord(arg1, idx, arg2); }; _this["subrule"] = function (idx, arg1, arg2) { return this.subruleInternalRecord(arg1, idx, arg2); }; _this["option"] = function (idx, arg1) { return this.optionInternalRecord(arg1, idx); }; _this["or"] = function (idx, arg1) { return this.orInternalRecord(arg1, idx); }; _this["many"] = function (idx, arg1) { this.manyInternalRecord(idx, arg1); }; _this["atLeastOne"] = function (idx, arg1) { this.atLeastOneInternalRecord(idx, arg1); }; _this.ACTION = _this.ACTION_RECORD; _this.BACKTRACK = _this.BACKTRACK_RECORD; _this.LA = _this.LA_RECORD; }); }; GastRecorder.prototype.disableRecording = function () { var _this = this; this.RECORDING_PHASE = false; // By deleting these **instance** properties, any future invocation // will be deferred to the original methods on the **prototype** object // This seems to get rid of any incorrect optimizations that V8 may // do during the recording phase. this.TRACE_INIT("Deleting Recording methods", function () { for (var i = 0; i < 10; i++) { var idx = i > 0 ? i : ""; delete _this["CONSUME" + idx]; delete _this["SUBRULE" + idx]; delete _this["OPTION" + idx]; delete _this["OR" + idx]; delete _this["MANY" + idx]; delete _this["MANY_SEP" + idx]; delete _this["AT_LEAST_ONE" + idx]; delete _this["AT_LEAST_ONE_SEP" + idx]; } delete _this["consume"]; delete _this["subrule"]; delete _this["option"]; delete _this["or"]; delete _this["many"]; delete _this["atLeastOne"]; delete _this.ACTION; delete _this.BACKTRACK; delete _this.LA; }); }; // TODO: is there any way to use this method to check no // Parser methods are called inside an ACTION? // Maybe try/catch/finally on ACTIONS while disabling the recorders state changes? GastRecorder.prototype.ACTION_RECORD = function (impl) { // NO-OP during recording return; }; // Executing backtracking logic will break our recording logic assumptions GastRecorder.prototype.BACKTRACK_RECORD = function (grammarRule, args) { return function () { return true; }; }; // LA is part of the official API and may be used for custom lookahead logic // by end users who may forget to wrap it in ACTION or inside a GATE GastRecorder.prototype.LA_RECORD = function (howMuch) { // We cannot use the RECORD_PHASE_TOKEN here because someone may depend // On LA return EOF at the end of the input so an infinite loop may occur. return parser_1.END_OF_FILE; }; GastRecorder.prototype.topLevelRuleRecord = function (name, def) { try { var newTopLevelRule = new gast_public_1.Rule({ definition: [], name: name }); newTopLevelRule.name = name; this.recordingProdStack.push(newTopLevelRule); def.call(this); this.recordingProdStack.pop(); return newTopLevelRule; } catch (originalError) { if (originalError.KNOWN_RECORDER_ERROR !== true) { try { originalError.message = originalError.message + '\n\t This error was thrown during the "grammar recording phase" For more info see:\n\t' + "https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording"; } catch (mutabilityError) { // We may not be able to modify the original error object throw originalError; } } throw originalError; } }; // Implementation of parsing DSL GastRecorder.prototype.optionInternalRecord = function (actionORMethodDef, occurrence) { return recordProd.call(this, gast_public_1.Option, actionORMethodDef, occurrence); }; GastRecorder.prototype.atLeastOneInternalRecord = function (occurrence, actionORMethodDef) { recordProd.call(this, gast_public_1.RepetitionMandatory, actionORMethodDef, occurrence); }; GastRecorder.prototype.atLeastOneSepFirstInternalRecord = function (occurrence, options) { recordProd.call(this, gast_public_1.RepetitionMandatoryWithSeparator, options, occurrence, HANDLE_SEPARATOR); }; GastRecorder.prototype.manyInternalRecord = function (occurrence, actionORMethodDef) { recordProd.call(this, gast_public_1.Repetition, actionORMethodDef, occurrence); }; GastRecorder.prototype.manySepFirstInternalRecord = function (occurrence, options) { recordProd.call(this, gast_public_1.RepetitionWithSeparator, options, occurrence, HANDLE_SEPARATOR); }; GastRecorder.prototype.orInternalRecord = function (altsOrOpts, occurrence) { return recordOrProd.call(this, altsOrOpts, occurrence); }; GastRecorder.prototype.subruleInternalRecord = function (ruleToCall, occurrence, options) { assertMethodIdxIsValid(occurrence); if (!ruleToCall || utils_1.has(ruleToCall, "ruleName") === false) { var error = new Error(" argument is invalid" + (" expecting a Parser method reference but got: <" + JSON.stringify(ruleToCall) + ">") + ("\n inside top level rule: <" + this.recordingProdStack[0].name + ">")); error.KNOWN_RECORDER_ERROR = true; throw error; } var prevProd = utils_1.peek(this.recordingProdStack); var ruleName = ruleToCall["ruleName"]; var newNoneTerminal = new gast_public_1.NonTerminal({ idx: occurrence, nonTerminalName: ruleName, // The resolving of the `referencedRule` property will be done once all the Rule's GASTs have been created referencedRule: undefined }); prevProd.definition.push(newNoneTerminal); return this.outputCst ? RECORDING_PHASE_CSTNODE : RECORDING_NULL_OBJECT; }; GastRecorder.prototype.consumeInternalRecord = function (tokType, occurrence, options) { assertMethodIdxIsValid(occurrence); if (!tokens_1.hasShortKeyProperty(tokType)) { var error = new Error(" argument is invalid" + (" expecting a TokenType reference but got: <" + JSON.stringify(tokType) + ">") + ("\n inside top level rule: <" + this.recordingProdStack[0].name + ">")); error.KNOWN_RECORDER_ERROR = true; throw error; } var prevProd = utils_1.peek(this.recordingProdStack); var newNoneTerminal = new gast_public_1.Terminal({ idx: occurrence, terminalType: tokType }); prevProd.definition.push(newNoneTerminal); return RECORDING_PHASE_TOKEN; }; return GastRecorder; }()); exports.GastRecorder = GastRecorder; function recordProd(prodConstructor, mainProdArg, occurrence, handleSep) { if (handleSep === void 0) { handleSep = false; } assertMethodIdxIsValid(occurrence); var prevProd = utils_1.peek(this.recordingProdStack); var grammarAction = utils_1.isFunction(mainProdArg) ? mainProdArg : mainProdArg.DEF; var newProd = new prodConstructor({ definition: [], idx: occurrence }); if (utils_1.has(mainProdArg, "NAME")) { newProd.name = mainProdArg.NAME; } if (handleSep) { newProd.separator = mainProdArg.SEP; } if (utils_1.has(mainProdArg, "MAX_LOOKAHEAD")) { newProd.maxLookahead = mainProdArg.MAX_LOOKAHEAD; } this.recordingProdStack.push(newProd); grammarAction.call(this); prevProd.definition.push(newProd); this.recordingProdStack.pop(); return RECORDING_NULL_OBJECT; } function recordOrProd(mainProdArg, occurrence) { var _this = this; assertMethodIdxIsValid(occurrence); var prevProd = utils_1.peek(this.recordingProdStack); // Only an array of alternatives var hasOptions = utils_1.isArray(mainProdArg) === false; var alts = hasOptions === false ? mainProdArg : mainProdArg.DEF; var newOrProd = new gast_public_1.Alternation({ definition: [], idx: occurrence, ignoreAmbiguities: hasOptions && mainProdArg.IGNORE_AMBIGUITIES === true }); if (utils_1.has(mainProdArg, "NAME")) { newOrProd.name = mainProdArg.NAME; } if (utils_1.has(mainProdArg, "MAX_LOOKAHEAD")) { newOrProd.maxLookahead = mainProdArg.MAX_LOOKAHEAD; } var hasPredicates = utils_1.some(alts, function (currAlt) { return utils_1.isFunction(currAlt.GATE); }); newOrProd.hasPredicates = hasPredicates; prevProd.definition.push(newOrProd); utils_1.forEach(alts, function (currAlt) { var currAltFlat = new gast_public_1.Flat({ definition: [] }); newOrProd.definition.push(currAltFlat); if (utils_1.has(currAlt, "NAME")) { currAltFlat.name = currAlt.NAME; } if (utils_1.has(currAlt, "IGNORE_AMBIGUITIES")) { currAltFlat.ignoreAmbiguities = currAlt.IGNORE_AMBIGUITIES; } // **implicit** ignoreAmbiguities due to usage of gate else if (utils_1.has(currAlt, "GATE")) { currAltFlat.ignoreAmbiguities = true; } _this.recordingProdStack.push(currAltFlat); currAlt.ALT.call(_this); _this.recordingProdStack.pop(); }); return RECORDING_NULL_OBJECT; } function getIdxSuffix(idx) { return idx === 0 ? "" : "" + idx; } function assertMethodIdxIsValid(idx) { if (idx < 0 || idx > MAX_METHOD_IDX) { var error = new Error( // The stack trace will contain all the needed details "Invalid DSL Method idx value: <" + idx + ">\n\t" + ("Idx value must be a none negative value smaller than " + (MAX_METHOD_IDX + 1))); error.KNOWN_RECORDER_ERROR = true; throw error; } } //# sourceMappingURL=gast_recorder.js.map /***/ }), /* 39 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var parser_1 = __webpack_require__(2); /** * Trait responsible for runtime parsing errors. */ var PerformanceTracer = /** @class */ (function () { function PerformanceTracer() { } PerformanceTracer.prototype.initPerformanceTracer = function (config) { if (utils_1.has(config, "traceInitPerf")) { var userTraceInitPerf = config.traceInitPerf; var traceIsNumber = typeof userTraceInitPerf === "number"; this.traceInitMaxIdent = traceIsNumber ? userTraceInitPerf : Infinity; this.traceInitPerf = traceIsNumber ? userTraceInitPerf > 0 : userTraceInitPerf; } else { this.traceInitMaxIdent = 0; this.traceInitPerf = parser_1.DEFAULT_PARSER_CONFIG.traceInitPerf; } this.traceInitIndent = -1; }; PerformanceTracer.prototype.TRACE_INIT = function (phaseDesc, phaseImpl) { // No need to optimize this using NOOP pattern because // It is not called in a hot spot... if (this.traceInitPerf === true) { this.traceInitIndent++; var indent = new Array(this.traceInitIndent + 1).join("\t"); if (this.traceInitIndent < this.traceInitMaxIdent) { console.log(indent + "--> <" + phaseDesc + ">"); } var _a = utils_1.timer(phaseImpl), time = _a.time, value = _a.value; /* istanbul ignore next - Difficult to reproduce specific performance behavior (>10ms) in tests */ var traceMethod = time > 10 ? console.warn : console.log; if (this.traceInitIndent < this.traceInitMaxIdent) { traceMethod(indent + "<-- <" + phaseDesc + "> time: " + time + "ms"); } this.traceInitIndent--; return value; } else { return phaseImpl(); } }; return PerformanceTracer; }()); exports.PerformanceTracer = PerformanceTracer; //# sourceMappingURL=perf_tracer.js.map /***/ }), /* 40 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var version_1 = __webpack_require__(19); function createSyntaxDiagramsCode(grammar, _a) { var _b = _a === void 0 ? {} : _a, _c = _b.resourceBase, resourceBase = _c === void 0 ? "https://unpkg.com/chevrotain@" + version_1.VERSION + "/diagrams/" : _c, _d = _b.css, css = _d === void 0 ? "https://unpkg.com/chevrotain@" + version_1.VERSION + "/diagrams/diagrams.css" : _d; var header = "\n\n\n\n\n\n"; var cssHtml = "\n\n"; var scripts = "\n\n\n\n\n"; var diagramsDiv = "\n
\n"; var serializedGrammar = "\n\n"; var initLogic = "\n\n"; return (header + cssHtml + scripts + diagramsDiv + serializedGrammar + initLogic); } exports.createSyntaxDiagramsCode = createSyntaxDiagramsCode; //# sourceMappingURL=render_public.js.map /***/ }), /* 41 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var generate_1 = __webpack_require__(42); function generateParserFactory(options) { var wrapperText = generate_1.genWrapperFunction({ name: options.name, rules: options.rules }); var constructorWrapper = new Function("tokenVocabulary", "config", "chevrotain", wrapperText); return function (config) { return constructorWrapper(options.tokenVocabulary, config, // TODO: check how the require is transpiled/webpacked __webpack_require__(18)); }; } exports.generateParserFactory = generateParserFactory; function generateParserModule(options) { return generate_1.genUmdModule({ name: options.name, rules: options.rules }); } exports.generateParserModule = generateParserModule; //# sourceMappingURL=generate_public.js.map /***/ }), /* 42 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = __webpack_require__(0); var gast_public_1 = __webpack_require__(1); /** * Missing features * 1. Rule arguments * 2. Gates * 3. embedded actions */ var NL = "\n"; function genUmdModule(options) { return "\n(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define(['chevrotain'], factory);\n } else if (typeof module === 'object' && module.exports) {\n // Node. Does not work with strict CommonJS, but\n // only CommonJS-like environments that support module.exports,\n // like Node.\n module.exports = factory(require('chevrotain'));\n } else {\n // Browser globals (root is window)\n root.returnExports = factory(root.b);\n }\n}(typeof self !== 'undefined' ? self : this, function (chevrotain) {\n\n" + genClass(options) + "\n \nreturn {\n " + options.name + ": " + options.name + " \n}\n}));\n"; } exports.genUmdModule = genUmdModule; function genWrapperFunction(options) { return " \n" + genClass(options) + "\nreturn new " + options.name + "(tokenVocabulary, config) \n"; } exports.genWrapperFunction = genWrapperFunction; function genClass(options) { // TODO: how to pass the token vocabulary? Constructor? other? var result = "\nfunction " + options.name + "(tokenVocabulary, config) {\n // invoke super constructor\n // No support for embedded actions currently, so we can 'hardcode'\n // The use of CstParser.\n chevrotain.CstParser.call(this, tokenVocabulary, config)\n\n const $ = this\n\n " + genAllRules(options.rules) + "\n\n // very important to call this after all the rules have been defined.\n // otherwise the parser may not work correctly as it will lack information\n // derived during the self analysis phase.\n this.performSelfAnalysis(this)\n}\n\n// inheritance as implemented in javascript in the previous decade... :(\n" + options.name + ".prototype = Object.create(chevrotain.CstParser.prototype)\n" + options.name + ".prototype.constructor = " + options.name + " \n "; return result; } exports.genClass = genClass; function genAllRules(rules) { var rulesText = utils_1.map(rules, function (currRule) { return genRule(currRule, 1); }); return rulesText.join("\n"); } exports.genAllRules = genAllRules; function genRule(prod, n) { var result = indent(n, "$.RULE(\"" + prod.name + "\", function() {") + NL; result += genDefinition(prod.definition, n + 1); result += indent(n + 1, "})") + NL; return result; } exports.genRule = genRule; function genTerminal(prod, n) { var name = prod.terminalType.name; // TODO: potential performance optimization, avoid tokenMap Dictionary access return indent(n, "$.CONSUME" + prod.idx + "(this.tokensMap." + name + ")" + NL); } exports.genTerminal = genTerminal; function genNonTerminal(prod, n) { return indent(n, "$.SUBRULE" + prod.idx + "($." + prod.nonTerminalName + ")" + NL); } exports.genNonTerminal = genNonTerminal; function genAlternation(prod, n) { var result = indent(n, "$.OR" + prod.idx + "([") + NL; var alts = utils_1.map(prod.definition, function (altDef) { return genSingleAlt(altDef, n + 1); }); result += alts.join("," + NL); result += NL + indent(n, "])" + NL); return result; } exports.genAlternation = genAlternation; function genSingleAlt(prod, n) { var result = indent(n, "{") + NL; if (prod.name) { result += indent(n + 1, "NAME: \"" + prod.name + "\",") + NL; } result += indent(n + 1, "ALT: function() {") + NL; result += genDefinition(prod.definition, n + 1); result += indent(n + 1, "}") + NL; result += indent(n, "}"); return result; } exports.genSingleAlt = genSingleAlt; function genProd(prod, n) { /* istanbul ignore else */ if (prod instanceof gast_public_1.NonTerminal) { return genNonTerminal(prod, n); } else if (prod instanceof gast_public_1.Option) { return genDSLRule("OPTION", prod, n); } else if (prod instanceof gast_public_1.RepetitionMandatory) { return genDSLRule("AT_LEAST_ONE", prod, n); } else if (prod instanceof gast_public_1.RepetitionMandatoryWithSeparator) { return genDSLRule("AT_LEAST_ONE_SEP", prod, n); } else if (prod instanceof gast_public_1.RepetitionWithSeparator) { return genDSLRule("MANY_SEP", prod, n); } else if (prod instanceof gast_public_1.Repetition) { return genDSLRule("MANY", prod, n); } else if (prod instanceof gast_public_1.Alternation) { return genAlternation(prod, n); } else if (prod instanceof gast_public_1.Terminal) { return genTerminal(prod, n); } else if (prod instanceof gast_public_1.Flat) { return genDefinition(prod.definition, n); } else { throw Error("non exhaustive match"); } } function genDSLRule(dslName, prod, n) { var result = indent(n, "$." + (dslName + prod.idx) + "("); if (prod.name || prod.separator) { result += "{" + NL; if (prod.name) { result += indent(n + 1, "NAME: \"" + prod.name + "\"") + "," + NL; } if (prod.separator) { result += indent(n + 1, "SEP: this.tokensMap." + prod.separator.name) + "," + NL; } result += "DEF: " + genDefFunction(prod.definition, n + 2) + NL; result += indent(n, "}") + NL; } else { result += genDefFunction(prod.definition, n + 1); } result += indent(n, ")") + NL; return result; } function genDefFunction(definition, n) { var def = "function() {" + NL; def += genDefinition(definition, n); def += indent(n, "}") + NL; return def; } function genDefinition(def, n) { var result = ""; utils_1.forEach(def, function (prod) { result += genProd(prod, n + 1); }); return result; } function indent(howMuch, text) { var spaces = Array(howMuch * 4 + 1).join(" "); return spaces + text; } //# sourceMappingURL=generate.js.map /***/ }) /******/ ]); }); ================================================ FILE: vipercard/vipercard/external/chevrotain-6.5.0/chevrotaintyping.d.ts ================================================ export as namespace chevrotain export declare const VERSION: string /** * This class does not actually exists nor is exposed at runtime. * This is just a helper to avoid duplications in the Type Definitions * Of `CstParser` and `EmbeddedActionsParser` */ declare abstract class BaseParser { /** * This must be called at the end of a Parser constructor. * See: http://sap.github.io/chevrotain/docs/tutorial/step2_parsing.html#under-the-hood */ protected performSelfAnalysis(): void /** * It is recommended to reuse the same Parser instance * by passing an empty array to the input argument * and only later setting the input by using the input property. * See: http://sap.github.io/chevrotain/docs/FAQ.html#major-performance-benefits * * @param tokenVocabulary - A data structure containing all the Tokens used by the Parser. * @param config - The Parser's configuration. */ constructor(tokenVocabulary: TokenVocabulary, config?: IParserConfig) errors: IRecognitionException[] /** * Flag indicating the Parser is at the recording phase. * Can be used to implement methods similar to {@link BaseParser.ACTION} * Or any other logic to requires knowledge of the recording phase. * See: * - https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording * to learn more on the recording phase and how Chevrotain works. */ RECORDING_PHASE: boolean /** * Resets the parser state, should be overridden for custom parsers which "carry" additional state. * When overriding, remember to also invoke the super implementation! */ reset(): void getBaseCstVisitorConstructor(): { new (...args: any[]): ICstVisitor } getBaseCstVisitorConstructorWithDefaults(): { new (...args: any[]): ICstVisitor } getGAstProductions(): Record getSerializedGastProductions(): ISerializedGast[] /** * @param startRuleName * @param precedingInput - The token vector up to (not including) the content assist point */ computeContentAssist( startRuleName: string, precedingInput: IToken[] ): ISyntacticContentAssistPath[] /** * @param grammarRule - The rule to try and parse in backtracking mode. * @param args - argumens to be passed to the grammar rule execution * * @return a lookahead function that will try to parse the given grammarRule and will return true if succeed. */ protected BACKTRACK( grammarRule: (...args: any[]) => T, args?: any[] ): () => boolean /** * The Semantic Actions wrapper. * Should be used to wrap semantic actions that either: * - May fail when executing in "recording phase". * - Have global side effects that should be avoided during "recording phase". * * For more information see: * - https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording */ protected ACTION(impl: () => T): T /** * Like `CONSUME` with the numerical suffix as a parameter, e.g: * consume(0, X) === CONSUME(X) * consume(1, X) === CONSUME1(X) * consume(2, X) === CONSUME2(X) * ... * @see CONSUME */ protected consume( idx: number, tokType: TokenType, options?: ConsumeMethodOpts ): IToken /** * Like `OPTION` with the numerical suffix as a parameter, e.g: * option(0, X) === OPTION(X) * option(1, X) === OPTION1(X) * option(2, X) === OPTION2(X) * ... * @see SUBRULE */ protected option( idx: number, actionORMethodDef: GrammarAction | DSLMethodOpts ): OUT /** * Like `OR` with the numerical suffix as a parameter, e.g: * or(0, X) === OR(X) * or(1, X) === OR1(X) * or(2, X) === OR2(X) * ... * @see OR */ protected or(idx: number, altsOrOpts: IOrAlt[] | OrMethodOpts): any /** * Like `MANY` with the numerical suffix as a parameter, e.g: * many(0, X) === MANY(X) * many(1, X) === MANY1(X) * many(2, X) === MANY2(X) * ... * @see MANY */ protected many( idx: number, actionORMethodDef: GrammarAction | DSLMethodOpts ): void /** * Like `AT_LEAST_ONE` with the numerical suffix as a parameter, e.g: * atLeastOne(0, X) === AT_LEAST_ONE(X) * atLeastOne(1, X) === AT_LEAST_ONE1(X) * atLeastOne(2, X) === AT_LEAST_ONE2(X) * ... * @see AT_LEAST_ONE */ protected atLeastOne( idx: number, actionORMethodDef: GrammarAction | DSLMethodOptsWithErr ): void /** * * A Parsing DSL method use to consume a single Token. * In EBNF terms this is equivalent to a Terminal. * * A Token will be consumed, IFF the next token in the token vector matches . * otherwise the parser may attempt to perform error recovery (if enabled). * * The index in the method name indicates the unique occurrence of a terminal consumption * inside a the top level rule. What this means is that if a terminal appears * more than once in a single rule, each appearance must have a **different** index. * * For example: * ``` * this.RULE("qualifiedName", () => { * this.CONSUME1(Identifier); * this.MANY(() => { * this.CONSUME1(Dot); * // here we use CONSUME2 because the terminal * // 'Identifier' has already appeared previously in the * // the rule 'parseQualifiedName' * this.CONSUME2(Identifier); * }); * }) * ``` * * - See more details on the [unique suffixes requirement](http://sap.github.io/chevrotain/docs/FAQ.html#NUMERICAL_SUFFIXES). * * @param tokType - The Type of the token to be consumed. * @param options - optional properties to modify the behavior of CONSUME. */ protected CONSUME( tokType: TokenType, options?: ConsumeMethodOpts ): IToken /** * @see CONSUME * @hidden */ protected CONSUME1( tokType: TokenType, options?: ConsumeMethodOpts ): IToken /** * @see CONSUME * @hidden */ protected CONSUME2( tokType: TokenType, options?: ConsumeMethodOpts ): IToken /** * @see CONSUME * @hidden */ protected CONSUME3( tokType: TokenType, options?: ConsumeMethodOpts ): IToken /** * @see CONSUME * @hidden */ protected CONSUME4( tokType: TokenType, options?: ConsumeMethodOpts ): IToken /** * @see CONSUME * @hidden */ protected CONSUME5( tokType: TokenType, options?: ConsumeMethodOpts ): IToken /** * @see CONSUME * @hidden */ protected CONSUME6( tokType: TokenType, options?: ConsumeMethodOpts ): IToken /** * @see CONSUME * @hidden */ protected CONSUME7( tokType: TokenType, options?: ConsumeMethodOpts ): IToken /** * @see CONSUME * @hidden */ protected CONSUME8( tokType: TokenType, options?: ConsumeMethodOpts ): IToken /** * @see CONSUME * @hidden */ protected CONSUME9( tokType: TokenType, options?: ConsumeMethodOpts ): IToken /** * Parsing DSL Method that Indicates an Optional production. * in EBNF notation this is equivalent to: "[...]". * * Note that there are two syntax forms: * - Passing the grammar action directly: * ``` * this.OPTION(() => { * this.CONSUME(Digit)} * ); * ``` * * - using an "options" object: * ``` * this.OPTION({ * GATE:predicateFunc, * DEF: () => { * this.CONSUME(Digit) * }}); * ``` * * The optional 'GATE' property in "options" object form can be used to add constraints * to invoking the grammar action. * * As in CONSUME the index in the method name indicates the occurrence * of the optional production in it's top rule. * * @param actionORMethodDef - The grammar action to optionally invoke once * or an "OPTIONS" object describing the grammar action and optional properties. */ // TODO: return `OUT | undefined` explicitly protected OPTION( actionORMethodDef: GrammarAction | DSLMethodOpts ): OUT /** * @see OPTION * @hidden */ protected OPTION1( actionORMethodDef: GrammarAction | DSLMethodOpts ): OUT /** * @see OPTION * @hidden */ protected OPTION2( actionORMethodDef: GrammarAction | DSLMethodOpts ): OUT /** * @see OPTION * @hidden */ protected OPTION3( actionORMethodDef: GrammarAction | DSLMethodOpts ): OUT /** * @see OPTION * @hidden */ protected OPTION4( actionORMethodDef: GrammarAction | DSLMethodOpts ): OUT /** * @see OPTION * @hidden */ protected OPTION5( actionORMethodDef: GrammarAction | DSLMethodOpts ): OUT /** * @see OPTION * @hidden */ protected OPTION6( actionORMethodDef: GrammarAction | DSLMethodOpts ): OUT /** * @see OPTION * @hidden */ protected OPTION7( actionORMethodDef: GrammarAction | DSLMethodOpts ): OUT /** * @see OPTION * @hidden */ protected OPTION8( actionORMethodDef: GrammarAction | DSLMethodOpts ): OUT /** * @see OPTION * @hidden */ protected OPTION9( actionORMethodDef: GrammarAction | DSLMethodOpts ): OUT /** * Parsing DSL method that indicates a choice between a set of alternatives must be made. * This is equivalent to an EBNF alternation (A | B | C | D ...), except * that the alternatives are ordered like in a PEG grammar. * This means that the **first** matching alternative is always chosen. * * There are several forms for the inner alternatives array: * * - Passing alternatives array directly: * ``` * this.OR([ * { ALT:() => { this.CONSUME(One) }}, * { ALT:() => { this.CONSUME(Two) }}, * { ALT:() => { this.CONSUME(Three) }} * ]) * ``` * * - Passing alternative array directly with predicates (GATE): * ``` * this.OR([ * { GATE: predicateFunc1, ALT:() => { this.CONSUME(One) }}, * { GATE: predicateFuncX, ALT:() => { this.CONSUME(Two) }}, * { GATE: predicateFuncX, ALT:() => { this.CONSUME(Three) }} * ]) * ``` * * - These syntax forms can also be mixed: * ``` * this.OR([ * { * GATE: predicateFunc1, * ALT:() => { this.CONSUME(One) } * }, * { ALT:() => { this.CONSUME(Two) }}, * { ALT:() => { this.CONSUME(Three) }} * ]) * ``` * * - Additionally an "options" object may be used: * ``` * this.OR({ * DEF:[ * { ALT:() => { this.CONSUME(One) }}, * { ALT:() => { this.CONSUME(Two) }}, * { ALT:() => { this.CONSUME(Three) }} * ], * // OPTIONAL property * ERR_MSG: "A Number" * }) * ``` * * The 'predicateFuncX' in the long form can be used to add constraints to choosing the alternative. * * As in CONSUME the index in the method name indicates the occurrence * of the alternation production in it's top rule. * * @param altsOrOpts - A set of alternatives or an "OPTIONS" object describing the alternatives and optional properties. * * @returns The result of invoking the chosen alternative. */ protected OR(altsOrOpts: IOrAlt[] | OrMethodOpts): any /** * @see OR * @hidden */ protected OR1(altsOrOpts: IOrAlt[] | OrMethodOpts): any /** * @see OR * @hidden */ protected OR2(altsOrOpts: IOrAlt[] | OrMethodOpts): any /** * @see OR * @hidden */ protected OR3(altsOrOpts: IOrAlt[] | OrMethodOpts): any /** * @see OR * @hidden */ protected OR4(altsOrOpts: IOrAlt[] | OrMethodOpts): any /** * @see OR * @hidden */ protected OR5(altsOrOpts: IOrAlt[] | OrMethodOpts): any /** * @see OR * @hidden */ protected OR6(altsOrOpts: IOrAlt[] | OrMethodOpts): any /** * @see OR * @hidden */ protected OR7(altsOrOpts: IOrAlt[] | OrMethodOpts): any /** * @see OR * @hidden */ protected OR8(altsOrOpts: IOrAlt[] | OrMethodOpts): any /** * @see OR * @hidden */ protected OR9(altsOrOpts: IOrAlt[] | OrMethodOpts): any /** * Parsing DSL method, that indicates a repetition of zero or more. * This is equivalent to EBNF repetition {...}. * * Note that there are two syntax forms: * - Passing the grammar action directly: * ``` * this.MANY(() => { * this.CONSUME(Comma) * this.CONSUME(Digit) * }) * ``` * * - using an "options" object: * ``` * this.MANY({ * GATE: predicateFunc, * DEF: () => { * this.CONSUME(Comma) * this.CONSUME(Digit) * } * }); * ``` * * The optional 'GATE' property in "options" object form can be used to add constraints * to invoking the grammar action. * * As in CONSUME the index in the method name indicates the occurrence * of the repetition production in it's top rule. * * @param actionORMethodDef - The grammar action to optionally invoke multiple times * or an "OPTIONS" object describing the grammar action and optional properties. * */ protected MANY( actionORMethodDef: GrammarAction | DSLMethodOpts ): void /** * @see MANY * @hidden */ protected MANY1( actionORMethodDef: GrammarAction | DSLMethodOpts ): void /** * @see MANY * @hidden */ protected MANY2( actionORMethodDef: GrammarAction | DSLMethodOpts ): void /** * @see MANY * @hidden */ protected MANY3( actionORMethodDef: GrammarAction | DSLMethodOpts ): void /** * @see MANY * @hidden */ protected MANY4( actionORMethodDef: GrammarAction | DSLMethodOpts ): void /** * @see MANY * @hidden */ protected MANY5( actionORMethodDef: GrammarAction | DSLMethodOpts ): void /** * @see MANY * @hidden */ protected MANY6( actionORMethodDef: GrammarAction | DSLMethodOpts ): void /** * @see MANY * @hidden */ protected MANY7( actionORMethodDef: GrammarAction | DSLMethodOpts ): void /** * @see MANY * @hidden */ protected MANY8( actionORMethodDef: GrammarAction | DSLMethodOpts ): void /** * @see MANY * @hidden */ protected MANY9( actionORMethodDef: GrammarAction | DSLMethodOpts ): void /** * Parsing DSL method, that indicates a repetition of zero or more with a separator * Token between the repetitions. * * Example: * * ``` * this.MANY_SEP({ * SEP:Comma, * DEF: () => { * this.CONSUME(Number}; * // ... * }) * ``` * * Note that because this DSL method always requires more than one argument the options object is always required * and it is not possible to use a shorter form like in the MANY DSL method. * * Note that for the purposes of deciding on whether or not another iteration exists * Only a single Token is examined (The separator). Therefore if the grammar being implemented is * so "crazy" to require multiple tokens to identify an item separator please use the more basic DSL methods * to implement it. * * As in CONSUME the index in the method name indicates the occurrence * of the repetition production in it's top rule. * * @param options - An object defining the grammar of each iteration and the separator between iterations * */ protected MANY_SEP(options: ManySepMethodOpts): void /** * @see MANY_SEP * @hidden */ protected MANY_SEP1(options: ManySepMethodOpts): void /** * @see MANY_SEP * @hidden */ protected MANY_SEP2(options: ManySepMethodOpts): void /** * @see MANY_SEP * @hidden */ protected MANY_SEP3(options: ManySepMethodOpts): void /** * @see MANY_SEP * @hidden */ protected MANY_SEP4(options: ManySepMethodOpts): void /** * @see MANY_SEP * @hidden */ protected MANY_SEP5(options: ManySepMethodOpts): void /** * @see MANY_SEP * @hidden */ protected MANY_SEP6(options: ManySepMethodOpts): void /** * @see MANY_SEP * @hidden */ protected MANY_SEP7(options: ManySepMethodOpts): void /** * @see MANY_SEP * @hidden */ protected MANY_SEP8(options: ManySepMethodOpts): void /** * @see MANY_SEP * @hidden */ protected MANY_SEP9(options: ManySepMethodOpts): void /** * Convenience method, same as MANY but the repetition is of one or more. * failing to match at least one repetition will result in a parsing error and * cause a parsing error. * * @see MANY * * @param actionORMethodDef - The grammar action to optionally invoke multiple times * or an "OPTIONS" object describing the grammar action and optional properties. * */ protected AT_LEAST_ONE( actionORMethodDef: GrammarAction | DSLMethodOptsWithErr ): void /** * @see AT_LEAST_ONE * @hidden */ protected AT_LEAST_ONE1( actionORMethodDef: GrammarAction | DSLMethodOptsWithErr ): void /** * @see AT_LEAST_ONE * @hidden */ protected AT_LEAST_ONE2( actionORMethodDef: GrammarAction | DSLMethodOptsWithErr ): void /** * @see AT_LEAST_ONE * @hidden */ protected AT_LEAST_ONE3( actionORMethodDef: GrammarAction | DSLMethodOptsWithErr ): void /** * @see AT_LEAST_ONE * @hidden */ protected AT_LEAST_ONE4( actionORMethodDef: GrammarAction | DSLMethodOptsWithErr ): void /** * @see AT_LEAST_ONE * @hidden */ protected AT_LEAST_ONE5( actionORMethodDef: GrammarAction | DSLMethodOptsWithErr ): void /** * @see AT_LEAST_ONE * @hidden */ protected AT_LEAST_ONE6( actionORMethodDef: GrammarAction | DSLMethodOptsWithErr ): void /** * @see AT_LEAST_ONE * @hidden */ protected AT_LEAST_ONE7( actionORMethodDef: GrammarAction | DSLMethodOptsWithErr ): void /** * @see AT_LEAST_ONE * @hidden */ protected AT_LEAST_ONE8( actionORMethodDef: GrammarAction | DSLMethodOptsWithErr ): void /** * @see AT_LEAST_ONE * @hidden */ protected AT_LEAST_ONE9( actionORMethodDef: GrammarAction | DSLMethodOptsWithErr ): void /** * Convenience method, same as MANY_SEP but the repetition is of one or more. * failing to match at least one repetition will result in a parsing error and * cause the parser to attempt error recovery. * * Note that an additional optional property ERR_MSG can be used to provide custom error messages. * * @see MANY_SEP * * @param options - An object defining the grammar of each iteration and the separator between iterations * * @return {ISeparatedIterationResult} */ protected AT_LEAST_ONE_SEP( options: AtLeastOneSepMethodOpts ): void /** * @see AT_LEAST_ONE_SEP * @hidden */ protected AT_LEAST_ONE_SEP1( options: AtLeastOneSepMethodOpts ): void /** * @see AT_LEAST_ONE_SEP * @hidden */ protected AT_LEAST_ONE_SEP2( options: AtLeastOneSepMethodOpts ): void /** * @see AT_LEAST_ONE_SEP * @hidden */ protected AT_LEAST_ONE_SEP3( options: AtLeastOneSepMethodOpts ): void /** * @see AT_LEAST_ONE_SEP * @hidden */ protected AT_LEAST_ONE_SEP4( options: AtLeastOneSepMethodOpts ): void /** * @see AT_LEAST_ONE_SEP * @hidden */ protected AT_LEAST_ONE_SEP5( options: AtLeastOneSepMethodOpts ): void /** * @see AT_LEAST_ONE_SEP * @hidden */ protected AT_LEAST_ONE_SEP6( options: AtLeastOneSepMethodOpts ): void /** * @see AT_LEAST_ONE_SEP * @hidden */ protected AT_LEAST_ONE_SEP7( options: AtLeastOneSepMethodOpts ): void /** * @see AT_LEAST_ONE_SEP * @hidden */ protected AT_LEAST_ONE_SEP8( options: AtLeastOneSepMethodOpts ): void /** * @see AT_LEAST_ONE_SEP * @hidden */ protected AT_LEAST_ONE_SEP9( options: AtLeastOneSepMethodOpts ): void /** * Returns an "imaginary" Token to insert when Single Token Insertion is done * Override this if you require special behavior in your grammar. * For example if an IntegerToken is required provide one with the image '0' so it would be valid syntactically. */ protected getTokenToInsert(tokType: TokenType): IToken /** * By default all tokens type may be inserted. This behavior may be overridden in inheriting Recognizers * for example: One may decide that only punctuation tokens may be inserted automatically as they have no additional * semantic value. (A mandatory semicolon has no additional semantic meaning, but an Integer may have additional meaning * depending on its int value and context (Inserting an integer 0 in cardinality: "[1..]" will cause semantic issues * as the max of the cardinality will be greater than the min value (and this is a false error!). */ protected canTokenTypeBeInsertedInRecovery( tokType: TokenType ): boolean /** * @deprecated - will be removed in the future */ protected getNextPossibleTokenTypes( grammarPath: ITokenGrammarPath ): TokenType[] input: IToken[] protected SKIP_TOKEN(): IToken /** * Look-Ahead for the Token Vector * LA(1) is the next Token ahead. * LA(n) is the nth Token ahead. * LA(0) is the previously consumed Token. * * Looking beyond the end of the Token Vector or before its begining * will return in an IToken of type EOF {@link EOF}. * This behavior can be used to avoid infinite loops. * * This is often used to implement custom lookahead logic for GATES. * https://sap.github.io/chevrotain/docs/features/gates.html */ protected LA(howMuch: number): IToken } /** * @deprecated Soft deprecated, CstParser or EmbeddedActionsParser instead. * - {@link CstParser} * - {@link EmbeddedActionsParser} */ export declare class Parser extends BaseParser { /** * @deprecated use {@link Parser.performSelfAnalysis} **instance** method instead. */ protected static performSelfAnalysis(parserInstance: Parser): void /** * * @param name - The name of the rule. * @param implementation - The implementation of the rule. * @param [config] - The rule's optional configuration. * * @returns - The parsing rule which is the production implementation wrapped with the parsing logic that handles * Parser state / error recovery&reporting/ ... */ protected RULE( name: string, implementation: (...implArgs: any[]) => T, config?: IRuleConfig ): (idxInCallingRule?: number, ...args: any[]) => T | any /** * Same as {@link Parser.RULE}, but should only be used in * "extending" grammars to override rules/productions from the super grammar. * See [Parser Inheritance Example](https://github.com/SAP/chevrotain/tree/master/examples/parser/inheritance). */ protected OVERRIDE_RULE( name: string, impl: (...implArgs: any[]) => T, config?: IRuleConfig ): (idxInCallingRule?: number, ...args: any[]) => T | any protected SUBRULE( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE1( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE2( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE3( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE4( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE5( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE6( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE7( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE8( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE9( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T } /** * A Parser that outputs a Concrete Syntax Tree. * See: * - https://sap.github.io/chevrotain/docs/tutorial/step3_adding_actions_root.html#alternatives * - https://sap.github.io/chevrotain/docs/guide/concrete_syntax_tree.html * For in depth docs. */ export declare class CstParser extends BaseParser { // TODO: remove `outputCST` from the config options in the constructor /** * @deprecated use {@link Parser.performSelfAnalysis} **instance** method instead. */ protected static performSelfAnalysis(parserInstance: Parser): void /** * Creates a Grammar Rule */ protected RULE( name: string, implementation: (...implArgs: any[]) => any, config?: IRuleConfig ): (idxInCallingRule?: number, ...args: any[]) => CstNode /** * Overrides a Grammar Rule * See usage example in: https://github.com/SAP/chevrotain/blob/master/examples/parser/versioning/versioning.js */ protected OVERRIDE_RULE( name: string, implementation: (...implArgs: any[]) => any, config?: IRuleConfig ): (idxInCallingRule?: number, ...args: any[]) => CstNode /** * Like `SUBRULE` with the numerical suffix as a parameter, e.g: * subrule(0, X) === SUBRULE(X) * subrule(1, X) === SUBRULE1(X) * subrule(2, X) === SUBRULE2(X) * ... * @see SUBRULE */ protected subrule( idx: number, ruleToCall: (idx: number) => CstNode, options?: SubruleMethodOpts ): CstNode /** * The Parsing DSL Method is used by one rule to call another. * It is equivalent to a non-Terminal in EBNF notation. * * This may seem redundant as it does not actually do much. * However using it is **mandatory** for all sub rule invocations. * * Calling another rule without wrapping in SUBRULE(...) * will cause errors/mistakes in the Parser's self analysis phase, * which will lead to errors in error recovery/automatic lookahead calculation * and any other functionality relying on the Parser's self analysis * output. * * As in CONSUME the index in the method name indicates the occurrence * of the sub rule invocation in its rule. * */ protected SUBRULE( ruleToCall: (idx: number) => CstNode, options?: SubruleMethodOpts ): CstNode /** * @see SUBRULE * @hidden */ protected SUBRULE1( ruleToCall: (idx: number) => CstNode, options?: SubruleMethodOpts ): CstNode /** * @see SUBRULE * @hidden */ protected SUBRULE2( ruleToCall: (idx: number) => CstNode, options?: SubruleMethodOpts ): CstNode /** * @see SUBRULE * @hidden */ protected SUBRULE3( ruleToCall: (idx: number) => CstNode, options?: SubruleMethodOpts ): CstNode /** * @see SUBRULE * @hidden */ protected SUBRULE4( ruleToCall: (idx: number) => CstNode, options?: SubruleMethodOpts ): CstNode /** * @see SUBRULE * @hidden */ protected SUBRULE5( ruleToCall: (idx: number) => CstNode, options?: SubruleMethodOpts ): CstNode /** * @see SUBRULE * @hidden */ protected SUBRULE6( ruleToCall: (idx: number) => CstNode, options?: SubruleMethodOpts ): CstNode /** * @see SUBRULE * @hidden */ protected SUBRULE7( ruleToCall: (idx: number) => CstNode, options?: SubruleMethodOpts ): CstNode /** * @see SUBRULE * @hidden */ protected SUBRULE8( ruleToCall: (idx: number) => CstNode, options?: SubruleMethodOpts ): CstNode /** * @see SUBRULE * @hidden */ protected SUBRULE9( ruleToCall: (idx: number) => CstNode, options?: SubruleMethodOpts ): CstNode } /** * A Parser that relies on end user's embedded actions to control its output. * For more details see: * - https://sap.github.io/chevrotain/docs/tutorial/step3_adding_actions_root.html#alternatives * - https://sap.github.io/chevrotain/docs/tutorial/step3b_adding_actions_embedded.html#simple-example */ export declare class EmbeddedActionsParser extends BaseParser { /** * @deprecated use {@link Parser.performSelfAnalysis} **instance** method instead. */ protected static performSelfAnalysis(parserInstance: Parser): void // TODO: remove `outputCST` from the config options in the constructor /** * Creates a Grammar Rule */ protected RULE( name: string, implementation: (...implArgs: any[]) => T, config?: IRuleConfig ): (idxInCallingRule?: number, ...args: any[]) => T /** * Overrides a Grammar Rule * See usage example in: https://github.com/SAP/chevrotain/blob/master/examples/parser/versioning/versioning.js */ protected OVERRIDE_RULE( name: string, impl: (...implArgs: any[]) => T, config?: IRuleConfig ): (idxInCallingRule?: number, ...args: any[]) => T /** * Like `SUBRULE` with the numerical suffix as a parameter, e.g: * subrule(0, X) === SUBRULE(X) * subrule(1, X) === SUBRULE1(X) * subrule(2, X) === SUBRULE2(X) * ... * @see SUBRULE */ protected subrule( idx: number, ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * The Parsing DSL Method is used by one rule to call another. * It is equivalent to a non-Terminal in EBNF notation. * * This may seem redundant as it does not actually do much. * However using it is **mandatory** for all sub rule invocations. * * Calling another rule without wrapping in SUBRULE(...) * will cause errors/mistakes in the Parser's self analysis phase, * which will lead to errors in error recovery/automatic lookahead calculation * and any other functionality relying on the Parser's self analysis * output. * * As in CONSUME the index in the method name indicates the occurrence * of the sub rule invocation in its rule. * */ protected SUBRULE( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE1( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE2( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE3( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE4( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE5( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE6( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE7( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE8( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T /** * @see SUBRULE * @hidden */ protected SUBRULE9( ruleToCall: (idx: number) => T, options?: SubruleMethodOpts ): T } export declare enum ParserDefinitionErrorType { INVALID_RULE_NAME = 0, DUPLICATE_RULE_NAME = 1, INVALID_RULE_OVERRIDE = 2, DUPLICATE_PRODUCTIONS = 3, UNRESOLVED_SUBRULE_REF = 4, LEFT_RECURSION = 5, NONE_LAST_EMPTY_ALT = 6, AMBIGUOUS_ALTS = 7, CONFLICT_TOKENS_RULES_NAMESPACE = 8, INVALID_TOKEN_NAME = 9, INVALID_NESTED_RULE_NAME = 10, DUPLICATE_NESTED_NAME = 11, NO_NON_EMPTY_LOOKAHEAD = 12, AMBIGUOUS_PREFIX_ALTS = 13, TOO_MANY_ALTS = 14 } export interface ILexerDefinitionError { message: string type: LexerDefinitionErrorType tokenTypes?: TokenType[] } export declare class Lexer { static SKIPPED: string /** * A Constant to mark "abstract" TokenTypes that are used * purely as token categories. * See: {@link createToken.categories} */ static NA: RegExp lexerDefinitionErrors: ILexerDefinitionError[] /** * @param lexerDefinition - * Structure composed of Tokens Types this lexer will identify. * * In the simple case the structure is an array of TokenTypes. * In the case of {@link IMultiModeLexerDefinition} the structure is an object with two properties: * 1. a "modes" property where each value is an array of TokenTypes. * 2. a "defaultMode" property specifying the initial lexer mode. * * for example: * * ``` * { * modes : { * modeX : [Token1, Token2], * modeY : [Token3, Token4] * }, * * defaultMode : "modeY" * } * ``` * * A lexer with {@link MultiModesDefinition} is simply multiple Lexers where only one Lexer(mode) can be active at the same time. * This is useful for lexing languages where there are different lexing rules depending on context. * * The current lexing mode is selected via a "mode stack". * The last (peek) value in the stack will be the current mode of the lexer. * Defining entering and exiting lexer modes is done using the "push_mode" and "pop_mode" properites * of the {@link createToken.config} parameter. * * - The Lexer will match the **first** pattern that matches, Therefor the order of Token Types is significant. * For example when one pattern may match a prefix of another pattern. * * Note that there are situations in which we may wish to order the longer pattern after the shorter one. * For example: [keywords vs Identifiers](https://github.com/SAP/chevrotain/tree/master/examples/lexer/keywords_vs_identifiers). */ constructor( lexerDefinition: TokenType[] | IMultiModeLexerDefinition, config?: ILexerConfig ) /** * Will lex(Tokenize) a string. * Note that this can be called repeatedly on different strings as this method * does not modify the state of the Lexer. * * @param text - The string to lex * @param [initialMode] - The initial Lexer Mode to start with, by default this will be the first mode in the lexer's * definition. If the lexer has no explicit modes it will be the implicit single 'default_mode' mode. */ tokenize(text: string, initialMode?: string): ILexingResult } export interface ILexingResult { tokens: IToken[] groups: { [groupName: string]: IToken[] } errors: ILexingError[] } export interface ILexingError { offset: number line: number column: number length: number message: string } export interface ILexerConfig { /** * An optional flag indicating that lexer definition errors * should not automatically cause an error to be raised. * This can be useful when wishing to indicate lexer errors in another manner * than simply throwing an error (for example in an online playground). */ deferDefinitionErrorsHandling?: boolean /** * "full" location information means all six combinations of /(end|start)(Line|Column|Offset)/ properties. * "onlyStart" means that only startLine, startColumn and startOffset will be tracked * "onlyOffset" means that only the startOffset will be tracked. * * The less position tracking the faster the Lexer will be and the less memory used. * However the difference is not large (~10% On V8), thus reduced location tracking options should only be used * in edge cases where every last ounce of performance is needed. */ // TODO: consider renaming this to LocationTracking to align with NodeLocationTracking option on the ParserConfig. positionTracking?: "full" | "onlyStart" | "onlyOffset" /** * A regExp defining custom line terminators. * This will be used to calculate the line and column information. * * Note that the regExp should use the global flag, for example: /\n/g * * The default is: /\n|\r\n?/g * * But some grammars have a different definition, for example in ECMAScript: * https://www.ecma-international.org/ecma-262/8.0/index.html#sec-line-terminators * U+2028 and U+2029 are also treated as line terminators. * * In that case we would use /\n|\r|\u2028|\u2029/g * * Note that it is also possible to supply an optimized RegExp like implementation * as only a subset of the RegExp APIs is needed, {@link ILineTerminatorsTester} * for details. * * keep in mind that for the default pattern: /\n|\r\n?/g an optimized implementation is already built-in. * This means the optimization is only relevant for lexers overriding the default pattern. */ lineTerminatorsPattern?: RegExp | ILineTerminatorsTester /** * Characters or CharCodes that represent line terminators for this lexer. * This always needs to be provided when using a custom {@link ILexerConfig.lineTerminatorsPattern}. * In the future this duplication may be removed or reduced. */ lineTerminatorCharacters?: (number | string)[] /** * When true this flag will cause the Lexer to throw an Error * When it is unable to perform all of its performance optimizations. * * In addition error messages will be printed to the console with details * how to resolve the optimizations issues. * * Use this flag to guarantee higher lexer performance. * The optimizations can boost the lexer's performance anywhere from 30% * to 100%+ depending on the number of TokenTypes used. */ ensureOptimizations?: boolean /** * Can be used to disable lexer optimizations * If there is a suspicion they are causing incorrect behavior. * Note that this would have negative performance implications. */ safeMode?: boolean /** * A custom error message provider. * Can be used to override the default error messages. * For example: * - Translating the error messages to a different languages. * - Changing the formatting. */ errorMessageProvider?: ILexerErrorMessageProvider /** * Enabling this flag will print performance tracing logs during lexer * Initialization (constructor invocation), this is useful to narrow down the cause * of the initialization performance problem. * * You can also pass a numerical value which affects the verbosity * of the traces, this number is the maximum nesting level of the traces, e.g: * 0: Traces disabled === 'false' * 1: Top Level traces only. * 2: One level of nested inner traces. * ... * * Note that passing the boolean `true` is identical to passing the numerical value `infinity` */ traceInitPerf?: boolean | number /** * This flag will avoid running the Lexer validations during Lexer initialization. * * This can substantially improve the Lexer's initialization (constructor) time. * @see ILexerConfig.traceInitPerf to measure the Lexer validations cost for your Lexer. * * Note that the Lexer validations are **extremely useful** during development time, * e.g: Detecting empty/invalid regExp Patterns. * So they should not be skipped during development flows. * - For example: via a conditional that checks an env variable. */ skipValidations?: boolean } export interface ILexerErrorMessageProvider { /** * An Unexpected Character Error occurs when the lexer is unable to match a range of one or more * characters in the input text against any of the Token Types in it's Lexer definition * * @param fullText - Full original input text. * * @param startOffset - Offset in input text where error starts. * * @param length - Error length. * * @param line - Line number where the error occured. (optional) * Will not be provided when lexer is not defined to track lines/columns * * @param column - Column number where the error occured. (optional) * Will not be provided when lexer is not defined to track lines/columns */ buildUnexpectedCharactersMessage( fullText: string, startOffset: number, length: number, line?: number, column?: number ): string /** * Unable To Pop Lexer Mode Error happens when lexer tries to pop the last remaining mode from the mode stack * so that there is no longer any active lexer mode * This error only relevant for multi-mode lexers * * @param token - The Token that requested pop mode. */ buildUnableToPopLexerModeMessage(token: IToken): string } /** * This is the default logic Chevrotain uses to construct lexing error messages. * It can be used as a reference or as a starting point customize a lexer's * error messages. * * - See: {@link ILexerConfig.errorMessageProvider} */ export declare const defaultLexerErrorProvider: ILexerErrorMessageProvider /** * A subset of the regExp interface. * Needed to compute line/column info by a chevrotain lexer. */ export interface ILineTerminatorsTester { /** * Just like regExp.test */ test: (text: string) => boolean /** * Just like the regExp lastIndex with the global flag enabled * It should be updated after every match to point to the offset where the next * match attempt starts. */ lastIndex: number } export type TokenPattern = | RegExp | string | CustomPatternMatcherFunc | ICustomPattern export interface ITokenConfig { name: string /** * Categories enable polymorphism on Token Types. * A TokenType X with categories C1, C2, ... ,Cn can * be matched by the parser against any of those categories. * In practical terms this means that: * CONSUME(C1) can match a Token of type X. */ categories?: TokenType | TokenType[] /** * The Label is a human readable name to be used * in error messages and syntax diagrams. * * For example a TokenType may be called LCurly, which is * short for "left curly brace". The much easier to understand * label could simply be "{". */ label?: string /** * This defines what sequence of characters would be matched * To this TokenType when Lexing. * * For Custom Patterns see: http://sap.github.io/chevrotain/docs/guide/custom_token_patterns.html */ pattern?: TokenPattern /** * The group property will cause the lexer to collect * Tokens of this type separately from the other Tokens. * * For example this could be used to collect comments for * post processing. * * See: https://github.com/SAP/chevrotain/tree/master/examples/lexer/token_groups */ group?: string /** * A name of a Lexer mode to "enter" once this Token Type has been matched. * Lexer modes can be used to support different sets of possible Tokens Types * * Lexer Modes work as a stack of Lexers, so "entering" a mode means pushing it to the top of the stack. * * See: https://github.com/SAP/chevrotain/tree/master/examples/lexer/multi_mode_lexer */ push_mode?: string /** * If "pop_mode" is true the Lexer will pop the last mode of the modes stack and * continue lexing using the new mode at the top of the stack. * * See: https://github.com/SAP/chevrotain/tree/master/examples/lexer/multi_mode_lexer */ pop_mode?: boolean /** * The "longer_alt" property will cause the Lexer to attempt matching against another Token Type * every time this Token Type has been matched. * * This feature can be useful when two Token Types have common prefixes which * cannot be resolved (only) by the ordering of the Tokens in the lexer definition. * * For example see: https://github.com/SAP/chevrotain/tree/master/examples/lexer/keywords_vs_identifiers * For resolving the keywords vs Identifier ambiguity. */ longer_alt?: TokenType /** * Can a String matching this Token Type's pattern possibly contain a line terminator? * If true and the line_breaks property is not also true this will cause inaccuracies in the Lexer's line / column tracking. */ line_breaks?: boolean /** * Possible starting characters or charCodes of the pattern. * These will be used to optimize the Lexer's performance. * * These are normally **automatically** computed, however the option to explicitly * specify those can enable optimizations even when the automatic analysis fails. * * e.g: * * strings hints should be one character long. * ``` * { start_chars_hint: ["a", "b"] } * ``` * * * number hints are the result of running ".charCodeAt(0)" on the strings. * ``` * { start_chars_hint: [97, 98] } * ``` * * * For unicode characters outside the BMP use the first of their surrogate pairs. * for example: The '💩' character is represented by surrogate pairs: '\uD83D\uDCA9' * and D83D is 55357 in decimal. * * Note that "💩".charCodeAt(0) === 55357 */ start_chars_hint?: (string | number)[] } /** * Creates a new TokenType which can then be used * to define a Lexer and Parser */ export declare function createToken(config: ITokenConfig): TokenType /** * Utility to create Chevrotain IToken "instances" * Note that Chevrotain tokens are not real TokenTypes instances * and thus the instanceOf cannot be used with them. */ export declare function createTokenInstance( tokType: TokenType, image: string, startOffset: number, endOffset: number, startLine: number, endLine: number, startColumn: number, endColumn: number ): IToken /** * API #1 [Custom Token Patterns](http://sap.github.io/chevrotain/docs/guide/custom_token_patterns.html). */ export declare type CustomPatternMatcherFunc = ( /** * The full input string. */ text: string, /** * The offset at which to attempt a match */ offset: number, /** * Previously scanned Tokens */ tokens: IToken[], /** * Token Groups */ groups: { [groupName: string]: IToken[] } ) => CustomPatternMatcherReturn | RegExpExecArray | null // RegExpExecArray included for legacy reasons export type CustomPatternMatcherReturn = [string] & { payload?: any } export interface TokenType { name: string GROUP?: string PATTERN?: TokenPattern LABEL?: string LONGER_ALT?: TokenType POP_MODE?: boolean PUSH_MODE?: string LINE_BREAKS?: boolean CATEGORIES?: TokenType[] tokenTypeIdx?: number categoryMatches?: number[] categoryMatchesMap?: { [tokType: number]: boolean } isParent?: boolean START_CHARS_HINT?: (string | number)[] } /** * API #2 for [Custom Token Patterns](http://sap.github.io/chevrotain/docs/guide/custom_token_patterns.html). */ interface ICustomPattern { exec: CustomPatternMatcherFunc } /** * Things to note: * - The offset range is inclusive to exclusive. * * - A lineTerminator as the last character does not effect the Token's line numbering. * In other words a new line only starts **after** a line terminator. * * - A Token's image is it's **literal** text. * e.g unicode escaping is untouched. */ export interface IToken { /** The textual representation of the Token as it appeared in the text. */ image: string /** Offset of the first character of the Token. */ startOffset: number /** Line of the first character of the Token. */ startLine?: number /** Column of the first character of the Token. */ startColumn?: number /** Offset of the last character of the Token. */ endOffset?: number /** Line of the last character of the Token. */ endLine?: number /** Column of the last character of the Token. */ endColumn?: number /** this marks if a Token does not really exist and has been inserted "artificially" during parsing in rule error recovery. */ isInsertedInRecovery?: boolean /** An number index representing the type of the Token use to get the Token Type from a token "instance" */ tokenTypeIdx: number /** * The actual Token Type of this Token "instance" * This is the same Object returned by the "createToken" API. * This property is very useful for debugging the Lexing and Parsing phases. */ tokenType: TokenType /** * Custom Payload value, this is an optional feature of Custom Token Patterns * For additional details see the docs: * https://sap.github.io/chevrotain/docs/guide/custom_token_patterns.html#custom-payloads */ payload?: any } export declare function tokenName(tokType: TokenType): string /** * Returns a human readable label for a TokenType if such exists, * otherwise will return the TokenType's name. * * Labels are useful in improving the readability of error messages and syntax diagrams. * To define labels provide the label property in the {@link createToken} config parameter. */ export declare function tokenLabel(tokType: TokenType): string /** * A Utility method to check if a token is of the type of the argument Token class. * This utility is needed because Chevrotain tokens support "categories" which means * A TokenType may have multiple categories. * * This means a simple comparison using the {@link IToken.tokenType} property may not suffice. * For example: * * ``` * import { createToken, tokenMatcher, Lexer } from "chevrotain" * * // An "abstract" Token used only for categorization purposes. * const NumberTokType = createToken({ name: "NumberTokType", pattern: Lexer.NA }) * * const IntegerTokType = createToken({ * name: "IntegerTokType", * pattern: /\d+/, * // Integer "Is A" Number * categories: [NumberTokType] * }) * * const DecimalTokType = createToken({ * name: "DecimalTokType", * pattern: /\d+\.\d+/, * // Double "Is A" Number * categories: [NumberTokType] * }) * * // Will always be false as the tokenType property can only * // be Integer or Double Token Types as the Number TokenType is "abstract". * if (myToken.tokenType === NumberTokType) { /* ... *\/ } * * // Will be true when myToken is of Type Integer or Double. * // Because the hierarchy defined by the categories is taken into account. * if (tokenMatcher(myToken, NumberTokType) { /* ... *\/ } * ``` * * @returns true iff the token matches the TokenType. */ export function tokenMatcher(token: IToken, tokType: TokenType): boolean export declare type MultiModesDefinition = { [modeName: string]: TokenType[] } export interface IMultiModeLexerDefinition { modes: MultiModesDefinition defaultMode: string } export type TokenTypeDictionary = { [tokenName: string]: TokenType } export declare type TokenVocabulary = | TokenTypeDictionary | TokenType[] | IMultiModeLexerDefinition export interface IRuleConfig { /** * The function which will be invoked to produce the returned value for a production that have not been * successfully executed and the parser recovered from. */ recoveryValueFunc?: () => T /** * Enable/Disable re-sync error recovery for this specific production. */ resyncEnabled?: boolean } export interface DSLMethodOpts { /** * in-lined method name */ NAME?: string /** * The Grammar to process in this method. */ DEF: GrammarAction /** * A semantic constraint on this DSL method * @see https://github.com/SAP/chevrotain/blob/master/examples/parser/predicate_lookahead/predicate_lookahead.js * For farther details. */ GATE?: () => boolean /** * Maximum number of "following tokens" which would be used to * Choose between the alternatives. * * By default this value is determined by the {@link IParserConfig.maxLookahead} value. * A Higher value may be used for a specific DSL method to resolve ambiguities * And a lower value may be used to resolve slow initialization times issues. * * TODO: create full docs and link */ MAX_LOOKAHEAD?: number } export interface DSLMethodOptsWithErr extends DSLMethodOpts { /** * Short title/classification to what is being matched. * Will be used in the error message,. * If none is provided, the error message will include the names of the expected * Tokens sequences which start the method's inner grammar */ ERR_MSG?: string } export interface OrMethodOpts { NAME?: string /** * The set of alternatives, * See detailed description in {@link Parser.OR} */ DEF: IOrAlt[] /** * A description for the alternatives used in error messages * If none is provided, the error message will include the names of the expected * Tokens sequences which may start each alternative. */ ERR_MSG?: string /** * A Flag indicating that **all** ambiguities in this alternation should * be ignored. * * This flag should only be used in rare circumstances, * As normally alternation ambiguities should be resolved in other ways: * - Re-ordering the alternatives. * - Re-factoring the grammar to extract common prefixes before alternation. * - Using gates {@link IOrAlt.GATE} to implement custom lookahead logic. * - Using the more granular {@link IOrAlt.IGNORE_AMBIGUITIES} on a **specific** alternative. */ IGNORE_AMBIGUITIES?: boolean /** * Maximum number of "following tokens" which would be used to * Choose between the alternatives. * * By default this value is determined by the {@link IParserConfig.maxLookahead} value. * A Higher value may be used for a specific DSL method to resolve ambiguities * And a lower value may be used to resolve slow initialization times issues. * * TODO: create full docs and link */ MAX_LOOKAHEAD?: number } export interface ManySepMethodOpts { NAME?: string /** * The grammar to process in each iteration. */ DEF: GrammarAction /** * The separator between each iteration. */ SEP: TokenType /** * @see DSLMethodOpts.MAX_LOOKAHEAD */ MAX_LOOKAHEAD?: number } export interface AtLeastOneSepMethodOpts extends ManySepMethodOpts { /** * Short title/classification to what is being matched. * Will be used in the error message,. * If none is provided, the error message will include the names of the expected * Tokens sequences which start the method's inner grammar. */ ERR_MSG?: string } export interface ConsumeMethodOpts { /** * A custom Error message if the Token could not be consumed. * This will override any error message provided by the parser's "errorMessageProvider" */ ERR_MSG?: string /** * A label to be used instead of the TokenType name in the created CST. */ LABEL?: string } export interface SubruleMethodOpts { /** * The arguments to parameterized rules, see: * https://github.com/SAP/chevrotain/blob/master/examples/parser/parametrized_rules/parametrized.js */ ARGS?: any[] /** * A label to be used instead of the subrule's name in the created CST. */ LABEL?: string } export declare type GrammarAction = () => OUT /** * TODO: remove this in next major version this `IOrAlt` is enough * @deprecated */ export declare type IAnyOrAlt = any export interface IOrAlt { NAME?: string GATE?: () => boolean ALT: () => any /** * A Flag indicating that any ambiguities involving this * specific alternative Should be ignored. * * This flag will be **implicitly** enabled if a GATE is used * as the assumption is that the GATE is used to resolve an ambiguity. */ IGNORE_AMBIGUITIES?: boolean } export interface IOrAltWithGate extends IOrAlt { // TODO: deprecate this interface } export interface ICstVisitor { visit(cstNode: CstNode | CstNode[], param?: IN): OUT validateVisitor(): void } /** * A [Concrete Syntax Tree](http://sap.github.io/chevrotain/docs/guide/concrete_syntax_tree.html) Node. * This structure represents the whole parse tree of the grammar * This means that information on each and every Token is present. * This is unlike an AST (Abstract Syntax Tree) where some of the syntactic information is missing. * * For example given an ECMAScript grammar, an AST would normally not contain information on the location * of Commas, Semi colons, redundant parenthesis ect, however a CST would have that information. */ export interface CstNode { readonly name: string readonly children: CstChildrenDictionary readonly recoveredNode?: boolean /** * Will only be present if the {@link IParserConfig.nodeLocationTracking} is * **not** set to "none". * See: http://sap.github.io/chevrotain/docs/guide/concrete_syntax_tree.html#cstnode-location * For more details. */ readonly location?: CstNodeLocation /** * Only relevant for [in-lined](http://sap.github.io/chevrotain/docs/guide/concrete_syntax_tree.html#in-lined-rules) rules. * the fullName will **also** include the name of the top level rule containing this nested rule. */ readonly fullName?: string } /** * The Column/Line properties will only be present when * The {@link IParserConfig.nodeLocationTracking} is set to "full". */ export interface CstNodeLocation { startOffset: number startLine: number startColumn?: number endOffset?: number endLine?: number endColumn?: number } export declare type CstChildrenDictionary = { [identifier: string]: CstElement[] } export declare type CstElement = IToken | CstNode export declare type nodeLocationTrackingOptions = "full" | "onlyOffset" | "none" export interface IParserConfig { /** * Is the error recovery / fault tolerance of the Chevrotain Parser enabled. */ recoveryEnabled?: boolean /** * Maximum number of tokens the parser will use to choose between alternatives. * By default this value is `4`. * In the future it may be reduced to `3` due to performance considerations. */ maxLookahead?: number /** * @deprecated - use the IGNORE_AMBIGUITIES flag on the relevant DSL method instead * - {@link IOrAlt.IGNORE_AMBIGUITIES} * - {@link OrMethodOpts.IGNORE_AMBIGUITIES} * * Used to mark parser definition errors that should be ignored. * For example: * * ``` * { * myCustomRule : { * OR3 : true * }, * myOtherRule : { * OPTION1 : true, * OR4 : true * } * } * ``` * * Be careful when ignoring errors, they are usually there for a reason :). */ ignoredIssues?: IgnoredParserIssues /** * Enable This Flag to to support Dynamically defined Tokens. * This will disable performance optimizations which cannot work if the whole Token vocabulary is not known * During Parser initialization. * * See [runnable example](https://github.com/SAP/chevrotain/tree/master/examples/parser/dynamic_tokens) */ dynamicTokensEnabled?: boolean /** * @deprecated - extend either CstParser or EmbeddedActionsParser to control this flag instead * - @see CstParser * - @see EmbeddedActionsParser * * Enable automatic Concrete Syntax Tree creation * For in-depth docs on [Concrete Syntax Trees](http://sap.github.io/chevrotain/docs/guide/concrete_syntax_tree.html): */ outputCst?: boolean /** * Enable computation of CST nodes location. * By default this is set to "none", meaning this feature is disabled. * See: http://sap.github.io/chevrotain/docs/guide/concrete_syntax_tree.html#cstnode-location * For more details. */ nodeLocationTracking?: nodeLocationTrackingOptions /** * A custom error message provider. * Can be used to override the default error messages. * For example: * - Translating the error messages to a different languages. * - Changing the formatting. * - Providing special error messages under certain conditions, e.g: missing semicolons. */ errorMessageProvider?: IParserErrorMessageProvider /** * Enabling this flag will print performance tracing logs during parser * Initialization (constructor invocation), this is useful to narrow down the cause * of the initialization performance problem. * * You can also pass a numerical value which affects the verbosity * of the traces, this number is the maximum nesting level of the traces, e.g: * 0: Traces disabled === 'false' * 1: Top Level traces only. * 2: One level of nested inner traces. * ... * * Note that passing the boolean `true` is identical to passing the numerical value `infinity` */ traceInitPerf?: boolean | number /** * This flag will avoid running the grammar validations during Parser initialization. * * This can substantially improve the Parser's initialization (constructor) time. * @see IParserConfig.traceInitPerf to measure the grammar validations cost for your parser. * * Note that the grammar validations are **extremely useful** during development time, * e.g: detecting ambiguities / left recursion. * So they should not be skipped during development flows. * - For example: via a conditional that checks an env variable. */ skipValidations?: boolean } /** * See: {@link IParserConfig.ignoredIssues} */ export declare type IgnoredParserIssues = { [ruleName: string]: IgnoredRuleIssues } /** * See: {@link IParserConfig.ignoredIssues} */ export declare type IgnoredRuleIssues = { [dslNameAndOccurrence: string]: boolean } export interface IParserErrorMessageProvider { /** * Mismatched Token Error happens when the parser attempted to consume a terminal and failed. * It corresponds to a failed {@link Parser.CONSUME} in Chevrotain DSL terms. * * @param options.expected - The expected Token Type. * * @param options.actual - The actual Token "instance". * * @param options.previous - The previous Token "instance". * This is useful if options.actual[0] is of type chevrotain.EOF and you need to know the last token parsed. * * @param options.ruleName - The rule in which the error occurred. */ buildMismatchTokenMessage?(options: { expected: TokenType actual: IToken previous: IToken ruleName: string }): string /** * A Redundant Input Error happens when the parser has completed parsing but there * is still unprocessed input remaining. * * @param options.firstRedundant - The first unprocessed token "instance". * * @param options.ruleName - The rule in which the error occurred. */ buildNotAllInputParsedMessage?(options: { firstRedundant: IToken ruleName: string }): string /** * A No Viable Alternative Error happens when the parser cannot detect any valid alternative in an alternation. * It corresponds to a failed {@link Parser.OR} in Chevrotain DSL terms. * * @param options.expectedPathsPerAlt - First level of the array represents each alternative * The next two levels represent valid (expected) paths in each alternative. * * @param options.actual - The actual sequence of tokens encountered. * * @param options.previous - The previous Token "instance". * This is useful if options.actual[0] is of type chevrotain.EOF and you need to know the last token parsed. * * @param options.customUserDescription - A user may provide custom error message descriptor in the {@link Parser.AT_LEAST_ONE} DSL method * options parameter, this is that custom message. * * @param options.ruleName - The rule in which the error occurred. */ buildNoViableAltMessage?(options: { expectedPathsPerAlt: TokenType[][][] actual: IToken[] previous: IToken customUserDescription: string ruleName: string }): string /** * An Early Exit Error happens when the parser cannot detect the first mandatory iteration of a repetition. * It corresponds to a failed {@link Parser.AT_LEAST_ONE} or {@link Parser.AT_LEAST_ONE_SEP} in Chevrotain DSL terms. * * @param options.expectedIterationPaths - The valid (expected) paths in the first iteration. * * @param options.actual - The actual sequence of tokens encountered. * * @param options.previous - The previous Token "instance". * This is useful if options.actual[0] is of type chevrotain.EOF and you need to know the last token parsed. * * @param options.customUserDescription - A user may provide custom error message descriptor in the {@link Parser.AT_LEAST_ONE} DSL method * options parameter, this is that custom message. * * @param options.ruleName - The rule in which the error occurred. */ buildEarlyExitMessage?(options: { expectedIterationPaths: TokenType[][] actual: IToken[] previous: IToken customUserDescription: string ruleName: string }): string } export interface IRecognizerContext { /** * A copy of the parser's rule stack at the "time" the RecognitionException occurred. * This can be used to help debug parsing errors (How did we get here?). */ ruleStack: string[] /** * A copy of the parser's rule occurrence stack at the "time" the RecognitionException occurred. * This can be used to help debug parsing errors (How did we get here?). */ ruleOccurrenceStack: number[] } export declare type ISeparatedIterationResult = { values: OUT[] separators: IToken[] } export interface ISerializedGast { type: | "NonTerminal" | "Flat" | "Option" | "RepetitionMandatory" | "RepetitionMandatoryWithSeparator" | "Repetition" | "RepetitionWithSeparator" | "Alternation" | "Terminal" | "Rule" definition?: ISerializedGast[] } /** * Structure for the path the parser "took" to reach a certain position * in the grammar. */ export interface IGrammarPath { /** * The Grammar rules invoked and still unterminated to reach this Grammar Path. */ ruleStack: string[] /** * The occurrence index (SUBRULE1/2/3/5/...) of each Grammar rule invoked and still unterminated. * Used to distinguish between **different** invocations of the same subrule at the same top level rule. */ occurrenceStack: number[] } export interface ISyntacticContentAssistPath extends IGrammarPath { nextTokenType: TokenType nextTokenOccurrence: number } export interface ITokenGrammarPath extends IGrammarPath { lastTok: TokenType lastTokOccurrence: number } export declare enum LexerDefinitionErrorType { MISSING_PATTERN = 0, INVALID_PATTERN = 1, EOI_ANCHOR_FOUND = 2, UNSUPPORTED_FLAGS_FOUND = 3, DUPLICATE_PATTERNS_FOUND = 4, INVALID_GROUP_TYPE_FOUND = 5, PUSH_MODE_DOES_NOT_EXIST = 6, MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE = 7, MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY = 8, MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST = 9, LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED = 10, SOI_ANCHOR_FOUND = 11, EMPTY_MATCH_PATTERN = 12, NO_LINE_BREAKS_FLAGS = 13, UNREACHABLE_PATTERN = 14, IDENTIFY_TERMINATOR = 15, CUSTOM_LINE_BREAK = 16 } /** * Type of End Of File Token. */ export declare const EOF: TokenType /** * Convenience used to express an **empty** alternative in an OR (alternation). * can be used to more clearly describe the intent in a case of empty alternation. * * For example: * * 1. without using EMPTY_ALT: * ``` * this.OR([ * {ALT: () => { * this.CONSUME1(OneTok) * return "1" * }}, * {ALT: () => { * this.CONSUME1(TwoTok) * return "2" * }}, * // implicitly empty because there are no invoked grammar * // rules (OR/MANY/CONSUME...) inside this alternative. * {ALT: () => { * return "666" * }}, * ]) * ``` * * 2. using EMPTY_ALT: * ``` * this.OR([ * {ALT: () => { * this.CONSUME1(OneTok) * return "1" * }}, * {ALT: () => { * this.CONSUME1(TwoTok) * return "2" * }}, * // explicitly empty, clearer intent * {ALT: EMPTY_ALT("666")}, * ]) * ``` */ export declare function EMPTY_ALT(value?: T): () => T /** * This is the default logic Chevrotain uses to construct error messages. * It can be used as a reference or as a starting point customize a parser's * error messages. * * - See: {@link IParserConfig.errorMessageProvider} */ export declare const defaultParserErrorProvider: IParserErrorMessageProvider /** * A Chevrotain Parser runtime exception. */ export interface IRecognitionException { name: string message: string /** * The token which caused the parser error. */ token: IToken /** * Additional tokens which have been re-synced in error recovery due to the original error. * This information can be used the calculate the whole text area which has been skipped due to an error. * For example for displaying with a red underline in a text editor. */ resyncedTokens: IToken[] context: IRecognizerContext } /** * A utility to detect if an Error is a Chevrotain Parser's runtime exception. */ export declare function isRecognitionException(error: Error): boolean // TODO refactor exceptions constructors to classes /** * An exception of this type will be saved in {@link Parser.errors} when {@link Parser.CONSUME} * was called but failed to match the expected Token Type. */ export declare class MismatchedTokenException extends Error { constructor(message: string, token: IToken, previousToken: IToken) } /** * An exception of this type will be saved in {@link Parser.errors} when {@link Parser.OR} * was called yet none of the possible alternatives could be matched. */ export declare class NoViableAltException extends Error { constructor(message: string, token: IToken, previousToken: IToken) } /** * An exception of this type will be saved in {@link Parser.errors} when * the parser has finished yet there exists remaining input (tokens) that has not processed. */ export declare class NotAllInputParsedException extends Error { constructor(message: string, token: IToken) } /** * An exception of this type will be saved in {@link Parser.errors} when {@link Parser.AT_LEAST_ONE} * or {@link Parser.AT_LEAST_ONE_SEP} was called but failed to match even a single iteration. */ export declare class EarlyExitException extends Error { constructor(message: string, token: IToken, previousToken: IToken) } export interface IOptionallyNamedProduction { name?: string } export interface IProduction { accept(visitor: IGASTVisitor): void } export interface IProductionWithOccurrence extends IProduction { idx: number } /** * A very basic implementation of a Visitor Pattern * For the Grammar AST structure. * * This may be useful for advanced users who create custom logic on the grammar AST. * For example, custom validations or introspection. */ export abstract class GAstVisitor { visit(node: IProduction): any abstract visitNonTerminal(node: NonTerminal): any abstract visitFlat(node: Flat): any abstract visitOption(node: Option): any abstract visitRepetition(node: Repetition): any abstract visitRepetitionMandatory(node: RepetitionMandatory): any abstract visitRepetitionMandatoryWithSeparator( node: RepetitionMandatoryWithSeparator ): any abstract visitRepetitionWithSeparator(node: RepetitionWithSeparator): any abstract visitAlternation(node: Alternation): any abstract visitTerminal(node: Terminal): any abstract visitRule(node: Rule): any } /** * The Grammar AST class representing a top level {@link Parser.RULE} call. */ export declare class Rule { name: string orgText: string definition: IProduction[] constructor(options: { name: string definition: IProduction[] orgText?: string }) accept(visitor: IGASTVisitor): void } /** * The Grammar AST class representing a top level {@link Parser.SUBRULE} call. */ export declare class NonTerminal implements IProductionWithOccurrence { nonTerminalName: string referencedRule: Rule idx: number constructor(options: { nonTerminalName: string referencedRule?: Rule idx?: number }) definition: IProduction[] accept(visitor: IGASTVisitor): void } /** * The Grammar AST class used to represent a sequence. * This is normally only used in {@link Alternation} to distinguish * between the different alternatives. */ export declare class Flat implements IOptionallyNamedProduction { name: string definition: IProduction[] constructor(options: { definition: IProduction[]; name?: string }) accept(visitor: IGASTVisitor): void } /** * The Grammar AST class representing a {@link Parser.OPTION} call. */ export declare class Option implements IProductionWithOccurrence, IOptionallyNamedProduction { idx: number name?: string definition: IProduction[] constructor(options: { definition: IProduction[] idx?: number name?: string }) accept(visitor: IGASTVisitor): void } /** * The Grammar AST class representing a {@link Parser.AT_LEAST_ONE} call. */ export declare class RepetitionMandatory implements IProductionWithOccurrence, IOptionallyNamedProduction { name: string idx: number definition: IProduction[] constructor(options: { definition: IProduction[] idx?: number name?: string }) accept(visitor: IGASTVisitor): void } /** * The Grammar AST class representing a {@link Parser.AT_LEAST_ONE_SEP} call. */ export declare class RepetitionMandatoryWithSeparator implements IProductionWithOccurrence, IOptionallyNamedProduction { separator: TokenType idx: number name: string definition: IProduction[] constructor(options: { definition: IProduction[] separator: TokenType idx?: number name?: string }) accept(visitor: IGASTVisitor): void } /** * The Grammar AST class representing a {@link Parser.MANY} call. */ export declare class Repetition implements IProductionWithOccurrence, IOptionallyNamedProduction { separator: TokenType idx: number name: string definition: IProduction[] constructor(options: { definition: IProduction[] idx?: number name?: string }) accept(visitor: IGASTVisitor): void } /** * The Grammar AST class representing a {@link Parser.MANY_SEP} call. */ export declare class RepetitionWithSeparator implements IProductionWithOccurrence, IOptionallyNamedProduction { separator: TokenType idx: number name: string definition: IProduction[] constructor(options: { definition: IProduction[] separator: TokenType idx?: number name?: string }) accept(visitor: IGASTVisitor): void } /** * The Grammar AST class representing a {@link Parser.OR} call. */ export declare class Alternation implements IProductionWithOccurrence, IOptionallyNamedProduction { idx: number name: string definition: IProduction[] constructor(options: { definition: IProduction[] idx?: number name?: string }) accept(visitor: IGASTVisitor): void } /** * The Grammar AST class representing a {@link Parser.CONSUME} call. */ export declare class Terminal implements IProductionWithOccurrence { terminalType: TokenType idx: number constructor(options: { terminalType: TokenType; idx?: number }) accept(visitor: IGASTVisitor): void } export interface IGASTVisitor { visit(prod: IProduction): any } /** * Serialize a Grammar to a JSON Object. * * This can be useful for scenarios requiring exporting the grammar structure * for example drawing syntax diagrams. */ export declare function serializeGrammar(topRules: Rule[]): ISerializedGast[] /** * Like {@link serializeGrammar} but for a single GAST Production instead of a set of Rules. */ export declare function serializeProduction(node: IProduction): ISerializedGast /** * A utility to resolve a grammar AST (rules parameter). * "Resolving" means assigning the appropiate value for all {@link NonTerminal.referencedRule} * properties in the grammar AST. * * - See detailed docs for [Custom APIs](http://sap.github.io/chevrotain/docs/guide/custom_apis.html) */ export declare function resolveGrammar(options: { rules: Rule[] errMsgProvider?: IGrammarResolverErrorMessageProvider }): IParserDefinitionError[] /** * A utility to validate a grammar AST (rules parameter). * For example: left recursion detection, ambiguity detection, ... * * - See detailed docs for [Custom APIs](http://sap.github.io/chevrotain/docs/guide/custom_apis.html) */ export declare function validateGrammar(options: { rules: Rule[] /** * The maximum lookahead used in the grammar. * This number is needed to perform ambiguity detection. */ maxLookahead: number /** * The Token Types used by the grammar. */ tokenTypes: TokenType[] grammarName: string errMsgProvider: IGrammarValidatorErrorMessageProvider ignoredIssues?: IgnoredParserIssues }): IParserDefinitionError[] /** * A utility for assigning unique occurence indices to a grammar AST (rules parameter). * This can be useful when using Chevrotain to create custom APIs. * * - FAQ: [Why are these unique occurences needed](http://sap.github.io/chevrotain/docs/FAQ.html#NUMERICAL_SUFFIXES) * - See detailed docs for [Custom APIs](http://sap.github.io/chevrotain/docs/guide/custom_apis.html) */ export declare function assignOccurrenceIndices(options: { rules: Rule[] }): void /** * The default grammar validations errror message provider used by Chevrotain. * this can be used as the basis for custom error providers when using Chevrotain's * custom APIs. * * - See detailed docs for [Custom APIs](http://sap.github.io/chevrotain/docs/guide/custom_apis.html#grammar-validations) */ export declare const defaultGrammarValidatorErrorProvider: IGrammarValidatorErrorMessageProvider /** * The default grammar resolver errror message provider used by Chevrotain. * this can be used as the basis for custom error providers when using Chevrotain's * custom APIs. * * - See detailed docs for [Custom APIs](http://sap.github.io/chevrotain/docs/guide/custom_apis.html#grammar-validations) */ export declare const defaultGrammarResolverErrorProvider: IGrammarResolverErrorMessageProvider /** * Implementing this interface enables customizing grammar validation errors * when using custom APIs. * * - See detailed docs for [Custom APIs](http://sap.github.io/chevrotain/docs/guide/custom_apis.html#grammar-validations) */ export interface IGrammarValidatorErrorMessageProvider { buildDuplicateFoundError( topLevelRule: Rule, duplicateProds: IProductionWithOccurrence[] ): string buildInvalidNestedRuleNameError( topLevelRule: Rule, nestedProd: IOptionallyNamedProduction ): string buildDuplicateNestedRuleNameError( topLevelRule: Rule, nestedProd: IOptionallyNamedProduction[] ): string buildNamespaceConflictError(topLevelRule: Rule): string buildAlternationPrefixAmbiguityError(options: { topLevelRule: Rule prefixPath: TokenType[] ambiguityIndices: number[] alternation: Alternation }): string buildAlternationAmbiguityError(options: { topLevelRule: Rule prefixPath: TokenType[] ambiguityIndices: number[] alternation: Alternation }): string buildEmptyRepetitionError(options: { topLevelRule: Rule repetition: IProductionWithOccurrence }): string buildTokenNameError(options: { tokenType: TokenType expectedPattern: RegExp }): any buildEmptyAlternationError(options: { topLevelRule: Rule alternation: Alternation emptyChoiceIdx: number }): any buildTooManyAlternativesError(options: { topLevelRule: Rule alternation: Alternation }): string buildLeftRecursionError(options: { topLevelRule: Rule leftRecursionPath: Rule[] }): string buildInvalidRuleNameError(options: { topLevelRule: Rule expectedPattern: RegExp }): string buildDuplicateRuleNameError(options: { topLevelRule: Rule | string grammarName: string }): string } /** * Implementing this interface enables customizing grammar resolving errors * when using custom APIs. * * - See detailed docs for [Custom APIs](http://sap.github.io/chevrotain/docs/guide/custom_apis.html#grammar-validations) */ export interface IGrammarResolverErrorMessageProvider { buildRuleNotFoundError( topLevelRule: Rule, undefinedRule: NonTerminal ): string } /** * Structure of grammar validations errors. * * - See detailed docs for [Custom APIs](http://sap.github.io/chevrotain/docs/guide/custom_apis.html#grammar-validations) */ export interface IParserDefinitionError { message: string type: ParserDefinitionErrorType ruleName?: string } /** * @deprecated * This function no longer does anything, Avoid using this function * As it will be removed in future versions. */ export declare function clearCache(): void /** * Structure of configuration object for {@link createSyntaxDiagramsCode} */ export interface ICreateSyntaxDiagramsConfig { /** * Base Url to load the runtime resources for rendering the diagrams */ resourceBase?: string /** * Url to load the styleSheet, replace with your own for styling customization. */ css?: string } /** * Will generate an html source code (text). * This html text will render syntax diagrams for the provided grammar. * * - See detailed docs for [Syntax Diagrams](http://sap.github.io/chevrotain/docs/guide/generating_syntax_diagrams.html). */ export declare function createSyntaxDiagramsCode( grammar: ISerializedGast[], config?: ICreateSyntaxDiagramsConfig ): string /** * Generate A Parser factory from a set of Rules. * * This variant will Create a factory function that once invoked with a IParserConfig will return * a Parser Object. * * - Note that this happens using the Function constructor (a type of "eval") so it will not work in environments * where content security policy is enabled, such as certain websites, Chrome extensions ect... * * This means this function is best used for development flows to reduce the feedback loops * or for productive flows targeting node.js only. * * For productive flows targeting a browser runtime see {@link generateParserModule}. * * - See detailed docs for [Custom APIs](http://sap.github.io/chevrotain/docs/guide/custom_apis.html). */ export declare function generateParserFactory(options: { name: string rules: Rule[] tokenVocabulary: TokenVocabulary }): (config?: IParserConfig) => Parser /** * Generate A Parser's text from a set of Rules. * * This variant will generate the **string literal** for a UMD module https://github.com/umdjs/umd * That exports a Parser Constructor. * * - Note that the constructor exposed by the generated module must receive the TokenVocabulary as the first * argument, the IParser config can be passed as the second argument. * * - See detailed docs for [Custom APIs](http://sap.github.io/chevrotain/docs/guide/custom_apis.html). */ export declare function generateParserModule(options: { name: string rules: Rule[] }): string ================================================ FILE: vipercard/vipercard/external/clipboard.js-2.0.6-notbundled/LICENSE ================================================ MIT License Copyright (c) Zeno Rocha Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: vipercard/vipercard/external/clipboard.js-2.0.6-notbundled/clipboard.js ================================================ /*! * clipboard.js v2.0.6 * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["ClipboardJS"] = factory(); else root["ClipboardJS"] = factory(); })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 6); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports) { function select(element) { var selectedText; if (element.nodeName === 'SELECT') { element.focus(); selectedText = element.value; } else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { var isReadOnly = element.hasAttribute('readonly'); if (!isReadOnly) { element.setAttribute('readonly', ''); } element.select(); element.setSelectionRange(0, element.value.length); if (!isReadOnly) { element.removeAttribute('readonly'); } selectedText = element.value; } else { if (element.hasAttribute('contenteditable')) { element.focus(); } var selection = window.getSelection(); var range = document.createRange(); range.selectNodeContents(element); selection.removeAllRanges(); selection.addRange(range); selectedText = selection.toString(); } return selectedText; } module.exports = select; /***/ }), /* 1 */ /***/ (function(module, exports) { function E () { // Keep this empty so it's easier to inherit from // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) } E.prototype = { on: function (name, callback, ctx) { var e = this.e || (this.e = {}); (e[name] || (e[name] = [])).push({ fn: callback, ctx: ctx }); return this; }, once: function (name, callback, ctx) { var self = this; function listener () { self.off(name, listener); callback.apply(ctx, arguments); }; listener._ = callback return this.on(name, listener, ctx); }, emit: function (name) { var data = [].slice.call(arguments, 1); var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); var i = 0; var len = evtArr.length; for (i; i < len; i++) { evtArr[i].fn.apply(evtArr[i].ctx, data); } return this; }, off: function (name, callback) { var e = this.e || (this.e = {}); var evts = e[name]; var liveEvents = []; if (evts && callback) { for (var i = 0, len = evts.length; i < len; i++) { if (evts[i].fn !== callback && evts[i].fn._ !== callback) liveEvents.push(evts[i]); } } // Remove event from queue to prevent memory leak // Suggested by https://github.com/lazd // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 (liveEvents.length) ? e[name] = liveEvents : delete e[name]; return this; } }; module.exports = E; module.exports.TinyEmitter = E; /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { var is = __webpack_require__(3); var delegate = __webpack_require__(4); /** * Validates all params and calls the right * listener function based on its target type. * * @param {String|HTMLElement|HTMLCollection|NodeList} target * @param {String} type * @param {Function} callback * @return {Object} */ function listen(target, type, callback) { if (!target && !type && !callback) { throw new Error('Missing required arguments'); } if (!is.string(type)) { throw new TypeError('Second argument must be a String'); } if (!is.fn(callback)) { throw new TypeError('Third argument must be a Function'); } if (is.node(target)) { return listenNode(target, type, callback); } else if (is.nodeList(target)) { return listenNodeList(target, type, callback); } else if (is.string(target)) { return listenSelector(target, type, callback); } else { throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList'); } } /** * Adds an event listener to a HTML element * and returns a remove listener function. * * @param {HTMLElement} node * @param {String} type * @param {Function} callback * @return {Object} */ function listenNode(node, type, callback) { node.addEventListener(type, callback); return { destroy: function() { node.removeEventListener(type, callback); } } } /** * Add an event listener to a list of HTML elements * and returns a remove listener function. * * @param {NodeList|HTMLCollection} nodeList * @param {String} type * @param {Function} callback * @return {Object} */ function listenNodeList(nodeList, type, callback) { Array.prototype.forEach.call(nodeList, function(node) { node.addEventListener(type, callback); }); return { destroy: function() { Array.prototype.forEach.call(nodeList, function(node) { node.removeEventListener(type, callback); }); } } } /** * Add an event listener to a selector * and returns a remove listener function. * * @param {String} selector * @param {String} type * @param {Function} callback * @return {Object} */ function listenSelector(selector, type, callback) { return delegate(document.body, selector, type, callback); } module.exports = listen; /***/ }), /* 3 */ /***/ (function(module, exports) { /** * Check if argument is a HTML element. * * @param {Object} value * @return {Boolean} */ exports.node = function(value) { return value !== undefined && value instanceof HTMLElement && value.nodeType === 1; }; /** * Check if argument is a list of HTML elements. * * @param {Object} value * @return {Boolean} */ exports.nodeList = function(value) { var type = Object.prototype.toString.call(value); return value !== undefined && (type === '[object NodeList]' || type === '[object HTMLCollection]') && ('length' in value) && (value.length === 0 || exports.node(value[0])); }; /** * Check if argument is a string. * * @param {Object} value * @return {Boolean} */ exports.string = function(value) { return typeof value === 'string' || value instanceof String; }; /** * Check if argument is a function. * * @param {Object} value * @return {Boolean} */ exports.fn = function(value) { var type = Object.prototype.toString.call(value); return type === '[object Function]'; }; /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { var closest = __webpack_require__(5); /** * Delegates event to a selector. * * @param {Element} element * @param {String} selector * @param {String} type * @param {Function} callback * @param {Boolean} useCapture * @return {Object} */ function _delegate(element, selector, type, callback, useCapture) { var listenerFn = listener.apply(this, arguments); element.addEventListener(type, listenerFn, useCapture); return { destroy: function() { element.removeEventListener(type, listenerFn, useCapture); } } } /** * Delegates event to a selector. * * @param {Element|String|Array} [elements] * @param {String} selector * @param {String} type * @param {Function} callback * @param {Boolean} useCapture * @return {Object} */ function delegate(elements, selector, type, callback, useCapture) { // Handle the regular Element usage if (typeof elements.addEventListener === 'function') { return _delegate.apply(null, arguments); } // Handle Element-less usage, it defaults to global delegation if (typeof type === 'function') { // Use `document` as the first parameter, then apply arguments // This is a short way to .unshift `arguments` without running into deoptimizations return _delegate.bind(null, document).apply(null, arguments); } // Handle Selector-based usage if (typeof elements === 'string') { elements = document.querySelectorAll(elements); } // Handle Array-like based usage return Array.prototype.map.call(elements, function (element) { return _delegate(element, selector, type, callback, useCapture); }); } /** * Finds closest match and invokes callback. * * @param {Element} element * @param {String} selector * @param {String} type * @param {Function} callback * @return {Function} */ function listener(element, selector, type, callback) { return function(e) { e.delegateTarget = closest(e.target, selector); if (e.delegateTarget) { callback.call(element, e); } } } module.exports = delegate; /***/ }), /* 5 */ /***/ (function(module, exports) { var DOCUMENT_NODE_TYPE = 9; /** * A polyfill for Element.matches() */ if (typeof Element !== 'undefined' && !Element.prototype.matches) { var proto = Element.prototype; proto.matches = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; } /** * Finds the closest parent that matches a selector. * * @param {Element} element * @param {String} selector * @return {Function} */ function closest (element, selector) { while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { if (typeof element.matches === 'function' && element.matches(selector)) { return element; } element = element.parentNode; } } module.exports = closest; /***/ }), /* 6 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); // EXTERNAL MODULE: ./node_modules/select/src/select.js var src_select = __webpack_require__(0); var select_default = /*#__PURE__*/__webpack_require__.n(src_select); // CONCATENATED MODULE: ./src/clipboard-action.js var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Inner class which performs selection from either `text` or `target` * properties and then executes copy or cut operations. */ var clipboard_action_ClipboardAction = function () { /** * @param {Object} options */ function ClipboardAction(options) { _classCallCheck(this, ClipboardAction); this.resolveOptions(options); this.initSelection(); } /** * Defines base properties passed from constructor. * @param {Object} options */ _createClass(ClipboardAction, [{ key: 'resolveOptions', value: function resolveOptions() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.action = options.action; this.container = options.container; this.emitter = options.emitter; this.target = options.target; this.text = options.text; this.trigger = options.trigger; this.selectedText = ''; } /** * Decides which selection strategy is going to be applied based * on the existence of `text` and `target` properties. */ }, { key: 'initSelection', value: function initSelection() { if (this.text) { this.selectFake(); } else if (this.target) { this.selectTarget(); } } /** * Creates a fake textarea element, sets its value from `text` property, * and makes a selection on it. */ }, { key: 'selectFake', value: function selectFake() { var _this = this; var isRTL = document.documentElement.getAttribute('dir') == 'rtl'; this.removeFake(); this.fakeHandlerCallback = function () { return _this.removeFake(); }; this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true; this.fakeElem = document.createElement('textarea'); // Prevent zooming on iOS this.fakeElem.style.fontSize = '12pt'; // Reset box model this.fakeElem.style.border = '0'; this.fakeElem.style.padding = '0'; this.fakeElem.style.margin = '0'; // Move element out of screen horizontally this.fakeElem.style.position = 'absolute'; this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically var yPosition = window.pageYOffset || document.documentElement.scrollTop; this.fakeElem.style.top = yPosition + 'px'; this.fakeElem.setAttribute('readonly', ''); this.fakeElem.value = this.text; this.container.appendChild(this.fakeElem); this.selectedText = select_default()(this.fakeElem); this.copyText(); } /** * Only removes the fake element after another click event, that way * a user can hit `Ctrl+C` to copy because selection still exists. */ }, { key: 'removeFake', value: function removeFake() { if (this.fakeHandler) { this.container.removeEventListener('click', this.fakeHandlerCallback); this.fakeHandler = null; this.fakeHandlerCallback = null; } if (this.fakeElem) { this.container.removeChild(this.fakeElem); this.fakeElem = null; } } /** * Selects the content from element passed on `target` property. */ }, { key: 'selectTarget', value: function selectTarget() { this.selectedText = select_default()(this.target); this.copyText(); } /** * Executes the copy operation based on the current selection. */ }, { key: 'copyText', value: function copyText() { var succeeded = void 0; try { succeeded = document.execCommand(this.action); } catch (err) { succeeded = false; } this.handleResult(succeeded); } /** * Fires an event based on the copy operation result. * @param {Boolean} succeeded */ }, { key: 'handleResult', value: function handleResult(succeeded) { this.emitter.emit(succeeded ? 'success' : 'error', { action: this.action, text: this.selectedText, trigger: this.trigger, clearSelection: this.clearSelection.bind(this) }); } /** * Moves focus away from `target` and back to the trigger, removes current selection. */ }, { key: 'clearSelection', value: function clearSelection() { if (this.trigger) { this.trigger.focus(); } document.activeElement.blur(); window.getSelection().removeAllRanges(); } /** * Sets the `action` to be performed which can be either 'copy' or 'cut'. * @param {String} action */ }, { key: 'destroy', /** * Destroy lifecycle. */ value: function destroy() { this.removeFake(); } }, { key: 'action', set: function set() { var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy'; this._action = action; if (this._action !== 'copy' && this._action !== 'cut') { throw new Error('Invalid "action" value, use either "copy" or "cut"'); } } /** * Gets the `action` property. * @return {String} */ , get: function get() { return this._action; } /** * Sets the `target` property using an element * that will be have its content copied. * @param {Element} target */ }, { key: 'target', set: function set(target) { if (target !== undefined) { if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) { if (this.action === 'copy' && target.hasAttribute('disabled')) { throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); } if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); } this._target = target; } else { throw new Error('Invalid "target" value, use a valid Element'); } } } /** * Gets the `target` property. * @return {String|HTMLElement} */ , get: function get() { return this._target; } }]); return ClipboardAction; }(); /* harmony default export */ var clipboard_action = (clipboard_action_ClipboardAction); // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js var tiny_emitter = __webpack_require__(1); var tiny_emitter_default = /*#__PURE__*/__webpack_require__.n(tiny_emitter); // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js var listen = __webpack_require__(2); var listen_default = /*#__PURE__*/__webpack_require__.n(listen); // CONCATENATED MODULE: ./src/clipboard.js var clipboard_typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var clipboard_createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * Base class which takes one or more elements, adds event listeners to them, * and instantiates a new `ClipboardAction` on each click. */ var clipboard_Clipboard = function (_Emitter) { _inherits(Clipboard, _Emitter); /** * @param {String|HTMLElement|HTMLCollection|NodeList} trigger * @param {Object} options */ function Clipboard(trigger, options) { clipboard_classCallCheck(this, Clipboard); var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this)); _this.resolveOptions(options); _this.listenClick(trigger); return _this; } /** * Defines if attributes would be resolved using internal setter functions * or custom functions that were passed in the constructor. * @param {Object} options */ clipboard_createClass(Clipboard, [{ key: 'resolveOptions', value: function resolveOptions() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.action = typeof options.action === 'function' ? options.action : this.defaultAction; this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; this.text = typeof options.text === 'function' ? options.text : this.defaultText; this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body; } /** * Adds a click event listener to the passed trigger. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger */ }, { key: 'listenClick', value: function listenClick(trigger) { var _this2 = this; this.listener = listen_default()(trigger, 'click', function (e) { return _this2.onClick(e); }); } /** * Defines a new `ClipboardAction` on each click event. * @param {Event} e */ }, { key: 'onClick', value: function onClick(e) { var trigger = e.delegateTarget || e.currentTarget; if (this.clipboardAction) { this.clipboardAction = null; } this.clipboardAction = new clipboard_action({ action: this.action(trigger), target: this.target(trigger), text: this.text(trigger), container: this.container, trigger: trigger, emitter: this }); } /** * Default `action` lookup function. * @param {Element} trigger */ }, { key: 'defaultAction', value: function defaultAction(trigger) { return getAttributeValue('action', trigger); } /** * Default `target` lookup function. * @param {Element} trigger */ }, { key: 'defaultTarget', value: function defaultTarget(trigger) { var selector = getAttributeValue('target', trigger); if (selector) { return document.querySelector(selector); } } /** * Returns the support of the given action, or all actions if no action is * given. * @param {String} [action] */ }, { key: 'defaultText', /** * Default `text` lookup function. * @param {Element} trigger */ value: function defaultText(trigger) { return getAttributeValue('text', trigger); } /** * Destroy lifecycle. */ }, { key: 'destroy', value: function destroy() { this.listener.destroy(); if (this.clipboardAction) { this.clipboardAction.destroy(); this.clipboardAction = null; } } }], [{ key: 'isSupported', value: function isSupported() { var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut']; var actions = typeof action === 'string' ? [action] : action; var support = !!document.queryCommandSupported; actions.forEach(function (action) { support = support && !!document.queryCommandSupported(action); }); return support; } }]); return Clipboard; }(tiny_emitter_default.a); /** * Helper function to retrieve attribute value. * @param {String} suffix * @param {Element} element */ function getAttributeValue(suffix, element) { var attribute = 'data-clipboard-' + suffix; if (!element.hasAttribute(attribute)) { return; } return element.getAttribute(attribute); } /* harmony default export */ var clipboard = __webpack_exports__["default"] = (clipboard_Clipboard); /***/ }) /******/ ])["default"]; }); ================================================ FILE: vipercard/vipercard/external/clipboard.js-2.0.6-notbundled/readme.md ================================================ # clipboard.js [![Build Status](http://img.shields.io/travis/zenorocha/clipboard.js/master.svg?style=flat)](https://travis-ci.org/zenorocha/clipboard.js) ![Killing Flash](https://img.shields.io/badge/killing-flash-brightgreen.svg?style=flat) > Modern copy to clipboard. No Flash. Just 3kb gzipped.
Demo ## Why Copying text to the clipboard shouldn't be hard. It shouldn't require dozens of steps to configure or hundreds of KBs to load. But most of all, it shouldn't depend on Flash or any bloated framework. That's why clipboard.js exists. ## Install You can get it on npm. ``` npm install clipboard --save ``` Or if you're not into package management, just [download a ZIP](https://github.com/zenorocha/clipboard.js/archive/master.zip) file. ## Setup First, include the script located on the `dist` folder or load it from [a third-party CDN provider](https://github.com/zenorocha/clipboard.js/wiki/CDN-Providers). ```html ``` Now, you need to instantiate it by [passing a DOM selector](https://github.com/zenorocha/clipboard.js/blob/master/demo/constructor-selector.html#L18), [HTML element](https://github.com/zenorocha/clipboard.js/blob/master/demo/constructor-node.html#L16-L17), or [list of HTML elements](https://github.com/zenorocha/clipboard.js/blob/master/demo/constructor-nodelist.html#L18-L19). ```js new ClipboardJS('.btn'); ``` Internally, we need to fetch all elements that matches with your selector and attach event listeners for each one. But guess what? If you have hundreds of matches, this operation can consume a lot of memory. For this reason we use [event delegation](https://stackoverflow.com/questions/1687296/what-is-dom-event-delegation) which replaces multiple event listeners with just a single listener. After all, [#perfmatters](https://twitter.com/hashtag/perfmatters). # Usage We're living a _declarative renaissance_, that's why we decided to take advantage of [HTML5 data attributes](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes) for better usability. ### Copy text from another element A pretty common use case is to copy content from another element. You can do that by adding a `data-clipboard-target` attribute in your trigger element. The value you include on this attribute needs to match another's element selector. example-2 ```html ``` ### Cut text from another element Additionally, you can define a `data-clipboard-action` attribute to specify if you want to either `copy` or `cut` content. If you omit this attribute, `copy` will be used by default. example-3 ```html ``` As you may expect, the `cut` action only works on `` or `