diff --git a/plugins/match2/.editorconfig b/plugins/match2/.editorconfig new file mode 100644 index 000000000..bc02f8e3a --- /dev/null +++ b/plugins/match2/.editorconfig @@ -0,0 +1,20 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +trim_trailing_whitespace = true +end_of_line = lf +insert_final_newline = true +indent_style = space + +# Tab indentation (no size specified) +[Makefile] +indent_style = tab + +[*.{c,h,cpp,cpp,hpp}] +indent_size = 4 + +[*.{js,jsx}] +indent_size = 2 diff --git a/plugins/match2/.gitignore b/plugins/match2/.gitignore new file mode 100644 index 000000000..686a05e54 --- /dev/null +++ b/plugins/match2/.gitignore @@ -0,0 +1,116 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +#dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* diff --git a/plugins/match2/.prettierignore b/plugins/match2/.prettierignore new file mode 100644 index 000000000..1d702ac4c --- /dev/null +++ b/plugins/match2/.prettierignore @@ -0,0 +1,3 @@ + +dist/ + diff --git a/plugins/match2/LICENSE b/plugins/match2/LICENSE new file mode 100644 index 000000000..f288702d2 --- /dev/null +++ b/plugins/match2/LICENSE @@ -0,0 +1,674 @@ + 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. + + + Copyright (C) + + 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: + + Copyright (C) + 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 +. diff --git a/plugins/match2/README.md b/plugins/match2/README.md new file mode 100644 index 000000000..412debd27 --- /dev/null +++ b/plugins/match2/README.md @@ -0,0 +1,87 @@ +# compromise-match2 + +A batter match function for nlp compromise. + +## Links + +- [Github](https://github.com/catalogm/compromise-match2) +- [npm](https://www.npmjs.com/package/compromise-match2) + +## Quickstart + +**Install:** + +``` +npm install compromise-match2 +``` + +### Usage + +**es6**: + +```javascript +import nlp from "compromise"; +import compromise_match2 from "compromise-match2"; + +nlp.extend(compromise_match2); + +let doc = nlp("hello world") + .match2("(?Phi|hello|good morning) #Noun") + .groups("greeting"); +console.log(doc.text()); +``` + +**commonjs:** + +```javascript +const nlp = require("compromise"); +nlp.extend(require("compromise-match2")); + +let doc = nlp("Good morning world") + .match2("(?Phi|hello|good morning) #Noun") + .groups("greeting"); +console.log(doc.text()); +``` + +## API + +### Compling regexp + +**es6:** + +```javascript +import { NLPRegexP } from "compromise-match2"; +// ... rest from usage above + +const regex = new NLPRegexP("(?Phi|hello|good morning) #Noun"); +// or: const regex = nlp.compileRegex('(?Phi|hello|good morning) #Noun'); +// or: const regex = doc.compileRegex('(?Phi|hello|good morning) #Noun'); + +let doc = nlp("hello world").match2(regex).groups("greeting"); +console.log(doc.text()); +``` + +### Supported RegexP grammar + +- StartOf: `^` - start of string +- Value: can be repeated + - Any: `.` - match any word + - Tag: `#Noun` - part of speech / tags + - Word: `hello` - just the word + - EscapedWord: `\#Noun` matches the word `#Noun` + - Group: `(...)` - match groups, will also capture which saves group + content, values of `...` will be matched. + - Or: `(value0|value1|value2 value3)` - matches either value statements in + group. + - Named: `(?P...)` - saves group which can later be accessed by name + - NonCapturing: `(?:...)` - don't save group's matched content + - Positive Lookahead: `(?=...)` - does not consume, asserts that group matches ahead + - Negative Lookahead: `(?!...)` - does not consume, opposite of positive lookahead + - Modifiers: goes at the end of value, ex: `Hi+` + - Plus: `+` - matches one or more occurances of value + - Star: `*` - matches zero or more occurances of value + - Question: `?` - matches zer or one occurance of value + - Non Greedy Matches: `+?`, `*?`, `??` match as little as possible while + still maintining a match. + - **Note**: repeatedly matched groups will overwrite and save only the last value. +- EndOf: `$` - end of string diff --git a/plugins/match2/babel.config.js b/plugins/match2/babel.config.js new file mode 100644 index 000000000..392abb66d --- /dev/null +++ b/plugins/match2/babel.config.js @@ -0,0 +1,12 @@ +module.exports = { + presets: [ + [ + "@babel/preset-env", + { + targets: { + node: "current", + }, + }, + ], + ], +}; diff --git a/plugins/match2/bench.js b/plugins/match2/bench.js new file mode 100644 index 000000000..ed7735eab --- /dev/null +++ b/plugins/match2/bench.js @@ -0,0 +1,35 @@ +const Benchmark = require("benchmark"); + +const nlp = require("compromise"); +const { + default: compromise_match2, + NLPRegexP, +} = require("./dist/compromise-match2.js"); + +nlp.extend(compromise_match2); + +const suite = new Benchmark.Suite(); + +let text = + "Improved own provided blessing may peculiar domestic. Sight house has sex never. No visited raising gravity outward subject my cottage mr be. Hold do at tore in park feet near my case. Invitation at understood occasional sentiments insipidity inhabiting in. Off melancholy alteration principles old. Is do speedily kindness properly oh. Respect article painted cottage he is offices parlors."; +text = text.replace(".", ""); +const tofind = "sentiments insipidity inhabiting"; +const regex = nlp.compileRegex(tofind); + +suite + .add("nlp match", () => { + nlp(text).match(tofind); + }) + .add("match2", () => { + nlp(text).match2(tofind); + }) + .add("compiled match2", () => { + nlp(text).match2(regex); + }) + .on("cycle", function (event) { + console.log(String(event.target)); + }) + .on("complete", function (event) { + console.log("Fastest is " + this.filter("fastest").map("name")); + }) + .run(); diff --git a/plugins/match2/dist/compromise-match2.js b/plugins/match2/dist/compromise-match2.js new file mode 100644 index 000000000..816a56fc0 --- /dev/null +++ b/plugins/match2/dist/compromise-match2.js @@ -0,0 +1,10817 @@ +/* compromise-match2 1.2.0 GPLv3 */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = global || self, factory(global.compromiseMatch2 = {})); +}(this, (function (exports) { 'use strict'; + + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a 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); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; + } + + function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); + } + + function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); + } + + function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; + } + + function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + + function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + + /* + 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... + */ + function isEmpty(arr) { + return arr && arr.length === 0; + } + function keys(obj) { + if (obj === undefined || obj === null) { + return []; + } + + return Object.keys(obj); + } + 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; + } + 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; + } + function map(arr, callback) { + var result = []; + + for (var idx = 0; idx < arr.length; idx++) { + result.push(callback.call(null, arr[idx], idx)); + } + + return result; + } + 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; + } + function first(arr) { + return isEmpty(arr) ? undefined : arr[0]; + } + function last(arr) { + var len = arr && arr.length; + return len ? arr[len - 1] : undefined; + } + 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"); + } + } + function isString(item) { + return typeof item === "string"; + } + function isUndefined(item) { + return item === undefined; + } + function isFunction(item) { + return item instanceof Function; + } + function drop(arr, howMuch) { + if (howMuch === void 0) { + howMuch = 1; + } + + return arr.slice(howMuch, arr.length); + } + function dropRight(arr, howMuch) { + if (howMuch === void 0) { + howMuch = 1; + } + + return arr.slice(0, arr.length - howMuch); + } + 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; + } + function reject(arr, predicate) { + return filter(arr, function (item) { + return !predicate(item); + }); + } + 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; + } + function has(obj, prop) { + if (isObject(obj)) { + return obj.hasOwnProperty(prop); + } + + return false; + } + function contains(arr, item) { + return find(arr, function (currItem) { + return currItem === item; + }) !== undefined ? true : false; + } + /** + * shallow clone + */ + + function cloneArr(arr) { + var newArr = []; + + for (var i = 0; i < arr.length; i++) { + newArr.push(arr[i]); + } + + return newArr; + } + /** + * 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; + } + 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; + } + 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; + } + 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; + } + function compact(arr) { + return reject(arr, function (item) { + return item === null || item === undefined; + }); + } + function uniq(arr, identity) { + if (identity === void 0) { + identity = function identity(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); + } + }, []); + } + function isArray(obj) { + return Array.isArray(obj); + } + function isRegExp(obj) { + return obj instanceof RegExp; + } + function isObject(obj) { + return obj instanceof Object; + } + function every(arr, predicate) { + for (var i = 0; i < arr.length; i++) { + if (!predicate(arr[i], i)) { + return false; + } + } + + return true; + } + function difference(arr, values) { + return reject(arr, function (item) { + return contains(values, item); + }); + } + function some(arr, predicate) { + for (var i = 0; i < arr.length; i++) { + if (predicate(arr[i])) { + return true; + } + } + + return false; + } + function indexOf(arr, value) { + for (var i = 0; i < arr.length; i++) { + if (arr[i] === value) { + return i; + } + } + + return -1; + } + /** + * 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; + } + /** + * 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]; + 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; + } + function defaults() { + var sources = []; + + for (var _i = 0; _i < arguments.length; _i++) { + sources[_i] = arguments[_i]; + } + + return assignNoOverwrite.apply(null, [{}].concat(sources)); + } + 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; + } + /** + * 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; + } + function NOOP() {} + function IDENTITY(item) { + return item; + } + /** + * 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; + } + function PRINT_ERROR(msg) { + /* istanbul ignore else - can't override global.console in node.js */ + if (console && console.error) { + console.error("Error: " + msg); + } + } + 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); + } + } + function isES2015MapSupported() { + return typeof Map === "function"; + } + 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]; + } + }); + }); + } // 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) + } + function peek(arr) { + return arr[arr.length - 1]; + } + /* 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 + }; + } + + var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + + function createCommonjsModule(fn, basedir, module) { + return module = { + path: basedir, + exports: {}, + require: function (path, base) { + return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); + } + }, fn(module, module.exports), module.exports; + } + + function commonjsRequire () { + throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); + } + + var regexpToAst = createCommonjsModule(function (module) { + + (function (root, factory) { + // istanbul ignore next + if ( module.exports) { + module.exports = factory(); + } else { + // istanbul ignore next + root.regexpToAst = factory(); + } + })(typeof self !== "undefined" ? // istanbul ignore next + self : commonjsGlobal, 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", + loc: { + begin: this.idx, + end: input.length + }, + 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, + loc: this.loc(0) + }; + }; + + RegExpParser.prototype.disjunction = function () { + var alts = []; + var begin = this.idx; + alts.push(this.alternative()); + + while (this.peekChar() === "|") { + this.consumeChar("|"); + alts.push(this.alternative()); + } + + return { + type: "Disjunction", + value: alts, + loc: this.loc(begin) + }; + }; + + RegExpParser.prototype.alternative = function () { + var terms = []; + var begin = this.idx; + + while (this.isTerm()) { + terms.push(this.term()); + } + + return { + type: "Alternative", + value: terms, + loc: this.loc(begin) + }; + }; + + RegExpParser.prototype.term = function () { + if (this.isAssertion()) { + return this.assertion(); + } else { + return this.atom(); + } + }; + + RegExpParser.prototype.assertion = function () { + var begin = this.idx; + + switch (this.popChar()) { + case "^": + return { + type: "StartAnchor", + loc: this.loc(begin) + }; + + case "$": + return { + type: "EndAnchor", + loc: this.loc(begin) + }; + // '\b' or '\B' + + case "\\": + switch (this.popChar()) { + case "b": + return { + type: "WordBoundary", + loc: this.loc(begin) + }; + + case "B": + return { + type: "NonWordBoundary", + loc: this.loc(begin) + }; + } // 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, + loc: this.loc(begin) + }; + } // istanbul ignore next + + + ASSERT_NEVER_REACH_HERE(); + }; + + RegExpParser.prototype.quantifier = function (isBacktracking) { + var range; + var begin = this.idx; + + 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"; + range.loc = this.loc(begin); + return range; + }; + + RegExpParser.prototype.atom = function () { + var atom; + var begin = this.idx; + + 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); + atom.loc = this.loc(begin); + + 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("\b") + }; + + 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++; + }; + + RegExpParser.prototype.loc = function (begin) { + return { + begin: begin, + end: this.idx + }; + }; // consts and utilities + + + var hexDigitPattern = /[0-9a-fA-F]/; + var decimalPattern = /[0-9]/; + var decimalPatternNoZero = /[1-9]/; + + function cc(_char2) { + return _char2.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("\xA0"), 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.5.0" + }; + }); + }); + + var regExpAstCache = {}; + var regExpParser = new regexpToAst.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; + } + } + function clearRegExpParserCache() { + regExpAstCache = {}; + } + + var __extends = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; + }(); + var complementErrorMessage = "Complement Sets are not supported for first char optimization"; + var failedOptimizationPrefixMsg = 'Unable to use "first char" lexer optimizations:\n'; + function getOptimizedStartCodesIndices(regExp, ensureOptimizations) { + if (ensureOptimizations === void 0) { + ensureOptimizations = false; + } + + try { + var ast = 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) { + PRINT_WARNING("" + 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."; + } + + PRINT_ERROR(failedOptimizationPrefixMsg + "\n" + ("\tFailed parsing: < " + regExp.toString() + " >\n") + ("\tUsing the regexp-to-ast library version: " + regexpToAst.VERSION + "\n") + "\tPlease open an issue at: https://github.com/bd82/regexp-to-ast/issues" + msgSuffix); + } + } + + return []; + } + 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); + } + + 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 < minOptimizationVal; rangeCode++) { + addOptimizedIdxToResult(rangeCode, result, ignoreCase); + } // Less common charCode where we optimize for faster init time, by using larger "buckets" + + + if (range.to >= minOptimizationVal) { + var minUnOptVal = range.from >= minOptimizationVal ? range.from : minOptimizationVal; + var maxUnOptVal = range.to; + var minOptIdx = charCodeToOptimizedIndex(minUnOptVal); + var maxOptIdx = 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 values(result); + } + + function addOptimizedIdxToResult(code, result, ignoreCase) { + var optimizedCharIdx = 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 = charCodeToOptimizedIndex(upperChar.charCodeAt(0)); + result[optimizedCharIdx] = optimizedCharIdx; + } else { + var lowerChar = _char.toLowerCase(); + + if (lowerChar !== _char) { + var optimizedCharIdx = charCodeToOptimizedIndex(lowerChar.charCodeAt(0)); + result[optimizedCharIdx] = optimizedCharIdx; + } + } + } + + function findCode(setNode, targetCharCodes) { + return find(setNode.value, function (codeOrRange) { + if (typeof codeOrRange === "number") { + return contains(targetCharCodes, codeOrRange); + } else { + // range + var range_1 = codeOrRange; + return 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 isArray(ast.value) ? 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 (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; + }(regexpToAst.BaseRegExpVisitor); + + function canMatchCharCode(charCodes, pattern) { + if (pattern instanceof RegExp) { + var ast = getRegExpAst(pattern); + var charCodeFinder = new CharCodeFinder(charCodes); + charCodeFinder.visit(ast); + return charCodeFinder.found; + } else { + return find(pattern, function (_char2) { + return contains(charCodes, _char2.charCodeAt(0)); + }) !== undefined; + } + } + + var __extends$1 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; + }(); + var PATTERN = "PATTERN"; + var DEFAULT_MODE = "defaultMode"; + var MODES = "modes"; + var SUPPORT_STICKY = typeof new RegExp("(?:)").sticky === "boolean"; + function analyzeTokenTypes(tokenTypes, options) { + options = defaults(options, { + useSticky: SUPPORT_STICKY, + debug: false, + safeMode: false, + positionTracking: "full", + lineTerminatorCharacters: ["\r", "\n"], + tracer: function tracer(msg, action) { + return action(); + } + }); + var tracer = options.tracer; + tracer("initCharCodeToOptimizedIndexMap", function () { + initCharCodeToOptimizedIndexMap(); + }); + var onlyRelevantTypes; + tracer("Reject Lexer.NA", function () { + onlyRelevantTypes = reject(tokenTypes, function (currType) { + return currType[PATTERN] === Lexer.NA; + }); + }); + var hasCustom = false; + var allTransformedPatterns; + tracer("Transform Patterns", function () { + hasCustom = false; + allTransformedPatterns = map(onlyRelevantTypes, function (currType) { + var currPattern = currType[PATTERN]; + /* istanbul ignore else */ + + if (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 !== "." && !currPattern.ignoreCase) { + return regExpSource; + } else if (regExpSource.length === 2 && regExpSource[0] === "\\" && // not a meta character + !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 (isFunction(currPattern)) { + hasCustom = true; // CustomPatternMatcherFunc - custom patterns do not require any transformations, only wrapping in a RegExp Like object + + return { + exec: currPattern + }; + } else if (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 = map(onlyRelevantTypes, function (currType) { + return currType.tokenTypeIdx; + }); + patternIdxToGroup = map(onlyRelevantTypes, function (clazz) { + var groupName = clazz.GROUP; + /* istanbul ignore next */ + + if (groupName === Lexer.SKIPPED) { + return undefined; + } else if (isString(groupName)) { + return groupName; + } else if (isUndefined(groupName)) { + return false; + } else { + throw Error("non exhaustive match"); + } + }); + patternIdxToLongerAltIdx = map(onlyRelevantTypes, function (clazz) { + var longerAltType = clazz.LONGER_ALT; + + if (longerAltType) { + var longerAltIdx = indexOf(onlyRelevantTypes, longerAltType); + return longerAltIdx; + } + }); + patternIdxToPushMode = map(onlyRelevantTypes, function (clazz) { + return clazz.PUSH_MODE; + }); + patternIdxToPopMode = map(onlyRelevantTypes, function (clazz) { + return has(clazz, "POP_MODE"); + }); + }); + var patternIdxToCanLineTerminator; + tracer("Line Terminator Handling", function () { + var lineTerminatorCharCodes = getCharCodes(options.lineTerminatorCharacters); + patternIdxToCanLineTerminator = map(onlyRelevantTypes, function (tokType) { + return false; + }); + + if (options.positionTracking !== "onlyOffset") { + patternIdxToCanLineTerminator = map(onlyRelevantTypes, function (tokType) { + if (has(tokType, "LINE_BREAKS")) { + return tokType.LINE_BREAKS; + } else { + if (checkLineBreaksIssues(tokType, lineTerminatorCharCodes) === false) { + return canMatchCharCode(lineTerminatorCharCodes, tokType.PATTERN); + } + } + }); + } + }); + var patternIdxToIsCustom; + var patternIdxToShort; + var emptyGroups; + var patternIdxToConfig; + tracer("Misc Mapping #2", function () { + patternIdxToIsCustom = map(onlyRelevantTypes, isCustomPattern); + patternIdxToShort = map(allTransformedPatterns, isShortPattern); + emptyGroups = reduce(onlyRelevantTypes, function (acc, clazz) { + var groupName = clazz.GROUP; + + if (isString(groupName) && !(groupName === Lexer.SKIPPED)) { + acc[groupName] = []; + } + + return acc; + }, {}); + patternIdxToConfig = 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 = 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 (isArray(currTokType.START_CHARS_HINT)) { + var lastOptimizedIdx_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 + + /* istanbul ignore else */ + // - Difficult to check this scenario effects as it is only a performance + // optimization that does not change correctness + + if (lastOptimizedIdx_1 !== currOptimizedIdx) { + lastOptimizedIdx_1 = currOptimizedIdx; + addToMapOfArrays(result, currOptimizedIdx, patternIdxToConfig[idx]); + } + }); + } else if (isRegExp(currTokType.PATTERN)) { + if (currTokType.PATTERN.unicode) { + canBeOptimized = false; + + if (options.ensureOptimizations) { + PRINT_ERROR("" + 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 = 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 (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; + } + + forEach(optimizedCodes, function (code) { + addToMapOfArrays(result, code, patternIdxToConfig[idx]); + }); + } + } else { + if (options.ensureOptimizations) { + PRINT_ERROR("" + 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 = packArray(charCodeToPatternIdxToConfig); + }); + return { + emptyGroups: emptyGroups, + patternIdxToConfig: patternIdxToConfig, + charCodeToPatternIdxToConfig: charCodeToPatternIdxToConfig, + hasCustom: hasCustom, + canBeOptimized: canBeOptimized + }; + } + 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; + } + + function validateRegExpPattern(tokenTypes) { + var errors = []; + var withRegExpPatterns = filter(tokenTypes, function (currTokType) { + return 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 = filter(tokenTypes, function (currType) { + return !has(currType, PATTERN); + }); + var errors = map(tokenTypesWithMissingPattern, function (currType) { + return { + message: "Token Type: ->" + currType.name + "<- missing static 'PATTERN' property", + type: LexerDefinitionErrorType.MISSING_PATTERN, + tokenTypes: [currType] + }; + }); + var valid = difference(tokenTypes, tokenTypesWithMissingPattern); + return { + errors: errors, + valid: valid + }; + } + function findInvalidPatterns(tokenTypes) { + var tokenTypesWithInvalidPattern = filter(tokenTypes, function (currType) { + var pattern = currType[PATTERN]; + return !isRegExp(pattern) && !isFunction(pattern) && !has(pattern, "exec") && !isString(pattern); + }); + var errors = 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: LexerDefinitionErrorType.INVALID_PATTERN, + tokenTypes: [currType] + }; + }); + var valid = difference(tokenTypes, tokenTypesWithInvalidPattern); + return { + errors: errors, + valid: valid + }; + } + var end_of_input = /[^\\][\$]/; + function findEndOfInputAnchor(tokenTypes) { + var EndAnchorFinder = + /** @class */ + function (_super) { + __extends$1(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; + }(regexpToAst.BaseRegExpVisitor); + + var invalidRegex = filter(tokenTypes, function (currType) { + var pattern = currType[PATTERN]; + + try { + var regexpAst = 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 = 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: LexerDefinitionErrorType.EOI_ANCHOR_FOUND, + tokenTypes: [currType] + }; + }); + return errors; + } + function findEmptyMatchRegExps(tokenTypes) { + var matchesEmptyString = filter(tokenTypes, function (currType) { + var pattern = currType[PATTERN]; + return pattern.test(""); + }); + var errors = map(matchesEmptyString, function (currType) { + return { + message: "Token Type: ->" + currType.name + "<- static 'PATTERN' must not match an empty string", + type: LexerDefinitionErrorType.EMPTY_MATCH_PATTERN, + tokenTypes: [currType] + }; + }); + return errors; + } + var start_of_input = /[^\\[][\^]|^\^/; + function findStartOfInputAnchor(tokenTypes) { + var StartAnchorFinder = + /** @class */ + function (_super) { + __extends$1(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; + }(regexpToAst.BaseRegExpVisitor); + + var invalidRegex = filter(tokenTypes, function (currType) { + var pattern = currType[PATTERN]; + + try { + var regexpAst = 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 = 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: LexerDefinitionErrorType.SOI_ANCHOR_FOUND, + tokenTypes: [currType] + }; + }); + return errors; + } + function findUnsupportedFlags(tokenTypes) { + var invalidFlags = filter(tokenTypes, function (currType) { + var pattern = currType[PATTERN]; + return pattern instanceof RegExp && (pattern.multiline || pattern.global); + }); + var errors = map(invalidFlags, function (currType) { + return { + message: "Token Type: ->" + currType.name + "<- static 'PATTERN' may NOT contain global('g') or multiline('m')", + type: LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND, + tokenTypes: [currType] + }; + }); + return errors; + } // This can only test for identical duplicate RegExps, not semantically equivalent ones. + + function findDuplicatePatterns(tokenTypes) { + var found = []; + var identicalPatterns = map(tokenTypes, function (outerType) { + return reduce(tokenTypes, function (result, innerType) { + if (outerType.PATTERN.source === innerType.PATTERN.source && !contains(found, innerType) && innerType.PATTERN !== 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 = compact(identicalPatterns); + var duplicatePatterns = filter(identicalPatterns, function (currIdenticalSet) { + return currIdenticalSet.length > 1; + }); + var errors = map(duplicatePatterns, function (setOfIdentical) { + var tokenTypeNames = map(setOfIdentical, function (currType) { + return currType.name; + }); + var dupPatternSrc = first(setOfIdentical).PATTERN; + return { + message: "The same RegExp pattern ->" + dupPatternSrc + "<-" + ("has been used in all of the following Token Types: " + tokenTypeNames.join(", ") + " <-"), + type: LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND, + tokenTypes: setOfIdentical + }; + }); + return errors; + } + function findInvalidGroupType(tokenTypes) { + var invalidTypes = filter(tokenTypes, function (clazz) { + if (!has(clazz, "GROUP")) { + return false; + } + + var group = clazz.GROUP; + return group !== Lexer.SKIPPED && group !== Lexer.NA && !isString(group); + }); + var errors = map(invalidTypes, function (currType) { + return { + message: "Token Type: ->" + currType.name + "<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String", + type: LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND, + tokenTypes: [currType] + }; + }); + return errors; + } + function findModesThatDoNotExist(tokenTypes, validModes) { + var invalidModes = filter(tokenTypes, function (clazz) { + return clazz.PUSH_MODE !== undefined && !contains(validModes, clazz.PUSH_MODE); + }); + var errors = 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: LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST, + tokenTypes: [tokType] + }; + }); + return errors; + } + function findUnreachablePatterns(tokenTypes) { + var errors = []; + var canBeTested = reduce(tokenTypes, function (result, tokType, idx) { + var pattern = tokType.PATTERN; + + if (pattern === Lexer.NA) { + return result; + } // a more comprehensive validation for all forms of regExps would require + // deeper regExp analysis capabilities + + + if (isString(pattern)) { + result.push({ + str: pattern, + idx: idx, + tokenType: tokType + }); + } else if (isRegExp(pattern) && noMetaChar(pattern)) { + result.push({ + str: pattern.source, + idx: idx, + tokenType: tokType + }); + } + + return result; + }, []); + forEach(tokenTypes, function (tokType, testIdx) { + 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: LexerDefinitionErrorType.UNREACHABLE_PATTERN, + tokenTypes: [tokType, tokenType] + }); + } + }); + }); + return errors; + } + + function testTokenType(str, pattern) { + /* istanbul ignore else */ + if (isRegExp(pattern)) { + var regExpArray = pattern.exec(str); + return regExpArray !== null && regExpArray.index === 0; + } else if (isFunction(pattern)) { + // maintain the API of custom patterns + return pattern(str, 0, [], {}); + } else if (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 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); + } + 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); + } + function performRuntimeChecks(lexerDefinition, trackLines, lineTerminatorCharacters) { + var errors = []; // some run time checks to help the end users. + + if (!has(lexerDefinition, DEFAULT_MODE)) { + errors.push({ + message: "A MultiMode Lexer cannot be initialized without a <" + DEFAULT_MODE + "> property in its definition\n", + type: LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE + }); + } + + if (!has(lexerDefinition, MODES)) { + errors.push({ + message: "A MultiMode Lexer cannot be initialized without a <" + MODES + "> property in its definition\n", + type: LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY + }); + } + + if (has(lexerDefinition, MODES) && has(lexerDefinition, DEFAULT_MODE) && !has(lexerDefinition.modes, lexerDefinition.defaultMode)) { + errors.push({ + message: "A MultiMode Lexer cannot be initialized with a " + DEFAULT_MODE + ": <" + lexerDefinition.defaultMode + ">" + "which does not exist\n", + type: LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST + }); + } + + if (has(lexerDefinition, MODES)) { + forEach(lexerDefinition.modes, function (currModeValue, currModeName) { + forEach(currModeValue, function (currTokType, currIdx) { + if (isUndefined(currTokType)) { + errors.push({ + message: "A Lexer cannot be initialized using an undefined Token Type. Mode:" + ("<" + currModeName + "> at index: <" + currIdx + ">\n"), + type: LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED + }); + } + }); + }); + } + + return errors; + } + function performWarningRuntimeChecks(lexerDefinition, trackLines, lineTerminatorCharacters) { + var warnings = []; + var hasAnyLineBreak = false; + var allTokenTypes = compact(flatten(mapValues(lexerDefinition.modes, function (tokTypes) { + return tokTypes; + }))); + var concreteTokenTypes = reject(allTokenTypes, function (currType) { + return currType[PATTERN] === Lexer.NA; + }); + var terminatorCharCodes = getCharCodes(lineTerminatorCharacters); + + if (trackLines) { + 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 (has(tokType, "LINE_BREAKS")) { + if (tokType.LINE_BREAKS === true) { + hasAnyLineBreak = true; + } + } else { + if (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: LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS + }); + } + + return warnings; + } + function cloneEmptyGroups(emptyGroups) { + var clonedResult = {}; + var groupKeys = keys(emptyGroups); + forEach(groupKeys, function (currKey) { + var currGroupValue = emptyGroups[currKey]; + /* istanbul ignore else */ + + if (isArray(currGroupValue)) { + clonedResult[currKey] = []; + } else { + throw Error("non exhaustive match"); + } + }); + return clonedResult; + } // TODO: refactor to avoid duplication + + function isCustomPattern(tokenType) { + var pattern = tokenType.PATTERN; + /* istanbul ignore else */ + + if (isRegExp(pattern)) { + return false; + } else if (isFunction(pattern)) { + // CustomPatternMatcherFunc - custom patterns do not require any transformations, only wrapping in a RegExp Like object + return true; + } else if (has(pattern, "exec")) { + // ICustomPattern + return true; + } else if (isString(pattern)) { + return false; + } else { + throw Error("non exhaustive match"); + } + } + function isShortPattern(pattern) { + if (isString(pattern) && pattern.length === 1) { + return pattern.charCodeAt(0); + } else { + return false; + } + } + /** + * Faster than using a RegExp for default newline detection during lexing. + */ + + var LineTerminatorOptimizedTester = { + // implements /\n|\r\n?/g.test + test: function test(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 (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 (isRegExp(tokType.PATTERN)) { + try { + canMatchCharCode(lineTerminatorCharCodes, tokType.PATTERN); + } catch (e) { + /* istanbul ignore next - to test this we would have to mock to throw an error */ + return { + issue: LexerDefinitionErrorType.IDENTIFY_TERMINATOR, + errMsg: e.message + }; + } + + return false; + } else if (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: LexerDefinitionErrorType.CUSTOM_LINE_BREAK + }; + } else { + throw Error("non exhaustive match"); + } + } + } + + function buildLineBreakIssueMessage(tokType, details) { + /* istanbul ignore else */ + if (details.issue === 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 === 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"); + } + } + + function getCharCodes(charsOrCodes) { + var charCodes = map(charsOrCodes, function (numOrString) { + if (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); + } + } + + var 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 < minOptimizationVal ? charCode : charCodeToOptimizedIdxMap[charCode]; + } + /** + * 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 (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 */ + } + } + } + + function tokenStructuredMatcher(tokInstance, tokConstructor) { + var instanceType = tokInstance.tokenTypeIdx; + + if (instanceType === tokConstructor.tokenTypeIdx) { + return true; + } else { + return tokConstructor.isParent === true && tokConstructor.categoryMatchesMap[instanceType] === true; + } + } // 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; + } + var tokenShortNameIdx = 1; + var 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); + forEach(tokenTypesAndParents, function (tokType) { + tokType.isParent = tokType.categoryMatches.length > 0; + }); + } + function expandCategories(tokenTypes) { + var result = cloneArr(tokenTypes); + var categories = tokenTypes; + var searching = true; + + while (searching) { + categories = compact(flatten(map(categories, function (currTokType) { + return currTokType.CATEGORIES; + }))); + var newCategories = difference(categories, result); + result = result.concat(newCategories); + + if (isEmpty(newCategories)) { + searching = false; + } else { + categories = newCategories; + } + } + + return result; + } + function assignTokenDefaultProps(tokenTypes) { + forEach(tokenTypes, function (currTokType) { + if (!hasShortKeyProperty(currTokType)) { + tokenIdxToClass[tokenShortNameIdx] = currTokType; + currTokType.tokenTypeIdx = tokenShortNameIdx++; + } // CATEGORIES? : TokenType | TokenType[] + + + if (hasCategoriesProperty(currTokType) && !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 = {}; + } + }); + } + function assignCategoriesTokensProp(tokenTypes) { + forEach(tokenTypes, function (currTokType) { + // avoid duplications + currTokType.categoryMatches = []; + forEach(currTokType.categoryMatchesMap, function (val, key) { + currTokType.categoryMatches.push(tokenIdxToClass[key].tokenTypeIdx); + }); + }); + } + function assignCategoriesMapProp(tokenTypes) { + forEach(tokenTypes, function (currTokType) { + singleAssignCategoriesToksMap([], currTokType); + }); + } + function singleAssignCategoriesToksMap(path, nextNode) { + forEach(path, function (pathNode) { + nextNode.categoryMatchesMap[pathNode.tokenTypeIdx] = true; + }); + forEach(nextNode.CATEGORIES, function (nextCategory) { + var newPath = path.concat(nextNode); // avoids infinite loops due to cyclic categories. + + if (!contains(newPath, nextCategory)) { + singleAssignCategoriesToksMap(newPath, nextCategory); + } + }); + } + function hasShortKeyProperty(tokType) { + return has(tokType, "tokenTypeIdx"); + } + function hasCategoriesProperty(tokType) { + return has(tokType, "CATEGORIES"); + } + function hasExtendingTokensTypesProperty(tokType) { + return has(tokType, "categoryMatches"); + } + function hasExtendingTokensTypesMapProperty(tokType) { + return has(tokType, "categoryMatchesMap"); + } + function isTokenType(tokType) { + return has(tokType, "tokenTypeIdx"); + } + + var defaultLexerErrorProvider = { + buildUnableToPopLexerModeMessage: function buildUnableToPopLexerModeMessage(token) { + return "Unable to pop Lexer Mode after encountering Token ->" + token.image + "<- The Mode Stack is empty"; + }, + buildUnexpectedCharactersMessage: function buildUnexpectedCharactersMessage(fullText, startOffset, length, line, column) { + return "unexpected character: ->" + fullText.charAt(startOffset) + "<- at offset: " + startOffset + "," + (" skipped " + length + " characters."); + } + }; + + 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 || (LexerDefinitionErrorType = {})); + + var DEFAULT_LEXER_CONFIG = { + deferDefinitionErrorsHandling: false, + positionTracking: "full", + lineTerminatorsPattern: /\n|\r\n?/g, + lineTerminatorCharacters: ["\n", "\r"], + ensureOptimizations: false, + safeMode: false, + errorMessageProvider: 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 = 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 = 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 (isArray(lexerDefinition)) { + actualDefinition = { + modes: {} + }; + actualDefinition.modes[DEFAULT_MODE] = cloneArr(lexerDefinition); + actualDefinition[DEFAULT_MODE] = DEFAULT_MODE; + } else { + // no conversion needed, input should already be a IMultiModeLexerDefinition + hasOnlySingleMode = false; + actualDefinition = cloneObj(lexerDefinition); + } + }); + + if (_this.config.skipValidations === false) { + _this.TRACE_INIT("performRuntimeChecks", function () { + _this.lexerDefinitionErrors = _this.lexerDefinitionErrors.concat(performRuntimeChecks(actualDefinition, _this.trackStartLines, _this.config.lineTerminatorCharacters)); + }); + + _this.TRACE_INIT("performWarningRuntimeChecks", function () { + _this.lexerDefinitionWarning = _this.lexerDefinitionWarning.concat(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. + + forEach(actualDefinition.modes, function (currModeValue, currModeName) { + actualDefinition.modes[currModeName] = reject(currModeValue, function (currTokType) { + return isUndefined(currTokType); + }); + }); + var allModeNames = keys(actualDefinition.modes); + 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(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 (isEmpty(_this.lexerDefinitionErrors)) { + augmentTokenTypes(currModDef); + var currAnalyzeResult_1; + + _this.TRACE_INIT("analyzeTokenTypes", function () { + currAnalyzeResult_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 = merge(_this.emptyGroups, currAnalyzeResult_1.emptyGroups); + _this.hasCustom = currAnalyzeResult_1.hasCustom || _this.hasCustom; + _this.canModeBeOptimized[currModName] = currAnalyzeResult_1.canBeOptimized; + } + }); + }); + _this.defaultMode = actualDefinition.defaultMode; + + if (!isEmpty(_this.lexerDefinitionErrors) && !_this.config.deferDefinitionErrorsHandling) { + var allErrMessages = 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 + + + forEach(_this.lexerDefinitionWarning, function (warningDescriptor) { + 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 (SUPPORT_STICKY) { + _this.chopInput = IDENTITY; + _this.match = _this.matchWithTest; + } else { + _this.updateLastIndex = NOOP; + _this.match = _this.matchWithExec; + } + + if (hasOnlySingleMode) { + _this.handleModes = NOOP; + } + + if (_this.trackStartLines === false) { + _this.computeNewColumn = IDENTITY; + } + + if (_this.trackEndLines === false) { + _this.updateTokenEndLineColumnLocation = 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 = reduce(_this.canModeBeOptimized, function (cannotBeOptimized, canBeOptimized, modeName) { + if (canBeOptimized === false) { + cannotBeOptimized.push(modeName); + } + + return cannotBeOptimized; + }, []); + + if (config.ensureOptimizations && !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 () { + clearRegExpParserCache(); + }); + + _this.TRACE_INIT("toFastProperties", function () { + toFastProperties(_this); + }); + }); + } + + Lexer.prototype.tokenize = function (text, initialMode) { + if (initialMode === void 0) { + initialMode = this.defaultMode; + } + + if (!isEmpty(this.lexerDefinitionErrors)) { + var allErrMessages = 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 = 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 = charCodeToOptimizedIndex(charCode); + var possiblePatterns = currCharCodeToPatternIdxToConfig[optimizedCharIdx]; + + if (possiblePatterns === undefined) { + return emptyArray; + } else { + return possiblePatterns; + } + } + + var pop_mode = function pop_mode(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 = 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 = 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; + }(); + + function tokenLabel(tokType) { + if (hasTokenLabel(tokType)) { + return tokType.LABEL; + } else { + return tokType.name; + } + } + function hasTokenLabel(obj) { + return isString(obj.LABEL) && obj.LABEL !== ""; + } + 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); + } + + function createTokenInternal(config) { + var pattern = config.pattern; + var tokenType = {}; + tokenType.name = config.name; + + if (!isUndefined(pattern)) { + tokenType.PATTERN = pattern; + } + + if (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 (has(config, CATEGORIES)) { + // casting to ANY as this will be fixed inside `augmentTokenTypes`` + tokenType.CATEGORIES = config[CATEGORIES]; + } + + augmentTokenTypes([tokenType]); + + if (has(config, LABEL)) { + tokenType.LABEL = config[LABEL]; + } + + if (has(config, GROUP)) { + tokenType.GROUP = config[GROUP]; + } + + if (has(config, POP_MODE)) { + tokenType.POP_MODE = config[POP_MODE]; + } + + if (has(config, PUSH_MODE)) { + tokenType.PUSH_MODE = config[PUSH_MODE]; + } + + if (has(config, LONGER_ALT)) { + tokenType.LONGER_ALT = config[LONGER_ALT]; + } + + if (has(config, LINE_BREAKS)) { + tokenType.LINE_BREAKS = config[LINE_BREAKS]; + } + + if (has(config, START_CHARS_HINT)) { + tokenType.START_CHARS_HINT = config[START_CHARS_HINT]; + } + + return tokenType; + } + + var EOF = createToken({ + name: "EOF", + pattern: Lexer.NA + }); + augmentTokenTypes([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 + }; + } + + var __extends$2 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; + }(); + + var AbstractProduction = + /** @class */ + function () { + function AbstractProduction(definition) { + this.definition = definition; + } + + AbstractProduction.prototype.accept = function (visitor) { + visitor.visit(this); + forEach(this.definition, function (prod) { + prod.accept(visitor); + }); + }; + + return AbstractProduction; + }(); + + var NonTerminal = + /** @class */ + function (_super) { + __extends$2(NonTerminal, _super); + + function NonTerminal(options) { + var _this = _super.call(this, []) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + Object.defineProperty(NonTerminal.prototype, "definition", { + get: function get() { + if (this.referencedRule !== undefined) { + return this.referencedRule.definition; + } + + return []; + }, + set: function set(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); + + var Rule = + /** @class */ + function (_super) { + __extends$2(Rule, _super); + + function Rule(options) { + var _this = _super.call(this, options.definition) || this; + + _this.orgText = ""; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return Rule; + }(AbstractProduction); + + var Alternative = + /** @class */ + function (_super) { + __extends$2(Alternative, _super); + + function Alternative(options) { + var _this = _super.call(this, options.definition) || this; + + _this.ignoreAmbiguities = false; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return Alternative; + }(AbstractProduction); + + var Option = + /** @class */ + function (_super) { + __extends$2(Option, _super); + + function Option(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return Option; + }(AbstractProduction); + + var RepetitionMandatory = + /** @class */ + function (_super) { + __extends$2(RepetitionMandatory, _super); + + function RepetitionMandatory(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return RepetitionMandatory; + }(AbstractProduction); + + var RepetitionMandatoryWithSeparator = + /** @class */ + function (_super) { + __extends$2(RepetitionMandatoryWithSeparator, _super); + + function RepetitionMandatoryWithSeparator(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return RepetitionMandatoryWithSeparator; + }(AbstractProduction); + + var Repetition = + /** @class */ + function (_super) { + __extends$2(Repetition, _super); + + function Repetition(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return Repetition; + }(AbstractProduction); + + var RepetitionWithSeparator = + /** @class */ + function (_super) { + __extends$2(RepetitionWithSeparator, _super); + + function RepetitionWithSeparator(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return RepetitionWithSeparator; + }(AbstractProduction); + + var Alternation = + /** @class */ + function (_super) { + __extends$2(Alternation, _super); + + function Alternation(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + _this.ignoreAmbiguities = false; + _this.hasPredicates = false; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return Alternation; + }(AbstractProduction); + + var Terminal = + /** @class */ + function () { + function Terminal(options) { + this.idx = 1; + assign(this, pick(options, function (v) { + return v !== undefined; + })); + } + + Terminal.prototype.accept = function (visitor) { + visitor.visit(this); + }; + + return Terminal; + }(); + function serializeGrammar(topRules) { + return map(topRules, serializeProduction); + } + function serializeProduction(node) { + function convertDefinition(definition) { + return map(definition, serializeProduction); + } + /* istanbul ignore else */ + + + if (node instanceof NonTerminal) { + return { + type: "NonTerminal", + name: node.nonTerminalName, + idx: node.idx + }; + } else if (node instanceof Alternative) { + return { + type: "Alternative", + 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", + idx: node.idx, + definition: convertDefinition(node.definition) + }; + } else if (node instanceof RepetitionMandatoryWithSeparator) { + return { + type: "RepetitionMandatoryWithSeparator", + idx: node.idx, + separator: serializeProduction(new Terminal({ + terminalType: node.separator + })), + definition: convertDefinition(node.definition) + }; + } else if (node instanceof RepetitionWithSeparator) { + return { + type: "RepetitionWithSeparator", + idx: node.idx, + separator: serializeProduction(new Terminal({ + terminalType: node.separator + })), + definition: convertDefinition(node.definition) + }; + } else if (node instanceof Repetition) { + return { + type: "Repetition", + idx: node.idx, + definition: convertDefinition(node.definition) + }; + } else if (node instanceof Alternation) { + return { + type: "Alternation", + idx: node.idx, + definition: convertDefinition(node.definition) + }; + } else if (node instanceof Terminal) { + var serializedTerminal = { + type: "Terminal", + name: node.terminalType.name, + label: tokenLabel(node.terminalType), + idx: node.idx + }; + var pattern = node.terminalType.PATTERN; + + if (node.terminalType.PATTERN) { + serializedTerminal.pattern = 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"); + } + } + + /** + * 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 = []; + } + + forEach(prod.definition, function (subProd, index) { + var currRest = drop(prod.definition, index + 1); + /* istanbul ignore else */ + + if (subProd instanceof NonTerminal) { + _this.walkProdRef(subProd, currRest, prevRest); + } else if (subProd instanceof Terminal) { + _this.walkTerminal(subProd, currRest, prevRest); + } else if (subProd instanceof Alternative) { + _this.walkFlat(subProd, currRest, prevRest); + } else if (subProd instanceof Option) { + _this.walkOption(subProd, currRest, prevRest); + } else if (subProd instanceof RepetitionMandatory) { + _this.walkAtLeastOne(subProd, currRest, prevRest); + } else if (subProd instanceof RepetitionMandatoryWithSeparator) { + _this.walkAtLeastOneSep(subProd, currRest, prevRest); + } else if (subProd instanceof RepetitionWithSeparator) { + _this.walkManySep(subProd, currRest, prevRest); + } else if (subProd instanceof Repetition) { + _this.walkMany(subProd, currRest, prevRest); + } else if (subProd instanceof 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 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 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 + + 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 Alternative({ + definition: [alt] + }); + + _this.walk(prodWrapper, fullOrRest); + }); + }; + + return RestWalker; + }(); + + function restForRepetitionWithSeparator(repSepProd, currRest, prevRest) { + var repSepRest = [new Option({ + definition: [new Terminal({ + terminalType: repSepProd.separator + })].concat(repSepProd.definition) + })]; + var fullRepSepRest = repSepRest.concat(currRest, prevRest); + return fullRepSepRest; + } + + var GAstVisitor = + /** @class */ + function () { + function GAstVisitor() {} + + GAstVisitor.prototype.visit = function (node) { + var nodeAny = node; + + switch (nodeAny.constructor) { + case NonTerminal: + return this.visitNonTerminal(nodeAny); + + case Alternative: + return this.visitAlternative(nodeAny); + + case Option: + return this.visitOption(nodeAny); + + case RepetitionMandatory: + return this.visitRepetitionMandatory(nodeAny); + + case RepetitionMandatoryWithSeparator: + return this.visitRepetitionMandatoryWithSeparator(nodeAny); + + case RepetitionWithSeparator: + return this.visitRepetitionWithSeparator(nodeAny); + + case Repetition: + return this.visitRepetition(nodeAny); + + case Alternation: + return this.visitAlternation(nodeAny); + + case Terminal: + return this.visitTerminal(nodeAny); + + case Rule: + return this.visitRule(nodeAny); + + /* istanbul ignore next */ + + default: + throw Error("non exhaustive match"); + } + }; + + GAstVisitor.prototype.visitNonTerminal = function (node) {}; + + GAstVisitor.prototype.visitAlternative = 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; + }(); + + var __extends$3 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; + }(); + function isSequenceProd(prod) { + return prod instanceof Alternative || prod instanceof Option || prod instanceof Repetition || prod instanceof RepetitionMandatory || prod instanceof RepetitionMandatoryWithSeparator || prod instanceof RepetitionWithSeparator || prod instanceof Terminal || prod instanceof Rule; + } + function isOptionalProd(prod, alreadyVisited) { + if (alreadyVisited === void 0) { + alreadyVisited = []; + } + + var isDirectlyOptional = prod instanceof Option || prod instanceof Repetition || prod instanceof 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 Alternation) { + // for OR its enough for just one of the alternatives to be optional + return some(prod.definition, function (subProd) { + return isOptionalProd(subProd, alreadyVisited); + }); + } else if (prod instanceof NonTerminal && contains(alreadyVisited, prod)) { + // avoiding stack overflow due to infinite recursion + return false; + } else if (prod instanceof AbstractProduction) { + if (prod instanceof NonTerminal) { + alreadyVisited.push(prod); + } + + return every(prod.definition, function (subProd) { + return isOptionalProd(subProd, alreadyVisited); + }); + } else { + return false; + } + } + function isBranchingProd(prod) { + return prod instanceof Alternation; + } + function getProductionDslName(prod) { + /* istanbul ignore else */ + if (prod instanceof NonTerminal) { + return "SUBRULE"; + } else if (prod instanceof Option) { + return "OPTION"; + } else if (prod instanceof Alternation) { + return "OR"; + } else if (prod instanceof RepetitionMandatory) { + return "AT_LEAST_ONE"; + } else if (prod instanceof RepetitionMandatoryWithSeparator) { + return "AT_LEAST_ONE_SEP"; + } else if (prod instanceof RepetitionWithSeparator) { + return "MANY_SEP"; + } else if (prod instanceof Repetition) { + return "MANY"; + } else if (prod instanceof Terminal) { + return "CONSUME"; + } else { + throw Error("non exhaustive match"); + } + } + + var DslMethodsCollectorVisitor = + /** @class */ + function (_super) { + __extends$3(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 (!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 (!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; + }(GAstVisitor); + var collectorVisitor = new DslMethodsCollectorVisitor(); + function collectMethods(rule) { + collectorVisitor.reset(); + rule.accept(collectorVisitor); + var dslMethods = collectorVisitor.dslMethods; // avoid uncleaned references + + collectorVisitor.reset(); + return dslMethods; + } + + function first$1(prod) { + /* istanbul ignore else */ + if (prod instanceof 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$1(prod.referencedRule); + } else if (prod instanceof Terminal) { + return firstForTerminal(prod); + } else if (isSequenceProd(prod)) { + return firstForSequence(prod); + } else if (isBranchingProd(prod)) { + return firstForBranching(prod); + } else { + throw Error("non exhaustive match"); + } + } + 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 = isOptionalProd(currSubProd); + firstSet = firstSet.concat(first$1(currSubProd)); + nextSubProdIdx = nextSubProdIdx + 1; + hasInnerProdsRemaining = seq.length > nextSubProdIdx; + } + + return uniq(firstSet); + } + function firstForBranching(prod) { + var allAlternativesFirsts = map(prod.definition, function (innerProd) { + return first$1(innerProd); + }); + return uniq(flatten(allAlternativesFirsts)); + } + function firstForTerminal(terminal) { + return [terminal.terminalType]; + } + + // TODO: can this be removed? where is it used? + var IN = "_~IN~_"; + + var __extends$4 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; + }(); + // (skipping reference production). + + var ResyncFollowsWalker = + /** @class */ + function (_super) { + __extends$4(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 Alternative({ + definition: fullRest + }); + var t_in_topProd_follows = first$1(restProd); + this.follows[followName] = t_in_topProd_follows; + }; + + return ResyncFollowsWalker; + }(RestWalker); + function computeAllProdsFollows(topProductions) { + var reSyncFollows = {}; + forEach(topProductions, function (topProd) { + var currRefsFollow = new ResyncFollowsWalker(topProd).startWalking(); + assign(reSyncFollows, currRefsFollow); + }); + return reSyncFollows; + } + function buildBetweenProdsFollowPrefix(inner, occurenceInParent) { + return inner.name + occurenceInParent + IN; + } + + var defaultParserErrorProvider = { + buildMismatchTokenMessage: function buildMismatchTokenMessage(_a) { + var expected = _a.expected, + actual = _a.actual, + previous = _a.previous, + ruleName = _a.ruleName; + var hasLabel = hasTokenLabel(expected); + var expectedMsg = hasLabel ? "--> " + tokenLabel(expected) + " <--" : "token of type --> " + expected.name + " <--"; + var msg = "Expecting " + expectedMsg + " but found --> '" + actual.image + "' <--"; + return msg; + }, + buildNotAllInputParsedMessage: function buildNotAllInputParsedMessage(_a) { + var firstRedundant = _a.firstRedundant, + ruleName = _a.ruleName; + return "Redundant input, expecting EOF but found: " + firstRedundant.image; + }, + buildNoViableAltMessage: function buildNoViableAltMessage(_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 = first(actual).image; + var errSuffix = "\nbut found: '" + actualText + "'"; + + if (customUserDescription) { + return errPrefix + customUserDescription + errSuffix; + } else { + var allLookAheadPaths = reduce(expectedPathsPerAlt, function (result, currAltPaths) { + return result.concat(currAltPaths); + }, []); + var nextValidTokenSequences = map(allLookAheadPaths, function (currPath) { + return "[" + map(currPath, function (currTokenType) { + return tokenLabel(currTokenType); + }).join(", ") + "]"; + }); + var nextValidSequenceItems = 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 buildEarlyExitMessage(_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 = first(actual).image; + var errSuffix = "\nbut found: '" + actualText + "'"; + + if (customUserDescription) { + return errPrefix + customUserDescription + errSuffix; + } else { + var nextValidTokenSequences = map(expectedIterationPaths, function (currPath) { + return "[" + map(currPath, function (currTokenType) { + return 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(defaultParserErrorProvider); + var defaultGrammarResolverErrorProvider = { + buildRuleNotFoundError: function buildRuleNotFoundError(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; + } + }; + var defaultGrammarValidatorErrorProvider = { + buildDuplicateFoundError: function buildDuplicateFoundError(topLevelRule, duplicateProds) { + function getExtraProductionArgument(prod) { + if (prod instanceof Terminal) { + return prod.terminalType.name; + } else if (prod instanceof NonTerminal) { + return prod.nonTerminalName; + } else { + return ""; + } + } + + var topLevelName = topLevelRule.name; + var duplicateProd = first(duplicateProds); + var index = duplicateProd.idx; + var dslName = 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; + }, + buildNamespaceConflictError: function buildNamespaceConflictError(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 buildAlternationPrefixAmbiguityError(options) { + var pathMsg = map(options.prefixPath, function (currTok) { + return 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 buildAlternationAmbiguityError(options) { + var pathMsg = map(options.prefixPath, function (currtok) { + return 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 buildEmptyRepetitionError(options) { + var dslName = 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 buildTokenNameError(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 buildEmptyAlternationError(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 buildTooManyAlternativesError(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 buildLeftRecursionError(options) { + var ruleName = options.topLevelRule.name; + var pathNames = 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 buildInvalidRuleNameError(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 buildDuplicateRuleNameError(options) { + var ruleName; + + if (options.topLevelRule instanceof 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; + } + }; + + var __extends$5 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; + }(); + function resolveGrammar(topLevels, errMsgProvider) { + var refResolver = new GastRefResolverVisitor(topLevels, errMsgProvider); + refResolver.resolveRefs(); + return refResolver.errors; + } + + var GastRefResolverVisitor = + /** @class */ + function (_super) { + __extends$5(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; + + forEach(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: ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF, + ruleName: this.currTopLevel.name, + unresolvedRefName: node.nonTerminalName + }); + } else { + node.referencedRule = ref; + } + }; + + return GastRefResolverVisitor; + }(GAstVisitor); + + var __extends$6 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; + }(); + + var AbstractNextPossibleTokensWalker = + /** @class */ + function (_super) { + __extends$6(AbstractNextPossibleTokensWalker, _super); + + function AbstractNextPossibleTokensWalker(topProd, path) { + var _this = _super.call(this) || 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 = cloneArr(this.path.ruleStack).reverse(); // intelij bug requires assertion + + this.occurrenceStack = 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 (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; + }(RestWalker); + + var NextAfterTokenWalker = + /** @class */ + function (_super) { + __extends$6(NextAfterTokenWalker, _super); + + function NextAfterTokenWalker(topProd, path) { + var _this = _super.call(this, topProd, path) || 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 Alternative({ + definition: fullRest + }); + this.possibleTokTypes = first$1(restProd); + this.found = true; + } + }; + + return NextAfterTokenWalker; + }(AbstractNextPossibleTokensWalker); + /** + * 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$6(AbstractNextTerminalAfterProductionWalker, _super); + + function AbstractNextTerminalAfterProductionWalker(topRule, occurrence) { + var _this = _super.call(this) || 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; + }(RestWalker); + + var NextTerminalAfterManyWalker = + /** @class */ + function (_super) { + __extends$6(NextTerminalAfterManyWalker, _super); + + function NextTerminalAfterManyWalker() { + return _super !== null && _super.apply(this, arguments) || this; + } + + NextTerminalAfterManyWalker.prototype.walkMany = function (manyProd, currRest, prevRest) { + if (manyProd.idx === this.occurrence) { + var firstAfterMany = first(currRest.concat(prevRest)); + + this.result.isEndOfRule = firstAfterMany === undefined; + + if (firstAfterMany instanceof Terminal) { + this.result.token = firstAfterMany.terminalType; + this.result.occurrence = firstAfterMany.idx; + } + } else { + _super.prototype.walkMany.call(this, manyProd, currRest, prevRest); + } + }; + + return NextTerminalAfterManyWalker; + }(AbstractNextTerminalAfterProductionWalker); + + var NextTerminalAfterManySepWalker = + /** @class */ + function (_super) { + __extends$6(NextTerminalAfterManySepWalker, _super); + + function NextTerminalAfterManySepWalker() { + return _super !== null && _super.apply(this, arguments) || this; + } + + NextTerminalAfterManySepWalker.prototype.walkManySep = function (manySepProd, currRest, prevRest) { + if (manySepProd.idx === this.occurrence) { + var firstAfterManySep = first(currRest.concat(prevRest)); + + this.result.isEndOfRule = firstAfterManySep === undefined; + + if (firstAfterManySep instanceof Terminal) { + this.result.token = firstAfterManySep.terminalType; + this.result.occurrence = firstAfterManySep.idx; + } + } else { + _super.prototype.walkManySep.call(this, manySepProd, currRest, prevRest); + } + }; + + return NextTerminalAfterManySepWalker; + }(AbstractNextTerminalAfterProductionWalker); + + var NextTerminalAfterAtLeastOneWalker = + /** @class */ + function (_super) { + __extends$6(NextTerminalAfterAtLeastOneWalker, _super); + + function NextTerminalAfterAtLeastOneWalker() { + return _super !== null && _super.apply(this, arguments) || this; + } + + NextTerminalAfterAtLeastOneWalker.prototype.walkAtLeastOne = function (atLeastOneProd, currRest, prevRest) { + if (atLeastOneProd.idx === this.occurrence) { + var firstAfterAtLeastOne = first(currRest.concat(prevRest)); + + this.result.isEndOfRule = firstAfterAtLeastOne === undefined; + + if (firstAfterAtLeastOne instanceof Terminal) { + this.result.token = firstAfterAtLeastOne.terminalType; + this.result.occurrence = firstAfterAtLeastOne.idx; + } + } else { + _super.prototype.walkAtLeastOne.call(this, atLeastOneProd, currRest, prevRest); + } + }; + + return NextTerminalAfterAtLeastOneWalker; + }(AbstractNextTerminalAfterProductionWalker); + + var NextTerminalAfterAtLeastOneSepWalker = + /** @class */ + function (_super) { + __extends$6(NextTerminalAfterAtLeastOneSepWalker, _super); + + function NextTerminalAfterAtLeastOneSepWalker() { + return _super !== null && _super.apply(this, arguments) || this; + } + + NextTerminalAfterAtLeastOneSepWalker.prototype.walkAtLeastOneSep = function (atleastOneSepProd, currRest, prevRest) { + if (atleastOneSepProd.idx === this.occurrence) { + var firstAfterfirstAfterAtLeastOneSep = first(currRest.concat(prevRest)); + + this.result.isEndOfRule = firstAfterfirstAfterAtLeastOneSep === undefined; + + if (firstAfterfirstAfterAtLeastOneSep instanceof Terminal) { + this.result.token = firstAfterfirstAfterAtLeastOneSep.terminalType; + this.result.occurrence = firstAfterfirstAfterAtLeastOneSep.idx; + } + } else { + _super.prototype.walkAtLeastOneSep.call(this, atleastOneSepProd, currRest, prevRest); + } + }; + + return NextTerminalAfterAtLeastOneSepWalker; + }(AbstractNextTerminalAfterProductionWalker); + function possiblePathsFrom(targetDef, maxLength, currPath) { + if (currPath === void 0) { + currPath = []; + } // avoid side effects + + + currPath = cloneArr(currPath); + var result = []; + var i = 0; // TODO: avoid inner funcs + + function remainingPathWith(nextDef) { + return nextDef.concat(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 Alternative) { + return getAlternativesForProd(prod.definition); + } else if (prod instanceof NonTerminal) { + return getAlternativesForProd(prod.definition); + } else if (prod instanceof Option) { + result = getAlternativesForProd(prod.definition); + } else if (prod instanceof RepetitionMandatory) { + var newDef = prod.definition.concat([new Repetition({ + definition: prod.definition + })]); + return getAlternativesForProd(newDef); + } else if (prod instanceof RepetitionMandatoryWithSeparator) { + var newDef = [new Alternative({ + definition: prod.definition + }), new Repetition({ + definition: [new Terminal({ + terminalType: prod.separator + })].concat(prod.definition) + })]; + return getAlternativesForProd(newDef); + } else if (prod instanceof RepetitionWithSeparator) { + var newDef = prod.definition.concat([new Repetition({ + definition: [new Terminal({ + terminalType: prod.separator + })].concat(prod.definition) + })]); + result = getAlternativesForProd(newDef); + } else if (prod instanceof Repetition) { + var newDef = prod.definition.concat([new Repetition({ + definition: prod.definition + })]); + result = getAlternativesForProd(newDef); + } else if (prod instanceof Alternation) { + forEach(prod.definition, function (currAlt) { + result = getAlternativesForProd(currAlt.definition); + }); + return result; + } else if (prod instanceof Terminal) { + currPath.push(prod.terminalType); + } else { + throw Error("non exhaustive match"); + } + + i++; + } + + result.push({ + partialPath: currPath, + suffixDef: drop(targetDef, i) + }); + return result; + } + 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 (!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 && 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 (isEmpty(currDef)) { + continue; + } + + var prod = currDef[0]; + /* istanbul ignore else */ + + if (prod === EXIT_NON_TERMINAL) { + var nextPath = { + idx: currIdx, + def: drop(currDef), + ruleStack: dropRight(currRuleStack), + occurrenceStack: dropRight(currOccurrenceStack) + }; + possiblePaths.push(nextPath); + } else if (prod instanceof 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: 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 NonTerminal) { + var newRuleStack = cloneArr(currRuleStack); + newRuleStack.push(prod.nonTerminalName); + var newOccurrenceStack = cloneArr(currOccurrenceStack); + newOccurrenceStack.push(prod.idx); + var nextPath = { + idx: currIdx, + def: prod.definition.concat(EXIT_NON_TERMINAL_ARR, drop(currDef)), + ruleStack: newRuleStack, + occurrenceStack: newOccurrenceStack + }; + possiblePaths.push(nextPath); + } else if (prod instanceof Option) { + // the order of alternatives is meaningful, FILO (Last path will be traversed first). + var nextPathWithout = { + idx: currIdx, + def: 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(drop(currDef)), + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(nextPathWith); + } else if (prod instanceof RepetitionMandatory) { + // TODO:(THE NEW operators here take a while...) (convert once?) + var secondIteration = new Repetition({ + definition: prod.definition, + idx: prod.idx + }); + var nextDef = prod.definition.concat([secondIteration], drop(currDef)); + var nextPath = { + idx: currIdx, + def: nextDef, + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(nextPath); + } else if (prod instanceof RepetitionMandatoryWithSeparator) { + // TODO:(THE NEW operators here take a while...) (convert once?) + var separatorGast = new Terminal({ + terminalType: prod.separator + }); + var secondIteration = new Repetition({ + definition: [separatorGast].concat(prod.definition), + idx: prod.idx + }); + var nextDef = prod.definition.concat([secondIteration], drop(currDef)); + var nextPath = { + idx: currIdx, + def: nextDef, + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(nextPath); + } else if (prod instanceof RepetitionWithSeparator) { + // the order of alternatives is meaningful, FILO (Last path will be traversed first). + var nextPathWithout = { + idx: currIdx, + def: 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 Terminal({ + terminalType: prod.separator + }); + var nthRepetition = new Repetition({ + definition: [separatorGast].concat(prod.definition), + idx: prod.idx + }); + var nextDef = prod.definition.concat([nthRepetition], drop(currDef)); + var nextPathWith = { + idx: currIdx, + def: nextDef, + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(nextPathWith); + } else if (prod instanceof Repetition) { + // the order of alternatives is meaningful, FILO (Last path will be traversed first). + var nextPathWithout = { + idx: currIdx, + def: 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 Repetition({ + definition: prod.definition, + idx: prod.idx + }); + var nextDef = prod.definition.concat([nthRepetition], drop(currDef)); + var nextPathWith = { + idx: currIdx, + def: nextDef, + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(nextPathWith); + } else if (prod instanceof 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(drop(currDef)), + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(currAltPath); + possiblePaths.push(EXIT_ALTERNATIVE); + } + } else if (prod instanceof Alternative) { + possiblePaths.push({ + idx: currIdx, + def: prod.definition.concat(drop(currDef)), + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }); + } else if (prod instanceof 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; + } + + function expandTopLevelRule(topRule, currIdx, currRuleStack, currOccurrenceStack) { + var newRuleStack = cloneArr(currRuleStack); + newRuleStack.push(topRule.name); + var newCurrOccurrenceStack = 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 + }; + } + + var __extends$7 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; + }(); + 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 || (PROD_TYPE = {})); + + function getProdType(prod) { + /* istanbul ignore else */ + if (prod instanceof Option) { + return PROD_TYPE.OPTION; + } else if (prod instanceof Repetition) { + return PROD_TYPE.REPETITION; + } else if (prod instanceof RepetitionMandatory) { + return PROD_TYPE.REPETITION_MANDATORY; + } else if (prod instanceof RepetitionMandatoryWithSeparator) { + return PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR; + } else if (prod instanceof RepetitionWithSeparator) { + return PROD_TYPE.REPETITION_WITH_SEPARATOR; + } else if (prod instanceof Alternation) { + return PROD_TYPE.ALTERNATION; + } else { + throw Error("non exhaustive match"); + } + } + function buildLookaheadFuncForOr(occurrence, ruleGrammar, maxLookahead, hasPredicates, dynamicTokensEnabled, laFuncBuilder) { + var lookAheadPaths = getLookaheadPathsForOr(occurrence, ruleGrammar, maxLookahead); + var tokenMatcher = areTokenCategoriesNotUsed(lookAheadPaths) ? tokenStructuredMatcherNoCategories : tokenStructuredMatcher; + return laFuncBuilder(lookAheadPaths, hasPredicates, tokenMatcher, dynamicTokensEnabled); + } + /** + * 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) ? tokenStructuredMatcherNoCategories : tokenStructuredMatcher; + return lookaheadBuilder(lookAheadPaths[0], tokenMatcher, dynamicTokensEnabled); + } + function buildAlternativesLookAheadFunc(alts, hasPredicates, tokenMatcher, dynamicTokensEnabled) { + var numOfAlts = alts.length; + var areAllOneTokenLookahead = every(alts, function (currAlt) { + return 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 = 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 = map(alts, function (currAlt) { + return flatten(currAlt); + }); + var choiceToAlt_1 = reduce(singleTokenAlts, function (result, currAlt, idx) { + forEach(currAlt, function (currTokType) { + if (!has(result, currTokType.tokenTypeIdx)) { + result[currTokType.tokenTypeIdx] = idx; + } + + forEach(currTokType.categoryMatches, function (currExtendingType) { + if (!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; + }; + } + } + function buildSingleAlternativeLookaheadFunction(alt, tokenMatcher, dynamicTokensEnabled) { + var areAllOneTokenLookahead = 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 = flatten(alt); + + if (singleTokensTypes.length === 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 = reduce(singleTokensTypes, function (result, currTokType, idx) { + result[currTokType.tokenTypeIdx] = true; + 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; + }; + } + } + + var RestDefinitionFinderWalker = + /** @class */ + function (_super) { + __extends$7(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; + }(RestWalker); + /** + * Returns the definition of a target production in a top level level rule. + */ + + + var InsideDefinitionFinderVisitor = + /** @class */ + function (_super) { + __extends$7(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; + }(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 = map(altsDefs, function (currAlt) { + return possiblePathsFrom([currAlt], 1); + }); + var finalResult = initializeArrayOfArrays(partialAlts.length); + var altsHashes = map(partialAlts, function (currAltPaths) { + var dict = {}; + forEach(currAltPaths, function (item) { + var keys = pathToHashKeys(item.partialPath); + 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 _loop_1(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 || 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 = possiblePathsFrom(suffixDef, pathLength + 1, currPathPrefix); + newData[altIdx] = newData[altIdx].concat(newPartialPathsAndSuffixes); // Update keys for new known paths + + forEach(newPartialPathsAndSuffixes, function (item) { + var prefixKeys = pathToHashKeys(item.partialPath); + forEach(prefixKeys, function (key) { + altsHashes[altIdx][key] = true; + }); + }); + } + } + }; // alternatives loop + + + for (var altIdx = 0; altIdx < currDataset.length; altIdx++) { + _loop_1(altIdx); + } + } + + return finalResult; + } + function getLookaheadPathsForOr(occurrence, ruleGrammar, k, orProd) { + var visitor = new InsideDefinitionFinderVisitor(occurrence, PROD_TYPE.ALTERNATION, orProd); + ruleGrammar.accept(visitor); + return lookAheadSequenceFromAlternatives(visitor.result, k); + } + 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 Alternative({ + definition: insideDef + }); + var afterFlat = new Alternative({ + definition: afterDef + }); + return lookAheadSequenceFromAlternatives([insideFlat, afterFlat], k); + } + 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; + } + function isStrictPrefixOfPath(prefix, other) { + return prefix.length < other.length && every(prefix, function (tokType, idx) { + var otherTokType = other[idx]; + return tokType === otherTokType || otherTokType.categoryMatchesMap[tokType.tokenTypeIdx]; + }); + } + function areTokenCategoriesNotUsed(lookAheadPaths) { + return every(lookAheadPaths, function (singleAltPaths) { + return every(singleAltPaths, function (singlePath) { + return every(singlePath, function (token) { + return isEmpty(token.categoryMatches); + }); + }); + }); + } + + var __extends$8 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; + }(); + function validateGrammar(topLevels, globalMaxLookahead, tokenTypes, errMsgProvider, grammarName) { + var duplicateErrors = map(topLevels, function (currTopLevel) { + return validateDuplicateProductions(currTopLevel, errMsgProvider); + }); + var leftRecursionErrors = 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 (every(leftRecursionErrors, isEmpty)) { + emptyAltErrors = map(topLevels, function (currTopRule) { + return validateEmptyOrAlternative(currTopRule, errMsgProvider); + }); + ambiguousAltsErrors = map(topLevels, function (currTopRule) { + return validateAmbiguousAlternationAlternatives(currTopRule, globalMaxLookahead, errMsgProvider); + }); + emptyRepetitionErrors = validateSomeNonEmptyLookaheadPath(topLevels, globalMaxLookahead, errMsgProvider); + } + + var termsNamespaceConflictErrors = checkTerminalAndNoneTerminalsNameSpace(topLevels, tokenTypes, errMsgProvider); + var tokenNameErrors = map(tokenTypes, function (currTokType) { + return validateTokenName(currTokType, errMsgProvider); + }); + var tooManyAltsErrors = map(topLevels, function (curRule) { + return validateTooManyAlts(curRule, errMsgProvider); + }); + var ruleNameErrors = map(topLevels, function (curRule) { + return validateRuleName(curRule, errMsgProvider); + }); + var duplicateRulesError = map(topLevels, function (curRule) { + return validateRuleDoesNotAlreadyExist(curRule, topLevels, grammarName, errMsgProvider); + }); + return flatten(duplicateErrors.concat(tokenNameErrors, emptyRepetitionErrors, leftRecursionErrors, emptyAltErrors, ambiguousAltsErrors, termsNamespaceConflictErrors, tooManyAltsErrors, ruleNameErrors, duplicateRulesError)); + } + + function validateDuplicateProductions(topLevelRule, errMsgProvider) { + var collectorVisitor = new OccurrenceValidationCollector(); + topLevelRule.accept(collectorVisitor); + var allRuleProductions = collectorVisitor.allProductions; + var productionGroups = groupBy(allRuleProductions, identifyProductionForDuplicates); + var duplicates = pick(productionGroups, function (currGroup) { + return currGroup.length > 1; + }); + var errors = map(values(duplicates), function (currDuplicates) { + var firstProd = first(currDuplicates); + var msg = errMsgProvider.buildDuplicateFoundError(topLevelRule, currDuplicates); + var dslName = getProductionDslName(firstProd); + var defError = { + message: msg, + type: 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 getProductionDslName(prod) + "_#_" + prod.idx + "_#_" + getExtraProductionArgument(prod); + } + + function getExtraProductionArgument(prod) { + if (prod instanceof Terminal) { + return prod.terminalType.name; + } else if (prod instanceof NonTerminal) { + return prod.nonTerminalName; + } else { + return ""; + } + } + + var OccurrenceValidationCollector = + /** @class */ + function (_super) { + __extends$8(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; + }(GAstVisitor); + var validTermsPattern = /^[a-zA-Z_]\w*$/; // TODO: remove this limitation now that we use recorders + + function validateRuleName(rule, errMsgProvider) { + var errors = []; + var ruleName = rule.name; + + if (!ruleName.match(validTermsPattern)) { + errors.push({ + message: errMsgProvider.buildInvalidRuleNameError({ + topLevelRule: rule, + expectedPattern: validTermsPattern + }), + type: ParserDefinitionErrorType.INVALID_RULE_NAME, + ruleName: ruleName + }); + } + + return errors; + } // TODO: remove this limitation now that we use recorders + + function validateTokenName(tokenType, errMsgProvider) { + var errors = []; + var tokTypeName = tokenType.name; + + if (!tokTypeName.match(validTermsPattern)) { + errors.push({ + message: errMsgProvider.buildTokenNameError({ + tokenType: tokenType, + expectedPattern: validTermsPattern + }), + type: ParserDefinitionErrorType.INVALID_TOKEN_NAME + }); + } + + return errors; + } + function validateRuleDoesNotAlreadyExist(rule, allRules, className, errMsgProvider) { + var errors = []; + var occurrences = 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: ParserDefinitionErrorType.DUPLICATE_RULE_NAME, + ruleName: rule.name + }); + } + + return errors; + } // 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 (!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: ParserDefinitionErrorType.INVALID_RULE_OVERRIDE, + ruleName: ruleName + }); + } + + return errors; + } + function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path) { + if (path === void 0) { + path = []; + } + + var errors = []; + var nextNonTerminals = getFirstNoneTerminal(currRule.definition); + + if (isEmpty(nextNonTerminals)) { + return []; + } else { + var ruleName = topRule.name; + var foundLeftRecursion = contains(nextNonTerminals, topRule); + + if (foundLeftRecursion) { + errors.push({ + message: errMsgProvider.buildLeftRecursionError({ + topLevelRule: topRule, + leftRecursionPath: path + }), + type: 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 = difference(nextNonTerminals, path.concat([topRule])); + var errorsFromNextSteps = map(validNextSteps, function (currRefRule) { + var newPath = cloneArr(path); + newPath.push(currRefRule); + return validateNoLeftRecursion(topRule, currRefRule, errMsgProvider, newPath); + }); + return errors.concat(flatten(errorsFromNextSteps)); + } + } + function getFirstNoneTerminal(definition) { + var result = []; + + if (isEmpty(definition)) { + return result; + } + + var firstProd = first(definition); + /* istanbul ignore else */ + + if (firstProd instanceof NonTerminal) { + result.push(firstProd.referencedRule); + } else if (firstProd instanceof Alternative || firstProd instanceof Option || firstProd instanceof RepetitionMandatory || firstProd instanceof RepetitionMandatoryWithSeparator || firstProd instanceof RepetitionWithSeparator || firstProd instanceof Repetition) { + result = result.concat(getFirstNoneTerminal(firstProd.definition)); + } else if (firstProd instanceof Alternation) { + // each sub definition in alternation is a FLAT + result = flatten(map(firstProd.definition, function (currSubDef) { + return getFirstNoneTerminal(currSubDef.definition); + })); + } else if (firstProd instanceof Terminal) ; else { + throw Error("non exhaustive match"); + } + + var isFirstOptional = isOptionalProd(firstProd); + var hasMore = definition.length > 1; + + if (isFirstOptional && hasMore) { + var rest = drop(definition); + return result.concat(getFirstNoneTerminal(rest)); + } else { + return result; + } + } + + var OrCollector = + /** @class */ + function (_super) { + __extends$8(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; + }(GAstVisitor); + + function validateEmptyOrAlternative(topLevelRule, errMsgProvider) { + var orCollector = new OrCollector(); + topLevelRule.accept(orCollector); + var ors = orCollector.alternations; + var errors = reduce(ors, function (errors, currOr) { + var exceptLast = dropRight(currOr.definition); + var currErrors = map(exceptLast, function (currAlternative, currAltIdx) { + var possibleFirstInAlt = nextPossibleTokensAfter([currAlternative], [], null, 1); + + if (isEmpty(possibleFirstInAlt)) { + return { + message: errMsgProvider.buildEmptyAlternationError({ + topLevelRule: topLevelRule, + alternation: currOr, + emptyChoiceIdx: currAltIdx + }), + type: ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT, + ruleName: topLevelRule.name, + occurrence: currOr.idx, + alternative: currAltIdx + 1 + }; + } else { + return null; + } + }); + return errors.concat(compact(currErrors)); + }, []); + return errors; + } + function validateAmbiguousAlternationAlternatives(topLevelRule, globalMaxLookahead, errMsgProvider) { + var orCollector = new OrCollector(); + topLevelRule.accept(orCollector); + var ors = orCollector.alternations; // New Handling of ignoring ambiguities + // - https://github.com/SAP/chevrotain/issues/869 + + ors = reject(ors, function (currOr) { + return currOr.ignoreAmbiguities === true; + }); + var errors = reduce(ors, function (result, currOr) { + var currOccurrence = currOr.idx; + var actualMaxLookahead = currOr.maxLookahead || globalMaxLookahead; + var alternatives = 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; + } + + var RepetionCollector = + /** @class */ + function (_super) { + __extends$8(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; + }(GAstVisitor); + function validateTooManyAlts(topLevelRule, errMsgProvider) { + var orCollector = new OrCollector(); + topLevelRule.accept(orCollector); + var ors = orCollector.alternations; + var errors = reduce(ors, function (errors, currOr) { + if (currOr.definition.length > 255) { + errors.push({ + message: errMsgProvider.buildTooManyAlternativesError({ + topLevelRule: topLevelRule, + alternation: currOr + }), + type: ParserDefinitionErrorType.TOO_MANY_ALTS, + ruleName: topLevelRule.name, + occurrence: currOr.idx + }); + } + + return errors; + }, []); + return errors; + } + function validateSomeNonEmptyLookaheadPath(topLevelRules, maxLookahead, errMsgProvider) { + var errors = []; + forEach(topLevelRules, function (currTopRule) { + var collectorVisitor = new RepetionCollector(); + currTopRule.accept(collectorVisitor); + var allRuleProductions = collectorVisitor.allProductions; + forEach(allRuleProductions, function (currProd) { + var prodType = getProdType(currProd); + var actualMaxLookahead = currProd.maxLookahead || maxLookahead; + var currOccurrence = currProd.idx; + var paths = getLookaheadPathsForOptionalProd(currOccurrence, currTopRule, prodType, actualMaxLookahead); + var pathsInsideProduction = paths[0]; + + if (isEmpty(flatten(pathsInsideProduction))) { + var errMsg = errMsgProvider.buildEmptyRepetitionError({ + topLevelRule: currTopRule, + repetition: currProd + }); + errors.push({ + message: errMsg, + type: ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD, + ruleName: currTopRule.name + }); + } + }); + }); + return errors; + } + + function checkAlternativesAmbiguities(alternatives, alternation, rule, errMsgProvider) { + var foundAmbiguousPaths = []; + var identicalAmbiguities = reduce(alternatives, function (result, currAlt, currAltIdx) { + // ignore (skip) ambiguities with this alternative + if (alternation.definition[currAltIdx].ignoreAmbiguities === true) { + return result; + } + + forEach(currAlt, function (currPath) { + var altsCurrPathAppearsIn = [currAltIdx]; + forEach(alternatives, function (currOtherAlt, currOtherAltIdx) { + if (currAltIdx !== currOtherAltIdx && containsPath(currOtherAlt, currPath) && // ignore (skip) ambiguities with this "other" alternative + alternation.definition[currOtherAltIdx].ignoreAmbiguities !== true) { + altsCurrPathAppearsIn.push(currOtherAltIdx); + } + }); + + if (altsCurrPathAppearsIn.length > 1 && !containsPath(foundAmbiguousPaths, currPath)) { + foundAmbiguousPaths.push(currPath); + result.push({ + alts: altsCurrPathAppearsIn, + path: currPath + }); + } + }); + return result; + }, []); + var currErrors = map(identicalAmbiguities, function (currAmbDescriptor) { + var ambgIndices = 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: 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 = reduce(alternatives, function (result, currAlt, idx) { + var currPathsAndIdx = map(currAlt, function (currPath) { + return { + idx: idx, + path: currPath + }; + }); + return result.concat(currPathsAndIdx); + }, []); + 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 = 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. + isStrictPrefixOfPath(searchPathAndIdx.path, targetPath) + ); + }); + var currPathPrefixErrors = 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: ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS, + ruleName: rule.name, + occurrence: occurrence, + alternatives: ambgIndices + }; + }); + errors = errors.concat(currPathPrefixErrors); + }); + return errors; + } + + function checkTerminalAndNoneTerminalsNameSpace(topLevels, tokenTypes, errMsgProvider) { + var errors = []; + var tokenNames = map(tokenTypes, function (currToken) { + return currToken.name; + }); + forEach(topLevels, function (currRule) { + var currRuleName = currRule.name; + + if (contains(tokenNames, currRuleName)) { + var errMsg = errMsgProvider.buildNamespaceConflictError(currRule); + errors.push({ + message: errMsg, + type: ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE, + ruleName: currRuleName + }); + } + }); + return errors; + } + + function resolveGrammar$1(options) { + options = defaults(options, { + errMsgProvider: defaultGrammarResolverErrorProvider + }); + var topRulesTable = {}; + forEach(options.rules, function (rule) { + topRulesTable[rule.name] = rule; + }); + return resolveGrammar(topRulesTable, options.errMsgProvider); + } + function validateGrammar$1(options) { + options = defaults(options, { + errMsgProvider: defaultGrammarValidatorErrorProvider + }); + return validateGrammar(options.rules, options.maxLookahead, options.tokenTypes, options.errMsgProvider, options.grammarName); + } + + 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 contains(RECOGNITION_EXCEPTION_NAMES, error.name); + } + function MismatchedTokenException(message, token, previousToken) { + this.name = MISMATCHED_TOKEN_EXCEPTION; + this.message = message; + this.token = token; + this.previousToken = previousToken; + this.resyncedTokens = []; + } // 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 = []; + } + NoViableAltException.prototype = Error.prototype; + function NotAllInputParsedException(message, token) { + this.name = NOT_ALL_INPUT_PARSED_EXCEPTION; + this.message = message; + this.token = token; + this.resyncedTokens = []; + } + 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 = []; + } + EarlyExitException.prototype = Error.prototype; + + var EOF_FOLLOW_KEY = {}; + var IN_RULE_RECOVERY_EXCEPTION = "InRuleRecoveryException"; + function InRuleRecoveryException(message) { + this.name = IN_RULE_RECOVERY_EXCEPTION; + this.message = message; + } + 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 = has(config, "recoveryEnabled") ? config.recoveryEnabled : 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 = 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 generateErrorMessage() { + 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 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 = 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 (isEmpty(follows)) { + return false; + } + + var mismatchedTok = this.LA(1); + var isMisMatchedTokInFollows = 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 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 (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 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; + return map(explicitRuleStack, function (ruleName, idx) { + if (idx === 0) { + return 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 = map(this.buildFullFollowKeyStack(), function (currKey) { + return _this.getFollowSetFromFollowKey(currKey); + }); + return flatten(followStack); + }; + + Recoverable.prototype.getFollowSetFromFollowKey = function (followKey) { + if (followKey === EOF_FOLLOW_KEY) { + return [EOF]; + } + + var followName = followKey.ruleName + followKey.idxInCallingRule + 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, 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 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 = cloneArr(this.RULE_OCCURRENCE_STACK); + var grammarPath = { + ruleStack: pathRuleStack, + occurrenceStack: pathOccurrenceStack, + lastTok: tokType, + lastTokOccurrence: tokIdxInRule + }; + return grammarPath; + }; + + Recoverable.prototype.getHumanReadableRuleStack = function () { + var _this = this; + + return map(this.RULE_STACK, function (currShortName) { + return _this.shortRuleNameToFullName(currShortName); + }); + }; + + return 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 = 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); + } + } + + // 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 + var BITS_FOR_METHOD_TYPE = 4; + var BITS_FOR_OCCURRENCE_IDX = 8; + // 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 */ + + var OR_IDX = 1 << BITS_FOR_OCCURRENCE_IDX; + var OPTION_IDX = 2 << BITS_FOR_OCCURRENCE_IDX; + var MANY_IDX = 3 << BITS_FOR_OCCURRENCE_IDX; + var AT_LEAST_ONE_IDX = 4 << BITS_FOR_OCCURRENCE_IDX; + var MANY_SEP_IDX = 5 << BITS_FOR_OCCURRENCE_IDX; + var AT_LEAST_ONE_SEP_IDX = 6 << 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 */ + } + + /** + * Trait responsible for the lookahead related utilities and optimizations. + */ + + var LooksAhead = + /** @class */ + function () { + function LooksAhead() {} + + LooksAhead.prototype.initLooksAhead = function (config) { + this.dynamicTokensEnabled = has(config, "dynamicTokensEnabled") ? config.dynamicTokensEnabled : DEFAULT_PARSER_CONFIG.dynamicTokensEnabled; + this.maxLookahead = has(config, "maxLookahead") ? config.maxLookahead : DEFAULT_PARSER_CONFIG.maxLookahead; + /* istanbul ignore next - Using plain array as dictionary will be tested on older node.js versions and IE11 */ + + this.lookAheadFuncsCache = 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 (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; + + forEach(rules, function (currRule) { + _this.TRACE_INIT(currRule.name + " Rule Lookahead", function () { + var _a = collectMethods(currRule), + alternation = _a.alternation, + repetition = _a.repetition, + option = _a.option, + repetitionMandatory = _a.repetitionMandatory, + repetitionMandatoryWithSeparator = _a.repetitionMandatoryWithSeparator, + repetitionWithSeparator = _a.repetitionWithSeparator; + + forEach(alternation, function (currProd) { + var prodIdx = currProd.idx === 0 ? "" : currProd.idx; + + _this.TRACE_INIT("" + getProductionDslName(currProd) + prodIdx, function () { + var laFunc = buildLookaheadFuncForOr(currProd.idx, currRule, currProd.maxLookahead || _this.maxLookahead, currProd.hasPredicates, _this.dynamicTokensEnabled, _this.lookAheadBuilderForAlternatives); + var key = getKeyForAutomaticLookahead(_this.fullRuleNameToShort[currRule.name], OR_IDX, currProd.idx); + + _this.setLaFuncCache(key, laFunc); + }); + }); + forEach(repetition, function (currProd) { + _this.computeLookaheadFunc(currRule, currProd.idx, MANY_IDX, PROD_TYPE.REPETITION, currProd.maxLookahead, getProductionDslName(currProd)); + }); + forEach(option, function (currProd) { + _this.computeLookaheadFunc(currRule, currProd.idx, OPTION_IDX, PROD_TYPE.OPTION, currProd.maxLookahead, getProductionDslName(currProd)); + }); + forEach(repetitionMandatory, function (currProd) { + _this.computeLookaheadFunc(currRule, currProd.idx, AT_LEAST_ONE_IDX, PROD_TYPE.REPETITION_MANDATORY, currProd.maxLookahead, getProductionDslName(currProd)); + }); + forEach(repetitionMandatoryWithSeparator, function (currProd) { + _this.computeLookaheadFunc(currRule, currProd.idx, AT_LEAST_ONE_SEP_IDX, PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR, currProd.maxLookahead, getProductionDslName(currProd)); + }); + forEach(repetitionWithSeparator, function (currProd) { + _this.computeLookaheadFunc(currRule, currProd.idx, MANY_SEP_IDX, PROD_TYPE.REPETITION_WITH_SEPARATOR, currProd.maxLookahead, 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 = buildLookaheadFuncForOptionalProd(prodOccurrence, rule, prodMaxLookahead || _this.maxLookahead, _this.dynamicTokensEnabled, prodType, _this.lookAheadBuilderForOptional); + var key = getKeyForAutomaticLookahead(_this.fullRuleNameToShort[rule.name], prodKey, prodOccurrence); + + _this.setLaFuncCache(key, laFunc); + }); + }; + + LooksAhead.prototype.lookAheadBuilderForOptional = function (alt, tokenMatcher, dynamicTokensEnabled) { + return buildSingleAlternativeLookaheadFunction(alt, tokenMatcher, dynamicTokensEnabled); + }; + + LooksAhead.prototype.lookAheadBuilderForAlternatives = function (alts, hasPredicates, tokenMatcher, dynamicTokensEnabled) { + return 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 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; + }(); + + /** + * 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; + } + } + /** + * 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; + } + } + function addTerminalToCst(node, token, tokenTypeName) { + if (node.children[tokenTypeName] === undefined) { + node.children[tokenTypeName] = [token]; + } else { + node.children[tokenTypeName].push(token); + } + } + function addNoneTerminalToCst(node, ruleName, ruleResult) { + if (node.children[ruleName] === undefined) { + node.children[ruleName] = [ruleResult]; + } else { + node.children[ruleName].push(ruleResult); + } + } + + function classNameFromInstance(instance) { + return functionName(instance.constructor); + } + 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; + } + /** + * @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 (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; + } + + function defaultVisit(ctx, param) { + var childrenNames = 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) { + this[currChild.name](currChild.children, param); + } + } + } // defaultVisit does not support generic out param + + + return undefined; + } + function createBaseSemanticVisitorConstructor(grammarName, ruleNames) { + var derivedConstructor = function derivedConstructor() {}; // 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 + + + defineNameProp(derivedConstructor, grammarName + "BaseSemantics"); + var semanticProto = { + visit: function visit(cstNode, param) { + // enables writing more concise visitor methods when CstNode has only a single child + if (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 (isUndefined(cstNode)) { + return undefined; + } + + return this[cstNode.name](cstNode.children, param); + }, + validateVisitor: function validateVisitor() { + var semanticDefinitionErrors = _validateVisitor(this, ruleNames); + + if (!isEmpty(semanticDefinitionErrors)) { + var errorMessages = map(semanticDefinitionErrors, function (currDefError) { + return currDefError.msg; + }); + throw Error("Errors Detected in CST Visitor <" + 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; + } + function createBaseVisitorConstructorWithDefaults(grammarName, ruleNames, baseConstructor) { + var derivedConstructor = function derivedConstructor() {}; // 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 + + + defineNameProp(derivedConstructor, grammarName + "BaseSemanticsWithDefaults"); + var withDefaultsProto = Object.create(baseConstructor.prototype); + forEach(ruleNames, function (ruleName) { + withDefaultsProto[ruleName] = defaultVisit; + }); + derivedConstructor.prototype = withDefaultsProto; + derivedConstructor.prototype.constructor = derivedConstructor; + return derivedConstructor; + } + var CstVisitorDefinitionError; + + (function (CstVisitorDefinitionError) { + CstVisitorDefinitionError[CstVisitorDefinitionError["REDUNDANT_METHOD"] = 0] = "REDUNDANT_METHOD"; + CstVisitorDefinitionError[CstVisitorDefinitionError["MISSING_METHOD"] = 1] = "MISSING_METHOD"; + })(CstVisitorDefinitionError || (CstVisitorDefinitionError = {})); + + function _validateVisitor(visitorInstance, ruleNames) { + var missingErrors = validateMissingCstMethods(visitorInstance, ruleNames); + var redundantErrors = validateRedundantMethods(visitorInstance, ruleNames); + return missingErrors.concat(redundantErrors); + } + function validateMissingCstMethods(visitorInstance, ruleNames) { + var errors = map(ruleNames, function (currRuleName) { + if (!isFunction(visitorInstance[currRuleName])) { + return { + msg: "Missing visitor method: <" + currRuleName + "> on " + functionName(visitorInstance.constructor) + " CST Visitor.", + type: CstVisitorDefinitionError.MISSING_METHOD, + methodName: currRuleName + }; + } + }); + return compact(errors); + } + var VALID_PROP_NAMES = ["constructor", "visit", "validateVisitor"]; + function validateRedundantMethods(visitorInstance, ruleNames) { + var errors = []; + + for (var prop in visitorInstance) { + if (validTermsPattern.test(prop) && isFunction(visitorInstance[prop]) && !contains(VALID_PROP_NAMES, prop) && !contains(ruleNames, prop)) { + errors.push({ + msg: "Redundant visitor method: <" + prop + "> on " + 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 /" + validTermsPattern.source + "/."), + type: CstVisitorDefinitionError.REDUNDANT_METHOD, + methodName: prop + }); + } + } + + return errors; + } + + /** + * This trait is responsible for the CST building logic. + */ + + var TreeBuilder = + /** @class */ + function () { + function TreeBuilder() {} + + TreeBuilder.prototype.initTreeBuilder = function (config) { + this.CST_STACK = []; // outputCst is no longer exposed/defined in the pubic API + + this.outputCst = config.outputCst; + this.nodeLocationTracking = has(config, "nodeLocationTracking") ? config.nodeLocationTracking : DEFAULT_PARSER_CONFIG.nodeLocationTracking; + + if (!this.outputCst) { + this.cstInvocationStateUpdate = NOOP; + this.cstFinallyStateUpdate = NOOP; + this.cstPostTerminal = NOOP; + this.cstPostNonTerminal = NOOP; + this.cstPostRule = NOOP; + } else { + if (/full/i.test(this.nodeLocationTracking)) { + if (this.recoveryEnabled) { + this.setNodeLocationFromToken = setNodeLocationFull; + this.setNodeLocationFromNode = setNodeLocationFull; + this.cstPostRule = NOOP; + this.setInitialNodeLocation = this.setInitialNodeLocationFullRecovery; + } else { + this.setNodeLocationFromToken = NOOP; + this.setNodeLocationFromNode = NOOP; + this.cstPostRule = this.cstPostRuleFull; + this.setInitialNodeLocation = this.setInitialNodeLocationFullRegular; + } + } else if (/onlyOffset/i.test(this.nodeLocationTracking)) { + if (this.recoveryEnabled) { + this.setNodeLocationFromToken = setNodeLocationOnlyOffset; + this.setNodeLocationFromNode = setNodeLocationOnlyOffset; + this.cstPostRule = NOOP; + this.setInitialNodeLocation = this.setInitialNodeLocationOnlyOffsetRecovery; + } else { + this.setNodeLocationFromToken = NOOP; + this.setNodeLocationFromNode = NOOP; + this.cstPostRule = this.cstPostRuleOnlyOffset; + this.setInitialNodeLocation = this.setInitialNodeLocationOnlyOffsetRegular; + } + } else if (/none/i.test(this.nodeLocationTracking)) { + this.setNodeLocationFromToken = NOOP; + this.setNodeLocationFromNode = NOOP; + this.cstPostRule = NOOP; + this.setInitialNodeLocation = 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 + }; + }; + + TreeBuilder.prototype.cstInvocationStateUpdate = function (fullRuleName, shortName) { + var cstNode = { + name: fullRuleName, + children: {} + }; + this.setInitialNodeLocation(cstNode); + this.CST_STACK.push(cstNode); + }; + + TreeBuilder.prototype.cstFinallyStateUpdate = function () { + this.CST_STACK.pop(); + }; + + 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. + + 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. + + 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]; + 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) { + var preCstNode = this.CST_STACK[this.CST_STACK.length - 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 (isUndefined(this.baseCstVisitorConstructor)) { + var newBaseCstVisitorConstructor = createBaseSemanticVisitorConstructor(this.className, keys(this.gastProductionsCache)); + this.baseCstVisitorConstructor = newBaseCstVisitorConstructor; + return newBaseCstVisitorConstructor; + } + + return this.baseCstVisitorConstructor; + }; + + TreeBuilder.prototype.getBaseCstVisitorConstructorWithDefaults = function () { + if (isUndefined(this.baseCstVisitorWithDefaultsConstructor)) { + var newConstructor = createBaseVisitorConstructorWithDefaults(this.className, keys(this.gastProductionsCache), this.getBaseCstVisitorConstructor()); + this.baseCstVisitorWithDefaultsConstructor = newConstructor; + return newConstructor; + } + + return this.baseCstVisitorWithDefaultsConstructor; + }; + + TreeBuilder.prototype.getLastExplicitRuleShortName = function () { + var ruleStack = this.RULE_STACK; + return ruleStack[ruleStack.length - 1]; + }; + + TreeBuilder.prototype.getPreviousExplicitRuleShortName = function () { + var ruleStack = this.RULE_STACK; + return ruleStack[ruleStack.length - 2]; + }; + + TreeBuilder.prototype.getLastExplicitRuleOccurrenceIndex = function () { + var occurrenceStack = this.RULE_OCCURRENCE_STACK; + return occurrenceStack[occurrenceStack.length - 1]; + }; + + return TreeBuilder; + }(); + + /** + * 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 get() { + return this.tokVector; + }, + set: function set(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 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 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; + }(); + + /** + * 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 = DEFAULT_RULE_CONFIG; + } + + if (contains(this.definedRulesNames, name)) { + var errMsg = defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({ + topLevelRule: name, + grammarName: this.className + }); + var error = { + message: errMsg, + type: 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 = DEFAULT_RULE_CONFIG; + } + + var ruleErrors = []; + ruleErrors = ruleErrors.concat(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 (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 serializeGrammar(values(this.gastProductionsCache)); + }; + + return RecognizerApi; + }(); + + /** + * 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 = 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 = tokenStructuredMatcherNoCategories; + this.definedRulesNames = []; + this.tokensMap = {}; + this.isBackTrackingStack = []; + this.RULE_STACK = []; + this.RULE_OCCURRENCE_STACK = []; + this.gastProductionsCache = {}; + + if (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 (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 (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 (isArray(tokenVocabulary)) { + this.tokensMap = reduce(tokenVocabulary, function (acc, tokType) { + acc[tokType.name] = tokType; + return acc; + }, {}); + } else if (has(tokenVocabulary, "modes") && every(flatten(values(tokenVocabulary.modes)), isTokenType)) { + var allTokenTypes = flatten(values(tokenVocabulary.modes)); + var uniqueTokens = uniq(allTokenTypes); + this.tokensMap = reduce(uniqueTokens, function (acc, tokType) { + acc[tokType.name] = tokType; + return acc; + }, {}); + } else if (isObject(tokenVocabulary)) { + this.tokensMap = 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"] = EOF; // TODO: This check may not be accurate for multi mode lexers + + var noTokenCategoriesUsed = every(values(tokenVocabulary), function (tokenConstructor) { + return isEmpty(tokenConstructor.categoryMatches); + }); + this.tokenMatcher = noTokenCategoriesUsed ? tokenStructuredMatcherNoCategories : 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 + + augmentTokenTypes(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 = has(config, "resyncEnabled") ? config.resyncEnabled : DEFAULT_RULE_CONFIG.resyncEnabled; + var recoveryValueFunc = has(config, "recoveryValueFunc") ? config.recoveryValueFunc : 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 << BITS_FOR_METHOD_TYPE + 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 wrappedGrammarRule(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 (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(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 lookAheadFunc() { + 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(AT_LEAST_ONE_IDX, prodOccurrence); + return this.atLeastOneInternalLogic(prodOccurrence, actionORMethodDef, laKey); + }; + + 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 lookAheadFunc() { + 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, 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, AT_LEAST_ONE_IDX, prodOccurrence, NextTerminalAfterAtLeastOneWalker); + }; + + RecognizerEngine.prototype.atLeastOneSepFirstInternal = function (prodOccurrence, options) { + var laKey = this.getKeyForAutomaticLookahead(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 separatorLookAheadFunc() { + 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, NextTerminalAfterAtLeastOneSepWalker], separatorLookAheadFunc, AT_LEAST_ONE_SEP_IDX, prodOccurrence, NextTerminalAfterAtLeastOneSepWalker); + } else { + throw this.raiseEarlyExitException(prodOccurrence, PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR, options.ERR_MSG); + } + }; + + RecognizerEngine.prototype.manyInternal = function (prodOccurrence, actionORMethodDef) { + var laKey = this.getKeyForAutomaticLookahead(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 lookaheadFunction() { + 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, MANY_IDX, prodOccurrence, 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(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 separatorLookAheadFunc() { + 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, NextTerminalAfterManySepWalker], separatorLookAheadFunc, MANY_SEP_IDX, prodOccurrence, 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, 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.orInternal = function (altsOrOpts, occurrence) { + var laKey = this.getKeyForAutomaticLookahead(OR_IDX, occurrence); + var alts = isArray(altsOrOpts) ? altsOrOpts : altsOrOpts.DEF; + 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.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 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 (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 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 === 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 = cloneArr(this.RULE_STACK); + return { + errors: savedErrors, + lexerState: this.exportLexerState(), + RULE_STACK: savedRuleStack, + CST_STACK: this.CST_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), EOF); + }; + + RecognizerEngine.prototype.reset = function () { + this.resetLexerState(); + this.isBackTrackingStack = []; + this.errors = []; + this.RULE_STACK = []; // TODO: extract a specific reset for TreeBuilder trait + + this.CST_STACK = []; + this.RULE_OCCURRENCE_STACK = []; + }; + + return RecognizerEngine; + }(); + + /** + * Trait responsible for runtime parsing errors. + */ + + var ErrorHandler = + /** @class */ + function () { + function ErrorHandler() {} + + ErrorHandler.prototype.initErrorHandler = function (config) { + this._errors = []; + this.errorMessageProvider = has(config, "errorMessageProvider") ? config.errorMessageProvider : DEFAULT_PARSER_CONFIG.errorMessageProvider; + }; + + ErrorHandler.prototype.SAVE_ERROR = function (error) { + if (isRecognitionException(error)) { + error.context = { + ruleStack: this.getHumanReadableRuleStack(), + ruleOccurrenceStack: 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", { + get: function get() { + return cloneArr(this._errors); + }, + set: function set(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 = 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 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 = 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 NoViableAltException(errMsg, this.LA(1), previousToken)); + }; + + return ErrorHandler; + }(); + + var ContentAssist = + /** @class */ + function () { + function ContentAssist() {} + + ContentAssist.prototype.initContentAssist = function () {}; + + ContentAssist.prototype.computeContentAssist = function (startRuleName, precedingInput) { + var startRuleGast = this.gastProductionsCache[startRuleName]; + + if (isUndefined(startRuleGast)) { + throw Error("Rule ->" + startRuleName + "<- does not exist in this grammar."); + } + + return 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 = first(grammarPath.ruleStack); + var gastProductions = this.getGAstProductions(); + var topProduction = gastProductions[topRuleName]; + var nextPossibleTokenTypes = new NextAfterTokenWalker(topProduction, grammarPath).startWalking(); + return nextPossibleTokenTypes; + }; + + return ContentAssist; + }(); + + 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, BITS_FOR_OCCURRENCE_IDX) - 1; + var RFT = createToken({ + name: "RECORDING_PHASE_TOKEN", + pattern: Lexer.NA + }); + augmentTokenTypes([RFT]); + var RECORDING_PHASE_TOKEN = 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 _loop_1(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 END_OF_FILE; + }; + + GastRecorder.prototype.topLevelRuleRecord = function (name, def) { + try { + var newTopLevelRule = new 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, Option, actionORMethodDef, occurrence); + }; + + GastRecorder.prototype.atLeastOneInternalRecord = function (occurrence, actionORMethodDef) { + recordProd.call(this, RepetitionMandatory, actionORMethodDef, occurrence); + }; + + GastRecorder.prototype.atLeastOneSepFirstInternalRecord = function (occurrence, options) { + recordProd.call(this, RepetitionMandatoryWithSeparator, options, occurrence, HANDLE_SEPARATOR); + }; + + GastRecorder.prototype.manyInternalRecord = function (occurrence, actionORMethodDef) { + recordProd.call(this, Repetition, actionORMethodDef, occurrence); + }; + + GastRecorder.prototype.manySepFirstInternalRecord = function (occurrence, options) { + recordProd.call(this, 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 || 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 = peek(this.recordingProdStack); + var ruleName = ruleToCall["ruleName"]; + var newNoneTerminal = new 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 (!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 = peek(this.recordingProdStack); + var newNoneTerminal = new Terminal({ + idx: occurrence, + terminalType: tokType + }); + prevProd.definition.push(newNoneTerminal); + return RECORDING_PHASE_TOKEN; + }; + + return GastRecorder; + }(); + + function recordProd(prodConstructor, mainProdArg, occurrence, handleSep) { + if (handleSep === void 0) { + handleSep = false; + } + + assertMethodIdxIsValid(occurrence); + var prevProd = peek(this.recordingProdStack); + var grammarAction = isFunction(mainProdArg) ? mainProdArg : mainProdArg.DEF; + var newProd = new prodConstructor({ + definition: [], + idx: occurrence + }); + + if (handleSep) { + newProd.separator = mainProdArg.SEP; + } + + if (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 = peek(this.recordingProdStack); // Only an array of alternatives + + var hasOptions = isArray(mainProdArg) === false; + var alts = hasOptions === false ? mainProdArg : mainProdArg.DEF; + var newOrProd = new Alternation({ + definition: [], + idx: occurrence, + ignoreAmbiguities: hasOptions && mainProdArg.IGNORE_AMBIGUITIES === true + }); + + if (has(mainProdArg, "MAX_LOOKAHEAD")) { + newOrProd.maxLookahead = mainProdArg.MAX_LOOKAHEAD; + } + + var hasPredicates = some(alts, function (currAlt) { + return isFunction(currAlt.GATE); + }); + newOrProd.hasPredicates = hasPredicates; + prevProd.definition.push(newOrProd); + forEach(alts, function (currAlt) { + var currAltFlat = new Alternative({ + definition: [] + }); + newOrProd.definition.push(currAltFlat); + + if (has(currAlt, "IGNORE_AMBIGUITIES")) { + currAltFlat.ignoreAmbiguities = currAlt.IGNORE_AMBIGUITIES; + } // **implicit** ignoreAmbiguities due to usage of gate + else if (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; + } + } + + /** + * Trait responsible for runtime parsing errors. + */ + + var PerformanceTracer = + /** @class */ + function () { + function PerformanceTracer() {} + + PerformanceTracer.prototype.initPerformanceTracer = function (config) { + if (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 = 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 = 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; + }(); + + var __extends$9 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; + }(); + var END_OF_FILE = createTokenInstance(EOF, "", NaN, NaN, NaN, NaN, NaN, NaN); + Object.freeze(END_OF_FILE); + var DEFAULT_PARSER_CONFIG = Object.freeze({ + recoveryEnabled: false, + maxLookahead: 3, + dynamicTokensEnabled: false, + outputCst: true, + errorMessageProvider: defaultParserErrorProvider, + nodeLocationTracking: "none", + traceInitPerf: false, + skipValidations: false + }); + var DEFAULT_RULE_CONFIG = Object.freeze({ + recoveryValueFunc: function recoveryValueFunc() { + 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["NO_NON_EMPTY_LOOKAHEAD"] = 10] = "NO_NON_EMPTY_LOOKAHEAD"; + ParserDefinitionErrorType[ParserDefinitionErrorType["AMBIGUOUS_PREFIX_ALTS"] = 11] = "AMBIGUOUS_PREFIX_ALTS"; + ParserDefinitionErrorType[ParserDefinitionErrorType["TOO_MANY_ALTS"] = 12] = "TOO_MANY_ALTS"; + })(ParserDefinitionErrorType || (ParserDefinitionErrorType = {})); + + var Parser = + /** @class */ + function () { + function Parser(tokenVocabulary, config) { + 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); + + if (has(config, "ignoredIssues")) { + throw new Error("The IParserConfig property has been deprecated.\n\t" + "Please use the flag on the relevant DSL method instead.\n\t" + "See: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\t" + "For further details."); + } + + this.skipValidations = has(config, "skipValidations") ? config.skipValidations : DEFAULT_PARSER_CONFIG.skipValidations; + } + /** + * @deprecated use the **instance** method with the same name instead + */ + + + Parser.performSelfAnalysis = function (parserInstance) { + throw Error("The **static** `performSelfAnalysis` method has been deprecated." + "\t\nUse the **instance** method with the same name instead."); + }; + + 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. + toFastProperties(_this); + }); + + _this.TRACE_INIT("Grammar Recording", function () { + try { + _this.enableRecording(); // Building the GAST + + + 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 = resolveGrammar$1({ + rules: 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 (isEmpty(resolverErrors) && _this.skipValidations === false) { + var validationErrors = validateGrammar$1({ + rules: values(_this.gastProductionsCache), + maxLookahead: _this.maxLookahead, + tokenTypes: values(_this.tokensMap), + errMsgProvider: 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 (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 = computeAllProdsFollows(values(_this.gastProductionsCache)); + _this.resyncFollows = allFollows; + }); + } + + _this.TRACE_INIT("ComputeLookaheadFunctions", function () { + _this.preComputeLookaheadFunctions(values(_this.gastProductionsCache)); + }); + } + + if (!Parser.DEFER_DEFINITION_ERRORS_HANDLING && !isEmpty(_this.definitionErrors)) { + defErrorsMsgs = 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; + }(); + applyMixins(Parser, [Recoverable, LooksAhead, TreeBuilder, LexerAdapter, RecognizerEngine, RecognizerApi, ErrorHandler, ContentAssist, GastRecorder, PerformanceTracer]); + + var CstParser = + /** @class */ + function (_super) { + __extends$9(CstParser, _super); + + function CstParser(tokenVocabulary, config) { + if (config === void 0) { + config = DEFAULT_PARSER_CONFIG; + } + + var _this = this; + + var configClone = cloneObj(config); + configClone.outputCst = true; + _this = _super.call(this, tokenVocabulary, configClone) || this; + return _this; + } + + return CstParser; + }(Parser); + + var EmbeddedActionsParser = + /** @class */ + function (_super) { + __extends$9(EmbeddedActionsParser, _super); + + function EmbeddedActionsParser(tokenVocabulary, config) { + if (config === void 0) { + config = DEFAULT_PARSER_CONFIG; + } + + var _this = this; + + var configClone = cloneObj(config); + configClone.outputCst = false; + _this = _super.call(this, tokenVocabulary, configClone) || this; + return _this; + } + + return EmbeddedActionsParser; + }(Parser); + + var NOOP$1 = Symbol("NOOP"); // basically continue + + var MATCH_ANY = Symbol("MATCH_ANY"); + var MATCH_WORD = Symbol("MATCH_WORD"); + var MATCH_TAG = Symbol("MATCH_TAG"); + var MATCH_METHOD = Symbol("MATCH_METHOD"); + var MATCH_END = Symbol("MATCH_END"); + var JMP = Symbol("JMP"); + var SPLIT = Symbol("SPLIT"); + var GLOBAL_SAVE = Symbol("GLOBAL_SAVE"); // Set global save value, if true saves results. + + var MATCH = Symbol("MATCH"); + var OGROUP = Symbol("OGROUP"); // open group + + var CGROUP = Symbol("CGROUP"); // close group + + var INCV = Symbol("INCV"); // increment a value, set to 0 by default + + var JMP_LT = Symbol("JMP_LT"); // jmp if a variable is less than value else continue + + var SPLIT_LT = Symbol("SPLIT_LT"); // split if a variable is less than value else continue + + var LOOKAHEAD = Symbol("LOOKAHEAD"); + var NEGATIVE_LOOKAHEAD = Symbol("NEGATIVE_LOOKAHEAD"); + + var StartOf = createToken({ + name: "StartOf", + pattern: /\^/ + }); + var EndOf = createToken({ + name: "EndOf", + pattern: /\$/ + }); + var Tag = createToken({ + name: "Tag", + pattern: /#([_-\w]|\\.)+/ + }); + var EscapedWord = createToken({ + name: "EscapedWord", + pattern: /\\[#@]([_-\w]|\\.)+/ + }); + var Word = createToken({ + name: "Word", + pattern: /([_-\w]|\\.)+/ + }); + var Method = createToken({ + name: "Method", + pattern: /@[_-\w]+/ + }); + var Question = createToken({ + name: "Question", + pattern: /\?/, + longer_alt: Word + }); + var Exclamation = createToken({ + name: "Exclamation", + pattern: /!/, + longer_alt: Word + }); + var Equals = createToken({ + name: "Equals", + pattern: /=/, + longer_alt: Word + }); + var Pound = createToken({ + name: "Pound", + pattern: /#/, + longer_alt: Tag + }); + var Dot = createToken({ + name: "Dot", + pattern: /\./, + longer_alt: Word + }); + var RegexP = createToken({ + name: "RegexP", + pattern: /\/.*?\// + }); + var Pipe = createToken({ + name: "Pipe", + pattern: /\|/ + }); + var Comma = createToken({ + name: "Comma", + pattern: /,/, + longer_alt: Word + }); + var Colon = createToken({ + name: "Colon", + pattern: /:/, + longer_alt: Word + }); + var Plus = createToken({ + name: "Plus", + pattern: /\+/ + }); + var Star = createToken({ + name: "Star", + pattern: /\*/ + }); + var Zero = createToken({ + name: "Zero", + pattern: /0/, + longer_alt: Word + }); + var PositiveInt = createToken({ + name: "PositiveInt", + pattern: /[1-9]\d*/, + longer_alt: Word + }); + var LParenthesis = createToken({ + name: "LParenthesis", + pattern: /\(/ + }); + var RParenthesis = createToken({ + name: "RParenthesis", + pattern: /\)/ + }); + var LCurly = createToken({ + name: "LCurly", + pattern: /\{/ + }); + var RCurly = createToken({ + name: "RCurly", + pattern: /\}/ + }); + var NamedGroupBegin = createToken({ + name: "NamedGroupBegin", + pattern: /P/, + longer_alt: Word + }); + var WhiteSpace = createToken({ + name: "WhiteSpace", + pattern: /\s+/, + group: Lexer.SKIPPED + }); + var allTokens = [NamedGroupBegin, NamedGroupEnd, WhiteSpace, StartOf, EndOf, Zero, PositiveInt, Dot, EscapedWord, Word, Method, Tag, Exclamation, Equals, Pound, Colon, Question, Plus, Star, Comma, Pipe, LParenthesis, RParenthesis, LCurly, RCurly]; // Notes or something like it, may not be accurate. + // (a|b) + // 0. split 1, 3 + // 1. char a + // 2. jmp 4 + // 3. char b + // 4. match + // + // (a|b|c) + // 0. split 1, 3, 5 + // 1. char a + // 2. jmp 7 + // 3. char b + // 4. jmp 7 + // 5. char c + // 6. match + // + // ((a|b)|c) + // 0. split 1, 6 + // 1. split 2, 4 + // 2. char a + // 3. jmp 7 + // 4. char b + // 5. jmp 7 + // 6. char c + // 7. match + // + // a{2} + // 0. noop + // 1. char a + // 2. incv i 1, def=0 + // 3. jmp_lt i 2 [0] + // + // a{2, 3} + // 0. noop + // 1. char a + // 2. incv i 1, def=0 + // 3. jmp_lt 0 i [2] + // 4. split_lt i 3 [0, 6] + // + // a{,3} + // 0. noop + // 1. char a + // 2. incv i 1, def=0 + // 3. split_lt i 3 [0, 5] + // + // a{3,} + // 0. noop + // 1. char a + // 2. incv i 1, def=0 + // 3. jmp_lt i 3 + // 4. split [0, 6] + // + // a(!b) + // 0. noop + // 1. char a + // 2. nlookahead prog // negative lookahead is a sub program + // 1. match b + // 2. match + // 2.1. if found stop, else continue at current sp + // + + var NLPMatchParser = /*#__PURE__*/function (_EmbeddedActionsParse) { + _inherits(NLPMatchParser, _EmbeddedActionsParse); + + var _super = _createSuper(NLPMatchParser); + + function NLPMatchParser() { + var _this; + + _classCallCheck(this, NLPMatchParser); + + _this = _super.call(this, allTokens); + /* + * '.' + * '^remind #Noun$' + * '\#Noun' -- escaped word containing # + * '(remind|#Noun)' + * '(remind+|#Noun)' + * '(remind|#Noun)+' + * '#Noun{2}' + * '#Noun?' + * '#Noun*' + * '(?:remind #Noun)' -- non capturing group + * '(?P#Noun)' + * '(?P#Noun)+' + * + * matchStatement ([startOf] valueStatement [endOf]) + * valueStatement (value [...value]) + * rangeModifier (LCurly, ((PositiveInt|Zero) [, PositiveInt]) RCurly) + * oneOrMore (Plus) + * zeroOrMore (Star) + * zeroOrOne (Question) + * valueModifier (oneOrMore, rangeModifier, zeroOrMore, zeroOrOne) + * value (dot, word, escapedWord, tag, Zero, PositiveInt, group)[valueModifier] + * namedGroupBegin: token pattern /\?P/ + * namedGroup (namedGroupBegin, Word, namedGroupEnd) + * nonCapturingGroup token pattern /\?:/ -- TODO: figure out how to escape these + * negativeGroup token patter /\?!/ + * groupModifier [namedGroup|nonCapturingGroup] + * group (LParent, [groupModifier], valueStatement|...), RParen) + * + */ + + var $ = _assertThisInitialized(_this); + + $.RULE("matchStatement", function () { + var matches = { + startOf: false, + prog: [], + endOf: false + }; + $.OPTION(function () { + $.CONSUME(StartOf); + matches.startOf = true; + }); // handle ^ startOf + + if (!matches.startOf) { + // .*? at the start when not ^ / startOf, don't save the matched + // values. + matches.prog.push({ + code: GLOBAL_SAVE, + value: false + }); + matches.prog.push({ + code: SPLIT, + locs: [4, 2] + }); + matches.prog.push({ + code: MATCH_ANY + }); + matches.prog.push({ + code: JMP, + loc: 1 + }); + matches.prog.push({ + code: GLOBAL_SAVE, + value: true + }); + } + + matches.groups = []; + $.SUBRULE($.valueStatement, { + ARGS: [matches.prog, matches.groups] + }); + $.OPTION1(function () { + $.CONSUME(EndOf); + matches.endOf = true; + }); // handle $ endOf + + $.ACTION(function () { + if (matches.endOf) { + matches.prog.push({ + code: MATCH_END + }); + } + + matches.prog.push({ + code: MATCH + }); + }); + return matches; + }); + $.RULE("valueStatement", function () { + var prog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var groups = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + var vars = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; + var inst = []; + $.AT_LEAST_ONE({ + DEF: function DEF() { + $.SUBRULE($.value, { + ARGS: [prog, groups, vars] + }); + } + }); + return inst; + }); + $.RULE("value", function () { + var prog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var groups = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + var vars = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; + var split = { + code: NOOP$1 + }; // save split for modifiers + + prog.push(split); + var start = prog.length; // save start for split jmp later + + $.OR([{ + ALT: function ALT() { + $.CONSUME(Dot); + prog.push({ + code: MATCH_ANY + }); + } + }, { + ALT: function ALT() { + prog.push({ + code: MATCH_WORD, + value: $.CONSUME(Word).image + }); + } + }, { + ALT: function ALT() { + var _$$CONSUME$image; + + prog.push({ + code: MATCH_WORD, + value: (_$$CONSUME$image = $.CONSUME(EscapedWord).image) === null || _$$CONSUME$image === void 0 ? void 0 : _$$CONSUME$image.substr(1) + }); + } + }, { + ALT: function ALT() { + var _$$CONSUME$image2; + + prog.push({ + code: MATCH_TAG, + value: (_$$CONSUME$image2 = $.CONSUME(Tag).image) === null || _$$CONSUME$image2 === void 0 ? void 0 : _$$CONSUME$image2.substr(1) + }); + } + }, { + ALT: function ALT() { + prog.push({ + code: MATCH_WORD, + value: $.CONSUME(Zero).image + }); + } + }, { + ALT: function ALT() { + prog.push({ + code: MATCH_WORD, + value: $.CONSUME(PositiveInt).image + }); + } + }, { + ALT: function ALT() { + var _$$CONSUME$image3; + + prog.push({ + code: MATCH_METHOD, + value: (_$$CONSUME$image3 = $.CONSUME(Method).image) === null || _$$CONSUME$image3 === void 0 ? void 0 : _$$CONSUME$image3.substr(1) + }); + } + }, { + ALT: function ALT() { + $.SUBRULE($.group, { + ARGS: [prog, groups, vars] + }); + } + }]); + $.OPTION(function () { + // TODO: could probably allow relative jmps to get rid of noop + var _$$SUBRULE = $.SUBRULE($.valueModifier), + type = _$$SUBRULE.type, + greedy = _$$SUBRULE.greedy, + min = _$$SUBRULE.min, + max = _$$SUBRULE.max; + + switch (type) { + case "ZERO_OR_ONE": + split.code = SPLIT; + split.locs = [start, prog.length]; + break; + + case "ZERO_OR_MORE": + prog.push({ + code: JMP, + loc: start - 1 + }); + split.code = SPLIT; + split.locs = [start, prog.length]; + break; + + case "ONE_OR_MORE": + prog.push({ + code: SPLIT, + locs: [start, prog.length + 1] + }); + + if (!greedy) { + prog[prog.length - 1].locs.reverse(); + } + + break; + + case "RANGE": + var varId = vars.length; + vars.push(varId); + prog.push({ + code: INCV, + varId: varId + }); // increment first + + var minInst = { + code: JMP_LT, + varId: varId, + value: min !== null && min !== void 0 ? min : 0, + loc: start + }; + var maxInst = null; + + if (min === max) { + // a{x} + if (min === 0) { + // a{0} skip matching, causes token to be ignored + split.code = JMP; + split.loc = prog.length; // next instruction + } else { + // a{x} + prog.push(minInst); + } + } else if ((min !== null && min !== void 0 ? min : 0) === 0 && max !== null) { + // a{,y} a{0,y} + split.code = SPLIT; + split.locs = [start, prog.length + 1]; + maxInst = { + code: SPLIT_LT, + varId: varId, + value: max, + locs: [start, prog.length + 1] + }; + prog.push(maxInst); + } else if (min !== null && max === null) { + // a{x,} + prog.push(minInst); + maxInst = { + code: SPLIT, + locs: [start, prog.length + 1] + }; + prog.push(maxInst); + } else { + // if (min !== null && max !== null) { + // a{x,y} + prog.push(minInst); + maxInst = { + code: SPLIT_LT, + varId: varId, + value: max, + locs: [start, prog.length + 1] + }; + prog.push(maxInst); + } + + if (!greedy) { + var _maxInst, _maxInst$locs; + + (_maxInst = maxInst) === null || _maxInst === void 0 ? void 0 : (_maxInst$locs = _maxInst.locs) === null || _maxInst$locs === void 0 ? void 0 : _maxInst$locs.reverse(); // reverse thread priority for greedy / non-greedy + } //{ code: SPLIT, locs: [ ] } + //prog.push({ code: SETV_ONCE, id: rid, value: 0 }); + //prog.push({ code: INCREMENT, id: rid, value: 1 }); + //prog.push({ code: JMP_IF_GTE, id: rid, value: 0 }); + + + break; + } + + if (!greedy) { + var _split$locs; + + split === null || split === void 0 ? void 0 : (_split$locs = split.locs) === null || _split$locs === void 0 ? void 0 : _split$locs.reverse(); + } + }); + }); + $.RULE("valueModifier", function () { + var result = { + type: null, + greedy: true + }; + $.OR([{ + ALT: function ALT() { + $.CONSUME(Question); + result.type = "ZERO_OR_ONE"; + } + }, { + ALT: function ALT() { + $.CONSUME(Star); + result.type = "ZERO_OR_MORE"; + } + }, { + ALT: function ALT() { + $.CONSUME(Plus); + result.type = "ONE_OR_MORE"; + } + }, { + ALT: function ALT() { + var _$$SUBRULE2 = $.SUBRULE($.rangeModifier), + min = _$$SUBRULE2.min, + max = _$$SUBRULE2.max; + + $.ACTION(function () { + result.type = "RANGE"; + result.min = min; + result.max = max; + }); + } + }]); + $.OPTION(function () { + $.CONSUME1(Question); + $.ACTION(function () { + result.greedy = false; + }); + }); + return result; + }); + $.RULE("rangeModifier", function () { + var range = { + min: null, + max: null + }; + $.CONSUME(LCurly); // {x} + + $.OPTION(function () { + $.OR([{ + ALT: function ALT() { + range.min = $.CONSUME(Zero).image; + } + }, { + ALT: function ALT() { + range.min = $.CONSUME(PositiveInt).image; + } + }]); + }); // {x} + + range.max = range.min; + $.OPTION1(function () { + $.CONSUME(Comma); // {x,} + + range.max = null; // {,x} {x,}, {x,y} + + $.OPTION2(function () { + range.max = $.CONSUME1(PositiveInt).image; + }); + }); + $.ACTION(function () { + if (range.min) { + range.min = parseInt(range.min); + } + + if (range.max) { + range.max = parseInt(range.max); + } + + var min = range.min, + max = range.max; + + if (min && max && min > max) { + throw new Error("Range min(".concat(min, ") must be greater than max(").concat(max, ").")); + } + + if (min === null && max === null) { + throw new Error("Range min or max must be defined."); + } + }); + $.CONSUME(RCurly); + return range; + }); + $.RULE("group", function () { + var prog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var groups = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + var vars = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; + var modifiers = { + capture: true, + name: null, + lookahead: false, + negative: false + }; + $.CONSUME(LParenthesis); + $.OPTION(function () { + modifiers = $.SUBRULE($.groupModifier); + }); + var oProg = null; + + if (modifiers.lookahead) { + // part 1, see finish at end + modifiers.capture = false; + oProg = prog; + prog = []; + } + + var gId = groups.length; + + if (modifiers.capture) { + groups.push(modifiers); + prog.push({ + code: OGROUP, + id: gId, + name: modifiers.name + }); + } + + var split = { + code: SPLIT, + locs: [] + }; + prog.push(split); + var jmps = []; + $.AT_LEAST_ONE_SEP({ + SEP: Pipe, + DEF: function DEF() { + split.locs.push(prog.length); + $.SUBRULE($.valueStatement, { + ARGS: [prog, groups, vars] + }); + var jmp = { + code: JMP, + loc: null + }; + jmps.push(jmp); + prog.push(jmp); + } + }); // make split noop when just one in group + + if (split.locs.length === 1) { + split.code = NOOP$1; + delete split.locs; + } // remove last jmp so it continues + + + prog.pop(); // set jmps to end + + for (var _i = 0, _jmps = jmps; _i < _jmps.length; _i++) { + var jmp = _jmps[_i]; + jmp.loc = prog.length; + } // close the group if necessary as the last step + + + if (modifiers.capture) { + prog.push({ + code: CGROUP, + id: gId, + name: modifiers.name + }); + } + + if (modifiers.lookahead) { + prog.push({ + code: MATCH + }); + oProg.push({ + code: modifiers.negative ? NEGATIVE_LOOKAHEAD : LOOKAHEAD, + prog: prog + }); + } + + $.CONSUME(RParenthesis); + }); + $.RULE("namedGroup", function () { + $.CONSUME(Question); + $.CONSUME(NamedGroupBegin); + var name = $.CONSUME(Word).image; + $.CONSUME(NamedGroupEnd); + return name; + }); + $.RULE("nonCapturingGroup", function () { + $.CONSUME(Question); + $.CONSUME(Colon); + }); + $.RULE("negativeLookaheadGroup", function () { + $.CONSUME(Question); + $.CONSUME(Exclamation); + }); + $.RULE("positiveLookaheadGroup", function () { + $.CONSUME(Question); + $.CONSUME(Equals); + }); + $.RULE("commentGroup", function () { + $.CONSUME(Question); + $.CONSUME(Pound); + }); + $.RULE("groupModifier", function () { + var result = { + capture: true, + name: null, + lookahead: false, + negative: false, + comment: false + }; + $.OR([{ + ALT: function ALT() { + $.SUBRULE($.nonCapturingGroup); + result.capture = false; + } + }, { + ALT: function ALT() { + result.name = $.SUBRULE($.namedGroup); + } + }, { + ALT: function ALT() { + $.SUBRULE($.negativeLookaheadGroup); + result.capture = false; + result.lookahead = true; + result.negative = true; + } + }, { + ALT: function ALT() { + $.SUBRULE($.positiveLookaheadGroup); + result.capture = false; + result.lookahead = true; + result.negative = false; + } + } + /* + { ALT: () => { + $.SUBRULE($.commentGroup); + result.capture = false; + result.comment = true; + }} + */ + ]); + return result; + }); + + _this.performSelfAnalysis(); + + return _this; + } + + return NLPMatchParser; + }(EmbeddedActionsParser); + + var termContainsTag = function termContainsTag(term, name) { + var _term$tags; + + return Object.entries((_term$tags = term === null || term === void 0 ? void 0 : term.tags) !== null && _term$tags !== void 0 ? _term$tags : {}).filter(function (_ref) { + var _ref2 = _slicedToArray(_ref, 2), + k = _ref2[0], + v = _ref2[1]; + + return v; + }).map(function (entry) { + return entry[0].toLowerCase(); + }).includes(name.toLowerCase()); + }; + /** + * Helper function, create a thread + * Copies saved and groups.saved so that each thread contains its own + * independent saved values. + * + * Note: Using the { saved, groups } allows passing a thread which will cause + * its saved to be cloned. + * + * @param {int} pc - position of instance code to execute + * @param {*[]} saved - matched objects that were saved + * @param {object} groups - capture groups key of group id + * @returns {object} thread + */ + + var thread = function thread(pc) { + var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref3$save = _ref3.save, + save = _ref3$save === void 0 ? true : _ref3$save, + _ref3$saved = _ref3.saved, + saved = _ref3$saved === void 0 ? [] : _ref3$saved, + _ref3$groups = _ref3.groups, + groups = _ref3$groups === void 0 ? {} : _ref3$groups, + _ref3$vars = _ref3.vars, + vars = _ref3$vars === void 0 ? {} : _ref3$vars; + + var ngroups = Object.values(groups).reduce(function (ng, g) { + ng[g.id] = _objectSpread2(_objectSpread2({}, g), {}, { + saved: _toConsumableArray(g.saved) + }); + return ng; + }, {}); + return { + pc: pc, + save: save, + saved: _toConsumableArray(saved), + // clone groups.saved + groups: ngroups, + vars: _objectSpread2({}, vars) + }; + }; + + var addthread = function addthread(prog, list, th) { + var _th$vars$inst$varId, _th$vars; + + var inst = prog[th.pc]; //console.log("addthread:", th.pc); + //console.log(" inst:", inst); + + switch (inst.code) { + case GLOBAL_SAVE: + th.save = inst.value; + addthread(prog, list, thread(th.pc + 1, th)); + break; + + case NOOP$1: + addthread(prog, list, thread(th.pc + 1, th)); + break; + + case JMP: + addthread(prog, list, thread(inst.loc, th)); + break; + + case SPLIT: + var _iterator = _createForOfIteratorHelper(inst.locs), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var loc = _step.value; + addthread(prog, list, thread(loc, th)); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + break; + + case OGROUP: + // again (see below comment in pikevm match), can modify thread + // because it ends here + th.groups[inst.id] = { + id: inst.id, + name: inst.name, + saved: [], + open: true + }; + addthread(prog, list, thread(th.pc + 1, th)); + break; + + case CGROUP: + th.groups[inst.id].open = false; + addthread(prog, list, thread(th.pc + 1, th)); + break; + + case INCV: + th.vars[inst.varId] = ((_th$vars$inst$varId = (_th$vars = th.vars) === null || _th$vars === void 0 ? void 0 : _th$vars[inst.varId]) !== null && _th$vars$inst$varId !== void 0 ? _th$vars$inst$varId : 0) + 1; + addthread(prog, list, thread(th.pc + 1, th)); + break; + + case JMP_LT: + if (th.vars[inst.varId] < inst.value) { + // jump! + addthread(prog, list, thread(inst.loc, th)); + } else { + // continue + addthread(prog, list, thread(th.pc + 1, th)); + } + + break; + + case SPLIT_LT: + if (th.vars[inst.varId] < inst.value) { + // split! + var _iterator2 = _createForOfIteratorHelper(inst.locs), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _loc = _step2.value; + addthread(prog, list, thread(_loc, th)); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + } else { + // continue + addthread(prog, list, thread(th.pc + 1, th)); + } + + break; + + default: + list.push(th); + break; + } + }; + /** + * Save a match to a thread. + * Handles saving to open groups too + * @param {object} th - the thread + * @param {*] sp - the matched value to add + * @return {object} the thread th + */ + + + var saveMatch = function saveMatch(th, sp) { + if (!th.save) { + return th; + } + + var buckets = [th.saved].concat(_toConsumableArray(Object.values(th.groups).filter(function (g) { + return g.open; + }).map(function (g) { + return g.saved; + }))); + + var _iterator3 = _createForOfIteratorHelper(buckets), + _step3; + + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var saved = _step3.value; + saved.push(sp); + } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); + } + + return th; + }; + /** + * Simulate pike's vm, see https://swtch.com/~rsc/regexp/regexp2.html + * @param {object[]} inst - instructions to execute + * @param {object[]} input - input word w/ terms + * @returns true or false for match and saved matches + */ + + + var pikevm = function pikevm(prog, input) { + var _sp$text, _sp$inst$value; + var clist = []; + var nlist = []; + var found = false; + var groups = {}; + var saved = []; // helps with match end and also matches that end at exactly the end so that + // the match function gets a chance to run. + + var END = Symbol("END"); + input = [].concat(_toConsumableArray(input), [END]); + addthread(prog, clist, thread(0)); // and so we begin... + + for (var i = 0; i < input.length; i++) { + if (clist.length === 0) { + break; + } + + var sp = input[i]; + + for (var j = 0; j < clist.length; j++) { + // can probably convert to clist.shift as optimization + var th = clist[j]; + var inst = prog[th.pc]; //console.log("exec:", inst); + //console.log(` stack(${i}):`, clist); + + var gotoNextWord = false; + + switch (inst.code) { + case MATCH_ANY: + // Note: can call save match like this without worrying about other + // threads because this thread ends here and another will be created + // in its place + if (sp !== END) { + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + + break; + + case MATCH_WORD: + if ((sp === null || sp === void 0 ? void 0 : (_sp$text = sp.text) === null || _sp$text === void 0 ? void 0 : _sp$text.toLowerCase()) === inst.value.toLowerCase()) { + // continue on next word + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + + break; + + case MATCH_TAG: + if (termContainsTag(sp, inst.value)) { + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + + break; + + case MATCH_METHOD: + // call method using null coalescing on term, if it returns true continue + if (sp === null || sp === void 0 ? void 0 : (_sp$inst$value = sp[inst.value]) === null || _sp$inst$value === void 0 ? void 0 : _sp$inst$value.call(sp)) { + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + + break; + + case MATCH_END: + if (sp === END) { + // continue + addthread(prog, clist, thread(th.pc + 1, th)); + } + + break; + + case LOOKAHEAD: + var mla = pikevm(inst.prog, input.slice(i)); + + if (mla.found) { + addthread(prog, clist, thread(th.pc + 1, th)); + } + + break; + + case NEGATIVE_LOOKAHEAD: + var mnla = pikevm(inst.prog, input.slice(i)); + + if (!mnla.found) { + // continue at current position + // NOTE: this would be in addthread but we require access to input + addthread(prog, clist, thread(th.pc + 1, th)); + } + + break; + + case MATCH: + saved = th.saved; + groups = th.groups; + found = true; // Go to the next word which causes all pending threads in the + // current list (stack) to be cleared so we don't go down those + // paths. This allows for greedy and non-greedy matches to work. + + gotoNextWord = true; + break; + + default: + throw new Error("Unsuppored Op code: ".concat(inst.code)); + } + + if (gotoNextWord) { + break; // continue next iteration + } + } + + clist = nlist; + nlist = []; + } + + if (found) { + return { + found: found, + saved: saved, + groups: groups + }; + } + + return { + found: found + }; + }; + + var NLPMatchLexer = new Lexer(allTokens); + var parserInstance = new NLPMatchParser(); + var NLPRegexParseError = /*#__PURE__*/function () { + function NLPRegexParseError(errors) { + _classCallCheck(this, NLPRegexParseError); + + this.errors = errors; + } + + _createClass(NLPRegexParseError, [{ + key: "toString", + value: function toString() { + return "NLP RegexP Parsing error: ".concat(this.message); + } + }, { + key: "message", + get: function get() { + var _this$errors$; + + return (_this$errors$ = this.errors[0]) === null || _this$errors$ === void 0 ? void 0 : _this$errors$.message; + } + }]); + + return NLPRegexParseError; + }(); + /** + * Custom NLPRegexP class for regexp compile / cache. + */ + + var NLPRegexP = /*#__PURE__*/function () { + /** + * @param {string} regex - regular expression like string for matching nlp + * terms. + */ + function NLPRegexP(regex) { + _classCallCheck(this, NLPRegexP); + + if (regex === null || regex === void 0 ? void 0 : regex.prog) { + // take another NLPRegexP + this.regex = regex.regex; + this.prog = _toConsumableArray(regex.prog); + return; + } + + var _NLPMatchLexer$tokeni = NLPMatchLexer.tokenize(regex), + tokens = _NLPMatchLexer$tokeni.tokens; + + parserInstance.input = tokens; + var parsed = null; + + try { + parsed = parserInstance.matchStatement(); + } catch (e) { + // catch thrown error + throw new NLPRegexParseError([e]); + } + + if (parserInstance.errors.length > 0) { + throw new NLPRegexParseError(parserInstance.errors); + } + + this.regex = regex; + this.prog = parsed.prog; + } + + _createClass(NLPRegexP, [{ + key: "exec", + value: function exec(docOrPhrase) { + var _docOrPhrase$isA; + + switch (docOrPhrase === null || docOrPhrase === void 0 ? void 0 : (_docOrPhrase$isA = docOrPhrase.isA) === null || _docOrPhrase$isA === void 0 ? void 0 : _docOrPhrase$isA.toLowerCase()) { + case "doc": + return this.execDoc(docOrPhrase); + + case "phrase": + return this.execPhrase(docOrPhrase); + + default: + throw new Error("Invalid type, must be Document or Phrase"); + } + } + }, { + key: "execDoc", + value: function execDoc(doc) { + var _this = this; + + return doc.buildFrom(doc.list.map(function (phrase) { + return _this.execPhrase(phrase); + }).filter(function (p) { + return p !== null; + })); + } + }, { + key: "execPhrase", + value: function execPhrase(phrase) { + var _saved$; + + var _pikevm = pikevm(this.prog, phrase.terms()), + found = _pikevm.found, + _pikevm$saved = _pikevm.saved, + saved = _pikevm$saved === void 0 ? [] : _pikevm$saved, + _pikevm$groups = _pikevm.groups, + groups = _pikevm$groups === void 0 ? {} : _pikevm$groups; + + var namedGroups = Object.values(groups).reduce(function (arr, g) { + var _g$name, _g$saved$0$id, _g$saved$; + + return _objectSpread2(_objectSpread2({}, arr), {}, _defineProperty({}, parseInt(g.id), { + group: (_g$name = g === null || g === void 0 ? void 0 : g.name) !== null && _g$name !== void 0 ? _g$name : "".concat(g.id), + start: (_g$saved$0$id = (_g$saved$ = g.saved[0]) === null || _g$saved$ === void 0 ? void 0 : _g$saved$.id) !== null && _g$saved$0$id !== void 0 ? _g$saved$0$id : 0, + length: g.saved.length + })); + }, {}); + return found && (saved === null || saved === void 0 ? void 0 : (_saved$ = saved[0]) === null || _saved$ === void 0 ? void 0 : _saved$.id) ? phrase.buildFrom(saved[0].id, saved.length, namedGroups) : null; + } + }]); + + return NLPRegexP; + }(); + + var Match2Plugin = function Match2Plugin(Doc, world, nlp, Phrase) { + var compileRegex = function compileRegex(regex) { + return new NLPRegexP(regex); + }; + + nlp.compileRegex = compileRegex; + Doc.prototype.compileRegex = compileRegex; + + var match2 = function match2(regex) { + // function, non arrow, need bind for this which is doc/phrase + regex = new NLPRegexP(regex); // coerce the value + + return regex.exec(this); + }; + + Doc.prototype.match2 = match2; + Phrase.prototype.match2 = match2; + }; + + exports.Match2Plugin = Match2Plugin; + exports.NLPMatchParser = NLPMatchParser; + exports.NLPRegexP = NLPRegexP; + exports.NLPRegexParseError = NLPRegexParseError; + exports.default = Match2Plugin; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); +//# sourceMappingURL=compromise-match2.js.map diff --git a/plugins/match2/dist/compromise-match2.js.map b/plugins/match2/dist/compromise-match2.js.map new file mode 100644 index 000000000..42ee46b65 --- /dev/null +++ b/plugins/match2/dist/compromise-match2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"compromise-match2.js","sources":["../node_modules/chevrotain/lib_esm/src/utils/utils.js","../node_modules/regexp-to-ast/lib/regexp-to-ast.js","../node_modules/chevrotain/lib_esm/src/scan/reg_exp_parser.js","../node_modules/chevrotain/lib_esm/src/scan/reg_exp.js","../node_modules/chevrotain/lib_esm/src/scan/lexer.js","../node_modules/chevrotain/lib_esm/src/scan/tokens.js","../node_modules/chevrotain/lib_esm/src/scan/lexer_errors_public.js","../node_modules/chevrotain/lib_esm/src/scan/lexer_public.js","../node_modules/chevrotain/lib_esm/src/scan/tokens_public.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/gast/gast_public.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/rest.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/gast/gast_visitor_public.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/gast/gast.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/first.js","../node_modules/chevrotain/lib_esm/src/parse/constants.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/follow.js","../node_modules/chevrotain/lib_esm/src/parse/errors_public.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/resolver.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/interpreter.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/lookahead.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/checks.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/gast/gast_resolver_public.js","../node_modules/chevrotain/lib_esm/src/parse/exceptions_public.js","../node_modules/chevrotain/lib_esm/src/parse/parser/traits/recoverable.js","../node_modules/chevrotain/lib_esm/src/parse/grammar/keys.js","../node_modules/chevrotain/lib_esm/src/parse/parser/traits/looksahead.js","../node_modules/chevrotain/lib_esm/src/parse/cst/cst.js","../node_modules/chevrotain/lib_esm/src/lang/lang_extensions.js","../node_modules/chevrotain/lib_esm/src/parse/cst/cst_visitor.js","../node_modules/chevrotain/lib_esm/src/parse/parser/traits/tree_builder.js","../node_modules/chevrotain/lib_esm/src/parse/parser/traits/lexer_adapter.js","../node_modules/chevrotain/lib_esm/src/parse/parser/traits/recognizer_api.js","../node_modules/chevrotain/lib_esm/src/parse/parser/traits/recognizer_engine.js","../node_modules/chevrotain/lib_esm/src/parse/parser/traits/error_handler.js","../node_modules/chevrotain/lib_esm/src/parse/parser/traits/context_assist.js","../node_modules/chevrotain/lib_esm/src/parse/parser/traits/gast_recorder.js","../node_modules/chevrotain/lib_esm/src/parse/parser/traits/perf_tracer.js","../node_modules/chevrotain/lib_esm/src/parse/parser/parser.js","../src/constants.js","../src/parser.js","../src/pikevm.js","../src/regex.js","../src/index.js"],"sourcesContent":["/*\n Utils using lodash style API. (not necessarily 100% compliant) for functional and other utils.\n These utils should replace usage of lodash in the production code base. not because they are any better...\n but for the purpose of being a dependency free library.\n\n The hotspots in the code are already written in imperative style for performance reasons.\n so writing several dozen utils which may be slower than the original lodash, does not matter as much\n considering they will not be invoked in hotspots...\n */\nexport function isEmpty(arr) {\n return arr && arr.length === 0;\n}\nexport function keys(obj) {\n if (obj === undefined || obj === null) {\n return [];\n }\n return Object.keys(obj);\n}\nexport function values(obj) {\n var vals = [];\n var keys = Object.keys(obj);\n for (var i = 0; i < keys.length; i++) {\n vals.push(obj[keys[i]]);\n }\n return vals;\n}\nexport function mapValues(obj, callback) {\n var result = [];\n var objKeys = keys(obj);\n for (var idx = 0; idx < objKeys.length; idx++) {\n var currKey = objKeys[idx];\n result.push(callback.call(null, obj[currKey], currKey));\n }\n return result;\n}\nexport function map(arr, callback) {\n var result = [];\n for (var idx = 0; idx < arr.length; idx++) {\n result.push(callback.call(null, arr[idx], idx));\n }\n return result;\n}\nexport function flatten(arr) {\n var result = [];\n for (var idx = 0; idx < arr.length; idx++) {\n var currItem = arr[idx];\n if (Array.isArray(currItem)) {\n result = result.concat(flatten(currItem));\n }\n else {\n result.push(currItem);\n }\n }\n return result;\n}\nexport function first(arr) {\n return isEmpty(arr) ? undefined : arr[0];\n}\nexport function last(arr) {\n var len = arr && arr.length;\n return len ? arr[len - 1] : undefined;\n}\nexport function forEach(collection, iteratorCallback) {\n /* istanbul ignore else */\n if (Array.isArray(collection)) {\n for (var i = 0; i < collection.length; i++) {\n iteratorCallback.call(null, collection[i], i);\n }\n }\n else if (isObject(collection)) {\n var colKeys = keys(collection);\n for (var i = 0; i < colKeys.length; i++) {\n var key = colKeys[i];\n var value = collection[key];\n iteratorCallback.call(null, value, key);\n }\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n}\nexport function isString(item) {\n return typeof item === \"string\";\n}\nexport function isUndefined(item) {\n return item === undefined;\n}\nexport function isFunction(item) {\n return item instanceof Function;\n}\nexport function drop(arr, howMuch) {\n if (howMuch === void 0) { howMuch = 1; }\n return arr.slice(howMuch, arr.length);\n}\nexport function dropRight(arr, howMuch) {\n if (howMuch === void 0) { howMuch = 1; }\n return arr.slice(0, arr.length - howMuch);\n}\nexport function filter(arr, predicate) {\n var result = [];\n if (Array.isArray(arr)) {\n for (var i = 0; i < arr.length; i++) {\n var item = arr[i];\n if (predicate.call(null, item)) {\n result.push(item);\n }\n }\n }\n return result;\n}\nexport function reject(arr, predicate) {\n return filter(arr, function (item) { return !predicate(item); });\n}\nexport function pick(obj, predicate) {\n var keys = Object.keys(obj);\n var result = {};\n for (var i = 0; i < keys.length; i++) {\n var currKey = keys[i];\n var currItem = obj[currKey];\n if (predicate(currItem)) {\n result[currKey] = currItem;\n }\n }\n return result;\n}\nexport function has(obj, prop) {\n if (isObject(obj)) {\n return obj.hasOwnProperty(prop);\n }\n return false;\n}\nexport function contains(arr, item) {\n return find(arr, function (currItem) { return currItem === item; }) !== undefined ? true : false;\n}\n/**\n * shallow clone\n */\nexport function cloneArr(arr) {\n var newArr = [];\n for (var i = 0; i < arr.length; i++) {\n newArr.push(arr[i]);\n }\n return newArr;\n}\n/**\n * shallow clone\n */\nexport function cloneObj(obj) {\n var clonedObj = {};\n for (var key in obj) {\n /* istanbul ignore else */\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clonedObj[key] = obj[key];\n }\n }\n return clonedObj;\n}\nexport function find(arr, predicate) {\n for (var i = 0; i < arr.length; i++) {\n var item = arr[i];\n if (predicate.call(null, item)) {\n return item;\n }\n }\n return undefined;\n}\nexport function findAll(arr, predicate) {\n var found = [];\n for (var i = 0; i < arr.length; i++) {\n var item = arr[i];\n if (predicate.call(null, item)) {\n found.push(item);\n }\n }\n return found;\n}\nexport function reduce(arrOrObj, iterator, initial) {\n var isArr = Array.isArray(arrOrObj);\n var vals = isArr ? arrOrObj : values(arrOrObj);\n var objKeys = isArr ? [] : keys(arrOrObj);\n var accumulator = initial;\n for (var i = 0; i < vals.length; i++) {\n accumulator = iterator.call(null, accumulator, vals[i], isArr ? i : objKeys[i]);\n }\n return accumulator;\n}\nexport function compact(arr) {\n return reject(arr, function (item) { return item === null || item === undefined; });\n}\nexport function uniq(arr, identity) {\n if (identity === void 0) { identity = function (item) { return item; }; }\n var identities = [];\n return reduce(arr, function (result, currItem) {\n var currIdentity = identity(currItem);\n if (contains(identities, currIdentity)) {\n return result;\n }\n else {\n identities.push(currIdentity);\n return result.concat(currItem);\n }\n }, []);\n}\nexport function partial(func) {\n var restArgs = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n restArgs[_i - 1] = arguments[_i];\n }\n var firstArg = [null];\n var allArgs = firstArg.concat(restArgs);\n return Function.bind.apply(func, allArgs);\n}\nexport function isArray(obj) {\n return Array.isArray(obj);\n}\nexport function isRegExp(obj) {\n return obj instanceof RegExp;\n}\nexport function isObject(obj) {\n return obj instanceof Object;\n}\nexport function every(arr, predicate) {\n for (var i = 0; i < arr.length; i++) {\n if (!predicate(arr[i], i)) {\n return false;\n }\n }\n return true;\n}\nexport function difference(arr, values) {\n return reject(arr, function (item) { return contains(values, item); });\n}\nexport function some(arr, predicate) {\n for (var i = 0; i < arr.length; i++) {\n if (predicate(arr[i])) {\n return true;\n }\n }\n return false;\n}\nexport function indexOf(arr, value) {\n for (var i = 0; i < arr.length; i++) {\n if (arr[i] === value) {\n return i;\n }\n }\n return -1;\n}\nexport function sortBy(arr, orderFunc) {\n var result = cloneArr(arr);\n result.sort(function (a, b) { return orderFunc(a) - orderFunc(b); });\n return result;\n}\nexport function zipObject(keys, values) {\n if (keys.length !== values.length) {\n throw Error(\"can't zipObject with different number of keys and values!\");\n }\n var result = {};\n for (var i = 0; i < keys.length; i++) {\n result[keys[i]] = values[i];\n }\n return result;\n}\n/**\n * mutates! (and returns) target\n */\nexport function assign(target) {\n var sources = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n sources[_i - 1] = arguments[_i];\n }\n for (var i = 0; i < sources.length; i++) {\n var curSource = sources[i];\n var currSourceKeys = keys(curSource);\n for (var j = 0; j < currSourceKeys.length; j++) {\n var currKey = currSourceKeys[j];\n target[currKey] = curSource[currKey];\n }\n }\n return target;\n}\n/**\n * mutates! (and returns) target\n */\nexport function assignNoOverwrite(target) {\n var sources = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n sources[_i - 1] = arguments[_i];\n }\n for (var i = 0; i < sources.length; i++) {\n var curSource = sources[i];\n var currSourceKeys = keys(curSource);\n for (var j = 0; j < currSourceKeys.length; j++) {\n var currKey = currSourceKeys[j];\n if (!has(target, currKey)) {\n target[currKey] = curSource[currKey];\n }\n }\n }\n return target;\n}\nexport function defaults() {\n var sources = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n sources[_i] = arguments[_i];\n }\n return assignNoOverwrite.apply(null, [{}].concat(sources));\n}\nexport function groupBy(arr, groupKeyFunc) {\n var result = {};\n forEach(arr, function (item) {\n var currGroupKey = groupKeyFunc(item);\n var currGroupArr = result[currGroupKey];\n if (currGroupArr) {\n currGroupArr.push(item);\n }\n else {\n result[currGroupKey] = [item];\n }\n });\n return result;\n}\n/**\n * Merge obj2 into obj1.\n * Will overwrite existing properties with the same name\n */\nexport function merge(obj1, obj2) {\n var result = cloneObj(obj1);\n var keys2 = keys(obj2);\n for (var i = 0; i < keys2.length; i++) {\n var key = keys2[i];\n var value = obj2[key];\n result[key] = value;\n }\n return result;\n}\nexport function NOOP() { }\nexport function IDENTITY(item) {\n return item;\n}\n/**\n * Will return a new packed array with same values.\n */\nexport function packArray(holeyArr) {\n var result = [];\n for (var i = 0; i < holeyArr.length; i++) {\n var orgValue = holeyArr[i];\n result.push(orgValue !== undefined ? orgValue : undefined);\n }\n return result;\n}\nexport function PRINT_ERROR(msg) {\n /* istanbul ignore else - can't override global.console in node.js */\n if (console && console.error) {\n console.error(\"Error: \" + msg);\n }\n}\nexport function PRINT_WARNING(msg) {\n /* istanbul ignore else - can't override global.console in node.js*/\n if (console && console.warn) {\n // TODO: modify docs accordingly\n console.warn(\"Warning: \" + msg);\n }\n}\nexport function isES2015MapSupported() {\n return typeof Map === \"function\";\n}\nexport function applyMixins(derivedCtor, baseCtors) {\n baseCtors.forEach(function (baseCtor) {\n var baseProto = baseCtor.prototype;\n Object.getOwnPropertyNames(baseProto).forEach(function (propName) {\n if (propName === \"constructor\") {\n return;\n }\n var basePropDescriptor = Object.getOwnPropertyDescriptor(baseProto, propName);\n // Handle Accessors\n if (basePropDescriptor &&\n (basePropDescriptor.get || basePropDescriptor.set)) {\n Object.defineProperty(derivedCtor.prototype, propName, basePropDescriptor);\n }\n else {\n derivedCtor.prototype[propName] = baseCtor.prototype[propName];\n }\n });\n });\n}\n// base on: https://github.com/petkaantonov/bluebird/blob/b97c0d2d487e8c5076e8bd897e0dcd4622d31846/src/util.js#L201-L216\nexport function toFastProperties(toBecomeFast) {\n function FakeConstructor() { }\n // If our object is used as a constructor it would receive\n FakeConstructor.prototype = toBecomeFast;\n var fakeInstance = new FakeConstructor();\n function fakeAccess() {\n return typeof fakeInstance.bar;\n }\n // help V8 understand this is a \"real\" prototype by actually using\n // the fake instance.\n fakeAccess();\n fakeAccess();\n return toBecomeFast;\n // Eval prevents optimization of this method (even though this is dead code)\n /* istanbul ignore next */\n // tslint:disable-next-line\n eval(toBecomeFast);\n}\nexport function peek(arr) {\n return arr[arr.length - 1];\n}\n/* istanbul ignore next - for performance tracing*/\nexport function timer(func) {\n var start = new Date().getTime();\n var val = func();\n var end = new Date().getTime();\n var total = end - start;\n return { time: total, value: val };\n}\n//# sourceMappingURL=utils.js.map",";(function(root, factory) {\n // istanbul ignore next\n if (typeof define === \"function\" && define.amd) {\n // istanbul ignore next\n define([], factory)\n } else if (typeof module === \"object\" && module.exports) {\n module.exports = factory()\n } else {\n // istanbul ignore next\n root.regexpToAst = factory()\n }\n})(\n typeof self !== \"undefined\"\n ? // istanbul ignore next\n self\n : this,\n function() {\n // references\n // https://hackernoon.com/the-madness-of-parsing-real-world-javascript-regexps-d9ee336df983\n // https://www.ecma-international.org/ecma-262/8.0/index.html#prod-Pattern\n function RegExpParser() {}\n\n RegExpParser.prototype.saveState = function() {\n return {\n idx: this.idx,\n input: this.input,\n groupIdx: this.groupIdx\n }\n }\n\n RegExpParser.prototype.restoreState = function(newState) {\n this.idx = newState.idx\n this.input = newState.input\n this.groupIdx = newState.groupIdx\n }\n\n RegExpParser.prototype.pattern = function(input) {\n // parser state\n this.idx = 0\n this.input = input\n this.groupIdx = 0\n\n this.consumeChar(\"/\")\n var value = this.disjunction()\n this.consumeChar(\"/\")\n\n var flags = {\n type: \"Flags\",\n loc: { begin: this.idx, end: input.length },\n global: false,\n ignoreCase: false,\n multiLine: false,\n unicode: false,\n sticky: false\n }\n\n while (this.isRegExpFlag()) {\n switch (this.popChar()) {\n case \"g\":\n addFlag(flags, \"global\")\n break\n case \"i\":\n addFlag(flags, \"ignoreCase\")\n break\n case \"m\":\n addFlag(flags, \"multiLine\")\n break\n case \"u\":\n addFlag(flags, \"unicode\")\n break\n case \"y\":\n addFlag(flags, \"sticky\")\n break\n }\n }\n\n if (this.idx !== this.input.length) {\n throw Error(\n \"Redundant input: \" + this.input.substring(this.idx)\n )\n }\n return {\n type: \"Pattern\",\n flags: flags,\n value: value,\n loc: this.loc(0)\n }\n }\n\n RegExpParser.prototype.disjunction = function() {\n var alts = []\n var begin = this.idx\n\n alts.push(this.alternative())\n\n while (this.peekChar() === \"|\") {\n this.consumeChar(\"|\")\n alts.push(this.alternative())\n }\n\n return { type: \"Disjunction\", value: alts, loc: this.loc(begin) }\n }\n\n RegExpParser.prototype.alternative = function() {\n var terms = []\n var begin = this.idx\n\n while (this.isTerm()) {\n terms.push(this.term())\n }\n\n return { type: \"Alternative\", value: terms, loc: this.loc(begin) }\n }\n\n RegExpParser.prototype.term = function() {\n if (this.isAssertion()) {\n return this.assertion()\n } else {\n return this.atom()\n }\n }\n\n RegExpParser.prototype.assertion = function() {\n var begin = this.idx\n switch (this.popChar()) {\n case \"^\":\n return {\n type: \"StartAnchor\",\n loc: this.loc(begin)\n }\n case \"$\":\n return { type: \"EndAnchor\", loc: this.loc(begin) }\n // '\\b' or '\\B'\n case \"\\\\\":\n switch (this.popChar()) {\n case \"b\":\n return {\n type: \"WordBoundary\",\n loc: this.loc(begin)\n }\n case \"B\":\n return {\n type: \"NonWordBoundary\",\n loc: this.loc(begin)\n }\n }\n // istanbul ignore next\n throw Error(\"Invalid Assertion Escape\")\n // '(?=' or '(?!'\n case \"(\":\n this.consumeChar(\"?\")\n\n var type\n switch (this.popChar()) {\n case \"=\":\n type = \"Lookahead\"\n break\n case \"!\":\n type = \"NegativeLookahead\"\n break\n }\n ASSERT_EXISTS(type)\n\n var disjunction = this.disjunction()\n\n this.consumeChar(\")\")\n\n return {\n type: type,\n value: disjunction,\n loc: this.loc(begin)\n }\n }\n // istanbul ignore next\n ASSERT_NEVER_REACH_HERE()\n }\n\n RegExpParser.prototype.quantifier = function(isBacktracking) {\n var range\n var begin = this.idx\n switch (this.popChar()) {\n case \"*\":\n range = {\n atLeast: 0,\n atMost: Infinity\n }\n break\n case \"+\":\n range = {\n atLeast: 1,\n atMost: Infinity\n }\n break\n case \"?\":\n range = {\n atLeast: 0,\n atMost: 1\n }\n break\n case \"{\":\n var atLeast = this.integerIncludingZero()\n switch (this.popChar()) {\n case \"}\":\n range = {\n atLeast: atLeast,\n atMost: atLeast\n }\n break\n case \",\":\n var atMost\n if (this.isDigit()) {\n atMost = this.integerIncludingZero()\n range = {\n atLeast: atLeast,\n atMost: atMost\n }\n } else {\n range = {\n atLeast: atLeast,\n atMost: Infinity\n }\n }\n this.consumeChar(\"}\")\n break\n }\n // throwing exceptions from \"ASSERT_EXISTS\" during backtracking\n // causes severe performance degradations\n if (isBacktracking === true && range === undefined) {\n return undefined\n }\n ASSERT_EXISTS(range)\n break\n }\n\n // throwing exceptions from \"ASSERT_EXISTS\" during backtracking\n // causes severe performance degradations\n if (isBacktracking === true && range === undefined) {\n return undefined\n }\n\n ASSERT_EXISTS(range)\n\n if (this.peekChar(0) === \"?\") {\n this.consumeChar(\"?\")\n range.greedy = false\n } else {\n range.greedy = true\n }\n\n range.type = \"Quantifier\"\n range.loc = this.loc(begin)\n return range\n }\n\n RegExpParser.prototype.atom = function() {\n var atom\n var begin = this.idx\n switch (this.peekChar()) {\n case \".\":\n atom = this.dotAll()\n break\n case \"\\\\\":\n atom = this.atomEscape()\n break\n case \"[\":\n atom = this.characterClass()\n break\n case \"(\":\n atom = this.group()\n break\n }\n\n if (atom === undefined && this.isPatternCharacter()) {\n atom = this.patternCharacter()\n }\n\n ASSERT_EXISTS(atom)\n\n atom.loc = this.loc(begin)\n\n if (this.isQuantifier()) {\n atom.quantifier = this.quantifier()\n }\n\n return atom\n }\n\n RegExpParser.prototype.dotAll = function() {\n this.consumeChar(\".\")\n return {\n type: \"Set\",\n complement: true,\n value: [cc(\"\\n\"), cc(\"\\r\"), cc(\"\\u2028\"), cc(\"\\u2029\")]\n }\n }\n\n RegExpParser.prototype.atomEscape = function() {\n this.consumeChar(\"\\\\\")\n\n switch (this.peekChar()) {\n case \"1\":\n case \"2\":\n case \"3\":\n case \"4\":\n case \"5\":\n case \"6\":\n case \"7\":\n case \"8\":\n case \"9\":\n return this.decimalEscapeAtom()\n case \"d\":\n case \"D\":\n case \"s\":\n case \"S\":\n case \"w\":\n case \"W\":\n return this.characterClassEscape()\n case \"f\":\n case \"n\":\n case \"r\":\n case \"t\":\n case \"v\":\n return this.controlEscapeAtom()\n case \"c\":\n return this.controlLetterEscapeAtom()\n case \"0\":\n return this.nulCharacterAtom()\n case \"x\":\n return this.hexEscapeSequenceAtom()\n case \"u\":\n return this.regExpUnicodeEscapeSequenceAtom()\n default:\n return this.identityEscapeAtom()\n }\n }\n\n RegExpParser.prototype.decimalEscapeAtom = function() {\n var value = this.positiveInteger()\n\n return { type: \"GroupBackReference\", value: value }\n }\n\n RegExpParser.prototype.characterClassEscape = function() {\n var set\n var complement = false\n switch (this.popChar()) {\n case \"d\":\n set = digitsCharCodes\n break\n case \"D\":\n set = digitsCharCodes\n complement = true\n break\n case \"s\":\n set = whitespaceCodes\n break\n case \"S\":\n set = whitespaceCodes\n complement = true\n break\n case \"w\":\n set = wordCharCodes\n break\n case \"W\":\n set = wordCharCodes\n complement = true\n break\n }\n\n ASSERT_EXISTS(set)\n\n return { type: \"Set\", value: set, complement: complement }\n }\n\n RegExpParser.prototype.controlEscapeAtom = function() {\n var escapeCode\n switch (this.popChar()) {\n case \"f\":\n escapeCode = cc(\"\\f\")\n break\n case \"n\":\n escapeCode = cc(\"\\n\")\n break\n case \"r\":\n escapeCode = cc(\"\\r\")\n break\n case \"t\":\n escapeCode = cc(\"\\t\")\n break\n case \"v\":\n escapeCode = cc(\"\\v\")\n break\n }\n ASSERT_EXISTS(escapeCode)\n\n return { type: \"Character\", value: escapeCode }\n }\n\n RegExpParser.prototype.controlLetterEscapeAtom = function() {\n this.consumeChar(\"c\")\n var letter = this.popChar()\n if (/[a-zA-Z]/.test(letter) === false) {\n throw Error(\"Invalid \")\n }\n\n var letterCode = letter.toUpperCase().charCodeAt(0) - 64\n return { type: \"Character\", value: letterCode }\n }\n\n RegExpParser.prototype.nulCharacterAtom = function() {\n // TODO implement '[lookahead ∉ DecimalDigit]'\n // TODO: for the deprecated octal escape sequence\n this.consumeChar(\"0\")\n return { type: \"Character\", value: cc(\"\\0\") }\n }\n\n RegExpParser.prototype.hexEscapeSequenceAtom = function() {\n this.consumeChar(\"x\")\n return this.parseHexDigits(2)\n }\n\n RegExpParser.prototype.regExpUnicodeEscapeSequenceAtom = function() {\n this.consumeChar(\"u\")\n return this.parseHexDigits(4)\n }\n\n RegExpParser.prototype.identityEscapeAtom = function() {\n // TODO: implement \"SourceCharacter but not UnicodeIDContinue\"\n // // http://unicode.org/reports/tr31/#Specific_Character_Adjustments\n var escapedChar = this.popChar()\n return { type: \"Character\", value: cc(escapedChar) }\n }\n\n RegExpParser.prototype.classPatternCharacterAtom = function() {\n switch (this.peekChar()) {\n // istanbul ignore next\n case \"\\n\":\n // istanbul ignore next\n case \"\\r\":\n // istanbul ignore next\n case \"\\u2028\":\n // istanbul ignore next\n case \"\\u2029\":\n // istanbul ignore next\n case \"\\\\\":\n // istanbul ignore next\n case \"]\":\n throw Error(\"TBD\")\n default:\n var nextChar = this.popChar()\n return { type: \"Character\", value: cc(nextChar) }\n }\n }\n\n RegExpParser.prototype.characterClass = function() {\n var set = []\n var complement = false\n this.consumeChar(\"[\")\n if (this.peekChar(0) === \"^\") {\n this.consumeChar(\"^\")\n complement = true\n }\n\n while (this.isClassAtom()) {\n var from = this.classAtom()\n var isFromSingleChar = from.type === \"Character\"\n if (isFromSingleChar && this.isRangeDash()) {\n this.consumeChar(\"-\")\n var to = this.classAtom()\n var isToSingleChar = to.type === \"Character\"\n\n // a range can only be used when both sides are single characters\n if (isToSingleChar) {\n if (to.value < from.value) {\n throw Error(\"Range out of order in character class\")\n }\n set.push({ from: from.value, to: to.value })\n } else {\n // literal dash\n insertToSet(from.value, set)\n set.push(cc(\"-\"))\n insertToSet(to.value, set)\n }\n } else {\n insertToSet(from.value, set)\n }\n }\n\n this.consumeChar(\"]\")\n\n return { type: \"Set\", complement: complement, value: set }\n }\n\n RegExpParser.prototype.classAtom = function() {\n switch (this.peekChar()) {\n // istanbul ignore next\n case \"]\":\n // istanbul ignore next\n case \"\\n\":\n // istanbul ignore next\n case \"\\r\":\n // istanbul ignore next\n case \"\\u2028\":\n // istanbul ignore next\n case \"\\u2029\":\n throw Error(\"TBD\")\n case \"\\\\\":\n return this.classEscape()\n default:\n return this.classPatternCharacterAtom()\n }\n }\n\n RegExpParser.prototype.classEscape = function() {\n this.consumeChar(\"\\\\\")\n switch (this.peekChar()) {\n // Matches a backspace.\n // (Not to be confused with \\b word boundary outside characterClass)\n case \"b\":\n this.consumeChar(\"b\")\n return { type: \"Character\", value: cc(\"\\u0008\") }\n case \"d\":\n case \"D\":\n case \"s\":\n case \"S\":\n case \"w\":\n case \"W\":\n return this.characterClassEscape()\n case \"f\":\n case \"n\":\n case \"r\":\n case \"t\":\n case \"v\":\n return this.controlEscapeAtom()\n case \"c\":\n return this.controlLetterEscapeAtom()\n case \"0\":\n return this.nulCharacterAtom()\n case \"x\":\n return this.hexEscapeSequenceAtom()\n case \"u\":\n return this.regExpUnicodeEscapeSequenceAtom()\n default:\n return this.identityEscapeAtom()\n }\n }\n\n RegExpParser.prototype.group = function() {\n var capturing = true\n this.consumeChar(\"(\")\n switch (this.peekChar(0)) {\n case \"?\":\n this.consumeChar(\"?\")\n this.consumeChar(\":\")\n capturing = false\n break\n default:\n this.groupIdx++\n break\n }\n var value = this.disjunction()\n this.consumeChar(\")\")\n\n var groupAst = {\n type: \"Group\",\n capturing: capturing,\n value: value\n }\n\n if (capturing) {\n groupAst.idx = this.groupIdx\n }\n\n return groupAst\n }\n\n RegExpParser.prototype.positiveInteger = function() {\n var number = this.popChar()\n\n // istanbul ignore next - can't ever get here due to previous lookahead checks\n // still implementing this error checking in case this ever changes.\n if (decimalPatternNoZero.test(number) === false) {\n throw Error(\"Expecting a positive integer\")\n }\n\n while (decimalPattern.test(this.peekChar(0))) {\n number += this.popChar()\n }\n\n return parseInt(number, 10)\n }\n\n RegExpParser.prototype.integerIncludingZero = function() {\n var number = this.popChar()\n if (decimalPattern.test(number) === false) {\n throw Error(\"Expecting an integer\")\n }\n\n while (decimalPattern.test(this.peekChar(0))) {\n number += this.popChar()\n }\n\n return parseInt(number, 10)\n }\n\n RegExpParser.prototype.patternCharacter = function() {\n var nextChar = this.popChar()\n switch (nextChar) {\n // istanbul ignore next\n case \"\\n\":\n // istanbul ignore next\n case \"\\r\":\n // istanbul ignore next\n case \"\\u2028\":\n // istanbul ignore next\n case \"\\u2029\":\n // istanbul ignore next\n case \"^\":\n // istanbul ignore next\n case \"$\":\n // istanbul ignore next\n case \"\\\\\":\n // istanbul ignore next\n case \".\":\n // istanbul ignore next\n case \"*\":\n // istanbul ignore next\n case \"+\":\n // istanbul ignore next\n case \"?\":\n // istanbul ignore next\n case \"(\":\n // istanbul ignore next\n case \")\":\n // istanbul ignore next\n case \"[\":\n // istanbul ignore next\n case \"|\":\n // istanbul ignore next\n throw Error(\"TBD\")\n default:\n return { type: \"Character\", value: cc(nextChar) }\n }\n }\n RegExpParser.prototype.isRegExpFlag = function() {\n switch (this.peekChar(0)) {\n case \"g\":\n case \"i\":\n case \"m\":\n case \"u\":\n case \"y\":\n return true\n default:\n return false\n }\n }\n\n RegExpParser.prototype.isRangeDash = function() {\n return this.peekChar() === \"-\" && this.isClassAtom(1)\n }\n\n RegExpParser.prototype.isDigit = function() {\n return decimalPattern.test(this.peekChar(0))\n }\n\n RegExpParser.prototype.isClassAtom = function(howMuch) {\n if (howMuch === undefined) {\n howMuch = 0\n }\n\n switch (this.peekChar(howMuch)) {\n case \"]\":\n case \"\\n\":\n case \"\\r\":\n case \"\\u2028\":\n case \"\\u2029\":\n return false\n default:\n return true\n }\n }\n\n RegExpParser.prototype.isTerm = function() {\n return this.isAtom() || this.isAssertion()\n }\n\n RegExpParser.prototype.isAtom = function() {\n if (this.isPatternCharacter()) {\n return true\n }\n\n switch (this.peekChar(0)) {\n case \".\":\n case \"\\\\\": // atomEscape\n case \"[\": // characterClass\n // TODO: isAtom must be called before isAssertion - disambiguate\n case \"(\": // group\n return true\n default:\n return false\n }\n }\n\n RegExpParser.prototype.isAssertion = function() {\n switch (this.peekChar(0)) {\n case \"^\":\n case \"$\":\n return true\n // '\\b' or '\\B'\n case \"\\\\\":\n switch (this.peekChar(1)) {\n case \"b\":\n case \"B\":\n return true\n default:\n return false\n }\n // '(?=' or '(?!'\n case \"(\":\n return (\n this.peekChar(1) === \"?\" &&\n (this.peekChar(2) === \"=\" || this.peekChar(2) === \"!\")\n )\n default:\n return false\n }\n }\n\n RegExpParser.prototype.isQuantifier = function() {\n var prevState = this.saveState()\n try {\n return this.quantifier(true) !== undefined\n } catch (e) {\n return false\n } finally {\n this.restoreState(prevState)\n }\n }\n\n RegExpParser.prototype.isPatternCharacter = function() {\n switch (this.peekChar()) {\n case \"^\":\n case \"$\":\n case \"\\\\\":\n case \".\":\n case \"*\":\n case \"+\":\n case \"?\":\n case \"(\":\n case \")\":\n case \"[\":\n case \"|\":\n case \"/\":\n case \"\\n\":\n case \"\\r\":\n case \"\\u2028\":\n case \"\\u2029\":\n return false\n default:\n return true\n }\n }\n\n RegExpParser.prototype.parseHexDigits = function(howMany) {\n var hexString = \"\"\n for (var i = 0; i < howMany; i++) {\n var hexChar = this.popChar()\n if (hexDigitPattern.test(hexChar) === false) {\n throw Error(\"Expecting a HexDecimal digits\")\n }\n hexString += hexChar\n }\n var charCode = parseInt(hexString, 16)\n return { type: \"Character\", value: charCode }\n }\n\n RegExpParser.prototype.peekChar = function(howMuch) {\n if (howMuch === undefined) {\n howMuch = 0\n }\n return this.input[this.idx + howMuch]\n }\n\n RegExpParser.prototype.popChar = function() {\n var nextChar = this.peekChar(0)\n this.consumeChar()\n return nextChar\n }\n\n RegExpParser.prototype.consumeChar = function(char) {\n if (char !== undefined && this.input[this.idx] !== char) {\n throw Error(\n \"Expected: '\" +\n char +\n \"' but found: '\" +\n this.input[this.idx] +\n \"' at offset: \" +\n this.idx\n )\n }\n\n if (this.idx >= this.input.length) {\n throw Error(\"Unexpected end of input\")\n }\n this.idx++\n }\n\n RegExpParser.prototype.loc = function(begin) {\n return { begin: begin, end: this.idx }\n }\n\n // consts and utilities\n var hexDigitPattern = /[0-9a-fA-F]/\n var decimalPattern = /[0-9]/\n var decimalPatternNoZero = /[1-9]/\n\n function cc(char) {\n return char.charCodeAt(0)\n }\n\n function insertToSet(item, set) {\n if (item.length !== undefined) {\n item.forEach(function(subItem) {\n set.push(subItem)\n })\n } else {\n set.push(item)\n }\n }\n\n function addFlag(flagObj, flagKey) {\n if (flagObj[flagKey] === true) {\n throw \"duplicate flag \" + flagKey\n }\n\n flagObj[flagKey] = true\n }\n\n function ASSERT_EXISTS(obj) {\n // istanbul ignore next\n if (obj === undefined) {\n throw Error(\"Internal Error - Should never get here!\")\n }\n }\n\n // istanbul ignore next\n function ASSERT_NEVER_REACH_HERE() {\n throw Error(\"Internal Error - Should never get here!\")\n }\n\n var i\n var digitsCharCodes = []\n for (i = cc(\"0\"); i <= cc(\"9\"); i++) {\n digitsCharCodes.push(i)\n }\n\n var wordCharCodes = [cc(\"_\")].concat(digitsCharCodes)\n for (i = cc(\"a\"); i <= cc(\"z\"); i++) {\n wordCharCodes.push(i)\n }\n\n for (i = cc(\"A\"); i <= cc(\"Z\"); i++) {\n wordCharCodes.push(i)\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#character-classes\n var whitespaceCodes = [\n cc(\" \"),\n cc(\"\\f\"),\n cc(\"\\n\"),\n cc(\"\\r\"),\n cc(\"\\t\"),\n cc(\"\\v\"),\n cc(\"\\t\"),\n cc(\"\\u00a0\"),\n cc(\"\\u1680\"),\n cc(\"\\u2000\"),\n cc(\"\\u2001\"),\n cc(\"\\u2002\"),\n cc(\"\\u2003\"),\n cc(\"\\u2004\"),\n cc(\"\\u2005\"),\n cc(\"\\u2006\"),\n cc(\"\\u2007\"),\n cc(\"\\u2008\"),\n cc(\"\\u2009\"),\n cc(\"\\u200a\"),\n cc(\"\\u2028\"),\n cc(\"\\u2029\"),\n cc(\"\\u202f\"),\n cc(\"\\u205f\"),\n cc(\"\\u3000\"),\n cc(\"\\ufeff\")\n ]\n\n function BaseRegExpVisitor() {}\n\n BaseRegExpVisitor.prototype.visitChildren = function(node) {\n for (var key in node) {\n var child = node[key]\n /* istanbul ignore else */\n if (node.hasOwnProperty(key)) {\n if (child.type !== undefined) {\n this.visit(child)\n } else if (Array.isArray(child)) {\n child.forEach(function(subChild) {\n this.visit(subChild)\n }, this)\n }\n }\n }\n }\n\n BaseRegExpVisitor.prototype.visit = function(node) {\n switch (node.type) {\n case \"Pattern\":\n this.visitPattern(node)\n break\n case \"Flags\":\n this.visitFlags(node)\n break\n case \"Disjunction\":\n this.visitDisjunction(node)\n break\n case \"Alternative\":\n this.visitAlternative(node)\n break\n case \"StartAnchor\":\n this.visitStartAnchor(node)\n break\n case \"EndAnchor\":\n this.visitEndAnchor(node)\n break\n case \"WordBoundary\":\n this.visitWordBoundary(node)\n break\n case \"NonWordBoundary\":\n this.visitNonWordBoundary(node)\n break\n case \"Lookahead\":\n this.visitLookahead(node)\n break\n case \"NegativeLookahead\":\n this.visitNegativeLookahead(node)\n break\n case \"Character\":\n this.visitCharacter(node)\n break\n case \"Set\":\n this.visitSet(node)\n break\n case \"Group\":\n this.visitGroup(node)\n break\n case \"GroupBackReference\":\n this.visitGroupBackReference(node)\n break\n case \"Quantifier\":\n this.visitQuantifier(node)\n break\n }\n\n this.visitChildren(node)\n }\n\n BaseRegExpVisitor.prototype.visitPattern = function(node) {}\n\n BaseRegExpVisitor.prototype.visitFlags = function(node) {}\n\n BaseRegExpVisitor.prototype.visitDisjunction = function(node) {}\n\n BaseRegExpVisitor.prototype.visitAlternative = function(node) {}\n\n // Assertion\n BaseRegExpVisitor.prototype.visitStartAnchor = function(node) {}\n\n BaseRegExpVisitor.prototype.visitEndAnchor = function(node) {}\n\n BaseRegExpVisitor.prototype.visitWordBoundary = function(node) {}\n\n BaseRegExpVisitor.prototype.visitNonWordBoundary = function(node) {}\n\n BaseRegExpVisitor.prototype.visitLookahead = function(node) {}\n\n BaseRegExpVisitor.prototype.visitNegativeLookahead = function(node) {}\n\n // atoms\n BaseRegExpVisitor.prototype.visitCharacter = function(node) {}\n\n BaseRegExpVisitor.prototype.visitSet = function(node) {}\n\n BaseRegExpVisitor.prototype.visitGroup = function(node) {}\n\n BaseRegExpVisitor.prototype.visitGroupBackReference = function(node) {}\n\n BaseRegExpVisitor.prototype.visitQuantifier = function(node) {}\n\n return {\n RegExpParser: RegExpParser,\n BaseRegExpVisitor: BaseRegExpVisitor,\n VERSION: \"0.5.0\"\n }\n }\n)\n","import { RegExpParser } from \"regexp-to-ast\";\nvar regExpAstCache = {};\nvar regExpParser = new RegExpParser();\nexport function getRegExpAst(regExp) {\n var regExpStr = regExp.toString();\n if (regExpAstCache.hasOwnProperty(regExpStr)) {\n return regExpAstCache[regExpStr];\n }\n else {\n var regExpAst = regExpParser.pattern(regExpStr);\n regExpAstCache[regExpStr] = regExpAst;\n return regExpAst;\n }\n}\nexport function clearRegExpParserCache() {\n regExpAstCache = {};\n}\n//# sourceMappingURL=reg_exp_parser.js.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { VERSION, BaseRegExpVisitor } from \"regexp-to-ast\";\nimport { forEach, contains, PRINT_ERROR, PRINT_WARNING, find, isArray, every, values } from \"../utils/utils\";\nimport { getRegExpAst } from \"./reg_exp_parser\";\nimport { charCodeToOptimizedIndex, minOptimizationVal } from \"./lexer\";\nvar complementErrorMessage = \"Complement Sets are not supported for first char optimization\";\nexport var failedOptimizationPrefixMsg = 'Unable to use \"first char\" lexer optimizations:\\n';\nexport function getOptimizedStartCodesIndices(regExp, ensureOptimizations) {\n if (ensureOptimizations === void 0) { ensureOptimizations = false; }\n try {\n var ast = getRegExpAst(regExp);\n var firstChars = firstCharOptimizedIndices(ast.value, {}, ast.flags.ignoreCase);\n return firstChars;\n }\n catch (e) {\n /* istanbul ignore next */\n // Testing this relies on the regexp-to-ast library having a bug... */\n // TODO: only the else branch needs to be ignored, try to fix with newer prettier / tsc\n if (e.message === complementErrorMessage) {\n if (ensureOptimizations) {\n PRINT_WARNING(\"\" + failedOptimizationPrefixMsg +\n (\"\\tUnable to optimize: < \" + regExp.toString() + \" >\\n\") +\n \"\\tComplement Sets cannot be automatically optimized.\\n\" +\n \"\\tThis will disable the lexer's first char optimizations.\\n\" +\n \"\\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.\");\n }\n }\n else {\n var msgSuffix = \"\";\n if (ensureOptimizations) {\n msgSuffix =\n \"\\n\\tThis will disable the lexer's first char optimizations.\\n\" +\n \"\\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.\";\n }\n PRINT_ERROR(failedOptimizationPrefixMsg + \"\\n\" +\n (\"\\tFailed parsing: < \" + regExp.toString() + \" >\\n\") +\n (\"\\tUsing the regexp-to-ast library version: \" + VERSION + \"\\n\") +\n \"\\tPlease open an issue at: https://github.com/bd82/regexp-to-ast/issues\" +\n msgSuffix);\n }\n }\n return [];\n}\nexport function firstCharOptimizedIndices(ast, result, ignoreCase) {\n switch (ast.type) {\n case \"Disjunction\":\n for (var i = 0; i < ast.value.length; i++) {\n firstCharOptimizedIndices(ast.value[i], result, ignoreCase);\n }\n break;\n case \"Alternative\":\n var terms = ast.value;\n for (var i = 0; i < terms.length; i++) {\n var term = terms[i];\n // skip terms that cannot effect the first char results\n switch (term.type) {\n case \"EndAnchor\":\n // A group back reference cannot affect potential starting char.\n // because if a back reference is the first production than automatically\n // the group being referenced has had to come BEFORE so its codes have already been added\n case \"GroupBackReference\":\n // assertions do not affect potential starting codes\n case \"Lookahead\":\n case \"NegativeLookahead\":\n case \"StartAnchor\":\n case \"WordBoundary\":\n case \"NonWordBoundary\":\n continue;\n }\n var atom = term;\n switch (atom.type) {\n case \"Character\":\n addOptimizedIdxToResult(atom.value, result, ignoreCase);\n break;\n case \"Set\":\n if (atom.complement === true) {\n throw Error(complementErrorMessage);\n }\n forEach(atom.value, function (code) {\n if (typeof code === \"number\") {\n addOptimizedIdxToResult(code, result, ignoreCase);\n }\n else {\n // range\n var range = code;\n // cannot optimize when ignoreCase is\n if (ignoreCase === true) {\n for (var rangeCode = range.from; rangeCode <= range.to; rangeCode++) {\n addOptimizedIdxToResult(rangeCode, result, ignoreCase);\n }\n }\n // Optimization (2 orders of magnitude less work for very large ranges)\n else {\n // handle unoptimized values\n for (var rangeCode = range.from; rangeCode <= range.to && rangeCode < minOptimizationVal; rangeCode++) {\n addOptimizedIdxToResult(rangeCode, result, ignoreCase);\n }\n // Less common charCode where we optimize for faster init time, by using larger \"buckets\"\n if (range.to >= minOptimizationVal) {\n var minUnOptVal = range.from >= minOptimizationVal\n ? range.from\n : minOptimizationVal;\n var maxUnOptVal = range.to;\n var minOptIdx = charCodeToOptimizedIndex(minUnOptVal);\n var maxOptIdx = charCodeToOptimizedIndex(maxUnOptVal);\n for (var currOptIdx = minOptIdx; currOptIdx <= maxOptIdx; currOptIdx++) {\n result[currOptIdx] = currOptIdx;\n }\n }\n }\n }\n });\n break;\n case \"Group\":\n firstCharOptimizedIndices(atom.value, result, ignoreCase);\n break;\n /* istanbul ignore next */\n default:\n throw Error(\"Non Exhaustive Match\");\n }\n // reached a mandatory production, no more **start** codes can be found on this alternative\n var isOptionalQuantifier = atom.quantifier !== undefined && atom.quantifier.atLeast === 0;\n if (\n // A group may be optional due to empty contents /(?:)/\n // or if everything inside it is optional /((a)?)/\n (atom.type === \"Group\" && isWholeOptional(atom) === false) ||\n // If this term is not a group it may only be optional if it has an optional quantifier\n (atom.type !== \"Group\" && isOptionalQuantifier === false)) {\n break;\n }\n }\n break;\n /* istanbul ignore next */\n default:\n throw Error(\"non exhaustive match!\");\n }\n // console.log(Object.keys(result).length)\n return values(result);\n}\nfunction addOptimizedIdxToResult(code, result, ignoreCase) {\n var optimizedCharIdx = charCodeToOptimizedIndex(code);\n result[optimizedCharIdx] = optimizedCharIdx;\n if (ignoreCase === true) {\n handleIgnoreCase(code, result);\n }\n}\nfunction handleIgnoreCase(code, result) {\n var char = String.fromCharCode(code);\n var upperChar = char.toUpperCase();\n /* istanbul ignore else */\n if (upperChar !== char) {\n var optimizedCharIdx = charCodeToOptimizedIndex(upperChar.charCodeAt(0));\n result[optimizedCharIdx] = optimizedCharIdx;\n }\n else {\n var lowerChar = char.toLowerCase();\n if (lowerChar !== char) {\n var optimizedCharIdx = charCodeToOptimizedIndex(lowerChar.charCodeAt(0));\n result[optimizedCharIdx] = optimizedCharIdx;\n }\n }\n}\nfunction findCode(setNode, targetCharCodes) {\n return find(setNode.value, function (codeOrRange) {\n if (typeof codeOrRange === \"number\") {\n return contains(targetCharCodes, codeOrRange);\n }\n else {\n // range\n var range_1 = codeOrRange;\n return (find(targetCharCodes, function (targetCode) { return range_1.from <= targetCode && targetCode <= range_1.to; }) !== undefined);\n }\n });\n}\nfunction isWholeOptional(ast) {\n if (ast.quantifier && ast.quantifier.atLeast === 0) {\n return true;\n }\n if (!ast.value) {\n return false;\n }\n return isArray(ast.value)\n ? every(ast.value, isWholeOptional)\n : isWholeOptional(ast.value);\n}\nvar CharCodeFinder = /** @class */ (function (_super) {\n __extends(CharCodeFinder, _super);\n function CharCodeFinder(targetCharCodes) {\n var _this = _super.call(this) || this;\n _this.targetCharCodes = targetCharCodes;\n _this.found = false;\n return _this;\n }\n CharCodeFinder.prototype.visitChildren = function (node) {\n // No need to keep looking...\n if (this.found === true) {\n return;\n }\n // switch lookaheads as they do not actually consume any characters thus\n // finding a charCode at lookahead context does not mean that regexp can actually contain it in a match.\n switch (node.type) {\n case \"Lookahead\":\n this.visitLookahead(node);\n return;\n case \"NegativeLookahead\":\n this.visitNegativeLookahead(node);\n return;\n }\n _super.prototype.visitChildren.call(this, node);\n };\n CharCodeFinder.prototype.visitCharacter = function (node) {\n if (contains(this.targetCharCodes, node.value)) {\n this.found = true;\n }\n };\n CharCodeFinder.prototype.visitSet = function (node) {\n if (node.complement) {\n if (findCode(node, this.targetCharCodes) === undefined) {\n this.found = true;\n }\n }\n else {\n if (findCode(node, this.targetCharCodes) !== undefined) {\n this.found = true;\n }\n }\n };\n return CharCodeFinder;\n}(BaseRegExpVisitor));\nexport function canMatchCharCode(charCodes, pattern) {\n if (pattern instanceof RegExp) {\n var ast = getRegExpAst(pattern);\n var charCodeFinder = new CharCodeFinder(charCodes);\n charCodeFinder.visit(ast);\n return charCodeFinder.found;\n }\n else {\n return (find(pattern, function (char) {\n return contains(charCodes, char.charCodeAt(0));\n }) !== undefined);\n }\n}\n//# sourceMappingURL=reg_exp.js.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { BaseRegExpVisitor } from \"regexp-to-ast\";\nimport { Lexer, LexerDefinitionErrorType } from \"./lexer_public\";\nimport { compact, contains, defaults, difference, filter, find, first, flatten, forEach, has, indexOf, isArray, isEmpty, isFunction, isRegExp, isString, isUndefined, keys, map, mapValues, packArray, PRINT_ERROR, reduce, reject } from \"../utils/utils\";\nimport { canMatchCharCode, failedOptimizationPrefixMsg, getOptimizedStartCodesIndices } from \"./reg_exp\";\nimport { getRegExpAst } from \"./reg_exp_parser\";\nvar PATTERN = \"PATTERN\";\nexport var DEFAULT_MODE = \"defaultMode\";\nexport var MODES = \"modes\";\nexport var SUPPORT_STICKY = typeof new RegExp(\"(?:)\").sticky === \"boolean\";\nexport function disableSticky() {\n SUPPORT_STICKY = false;\n}\nexport function enableSticky() {\n SUPPORT_STICKY = true;\n}\nexport function analyzeTokenTypes(tokenTypes, options) {\n options = defaults(options, {\n useSticky: SUPPORT_STICKY,\n debug: false,\n safeMode: false,\n positionTracking: \"full\",\n lineTerminatorCharacters: [\"\\r\", \"\\n\"],\n tracer: function (msg, action) { return action(); }\n });\n var tracer = options.tracer;\n tracer(\"initCharCodeToOptimizedIndexMap\", function () {\n initCharCodeToOptimizedIndexMap();\n });\n var onlyRelevantTypes;\n tracer(\"Reject Lexer.NA\", function () {\n onlyRelevantTypes = reject(tokenTypes, function (currType) {\n return currType[PATTERN] === Lexer.NA;\n });\n });\n var hasCustom = false;\n var allTransformedPatterns;\n tracer(\"Transform Patterns\", function () {\n hasCustom = false;\n allTransformedPatterns = map(onlyRelevantTypes, function (currType) {\n var currPattern = currType[PATTERN];\n /* istanbul ignore else */\n if (isRegExp(currPattern)) {\n var regExpSource = currPattern.source;\n if (regExpSource.length === 1 &&\n // only these regExp meta characters which can appear in a length one regExp\n regExpSource !== \"^\" &&\n regExpSource !== \"$\" &&\n regExpSource !== \".\" &&\n !currPattern.ignoreCase) {\n return regExpSource;\n }\n else if (regExpSource.length === 2 &&\n regExpSource[0] === \"\\\\\" &&\n // not a meta character\n !contains([\n \"d\",\n \"D\",\n \"s\",\n \"S\",\n \"t\",\n \"r\",\n \"n\",\n \"t\",\n \"0\",\n \"c\",\n \"b\",\n \"B\",\n \"f\",\n \"v\",\n \"w\",\n \"W\"\n ], regExpSource[1])) {\n // escaped meta Characters: /\\+/ /\\[/\n // or redundant escaping: /\\a/\n // without the escaping \"\\\"\n return regExpSource[1];\n }\n else {\n return options.useSticky\n ? addStickyFlag(currPattern)\n : addStartOfInput(currPattern);\n }\n }\n else if (isFunction(currPattern)) {\n hasCustom = true;\n // CustomPatternMatcherFunc - custom patterns do not require any transformations, only wrapping in a RegExp Like object\n return { exec: currPattern };\n }\n else if (has(currPattern, \"exec\")) {\n hasCustom = true;\n // ICustomPattern\n return currPattern;\n }\n else if (typeof currPattern === \"string\") {\n if (currPattern.length === 1) {\n return currPattern;\n }\n else {\n var escapedRegExpString = currPattern.replace(/[\\\\^$.*+?()[\\]{}|]/g, \"\\\\$&\");\n var wrappedRegExp = new RegExp(escapedRegExpString);\n return options.useSticky\n ? addStickyFlag(wrappedRegExp)\n : addStartOfInput(wrappedRegExp);\n }\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n });\n });\n var patternIdxToType;\n var patternIdxToGroup;\n var patternIdxToLongerAltIdx;\n var patternIdxToPushMode;\n var patternIdxToPopMode;\n tracer(\"misc mapping\", function () {\n patternIdxToType = map(onlyRelevantTypes, function (currType) { return currType.tokenTypeIdx; });\n patternIdxToGroup = map(onlyRelevantTypes, function (clazz) {\n var groupName = clazz.GROUP;\n /* istanbul ignore next */\n if (groupName === Lexer.SKIPPED) {\n return undefined;\n }\n else if (isString(groupName)) {\n return groupName;\n }\n else if (isUndefined(groupName)) {\n return false;\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n });\n patternIdxToLongerAltIdx = map(onlyRelevantTypes, function (clazz) {\n var longerAltType = clazz.LONGER_ALT;\n if (longerAltType) {\n var longerAltIdx = indexOf(onlyRelevantTypes, longerAltType);\n return longerAltIdx;\n }\n });\n patternIdxToPushMode = map(onlyRelevantTypes, function (clazz) { return clazz.PUSH_MODE; });\n patternIdxToPopMode = map(onlyRelevantTypes, function (clazz) {\n return has(clazz, \"POP_MODE\");\n });\n });\n var patternIdxToCanLineTerminator;\n tracer(\"Line Terminator Handling\", function () {\n var lineTerminatorCharCodes = getCharCodes(options.lineTerminatorCharacters);\n patternIdxToCanLineTerminator = map(onlyRelevantTypes, function (tokType) { return false; });\n if (options.positionTracking !== \"onlyOffset\") {\n patternIdxToCanLineTerminator = map(onlyRelevantTypes, function (tokType) {\n if (has(tokType, \"LINE_BREAKS\")) {\n return tokType.LINE_BREAKS;\n }\n else {\n if (checkLineBreaksIssues(tokType, lineTerminatorCharCodes) === false) {\n return canMatchCharCode(lineTerminatorCharCodes, tokType.PATTERN);\n }\n }\n });\n }\n });\n var patternIdxToIsCustom;\n var patternIdxToShort;\n var emptyGroups;\n var patternIdxToConfig;\n tracer(\"Misc Mapping #2\", function () {\n patternIdxToIsCustom = map(onlyRelevantTypes, isCustomPattern);\n patternIdxToShort = map(allTransformedPatterns, isShortPattern);\n emptyGroups = reduce(onlyRelevantTypes, function (acc, clazz) {\n var groupName = clazz.GROUP;\n if (isString(groupName) && !(groupName === Lexer.SKIPPED)) {\n acc[groupName] = [];\n }\n return acc;\n }, {});\n patternIdxToConfig = map(allTransformedPatterns, function (x, idx) {\n return {\n pattern: allTransformedPatterns[idx],\n longerAlt: patternIdxToLongerAltIdx[idx],\n canLineTerminator: patternIdxToCanLineTerminator[idx],\n isCustom: patternIdxToIsCustom[idx],\n short: patternIdxToShort[idx],\n group: patternIdxToGroup[idx],\n push: patternIdxToPushMode[idx],\n pop: patternIdxToPopMode[idx],\n tokenTypeIdx: patternIdxToType[idx],\n tokenType: onlyRelevantTypes[idx]\n };\n });\n });\n var canBeOptimized = true;\n var charCodeToPatternIdxToConfig = [];\n if (!options.safeMode) {\n tracer(\"First Char Optimization\", function () {\n charCodeToPatternIdxToConfig = reduce(onlyRelevantTypes, function (result, currTokType, idx) {\n if (typeof currTokType.PATTERN === \"string\") {\n var charCode = currTokType.PATTERN.charCodeAt(0);\n var optimizedIdx = charCodeToOptimizedIndex(charCode);\n addToMapOfArrays(result, optimizedIdx, patternIdxToConfig[idx]);\n }\n else if (isArray(currTokType.START_CHARS_HINT)) {\n var lastOptimizedIdx_1;\n forEach(currTokType.START_CHARS_HINT, function (charOrInt) {\n var charCode = typeof charOrInt === \"string\"\n ? charOrInt.charCodeAt(0)\n : charOrInt;\n var currOptimizedIdx = charCodeToOptimizedIndex(charCode);\n // Avoid adding the config multiple times\n /* istanbul ignore else */\n // - Difficult to check this scenario effects as it is only a performance\n // optimization that does not change correctness\n if (lastOptimizedIdx_1 !== currOptimizedIdx) {\n lastOptimizedIdx_1 = currOptimizedIdx;\n addToMapOfArrays(result, currOptimizedIdx, patternIdxToConfig[idx]);\n }\n });\n }\n else if (isRegExp(currTokType.PATTERN)) {\n if (currTokType.PATTERN.unicode) {\n canBeOptimized = false;\n if (options.ensureOptimizations) {\n PRINT_ERROR(\"\" + failedOptimizationPrefixMsg +\n (\"\\tUnable to analyze < \" + currTokType.PATTERN.toString() + \" > pattern.\\n\") +\n \"\\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\\n\" +\n \"\\tThis will disable the lexer's first char optimizations.\\n\" +\n \"\\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE\");\n }\n }\n else {\n var optimizedCodes = getOptimizedStartCodesIndices(currTokType.PATTERN, options.ensureOptimizations);\n /* istanbul ignore if */\n // start code will only be empty given an empty regExp or failure of regexp-to-ast library\n // the first should be a different validation and the second cannot be tested.\n if (isEmpty(optimizedCodes)) {\n // we cannot understand what codes may start possible matches\n // The optimization correctness requires knowing start codes for ALL patterns.\n // Not actually sure this is an error, no debug message\n canBeOptimized = false;\n }\n forEach(optimizedCodes, function (code) {\n addToMapOfArrays(result, code, patternIdxToConfig[idx]);\n });\n }\n }\n else {\n if (options.ensureOptimizations) {\n PRINT_ERROR(\"\" + failedOptimizationPrefixMsg +\n (\"\\tTokenType: <\" + currTokType.name + \"> is using a custom token pattern without providing parameter.\\n\") +\n \"\\tThis will disable the lexer's first char optimizations.\\n\" +\n \"\\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE\");\n }\n canBeOptimized = false;\n }\n return result;\n }, []);\n });\n }\n tracer(\"ArrayPacking\", function () {\n charCodeToPatternIdxToConfig = packArray(charCodeToPatternIdxToConfig);\n });\n return {\n emptyGroups: emptyGroups,\n patternIdxToConfig: patternIdxToConfig,\n charCodeToPatternIdxToConfig: charCodeToPatternIdxToConfig,\n hasCustom: hasCustom,\n canBeOptimized: canBeOptimized\n };\n}\nexport function validatePatterns(tokenTypes, validModesNames) {\n var errors = [];\n var missingResult = findMissingPatterns(tokenTypes);\n errors = errors.concat(missingResult.errors);\n var invalidResult = findInvalidPatterns(missingResult.valid);\n var validTokenTypes = invalidResult.valid;\n errors = errors.concat(invalidResult.errors);\n errors = errors.concat(validateRegExpPattern(validTokenTypes));\n errors = errors.concat(findInvalidGroupType(validTokenTypes));\n errors = errors.concat(findModesThatDoNotExist(validTokenTypes, validModesNames));\n errors = errors.concat(findUnreachablePatterns(validTokenTypes));\n return errors;\n}\nfunction validateRegExpPattern(tokenTypes) {\n var errors = [];\n var withRegExpPatterns = filter(tokenTypes, function (currTokType) {\n return isRegExp(currTokType[PATTERN]);\n });\n errors = errors.concat(findEndOfInputAnchor(withRegExpPatterns));\n errors = errors.concat(findStartOfInputAnchor(withRegExpPatterns));\n errors = errors.concat(findUnsupportedFlags(withRegExpPatterns));\n errors = errors.concat(findDuplicatePatterns(withRegExpPatterns));\n errors = errors.concat(findEmptyMatchRegExps(withRegExpPatterns));\n return errors;\n}\nexport function findMissingPatterns(tokenTypes) {\n var tokenTypesWithMissingPattern = filter(tokenTypes, function (currType) {\n return !has(currType, PATTERN);\n });\n var errors = map(tokenTypesWithMissingPattern, function (currType) {\n return {\n message: \"Token Type: ->\" +\n currType.name +\n \"<- missing static 'PATTERN' property\",\n type: LexerDefinitionErrorType.MISSING_PATTERN,\n tokenTypes: [currType]\n };\n });\n var valid = difference(tokenTypes, tokenTypesWithMissingPattern);\n return { errors: errors, valid: valid };\n}\nexport function findInvalidPatterns(tokenTypes) {\n var tokenTypesWithInvalidPattern = filter(tokenTypes, function (currType) {\n var pattern = currType[PATTERN];\n return (!isRegExp(pattern) &&\n !isFunction(pattern) &&\n !has(pattern, \"exec\") &&\n !isString(pattern));\n });\n var errors = map(tokenTypesWithInvalidPattern, function (currType) {\n return {\n message: \"Token Type: ->\" +\n currType.name +\n \"<- static 'PATTERN' can only be a RegExp, a\" +\n \" Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.\",\n type: LexerDefinitionErrorType.INVALID_PATTERN,\n tokenTypes: [currType]\n };\n });\n var valid = difference(tokenTypes, tokenTypesWithInvalidPattern);\n return { errors: errors, valid: valid };\n}\nvar end_of_input = /[^\\\\][\\$]/;\nexport function findEndOfInputAnchor(tokenTypes) {\n var EndAnchorFinder = /** @class */ (function (_super) {\n __extends(EndAnchorFinder, _super);\n function EndAnchorFinder() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.found = false;\n return _this;\n }\n EndAnchorFinder.prototype.visitEndAnchor = function (node) {\n this.found = true;\n };\n return EndAnchorFinder;\n }(BaseRegExpVisitor));\n var invalidRegex = filter(tokenTypes, function (currType) {\n var pattern = currType[PATTERN];\n try {\n var regexpAst = getRegExpAst(pattern);\n var endAnchorVisitor = new EndAnchorFinder();\n endAnchorVisitor.visit(regexpAst);\n return endAnchorVisitor.found;\n }\n catch (e) {\n // old behavior in case of runtime exceptions with regexp-to-ast.\n /* istanbul ignore next - cannot ensure an error in regexp-to-ast*/\n return end_of_input.test(pattern.source);\n }\n });\n var errors = map(invalidRegex, function (currType) {\n return {\n message: \"Unexpected RegExp Anchor Error:\\n\" +\n \"\\tToken Type: ->\" +\n currType.name +\n \"<- static 'PATTERN' cannot contain end of input anchor '$'\\n\" +\n \"\\tSee sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#ANCHORS\" +\n \"\\tfor details.\",\n type: LexerDefinitionErrorType.EOI_ANCHOR_FOUND,\n tokenTypes: [currType]\n };\n });\n return errors;\n}\nexport function findEmptyMatchRegExps(tokenTypes) {\n var matchesEmptyString = filter(tokenTypes, function (currType) {\n var pattern = currType[PATTERN];\n return pattern.test(\"\");\n });\n var errors = map(matchesEmptyString, function (currType) {\n return {\n message: \"Token Type: ->\" +\n currType.name +\n \"<- static 'PATTERN' must not match an empty string\",\n type: LexerDefinitionErrorType.EMPTY_MATCH_PATTERN,\n tokenTypes: [currType]\n };\n });\n return errors;\n}\nvar start_of_input = /[^\\\\[][\\^]|^\\^/;\nexport function findStartOfInputAnchor(tokenTypes) {\n var StartAnchorFinder = /** @class */ (function (_super) {\n __extends(StartAnchorFinder, _super);\n function StartAnchorFinder() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.found = false;\n return _this;\n }\n StartAnchorFinder.prototype.visitStartAnchor = function (node) {\n this.found = true;\n };\n return StartAnchorFinder;\n }(BaseRegExpVisitor));\n var invalidRegex = filter(tokenTypes, function (currType) {\n var pattern = currType[PATTERN];\n try {\n var regexpAst = getRegExpAst(pattern);\n var startAnchorVisitor = new StartAnchorFinder();\n startAnchorVisitor.visit(regexpAst);\n return startAnchorVisitor.found;\n }\n catch (e) {\n // old behavior in case of runtime exceptions with regexp-to-ast.\n /* istanbul ignore next - cannot ensure an error in regexp-to-ast*/\n return start_of_input.test(pattern.source);\n }\n });\n var errors = map(invalidRegex, function (currType) {\n return {\n message: \"Unexpected RegExp Anchor Error:\\n\" +\n \"\\tToken Type: ->\" +\n currType.name +\n \"<- static 'PATTERN' cannot contain start of input anchor '^'\\n\" +\n \"\\tSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#ANCHORS\" +\n \"\\tfor details.\",\n type: LexerDefinitionErrorType.SOI_ANCHOR_FOUND,\n tokenTypes: [currType]\n };\n });\n return errors;\n}\nexport function findUnsupportedFlags(tokenTypes) {\n var invalidFlags = filter(tokenTypes, function (currType) {\n var pattern = currType[PATTERN];\n return pattern instanceof RegExp && (pattern.multiline || pattern.global);\n });\n var errors = map(invalidFlags, function (currType) {\n return {\n message: \"Token Type: ->\" +\n currType.name +\n \"<- static 'PATTERN' may NOT contain global('g') or multiline('m')\",\n type: LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,\n tokenTypes: [currType]\n };\n });\n return errors;\n}\n// This can only test for identical duplicate RegExps, not semantically equivalent ones.\nexport function findDuplicatePatterns(tokenTypes) {\n var found = [];\n var identicalPatterns = map(tokenTypes, function (outerType) {\n return reduce(tokenTypes, function (result, innerType) {\n if (outerType.PATTERN.source === innerType.PATTERN.source &&\n !contains(found, innerType) &&\n innerType.PATTERN !== Lexer.NA) {\n // this avoids duplicates in the result, each Token Type may only appear in one \"set\"\n // in essence we are creating Equivalence classes on equality relation.\n found.push(innerType);\n result.push(innerType);\n return result;\n }\n return result;\n }, []);\n });\n identicalPatterns = compact(identicalPatterns);\n var duplicatePatterns = filter(identicalPatterns, function (currIdenticalSet) {\n return currIdenticalSet.length > 1;\n });\n var errors = map(duplicatePatterns, function (setOfIdentical) {\n var tokenTypeNames = map(setOfIdentical, function (currType) {\n return currType.name;\n });\n var dupPatternSrc = first(setOfIdentical).PATTERN;\n return {\n message: \"The same RegExp pattern ->\" + dupPatternSrc + \"<-\" +\n (\"has been used in all of the following Token Types: \" + tokenTypeNames.join(\", \") + \" <-\"),\n type: LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,\n tokenTypes: setOfIdentical\n };\n });\n return errors;\n}\nexport function findInvalidGroupType(tokenTypes) {\n var invalidTypes = filter(tokenTypes, function (clazz) {\n if (!has(clazz, \"GROUP\")) {\n return false;\n }\n var group = clazz.GROUP;\n return group !== Lexer.SKIPPED && group !== Lexer.NA && !isString(group);\n });\n var errors = map(invalidTypes, function (currType) {\n return {\n message: \"Token Type: ->\" +\n currType.name +\n \"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String\",\n type: LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,\n tokenTypes: [currType]\n };\n });\n return errors;\n}\nexport function findModesThatDoNotExist(tokenTypes, validModes) {\n var invalidModes = filter(tokenTypes, function (clazz) {\n return (clazz.PUSH_MODE !== undefined && !contains(validModes, clazz.PUSH_MODE));\n });\n var errors = map(invalidModes, function (tokType) {\n var msg = \"Token Type: ->\" + tokType.name + \"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->\" + tokType.PUSH_MODE + \"<-\" +\n \"which does not exist\";\n return {\n message: msg,\n type: LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST,\n tokenTypes: [tokType]\n };\n });\n return errors;\n}\nexport function findUnreachablePatterns(tokenTypes) {\n var errors = [];\n var canBeTested = reduce(tokenTypes, function (result, tokType, idx) {\n var pattern = tokType.PATTERN;\n if (pattern === Lexer.NA) {\n return result;\n }\n // a more comprehensive validation for all forms of regExps would require\n // deeper regExp analysis capabilities\n if (isString(pattern)) {\n result.push({ str: pattern, idx: idx, tokenType: tokType });\n }\n else if (isRegExp(pattern) && noMetaChar(pattern)) {\n result.push({ str: pattern.source, idx: idx, tokenType: tokType });\n }\n return result;\n }, []);\n forEach(tokenTypes, function (tokType, testIdx) {\n forEach(canBeTested, function (_a) {\n var str = _a.str, idx = _a.idx, tokenType = _a.tokenType;\n if (testIdx < idx && testTokenType(str, tokType.PATTERN)) {\n var msg = \"Token: ->\" + tokenType.name + \"<- can never be matched.\\n\" +\n (\"Because it appears AFTER the Token Type ->\" + tokType.name + \"<-\") +\n \"in the lexer's definition.\\n\" +\n \"See https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#UNREACHABLE\";\n errors.push({\n message: msg,\n type: LexerDefinitionErrorType.UNREACHABLE_PATTERN,\n tokenTypes: [tokType, tokenType]\n });\n }\n });\n });\n return errors;\n}\nfunction testTokenType(str, pattern) {\n /* istanbul ignore else */\n if (isRegExp(pattern)) {\n var regExpArray = pattern.exec(str);\n return regExpArray !== null && regExpArray.index === 0;\n }\n else if (isFunction(pattern)) {\n // maintain the API of custom patterns\n return pattern(str, 0, [], {});\n }\n else if (has(pattern, \"exec\")) {\n // maintain the API of custom patterns\n return pattern.exec(str, 0, [], {});\n }\n else if (typeof pattern === \"string\") {\n return pattern === str;\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n}\nfunction noMetaChar(regExp) {\n //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp\n var metaChars = [\n \".\",\n \"\\\\\",\n \"[\",\n \"]\",\n \"|\",\n \"^\",\n \"$\",\n \"(\",\n \")\",\n \"?\",\n \"*\",\n \"+\",\n \"{\"\n ];\n return (find(metaChars, function (char) { return regExp.source.indexOf(char) !== -1; }) === undefined);\n}\nexport function addStartOfInput(pattern) {\n var flags = pattern.ignoreCase ? \"i\" : \"\";\n // always wrapping in a none capturing group preceded by '^' to make sure matching can only work on start of input.\n // duplicate/redundant start of input markers have no meaning (/^^^^A/ === /^A/)\n return new RegExp(\"^(?:\" + pattern.source + \")\", flags);\n}\nexport function addStickyFlag(pattern) {\n var flags = pattern.ignoreCase ? \"iy\" : \"y\";\n // always wrapping in a none capturing group preceded by '^' to make sure matching can only work on start of input.\n // duplicate/redundant start of input markers have no meaning (/^^^^A/ === /^A/)\n return new RegExp(\"\" + pattern.source, flags);\n}\nexport function performRuntimeChecks(lexerDefinition, trackLines, lineTerminatorCharacters) {\n var errors = [];\n // some run time checks to help the end users.\n if (!has(lexerDefinition, DEFAULT_MODE)) {\n errors.push({\n message: \"A MultiMode Lexer cannot be initialized without a <\" +\n DEFAULT_MODE +\n \"> property in its definition\\n\",\n type: LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE\n });\n }\n if (!has(lexerDefinition, MODES)) {\n errors.push({\n message: \"A MultiMode Lexer cannot be initialized without a <\" +\n MODES +\n \"> property in its definition\\n\",\n type: LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY\n });\n }\n if (has(lexerDefinition, MODES) &&\n has(lexerDefinition, DEFAULT_MODE) &&\n !has(lexerDefinition.modes, lexerDefinition.defaultMode)) {\n errors.push({\n message: \"A MultiMode Lexer cannot be initialized with a \" + DEFAULT_MODE + \": <\" + lexerDefinition.defaultMode + \">\" +\n \"which does not exist\\n\",\n type: LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST\n });\n }\n if (has(lexerDefinition, MODES)) {\n forEach(lexerDefinition.modes, function (currModeValue, currModeName) {\n forEach(currModeValue, function (currTokType, currIdx) {\n if (isUndefined(currTokType)) {\n errors.push({\n message: \"A Lexer cannot be initialized using an undefined Token Type. Mode:\" +\n (\"<\" + currModeName + \"> at index: <\" + currIdx + \">\\n\"),\n type: LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED\n });\n }\n });\n });\n }\n return errors;\n}\nexport function performWarningRuntimeChecks(lexerDefinition, trackLines, lineTerminatorCharacters) {\n var warnings = [];\n var hasAnyLineBreak = false;\n var allTokenTypes = compact(flatten(mapValues(lexerDefinition.modes, function (tokTypes) { return tokTypes; })));\n var concreteTokenTypes = reject(allTokenTypes, function (currType) { return currType[PATTERN] === Lexer.NA; });\n var terminatorCharCodes = getCharCodes(lineTerminatorCharacters);\n if (trackLines) {\n forEach(concreteTokenTypes, function (tokType) {\n var currIssue = checkLineBreaksIssues(tokType, terminatorCharCodes);\n if (currIssue !== false) {\n var message = buildLineBreakIssueMessage(tokType, currIssue);\n var warningDescriptor = {\n message: message,\n type: currIssue.issue,\n tokenType: tokType\n };\n warnings.push(warningDescriptor);\n }\n else {\n // we don't want to attempt to scan if the user explicitly specified the line_breaks option.\n if (has(tokType, \"LINE_BREAKS\")) {\n if (tokType.LINE_BREAKS === true) {\n hasAnyLineBreak = true;\n }\n }\n else {\n if (canMatchCharCode(terminatorCharCodes, tokType.PATTERN)) {\n hasAnyLineBreak = true;\n }\n }\n }\n });\n }\n if (trackLines && !hasAnyLineBreak) {\n warnings.push({\n message: \"Warning: No LINE_BREAKS Found.\\n\" +\n \"\\tThis Lexer has been defined to track line and column information,\\n\" +\n \"\\tBut none of the Token Types can be identified as matching a line terminator.\\n\" +\n \"\\tSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \\n\" +\n \"\\tfor details.\",\n type: LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS\n });\n }\n return warnings;\n}\nexport function cloneEmptyGroups(emptyGroups) {\n var clonedResult = {};\n var groupKeys = keys(emptyGroups);\n forEach(groupKeys, function (currKey) {\n var currGroupValue = emptyGroups[currKey];\n /* istanbul ignore else */\n if (isArray(currGroupValue)) {\n clonedResult[currKey] = [];\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n });\n return clonedResult;\n}\n// TODO: refactor to avoid duplication\nexport function isCustomPattern(tokenType) {\n var pattern = tokenType.PATTERN;\n /* istanbul ignore else */\n if (isRegExp(pattern)) {\n return false;\n }\n else if (isFunction(pattern)) {\n // CustomPatternMatcherFunc - custom patterns do not require any transformations, only wrapping in a RegExp Like object\n return true;\n }\n else if (has(pattern, \"exec\")) {\n // ICustomPattern\n return true;\n }\n else if (isString(pattern)) {\n return false;\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n}\nexport function isShortPattern(pattern) {\n if (isString(pattern) && pattern.length === 1) {\n return pattern.charCodeAt(0);\n }\n else {\n return false;\n }\n}\n/**\n * Faster than using a RegExp for default newline detection during lexing.\n */\nexport var LineTerminatorOptimizedTester = {\n // implements /\\n|\\r\\n?/g.test\n test: function (text) {\n var len = text.length;\n for (var i = this.lastIndex; i < len; i++) {\n var c = text.charCodeAt(i);\n if (c === 10) {\n this.lastIndex = i + 1;\n return true;\n }\n else if (c === 13) {\n if (text.charCodeAt(i + 1) === 10) {\n this.lastIndex = i + 2;\n }\n else {\n this.lastIndex = i + 1;\n }\n return true;\n }\n }\n return false;\n },\n lastIndex: 0\n};\nfunction checkLineBreaksIssues(tokType, lineTerminatorCharCodes) {\n if (has(tokType, \"LINE_BREAKS\")) {\n // if the user explicitly declared the line_breaks option we will respect their choice\n // and assume it is correct.\n return false;\n }\n else {\n /* istanbul ignore else */\n if (isRegExp(tokType.PATTERN)) {\n try {\n canMatchCharCode(lineTerminatorCharCodes, tokType.PATTERN);\n }\n catch (e) {\n /* istanbul ignore next - to test this we would have to mock to throw an error */\n return {\n issue: LexerDefinitionErrorType.IDENTIFY_TERMINATOR,\n errMsg: e.message\n };\n }\n return false;\n }\n else if (isString(tokType.PATTERN)) {\n // string literal patterns can always be analyzed to detect line terminator usage\n return false;\n }\n else if (isCustomPattern(tokType)) {\n // custom token types\n return { issue: LexerDefinitionErrorType.CUSTOM_LINE_BREAK };\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n }\n}\nexport function buildLineBreakIssueMessage(tokType, details) {\n /* istanbul ignore else */\n if (details.issue === LexerDefinitionErrorType.IDENTIFY_TERMINATOR) {\n return (\"Warning: unable to identify line terminator usage in pattern.\\n\" +\n (\"\\tThe problem is in the <\" + tokType.name + \"> Token Type\\n\") +\n (\"\\t Root cause: \" + details.errMsg + \".\\n\") +\n \"\\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR\");\n }\n else if (details.issue === LexerDefinitionErrorType.CUSTOM_LINE_BREAK) {\n return (\"Warning: A Custom Token Pattern should specify the option.\\n\" +\n (\"\\tThe problem is in the <\" + tokType.name + \"> Token Type\\n\") +\n \"\\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK\");\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n}\nfunction getCharCodes(charsOrCodes) {\n var charCodes = map(charsOrCodes, function (numOrString) {\n if (isString(numOrString) && numOrString.length > 0) {\n return numOrString.charCodeAt(0);\n }\n else {\n return numOrString;\n }\n });\n return charCodes;\n}\nfunction addToMapOfArrays(map, key, value) {\n if (map[key] === undefined) {\n map[key] = [value];\n }\n else {\n map[key].push(value);\n }\n}\nexport var minOptimizationVal = 256;\n/**\n * We ae mapping charCode above ASCI (256) into buckets each in the size of 256.\n * This is because ASCI are the most common start chars so each one of those will get its own\n * possible token configs vector.\n *\n * Tokens starting with charCodes \"above\" ASCI are uncommon, so we can \"afford\"\n * to place these into buckets of possible token configs, What we gain from\n * this is avoiding the case of creating an optimization 'charCodeToPatternIdxToConfig'\n * which would contain 10,000+ arrays of small size (e.g unicode Identifiers scenario).\n * Our 'charCodeToPatternIdxToConfig' max size will now be:\n * 256 + (2^16 / 2^8) - 1 === 511\n *\n * note the hack for fast division integer part extraction\n * See: https://stackoverflow.com/a/4228528\n */\nexport function charCodeToOptimizedIndex(charCode) {\n return charCode < minOptimizationVal\n ? charCode\n : charCodeToOptimizedIdxMap[charCode];\n}\n/**\n * This is a compromise between cold start / hot running performance\n * Creating this array takes ~3ms on a modern machine,\n * But if we perform the computation at runtime as needed the CSS Lexer benchmark\n * performance degrades by ~10%\n *\n * TODO: Perhaps it should be lazy initialized only if a charCode > 255 is used.\n */\nvar charCodeToOptimizedIdxMap = [];\nfunction initCharCodeToOptimizedIndexMap() {\n if (isEmpty(charCodeToOptimizedIdxMap)) {\n charCodeToOptimizedIdxMap = new Array(65536);\n for (var i = 0; i < 65536; i++) {\n /* tslint:disable */\n charCodeToOptimizedIdxMap[i] = i > 255 ? 255 + ~~(i / 255) : i;\n /* tslint:enable */\n }\n }\n}\n//# sourceMappingURL=lexer.js.map","import { cloneArr, compact, contains, difference, flatten, forEach, has, isArray, isEmpty, map } from \"../utils/utils\";\nexport function tokenStructuredMatcher(tokInstance, tokConstructor) {\n var instanceType = tokInstance.tokenTypeIdx;\n if (instanceType === tokConstructor.tokenTypeIdx) {\n return true;\n }\n else {\n return (tokConstructor.isParent === true &&\n tokConstructor.categoryMatchesMap[instanceType] === true);\n }\n}\n// Optimized tokenMatcher in case our grammar does not use token categories\n// Being so tiny it is much more likely to be in-lined and this avoid the function call overhead\nexport function tokenStructuredMatcherNoCategories(token, tokType) {\n return token.tokenTypeIdx === tokType.tokenTypeIdx;\n}\nexport var tokenShortNameIdx = 1;\nexport var tokenIdxToClass = {};\nexport function augmentTokenTypes(tokenTypes) {\n // collect the parent Token Types as well.\n var tokenTypesAndParents = expandCategories(tokenTypes);\n // add required tokenType and categoryMatches properties\n assignTokenDefaultProps(tokenTypesAndParents);\n // fill up the categoryMatches\n assignCategoriesMapProp(tokenTypesAndParents);\n assignCategoriesTokensProp(tokenTypesAndParents);\n forEach(tokenTypesAndParents, function (tokType) {\n tokType.isParent = tokType.categoryMatches.length > 0;\n });\n}\nexport function expandCategories(tokenTypes) {\n var result = cloneArr(tokenTypes);\n var categories = tokenTypes;\n var searching = true;\n while (searching) {\n categories = compact(flatten(map(categories, function (currTokType) { return currTokType.CATEGORIES; })));\n var newCategories = difference(categories, result);\n result = result.concat(newCategories);\n if (isEmpty(newCategories)) {\n searching = false;\n }\n else {\n categories = newCategories;\n }\n }\n return result;\n}\nexport function assignTokenDefaultProps(tokenTypes) {\n forEach(tokenTypes, function (currTokType) {\n if (!hasShortKeyProperty(currTokType)) {\n tokenIdxToClass[tokenShortNameIdx] = currTokType;\n currTokType.tokenTypeIdx = tokenShortNameIdx++;\n }\n // CATEGORIES? : TokenType | TokenType[]\n if (hasCategoriesProperty(currTokType) &&\n !isArray(currTokType.CATEGORIES)\n // &&\n // !isUndefined(currTokType.CATEGORIES.PATTERN)\n ) {\n currTokType.CATEGORIES = [currTokType.CATEGORIES];\n }\n if (!hasCategoriesProperty(currTokType)) {\n currTokType.CATEGORIES = [];\n }\n if (!hasExtendingTokensTypesProperty(currTokType)) {\n currTokType.categoryMatches = [];\n }\n if (!hasExtendingTokensTypesMapProperty(currTokType)) {\n currTokType.categoryMatchesMap = {};\n }\n });\n}\nexport function assignCategoriesTokensProp(tokenTypes) {\n forEach(tokenTypes, function (currTokType) {\n // avoid duplications\n currTokType.categoryMatches = [];\n forEach(currTokType.categoryMatchesMap, function (val, key) {\n currTokType.categoryMatches.push(tokenIdxToClass[key].tokenTypeIdx);\n });\n });\n}\nexport function assignCategoriesMapProp(tokenTypes) {\n forEach(tokenTypes, function (currTokType) {\n singleAssignCategoriesToksMap([], currTokType);\n });\n}\nexport function singleAssignCategoriesToksMap(path, nextNode) {\n forEach(path, function (pathNode) {\n nextNode.categoryMatchesMap[pathNode.tokenTypeIdx] = true;\n });\n forEach(nextNode.CATEGORIES, function (nextCategory) {\n var newPath = path.concat(nextNode);\n // avoids infinite loops due to cyclic categories.\n if (!contains(newPath, nextCategory)) {\n singleAssignCategoriesToksMap(newPath, nextCategory);\n }\n });\n}\nexport function hasShortKeyProperty(tokType) {\n return has(tokType, \"tokenTypeIdx\");\n}\nexport function hasCategoriesProperty(tokType) {\n return has(tokType, \"CATEGORIES\");\n}\nexport function hasExtendingTokensTypesProperty(tokType) {\n return has(tokType, \"categoryMatches\");\n}\nexport function hasExtendingTokensTypesMapProperty(tokType) {\n return has(tokType, \"categoryMatchesMap\");\n}\nexport function isTokenType(tokType) {\n return has(tokType, \"tokenTypeIdx\");\n}\n//# sourceMappingURL=tokens.js.map","export var defaultLexerErrorProvider = {\n buildUnableToPopLexerModeMessage: function (token) {\n return \"Unable to pop Lexer Mode after encountering Token ->\" + token.image + \"<- The Mode Stack is empty\";\n },\n buildUnexpectedCharactersMessage: function (fullText, startOffset, length, line, column) {\n return (\"unexpected character: ->\" + fullText.charAt(startOffset) + \"<- at offset: \" + startOffset + \",\" + (\" skipped \" + length + \" characters.\"));\n }\n};\n//# sourceMappingURL=lexer_errors_public.js.map","import { analyzeTokenTypes, charCodeToOptimizedIndex, cloneEmptyGroups, DEFAULT_MODE, LineTerminatorOptimizedTester, performRuntimeChecks, performWarningRuntimeChecks, SUPPORT_STICKY, validatePatterns } from \"./lexer\";\nimport { cloneArr, cloneObj, forEach, IDENTITY, isArray, isEmpty, isUndefined, keys, last, map, merge, NOOP, PRINT_WARNING, reduce, reject, timer, toFastProperties } from \"../utils/utils\";\nimport { augmentTokenTypes } from \"./tokens\";\nimport { defaultLexerErrorProvider } from \"../scan/lexer_errors_public\";\nimport { clearRegExpParserCache } from \"./reg_exp_parser\";\nexport var LexerDefinitionErrorType;\n(function (LexerDefinitionErrorType) {\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"MISSING_PATTERN\"] = 0] = \"MISSING_PATTERN\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"INVALID_PATTERN\"] = 1] = \"INVALID_PATTERN\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"EOI_ANCHOR_FOUND\"] = 2] = \"EOI_ANCHOR_FOUND\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"UNSUPPORTED_FLAGS_FOUND\"] = 3] = \"UNSUPPORTED_FLAGS_FOUND\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"DUPLICATE_PATTERNS_FOUND\"] = 4] = \"DUPLICATE_PATTERNS_FOUND\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"INVALID_GROUP_TYPE_FOUND\"] = 5] = \"INVALID_GROUP_TYPE_FOUND\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"PUSH_MODE_DOES_NOT_EXIST\"] = 6] = \"PUSH_MODE_DOES_NOT_EXIST\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE\"] = 7] = \"MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY\"] = 8] = \"MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST\"] = 9] = \"MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED\"] = 10] = \"LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"SOI_ANCHOR_FOUND\"] = 11] = \"SOI_ANCHOR_FOUND\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"EMPTY_MATCH_PATTERN\"] = 12] = \"EMPTY_MATCH_PATTERN\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"NO_LINE_BREAKS_FLAGS\"] = 13] = \"NO_LINE_BREAKS_FLAGS\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"UNREACHABLE_PATTERN\"] = 14] = \"UNREACHABLE_PATTERN\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"IDENTIFY_TERMINATOR\"] = 15] = \"IDENTIFY_TERMINATOR\";\n LexerDefinitionErrorType[LexerDefinitionErrorType[\"CUSTOM_LINE_BREAK\"] = 16] = \"CUSTOM_LINE_BREAK\";\n})(LexerDefinitionErrorType || (LexerDefinitionErrorType = {}));\nvar DEFAULT_LEXER_CONFIG = {\n deferDefinitionErrorsHandling: false,\n positionTracking: \"full\",\n lineTerminatorsPattern: /\\n|\\r\\n?/g,\n lineTerminatorCharacters: [\"\\n\", \"\\r\"],\n ensureOptimizations: false,\n safeMode: false,\n errorMessageProvider: defaultLexerErrorProvider,\n traceInitPerf: false,\n skipValidations: false\n};\nObject.freeze(DEFAULT_LEXER_CONFIG);\nvar Lexer = /** @class */ (function () {\n function Lexer(lexerDefinition, config) {\n var _this = this;\n if (config === void 0) { config = DEFAULT_LEXER_CONFIG; }\n this.lexerDefinition = lexerDefinition;\n this.lexerDefinitionErrors = [];\n this.lexerDefinitionWarning = [];\n this.patternIdxToConfig = {};\n this.charCodeToPatternIdxToConfig = {};\n this.modes = [];\n this.emptyGroups = {};\n this.config = undefined;\n this.trackStartLines = true;\n this.trackEndLines = true;\n this.hasCustom = false;\n this.canModeBeOptimized = {};\n if (typeof config === \"boolean\") {\n throw Error(\"The second argument to the Lexer constructor is now an ILexerConfig Object.\\n\" +\n \"a boolean 2nd argument is no longer supported\");\n }\n // todo: defaults func?\n this.config = merge(DEFAULT_LEXER_CONFIG, config);\n var traceInitVal = this.config.traceInitPerf;\n if (traceInitVal === true) {\n this.traceInitMaxIdent = Infinity;\n this.traceInitPerf = true;\n }\n else if (typeof traceInitVal === \"number\") {\n this.traceInitMaxIdent = traceInitVal;\n this.traceInitPerf = true;\n }\n this.traceInitIndent = -1;\n this.TRACE_INIT(\"Lexer Constructor\", function () {\n var actualDefinition;\n var hasOnlySingleMode = true;\n _this.TRACE_INIT(\"Lexer Config handling\", function () {\n if (_this.config.lineTerminatorsPattern ===\n DEFAULT_LEXER_CONFIG.lineTerminatorsPattern) {\n // optimized built-in implementation for the defaults definition of lineTerminators\n _this.config.lineTerminatorsPattern = LineTerminatorOptimizedTester;\n }\n else {\n if (_this.config.lineTerminatorCharacters ===\n DEFAULT_LEXER_CONFIG.lineTerminatorCharacters) {\n throw Error(\"Error: Missing property on the Lexer config.\\n\" +\n \"\\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS\");\n }\n }\n if (config.safeMode && config.ensureOptimizations) {\n throw Error('\"safeMode\" and \"ensureOptimizations\" flags are mutually exclusive.');\n }\n _this.trackStartLines = /full|onlyStart/i.test(_this.config.positionTracking);\n _this.trackEndLines = /full/i.test(_this.config.positionTracking);\n // Convert SingleModeLexerDefinition into a IMultiModeLexerDefinition.\n if (isArray(lexerDefinition)) {\n actualDefinition = { modes: {} };\n actualDefinition.modes[DEFAULT_MODE] = cloneArr(lexerDefinition);\n actualDefinition[DEFAULT_MODE] = DEFAULT_MODE;\n }\n else {\n // no conversion needed, input should already be a IMultiModeLexerDefinition\n hasOnlySingleMode = false;\n actualDefinition = cloneObj(lexerDefinition);\n }\n });\n if (_this.config.skipValidations === false) {\n _this.TRACE_INIT(\"performRuntimeChecks\", function () {\n _this.lexerDefinitionErrors = _this.lexerDefinitionErrors.concat(performRuntimeChecks(actualDefinition, _this.trackStartLines, _this.config.lineTerminatorCharacters));\n });\n _this.TRACE_INIT(\"performWarningRuntimeChecks\", function () {\n _this.lexerDefinitionWarning = _this.lexerDefinitionWarning.concat(performWarningRuntimeChecks(actualDefinition, _this.trackStartLines, _this.config.lineTerminatorCharacters));\n });\n }\n // for extra robustness to avoid throwing an none informative error message\n actualDefinition.modes = actualDefinition.modes\n ? actualDefinition.modes\n : {};\n // an error of undefined TokenTypes will be detected in \"performRuntimeChecks\" above.\n // this transformation is to increase robustness in the case of partially invalid lexer definition.\n forEach(actualDefinition.modes, function (currModeValue, currModeName) {\n actualDefinition.modes[currModeName] = reject(currModeValue, function (currTokType) { return isUndefined(currTokType); });\n });\n var allModeNames = keys(actualDefinition.modes);\n forEach(actualDefinition.modes, function (currModDef, currModName) {\n _this.TRACE_INIT(\"Mode: <\" + currModName + \"> processing\", function () {\n _this.modes.push(currModName);\n if (_this.config.skipValidations === false) {\n _this.TRACE_INIT(\"validatePatterns\", function () {\n _this.lexerDefinitionErrors = _this.lexerDefinitionErrors.concat(validatePatterns(currModDef, allModeNames));\n });\n }\n // If definition errors were encountered, the analysis phase may fail unexpectedly/\n // Considering a lexer with definition errors may never be used, there is no point\n // to performing the analysis anyhow...\n if (isEmpty(_this.lexerDefinitionErrors)) {\n augmentTokenTypes(currModDef);\n var currAnalyzeResult_1;\n _this.TRACE_INIT(\"analyzeTokenTypes\", function () {\n currAnalyzeResult_1 = analyzeTokenTypes(currModDef, {\n lineTerminatorCharacters: _this.config\n .lineTerminatorCharacters,\n positionTracking: config.positionTracking,\n ensureOptimizations: config.ensureOptimizations,\n safeMode: config.safeMode,\n tracer: _this.TRACE_INIT.bind(_this)\n });\n });\n _this.patternIdxToConfig[currModName] =\n currAnalyzeResult_1.patternIdxToConfig;\n _this.charCodeToPatternIdxToConfig[currModName] =\n currAnalyzeResult_1.charCodeToPatternIdxToConfig;\n _this.emptyGroups = merge(_this.emptyGroups, currAnalyzeResult_1.emptyGroups);\n _this.hasCustom = currAnalyzeResult_1.hasCustom || _this.hasCustom;\n _this.canModeBeOptimized[currModName] =\n currAnalyzeResult_1.canBeOptimized;\n }\n });\n });\n _this.defaultMode = actualDefinition.defaultMode;\n if (!isEmpty(_this.lexerDefinitionErrors) &&\n !_this.config.deferDefinitionErrorsHandling) {\n var allErrMessages = map(_this.lexerDefinitionErrors, function (error) {\n return error.message;\n });\n var allErrMessagesString = allErrMessages.join(\"-----------------------\\n\");\n throw new Error(\"Errors detected in definition of Lexer:\\n\" + allErrMessagesString);\n }\n // Only print warning if there are no errors, This will avoid pl\n forEach(_this.lexerDefinitionWarning, function (warningDescriptor) {\n PRINT_WARNING(warningDescriptor.message);\n });\n _this.TRACE_INIT(\"Choosing sub-methods implementations\", function () {\n // Choose the relevant internal implementations for this specific parser.\n // These implementations should be in-lined by the JavaScript engine\n // to provide optimal performance in each scenario.\n if (SUPPORT_STICKY) {\n _this.chopInput = IDENTITY;\n _this.match = _this.matchWithTest;\n }\n else {\n _this.updateLastIndex = NOOP;\n _this.match = _this.matchWithExec;\n }\n if (hasOnlySingleMode) {\n _this.handleModes = NOOP;\n }\n if (_this.trackStartLines === false) {\n _this.computeNewColumn = IDENTITY;\n }\n if (_this.trackEndLines === false) {\n _this.updateTokenEndLineColumnLocation = NOOP;\n }\n if (/full/i.test(_this.config.positionTracking)) {\n _this.createTokenInstance = _this.createFullToken;\n }\n else if (/onlyStart/i.test(_this.config.positionTracking)) {\n _this.createTokenInstance = _this.createStartOnlyToken;\n }\n else if (/onlyOffset/i.test(_this.config.positionTracking)) {\n _this.createTokenInstance = _this.createOffsetOnlyToken;\n }\n else {\n throw Error(\"Invalid config option: \\\"\" + _this.config.positionTracking + \"\\\"\");\n }\n if (_this.hasCustom) {\n _this.addToken = _this.addTokenUsingPush;\n _this.handlePayload = _this.handlePayloadWithCustom;\n }\n else {\n _this.addToken = _this.addTokenUsingMemberAccess;\n _this.handlePayload = _this.handlePayloadNoCustom;\n }\n });\n _this.TRACE_INIT(\"Failed Optimization Warnings\", function () {\n var unOptimizedModes = reduce(_this.canModeBeOptimized, function (cannotBeOptimized, canBeOptimized, modeName) {\n if (canBeOptimized === false) {\n cannotBeOptimized.push(modeName);\n }\n return cannotBeOptimized;\n }, []);\n if (config.ensureOptimizations && !isEmpty(unOptimizedModes)) {\n throw Error(\"Lexer Modes: < \" + unOptimizedModes.join(\", \") + \" > cannot be optimized.\\n\" +\n '\\t Disable the \"ensureOptimizations\" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\\n' +\n \"\\t Or inspect the console log for details on how to resolve these issues.\");\n }\n });\n _this.TRACE_INIT(\"clearRegExpParserCache\", function () {\n clearRegExpParserCache();\n });\n _this.TRACE_INIT(\"toFastProperties\", function () {\n toFastProperties(_this);\n });\n });\n }\n Lexer.prototype.tokenize = function (text, initialMode) {\n if (initialMode === void 0) { initialMode = this.defaultMode; }\n if (!isEmpty(this.lexerDefinitionErrors)) {\n var allErrMessages = map(this.lexerDefinitionErrors, function (error) {\n return error.message;\n });\n var allErrMessagesString = allErrMessages.join(\"-----------------------\\n\");\n throw new Error(\"Unable to Tokenize because Errors detected in definition of Lexer:\\n\" +\n allErrMessagesString);\n }\n var lexResult = this.tokenizeInternal(text, initialMode);\n return lexResult;\n };\n // There is quite a bit of duplication between this and \"tokenizeInternalLazy\"\n // This is intentional due to performance considerations.\n Lexer.prototype.tokenizeInternal = function (text, initialMode) {\n var _this = this;\n var i, j, matchAltImage, longerAltIdx, matchedImage, payload, altPayload, imageLength, group, tokType, newToken, errLength, droppedChar, msg, match;\n var orgText = text;\n var orgLength = orgText.length;\n var offset = 0;\n var matchedTokensIndex = 0;\n // initializing the tokensArray to the \"guessed\" size.\n // guessing too little will still reduce the number of array re-sizes on pushes.\n // guessing too large (Tested by guessing x4 too large) may cost a bit more of memory\n // but would still have a faster runtime by avoiding (All but one) array resizing.\n var guessedNumberOfTokens = this.hasCustom\n ? 0 // will break custom token pattern APIs the matchedTokens array will contain undefined elements.\n : Math.floor(text.length / 10);\n var matchedTokens = new Array(guessedNumberOfTokens);\n var errors = [];\n var line = this.trackStartLines ? 1 : undefined;\n var column = this.trackStartLines ? 1 : undefined;\n var groups = cloneEmptyGroups(this.emptyGroups);\n var trackLines = this.trackStartLines;\n var lineTerminatorPattern = this.config.lineTerminatorsPattern;\n var currModePatternsLength = 0;\n var patternIdxToConfig = [];\n var currCharCodeToPatternIdxToConfig = [];\n var modeStack = [];\n var emptyArray = [];\n Object.freeze(emptyArray);\n var getPossiblePatterns = undefined;\n function getPossiblePatternsSlow() {\n return patternIdxToConfig;\n }\n function getPossiblePatternsOptimized(charCode) {\n var optimizedCharIdx = charCodeToOptimizedIndex(charCode);\n var possiblePatterns = currCharCodeToPatternIdxToConfig[optimizedCharIdx];\n if (possiblePatterns === undefined) {\n return emptyArray;\n }\n else {\n return possiblePatterns;\n }\n }\n var pop_mode = function (popToken) {\n // TODO: perhaps avoid this error in the edge case there is no more input?\n if (modeStack.length === 1 &&\n // if we have both a POP_MODE and a PUSH_MODE this is in-fact a \"transition\"\n // So no error should occur.\n popToken.tokenType.PUSH_MODE === undefined) {\n // if we try to pop the last mode there lexer will no longer have ANY mode.\n // thus the pop is ignored, an error will be created and the lexer will continue parsing in the previous mode.\n var msg_1 = _this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(popToken);\n errors.push({\n offset: popToken.startOffset,\n line: popToken.startLine !== undefined ? popToken.startLine : undefined,\n column: popToken.startColumn !== undefined\n ? popToken.startColumn\n : undefined,\n length: popToken.image.length,\n message: msg_1\n });\n }\n else {\n modeStack.pop();\n var newMode = last(modeStack);\n patternIdxToConfig = _this.patternIdxToConfig[newMode];\n currCharCodeToPatternIdxToConfig = _this.charCodeToPatternIdxToConfig[newMode];\n currModePatternsLength = patternIdxToConfig.length;\n var modeCanBeOptimized = _this.canModeBeOptimized[newMode] && _this.config.safeMode === false;\n if (currCharCodeToPatternIdxToConfig && modeCanBeOptimized) {\n getPossiblePatterns = getPossiblePatternsOptimized;\n }\n else {\n getPossiblePatterns = getPossiblePatternsSlow;\n }\n }\n };\n function push_mode(newMode) {\n modeStack.push(newMode);\n currCharCodeToPatternIdxToConfig = this.charCodeToPatternIdxToConfig[newMode];\n patternIdxToConfig = this.patternIdxToConfig[newMode];\n currModePatternsLength = patternIdxToConfig.length;\n currModePatternsLength = patternIdxToConfig.length;\n var modeCanBeOptimized = this.canModeBeOptimized[newMode] && this.config.safeMode === false;\n if (currCharCodeToPatternIdxToConfig && modeCanBeOptimized) {\n getPossiblePatterns = getPossiblePatternsOptimized;\n }\n else {\n getPossiblePatterns = getPossiblePatternsSlow;\n }\n }\n // this pattern seems to avoid a V8 de-optimization, although that de-optimization does not\n // seem to matter performance wise.\n push_mode.call(this, initialMode);\n var currConfig;\n while (offset < orgLength) {\n matchedImage = null;\n var nextCharCode = orgText.charCodeAt(offset);\n var chosenPatternIdxToConfig = getPossiblePatterns(nextCharCode);\n var chosenPatternsLength = chosenPatternIdxToConfig.length;\n for (i = 0; i < chosenPatternsLength; i++) {\n currConfig = chosenPatternIdxToConfig[i];\n var currPattern = currConfig.pattern;\n payload = null;\n // manually in-lined because > 600 chars won't be in-lined in V8\n var singleCharCode = currConfig.short;\n if (singleCharCode !== false) {\n if (nextCharCode === singleCharCode) {\n // single character string\n matchedImage = currPattern;\n }\n }\n else if (currConfig.isCustom === true) {\n match = currPattern.exec(orgText, offset, matchedTokens, groups);\n if (match !== null) {\n matchedImage = match[0];\n if (match.payload !== undefined) {\n payload = match.payload;\n }\n }\n else {\n matchedImage = null;\n }\n }\n else {\n this.updateLastIndex(currPattern, offset);\n matchedImage = this.match(currPattern, text, offset);\n }\n if (matchedImage !== null) {\n // even though this pattern matched we must try a another longer alternative.\n // this can be used to prioritize keywords over identifiers\n longerAltIdx = currConfig.longerAlt;\n if (longerAltIdx !== undefined) {\n // TODO: micro optimize, avoid extra prop access\n // by saving/linking longerAlt on the original config?\n var longerAltConfig = patternIdxToConfig[longerAltIdx];\n var longerAltPattern = longerAltConfig.pattern;\n altPayload = null;\n // single Char can never be a longer alt so no need to test it.\n // manually in-lined because > 600 chars won't be in-lined in V8\n if (longerAltConfig.isCustom === true) {\n match = longerAltPattern.exec(orgText, offset, matchedTokens, groups);\n if (match !== null) {\n matchAltImage = match[0];\n if (match.payload !== undefined) {\n altPayload = match.payload;\n }\n }\n else {\n matchAltImage = null;\n }\n }\n else {\n this.updateLastIndex(longerAltPattern, offset);\n matchAltImage = this.match(longerAltPattern, text, offset);\n }\n if (matchAltImage && matchAltImage.length > matchedImage.length) {\n matchedImage = matchAltImage;\n payload = altPayload;\n currConfig = longerAltConfig;\n }\n }\n break;\n }\n }\n // successful match\n if (matchedImage !== null) {\n imageLength = matchedImage.length;\n group = currConfig.group;\n if (group !== undefined) {\n tokType = currConfig.tokenTypeIdx;\n // TODO: \"offset + imageLength\" and the new column may be computed twice in case of \"full\" location information inside\n // createFullToken method\n newToken = this.createTokenInstance(matchedImage, offset, tokType, currConfig.tokenType, line, column, imageLength);\n this.handlePayload(newToken, payload);\n // TODO: optimize NOOP in case there are no special groups?\n if (group === false) {\n matchedTokensIndex = this.addToken(matchedTokens, matchedTokensIndex, newToken);\n }\n else {\n groups[group].push(newToken);\n }\n }\n text = this.chopInput(text, imageLength);\n offset = offset + imageLength;\n // TODO: with newlines the column may be assigned twice\n column = this.computeNewColumn(column, imageLength);\n if (trackLines === true && currConfig.canLineTerminator === true) {\n var numOfLTsInMatch = 0;\n var foundTerminator = void 0;\n var lastLTEndOffset = void 0;\n lineTerminatorPattern.lastIndex = 0;\n do {\n foundTerminator = lineTerminatorPattern.test(matchedImage);\n if (foundTerminator === true) {\n lastLTEndOffset = lineTerminatorPattern.lastIndex - 1;\n numOfLTsInMatch++;\n }\n } while (foundTerminator === true);\n if (numOfLTsInMatch !== 0) {\n line = line + numOfLTsInMatch;\n column = imageLength - lastLTEndOffset;\n this.updateTokenEndLineColumnLocation(newToken, group, lastLTEndOffset, numOfLTsInMatch, line, column, imageLength);\n }\n }\n // will be NOOP if no modes present\n this.handleModes(currConfig, pop_mode, push_mode, newToken);\n }\n else {\n // error recovery, drop characters until we identify a valid token's start point\n var errorStartOffset = offset;\n var errorLine = line;\n var errorColumn = column;\n var foundResyncPoint = false;\n while (!foundResyncPoint && offset < orgLength) {\n // drop chars until we succeed in matching something\n droppedChar = orgText.charCodeAt(offset);\n // Identity Func (when sticky flag is enabled)\n text = this.chopInput(text, 1);\n offset++;\n for (j = 0; j < currModePatternsLength; j++) {\n var currConfig_1 = patternIdxToConfig[j];\n var currPattern = currConfig_1.pattern;\n // manually in-lined because > 600 chars won't be in-lined in V8\n var singleCharCode = currConfig_1.short;\n if (singleCharCode !== false) {\n if (orgText.charCodeAt(offset) === singleCharCode) {\n // single character string\n foundResyncPoint = true;\n }\n }\n else if (currConfig_1.isCustom === true) {\n foundResyncPoint =\n currPattern.exec(orgText, offset, matchedTokens, groups) !==\n null;\n }\n else {\n this.updateLastIndex(currPattern, offset);\n foundResyncPoint = currPattern.exec(text) !== null;\n }\n if (foundResyncPoint === true) {\n break;\n }\n }\n }\n errLength = offset - errorStartOffset;\n // at this point we either re-synced or reached the end of the input text\n msg = this.config.errorMessageProvider.buildUnexpectedCharactersMessage(orgText, errorStartOffset, errLength, errorLine, errorColumn);\n errors.push({\n offset: errorStartOffset,\n line: errorLine,\n column: errorColumn,\n length: errLength,\n message: msg\n });\n }\n }\n // if we do have custom patterns which push directly into the\n // TODO: custom tokens should not push directly??\n if (!this.hasCustom) {\n // if we guessed a too large size for the tokens array this will shrink it to the right size.\n matchedTokens.length = matchedTokensIndex;\n }\n return {\n tokens: matchedTokens,\n groups: groups,\n errors: errors\n };\n };\n Lexer.prototype.handleModes = function (config, pop_mode, push_mode, newToken) {\n if (config.pop === true) {\n // need to save the PUSH_MODE property as if the mode is popped\n // patternIdxToPopMode is updated to reflect the new mode after popping the stack\n var pushMode = config.push;\n pop_mode(newToken);\n if (pushMode !== undefined) {\n push_mode.call(this, pushMode);\n }\n }\n else if (config.push !== undefined) {\n push_mode.call(this, config.push);\n }\n };\n Lexer.prototype.chopInput = function (text, length) {\n return text.substring(length);\n };\n Lexer.prototype.updateLastIndex = function (regExp, newLastIndex) {\n regExp.lastIndex = newLastIndex;\n };\n // TODO: decrease this under 600 characters? inspect stripping comments option in TSC compiler\n Lexer.prototype.updateTokenEndLineColumnLocation = function (newToken, group, lastLTIdx, numOfLTsInMatch, line, column, imageLength) {\n var lastCharIsLT, fixForEndingInLT;\n if (group !== undefined) {\n // a none skipped multi line Token, need to update endLine/endColumn\n lastCharIsLT = lastLTIdx === imageLength - 1;\n fixForEndingInLT = lastCharIsLT ? -1 : 0;\n if (!(numOfLTsInMatch === 1 && lastCharIsLT === true)) {\n // if a token ends in a LT that last LT only affects the line numbering of following Tokens\n newToken.endLine = line + fixForEndingInLT;\n // the last LT in a token does not affect the endColumn either as the [columnStart ... columnEnd)\n // inclusive to exclusive range.\n newToken.endColumn = column - 1 + -fixForEndingInLT;\n }\n // else single LT in the last character of a token, no need to modify the endLine/EndColumn\n }\n };\n Lexer.prototype.computeNewColumn = function (oldColumn, imageLength) {\n return oldColumn + imageLength;\n };\n // Place holder, will be replaced by the correct variant according to the locationTracking option at runtime.\n /* istanbul ignore next - place holder */\n Lexer.prototype.createTokenInstance = function () {\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return null;\n };\n Lexer.prototype.createOffsetOnlyToken = function (image, startOffset, tokenTypeIdx, tokenType) {\n return {\n image: image,\n startOffset: startOffset,\n tokenTypeIdx: tokenTypeIdx,\n tokenType: tokenType\n };\n };\n Lexer.prototype.createStartOnlyToken = function (image, startOffset, tokenTypeIdx, tokenType, startLine, startColumn) {\n return {\n image: image,\n startOffset: startOffset,\n startLine: startLine,\n startColumn: startColumn,\n tokenTypeIdx: tokenTypeIdx,\n tokenType: tokenType\n };\n };\n Lexer.prototype.createFullToken = function (image, startOffset, tokenTypeIdx, tokenType, startLine, startColumn, imageLength) {\n return {\n image: image,\n startOffset: startOffset,\n endOffset: startOffset + imageLength - 1,\n startLine: startLine,\n endLine: startLine,\n startColumn: startColumn,\n endColumn: startColumn + imageLength - 1,\n tokenTypeIdx: tokenTypeIdx,\n tokenType: tokenType\n };\n };\n // Place holder, will be replaced by the correct variant according to the locationTracking option at runtime.\n /* istanbul ignore next - place holder */\n Lexer.prototype.addToken = function (tokenVector, index, tokenToAdd) {\n return 666;\n };\n Lexer.prototype.addTokenUsingPush = function (tokenVector, index, tokenToAdd) {\n tokenVector.push(tokenToAdd);\n return index;\n };\n Lexer.prototype.addTokenUsingMemberAccess = function (tokenVector, index, tokenToAdd) {\n tokenVector[index] = tokenToAdd;\n index++;\n return index;\n };\n // Place holder, will be replaced by the correct variant according to the hasCustom flag option at runtime.\n /* istanbul ignore next - place holder */\n Lexer.prototype.handlePayload = function (token, payload) { };\n Lexer.prototype.handlePayloadNoCustom = function (token, payload) { };\n Lexer.prototype.handlePayloadWithCustom = function (token, payload) {\n if (payload !== null) {\n token.payload = payload;\n }\n };\n /* istanbul ignore next - place holder to be replaced with chosen alternative at runtime */\n Lexer.prototype.match = function (pattern, text, offset) {\n return null;\n };\n Lexer.prototype.matchWithTest = function (pattern, text, offset) {\n var found = pattern.test(text);\n if (found === true) {\n return text.substring(offset, pattern.lastIndex);\n }\n return null;\n };\n Lexer.prototype.matchWithExec = function (pattern, text) {\n var regExpArray = pattern.exec(text);\n return regExpArray !== null ? regExpArray[0] : regExpArray;\n };\n // Duplicated from the parser's perf trace trait to allow future extraction\n // of the lexer to a separate package.\n Lexer.prototype.TRACE_INIT = function (phaseDesc, phaseImpl) {\n // No need to optimize this using NOOP pattern because\n // It is not called in a hot spot...\n if (this.traceInitPerf === true) {\n this.traceInitIndent++;\n var indent = new Array(this.traceInitIndent + 1).join(\"\\t\");\n if (this.traceInitIndent < this.traceInitMaxIdent) {\n console.log(indent + \"--> <\" + phaseDesc + \">\");\n }\n var _a = timer(phaseImpl), time = _a.time, value = _a.value;\n /* istanbul ignore next - Difficult to reproduce specific performance behavior (>10ms) in tests */\n var traceMethod = time > 10 ? console.warn : console.log;\n if (this.traceInitIndent < this.traceInitMaxIdent) {\n traceMethod(indent + \"<-- <\" + phaseDesc + \"> time: \" + time + \"ms\");\n }\n this.traceInitIndent--;\n return value;\n }\n else {\n return phaseImpl();\n }\n };\n Lexer.SKIPPED = \"This marks a skipped Token pattern, this means each token identified by it will\" +\n \"be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.\";\n Lexer.NA = /NOT_APPLICABLE/;\n return Lexer;\n}());\nexport { Lexer };\n//# sourceMappingURL=lexer_public.js.map","import { has, isString, isUndefined } from \"../utils/utils\";\nimport { Lexer } from \"./lexer_public\";\nimport { augmentTokenTypes, tokenStructuredMatcher } from \"./tokens\";\nexport function tokenLabel(tokType) {\n if (hasTokenLabel(tokType)) {\n return tokType.LABEL;\n }\n else {\n return tokType.name;\n }\n}\nexport function tokenName(tokType) {\n return tokType.name;\n}\nexport function hasTokenLabel(obj) {\n return isString(obj.LABEL) && obj.LABEL !== \"\";\n}\nvar PARENT = \"parent\";\nvar CATEGORIES = \"categories\";\nvar LABEL = \"label\";\nvar GROUP = \"group\";\nvar PUSH_MODE = \"push_mode\";\nvar POP_MODE = \"pop_mode\";\nvar LONGER_ALT = \"longer_alt\";\nvar LINE_BREAKS = \"line_breaks\";\nvar START_CHARS_HINT = \"start_chars_hint\";\nexport function createToken(config) {\n return createTokenInternal(config);\n}\nfunction createTokenInternal(config) {\n var pattern = config.pattern;\n var tokenType = {};\n tokenType.name = config.name;\n if (!isUndefined(pattern)) {\n tokenType.PATTERN = pattern;\n }\n if (has(config, PARENT)) {\n throw (\"The parent property is no longer supported.\\n\" +\n \"See: https://github.com/SAP/chevrotain/issues/564#issuecomment-349062346 for details.\");\n }\n if (has(config, CATEGORIES)) {\n // casting to ANY as this will be fixed inside `augmentTokenTypes``\n tokenType.CATEGORIES = config[CATEGORIES];\n }\n augmentTokenTypes([tokenType]);\n if (has(config, LABEL)) {\n tokenType.LABEL = config[LABEL];\n }\n if (has(config, GROUP)) {\n tokenType.GROUP = config[GROUP];\n }\n if (has(config, POP_MODE)) {\n tokenType.POP_MODE = config[POP_MODE];\n }\n if (has(config, PUSH_MODE)) {\n tokenType.PUSH_MODE = config[PUSH_MODE];\n }\n if (has(config, LONGER_ALT)) {\n tokenType.LONGER_ALT = config[LONGER_ALT];\n }\n if (has(config, LINE_BREAKS)) {\n tokenType.LINE_BREAKS = config[LINE_BREAKS];\n }\n if (has(config, START_CHARS_HINT)) {\n tokenType.START_CHARS_HINT = config[START_CHARS_HINT];\n }\n return tokenType;\n}\nexport var EOF = createToken({ name: \"EOF\", pattern: Lexer.NA });\naugmentTokenTypes([EOF]);\nexport function createTokenInstance(tokType, image, startOffset, endOffset, startLine, endLine, startColumn, endColumn) {\n return {\n image: image,\n startOffset: startOffset,\n endOffset: endOffset,\n startLine: startLine,\n endLine: endLine,\n startColumn: startColumn,\n endColumn: endColumn,\n tokenTypeIdx: tokType.tokenTypeIdx,\n tokenType: tokType\n };\n}\nexport function tokenMatcher(token, tokType) {\n return tokenStructuredMatcher(token, tokType);\n}\n//# sourceMappingURL=tokens_public.js.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { assign, forEach, isRegExp, map, pick } from \"../../../utils/utils\";\nimport { tokenLabel } from \"../../../scan/tokens_public\";\nvar AbstractProduction = /** @class */ (function () {\n function AbstractProduction(definition) {\n this.definition = definition;\n }\n AbstractProduction.prototype.accept = function (visitor) {\n visitor.visit(this);\n forEach(this.definition, function (prod) {\n prod.accept(visitor);\n });\n };\n return AbstractProduction;\n}());\nexport { AbstractProduction };\nvar NonTerminal = /** @class */ (function (_super) {\n __extends(NonTerminal, _super);\n function NonTerminal(options) {\n var _this = _super.call(this, []) || this;\n _this.idx = 1;\n assign(_this, pick(options, function (v) { return v !== undefined; }));\n return _this;\n }\n Object.defineProperty(NonTerminal.prototype, \"definition\", {\n get: function () {\n if (this.referencedRule !== undefined) {\n return this.referencedRule.definition;\n }\n return [];\n },\n set: function (definition) {\n // immutable\n },\n enumerable: true,\n configurable: true\n });\n NonTerminal.prototype.accept = function (visitor) {\n visitor.visit(this);\n // don't visit children of a reference, we will get cyclic infinite loops if we do so\n };\n return NonTerminal;\n}(AbstractProduction));\nexport { NonTerminal };\nvar Rule = /** @class */ (function (_super) {\n __extends(Rule, _super);\n function Rule(options) {\n var _this = _super.call(this, options.definition) || this;\n _this.orgText = \"\";\n assign(_this, pick(options, function (v) { return v !== undefined; }));\n return _this;\n }\n return Rule;\n}(AbstractProduction));\nexport { Rule };\nvar Alternative = /** @class */ (function (_super) {\n __extends(Alternative, _super);\n function Alternative(options) {\n var _this = _super.call(this, options.definition) || this;\n _this.ignoreAmbiguities = false;\n assign(_this, pick(options, function (v) { return v !== undefined; }));\n return _this;\n }\n return Alternative;\n}(AbstractProduction));\nexport { Alternative };\nvar Option = /** @class */ (function (_super) {\n __extends(Option, _super);\n function Option(options) {\n var _this = _super.call(this, options.definition) || this;\n _this.idx = 1;\n assign(_this, pick(options, function (v) { return v !== undefined; }));\n return _this;\n }\n return Option;\n}(AbstractProduction));\nexport { Option };\nvar RepetitionMandatory = /** @class */ (function (_super) {\n __extends(RepetitionMandatory, _super);\n function RepetitionMandatory(options) {\n var _this = _super.call(this, options.definition) || this;\n _this.idx = 1;\n assign(_this, pick(options, function (v) { return v !== undefined; }));\n return _this;\n }\n return RepetitionMandatory;\n}(AbstractProduction));\nexport { RepetitionMandatory };\nvar RepetitionMandatoryWithSeparator = /** @class */ (function (_super) {\n __extends(RepetitionMandatoryWithSeparator, _super);\n function RepetitionMandatoryWithSeparator(options) {\n var _this = _super.call(this, options.definition) || this;\n _this.idx = 1;\n assign(_this, pick(options, function (v) { return v !== undefined; }));\n return _this;\n }\n return RepetitionMandatoryWithSeparator;\n}(AbstractProduction));\nexport { RepetitionMandatoryWithSeparator };\nvar Repetition = /** @class */ (function (_super) {\n __extends(Repetition, _super);\n function Repetition(options) {\n var _this = _super.call(this, options.definition) || this;\n _this.idx = 1;\n assign(_this, pick(options, function (v) { return v !== undefined; }));\n return _this;\n }\n return Repetition;\n}(AbstractProduction));\nexport { Repetition };\nvar RepetitionWithSeparator = /** @class */ (function (_super) {\n __extends(RepetitionWithSeparator, _super);\n function RepetitionWithSeparator(options) {\n var _this = _super.call(this, options.definition) || this;\n _this.idx = 1;\n assign(_this, pick(options, function (v) { return v !== undefined; }));\n return _this;\n }\n return RepetitionWithSeparator;\n}(AbstractProduction));\nexport { RepetitionWithSeparator };\nvar Alternation = /** @class */ (function (_super) {\n __extends(Alternation, _super);\n function Alternation(options) {\n var _this = _super.call(this, options.definition) || this;\n _this.idx = 1;\n _this.ignoreAmbiguities = false;\n _this.hasPredicates = false;\n assign(_this, pick(options, function (v) { return v !== undefined; }));\n return _this;\n }\n return Alternation;\n}(AbstractProduction));\nexport { Alternation };\nvar Terminal = /** @class */ (function () {\n function Terminal(options) {\n this.idx = 1;\n assign(this, pick(options, function (v) { return v !== undefined; }));\n }\n Terminal.prototype.accept = function (visitor) {\n visitor.visit(this);\n };\n return Terminal;\n}());\nexport { Terminal };\nexport function serializeGrammar(topRules) {\n return map(topRules, serializeProduction);\n}\nexport function serializeProduction(node) {\n function convertDefinition(definition) {\n return map(definition, serializeProduction);\n }\n /* istanbul ignore else */\n if (node instanceof NonTerminal) {\n return {\n type: \"NonTerminal\",\n name: node.nonTerminalName,\n idx: node.idx\n };\n }\n else if (node instanceof Alternative) {\n return {\n type: \"Alternative\",\n definition: convertDefinition(node.definition)\n };\n }\n else if (node instanceof Option) {\n return {\n type: \"Option\",\n idx: node.idx,\n definition: convertDefinition(node.definition)\n };\n }\n else if (node instanceof RepetitionMandatory) {\n return {\n type: \"RepetitionMandatory\",\n idx: node.idx,\n definition: convertDefinition(node.definition)\n };\n }\n else if (node instanceof RepetitionMandatoryWithSeparator) {\n return {\n type: \"RepetitionMandatoryWithSeparator\",\n idx: node.idx,\n separator: (serializeProduction(new Terminal({ terminalType: node.separator }))),\n definition: convertDefinition(node.definition)\n };\n }\n else if (node instanceof RepetitionWithSeparator) {\n return {\n type: \"RepetitionWithSeparator\",\n idx: node.idx,\n separator: (serializeProduction(new Terminal({ terminalType: node.separator }))),\n definition: convertDefinition(node.definition)\n };\n }\n else if (node instanceof Repetition) {\n return {\n type: \"Repetition\",\n idx: node.idx,\n definition: convertDefinition(node.definition)\n };\n }\n else if (node instanceof Alternation) {\n return {\n type: \"Alternation\",\n idx: node.idx,\n definition: convertDefinition(node.definition)\n };\n }\n else if (node instanceof Terminal) {\n var serializedTerminal = {\n type: \"Terminal\",\n name: node.terminalType.name,\n label: tokenLabel(node.terminalType),\n idx: node.idx\n };\n var pattern = node.terminalType.PATTERN;\n if (node.terminalType.PATTERN) {\n serializedTerminal.pattern = isRegExp(pattern)\n ? pattern.source\n : pattern;\n }\n return serializedTerminal;\n }\n else if (node instanceof Rule) {\n return {\n type: \"Rule\",\n name: node.name,\n orgText: node.orgText,\n definition: convertDefinition(node.definition)\n };\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n}\n//# sourceMappingURL=gast_public.js.map","import { drop, forEach } from \"../../utils/utils\";\nimport { Alternation, Alternative, NonTerminal, Option, Repetition, RepetitionMandatory, RepetitionMandatoryWithSeparator, RepetitionWithSeparator, Terminal } from \"./gast/gast_public\";\n/**\n * A Grammar Walker that computes the \"remaining\" grammar \"after\" a productions in the grammar.\n */\nvar RestWalker = /** @class */ (function () {\n function RestWalker() {\n }\n RestWalker.prototype.walk = function (prod, prevRest) {\n var _this = this;\n if (prevRest === void 0) { prevRest = []; }\n forEach(prod.definition, function (subProd, index) {\n var currRest = drop(prod.definition, index + 1);\n /* istanbul ignore else */\n if (subProd instanceof NonTerminal) {\n _this.walkProdRef(subProd, currRest, prevRest);\n }\n else if (subProd instanceof Terminal) {\n _this.walkTerminal(subProd, currRest, prevRest);\n }\n else if (subProd instanceof Alternative) {\n _this.walkFlat(subProd, currRest, prevRest);\n }\n else if (subProd instanceof Option) {\n _this.walkOption(subProd, currRest, prevRest);\n }\n else if (subProd instanceof RepetitionMandatory) {\n _this.walkAtLeastOne(subProd, currRest, prevRest);\n }\n else if (subProd instanceof RepetitionMandatoryWithSeparator) {\n _this.walkAtLeastOneSep(subProd, currRest, prevRest);\n }\n else if (subProd instanceof RepetitionWithSeparator) {\n _this.walkManySep(subProd, currRest, prevRest);\n }\n else if (subProd instanceof Repetition) {\n _this.walkMany(subProd, currRest, prevRest);\n }\n else if (subProd instanceof Alternation) {\n _this.walkOr(subProd, currRest, prevRest);\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n });\n };\n RestWalker.prototype.walkTerminal = function (terminal, currRest, prevRest) { };\n RestWalker.prototype.walkProdRef = function (refProd, currRest, prevRest) { };\n RestWalker.prototype.walkFlat = function (flatProd, currRest, prevRest) {\n // ABCDEF => after the D the rest is EF\n var fullOrRest = currRest.concat(prevRest);\n this.walk(flatProd, fullOrRest);\n };\n RestWalker.prototype.walkOption = function (optionProd, currRest, prevRest) {\n // ABC(DE)?F => after the (DE)? the rest is F\n var fullOrRest = currRest.concat(prevRest);\n this.walk(optionProd, fullOrRest);\n };\n RestWalker.prototype.walkAtLeastOne = function (atLeastOneProd, currRest, prevRest) {\n // ABC(DE)+F => after the (DE)+ the rest is (DE)?F\n var fullAtLeastOneRest = [\n new Option({ definition: atLeastOneProd.definition })\n ].concat(currRest, prevRest);\n this.walk(atLeastOneProd, fullAtLeastOneRest);\n };\n RestWalker.prototype.walkAtLeastOneSep = function (atLeastOneSepProd, currRest, prevRest) {\n // ABC DE(,DE)* F => after the (,DE)+ the rest is (,DE)?F\n var fullAtLeastOneSepRest = restForRepetitionWithSeparator(atLeastOneSepProd, currRest, prevRest);\n this.walk(atLeastOneSepProd, fullAtLeastOneSepRest);\n };\n RestWalker.prototype.walkMany = function (manyProd, currRest, prevRest) {\n // ABC(DE)*F => after the (DE)* the rest is (DE)?F\n var fullManyRest = [\n new Option({ definition: manyProd.definition })\n ].concat(currRest, prevRest);\n this.walk(manyProd, fullManyRest);\n };\n RestWalker.prototype.walkManySep = function (manySepProd, currRest, prevRest) {\n // ABC (DE(,DE)*)? F => after the (,DE)* the rest is (,DE)?F\n var fullManySepRest = restForRepetitionWithSeparator(manySepProd, currRest, prevRest);\n this.walk(manySepProd, fullManySepRest);\n };\n RestWalker.prototype.walkOr = function (orProd, currRest, prevRest) {\n var _this = this;\n // ABC(D|E|F)G => when finding the (D|E|F) the rest is G\n var fullOrRest = currRest.concat(prevRest);\n // walk all different alternatives\n forEach(orProd.definition, function (alt) {\n // wrapping each alternative in a single definition wrapper\n // to avoid errors in computing the rest of that alternative in the invocation to computeInProdFollows\n // (otherwise for OR([alt1,alt2]) alt2 will be considered in 'rest' of alt1\n var prodWrapper = new Alternative({ definition: [alt] });\n _this.walk(prodWrapper, fullOrRest);\n });\n };\n return RestWalker;\n}());\nexport { RestWalker };\nfunction restForRepetitionWithSeparator(repSepProd, currRest, prevRest) {\n var repSepRest = [\n new Option({\n definition: [new Terminal({ terminalType: repSepProd.separator })].concat(repSepProd.definition)\n })\n ];\n var fullRepSepRest = repSepRest.concat(currRest, prevRest);\n return fullRepSepRest;\n}\n//# sourceMappingURL=rest.js.map","import { Alternation, Alternative, NonTerminal, Option, Repetition, RepetitionMandatory, RepetitionMandatoryWithSeparator, RepetitionWithSeparator, Rule, Terminal } from \"./gast_public\";\nvar GAstVisitor = /** @class */ (function () {\n function GAstVisitor() {\n }\n GAstVisitor.prototype.visit = function (node) {\n var nodeAny = node;\n switch (nodeAny.constructor) {\n case NonTerminal:\n return this.visitNonTerminal(nodeAny);\n case Alternative:\n return this.visitAlternative(nodeAny);\n case Option:\n return this.visitOption(nodeAny);\n case RepetitionMandatory:\n return this.visitRepetitionMandatory(nodeAny);\n case RepetitionMandatoryWithSeparator:\n return this.visitRepetitionMandatoryWithSeparator(nodeAny);\n case RepetitionWithSeparator:\n return this.visitRepetitionWithSeparator(nodeAny);\n case Repetition:\n return this.visitRepetition(nodeAny);\n case Alternation:\n return this.visitAlternation(nodeAny);\n case Terminal:\n return this.visitTerminal(nodeAny);\n case Rule:\n return this.visitRule(nodeAny);\n /* istanbul ignore next */\n default:\n throw Error(\"non exhaustive match\");\n }\n };\n GAstVisitor.prototype.visitNonTerminal = function (node) { };\n GAstVisitor.prototype.visitAlternative = function (node) { };\n GAstVisitor.prototype.visitOption = function (node) { };\n GAstVisitor.prototype.visitRepetition = function (node) { };\n GAstVisitor.prototype.visitRepetitionMandatory = function (node) { };\n GAstVisitor.prototype.visitRepetitionMandatoryWithSeparator = function (node) { };\n GAstVisitor.prototype.visitRepetitionWithSeparator = function (node) { };\n GAstVisitor.prototype.visitAlternation = function (node) { };\n GAstVisitor.prototype.visitTerminal = function (node) { };\n GAstVisitor.prototype.visitRule = function (node) { };\n return GAstVisitor;\n}());\nexport { GAstVisitor };\n//# sourceMappingURL=gast_visitor_public.js.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { contains, every, has, some } from \"../../../utils/utils\";\nimport { AbstractProduction, Alternation, Alternative, NonTerminal, Option, Repetition, RepetitionMandatory, RepetitionMandatoryWithSeparator, RepetitionWithSeparator, Rule, Terminal } from \"./gast_public\";\nimport { GAstVisitor } from \"./gast_visitor_public\";\nexport function isSequenceProd(prod) {\n return (prod instanceof Alternative ||\n prod instanceof Option ||\n prod instanceof Repetition ||\n prod instanceof RepetitionMandatory ||\n prod instanceof RepetitionMandatoryWithSeparator ||\n prod instanceof RepetitionWithSeparator ||\n prod instanceof Terminal ||\n prod instanceof Rule);\n}\nexport function isOptionalProd(prod, alreadyVisited) {\n if (alreadyVisited === void 0) { alreadyVisited = []; }\n var isDirectlyOptional = prod instanceof Option ||\n prod instanceof Repetition ||\n prod instanceof RepetitionWithSeparator;\n if (isDirectlyOptional) {\n return true;\n }\n // note that this can cause infinite loop if one optional empty TOP production has a cyclic dependency with another\n // empty optional top rule\n // may be indirectly optional ((A?B?C?) | (D?E?F?))\n if (prod instanceof Alternation) {\n // for OR its enough for just one of the alternatives to be optional\n return some(prod.definition, function (subProd) {\n return isOptionalProd(subProd, alreadyVisited);\n });\n }\n else if (prod instanceof NonTerminal && contains(alreadyVisited, prod)) {\n // avoiding stack overflow due to infinite recursion\n return false;\n }\n else if (prod instanceof AbstractProduction) {\n if (prod instanceof NonTerminal) {\n alreadyVisited.push(prod);\n }\n return every(prod.definition, function (subProd) {\n return isOptionalProd(subProd, alreadyVisited);\n });\n }\n else {\n return false;\n }\n}\nexport function isBranchingProd(prod) {\n return prod instanceof Alternation;\n}\nexport function getProductionDslName(prod) {\n /* istanbul ignore else */\n if (prod instanceof NonTerminal) {\n return \"SUBRULE\";\n }\n else if (prod instanceof Option) {\n return \"OPTION\";\n }\n else if (prod instanceof Alternation) {\n return \"OR\";\n }\n else if (prod instanceof RepetitionMandatory) {\n return \"AT_LEAST_ONE\";\n }\n else if (prod instanceof RepetitionMandatoryWithSeparator) {\n return \"AT_LEAST_ONE_SEP\";\n }\n else if (prod instanceof RepetitionWithSeparator) {\n return \"MANY_SEP\";\n }\n else if (prod instanceof Repetition) {\n return \"MANY\";\n }\n else if (prod instanceof Terminal) {\n return \"CONSUME\";\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n}\nvar DslMethodsCollectorVisitor = /** @class */ (function (_super) {\n __extends(DslMethodsCollectorVisitor, _super);\n function DslMethodsCollectorVisitor() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n // A minus is never valid in an identifier name\n _this.separator = \"-\";\n _this.dslMethods = {\n option: [],\n alternation: [],\n repetition: [],\n repetitionWithSeparator: [],\n repetitionMandatory: [],\n repetitionMandatoryWithSeparator: []\n };\n return _this;\n }\n DslMethodsCollectorVisitor.prototype.reset = function () {\n this.dslMethods = {\n option: [],\n alternation: [],\n repetition: [],\n repetitionWithSeparator: [],\n repetitionMandatory: [],\n repetitionMandatoryWithSeparator: []\n };\n };\n DslMethodsCollectorVisitor.prototype.visitTerminal = function (terminal) {\n var key = terminal.terminalType.name + this.separator + \"Terminal\";\n if (!has(this.dslMethods, key)) {\n this.dslMethods[key] = [];\n }\n this.dslMethods[key].push(terminal);\n };\n DslMethodsCollectorVisitor.prototype.visitNonTerminal = function (subrule) {\n var key = subrule.nonTerminalName + this.separator + \"Terminal\";\n if (!has(this.dslMethods, key)) {\n this.dslMethods[key] = [];\n }\n this.dslMethods[key].push(subrule);\n };\n DslMethodsCollectorVisitor.prototype.visitOption = function (option) {\n this.dslMethods.option.push(option);\n };\n DslMethodsCollectorVisitor.prototype.visitRepetitionWithSeparator = function (manySep) {\n this.dslMethods.repetitionWithSeparator.push(manySep);\n };\n DslMethodsCollectorVisitor.prototype.visitRepetitionMandatory = function (atLeastOne) {\n this.dslMethods.repetitionMandatory.push(atLeastOne);\n };\n DslMethodsCollectorVisitor.prototype.visitRepetitionMandatoryWithSeparator = function (atLeastOneSep) {\n this.dslMethods.repetitionMandatoryWithSeparator.push(atLeastOneSep);\n };\n DslMethodsCollectorVisitor.prototype.visitRepetition = function (many) {\n this.dslMethods.repetition.push(many);\n };\n DslMethodsCollectorVisitor.prototype.visitAlternation = function (or) {\n this.dslMethods.alternation.push(or);\n };\n return DslMethodsCollectorVisitor;\n}(GAstVisitor));\nexport { DslMethodsCollectorVisitor };\nvar collectorVisitor = new DslMethodsCollectorVisitor();\nexport function collectMethods(rule) {\n collectorVisitor.reset();\n rule.accept(collectorVisitor);\n var dslMethods = collectorVisitor.dslMethods;\n // avoid uncleaned references\n collectorVisitor.reset();\n return dslMethods;\n}\n//# sourceMappingURL=gast.js.map","import { uniq, map, flatten } from \"../../utils/utils\";\nimport { NonTerminal, Terminal } from \"./gast/gast_public\";\nimport { isBranchingProd, isOptionalProd, isSequenceProd } from \"./gast/gast\";\nexport function first(prod) {\n /* istanbul ignore else */\n if (prod instanceof NonTerminal) {\n // this could in theory cause infinite loops if\n // (1) prod A refs prod B.\n // (2) prod B refs prod A\n // (3) AB can match the empty set\n // in other words a cycle where everything is optional so the first will keep\n // looking ahead for the next optional part and will never exit\n // currently there is no safeguard for this unique edge case because\n // (1) not sure a grammar in which this can happen is useful for anything (productive)\n return first(prod.referencedRule);\n }\n else if (prod instanceof Terminal) {\n return firstForTerminal(prod);\n }\n else if (isSequenceProd(prod)) {\n return firstForSequence(prod);\n }\n else if (isBranchingProd(prod)) {\n return firstForBranching(prod);\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n}\nexport function firstForSequence(prod) {\n var firstSet = [];\n var seq = prod.definition;\n var nextSubProdIdx = 0;\n var hasInnerProdsRemaining = seq.length > nextSubProdIdx;\n var currSubProd;\n // so we enter the loop at least once (if the definition is not empty\n var isLastInnerProdOptional = true;\n // scan a sequence until it's end or until we have found a NONE optional production in it\n while (hasInnerProdsRemaining && isLastInnerProdOptional) {\n currSubProd = seq[nextSubProdIdx];\n isLastInnerProdOptional = isOptionalProd(currSubProd);\n firstSet = firstSet.concat(first(currSubProd));\n nextSubProdIdx = nextSubProdIdx + 1;\n hasInnerProdsRemaining = seq.length > nextSubProdIdx;\n }\n return uniq(firstSet);\n}\nexport function firstForBranching(prod) {\n var allAlternativesFirsts = map(prod.definition, function (innerProd) {\n return first(innerProd);\n });\n return uniq(flatten(allAlternativesFirsts));\n}\nexport function firstForTerminal(terminal) {\n return [terminal.terminalType];\n}\n//# sourceMappingURL=first.js.map","// TODO: can this be removed? where is it used?\nexport var IN = \"_~IN~_\";\n//# sourceMappingURL=constants.js.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { RestWalker } from \"./rest\";\nimport { first } from \"./first\";\nimport { assign, forEach } from \"../../utils/utils\";\nimport { IN } from \"../constants\";\nimport { Alternative } from \"./gast/gast_public\";\n// This ResyncFollowsWalker computes all of the follows required for RESYNC\n// (skipping reference production).\nvar ResyncFollowsWalker = /** @class */ (function (_super) {\n __extends(ResyncFollowsWalker, _super);\n function ResyncFollowsWalker(topProd) {\n var _this = _super.call(this) || this;\n _this.topProd = topProd;\n _this.follows = {};\n return _this;\n }\n ResyncFollowsWalker.prototype.startWalking = function () {\n this.walk(this.topProd);\n return this.follows;\n };\n ResyncFollowsWalker.prototype.walkTerminal = function (terminal, currRest, prevRest) {\n // do nothing! just like in the public sector after 13:00\n };\n ResyncFollowsWalker.prototype.walkProdRef = function (refProd, currRest, prevRest) {\n var followName = buildBetweenProdsFollowPrefix(refProd.referencedRule, refProd.idx) +\n this.topProd.name;\n var fullRest = currRest.concat(prevRest);\n var restProd = new Alternative({ definition: fullRest });\n var t_in_topProd_follows = first(restProd);\n this.follows[followName] = t_in_topProd_follows;\n };\n return ResyncFollowsWalker;\n}(RestWalker));\nexport { ResyncFollowsWalker };\nexport function computeAllProdsFollows(topProductions) {\n var reSyncFollows = {};\n forEach(topProductions, function (topProd) {\n var currRefsFollow = new ResyncFollowsWalker(topProd).startWalking();\n assign(reSyncFollows, currRefsFollow);\n });\n return reSyncFollows;\n}\nexport function buildBetweenProdsFollowPrefix(inner, occurenceInParent) {\n return inner.name + occurenceInParent + IN;\n}\nexport function buildInProdFollowPrefix(terminal) {\n var terminalName = terminal.terminalType.name;\n return terminalName + terminal.idx + IN;\n}\n//# sourceMappingURL=follow.js.map","import { hasTokenLabel, tokenLabel } from \"../scan/tokens_public\";\nimport * as utils from \"../utils/utils\";\nimport { first, map, reduce } from \"../utils/utils\";\nimport { NonTerminal, Rule, Terminal } from \"./grammar/gast/gast_public\";\nimport { getProductionDslName } from \"./grammar/gast/gast\";\nexport var defaultParserErrorProvider = {\n buildMismatchTokenMessage: function (_a) {\n var expected = _a.expected, actual = _a.actual, previous = _a.previous, ruleName = _a.ruleName;\n var hasLabel = hasTokenLabel(expected);\n var expectedMsg = hasLabel\n ? \"--> \" + tokenLabel(expected) + \" <--\"\n : \"token of type --> \" + expected.name + \" <--\";\n var msg = \"Expecting \" + expectedMsg + \" but found --> '\" + actual.image + \"' <--\";\n return msg;\n },\n buildNotAllInputParsedMessage: function (_a) {\n var firstRedundant = _a.firstRedundant, ruleName = _a.ruleName;\n return \"Redundant input, expecting EOF but found: \" + firstRedundant.image;\n },\n buildNoViableAltMessage: function (_a) {\n var expectedPathsPerAlt = _a.expectedPathsPerAlt, actual = _a.actual, previous = _a.previous, customUserDescription = _a.customUserDescription, ruleName = _a.ruleName;\n var errPrefix = \"Expecting: \";\n // TODO: issue: No Viable Alternative Error may have incomplete details. #502\n var actualText = first(actual).image;\n var errSuffix = \"\\nbut found: '\" + actualText + \"'\";\n if (customUserDescription) {\n return errPrefix + customUserDescription + errSuffix;\n }\n else {\n var allLookAheadPaths = reduce(expectedPathsPerAlt, function (result, currAltPaths) { return result.concat(currAltPaths); }, []);\n var nextValidTokenSequences = map(allLookAheadPaths, function (currPath) {\n return \"[\" + map(currPath, function (currTokenType) { return tokenLabel(currTokenType); }).join(\", \") + \"]\";\n });\n var nextValidSequenceItems = map(nextValidTokenSequences, function (itemMsg, idx) { return \" \" + (idx + 1) + \". \" + itemMsg; });\n var calculatedDescription = \"one of these possible Token sequences:\\n\" + nextValidSequenceItems.join(\"\\n\");\n return errPrefix + calculatedDescription + errSuffix;\n }\n },\n buildEarlyExitMessage: function (_a) {\n var expectedIterationPaths = _a.expectedIterationPaths, actual = _a.actual, customUserDescription = _a.customUserDescription, ruleName = _a.ruleName;\n var errPrefix = \"Expecting: \";\n // TODO: issue: No Viable Alternative Error may have incomplete details. #502\n var actualText = first(actual).image;\n var errSuffix = \"\\nbut found: '\" + actualText + \"'\";\n if (customUserDescription) {\n return errPrefix + customUserDescription + errSuffix;\n }\n else {\n var nextValidTokenSequences = map(expectedIterationPaths, function (currPath) {\n return \"[\" + map(currPath, function (currTokenType) { return tokenLabel(currTokenType); }).join(\",\") + \"]\";\n });\n var calculatedDescription = \"expecting at least one iteration which starts with one of these possible Token sequences::\\n \" +\n (\"<\" + nextValidTokenSequences.join(\" ,\") + \">\");\n return errPrefix + calculatedDescription + errSuffix;\n }\n }\n};\nObject.freeze(defaultParserErrorProvider);\nexport var defaultGrammarResolverErrorProvider = {\n buildRuleNotFoundError: function (topLevelRule, undefinedRule) {\n var msg = \"Invalid grammar, reference to a rule which is not defined: ->\" +\n undefinedRule.nonTerminalName +\n \"<-\\n\" +\n \"inside top level rule: ->\" +\n topLevelRule.name +\n \"<-\";\n return msg;\n }\n};\nexport var defaultGrammarValidatorErrorProvider = {\n buildDuplicateFoundError: function (topLevelRule, duplicateProds) {\n function getExtraProductionArgument(prod) {\n if (prod instanceof Terminal) {\n return prod.terminalType.name;\n }\n else if (prod instanceof NonTerminal) {\n return prod.nonTerminalName;\n }\n else {\n return \"\";\n }\n }\n var topLevelName = topLevelRule.name;\n var duplicateProd = first(duplicateProds);\n var index = duplicateProd.idx;\n var dslName = getProductionDslName(duplicateProd);\n var extraArgument = getExtraProductionArgument(duplicateProd);\n var hasExplicitIndex = index > 0;\n 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 \";\n // white space trimming time! better to trim afterwards as it allows to use WELL formatted multi line template strings...\n msg = msg.replace(/[ \\t]+/g, \" \");\n msg = msg.replace(/\\s\\s+/g, \"\\n\");\n return msg;\n },\n buildNamespaceConflictError: function (rule) {\n var errMsg = \"Namespace conflict found in grammar.\\n\" +\n (\"The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <\" + rule.name + \">.\\n\") +\n \"To resolve this make sure each Terminal and Non-Terminal names are unique\\n\" +\n \"This is easy to accomplish by using the convention that Terminal names start with an uppercase letter\\n\" +\n \"and Non-Terminal names start with a lower case letter.\";\n return errMsg;\n },\n buildAlternationPrefixAmbiguityError: function (options) {\n var pathMsg = map(options.prefixPath, function (currTok) {\n return tokenLabel(currTok);\n }).join(\", \");\n var occurrence = options.alternation.idx === 0 ? \"\" : options.alternation.idx;\n var errMsg = \"Ambiguous alternatives: <\" + options.ambiguityIndices.join(\" ,\") + \"> due to common lookahead prefix\\n\" +\n (\"in inside <\" + options.topLevelRule.name + \"> Rule,\\n\") +\n (\"<\" + pathMsg + \"> may appears as a prefix path in all these alternatives.\\n\") +\n \"See: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\\n\" +\n \"For Further details.\";\n return errMsg;\n },\n buildAlternationAmbiguityError: function (options) {\n var pathMsg = map(options.prefixPath, function (currtok) {\n return tokenLabel(currtok);\n }).join(\", \");\n var occurrence = options.alternation.idx === 0 ? \"\" : options.alternation.idx;\n var currMessage = \"Ambiguous Alternatives Detected: <\" + options.ambiguityIndices.join(\" ,\") + \"> in \" +\n (\" inside <\" + options.topLevelRule.name + \"> Rule,\\n\") +\n (\"<\" + pathMsg + \"> may appears as a prefix path in all these alternatives.\\n\");\n currMessage =\n currMessage +\n \"See: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\\n\" +\n \"For Further details.\";\n return currMessage;\n },\n buildEmptyRepetitionError: function (options) {\n var dslName = getProductionDslName(options.repetition);\n if (options.repetition.idx !== 0) {\n dslName += options.repetition.idx;\n }\n var errMsg = \"The repetition <\" + dslName + \"> within Rule <\" + options.topLevelRule.name + \"> can never consume any tokens.\\n\" +\n \"This could lead to an infinite loop.\";\n return errMsg;\n },\n buildTokenNameError: function (options) {\n var tokTypeName = options.tokenType.name;\n var errMsg = \"Invalid Grammar Token name: ->\" + tokTypeName + \"<- it must match the pattern: ->\" + options.expectedPattern.toString() + \"<-\";\n return errMsg;\n },\n buildEmptyAlternationError: function (options) {\n var errMsg = \"Ambiguous empty alternative: <\" + (options.emptyChoiceIdx + 1) + \">\" +\n (\" in inside <\" + options.topLevelRule.name + \"> Rule.\\n\") +\n \"Only the last alternative may be an empty alternative.\";\n return errMsg;\n },\n buildTooManyAlternativesError: function (options) {\n var errMsg = \"An Alternation cannot have more than 256 alternatives:\\n\" +\n (\" inside <\" + options.topLevelRule.name + \"> Rule.\\n has \" + (options.alternation.definition.length + 1) + \" alternatives.\");\n return errMsg;\n },\n buildLeftRecursionError: function (options) {\n var ruleName = options.topLevelRule.name;\n var pathNames = utils.map(options.leftRecursionPath, function (currRule) { return currRule.name; });\n var leftRecursivePath = ruleName + \" --> \" + pathNames\n .concat([ruleName])\n .join(\" --> \");\n var errMsg = \"Left Recursion found in grammar.\\n\" +\n (\"rule: <\" + ruleName + \"> can be invoked from itself (directly or indirectly)\\n\") +\n (\"without consuming any Tokens. The grammar path that causes this is: \\n \" + leftRecursivePath + \"\\n\") +\n \" To fix this refactor your grammar to remove the left recursion.\\n\" +\n \"see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.\";\n return errMsg;\n },\n buildInvalidRuleNameError: function (options) {\n var ruleName = options.topLevelRule.name;\n var expectedPatternString = options.expectedPattern.toString();\n var errMsg = \"Invalid grammar rule name: ->\" + ruleName + \"<- it must match the pattern: ->\" + expectedPatternString + \"<-\";\n return errMsg;\n },\n buildDuplicateRuleNameError: function (options) {\n var ruleName;\n if (options.topLevelRule instanceof Rule) {\n ruleName = options.topLevelRule.name;\n }\n else {\n ruleName = options.topLevelRule;\n }\n var errMsg = \"Duplicate definition, rule: ->\" + ruleName + \"<- is already defined in the grammar: ->\" + options.grammarName + \"<-\";\n return errMsg;\n }\n};\n//# sourceMappingURL=errors_public.js.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { ParserDefinitionErrorType } from \"../parser/parser\";\nimport { forEach, values } from \"../../utils/utils\";\nimport { GAstVisitor } from \"./gast/gast_visitor_public\";\nexport function resolveGrammar(topLevels, errMsgProvider) {\n var refResolver = new GastRefResolverVisitor(topLevels, errMsgProvider);\n refResolver.resolveRefs();\n return refResolver.errors;\n}\nvar GastRefResolverVisitor = /** @class */ (function (_super) {\n __extends(GastRefResolverVisitor, _super);\n function GastRefResolverVisitor(nameToTopRule, errMsgProvider) {\n var _this = _super.call(this) || this;\n _this.nameToTopRule = nameToTopRule;\n _this.errMsgProvider = errMsgProvider;\n _this.errors = [];\n return _this;\n }\n GastRefResolverVisitor.prototype.resolveRefs = function () {\n var _this = this;\n forEach(values(this.nameToTopRule), function (prod) {\n _this.currTopLevel = prod;\n prod.accept(_this);\n });\n };\n GastRefResolverVisitor.prototype.visitNonTerminal = function (node) {\n var ref = this.nameToTopRule[node.nonTerminalName];\n if (!ref) {\n var msg = this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel, node);\n this.errors.push({\n message: msg,\n type: ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,\n ruleName: this.currTopLevel.name,\n unresolvedRefName: node.nonTerminalName\n });\n }\n else {\n node.referencedRule = ref;\n }\n };\n return GastRefResolverVisitor;\n}(GAstVisitor));\nexport { GastRefResolverVisitor };\n//# sourceMappingURL=resolver.js.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { RestWalker } from \"./rest\";\nimport { cloneArr, drop, dropRight, first as _first, forEach, isEmpty, last } from \"../../utils/utils\";\nimport { first } from \"./first\";\nimport { Alternation, Alternative, NonTerminal, Option, Repetition, RepetitionMandatory, RepetitionMandatoryWithSeparator, RepetitionWithSeparator, Rule, Terminal } from \"./gast/gast_public\";\nvar AbstractNextPossibleTokensWalker = /** @class */ (function (_super) {\n __extends(AbstractNextPossibleTokensWalker, _super);\n function AbstractNextPossibleTokensWalker(topProd, path) {\n var _this = _super.call(this) || this;\n _this.topProd = topProd;\n _this.path = path;\n _this.possibleTokTypes = [];\n _this.nextProductionName = \"\";\n _this.nextProductionOccurrence = 0;\n _this.found = false;\n _this.isAtEndOfPath = false;\n return _this;\n }\n AbstractNextPossibleTokensWalker.prototype.startWalking = function () {\n this.found = false;\n if (this.path.ruleStack[0] !== this.topProd.name) {\n throw Error(\"The path does not start with the walker's top Rule!\");\n }\n // immutable for the win\n this.ruleStack = cloneArr(this.path.ruleStack).reverse(); // intelij bug requires assertion\n this.occurrenceStack = cloneArr(this.path.occurrenceStack).reverse(); // intelij bug requires assertion\n // already verified that the first production is valid, we now seek the 2nd production\n this.ruleStack.pop();\n this.occurrenceStack.pop();\n this.updateExpectedNext();\n this.walk(this.topProd);\n return this.possibleTokTypes;\n };\n AbstractNextPossibleTokensWalker.prototype.walk = function (prod, prevRest) {\n if (prevRest === void 0) { prevRest = []; }\n // stop scanning once we found the path\n if (!this.found) {\n _super.prototype.walk.call(this, prod, prevRest);\n }\n };\n AbstractNextPossibleTokensWalker.prototype.walkProdRef = function (refProd, currRest, prevRest) {\n // found the next production, need to keep walking in it\n if (refProd.referencedRule.name === this.nextProductionName &&\n refProd.idx === this.nextProductionOccurrence) {\n var fullRest = currRest.concat(prevRest);\n this.updateExpectedNext();\n this.walk(refProd.referencedRule, fullRest);\n }\n };\n AbstractNextPossibleTokensWalker.prototype.updateExpectedNext = function () {\n // need to consume the Terminal\n if (isEmpty(this.ruleStack)) {\n // must reset nextProductionXXX to avoid walking down another Top Level production while what we are\n // really seeking is the last Terminal...\n this.nextProductionName = \"\";\n this.nextProductionOccurrence = 0;\n this.isAtEndOfPath = true;\n }\n else {\n this.nextProductionName = this.ruleStack.pop();\n this.nextProductionOccurrence = this.occurrenceStack.pop();\n }\n };\n return AbstractNextPossibleTokensWalker;\n}(RestWalker));\nexport { AbstractNextPossibleTokensWalker };\nvar NextAfterTokenWalker = /** @class */ (function (_super) {\n __extends(NextAfterTokenWalker, _super);\n function NextAfterTokenWalker(topProd, path) {\n var _this = _super.call(this, topProd, path) || this;\n _this.path = path;\n _this.nextTerminalName = \"\";\n _this.nextTerminalOccurrence = 0;\n _this.nextTerminalName = _this.path.lastTok.name;\n _this.nextTerminalOccurrence = _this.path.lastTokOccurrence;\n return _this;\n }\n NextAfterTokenWalker.prototype.walkTerminal = function (terminal, currRest, prevRest) {\n if (this.isAtEndOfPath &&\n terminal.terminalType.name === this.nextTerminalName &&\n terminal.idx === this.nextTerminalOccurrence &&\n !this.found) {\n var fullRest = currRest.concat(prevRest);\n var restProd = new Alternative({ definition: fullRest });\n this.possibleTokTypes = first(restProd);\n this.found = true;\n }\n };\n return NextAfterTokenWalker;\n}(AbstractNextPossibleTokensWalker));\nexport { NextAfterTokenWalker };\n/**\n * This walker only \"walks\" a single \"TOP\" level in the Grammar Ast, this means\n * it never \"follows\" production refs\n */\nvar AbstractNextTerminalAfterProductionWalker = /** @class */ (function (_super) {\n __extends(AbstractNextTerminalAfterProductionWalker, _super);\n function AbstractNextTerminalAfterProductionWalker(topRule, occurrence) {\n var _this = _super.call(this) || this;\n _this.topRule = topRule;\n _this.occurrence = occurrence;\n _this.result = {\n token: undefined,\n occurrence: undefined,\n isEndOfRule: undefined\n };\n return _this;\n }\n AbstractNextTerminalAfterProductionWalker.prototype.startWalking = function () {\n this.walk(this.topRule);\n return this.result;\n };\n return AbstractNextTerminalAfterProductionWalker;\n}(RestWalker));\nexport { AbstractNextTerminalAfterProductionWalker };\nvar NextTerminalAfterManyWalker = /** @class */ (function (_super) {\n __extends(NextTerminalAfterManyWalker, _super);\n function NextTerminalAfterManyWalker() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n NextTerminalAfterManyWalker.prototype.walkMany = function (manyProd, currRest, prevRest) {\n if (manyProd.idx === this.occurrence) {\n var firstAfterMany = _first(currRest.concat(prevRest));\n this.result.isEndOfRule = firstAfterMany === undefined;\n if (firstAfterMany instanceof Terminal) {\n this.result.token = firstAfterMany.terminalType;\n this.result.occurrence = firstAfterMany.idx;\n }\n }\n else {\n _super.prototype.walkMany.call(this, manyProd, currRest, prevRest);\n }\n };\n return NextTerminalAfterManyWalker;\n}(AbstractNextTerminalAfterProductionWalker));\nexport { NextTerminalAfterManyWalker };\nvar NextTerminalAfterManySepWalker = /** @class */ (function (_super) {\n __extends(NextTerminalAfterManySepWalker, _super);\n function NextTerminalAfterManySepWalker() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n NextTerminalAfterManySepWalker.prototype.walkManySep = function (manySepProd, currRest, prevRest) {\n if (manySepProd.idx === this.occurrence) {\n var firstAfterManySep = _first(currRest.concat(prevRest));\n this.result.isEndOfRule = firstAfterManySep === undefined;\n if (firstAfterManySep instanceof Terminal) {\n this.result.token = firstAfterManySep.terminalType;\n this.result.occurrence = firstAfterManySep.idx;\n }\n }\n else {\n _super.prototype.walkManySep.call(this, manySepProd, currRest, prevRest);\n }\n };\n return NextTerminalAfterManySepWalker;\n}(AbstractNextTerminalAfterProductionWalker));\nexport { NextTerminalAfterManySepWalker };\nvar NextTerminalAfterAtLeastOneWalker = /** @class */ (function (_super) {\n __extends(NextTerminalAfterAtLeastOneWalker, _super);\n function NextTerminalAfterAtLeastOneWalker() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n NextTerminalAfterAtLeastOneWalker.prototype.walkAtLeastOne = function (atLeastOneProd, currRest, prevRest) {\n if (atLeastOneProd.idx === this.occurrence) {\n var firstAfterAtLeastOne = _first(currRest.concat(prevRest));\n this.result.isEndOfRule = firstAfterAtLeastOne === undefined;\n if (firstAfterAtLeastOne instanceof Terminal) {\n this.result.token = firstAfterAtLeastOne.terminalType;\n this.result.occurrence = firstAfterAtLeastOne.idx;\n }\n }\n else {\n _super.prototype.walkAtLeastOne.call(this, atLeastOneProd, currRest, prevRest);\n }\n };\n return NextTerminalAfterAtLeastOneWalker;\n}(AbstractNextTerminalAfterProductionWalker));\nexport { NextTerminalAfterAtLeastOneWalker };\n// TODO: reduce code duplication in the AfterWalkers\nvar NextTerminalAfterAtLeastOneSepWalker = /** @class */ (function (_super) {\n __extends(NextTerminalAfterAtLeastOneSepWalker, _super);\n function NextTerminalAfterAtLeastOneSepWalker() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n NextTerminalAfterAtLeastOneSepWalker.prototype.walkAtLeastOneSep = function (atleastOneSepProd, currRest, prevRest) {\n if (atleastOneSepProd.idx === this.occurrence) {\n var firstAfterfirstAfterAtLeastOneSep = _first(currRest.concat(prevRest));\n this.result.isEndOfRule = firstAfterfirstAfterAtLeastOneSep === undefined;\n if (firstAfterfirstAfterAtLeastOneSep instanceof Terminal) {\n this.result.token = firstAfterfirstAfterAtLeastOneSep.terminalType;\n this.result.occurrence = firstAfterfirstAfterAtLeastOneSep.idx;\n }\n }\n else {\n _super.prototype.walkAtLeastOneSep.call(this, atleastOneSepProd, currRest, prevRest);\n }\n };\n return NextTerminalAfterAtLeastOneSepWalker;\n}(AbstractNextTerminalAfterProductionWalker));\nexport { NextTerminalAfterAtLeastOneSepWalker };\nexport function possiblePathsFrom(targetDef, maxLength, currPath) {\n if (currPath === void 0) { currPath = []; }\n // avoid side effects\n currPath = cloneArr(currPath);\n var result = [];\n var i = 0;\n // TODO: avoid inner funcs\n function remainingPathWith(nextDef) {\n return nextDef.concat(drop(targetDef, i + 1));\n }\n // TODO: avoid inner funcs\n function getAlternativesForProd(definition) {\n var alternatives = possiblePathsFrom(remainingPathWith(definition), maxLength, currPath);\n return result.concat(alternatives);\n }\n /**\n * Mandatory productions will halt the loop as the paths computed from their recursive calls will already contain the\n * following (rest) of the targetDef.\n *\n * For optional productions (Option/Repetition/...) the loop will continue to represent the paths that do not include the\n * the optional production.\n */\n while (currPath.length < maxLength && i < targetDef.length) {\n var prod = targetDef[i];\n /* istanbul ignore else */\n if (prod instanceof Alternative) {\n return getAlternativesForProd(prod.definition);\n }\n else if (prod instanceof NonTerminal) {\n return getAlternativesForProd(prod.definition);\n }\n else if (prod instanceof Option) {\n result = getAlternativesForProd(prod.definition);\n }\n else if (prod instanceof RepetitionMandatory) {\n var newDef = prod.definition.concat([\n new Repetition({\n definition: prod.definition\n })\n ]);\n return getAlternativesForProd(newDef);\n }\n else if (prod instanceof RepetitionMandatoryWithSeparator) {\n var newDef = [\n new Alternative({ definition: prod.definition }),\n new Repetition({\n definition: [new Terminal({ terminalType: prod.separator })].concat(prod.definition)\n })\n ];\n return getAlternativesForProd(newDef);\n }\n else if (prod instanceof RepetitionWithSeparator) {\n var newDef = prod.definition.concat([\n new Repetition({\n definition: [new Terminal({ terminalType: prod.separator })].concat(prod.definition)\n })\n ]);\n result = getAlternativesForProd(newDef);\n }\n else if (prod instanceof Repetition) {\n var newDef = prod.definition.concat([\n new Repetition({\n definition: prod.definition\n })\n ]);\n result = getAlternativesForProd(newDef);\n }\n else if (prod instanceof Alternation) {\n forEach(prod.definition, function (currAlt) {\n result = getAlternativesForProd(currAlt.definition);\n });\n return result;\n }\n else if (prod instanceof Terminal) {\n currPath.push(prod.terminalType);\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n i++;\n }\n result.push({\n partialPath: currPath,\n suffixDef: drop(targetDef, i)\n });\n return result;\n}\nexport function nextPossibleTokensAfter(initialDef, tokenVector, tokMatcher, maxLookAhead) {\n var EXIT_NON_TERMINAL = \"EXIT_NONE_TERMINAL\";\n // to avoid creating a new Array each time.\n var EXIT_NON_TERMINAL_ARR = [EXIT_NON_TERMINAL];\n var EXIT_ALTERNATIVE = \"EXIT_ALTERNATIVE\";\n var foundCompletePath = false;\n var tokenVectorLength = tokenVector.length;\n var minimalAlternativesIndex = tokenVectorLength - maxLookAhead - 1;\n var result = [];\n var possiblePaths = [];\n possiblePaths.push({\n idx: -1,\n def: initialDef,\n ruleStack: [],\n occurrenceStack: []\n });\n while (!isEmpty(possiblePaths)) {\n var currPath = possiblePaths.pop();\n // skip alternatives if no more results can be found (assuming deterministic grammar with fixed lookahead)\n if (currPath === EXIT_ALTERNATIVE) {\n if (foundCompletePath &&\n last(possiblePaths).idx <= minimalAlternativesIndex) {\n // remove irrelevant alternative\n possiblePaths.pop();\n }\n continue;\n }\n var currDef = currPath.def;\n var currIdx = currPath.idx;\n var currRuleStack = currPath.ruleStack;\n var currOccurrenceStack = currPath.occurrenceStack;\n // For Example: an empty path could exist in a valid grammar in the case of an EMPTY_ALT\n if (isEmpty(currDef)) {\n continue;\n }\n var prod = currDef[0];\n /* istanbul ignore else */\n if (prod === EXIT_NON_TERMINAL) {\n var nextPath = {\n idx: currIdx,\n def: drop(currDef),\n ruleStack: dropRight(currRuleStack),\n occurrenceStack: dropRight(currOccurrenceStack)\n };\n possiblePaths.push(nextPath);\n }\n else if (prod instanceof Terminal) {\n /* istanbul ignore else */\n if (currIdx < tokenVectorLength - 1) {\n var nextIdx = currIdx + 1;\n var actualToken = tokenVector[nextIdx];\n if (tokMatcher(actualToken, prod.terminalType)) {\n var nextPath = {\n idx: nextIdx,\n def: drop(currDef),\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n };\n possiblePaths.push(nextPath);\n }\n // end of the line\n }\n else if (currIdx === tokenVectorLength - 1) {\n // IGNORE ABOVE ELSE\n result.push({\n nextTokenType: prod.terminalType,\n nextTokenOccurrence: prod.idx,\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n });\n foundCompletePath = true;\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n }\n else if (prod instanceof NonTerminal) {\n var newRuleStack = cloneArr(currRuleStack);\n newRuleStack.push(prod.nonTerminalName);\n var newOccurrenceStack = cloneArr(currOccurrenceStack);\n newOccurrenceStack.push(prod.idx);\n var nextPath = {\n idx: currIdx,\n def: prod.definition.concat(EXIT_NON_TERMINAL_ARR, drop(currDef)),\n ruleStack: newRuleStack,\n occurrenceStack: newOccurrenceStack\n };\n possiblePaths.push(nextPath);\n }\n else if (prod instanceof Option) {\n // the order of alternatives is meaningful, FILO (Last path will be traversed first).\n var nextPathWithout = {\n idx: currIdx,\n def: drop(currDef),\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n };\n possiblePaths.push(nextPathWithout);\n // required marker to avoid backtracking paths whose higher priority alternatives already matched\n possiblePaths.push(EXIT_ALTERNATIVE);\n var nextPathWith = {\n idx: currIdx,\n def: prod.definition.concat(drop(currDef)),\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n };\n possiblePaths.push(nextPathWith);\n }\n else if (prod instanceof RepetitionMandatory) {\n // TODO:(THE NEW operators here take a while...) (convert once?)\n var secondIteration = new Repetition({\n definition: prod.definition,\n idx: prod.idx\n });\n var nextDef = prod.definition.concat([secondIteration], drop(currDef));\n var nextPath = {\n idx: currIdx,\n def: nextDef,\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n };\n possiblePaths.push(nextPath);\n }\n else if (prod instanceof RepetitionMandatoryWithSeparator) {\n // TODO:(THE NEW operators here take a while...) (convert once?)\n var separatorGast = new Terminal({\n terminalType: prod.separator\n });\n var secondIteration = new Repetition({\n definition: [separatorGast].concat(prod.definition),\n idx: prod.idx\n });\n var nextDef = prod.definition.concat([secondIteration], drop(currDef));\n var nextPath = {\n idx: currIdx,\n def: nextDef,\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n };\n possiblePaths.push(nextPath);\n }\n else if (prod instanceof RepetitionWithSeparator) {\n // the order of alternatives is meaningful, FILO (Last path will be traversed first).\n var nextPathWithout = {\n idx: currIdx,\n def: drop(currDef),\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n };\n possiblePaths.push(nextPathWithout);\n // required marker to avoid backtracking paths whose higher priority alternatives already matched\n possiblePaths.push(EXIT_ALTERNATIVE);\n var separatorGast = new Terminal({\n terminalType: prod.separator\n });\n var nthRepetition = new Repetition({\n definition: [separatorGast].concat(prod.definition),\n idx: prod.idx\n });\n var nextDef = prod.definition.concat([nthRepetition], drop(currDef));\n var nextPathWith = {\n idx: currIdx,\n def: nextDef,\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n };\n possiblePaths.push(nextPathWith);\n }\n else if (prod instanceof Repetition) {\n // the order of alternatives is meaningful, FILO (Last path will be traversed first).\n var nextPathWithout = {\n idx: currIdx,\n def: drop(currDef),\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n };\n possiblePaths.push(nextPathWithout);\n // required marker to avoid backtracking paths whose higher priority alternatives already matched\n possiblePaths.push(EXIT_ALTERNATIVE);\n // TODO: an empty repetition will cause infinite loops here, will the parser detect this in selfAnalysis?\n var nthRepetition = new Repetition({\n definition: prod.definition,\n idx: prod.idx\n });\n var nextDef = prod.definition.concat([nthRepetition], drop(currDef));\n var nextPathWith = {\n idx: currIdx,\n def: nextDef,\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n };\n possiblePaths.push(nextPathWith);\n }\n else if (prod instanceof Alternation) {\n // the order of alternatives is meaningful, FILO (Last path will be traversed first).\n for (var i = prod.definition.length - 1; i >= 0; i--) {\n var currAlt = prod.definition[i];\n var currAltPath = {\n idx: currIdx,\n def: currAlt.definition.concat(drop(currDef)),\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n };\n possiblePaths.push(currAltPath);\n possiblePaths.push(EXIT_ALTERNATIVE);\n }\n }\n else if (prod instanceof Alternative) {\n possiblePaths.push({\n idx: currIdx,\n def: prod.definition.concat(drop(currDef)),\n ruleStack: currRuleStack,\n occurrenceStack: currOccurrenceStack\n });\n }\n else if (prod instanceof Rule) {\n // last because we should only encounter at most a single one of these per invocation.\n possiblePaths.push(expandTopLevelRule(prod, currIdx, currRuleStack, currOccurrenceStack));\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n }\n return result;\n}\nfunction expandTopLevelRule(topRule, currIdx, currRuleStack, currOccurrenceStack) {\n var newRuleStack = cloneArr(currRuleStack);\n newRuleStack.push(topRule.name);\n var newCurrOccurrenceStack = cloneArr(currOccurrenceStack);\n // top rule is always assumed to have been called with occurrence index 1\n newCurrOccurrenceStack.push(1);\n return {\n idx: currIdx,\n def: topRule.definition,\n ruleStack: newRuleStack,\n occurrenceStack: newCurrOccurrenceStack\n };\n}\n//# sourceMappingURL=interpreter.js.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { map, reduce, every, isEmpty, flatten, forEach, has } from \"../../utils/utils\";\nimport { possiblePathsFrom } from \"./interpreter\";\nimport { RestWalker } from \"./rest\";\nimport { tokenStructuredMatcher, tokenStructuredMatcherNoCategories } from \"../../scan/tokens\";\nimport { Alternation, Alternative as AlternativeGAST, Option, Repetition, RepetitionMandatory, RepetitionMandatoryWithSeparator, RepetitionWithSeparator } from \"./gast/gast_public\";\nimport { GAstVisitor } from \"./gast/gast_visitor_public\";\nexport var PROD_TYPE;\n(function (PROD_TYPE) {\n PROD_TYPE[PROD_TYPE[\"OPTION\"] = 0] = \"OPTION\";\n PROD_TYPE[PROD_TYPE[\"REPETITION\"] = 1] = \"REPETITION\";\n PROD_TYPE[PROD_TYPE[\"REPETITION_MANDATORY\"] = 2] = \"REPETITION_MANDATORY\";\n PROD_TYPE[PROD_TYPE[\"REPETITION_MANDATORY_WITH_SEPARATOR\"] = 3] = \"REPETITION_MANDATORY_WITH_SEPARATOR\";\n PROD_TYPE[PROD_TYPE[\"REPETITION_WITH_SEPARATOR\"] = 4] = \"REPETITION_WITH_SEPARATOR\";\n PROD_TYPE[PROD_TYPE[\"ALTERNATION\"] = 5] = \"ALTERNATION\";\n})(PROD_TYPE || (PROD_TYPE = {}));\nexport function getProdType(prod) {\n /* istanbul ignore else */\n if (prod instanceof Option) {\n return PROD_TYPE.OPTION;\n }\n else if (prod instanceof Repetition) {\n return PROD_TYPE.REPETITION;\n }\n else if (prod instanceof RepetitionMandatory) {\n return PROD_TYPE.REPETITION_MANDATORY;\n }\n else if (prod instanceof RepetitionMandatoryWithSeparator) {\n return PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR;\n }\n else if (prod instanceof RepetitionWithSeparator) {\n return PROD_TYPE.REPETITION_WITH_SEPARATOR;\n }\n else if (prod instanceof Alternation) {\n return PROD_TYPE.ALTERNATION;\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n}\nexport function buildLookaheadFuncForOr(occurrence, ruleGrammar, maxLookahead, hasPredicates, dynamicTokensEnabled, laFuncBuilder) {\n var lookAheadPaths = getLookaheadPathsForOr(occurrence, ruleGrammar, maxLookahead);\n var tokenMatcher = areTokenCategoriesNotUsed(lookAheadPaths)\n ? tokenStructuredMatcherNoCategories\n : tokenStructuredMatcher;\n return laFuncBuilder(lookAheadPaths, hasPredicates, tokenMatcher, dynamicTokensEnabled);\n}\n/**\n * When dealing with an Optional production (OPTION/MANY/2nd iteration of AT_LEAST_ONE/...) we need to compare\n * the lookahead \"inside\" the production and the lookahead immediately \"after\" it in the same top level rule (context free).\n *\n * Example: given a production:\n * ABC(DE)?DF\n *\n * The optional '(DE)?' should only be entered if we see 'DE'. a single Token 'D' is not sufficient to distinguish between the two\n * alternatives.\n *\n * @returns A Lookahead function which will return true IFF the parser should parse the Optional production.\n */\nexport function buildLookaheadFuncForOptionalProd(occurrence, ruleGrammar, k, dynamicTokensEnabled, prodType, lookaheadBuilder) {\n var lookAheadPaths = getLookaheadPathsForOptionalProd(occurrence, ruleGrammar, prodType, k);\n var tokenMatcher = areTokenCategoriesNotUsed(lookAheadPaths)\n ? tokenStructuredMatcherNoCategories\n : tokenStructuredMatcher;\n return lookaheadBuilder(lookAheadPaths[0], tokenMatcher, dynamicTokensEnabled);\n}\nexport function buildAlternativesLookAheadFunc(alts, hasPredicates, tokenMatcher, dynamicTokensEnabled) {\n var numOfAlts = alts.length;\n var areAllOneTokenLookahead = every(alts, function (currAlt) {\n return every(currAlt, function (currPath) {\n return currPath.length === 1;\n });\n });\n // This version takes into account the predicates as well.\n if (hasPredicates) {\n /**\n * @returns {number} - The chosen alternative index\n */\n return function (orAlts) {\n // unfortunately the predicates must be extracted every single time\n // as they cannot be cached due to references to parameters(vars) which are no longer valid.\n // note that in the common case of no predicates, no cpu time will be wasted on this (see else block)\n var predicates = map(orAlts, function (currAlt) { return currAlt.GATE; });\n for (var t = 0; t < numOfAlts; t++) {\n var currAlt = alts[t];\n var currNumOfPaths = currAlt.length;\n var currPredicate = predicates[t];\n if (currPredicate !== undefined && currPredicate.call(this) === false) {\n // if the predicate does not match there is no point in checking the paths\n continue;\n }\n nextPath: for (var j = 0; j < currNumOfPaths; j++) {\n var currPath = currAlt[j];\n var currPathLength = currPath.length;\n for (var i = 0; i < currPathLength; i++) {\n var nextToken = this.LA(i + 1);\n if (tokenMatcher(nextToken, currPath[i]) === false) {\n // mismatch in current path\n // try the next pth\n continue nextPath;\n }\n }\n // found a full path that matches.\n // this will also work for an empty ALT as the loop will be skipped\n return t;\n }\n // none of the paths for the current alternative matched\n // try the next alternative\n }\n // none of the alternatives could be matched\n return undefined;\n };\n }\n else if (areAllOneTokenLookahead && !dynamicTokensEnabled) {\n // optimized (common) case of all the lookaheads paths requiring only\n // a single token lookahead. These Optimizations cannot work if dynamically defined Tokens are used.\n var singleTokenAlts = map(alts, function (currAlt) {\n return flatten(currAlt);\n });\n var choiceToAlt_1 = reduce(singleTokenAlts, function (result, currAlt, idx) {\n forEach(currAlt, function (currTokType) {\n if (!has(result, currTokType.tokenTypeIdx)) {\n result[currTokType.tokenTypeIdx] = idx;\n }\n forEach(currTokType.categoryMatches, function (currExtendingType) {\n if (!has(result, currExtendingType)) {\n result[currExtendingType] = idx;\n }\n });\n });\n return result;\n }, []);\n /**\n * @returns {number} - The chosen alternative index\n */\n return function () {\n var nextToken = this.LA(1);\n return choiceToAlt_1[nextToken.tokenTypeIdx];\n };\n }\n else {\n // optimized lookahead without needing to check the predicates at all.\n // this causes code duplication which is intentional to improve performance.\n /**\n * @returns {number} - The chosen alternative index\n */\n return function () {\n for (var t = 0; t < numOfAlts; t++) {\n var currAlt = alts[t];\n var currNumOfPaths = currAlt.length;\n nextPath: for (var j = 0; j < currNumOfPaths; j++) {\n var currPath = currAlt[j];\n var currPathLength = currPath.length;\n for (var i = 0; i < currPathLength; i++) {\n var nextToken = this.LA(i + 1);\n if (tokenMatcher(nextToken, currPath[i]) === false) {\n // mismatch in current path\n // try the next pth\n continue nextPath;\n }\n }\n // found a full path that matches.\n // this will also work for an empty ALT as the loop will be skipped\n return t;\n }\n // none of the paths for the current alternative matched\n // try the next alternative\n }\n // none of the alternatives could be matched\n return undefined;\n };\n }\n}\nexport function buildSingleAlternativeLookaheadFunction(alt, tokenMatcher, dynamicTokensEnabled) {\n var areAllOneTokenLookahead = every(alt, function (currPath) {\n return currPath.length === 1;\n });\n var numOfPaths = alt.length;\n // optimized (common) case of all the lookaheads paths requiring only\n // a single token lookahead.\n if (areAllOneTokenLookahead && !dynamicTokensEnabled) {\n var singleTokensTypes = flatten(alt);\n if (singleTokensTypes.length === 1 &&\n isEmpty(singleTokensTypes[0].categoryMatches)) {\n var expectedTokenType = singleTokensTypes[0];\n var expectedTokenUniqueKey_1 = expectedTokenType.tokenTypeIdx;\n return function () {\n return this.LA(1).tokenTypeIdx === expectedTokenUniqueKey_1;\n };\n }\n else {\n var choiceToAlt_2 = reduce(singleTokensTypes, function (result, currTokType, idx) {\n result[currTokType.tokenTypeIdx] = true;\n forEach(currTokType.categoryMatches, function (currExtendingType) {\n result[currExtendingType] = true;\n });\n return result;\n }, []);\n return function () {\n var nextToken = this.LA(1);\n return choiceToAlt_2[nextToken.tokenTypeIdx] === true;\n };\n }\n }\n else {\n return function () {\n nextPath: for (var j = 0; j < numOfPaths; j++) {\n var currPath = alt[j];\n var currPathLength = currPath.length;\n for (var i = 0; i < currPathLength; i++) {\n var nextToken = this.LA(i + 1);\n if (tokenMatcher(nextToken, currPath[i]) === false) {\n // mismatch in current path\n // try the next pth\n continue nextPath;\n }\n }\n // found a full path that matches.\n return true;\n }\n // none of the paths matched\n return false;\n };\n }\n}\nvar RestDefinitionFinderWalker = /** @class */ (function (_super) {\n __extends(RestDefinitionFinderWalker, _super);\n function RestDefinitionFinderWalker(topProd, targetOccurrence, targetProdType) {\n var _this = _super.call(this) || this;\n _this.topProd = topProd;\n _this.targetOccurrence = targetOccurrence;\n _this.targetProdType = targetProdType;\n return _this;\n }\n RestDefinitionFinderWalker.prototype.startWalking = function () {\n this.walk(this.topProd);\n return this.restDef;\n };\n RestDefinitionFinderWalker.prototype.checkIsTarget = function (node, expectedProdType, currRest, prevRest) {\n if (node.idx === this.targetOccurrence &&\n this.targetProdType === expectedProdType) {\n this.restDef = currRest.concat(prevRest);\n return true;\n }\n // performance optimization, do not iterate over the entire Grammar ast after we have found the target\n return false;\n };\n RestDefinitionFinderWalker.prototype.walkOption = function (optionProd, currRest, prevRest) {\n if (!this.checkIsTarget(optionProd, PROD_TYPE.OPTION, currRest, prevRest)) {\n _super.prototype.walkOption.call(this, optionProd, currRest, prevRest);\n }\n };\n RestDefinitionFinderWalker.prototype.walkAtLeastOne = function (atLeastOneProd, currRest, prevRest) {\n if (!this.checkIsTarget(atLeastOneProd, PROD_TYPE.REPETITION_MANDATORY, currRest, prevRest)) {\n _super.prototype.walkOption.call(this, atLeastOneProd, currRest, prevRest);\n }\n };\n RestDefinitionFinderWalker.prototype.walkAtLeastOneSep = function (atLeastOneSepProd, currRest, prevRest) {\n if (!this.checkIsTarget(atLeastOneSepProd, PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR, currRest, prevRest)) {\n _super.prototype.walkOption.call(this, atLeastOneSepProd, currRest, prevRest);\n }\n };\n RestDefinitionFinderWalker.prototype.walkMany = function (manyProd, currRest, prevRest) {\n if (!this.checkIsTarget(manyProd, PROD_TYPE.REPETITION, currRest, prevRest)) {\n _super.prototype.walkOption.call(this, manyProd, currRest, prevRest);\n }\n };\n RestDefinitionFinderWalker.prototype.walkManySep = function (manySepProd, currRest, prevRest) {\n if (!this.checkIsTarget(manySepProd, PROD_TYPE.REPETITION_WITH_SEPARATOR, currRest, prevRest)) {\n _super.prototype.walkOption.call(this, manySepProd, currRest, prevRest);\n }\n };\n return RestDefinitionFinderWalker;\n}(RestWalker));\n/**\n * Returns the definition of a target production in a top level level rule.\n */\nvar InsideDefinitionFinderVisitor = /** @class */ (function (_super) {\n __extends(InsideDefinitionFinderVisitor, _super);\n function InsideDefinitionFinderVisitor(targetOccurrence, targetProdType, targetRef) {\n var _this = _super.call(this) || this;\n _this.targetOccurrence = targetOccurrence;\n _this.targetProdType = targetProdType;\n _this.targetRef = targetRef;\n _this.result = [];\n return _this;\n }\n InsideDefinitionFinderVisitor.prototype.checkIsTarget = function (node, expectedProdName) {\n if (node.idx === this.targetOccurrence &&\n this.targetProdType === expectedProdName &&\n (this.targetRef === undefined || node === this.targetRef)) {\n this.result = node.definition;\n }\n };\n InsideDefinitionFinderVisitor.prototype.visitOption = function (node) {\n this.checkIsTarget(node, PROD_TYPE.OPTION);\n };\n InsideDefinitionFinderVisitor.prototype.visitRepetition = function (node) {\n this.checkIsTarget(node, PROD_TYPE.REPETITION);\n };\n InsideDefinitionFinderVisitor.prototype.visitRepetitionMandatory = function (node) {\n this.checkIsTarget(node, PROD_TYPE.REPETITION_MANDATORY);\n };\n InsideDefinitionFinderVisitor.prototype.visitRepetitionMandatoryWithSeparator = function (node) {\n this.checkIsTarget(node, PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR);\n };\n InsideDefinitionFinderVisitor.prototype.visitRepetitionWithSeparator = function (node) {\n this.checkIsTarget(node, PROD_TYPE.REPETITION_WITH_SEPARATOR);\n };\n InsideDefinitionFinderVisitor.prototype.visitAlternation = function (node) {\n this.checkIsTarget(node, PROD_TYPE.ALTERNATION);\n };\n return InsideDefinitionFinderVisitor;\n}(GAstVisitor));\nfunction initializeArrayOfArrays(size) {\n var result = new Array(size);\n for (var i = 0; i < size; i++) {\n result[i] = [];\n }\n return result;\n}\n/**\n * A sort of hash function between a Path in the grammar and a string.\n * Note that this returns multiple \"hashes\" to support the scenario of token categories.\n * - A single path with categories may match multiple **actual** paths.\n */\nfunction pathToHashKeys(path) {\n var keys = [\"\"];\n for (var i = 0; i < path.length; i++) {\n var tokType = path[i];\n var longerKeys = [];\n for (var j = 0; j < keys.length; j++) {\n var currShorterKey = keys[j];\n longerKeys.push(currShorterKey + \"_\" + tokType.tokenTypeIdx);\n for (var t = 0; t < tokType.categoryMatches.length; t++) {\n var categoriesKeySuffix = \"_\" + tokType.categoryMatches[t];\n longerKeys.push(currShorterKey + categoriesKeySuffix);\n }\n }\n keys = longerKeys;\n }\n return keys;\n}\n/**\n * Imperative style due to being called from a hot spot\n */\nfunction isUniquePrefixHash(altKnownPathsKeys, searchPathKeys, idx) {\n for (var currAltIdx = 0; currAltIdx < altKnownPathsKeys.length; currAltIdx++) {\n // We only want to test vs the other alternatives\n if (currAltIdx === idx) {\n continue;\n }\n var otherAltKnownPathsKeys = altKnownPathsKeys[currAltIdx];\n for (var searchIdx = 0; searchIdx < searchPathKeys.length; searchIdx++) {\n var searchKey = searchPathKeys[searchIdx];\n if (otherAltKnownPathsKeys[searchKey] === true) {\n return false;\n }\n }\n }\n // None of the SearchPathKeys were found in any of the other alternatives\n return true;\n}\nexport function lookAheadSequenceFromAlternatives(altsDefs, k) {\n var partialAlts = map(altsDefs, function (currAlt) { return possiblePathsFrom([currAlt], 1); });\n var finalResult = initializeArrayOfArrays(partialAlts.length);\n var altsHashes = map(partialAlts, function (currAltPaths) {\n var dict = {};\n forEach(currAltPaths, function (item) {\n var keys = pathToHashKeys(item.partialPath);\n forEach(keys, function (currKey) {\n dict[currKey] = true;\n });\n });\n return dict;\n });\n var newData = partialAlts;\n // maxLookahead loop\n for (var pathLength = 1; pathLength <= k; pathLength++) {\n var currDataset = newData;\n newData = initializeArrayOfArrays(currDataset.length);\n var _loop_1 = function (altIdx) {\n var currAltPathsAndSuffixes = currDataset[altIdx];\n // paths in current alternative loop\n for (var currPathIdx = 0; currPathIdx < currAltPathsAndSuffixes.length; currPathIdx++) {\n var currPathPrefix = currAltPathsAndSuffixes[currPathIdx].partialPath;\n var suffixDef = currAltPathsAndSuffixes[currPathIdx].suffixDef;\n var prefixKeys = pathToHashKeys(currPathPrefix);\n var isUnique = isUniquePrefixHash(altsHashes, prefixKeys, altIdx);\n // End of the line for this path.\n if (isUnique || isEmpty(suffixDef) || currPathPrefix.length === k) {\n var currAltResult = finalResult[altIdx];\n // TODO: Can we implement a containsPath using Maps/Dictionaries?\n if (containsPath(currAltResult, currPathPrefix) === false) {\n currAltResult.push(currPathPrefix);\n // Update all new keys for the current path.\n for (var j = 0; j < prefixKeys.length; j++) {\n var currKey = prefixKeys[j];\n altsHashes[altIdx][currKey] = true;\n }\n }\n }\n // Expand longer paths\n else {\n var newPartialPathsAndSuffixes = possiblePathsFrom(suffixDef, pathLength + 1, currPathPrefix);\n newData[altIdx] = newData[altIdx].concat(newPartialPathsAndSuffixes);\n // Update keys for new known paths\n forEach(newPartialPathsAndSuffixes, function (item) {\n var prefixKeys = pathToHashKeys(item.partialPath);\n forEach(prefixKeys, function (key) {\n altsHashes[altIdx][key] = true;\n });\n });\n }\n }\n };\n // alternatives loop\n for (var altIdx = 0; altIdx < currDataset.length; altIdx++) {\n _loop_1(altIdx);\n }\n }\n return finalResult;\n}\nexport function getLookaheadPathsForOr(occurrence, ruleGrammar, k, orProd) {\n var visitor = new InsideDefinitionFinderVisitor(occurrence, PROD_TYPE.ALTERNATION, orProd);\n ruleGrammar.accept(visitor);\n return lookAheadSequenceFromAlternatives(visitor.result, k);\n}\nexport function getLookaheadPathsForOptionalProd(occurrence, ruleGrammar, prodType, k) {\n var insideDefVisitor = new InsideDefinitionFinderVisitor(occurrence, prodType);\n ruleGrammar.accept(insideDefVisitor);\n var insideDef = insideDefVisitor.result;\n var afterDefWalker = new RestDefinitionFinderWalker(ruleGrammar, occurrence, prodType);\n var afterDef = afterDefWalker.startWalking();\n var insideFlat = new AlternativeGAST({ definition: insideDef });\n var afterFlat = new AlternativeGAST({ definition: afterDef });\n return lookAheadSequenceFromAlternatives([insideFlat, afterFlat], k);\n}\nexport function containsPath(alternative, searchPath) {\n compareOtherPath: for (var i = 0; i < alternative.length; i++) {\n var otherPath = alternative[i];\n if (otherPath.length !== searchPath.length) {\n continue;\n }\n for (var j = 0; j < otherPath.length; j++) {\n var searchTok = searchPath[j];\n var otherTok = otherPath[j];\n var matchingTokens = searchTok === otherTok ||\n otherTok.categoryMatchesMap[searchTok.tokenTypeIdx] !== undefined;\n if (matchingTokens === false) {\n continue compareOtherPath;\n }\n }\n return true;\n }\n return false;\n}\nexport function isStrictPrefixOfPath(prefix, other) {\n return (prefix.length < other.length &&\n every(prefix, function (tokType, idx) {\n var otherTokType = other[idx];\n return (tokType === otherTokType ||\n otherTokType.categoryMatchesMap[tokType.tokenTypeIdx]);\n }));\n}\nexport function areTokenCategoriesNotUsed(lookAheadPaths) {\n return every(lookAheadPaths, function (singleAltPaths) {\n return every(singleAltPaths, function (singlePath) {\n return every(singlePath, function (token) { return isEmpty(token.categoryMatches); });\n });\n });\n}\n//# sourceMappingURL=lookahead.js.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport * as utils from \"../../utils/utils\";\nimport { contains, every, findAll, flatten, forEach, isEmpty, map, reduce, reject } from \"../../utils/utils\";\nimport { ParserDefinitionErrorType } from \"../parser/parser\";\nimport { getProductionDslName, isOptionalProd } from \"./gast/gast\";\nimport { containsPath, getLookaheadPathsForOptionalProd, getLookaheadPathsForOr, getProdType, isStrictPrefixOfPath } from \"./lookahead\";\nimport { nextPossibleTokensAfter } from \"./interpreter\";\nimport { Alternation, Alternative as AlternativeGAST, NonTerminal, Option, Repetition, RepetitionMandatory, RepetitionMandatoryWithSeparator, RepetitionWithSeparator, Terminal } from \"./gast/gast_public\";\nimport { GAstVisitor } from \"./gast/gast_visitor_public\";\nexport function validateGrammar(topLevels, globalMaxLookahead, tokenTypes, errMsgProvider, grammarName) {\n var duplicateErrors = utils.map(topLevels, function (currTopLevel) {\n return validateDuplicateProductions(currTopLevel, errMsgProvider);\n });\n var leftRecursionErrors = utils.map(topLevels, function (currTopRule) {\n return validateNoLeftRecursion(currTopRule, currTopRule, errMsgProvider);\n });\n var emptyAltErrors = [];\n var ambiguousAltsErrors = [];\n var emptyRepetitionErrors = [];\n // left recursion could cause infinite loops in the following validations.\n // It is safest to first have the user fix the left recursion errors first and only then examine Further issues.\n if (every(leftRecursionErrors, isEmpty)) {\n emptyAltErrors = map(topLevels, function (currTopRule) {\n return validateEmptyOrAlternative(currTopRule, errMsgProvider);\n });\n ambiguousAltsErrors = map(topLevels, function (currTopRule) {\n return validateAmbiguousAlternationAlternatives(currTopRule, globalMaxLookahead, errMsgProvider);\n });\n emptyRepetitionErrors = validateSomeNonEmptyLookaheadPath(topLevels, globalMaxLookahead, errMsgProvider);\n }\n var termsNamespaceConflictErrors = checkTerminalAndNoneTerminalsNameSpace(topLevels, tokenTypes, errMsgProvider);\n var tokenNameErrors = utils.map(tokenTypes, function (currTokType) {\n return validateTokenName(currTokType, errMsgProvider);\n });\n var tooManyAltsErrors = map(topLevels, function (curRule) {\n return validateTooManyAlts(curRule, errMsgProvider);\n });\n var ruleNameErrors = map(topLevels, function (curRule) {\n return validateRuleName(curRule, errMsgProvider);\n });\n var duplicateRulesError = map(topLevels, function (curRule) {\n return validateRuleDoesNotAlreadyExist(curRule, topLevels, grammarName, errMsgProvider);\n });\n return (utils.flatten(duplicateErrors.concat(tokenNameErrors, emptyRepetitionErrors, leftRecursionErrors, emptyAltErrors, ambiguousAltsErrors, termsNamespaceConflictErrors, tooManyAltsErrors, ruleNameErrors, duplicateRulesError)));\n}\nfunction validateDuplicateProductions(topLevelRule, errMsgProvider) {\n var collectorVisitor = new OccurrenceValidationCollector();\n topLevelRule.accept(collectorVisitor);\n var allRuleProductions = collectorVisitor.allProductions;\n var productionGroups = utils.groupBy(allRuleProductions, identifyProductionForDuplicates);\n var duplicates = utils.pick(productionGroups, function (currGroup) {\n return currGroup.length > 1;\n });\n var errors = utils.map(utils.values(duplicates), function (currDuplicates) {\n var firstProd = utils.first(currDuplicates);\n var msg = errMsgProvider.buildDuplicateFoundError(topLevelRule, currDuplicates);\n var dslName = getProductionDslName(firstProd);\n var defError = {\n message: msg,\n type: ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,\n ruleName: topLevelRule.name,\n dslName: dslName,\n occurrence: firstProd.idx\n };\n var param = getExtraProductionArgument(firstProd);\n if (param) {\n defError.parameter = param;\n }\n return defError;\n });\n return errors;\n}\nexport function identifyProductionForDuplicates(prod) {\n return getProductionDslName(prod) + \"_#_\" + prod.idx + \"_#_\" + getExtraProductionArgument(prod);\n}\nfunction getExtraProductionArgument(prod) {\n if (prod instanceof Terminal) {\n return prod.terminalType.name;\n }\n else if (prod instanceof NonTerminal) {\n return prod.nonTerminalName;\n }\n else {\n return \"\";\n }\n}\nvar OccurrenceValidationCollector = /** @class */ (function (_super) {\n __extends(OccurrenceValidationCollector, _super);\n function OccurrenceValidationCollector() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.allProductions = [];\n return _this;\n }\n OccurrenceValidationCollector.prototype.visitNonTerminal = function (subrule) {\n this.allProductions.push(subrule);\n };\n OccurrenceValidationCollector.prototype.visitOption = function (option) {\n this.allProductions.push(option);\n };\n OccurrenceValidationCollector.prototype.visitRepetitionWithSeparator = function (manySep) {\n this.allProductions.push(manySep);\n };\n OccurrenceValidationCollector.prototype.visitRepetitionMandatory = function (atLeastOne) {\n this.allProductions.push(atLeastOne);\n };\n OccurrenceValidationCollector.prototype.visitRepetitionMandatoryWithSeparator = function (atLeastOneSep) {\n this.allProductions.push(atLeastOneSep);\n };\n OccurrenceValidationCollector.prototype.visitRepetition = function (many) {\n this.allProductions.push(many);\n };\n OccurrenceValidationCollector.prototype.visitAlternation = function (or) {\n this.allProductions.push(or);\n };\n OccurrenceValidationCollector.prototype.visitTerminal = function (terminal) {\n this.allProductions.push(terminal);\n };\n return OccurrenceValidationCollector;\n}(GAstVisitor));\nexport { OccurrenceValidationCollector };\nexport var validTermsPattern = /^[a-zA-Z_]\\w*$/;\n// TODO: remove this limitation now that we use recorders\nexport function validateRuleName(rule, errMsgProvider) {\n var errors = [];\n var ruleName = rule.name;\n if (!ruleName.match(validTermsPattern)) {\n errors.push({\n message: errMsgProvider.buildInvalidRuleNameError({\n topLevelRule: rule,\n expectedPattern: validTermsPattern\n }),\n type: ParserDefinitionErrorType.INVALID_RULE_NAME,\n ruleName: ruleName\n });\n }\n return errors;\n}\n// TODO: remove this limitation now that we use recorders\nexport function validateTokenName(tokenType, errMsgProvider) {\n var errors = [];\n var tokTypeName = tokenType.name;\n if (!tokTypeName.match(validTermsPattern)) {\n errors.push({\n message: errMsgProvider.buildTokenNameError({\n tokenType: tokenType,\n expectedPattern: validTermsPattern\n }),\n type: ParserDefinitionErrorType.INVALID_TOKEN_NAME\n });\n }\n return errors;\n}\nexport function validateRuleDoesNotAlreadyExist(rule, allRules, className, errMsgProvider) {\n var errors = [];\n var occurrences = reduce(allRules, function (result, curRule) {\n if (curRule.name === rule.name) {\n return result + 1;\n }\n return result;\n }, 0);\n if (occurrences > 1) {\n var errMsg = errMsgProvider.buildDuplicateRuleNameError({\n topLevelRule: rule,\n grammarName: className\n });\n errors.push({\n message: errMsg,\n type: ParserDefinitionErrorType.DUPLICATE_RULE_NAME,\n ruleName: rule.name\n });\n }\n return errors;\n}\n// TODO: is there anyway to get only the rule names of rules inherited from the super grammars?\n// This is not part of the IGrammarErrorProvider because the validation cannot be performed on\n// The grammar structure, only at runtime.\nexport function validateRuleIsOverridden(ruleName, definedRulesNames, className) {\n var errors = [];\n var errMsg;\n if (!utils.contains(definedRulesNames, ruleName)) {\n errMsg =\n \"Invalid rule override, rule: ->\" + ruleName + \"<- cannot be overridden in the grammar: ->\" + className + \"<-\" +\n \"as it is not defined in any of the super grammars \";\n errors.push({\n message: errMsg,\n type: ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,\n ruleName: ruleName\n });\n }\n return errors;\n}\nexport function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path) {\n if (path === void 0) { path = []; }\n var errors = [];\n var nextNonTerminals = getFirstNoneTerminal(currRule.definition);\n if (utils.isEmpty(nextNonTerminals)) {\n return [];\n }\n else {\n var ruleName = topRule.name;\n var foundLeftRecursion = utils.contains(nextNonTerminals, topRule);\n if (foundLeftRecursion) {\n errors.push({\n message: errMsgProvider.buildLeftRecursionError({\n topLevelRule: topRule,\n leftRecursionPath: path\n }),\n type: ParserDefinitionErrorType.LEFT_RECURSION,\n ruleName: ruleName\n });\n }\n // we are only looking for cyclic paths leading back to the specific topRule\n // other cyclic paths are ignored, we still need this difference to avoid infinite loops...\n var validNextSteps = utils.difference(nextNonTerminals, path.concat([topRule]));\n var errorsFromNextSteps = utils.map(validNextSteps, function (currRefRule) {\n var newPath = utils.cloneArr(path);\n newPath.push(currRefRule);\n return validateNoLeftRecursion(topRule, currRefRule, errMsgProvider, newPath);\n });\n return errors.concat(utils.flatten(errorsFromNextSteps));\n }\n}\nexport function getFirstNoneTerminal(definition) {\n var result = [];\n if (utils.isEmpty(definition)) {\n return result;\n }\n var firstProd = utils.first(definition);\n /* istanbul ignore else */\n if (firstProd instanceof NonTerminal) {\n result.push(firstProd.referencedRule);\n }\n else if (firstProd instanceof AlternativeGAST ||\n firstProd instanceof Option ||\n firstProd instanceof RepetitionMandatory ||\n firstProd instanceof RepetitionMandatoryWithSeparator ||\n firstProd instanceof RepetitionWithSeparator ||\n firstProd instanceof Repetition) {\n result = result.concat(getFirstNoneTerminal(firstProd.definition));\n }\n else if (firstProd instanceof Alternation) {\n // each sub definition in alternation is a FLAT\n result = utils.flatten(utils.map(firstProd.definition, function (currSubDef) {\n return getFirstNoneTerminal(currSubDef.definition);\n }));\n }\n else if (firstProd instanceof Terminal) {\n // nothing to see, move along\n }\n else {\n throw Error(\"non exhaustive match\");\n }\n var isFirstOptional = isOptionalProd(firstProd);\n var hasMore = definition.length > 1;\n if (isFirstOptional && hasMore) {\n var rest = utils.drop(definition);\n return result.concat(getFirstNoneTerminal(rest));\n }\n else {\n return result;\n }\n}\nvar OrCollector = /** @class */ (function (_super) {\n __extends(OrCollector, _super);\n function OrCollector() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.alternations = [];\n return _this;\n }\n OrCollector.prototype.visitAlternation = function (node) {\n this.alternations.push(node);\n };\n return OrCollector;\n}(GAstVisitor));\nexport function validateEmptyOrAlternative(topLevelRule, errMsgProvider) {\n var orCollector = new OrCollector();\n topLevelRule.accept(orCollector);\n var ors = orCollector.alternations;\n var errors = utils.reduce(ors, function (errors, currOr) {\n var exceptLast = utils.dropRight(currOr.definition);\n var currErrors = utils.map(exceptLast, function (currAlternative, currAltIdx) {\n var possibleFirstInAlt = nextPossibleTokensAfter([currAlternative], [], null, 1);\n if (utils.isEmpty(possibleFirstInAlt)) {\n return {\n message: errMsgProvider.buildEmptyAlternationError({\n topLevelRule: topLevelRule,\n alternation: currOr,\n emptyChoiceIdx: currAltIdx\n }),\n type: ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,\n ruleName: topLevelRule.name,\n occurrence: currOr.idx,\n alternative: currAltIdx + 1\n };\n }\n else {\n return null;\n }\n });\n return errors.concat(utils.compact(currErrors));\n }, []);\n return errors;\n}\nexport function validateAmbiguousAlternationAlternatives(topLevelRule, globalMaxLookahead, errMsgProvider) {\n var orCollector = new OrCollector();\n topLevelRule.accept(orCollector);\n var ors = orCollector.alternations;\n // New Handling of ignoring ambiguities\n // - https://github.com/SAP/chevrotain/issues/869\n ors = reject(ors, function (currOr) { return currOr.ignoreAmbiguities === true; });\n var errors = utils.reduce(ors, function (result, currOr) {\n var currOccurrence = currOr.idx;\n var actualMaxLookahead = currOr.maxLookahead || globalMaxLookahead;\n var alternatives = getLookaheadPathsForOr(currOccurrence, topLevelRule, actualMaxLookahead, currOr);\n var altsAmbiguityErrors = checkAlternativesAmbiguities(alternatives, currOr, topLevelRule, errMsgProvider);\n var altsPrefixAmbiguityErrors = checkPrefixAlternativesAmbiguities(alternatives, currOr, topLevelRule, errMsgProvider);\n return result.concat(altsAmbiguityErrors, altsPrefixAmbiguityErrors);\n }, []);\n return errors;\n}\nvar RepetionCollector = /** @class */ (function (_super) {\n __extends(RepetionCollector, _super);\n function RepetionCollector() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.allProductions = [];\n return _this;\n }\n RepetionCollector.prototype.visitRepetitionWithSeparator = function (manySep) {\n this.allProductions.push(manySep);\n };\n RepetionCollector.prototype.visitRepetitionMandatory = function (atLeastOne) {\n this.allProductions.push(atLeastOne);\n };\n RepetionCollector.prototype.visitRepetitionMandatoryWithSeparator = function (atLeastOneSep) {\n this.allProductions.push(atLeastOneSep);\n };\n RepetionCollector.prototype.visitRepetition = function (many) {\n this.allProductions.push(many);\n };\n return RepetionCollector;\n}(GAstVisitor));\nexport { RepetionCollector };\nexport function validateTooManyAlts(topLevelRule, errMsgProvider) {\n var orCollector = new OrCollector();\n topLevelRule.accept(orCollector);\n var ors = orCollector.alternations;\n var errors = utils.reduce(ors, function (errors, currOr) {\n if (currOr.definition.length > 255) {\n errors.push({\n message: errMsgProvider.buildTooManyAlternativesError({\n topLevelRule: topLevelRule,\n alternation: currOr\n }),\n type: ParserDefinitionErrorType.TOO_MANY_ALTS,\n ruleName: topLevelRule.name,\n occurrence: currOr.idx\n });\n }\n return errors;\n }, []);\n return errors;\n}\nexport function validateSomeNonEmptyLookaheadPath(topLevelRules, maxLookahead, errMsgProvider) {\n var errors = [];\n forEach(topLevelRules, function (currTopRule) {\n var collectorVisitor = new RepetionCollector();\n currTopRule.accept(collectorVisitor);\n var allRuleProductions = collectorVisitor.allProductions;\n forEach(allRuleProductions, function (currProd) {\n var prodType = getProdType(currProd);\n var actualMaxLookahead = currProd.maxLookahead || maxLookahead;\n var currOccurrence = currProd.idx;\n var paths = getLookaheadPathsForOptionalProd(currOccurrence, currTopRule, prodType, actualMaxLookahead);\n var pathsInsideProduction = paths[0];\n if (isEmpty(flatten(pathsInsideProduction))) {\n var errMsg = errMsgProvider.buildEmptyRepetitionError({\n topLevelRule: currTopRule,\n repetition: currProd\n });\n errors.push({\n message: errMsg,\n type: ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,\n ruleName: currTopRule.name\n });\n }\n });\n });\n return errors;\n}\nfunction checkAlternativesAmbiguities(alternatives, alternation, rule, errMsgProvider) {\n var foundAmbiguousPaths = [];\n var identicalAmbiguities = reduce(alternatives, function (result, currAlt, currAltIdx) {\n // ignore (skip) ambiguities with this alternative\n if (alternation.definition[currAltIdx].ignoreAmbiguities === true) {\n return result;\n }\n forEach(currAlt, function (currPath) {\n var altsCurrPathAppearsIn = [currAltIdx];\n forEach(alternatives, function (currOtherAlt, currOtherAltIdx) {\n if (currAltIdx !== currOtherAltIdx &&\n containsPath(currOtherAlt, currPath) &&\n // ignore (skip) ambiguities with this \"other\" alternative\n alternation.definition[currOtherAltIdx].ignoreAmbiguities !== true) {\n altsCurrPathAppearsIn.push(currOtherAltIdx);\n }\n });\n if (altsCurrPathAppearsIn.length > 1 &&\n !containsPath(foundAmbiguousPaths, currPath)) {\n foundAmbiguousPaths.push(currPath);\n result.push({\n alts: altsCurrPathAppearsIn,\n path: currPath\n });\n }\n });\n return result;\n }, []);\n var currErrors = utils.map(identicalAmbiguities, function (currAmbDescriptor) {\n var ambgIndices = map(currAmbDescriptor.alts, function (currAltIdx) { return currAltIdx + 1; });\n var currMessage = errMsgProvider.buildAlternationAmbiguityError({\n topLevelRule: rule,\n alternation: alternation,\n ambiguityIndices: ambgIndices,\n prefixPath: currAmbDescriptor.path\n });\n return {\n message: currMessage,\n type: ParserDefinitionErrorType.AMBIGUOUS_ALTS,\n ruleName: rule.name,\n occurrence: alternation.idx,\n alternatives: [currAmbDescriptor.alts]\n };\n });\n return currErrors;\n}\nexport function checkPrefixAlternativesAmbiguities(alternatives, alternation, rule, errMsgProvider) {\n var errors = [];\n // flatten\n var pathsAndIndices = reduce(alternatives, function (result, currAlt, idx) {\n var currPathsAndIdx = map(currAlt, function (currPath) {\n return { idx: idx, path: currPath };\n });\n return result.concat(currPathsAndIdx);\n }, []);\n forEach(pathsAndIndices, function (currPathAndIdx) {\n var alternativeGast = alternation.definition[currPathAndIdx.idx];\n // ignore (skip) ambiguities with this alternative\n if (alternativeGast.ignoreAmbiguities === true) {\n return;\n }\n var targetIdx = currPathAndIdx.idx;\n var targetPath = currPathAndIdx.path;\n var prefixAmbiguitiesPathsAndIndices = findAll(pathsAndIndices, function (searchPathAndIdx) {\n // prefix ambiguity can only be created from lower idx (higher priority) path\n return (\n // ignore (skip) ambiguities with this \"other\" alternative\n alternation.definition[searchPathAndIdx.idx].ignoreAmbiguities !==\n true &&\n searchPathAndIdx.idx < targetIdx &&\n // checking for strict prefix because identical lookaheads\n // will be be detected using a different validation.\n isStrictPrefixOfPath(searchPathAndIdx.path, targetPath));\n });\n var currPathPrefixErrors = map(prefixAmbiguitiesPathsAndIndices, function (currAmbPathAndIdx) {\n var ambgIndices = [currAmbPathAndIdx.idx + 1, targetIdx + 1];\n var occurrence = alternation.idx === 0 ? \"\" : alternation.idx;\n var message = errMsgProvider.buildAlternationPrefixAmbiguityError({\n topLevelRule: rule,\n alternation: alternation,\n ambiguityIndices: ambgIndices,\n prefixPath: currAmbPathAndIdx.path\n });\n return {\n message: message,\n type: ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,\n ruleName: rule.name,\n occurrence: occurrence,\n alternatives: ambgIndices\n };\n });\n errors = errors.concat(currPathPrefixErrors);\n });\n return errors;\n}\nfunction checkTerminalAndNoneTerminalsNameSpace(topLevels, tokenTypes, errMsgProvider) {\n var errors = [];\n var tokenNames = map(tokenTypes, function (currToken) { return currToken.name; });\n forEach(topLevels, function (currRule) {\n var currRuleName = currRule.name;\n if (contains(tokenNames, currRuleName)) {\n var errMsg = errMsgProvider.buildNamespaceConflictError(currRule);\n errors.push({\n message: errMsg,\n type: ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,\n ruleName: currRuleName\n });\n }\n });\n return errors;\n}\n//# sourceMappingURL=checks.js.map","import { defaults, forEach } from \"../../../utils/utils\";\nimport { resolveGrammar as orgResolveGrammar } from \"../resolver\";\nimport { validateGrammar as orgValidateGrammar } from \"../checks\";\nimport { defaultGrammarResolverErrorProvider, defaultGrammarValidatorErrorProvider } from \"../../errors_public\";\nimport { DslMethodsCollectorVisitor } from \"./gast\";\nexport function resolveGrammar(options) {\n options = defaults(options, {\n errMsgProvider: defaultGrammarResolverErrorProvider\n });\n var topRulesTable = {};\n forEach(options.rules, function (rule) {\n topRulesTable[rule.name] = rule;\n });\n return orgResolveGrammar(topRulesTable, options.errMsgProvider);\n}\nexport function validateGrammar(options) {\n options = defaults(options, {\n errMsgProvider: defaultGrammarValidatorErrorProvider\n });\n return orgValidateGrammar(options.rules, options.maxLookahead, options.tokenTypes, options.errMsgProvider, options.grammarName);\n}\nexport function assignOccurrenceIndices(options) {\n forEach(options.rules, function (currRule) {\n var methodsCollector = new DslMethodsCollectorVisitor();\n currRule.accept(methodsCollector);\n forEach(methodsCollector.dslMethods, function (methods) {\n forEach(methods, function (currMethod, arrIdx) {\n currMethod.idx = arrIdx + 1;\n });\n });\n });\n}\n//# sourceMappingURL=gast_resolver_public.js.map","import { contains } from \"../utils/utils\";\nvar MISMATCHED_TOKEN_EXCEPTION = \"MismatchedTokenException\";\nvar NO_VIABLE_ALT_EXCEPTION = \"NoViableAltException\";\nvar EARLY_EXIT_EXCEPTION = \"EarlyExitException\";\nvar NOT_ALL_INPUT_PARSED_EXCEPTION = \"NotAllInputParsedException\";\nvar RECOGNITION_EXCEPTION_NAMES = [\n MISMATCHED_TOKEN_EXCEPTION,\n NO_VIABLE_ALT_EXCEPTION,\n EARLY_EXIT_EXCEPTION,\n NOT_ALL_INPUT_PARSED_EXCEPTION\n];\nObject.freeze(RECOGNITION_EXCEPTION_NAMES);\n// hacks to bypass no support for custom Errors in javascript/typescript\nexport function isRecognitionException(error) {\n // can't do instanceof on hacked custom js exceptions\n return contains(RECOGNITION_EXCEPTION_NAMES, error.name);\n}\nexport function MismatchedTokenException(message, token, previousToken) {\n this.name = MISMATCHED_TOKEN_EXCEPTION;\n this.message = message;\n this.token = token;\n this.previousToken = previousToken;\n this.resyncedTokens = [];\n}\n// must use the \"Error.prototype\" instead of \"new Error\"\n// because the stack trace points to where \"new Error\" was invoked\"\nMismatchedTokenException.prototype = Error.prototype;\nexport function NoViableAltException(message, token, previousToken) {\n this.name = NO_VIABLE_ALT_EXCEPTION;\n this.message = message;\n this.token = token;\n this.previousToken = previousToken;\n this.resyncedTokens = [];\n}\nNoViableAltException.prototype = Error.prototype;\nexport function NotAllInputParsedException(message, token) {\n this.name = NOT_ALL_INPUT_PARSED_EXCEPTION;\n this.message = message;\n this.token = token;\n this.resyncedTokens = [];\n}\nNotAllInputParsedException.prototype = Error.prototype;\nexport function EarlyExitException(message, token, previousToken) {\n this.name = EARLY_EXIT_EXCEPTION;\n this.message = message;\n this.token = token;\n this.previousToken = previousToken;\n this.resyncedTokens = [];\n}\nEarlyExitException.prototype = Error.prototype;\n//# sourceMappingURL=exceptions_public.js.map","import { createTokenInstance, EOF } from \"../../../scan/tokens_public\";\nimport { cloneArr, contains, dropRight, find, flatten, has, isEmpty, map } from \"../../../utils/utils\";\nimport { MismatchedTokenException } from \"../../exceptions_public\";\nimport { IN } from \"../../constants\";\nimport { DEFAULT_PARSER_CONFIG } from \"../parser\";\nexport var EOF_FOLLOW_KEY = {};\nexport var IN_RULE_RECOVERY_EXCEPTION = \"InRuleRecoveryException\";\nexport function InRuleRecoveryException(message) {\n this.name = IN_RULE_RECOVERY_EXCEPTION;\n this.message = message;\n}\nInRuleRecoveryException.prototype = Error.prototype;\n/**\n * This trait is responsible for the error recovery and fault tolerant logic\n */\nvar Recoverable = /** @class */ (function () {\n function Recoverable() {\n }\n Recoverable.prototype.initRecoverable = function (config) {\n this.firstAfterRepMap = {};\n this.resyncFollows = {};\n this.recoveryEnabled = has(config, \"recoveryEnabled\")\n ? config.recoveryEnabled\n : DEFAULT_PARSER_CONFIG.recoveryEnabled;\n // performance optimization, NOOP will be inlined which\n // effectively means that this optional feature does not exist\n // when not used.\n if (this.recoveryEnabled) {\n this.attemptInRepetitionRecovery = attemptInRepetitionRecovery;\n }\n };\n Recoverable.prototype.getTokenToInsert = function (tokType) {\n var tokToInsert = createTokenInstance(tokType, \"\", NaN, NaN, NaN, NaN, NaN, NaN);\n tokToInsert.isInsertedInRecovery = true;\n return tokToInsert;\n };\n Recoverable.prototype.canTokenTypeBeInsertedInRecovery = function (tokType) {\n return true;\n };\n Recoverable.prototype.tryInRepetitionRecovery = function (grammarRule, grammarRuleArgs, lookAheadFunc, expectedTokType) {\n var _this = this;\n // TODO: can the resyncTokenType be cached?\n var reSyncTokType = this.findReSyncTokenType();\n var savedLexerState = this.exportLexerState();\n var resyncedTokens = [];\n var passedResyncPoint = false;\n var nextTokenWithoutResync = this.LA(1);\n var currToken = this.LA(1);\n var generateErrorMessage = function () {\n var previousToken = _this.LA(0);\n // we are preemptively re-syncing before an error has been detected, therefor we must reproduce\n // the error that would have been thrown\n var msg = _this.errorMessageProvider.buildMismatchTokenMessage({\n expected: expectedTokType,\n actual: nextTokenWithoutResync,\n previous: previousToken,\n ruleName: _this.getCurrRuleFullName()\n });\n var error = new MismatchedTokenException(msg, nextTokenWithoutResync, _this.LA(0));\n // the first token here will be the original cause of the error, this is not part of the resyncedTokens property.\n error.resyncedTokens = dropRight(resyncedTokens);\n _this.SAVE_ERROR(error);\n };\n while (!passedResyncPoint) {\n // re-synced to a point where we can safely exit the repetition/\n if (this.tokenMatcher(currToken, expectedTokType)) {\n generateErrorMessage();\n return; // must return here to avoid reverting the inputIdx\n }\n else if (lookAheadFunc.call(this)) {\n // we skipped enough tokens so we can resync right back into another iteration of the repetition grammar rule\n generateErrorMessage();\n // recursive invocation in other to support multiple re-syncs in the same top level repetition grammar rule\n grammarRule.apply(this, grammarRuleArgs);\n return; // must return here to avoid reverting the inputIdx\n }\n else if (this.tokenMatcher(currToken, reSyncTokType)) {\n passedResyncPoint = true;\n }\n else {\n currToken = this.SKIP_TOKEN();\n this.addToResyncTokens(currToken, resyncedTokens);\n }\n }\n // we were unable to find a CLOSER point to resync inside the Repetition, reset the state.\n // The parsing exception we were trying to prevent will happen in the NEXT parsing step. it may be handled by\n // \"between rules\" resync recovery later in the flow.\n this.importLexerState(savedLexerState);\n };\n Recoverable.prototype.shouldInRepetitionRecoveryBeTried = function (expectTokAfterLastMatch, nextTokIdx, notStuck) {\n // Edge case of arriving from a MANY repetition which is stuck\n // Attempting recovery in this case could cause an infinite loop\n if (notStuck === false) {\n return false;\n }\n // arguments to try and perform resync into the next iteration of the many are missing\n if (expectTokAfterLastMatch === undefined || nextTokIdx === undefined) {\n return false;\n }\n // no need to recover, next token is what we expect...\n if (this.tokenMatcher(this.LA(1), expectTokAfterLastMatch)) {\n return false;\n }\n // error recovery is disabled during backtracking as it can make the parser ignore a valid grammar path\n // and prefer some backtracking path that includes recovered errors.\n if (this.isBackTracking()) {\n return false;\n }\n // if we can perform inRule recovery (single token insertion or deletion) we always prefer that recovery algorithm\n // because if it works, it makes the least amount of changes to the input stream (greedy algorithm)\n //noinspection RedundantIfStatementJS\n if (this.canPerformInRuleRecovery(expectTokAfterLastMatch, this.getFollowsForInRuleRecovery(expectTokAfterLastMatch, nextTokIdx))) {\n return false;\n }\n return true;\n };\n // Error Recovery functionality\n Recoverable.prototype.getFollowsForInRuleRecovery = function (tokType, tokIdxInRule) {\n var grammarPath = this.getCurrentGrammarPath(tokType, tokIdxInRule);\n var follows = this.getNextPossibleTokenTypes(grammarPath);\n return follows;\n };\n Recoverable.prototype.tryInRuleRecovery = function (expectedTokType, follows) {\n if (this.canRecoverWithSingleTokenInsertion(expectedTokType, follows)) {\n var tokToInsert = this.getTokenToInsert(expectedTokType);\n return tokToInsert;\n }\n if (this.canRecoverWithSingleTokenDeletion(expectedTokType)) {\n var nextTok = this.SKIP_TOKEN();\n this.consumeToken();\n return nextTok;\n }\n throw new InRuleRecoveryException(\"sad sad panda\");\n };\n Recoverable.prototype.canPerformInRuleRecovery = function (expectedToken, follows) {\n return (this.canRecoverWithSingleTokenInsertion(expectedToken, follows) ||\n this.canRecoverWithSingleTokenDeletion(expectedToken));\n };\n Recoverable.prototype.canRecoverWithSingleTokenInsertion = function (expectedTokType, follows) {\n var _this = this;\n if (!this.canTokenTypeBeInsertedInRecovery(expectedTokType)) {\n return false;\n }\n // must know the possible following tokens to perform single token insertion\n if (isEmpty(follows)) {\n return false;\n }\n var mismatchedTok = this.LA(1);\n var isMisMatchedTokInFollows = find(follows, function (possibleFollowsTokType) {\n return _this.tokenMatcher(mismatchedTok, possibleFollowsTokType);\n }) !== undefined;\n return isMisMatchedTokInFollows;\n };\n Recoverable.prototype.canRecoverWithSingleTokenDeletion = function (expectedTokType) {\n var isNextTokenWhatIsExpected = this.tokenMatcher(this.LA(2), expectedTokType);\n return isNextTokenWhatIsExpected;\n };\n Recoverable.prototype.isInCurrentRuleReSyncSet = function (tokenTypeIdx) {\n var followKey = this.getCurrFollowKey();\n var currentRuleReSyncSet = this.getFollowSetFromFollowKey(followKey);\n return contains(currentRuleReSyncSet, tokenTypeIdx);\n };\n Recoverable.prototype.findReSyncTokenType = function () {\n var allPossibleReSyncTokTypes = this.flattenFollowSet();\n // this loop will always terminate as EOF is always in the follow stack and also always (virtually) in the input\n var nextToken = this.LA(1);\n var k = 2;\n while (true) {\n var nextTokenType = nextToken.tokenType;\n if (contains(allPossibleReSyncTokTypes, nextTokenType)) {\n return nextTokenType;\n }\n nextToken = this.LA(k);\n k++;\n }\n };\n Recoverable.prototype.getCurrFollowKey = function () {\n // the length is at least one as we always add the ruleName to the stack before invoking the rule.\n if (this.RULE_STACK.length === 1) {\n return EOF_FOLLOW_KEY;\n }\n var currRuleShortName = this.getLastExplicitRuleShortName();\n var currRuleIdx = this.getLastExplicitRuleOccurrenceIndex();\n var prevRuleShortName = this.getPreviousExplicitRuleShortName();\n return {\n ruleName: this.shortRuleNameToFullName(currRuleShortName),\n idxInCallingRule: currRuleIdx,\n inRule: this.shortRuleNameToFullName(prevRuleShortName)\n };\n };\n Recoverable.prototype.buildFullFollowKeyStack = function () {\n var _this = this;\n var explicitRuleStack = this.RULE_STACK;\n var explicitOccurrenceStack = this.RULE_OCCURRENCE_STACK;\n return map(explicitRuleStack, function (ruleName, idx) {\n if (idx === 0) {\n return EOF_FOLLOW_KEY;\n }\n return {\n ruleName: _this.shortRuleNameToFullName(ruleName),\n idxInCallingRule: explicitOccurrenceStack[idx],\n inRule: _this.shortRuleNameToFullName(explicitRuleStack[idx - 1])\n };\n });\n };\n Recoverable.prototype.flattenFollowSet = function () {\n var _this = this;\n var followStack = map(this.buildFullFollowKeyStack(), function (currKey) {\n return _this.getFollowSetFromFollowKey(currKey);\n });\n return flatten(followStack);\n };\n Recoverable.prototype.getFollowSetFromFollowKey = function (followKey) {\n if (followKey === EOF_FOLLOW_KEY) {\n return [EOF];\n }\n var followName = followKey.ruleName + followKey.idxInCallingRule + IN + followKey.inRule;\n return this.resyncFollows[followName];\n };\n // It does not make any sense to include a virtual EOF token in the list of resynced tokens\n // as EOF does not really exist and thus does not contain any useful information (line/column numbers)\n Recoverable.prototype.addToResyncTokens = function (token, resyncTokens) {\n if (!this.tokenMatcher(token, EOF)) {\n resyncTokens.push(token);\n }\n return resyncTokens;\n };\n Recoverable.prototype.reSyncTo = function (tokType) {\n var resyncedTokens = [];\n var nextTok = this.LA(1);\n while (this.tokenMatcher(nextTok, tokType) === false) {\n nextTok = this.SKIP_TOKEN();\n this.addToResyncTokens(nextTok, resyncedTokens);\n }\n // the last token is not part of the error.\n return dropRight(resyncedTokens);\n };\n Recoverable.prototype.attemptInRepetitionRecovery = function (prodFunc, args, lookaheadFunc, dslMethodIdx, prodOccurrence, nextToksWalker, notStuck) {\n // by default this is a NO-OP\n // The actual implementation is with the function(not method) below\n };\n Recoverable.prototype.getCurrentGrammarPath = function (tokType, tokIdxInRule) {\n var pathRuleStack = this.getHumanReadableRuleStack();\n var pathOccurrenceStack = cloneArr(this.RULE_OCCURRENCE_STACK);\n var grammarPath = {\n ruleStack: pathRuleStack,\n occurrenceStack: pathOccurrenceStack,\n lastTok: tokType,\n lastTokOccurrence: tokIdxInRule\n };\n return grammarPath;\n };\n Recoverable.prototype.getHumanReadableRuleStack = function () {\n var _this = this;\n return map(this.RULE_STACK, function (currShortName) {\n return _this.shortRuleNameToFullName(currShortName);\n });\n };\n return Recoverable;\n}());\nexport { Recoverable };\nexport function attemptInRepetitionRecovery(prodFunc, args, lookaheadFunc, dslMethodIdx, prodOccurrence, nextToksWalker, notStuck) {\n var key = this.getKeyForAutomaticLookahead(dslMethodIdx, prodOccurrence);\n var firstAfterRepInfo = this.firstAfterRepMap[key];\n if (firstAfterRepInfo === undefined) {\n var currRuleName = this.getCurrRuleFullName();\n var ruleGrammar = this.getGAstProductions()[currRuleName];\n var walker = new nextToksWalker(ruleGrammar, prodOccurrence);\n firstAfterRepInfo = walker.startWalking();\n this.firstAfterRepMap[key] = firstAfterRepInfo;\n }\n var expectTokAfterLastMatch = firstAfterRepInfo.token;\n var nextTokIdx = firstAfterRepInfo.occurrence;\n var isEndOfRule = firstAfterRepInfo.isEndOfRule;\n // special edge case of a TOP most repetition after which the input should END.\n // this will force an attempt for inRule recovery in that scenario.\n if (this.RULE_STACK.length === 1 &&\n isEndOfRule &&\n expectTokAfterLastMatch === undefined) {\n expectTokAfterLastMatch = EOF;\n nextTokIdx = 1;\n }\n if (this.shouldInRepetitionRecoveryBeTried(expectTokAfterLastMatch, nextTokIdx, notStuck)) {\n // TODO: performance optimization: instead of passing the original args here, we modify\n // the args param (or create a new one) and make sure the lookahead func is explicitly provided\n // to avoid searching the cache for it once more.\n this.tryInRepetitionRecovery(prodFunc, args, lookaheadFunc, expectTokAfterLastMatch);\n }\n}\n//# sourceMappingURL=recoverable.js.map","// Lookahead keys are 32Bit integers in the form\n// TTTTTTTT-ZZZZZZZZZZZZ-YYYY-XXXXXXXX\n// XXXX -> Occurrence Index bitmap.\n// YYYY -> DSL Method Type bitmap.\n// ZZZZZZZZZZZZZZZ -> Rule short Index bitmap.\n// TTTTTTTTT -> alternation alternative index bitmap\nexport var BITS_FOR_METHOD_TYPE = 4;\nexport var BITS_FOR_OCCURRENCE_IDX = 8;\nexport var BITS_FOR_RULE_IDX = 12;\n// TODO: validation, this means that there may at most 2^8 --> 256 alternatives for an alternation.\nexport var BITS_FOR_ALT_IDX = 8;\n// short string used as part of mapping keys.\n// being short improves the performance when composing KEYS for maps out of these\n// The 5 - 8 bits (16 possible values, are reserved for the DSL method indices)\n/* tslint:disable */\nexport var OR_IDX = 1 << BITS_FOR_OCCURRENCE_IDX;\nexport var OPTION_IDX = 2 << BITS_FOR_OCCURRENCE_IDX;\nexport var MANY_IDX = 3 << BITS_FOR_OCCURRENCE_IDX;\nexport var AT_LEAST_ONE_IDX = 4 << BITS_FOR_OCCURRENCE_IDX;\nexport var MANY_SEP_IDX = 5 << BITS_FOR_OCCURRENCE_IDX;\nexport var AT_LEAST_ONE_SEP_IDX = 6 << BITS_FOR_OCCURRENCE_IDX;\n/* tslint:enable */\n// this actually returns a number, but it is always used as a string (object prop key)\nexport function getKeyForAutomaticLookahead(ruleIdx, dslMethodIdx, occurrence) {\n /* tslint:disable */\n return occurrence | dslMethodIdx | ruleIdx;\n /* tslint:enable */\n}\nvar BITS_START_FOR_ALT_IDX = 32 - BITS_FOR_ALT_IDX;\n//# sourceMappingURL=keys.js.map","import { buildAlternativesLookAheadFunc, buildLookaheadFuncForOptionalProd, buildLookaheadFuncForOr, buildSingleAlternativeLookaheadFunction, PROD_TYPE } from \"../../grammar/lookahead\";\nimport { forEach, has, isES2015MapSupported } from \"../../../utils/utils\";\nimport { DEFAULT_PARSER_CONFIG } from \"../parser\";\nimport { AT_LEAST_ONE_IDX, AT_LEAST_ONE_SEP_IDX, getKeyForAutomaticLookahead, MANY_IDX, MANY_SEP_IDX, OPTION_IDX, OR_IDX } from \"../../grammar/keys\";\nimport { collectMethods, getProductionDslName } from \"../../grammar/gast/gast\";\n/**\n * Trait responsible for the lookahead related utilities and optimizations.\n */\nvar LooksAhead = /** @class */ (function () {\n function LooksAhead() {\n }\n LooksAhead.prototype.initLooksAhead = function (config) {\n this.dynamicTokensEnabled = has(config, \"dynamicTokensEnabled\")\n ? config.dynamicTokensEnabled\n : DEFAULT_PARSER_CONFIG.dynamicTokensEnabled;\n this.maxLookahead = has(config, \"maxLookahead\")\n ? config.maxLookahead\n : DEFAULT_PARSER_CONFIG.maxLookahead;\n /* istanbul ignore next - Using plain array as dictionary will be tested on older node.js versions and IE11 */\n this.lookAheadFuncsCache = isES2015MapSupported() ? new Map() : [];\n // Performance optimization on newer engines that support ES6 Map\n // For larger Maps this is slightly faster than using a plain object (array in our case).\n /* istanbul ignore else - The else branch will be tested on older node.js versions and IE11 */\n if (isES2015MapSupported()) {\n this.getLaFuncFromCache = this.getLaFuncFromMap;\n this.setLaFuncCache = this.setLaFuncCacheUsingMap;\n }\n else {\n this.getLaFuncFromCache = this.getLaFuncFromObj;\n this.setLaFuncCache = this.setLaFuncUsingObj;\n }\n };\n LooksAhead.prototype.preComputeLookaheadFunctions = function (rules) {\n var _this = this;\n forEach(rules, function (currRule) {\n _this.TRACE_INIT(currRule.name + \" Rule Lookahead\", function () {\n var _a = collectMethods(currRule), alternation = _a.alternation, repetition = _a.repetition, option = _a.option, repetitionMandatory = _a.repetitionMandatory, repetitionMandatoryWithSeparator = _a.repetitionMandatoryWithSeparator, repetitionWithSeparator = _a.repetitionWithSeparator;\n forEach(alternation, function (currProd) {\n var prodIdx = currProd.idx === 0 ? \"\" : currProd.idx;\n _this.TRACE_INIT(\"\" + getProductionDslName(currProd) + prodIdx, function () {\n var laFunc = buildLookaheadFuncForOr(currProd.idx, currRule, currProd.maxLookahead || _this.maxLookahead, currProd.hasPredicates, _this.dynamicTokensEnabled, _this.lookAheadBuilderForAlternatives);\n var key = getKeyForAutomaticLookahead(_this.fullRuleNameToShort[currRule.name], OR_IDX, currProd.idx);\n _this.setLaFuncCache(key, laFunc);\n });\n });\n forEach(repetition, function (currProd) {\n _this.computeLookaheadFunc(currRule, currProd.idx, MANY_IDX, PROD_TYPE.REPETITION, currProd.maxLookahead, getProductionDslName(currProd));\n });\n forEach(option, function (currProd) {\n _this.computeLookaheadFunc(currRule, currProd.idx, OPTION_IDX, PROD_TYPE.OPTION, currProd.maxLookahead, getProductionDslName(currProd));\n });\n forEach(repetitionMandatory, function (currProd) {\n _this.computeLookaheadFunc(currRule, currProd.idx, AT_LEAST_ONE_IDX, PROD_TYPE.REPETITION_MANDATORY, currProd.maxLookahead, getProductionDslName(currProd));\n });\n forEach(repetitionMandatoryWithSeparator, function (currProd) {\n _this.computeLookaheadFunc(currRule, currProd.idx, AT_LEAST_ONE_SEP_IDX, PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR, currProd.maxLookahead, getProductionDslName(currProd));\n });\n forEach(repetitionWithSeparator, function (currProd) {\n _this.computeLookaheadFunc(currRule, currProd.idx, MANY_SEP_IDX, PROD_TYPE.REPETITION_WITH_SEPARATOR, currProd.maxLookahead, getProductionDslName(currProd));\n });\n });\n });\n };\n LooksAhead.prototype.computeLookaheadFunc = function (rule, prodOccurrence, prodKey, prodType, prodMaxLookahead, dslMethodName) {\n var _this = this;\n this.TRACE_INIT(\"\" + dslMethodName + (prodOccurrence === 0 ? \"\" : prodOccurrence), function () {\n var laFunc = buildLookaheadFuncForOptionalProd(prodOccurrence, rule, prodMaxLookahead || _this.maxLookahead, _this.dynamicTokensEnabled, prodType, _this.lookAheadBuilderForOptional);\n var key = getKeyForAutomaticLookahead(_this.fullRuleNameToShort[rule.name], prodKey, prodOccurrence);\n _this.setLaFuncCache(key, laFunc);\n });\n };\n LooksAhead.prototype.lookAheadBuilderForOptional = function (alt, tokenMatcher, dynamicTokensEnabled) {\n return buildSingleAlternativeLookaheadFunction(alt, tokenMatcher, dynamicTokensEnabled);\n };\n LooksAhead.prototype.lookAheadBuilderForAlternatives = function (alts, hasPredicates, tokenMatcher, dynamicTokensEnabled) {\n return buildAlternativesLookAheadFunc(alts, hasPredicates, tokenMatcher, dynamicTokensEnabled);\n };\n // this actually returns a number, but it is always used as a string (object prop key)\n LooksAhead.prototype.getKeyForAutomaticLookahead = function (dslMethodIdx, occurrence) {\n var currRuleShortName = this.getLastExplicitRuleShortName();\n return getKeyForAutomaticLookahead(currRuleShortName, dslMethodIdx, occurrence);\n };\n /* istanbul ignore next */\n LooksAhead.prototype.getLaFuncFromCache = function (key) {\n return undefined;\n };\n LooksAhead.prototype.getLaFuncFromMap = function (key) {\n return this.lookAheadFuncsCache.get(key);\n };\n /* istanbul ignore next - Using plain array as dictionary will be tested on older node.js versions and IE11 */\n LooksAhead.prototype.getLaFuncFromObj = function (key) {\n return this.lookAheadFuncsCache[key];\n };\n /* istanbul ignore next */\n LooksAhead.prototype.setLaFuncCache = function (key, value) { };\n LooksAhead.prototype.setLaFuncCacheUsingMap = function (key, value) {\n this.lookAheadFuncsCache.set(key, value);\n };\n /* istanbul ignore next - Using plain array as dictionary will be tested on older node.js versions and IE11 */\n LooksAhead.prototype.setLaFuncUsingObj = function (key, value) {\n this.lookAheadFuncsCache[key] = value;\n };\n return LooksAhead;\n}());\nexport { LooksAhead };\n//# sourceMappingURL=looksahead.js.map","/**\n * This nodeLocation tracking is not efficient and should only be used\n * when error recovery is enabled or the Token Vector contains virtual Tokens\n * (e.g, Python Indent/Outdent)\n * As it executes the calculation for every single terminal/nonTerminal\n * and does not rely on the fact the token vector is **sorted**\n */\nexport function setNodeLocationOnlyOffset(currNodeLocation, newLocationInfo) {\n // First (valid) update for this cst node\n if (isNaN(currNodeLocation.startOffset) === true) {\n // assumption1: Token location information is either NaN or a valid number\n // assumption2: Token location information is fully valid if it exist\n // (both start/end offsets exist and are numbers).\n currNodeLocation.startOffset = newLocationInfo.startOffset;\n currNodeLocation.endOffset = newLocationInfo.endOffset;\n }\n // Once the startOffset has been updated with a valid number it should never receive\n // any farther updates as the Token vector is sorted.\n // We still have to check this this condition for every new possible location info\n // because with error recovery enabled we may encounter invalid tokens (NaN location props)\n else if (currNodeLocation.endOffset < newLocationInfo.endOffset === true) {\n currNodeLocation.endOffset = newLocationInfo.endOffset;\n }\n}\n/**\n * This nodeLocation tracking is not efficient and should only be used\n * when error recovery is enabled or the Token Vector contains virtual Tokens\n * (e.g, Python Indent/Outdent)\n * As it executes the calculation for every single terminal/nonTerminal\n * and does not rely on the fact the token vector is **sorted**\n */\nexport function setNodeLocationFull(currNodeLocation, newLocationInfo) {\n // First (valid) update for this cst node\n if (isNaN(currNodeLocation.startOffset) === true) {\n // assumption1: Token location information is either NaN or a valid number\n // assumption2: Token location information is fully valid if it exist\n // (all start/end props exist and are numbers).\n currNodeLocation.startOffset = newLocationInfo.startOffset;\n currNodeLocation.startColumn = newLocationInfo.startColumn;\n currNodeLocation.startLine = newLocationInfo.startLine;\n currNodeLocation.endOffset = newLocationInfo.endOffset;\n currNodeLocation.endColumn = newLocationInfo.endColumn;\n currNodeLocation.endLine = newLocationInfo.endLine;\n }\n // Once the start props has been updated with a valid number it should never receive\n // any farther updates as the Token vector is sorted.\n // We still have to check this this condition for every new possible location info\n // because with error recovery enabled we may encounter invalid tokens (NaN location props)\n else if (currNodeLocation.endOffset < newLocationInfo.endOffset === true) {\n currNodeLocation.endOffset = newLocationInfo.endOffset;\n currNodeLocation.endColumn = newLocationInfo.endColumn;\n currNodeLocation.endLine = newLocationInfo.endLine;\n }\n}\nexport function addTerminalToCst(node, token, tokenTypeName) {\n if (node.children[tokenTypeName] === undefined) {\n node.children[tokenTypeName] = [token];\n }\n else {\n node.children[tokenTypeName].push(token);\n }\n}\nexport function addNoneTerminalToCst(node, ruleName, ruleResult) {\n if (node.children[ruleName] === undefined) {\n node.children[ruleName] = [ruleResult];\n }\n else {\n node.children[ruleName].push(ruleResult);\n }\n}\n//# sourceMappingURL=cst.js.map","import { isUndefined } from \"../utils/utils\";\nexport function classNameFromInstance(instance) {\n return functionName(instance.constructor);\n}\nvar FUNC_NAME_REGEXP = /^\\s*function\\s*(\\S*)\\s*\\(/;\nvar NAME = \"name\";\n/* istanbul ignore next too many hacks for IE/old versions of node.js here*/\nexport function functionName(func) {\n // Engines that support Function.prototype.name OR the nth (n>1) time after\n // the name has been computed in the following else block.\n var existingNameProp = func.name;\n if (existingNameProp) {\n return existingNameProp;\n }\n // hack for IE and engines that do not support Object.defineProperty on function.name (Node.js 0.10 && 0.12)\n var computedName = func.toString().match(FUNC_NAME_REGEXP)[1];\n return computedName;\n}\n/**\n * @returns {boolean} - has the property been successfully defined\n */\nexport function defineNameProp(obj, nameValue) {\n var namePropDescriptor = Object.getOwnPropertyDescriptor(obj, NAME);\n /* istanbul ignore else -> will only run in old versions of node.js */\n if (isUndefined(namePropDescriptor) || namePropDescriptor.configurable) {\n Object.defineProperty(obj, NAME, {\n enumerable: false,\n configurable: true,\n writable: false,\n value: nameValue\n });\n return true;\n }\n /* istanbul ignore next -> will only run in old versions of node.js */\n return false;\n}\n//# sourceMappingURL=lang_extensions.js.map","import { compact, contains, forEach, isArray, isEmpty, isFunction, isUndefined, keys, map } from \"../../utils/utils\";\nimport { defineNameProp, functionName } from \"../../lang/lang_extensions\";\nimport { validTermsPattern } from \"../grammar/checks\";\nexport function defaultVisit(ctx, param) {\n var childrenNames = keys(ctx);\n var childrenNamesLength = childrenNames.length;\n for (var i = 0; i < childrenNamesLength; i++) {\n var currChildName = childrenNames[i];\n var currChildArray = ctx[currChildName];\n var currChildArrayLength = currChildArray.length;\n for (var j = 0; j < currChildArrayLength; j++) {\n var currChild = currChildArray[j];\n // distinction between Tokens Children and CstNode children\n if (currChild.tokenTypeIdx === undefined) {\n this[currChild.name](currChild.children, param);\n }\n }\n }\n // defaultVisit does not support generic out param\n return undefined;\n}\nexport function createBaseSemanticVisitorConstructor(grammarName, ruleNames) {\n var derivedConstructor = function () { };\n // can be overwritten according to:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/\n // name?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FFunction%2Fname\n defineNameProp(derivedConstructor, grammarName + \"BaseSemantics\");\n var semanticProto = {\n visit: function (cstNode, param) {\n // enables writing more concise visitor methods when CstNode has only a single child\n if (isArray(cstNode)) {\n // A CST Node's children dictionary can never have empty arrays as values\n // If a key is defined there will be at least one element in the corresponding value array.\n cstNode = cstNode[0];\n }\n // enables passing optional CstNodes concisely.\n if (isUndefined(cstNode)) {\n return undefined;\n }\n return this[cstNode.name](cstNode.children, param);\n },\n validateVisitor: function () {\n var semanticDefinitionErrors = validateVisitor(this, ruleNames);\n if (!isEmpty(semanticDefinitionErrors)) {\n var errorMessages = map(semanticDefinitionErrors, function (currDefError) { return currDefError.msg; });\n throw Error(\"Errors Detected in CST Visitor <\" + functionName(this.constructor) + \">:\\n\\t\" + (\"\" + errorMessages.join(\"\\n\\n\").replace(/\\n/g, \"\\n\\t\")));\n }\n }\n };\n derivedConstructor.prototype = semanticProto;\n derivedConstructor.prototype.constructor = derivedConstructor;\n derivedConstructor._RULE_NAMES = ruleNames;\n return derivedConstructor;\n}\nexport function createBaseVisitorConstructorWithDefaults(grammarName, ruleNames, baseConstructor) {\n var derivedConstructor = function () { };\n // can be overwritten according to:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/\n // name?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FFunction%2Fname\n defineNameProp(derivedConstructor, grammarName + \"BaseSemanticsWithDefaults\");\n var withDefaultsProto = Object.create(baseConstructor.prototype);\n forEach(ruleNames, function (ruleName) {\n withDefaultsProto[ruleName] = defaultVisit;\n });\n derivedConstructor.prototype = withDefaultsProto;\n derivedConstructor.prototype.constructor = derivedConstructor;\n return derivedConstructor;\n}\nexport var CstVisitorDefinitionError;\n(function (CstVisitorDefinitionError) {\n CstVisitorDefinitionError[CstVisitorDefinitionError[\"REDUNDANT_METHOD\"] = 0] = \"REDUNDANT_METHOD\";\n CstVisitorDefinitionError[CstVisitorDefinitionError[\"MISSING_METHOD\"] = 1] = \"MISSING_METHOD\";\n})(CstVisitorDefinitionError || (CstVisitorDefinitionError = {}));\nexport function validateVisitor(visitorInstance, ruleNames) {\n var missingErrors = validateMissingCstMethods(visitorInstance, ruleNames);\n var redundantErrors = validateRedundantMethods(visitorInstance, ruleNames);\n return missingErrors.concat(redundantErrors);\n}\nexport function validateMissingCstMethods(visitorInstance, ruleNames) {\n var errors = map(ruleNames, function (currRuleName) {\n if (!isFunction(visitorInstance[currRuleName])) {\n return {\n msg: \"Missing visitor method: <\" + currRuleName + \"> on \" + functionName(visitorInstance.constructor) + \" CST Visitor.\",\n type: CstVisitorDefinitionError.MISSING_METHOD,\n methodName: currRuleName\n };\n }\n });\n return compact(errors);\n}\nvar VALID_PROP_NAMES = [\"constructor\", \"visit\", \"validateVisitor\"];\nexport function validateRedundantMethods(visitorInstance, ruleNames) {\n var errors = [];\n for (var prop in visitorInstance) {\n if (validTermsPattern.test(prop) &&\n isFunction(visitorInstance[prop]) &&\n !contains(VALID_PROP_NAMES, prop) &&\n !contains(ruleNames, prop)) {\n errors.push({\n msg: \"Redundant visitor method: <\" + prop + \"> on \" + functionName(visitorInstance.constructor) + \" CST Visitor\\n\" +\n \"There is no Grammar Rule corresponding to this method's name.\\n\" +\n (\"For utility methods on visitor classes use methods names that do not match /\" + validTermsPattern.source + \"/.\"),\n type: CstVisitorDefinitionError.REDUNDANT_METHOD,\n methodName: prop\n });\n }\n }\n return errors;\n}\n//# sourceMappingURL=cst_visitor.js.map","import { addNoneTerminalToCst, addTerminalToCst, setNodeLocationFull, setNodeLocationOnlyOffset } from \"../../cst/cst\";\nimport { has, isUndefined, keys, NOOP } from \"../../../utils/utils\";\nimport { createBaseSemanticVisitorConstructor, createBaseVisitorConstructorWithDefaults } from \"../../cst/cst_visitor\";\nimport { DEFAULT_PARSER_CONFIG } from \"../parser\";\n/**\n * This trait is responsible for the CST building logic.\n */\nvar TreeBuilder = /** @class */ (function () {\n function TreeBuilder() {\n }\n TreeBuilder.prototype.initTreeBuilder = function (config) {\n this.CST_STACK = [];\n // outputCst is no longer exposed/defined in the pubic API\n this.outputCst = config.outputCst;\n this.nodeLocationTracking = has(config, \"nodeLocationTracking\")\n ? config.nodeLocationTracking\n : DEFAULT_PARSER_CONFIG.nodeLocationTracking;\n if (!this.outputCst) {\n this.cstInvocationStateUpdate = NOOP;\n this.cstFinallyStateUpdate = NOOP;\n this.cstPostTerminal = NOOP;\n this.cstPostNonTerminal = NOOP;\n this.cstPostRule = NOOP;\n }\n else {\n if (/full/i.test(this.nodeLocationTracking)) {\n if (this.recoveryEnabled) {\n this.setNodeLocationFromToken = setNodeLocationFull;\n this.setNodeLocationFromNode = setNodeLocationFull;\n this.cstPostRule = NOOP;\n this.setInitialNodeLocation = this.setInitialNodeLocationFullRecovery;\n }\n else {\n this.setNodeLocationFromToken = NOOP;\n this.setNodeLocationFromNode = NOOP;\n this.cstPostRule = this.cstPostRuleFull;\n this.setInitialNodeLocation = this.setInitialNodeLocationFullRegular;\n }\n }\n else if (/onlyOffset/i.test(this.nodeLocationTracking)) {\n if (this.recoveryEnabled) {\n this.setNodeLocationFromToken = setNodeLocationOnlyOffset;\n this.setNodeLocationFromNode = setNodeLocationOnlyOffset;\n this.cstPostRule = NOOP;\n this.setInitialNodeLocation = this.setInitialNodeLocationOnlyOffsetRecovery;\n }\n else {\n this.setNodeLocationFromToken = NOOP;\n this.setNodeLocationFromNode = NOOP;\n this.cstPostRule = this.cstPostRuleOnlyOffset;\n this.setInitialNodeLocation = this.setInitialNodeLocationOnlyOffsetRegular;\n }\n }\n else if (/none/i.test(this.nodeLocationTracking)) {\n this.setNodeLocationFromToken = NOOP;\n this.setNodeLocationFromNode = NOOP;\n this.cstPostRule = NOOP;\n this.setInitialNodeLocation = NOOP;\n }\n else {\n throw Error(\"Invalid config option: \\\"\" + config.nodeLocationTracking + \"\\\"\");\n }\n }\n };\n TreeBuilder.prototype.setInitialNodeLocationOnlyOffsetRecovery = function (cstNode) {\n cstNode.location = {\n startOffset: NaN,\n endOffset: NaN\n };\n };\n TreeBuilder.prototype.setInitialNodeLocationOnlyOffsetRegular = function (cstNode) {\n cstNode.location = {\n // without error recovery the starting Location of a new CstNode is guaranteed\n // To be the next Token's startOffset (for valid inputs).\n // For invalid inputs there won't be any CSTOutput so this potential\n // inaccuracy does not matter\n startOffset: this.LA(1).startOffset,\n endOffset: NaN\n };\n };\n TreeBuilder.prototype.setInitialNodeLocationFullRecovery = function (cstNode) {\n cstNode.location = {\n startOffset: NaN,\n startLine: NaN,\n startColumn: NaN,\n endOffset: NaN,\n endLine: NaN,\n endColumn: NaN\n };\n };\n /**\n * @see setInitialNodeLocationOnlyOffsetRegular for explanation why this work\n \n * @param cstNode\n */\n TreeBuilder.prototype.setInitialNodeLocationFullRegular = function (cstNode) {\n var nextToken = this.LA(1);\n cstNode.location = {\n startOffset: nextToken.startOffset,\n startLine: nextToken.startLine,\n startColumn: nextToken.startColumn,\n endOffset: NaN,\n endLine: NaN,\n endColumn: NaN\n };\n };\n TreeBuilder.prototype.cstInvocationStateUpdate = function (fullRuleName, shortName) {\n var cstNode = {\n name: fullRuleName,\n children: {}\n };\n this.setInitialNodeLocation(cstNode);\n this.CST_STACK.push(cstNode);\n };\n TreeBuilder.prototype.cstFinallyStateUpdate = function () {\n this.CST_STACK.pop();\n };\n TreeBuilder.prototype.cstPostRuleFull = function (ruleCstNode) {\n var prevToken = this.LA(0);\n var loc = ruleCstNode.location;\n // If this condition is true it means we consumed at least one Token\n // In this CstNode.\n if (loc.startOffset <= prevToken.startOffset === true) {\n loc.endOffset = prevToken.endOffset;\n loc.endLine = prevToken.endLine;\n loc.endColumn = prevToken.endColumn;\n }\n // \"empty\" CstNode edge case\n else {\n loc.startOffset = NaN;\n loc.startLine = NaN;\n loc.startColumn = NaN;\n }\n };\n TreeBuilder.prototype.cstPostRuleOnlyOffset = function (ruleCstNode) {\n var prevToken = this.LA(0);\n var loc = ruleCstNode.location;\n // If this condition is true it means we consumed at least one Token\n // In this CstNode.\n if (loc.startOffset <= prevToken.startOffset === true) {\n loc.endOffset = prevToken.endOffset;\n }\n // \"empty\" CstNode edge case\n else {\n loc.startOffset = NaN;\n }\n };\n TreeBuilder.prototype.cstPostTerminal = function (key, consumedToken) {\n var rootCst = this.CST_STACK[this.CST_STACK.length - 1];\n addTerminalToCst(rootCst, consumedToken, key);\n // This is only used when **both** error recovery and CST Output are enabled.\n this.setNodeLocationFromToken(rootCst.location, consumedToken);\n };\n TreeBuilder.prototype.cstPostNonTerminal = function (ruleCstResult, ruleName) {\n var preCstNode = this.CST_STACK[this.CST_STACK.length - 1];\n addNoneTerminalToCst(preCstNode, ruleName, ruleCstResult);\n // This is only used when **both** error recovery and CST Output are enabled.\n this.setNodeLocationFromNode(preCstNode.location, ruleCstResult.location);\n };\n TreeBuilder.prototype.getBaseCstVisitorConstructor = function () {\n if (isUndefined(this.baseCstVisitorConstructor)) {\n var newBaseCstVisitorConstructor = createBaseSemanticVisitorConstructor(this.className, keys(this.gastProductionsCache));\n this.baseCstVisitorConstructor = newBaseCstVisitorConstructor;\n return newBaseCstVisitorConstructor;\n }\n return this.baseCstVisitorConstructor;\n };\n TreeBuilder.prototype.getBaseCstVisitorConstructorWithDefaults = function () {\n if (isUndefined(this.baseCstVisitorWithDefaultsConstructor)) {\n var newConstructor = createBaseVisitorConstructorWithDefaults(this.className, keys(this.gastProductionsCache), this.getBaseCstVisitorConstructor());\n this.baseCstVisitorWithDefaultsConstructor = newConstructor;\n return newConstructor;\n }\n return this.baseCstVisitorWithDefaultsConstructor;\n };\n TreeBuilder.prototype.getLastExplicitRuleShortName = function () {\n var ruleStack = this.RULE_STACK;\n return ruleStack[ruleStack.length - 1];\n };\n TreeBuilder.prototype.getPreviousExplicitRuleShortName = function () {\n var ruleStack = this.RULE_STACK;\n return ruleStack[ruleStack.length - 2];\n };\n TreeBuilder.prototype.getLastExplicitRuleOccurrenceIndex = function () {\n var occurrenceStack = this.RULE_OCCURRENCE_STACK;\n return occurrenceStack[occurrenceStack.length - 1];\n };\n return TreeBuilder;\n}());\nexport { TreeBuilder };\n//# sourceMappingURL=tree_builder.js.map","import { END_OF_FILE } from \"../parser\";\n/**\n * Trait responsible abstracting over the interaction with Lexer output (Token vector).\n *\n * This could be generalized to support other kinds of lexers, e.g.\n * - Just in Time Lexing / Lexer-Less parsing.\n * - Streaming Lexer.\n */\nvar LexerAdapter = /** @class */ (function () {\n function LexerAdapter() {\n }\n LexerAdapter.prototype.initLexerAdapter = function () {\n this.tokVector = [];\n this.tokVectorLength = 0;\n this.currIdx = -1;\n };\n Object.defineProperty(LexerAdapter.prototype, \"input\", {\n get: function () {\n return this.tokVector;\n },\n set: function (newInput) {\n if (this.selfAnalysisDone !== true) {\n throw Error(\"Missing invocation at the end of the Parser's constructor.\");\n }\n this.reset();\n this.tokVector = newInput;\n this.tokVectorLength = newInput.length;\n },\n enumerable: true,\n configurable: true\n });\n // skips a token and returns the next token\n LexerAdapter.prototype.SKIP_TOKEN = function () {\n if (this.currIdx <= this.tokVector.length - 2) {\n this.consumeToken();\n return this.LA(1);\n }\n else {\n return END_OF_FILE;\n }\n };\n // Lexer (accessing Token vector) related methods which can be overridden to implement lazy lexers\n // or lexers dependent on parser context.\n LexerAdapter.prototype.LA = function (howMuch) {\n var soughtIdx = this.currIdx + howMuch;\n if (soughtIdx < 0 || this.tokVectorLength <= soughtIdx) {\n return END_OF_FILE;\n }\n else {\n return this.tokVector[soughtIdx];\n }\n };\n LexerAdapter.prototype.consumeToken = function () {\n this.currIdx++;\n };\n LexerAdapter.prototype.exportLexerState = function () {\n return this.currIdx;\n };\n LexerAdapter.prototype.importLexerState = function (newState) {\n this.currIdx = newState;\n };\n LexerAdapter.prototype.resetLexerState = function () {\n this.currIdx = -1;\n };\n LexerAdapter.prototype.moveToTerminatedState = function () {\n this.currIdx = this.tokVector.length - 1;\n };\n LexerAdapter.prototype.getLexerPosition = function () {\n return this.exportLexerState();\n };\n return LexerAdapter;\n}());\nexport { LexerAdapter };\n//# sourceMappingURL=lexer_adapter.js.map","import { contains, values } from \"../../../utils/utils\";\nimport { isRecognitionException } from \"../../exceptions_public\";\nimport { DEFAULT_RULE_CONFIG, ParserDefinitionErrorType } from \"../parser\";\nimport { defaultGrammarValidatorErrorProvider } from \"../../errors_public\";\nimport { validateRuleIsOverridden } from \"../../grammar/checks\";\nimport { serializeGrammar } from \"../../grammar/gast/gast_public\";\n/**\n * This trait is responsible for implementing the public API\n * for defining Chevrotain parsers, i.e:\n * - CONSUME\n * - RULE\n * - OPTION\n * - ...\n */\nvar RecognizerApi = /** @class */ (function () {\n function RecognizerApi() {\n }\n RecognizerApi.prototype.ACTION = function (impl) {\n return impl.call(this);\n };\n RecognizerApi.prototype.consume = function (idx, tokType, options) {\n return this.consumeInternal(tokType, idx, options);\n };\n RecognizerApi.prototype.subrule = function (idx, ruleToCall, options) {\n return this.subruleInternal(ruleToCall, idx, options);\n };\n RecognizerApi.prototype.option = function (idx, actionORMethodDef) {\n return this.optionInternal(actionORMethodDef, idx);\n };\n RecognizerApi.prototype.or = function (idx, altsOrOpts) {\n return this.orInternal(altsOrOpts, idx);\n };\n RecognizerApi.prototype.many = function (idx, actionORMethodDef) {\n return this.manyInternal(idx, actionORMethodDef);\n };\n RecognizerApi.prototype.atLeastOne = function (idx, actionORMethodDef) {\n return this.atLeastOneInternal(idx, actionORMethodDef);\n };\n RecognizerApi.prototype.CONSUME = function (tokType, options) {\n return this.consumeInternal(tokType, 0, options);\n };\n RecognizerApi.prototype.CONSUME1 = function (tokType, options) {\n return this.consumeInternal(tokType, 1, options);\n };\n RecognizerApi.prototype.CONSUME2 = function (tokType, options) {\n return this.consumeInternal(tokType, 2, options);\n };\n RecognizerApi.prototype.CONSUME3 = function (tokType, options) {\n return this.consumeInternal(tokType, 3, options);\n };\n RecognizerApi.prototype.CONSUME4 = function (tokType, options) {\n return this.consumeInternal(tokType, 4, options);\n };\n RecognizerApi.prototype.CONSUME5 = function (tokType, options) {\n return this.consumeInternal(tokType, 5, options);\n };\n RecognizerApi.prototype.CONSUME6 = function (tokType, options) {\n return this.consumeInternal(tokType, 6, options);\n };\n RecognizerApi.prototype.CONSUME7 = function (tokType, options) {\n return this.consumeInternal(tokType, 7, options);\n };\n RecognizerApi.prototype.CONSUME8 = function (tokType, options) {\n return this.consumeInternal(tokType, 8, options);\n };\n RecognizerApi.prototype.CONSUME9 = function (tokType, options) {\n return this.consumeInternal(tokType, 9, options);\n };\n RecognizerApi.prototype.SUBRULE = function (ruleToCall, options) {\n return this.subruleInternal(ruleToCall, 0, options);\n };\n RecognizerApi.prototype.SUBRULE1 = function (ruleToCall, options) {\n return this.subruleInternal(ruleToCall, 1, options);\n };\n RecognizerApi.prototype.SUBRULE2 = function (ruleToCall, options) {\n return this.subruleInternal(ruleToCall, 2, options);\n };\n RecognizerApi.prototype.SUBRULE3 = function (ruleToCall, options) {\n return this.subruleInternal(ruleToCall, 3, options);\n };\n RecognizerApi.prototype.SUBRULE4 = function (ruleToCall, options) {\n return this.subruleInternal(ruleToCall, 4, options);\n };\n RecognizerApi.prototype.SUBRULE5 = function (ruleToCall, options) {\n return this.subruleInternal(ruleToCall, 5, options);\n };\n RecognizerApi.prototype.SUBRULE6 = function (ruleToCall, options) {\n return this.subruleInternal(ruleToCall, 6, options);\n };\n RecognizerApi.prototype.SUBRULE7 = function (ruleToCall, options) {\n return this.subruleInternal(ruleToCall, 7, options);\n };\n RecognizerApi.prototype.SUBRULE8 = function (ruleToCall, options) {\n return this.subruleInternal(ruleToCall, 8, options);\n };\n RecognizerApi.prototype.SUBRULE9 = function (ruleToCall, options) {\n return this.subruleInternal(ruleToCall, 9, options);\n };\n RecognizerApi.prototype.OPTION = function (actionORMethodDef) {\n return this.optionInternal(actionORMethodDef, 0);\n };\n RecognizerApi.prototype.OPTION1 = function (actionORMethodDef) {\n return this.optionInternal(actionORMethodDef, 1);\n };\n RecognizerApi.prototype.OPTION2 = function (actionORMethodDef) {\n return this.optionInternal(actionORMethodDef, 2);\n };\n RecognizerApi.prototype.OPTION3 = function (actionORMethodDef) {\n return this.optionInternal(actionORMethodDef, 3);\n };\n RecognizerApi.prototype.OPTION4 = function (actionORMethodDef) {\n return this.optionInternal(actionORMethodDef, 4);\n };\n RecognizerApi.prototype.OPTION5 = function (actionORMethodDef) {\n return this.optionInternal(actionORMethodDef, 5);\n };\n RecognizerApi.prototype.OPTION6 = function (actionORMethodDef) {\n return this.optionInternal(actionORMethodDef, 6);\n };\n RecognizerApi.prototype.OPTION7 = function (actionORMethodDef) {\n return this.optionInternal(actionORMethodDef, 7);\n };\n RecognizerApi.prototype.OPTION8 = function (actionORMethodDef) {\n return this.optionInternal(actionORMethodDef, 8);\n };\n RecognizerApi.prototype.OPTION9 = function (actionORMethodDef) {\n return this.optionInternal(actionORMethodDef, 9);\n };\n RecognizerApi.prototype.OR = function (altsOrOpts) {\n return this.orInternal(altsOrOpts, 0);\n };\n RecognizerApi.prototype.OR1 = function (altsOrOpts) {\n return this.orInternal(altsOrOpts, 1);\n };\n RecognizerApi.prototype.OR2 = function (altsOrOpts) {\n return this.orInternal(altsOrOpts, 2);\n };\n RecognizerApi.prototype.OR3 = function (altsOrOpts) {\n return this.orInternal(altsOrOpts, 3);\n };\n RecognizerApi.prototype.OR4 = function (altsOrOpts) {\n return this.orInternal(altsOrOpts, 4);\n };\n RecognizerApi.prototype.OR5 = function (altsOrOpts) {\n return this.orInternal(altsOrOpts, 5);\n };\n RecognizerApi.prototype.OR6 = function (altsOrOpts) {\n return this.orInternal(altsOrOpts, 6);\n };\n RecognizerApi.prototype.OR7 = function (altsOrOpts) {\n return this.orInternal(altsOrOpts, 7);\n };\n RecognizerApi.prototype.OR8 = function (altsOrOpts) {\n return this.orInternal(altsOrOpts, 8);\n };\n RecognizerApi.prototype.OR9 = function (altsOrOpts) {\n return this.orInternal(altsOrOpts, 9);\n };\n RecognizerApi.prototype.MANY = function (actionORMethodDef) {\n this.manyInternal(0, actionORMethodDef);\n };\n RecognizerApi.prototype.MANY1 = function (actionORMethodDef) {\n this.manyInternal(1, actionORMethodDef);\n };\n RecognizerApi.prototype.MANY2 = function (actionORMethodDef) {\n this.manyInternal(2, actionORMethodDef);\n };\n RecognizerApi.prototype.MANY3 = function (actionORMethodDef) {\n this.manyInternal(3, actionORMethodDef);\n };\n RecognizerApi.prototype.MANY4 = function (actionORMethodDef) {\n this.manyInternal(4, actionORMethodDef);\n };\n RecognizerApi.prototype.MANY5 = function (actionORMethodDef) {\n this.manyInternal(5, actionORMethodDef);\n };\n RecognizerApi.prototype.MANY6 = function (actionORMethodDef) {\n this.manyInternal(6, actionORMethodDef);\n };\n RecognizerApi.prototype.MANY7 = function (actionORMethodDef) {\n this.manyInternal(7, actionORMethodDef);\n };\n RecognizerApi.prototype.MANY8 = function (actionORMethodDef) {\n this.manyInternal(8, actionORMethodDef);\n };\n RecognizerApi.prototype.MANY9 = function (actionORMethodDef) {\n this.manyInternal(9, actionORMethodDef);\n };\n RecognizerApi.prototype.MANY_SEP = function (options) {\n this.manySepFirstInternal(0, options);\n };\n RecognizerApi.prototype.MANY_SEP1 = function (options) {\n this.manySepFirstInternal(1, options);\n };\n RecognizerApi.prototype.MANY_SEP2 = function (options) {\n this.manySepFirstInternal(2, options);\n };\n RecognizerApi.prototype.MANY_SEP3 = function (options) {\n this.manySepFirstInternal(3, options);\n };\n RecognizerApi.prototype.MANY_SEP4 = function (options) {\n this.manySepFirstInternal(4, options);\n };\n RecognizerApi.prototype.MANY_SEP5 = function (options) {\n this.manySepFirstInternal(5, options);\n };\n RecognizerApi.prototype.MANY_SEP6 = function (options) {\n this.manySepFirstInternal(6, options);\n };\n RecognizerApi.prototype.MANY_SEP7 = function (options) {\n this.manySepFirstInternal(7, options);\n };\n RecognizerApi.prototype.MANY_SEP8 = function (options) {\n this.manySepFirstInternal(8, options);\n };\n RecognizerApi.prototype.MANY_SEP9 = function (options) {\n this.manySepFirstInternal(9, options);\n };\n RecognizerApi.prototype.AT_LEAST_ONE = function (actionORMethodDef) {\n this.atLeastOneInternal(0, actionORMethodDef);\n };\n RecognizerApi.prototype.AT_LEAST_ONE1 = function (actionORMethodDef) {\n return this.atLeastOneInternal(1, actionORMethodDef);\n };\n RecognizerApi.prototype.AT_LEAST_ONE2 = function (actionORMethodDef) {\n this.atLeastOneInternal(2, actionORMethodDef);\n };\n RecognizerApi.prototype.AT_LEAST_ONE3 = function (actionORMethodDef) {\n this.atLeastOneInternal(3, actionORMethodDef);\n };\n RecognizerApi.prototype.AT_LEAST_ONE4 = function (actionORMethodDef) {\n this.atLeastOneInternal(4, actionORMethodDef);\n };\n RecognizerApi.prototype.AT_LEAST_ONE5 = function (actionORMethodDef) {\n this.atLeastOneInternal(5, actionORMethodDef);\n };\n RecognizerApi.prototype.AT_LEAST_ONE6 = function (actionORMethodDef) {\n this.atLeastOneInternal(6, actionORMethodDef);\n };\n RecognizerApi.prototype.AT_LEAST_ONE7 = function (actionORMethodDef) {\n this.atLeastOneInternal(7, actionORMethodDef);\n };\n RecognizerApi.prototype.AT_LEAST_ONE8 = function (actionORMethodDef) {\n this.atLeastOneInternal(8, actionORMethodDef);\n };\n RecognizerApi.prototype.AT_LEAST_ONE9 = function (actionORMethodDef) {\n this.atLeastOneInternal(9, actionORMethodDef);\n };\n RecognizerApi.prototype.AT_LEAST_ONE_SEP = function (options) {\n this.atLeastOneSepFirstInternal(0, options);\n };\n RecognizerApi.prototype.AT_LEAST_ONE_SEP1 = function (options) {\n this.atLeastOneSepFirstInternal(1, options);\n };\n RecognizerApi.prototype.AT_LEAST_ONE_SEP2 = function (options) {\n this.atLeastOneSepFirstInternal(2, options);\n };\n RecognizerApi.prototype.AT_LEAST_ONE_SEP3 = function (options) {\n this.atLeastOneSepFirstInternal(3, options);\n };\n RecognizerApi.prototype.AT_LEAST_ONE_SEP4 = function (options) {\n this.atLeastOneSepFirstInternal(4, options);\n };\n RecognizerApi.prototype.AT_LEAST_ONE_SEP5 = function (options) {\n this.atLeastOneSepFirstInternal(5, options);\n };\n RecognizerApi.prototype.AT_LEAST_ONE_SEP6 = function (options) {\n this.atLeastOneSepFirstInternal(6, options);\n };\n RecognizerApi.prototype.AT_LEAST_ONE_SEP7 = function (options) {\n this.atLeastOneSepFirstInternal(7, options);\n };\n RecognizerApi.prototype.AT_LEAST_ONE_SEP8 = function (options) {\n this.atLeastOneSepFirstInternal(8, options);\n };\n RecognizerApi.prototype.AT_LEAST_ONE_SEP9 = function (options) {\n this.atLeastOneSepFirstInternal(9, options);\n };\n RecognizerApi.prototype.RULE = function (name, implementation, config) {\n if (config === void 0) { config = DEFAULT_RULE_CONFIG; }\n if (contains(this.definedRulesNames, name)) {\n var errMsg = defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({\n topLevelRule: name,\n grammarName: this.className\n });\n var error = {\n message: errMsg,\n type: ParserDefinitionErrorType.DUPLICATE_RULE_NAME,\n ruleName: name\n };\n this.definitionErrors.push(error);\n }\n this.definedRulesNames.push(name);\n var ruleImplementation = this.defineRule(name, implementation, config);\n this[name] = ruleImplementation;\n return ruleImplementation;\n };\n RecognizerApi.prototype.OVERRIDE_RULE = function (name, impl, config) {\n if (config === void 0) { config = DEFAULT_RULE_CONFIG; }\n var ruleErrors = [];\n ruleErrors = ruleErrors.concat(validateRuleIsOverridden(name, this.definedRulesNames, this.className));\n this.definitionErrors.push.apply(this.definitionErrors, ruleErrors); // mutability for the win\n var ruleImplementation = this.defineRule(name, impl, config);\n this[name] = ruleImplementation;\n return ruleImplementation;\n };\n RecognizerApi.prototype.BACKTRACK = function (grammarRule, args) {\n return function () {\n // save org state\n this.isBackTrackingStack.push(1);\n var orgState = this.saveRecogState();\n try {\n grammarRule.apply(this, args);\n // if no exception was thrown we have succeed parsing the rule.\n return true;\n }\n catch (e) {\n if (isRecognitionException(e)) {\n return false;\n }\n else {\n throw e;\n }\n }\n finally {\n this.reloadRecogState(orgState);\n this.isBackTrackingStack.pop();\n }\n };\n };\n // GAST export APIs\n RecognizerApi.prototype.getGAstProductions = function () {\n return this.gastProductionsCache;\n };\n RecognizerApi.prototype.getSerializedGastProductions = function () {\n return serializeGrammar(values(this.gastProductionsCache));\n };\n return RecognizerApi;\n}());\nexport { RecognizerApi };\n//# sourceMappingURL=recognizer_api.js.map","import { cloneArr, cloneObj, every, flatten, has, isArray, isEmpty, isObject, reduce, uniq, values } from \"../../../utils/utils\";\nimport { AT_LEAST_ONE_IDX, AT_LEAST_ONE_SEP_IDX, BITS_FOR_METHOD_TYPE, BITS_FOR_OCCURRENCE_IDX, MANY_IDX, MANY_SEP_IDX, OPTION_IDX, OR_IDX } from \"../../grammar/keys\";\nimport { isRecognitionException, MismatchedTokenException, NotAllInputParsedException } from \"../../exceptions_public\";\nimport { PROD_TYPE } from \"../../grammar/lookahead\";\nimport { NextTerminalAfterAtLeastOneSepWalker, NextTerminalAfterAtLeastOneWalker, NextTerminalAfterManySepWalker, NextTerminalAfterManyWalker } from \"../../grammar/interpreter\";\nimport { DEFAULT_RULE_CONFIG } from \"../parser\";\nimport { IN_RULE_RECOVERY_EXCEPTION } from \"./recoverable\";\nimport { EOF } from \"../../../scan/tokens_public\";\nimport { augmentTokenTypes, isTokenType, tokenStructuredMatcher, tokenStructuredMatcherNoCategories } from \"../../../scan/tokens\";\nimport { classNameFromInstance } from \"../../../lang/lang_extensions\";\n/**\n * This trait is responsible for the runtime parsing engine\n * Used by the official API (recognizer_api.ts)\n */\nvar RecognizerEngine = /** @class */ (function () {\n function RecognizerEngine() {\n }\n RecognizerEngine.prototype.initRecognizerEngine = function (tokenVocabulary, config) {\n this.className = classNameFromInstance(this);\n // TODO: would using an ES6 Map or plain object be faster (CST building scenario)\n this.shortRuleNameToFull = {};\n this.fullRuleNameToShort = {};\n this.ruleShortNameIdx = 256;\n this.tokenMatcher = tokenStructuredMatcherNoCategories;\n this.definedRulesNames = [];\n this.tokensMap = {};\n this.isBackTrackingStack = [];\n this.RULE_STACK = [];\n this.RULE_OCCURRENCE_STACK = [];\n this.gastProductionsCache = {};\n if (has(config, \"serializedGrammar\")) {\n throw Error(\"The Parser's configuration can no longer contain a property.\\n\" +\n \"\\tSee: https://sap.github.io/chevrotain/docs/changes/BREAKING_CHANGES.html#_6-0-0\\n\" +\n \"\\tFor Further details.\");\n }\n if (isArray(tokenVocabulary)) {\n // This only checks for Token vocabularies provided as arrays.\n // That is good enough because the main objective is to detect users of pre-V4.0 APIs\n // rather than all edge cases of empty Token vocabularies.\n if (isEmpty(tokenVocabulary)) {\n throw Error(\"A Token Vocabulary cannot be empty.\\n\" +\n \"\\tNote that the first argument for the parser constructor\\n\" +\n \"\\tis no longer a Token vector (since v4.0).\");\n }\n if (typeof tokenVocabulary[0].startOffset === \"number\") {\n throw Error(\"The Parser constructor no longer accepts a token vector as the first argument.\\n\" +\n \"\\tSee: https://sap.github.io/chevrotain/docs/changes/BREAKING_CHANGES.html#_4-0-0\\n\" +\n \"\\tFor Further details.\");\n }\n }\n if (isArray(tokenVocabulary)) {\n this.tokensMap = reduce(tokenVocabulary, function (acc, tokType) {\n acc[tokType.name] = tokType;\n return acc;\n }, {});\n }\n else if (has(tokenVocabulary, \"modes\") &&\n every(flatten(values(tokenVocabulary.modes)), isTokenType)) {\n var allTokenTypes = flatten(values(tokenVocabulary.modes));\n var uniqueTokens = uniq(allTokenTypes);\n this.tokensMap = reduce(uniqueTokens, function (acc, tokType) {\n acc[tokType.name] = tokType;\n return acc;\n }, {});\n }\n else if (isObject(tokenVocabulary)) {\n this.tokensMap = cloneObj(tokenVocabulary);\n }\n else {\n throw new Error(\" argument must be An Array of Token constructors,\" +\n \" A dictionary of Token constructors or an IMultiModeLexerDefinition\");\n }\n // always add EOF to the tokenNames -> constructors map. it is useful to assure all the input has been\n // parsed with a clear error message (\"expecting EOF but found ...\")\n /* tslint:disable */\n this.tokensMap[\"EOF\"] = EOF;\n // TODO: This check may not be accurate for multi mode lexers\n var noTokenCategoriesUsed = every(values(tokenVocabulary), function (tokenConstructor) { return isEmpty(tokenConstructor.categoryMatches); });\n this.tokenMatcher = noTokenCategoriesUsed\n ? tokenStructuredMatcherNoCategories\n : tokenStructuredMatcher;\n // Because ES2015+ syntax should be supported for creating Token classes\n // We cannot assume that the Token classes were created using the \"extendToken\" utilities\n // Therefore we must augment the Token classes both on Lexer initialization and on Parser initialization\n augmentTokenTypes(values(this.tokensMap));\n };\n RecognizerEngine.prototype.defineRule = function (ruleName, impl, config) {\n if (this.selfAnalysisDone) {\n throw Error(\"Grammar rule <\" + ruleName + \"> may not be defined after the 'performSelfAnalysis' method has been called'\\n\" +\n \"Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.\");\n }\n var resyncEnabled = has(config, \"resyncEnabled\")\n ? config.resyncEnabled\n : DEFAULT_RULE_CONFIG.resyncEnabled;\n var recoveryValueFunc = has(config, \"recoveryValueFunc\")\n ? config.recoveryValueFunc\n : DEFAULT_RULE_CONFIG.recoveryValueFunc;\n // performance optimization: Use small integers as keys for the longer human readable \"full\" rule names.\n // this greatly improves Map access time (as much as 8% for some performance benchmarks).\n /* tslint:disable */\n var shortName = this.ruleShortNameIdx << (BITS_FOR_METHOD_TYPE + BITS_FOR_OCCURRENCE_IDX);\n /* tslint:enable */\n this.ruleShortNameIdx++;\n this.shortRuleNameToFull[shortName] = ruleName;\n this.fullRuleNameToShort[ruleName] = shortName;\n function invokeRuleWithTry(args) {\n try {\n if (this.outputCst === true) {\n impl.apply(this, args);\n var cst = this.CST_STACK[this.CST_STACK.length - 1];\n this.cstPostRule(cst);\n return cst;\n }\n else {\n return impl.apply(this, args);\n }\n }\n catch (e) {\n return this.invokeRuleCatch(e, resyncEnabled, recoveryValueFunc);\n }\n finally {\n this.ruleFinallyStateUpdate();\n }\n }\n var wrappedGrammarRule;\n wrappedGrammarRule = function (idxInCallingRule, args) {\n if (idxInCallingRule === void 0) { idxInCallingRule = 0; }\n this.ruleInvocationStateUpdate(shortName, ruleName, idxInCallingRule);\n return invokeRuleWithTry.call(this, args);\n };\n var ruleNamePropName = \"ruleName\";\n wrappedGrammarRule[ruleNamePropName] = ruleName;\n wrappedGrammarRule[\"originalGrammarAction\"] = impl;\n return wrappedGrammarRule;\n };\n RecognizerEngine.prototype.invokeRuleCatch = function (e, resyncEnabledConfig, recoveryValueFunc) {\n var isFirstInvokedRule = this.RULE_STACK.length === 1;\n // note the reSync is always enabled for the first rule invocation, because we must always be able to\n // reSync with EOF and just output some INVALID ParseTree\n // during backtracking reSync recovery is disabled, otherwise we can't be certain the backtracking\n // path is really the most valid one\n var reSyncEnabled = resyncEnabledConfig && !this.isBackTracking() && this.recoveryEnabled;\n if (isRecognitionException(e)) {\n var recogError = e;\n if (reSyncEnabled) {\n var reSyncTokType = this.findReSyncTokenType();\n if (this.isInCurrentRuleReSyncSet(reSyncTokType)) {\n recogError.resyncedTokens = this.reSyncTo(reSyncTokType);\n if (this.outputCst) {\n var partialCstResult = this.CST_STACK[this.CST_STACK.length - 1];\n partialCstResult.recoveredNode = true;\n return partialCstResult;\n }\n else {\n return recoveryValueFunc();\n }\n }\n else {\n if (this.outputCst) {\n var partialCstResult = this.CST_STACK[this.CST_STACK.length - 1];\n partialCstResult.recoveredNode = true;\n recogError.partialCstResult = partialCstResult;\n }\n // to be handled Further up the call stack\n throw recogError;\n }\n }\n else if (isFirstInvokedRule) {\n // otherwise a Redundant input error will be created as well and we cannot guarantee that this is indeed the case\n this.moveToTerminatedState();\n // the parser should never throw one of its own errors outside its flow.\n // even if error recovery is disabled\n return recoveryValueFunc();\n }\n else {\n // to be recovered Further up the call stack\n throw recogError;\n }\n }\n else {\n // some other Error type which we don't know how to handle (for example a built in JavaScript Error)\n throw e;\n }\n };\n // Implementation of parsing DSL\n RecognizerEngine.prototype.optionInternal = function (actionORMethodDef, occurrence) {\n var key = this.getKeyForAutomaticLookahead(OPTION_IDX, occurrence);\n return this.optionInternalLogic(actionORMethodDef, occurrence, key);\n };\n RecognizerEngine.prototype.optionInternalLogic = function (actionORMethodDef, occurrence, key) {\n var _this = this;\n var lookAheadFunc = this.getLaFuncFromCache(key);\n var action;\n var predicate;\n if (actionORMethodDef.DEF !== undefined) {\n action = actionORMethodDef.DEF;\n predicate = actionORMethodDef.GATE;\n // predicate present\n if (predicate !== undefined) {\n var orgLookaheadFunction_1 = lookAheadFunc;\n lookAheadFunc = function () {\n return predicate.call(_this) && orgLookaheadFunction_1.call(_this);\n };\n }\n }\n else {\n action = actionORMethodDef;\n }\n if (lookAheadFunc.call(this) === true) {\n return action.call(this);\n }\n return undefined;\n };\n RecognizerEngine.prototype.atLeastOneInternal = function (prodOccurrence, actionORMethodDef) {\n var laKey = this.getKeyForAutomaticLookahead(AT_LEAST_ONE_IDX, prodOccurrence);\n return this.atLeastOneInternalLogic(prodOccurrence, actionORMethodDef, laKey);\n };\n RecognizerEngine.prototype.atLeastOneInternalLogic = function (prodOccurrence, actionORMethodDef, key) {\n var _this = this;\n var lookAheadFunc = this.getLaFuncFromCache(key);\n var action;\n var predicate;\n if (actionORMethodDef.DEF !== undefined) {\n action = actionORMethodDef.DEF;\n predicate = actionORMethodDef.GATE;\n // predicate present\n if (predicate !== undefined) {\n var orgLookaheadFunction_2 = lookAheadFunc;\n lookAheadFunc = function () {\n return predicate.call(_this) && orgLookaheadFunction_2.call(_this);\n };\n }\n }\n else {\n action = actionORMethodDef;\n }\n if (lookAheadFunc.call(this) === true) {\n var notStuck = this.doSingleRepetition(action);\n while (lookAheadFunc.call(this) === true &&\n notStuck === true) {\n notStuck = this.doSingleRepetition(action);\n }\n }\n else {\n throw this.raiseEarlyExitException(prodOccurrence, PROD_TYPE.REPETITION_MANDATORY, actionORMethodDef.ERR_MSG);\n }\n // note that while it may seem that this can cause an error because by using a recursive call to\n // AT_LEAST_ONE we change the grammar to AT_LEAST_TWO, AT_LEAST_THREE ... , the possible recursive call\n // from the tryInRepetitionRecovery(...) will only happen IFF there really are TWO/THREE/.... items.\n // Performance optimization: \"attemptInRepetitionRecovery\" will be defined as NOOP unless recovery is enabled\n this.attemptInRepetitionRecovery(this.atLeastOneInternal, [prodOccurrence, actionORMethodDef], lookAheadFunc, AT_LEAST_ONE_IDX, prodOccurrence, NextTerminalAfterAtLeastOneWalker);\n };\n RecognizerEngine.prototype.atLeastOneSepFirstInternal = function (prodOccurrence, options) {\n var laKey = this.getKeyForAutomaticLookahead(AT_LEAST_ONE_SEP_IDX, prodOccurrence);\n this.atLeastOneSepFirstInternalLogic(prodOccurrence, options, laKey);\n };\n RecognizerEngine.prototype.atLeastOneSepFirstInternalLogic = function (prodOccurrence, options, key) {\n var _this = this;\n var action = options.DEF;\n var separator = options.SEP;\n var firstIterationLookaheadFunc = this.getLaFuncFromCache(key);\n // 1st iteration\n if (firstIterationLookaheadFunc.call(this) === true) {\n ;\n action.call(this);\n // TODO: Optimization can move this function construction into \"attemptInRepetitionRecovery\"\n // because it is only needed in error recovery scenarios.\n var separatorLookAheadFunc = function () {\n return _this.tokenMatcher(_this.LA(1), separator);\n };\n // 2nd..nth iterations\n while (this.tokenMatcher(this.LA(1), separator) === true) {\n // note that this CONSUME will never enter recovery because\n // the separatorLookAheadFunc checks that the separator really does exist.\n this.CONSUME(separator);\n action.call(this);\n }\n // Performance optimization: \"attemptInRepetitionRecovery\" will be defined as NOOP unless recovery is enabled\n this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal, [\n prodOccurrence,\n separator,\n separatorLookAheadFunc,\n action,\n NextTerminalAfterAtLeastOneSepWalker\n ], separatorLookAheadFunc, AT_LEAST_ONE_SEP_IDX, prodOccurrence, NextTerminalAfterAtLeastOneSepWalker);\n }\n else {\n throw this.raiseEarlyExitException(prodOccurrence, PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR, options.ERR_MSG);\n }\n };\n RecognizerEngine.prototype.manyInternal = function (prodOccurrence, actionORMethodDef) {\n var laKey = this.getKeyForAutomaticLookahead(MANY_IDX, prodOccurrence);\n return this.manyInternalLogic(prodOccurrence, actionORMethodDef, laKey);\n };\n RecognizerEngine.prototype.manyInternalLogic = function (prodOccurrence, actionORMethodDef, key) {\n var _this = this;\n var lookaheadFunction = this.getLaFuncFromCache(key);\n var action;\n var predicate;\n if (actionORMethodDef.DEF !== undefined) {\n action = actionORMethodDef.DEF;\n predicate = actionORMethodDef.GATE;\n // predicate present\n if (predicate !== undefined) {\n var orgLookaheadFunction_3 = lookaheadFunction;\n lookaheadFunction = function () {\n return predicate.call(_this) && orgLookaheadFunction_3.call(_this);\n };\n }\n }\n else {\n action = actionORMethodDef;\n }\n var notStuck = true;\n while (lookaheadFunction.call(this) === true && notStuck === true) {\n notStuck = this.doSingleRepetition(action);\n }\n // Performance optimization: \"attemptInRepetitionRecovery\" will be defined as NOOP unless recovery is enabled\n this.attemptInRepetitionRecovery(this.manyInternal, [prodOccurrence, actionORMethodDef], lookaheadFunction, MANY_IDX, prodOccurrence, NextTerminalAfterManyWalker, \n // The notStuck parameter is only relevant when \"attemptInRepetitionRecovery\"\n // is invoked from manyInternal, in the MANY_SEP case and AT_LEAST_ONE[_SEP]\n // An infinite loop cannot occur as:\n // - Either the lookahead is guaranteed to consume something (Single Token Separator)\n // - AT_LEAST_ONE by definition is guaranteed to consume something (or error out).\n notStuck);\n };\n RecognizerEngine.prototype.manySepFirstInternal = function (prodOccurrence, options) {\n var laKey = this.getKeyForAutomaticLookahead(MANY_SEP_IDX, prodOccurrence);\n this.manySepFirstInternalLogic(prodOccurrence, options, laKey);\n };\n RecognizerEngine.prototype.manySepFirstInternalLogic = function (prodOccurrence, options, key) {\n var _this = this;\n var action = options.DEF;\n var separator = options.SEP;\n var firstIterationLaFunc = this.getLaFuncFromCache(key);\n // 1st iteration\n if (firstIterationLaFunc.call(this) === true) {\n action.call(this);\n var separatorLookAheadFunc = function () {\n return _this.tokenMatcher(_this.LA(1), separator);\n };\n // 2nd..nth iterations\n while (this.tokenMatcher(this.LA(1), separator) === true) {\n // note that this CONSUME will never enter recovery because\n // the separatorLookAheadFunc checks that the separator really does exist.\n this.CONSUME(separator);\n // No need for checking infinite loop here due to consuming the separator.\n action.call(this);\n }\n // Performance optimization: \"attemptInRepetitionRecovery\" will be defined as NOOP unless recovery is enabled\n this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal, [\n prodOccurrence,\n separator,\n separatorLookAheadFunc,\n action,\n NextTerminalAfterManySepWalker\n ], separatorLookAheadFunc, MANY_SEP_IDX, prodOccurrence, NextTerminalAfterManySepWalker);\n }\n };\n RecognizerEngine.prototype.repetitionSepSecondInternal = function (prodOccurrence, separator, separatorLookAheadFunc, action, nextTerminalAfterWalker) {\n while (separatorLookAheadFunc()) {\n // note that this CONSUME will never enter recovery because\n // the separatorLookAheadFunc checks that the separator really does exist.\n this.CONSUME(separator);\n action.call(this);\n }\n // we can only arrive to this function after an error\n // has occurred (hence the name 'second') so the following\n // IF will always be entered, its possible to remove it...\n // however it is kept to avoid confusion and be consistent.\n // Performance optimization: \"attemptInRepetitionRecovery\" will be defined as NOOP unless recovery is enabled\n /* istanbul ignore else */\n this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal, [\n prodOccurrence,\n separator,\n separatorLookAheadFunc,\n action,\n nextTerminalAfterWalker\n ], separatorLookAheadFunc, AT_LEAST_ONE_SEP_IDX, prodOccurrence, nextTerminalAfterWalker);\n };\n RecognizerEngine.prototype.doSingleRepetition = function (action) {\n var beforeIteration = this.getLexerPosition();\n action.call(this);\n var afterIteration = this.getLexerPosition();\n // This boolean will indicate if this repetition progressed\n // or if we are \"stuck\" (potential infinite loop in the repetition).\n return afterIteration > beforeIteration;\n };\n RecognizerEngine.prototype.orInternal = function (altsOrOpts, occurrence) {\n var laKey = this.getKeyForAutomaticLookahead(OR_IDX, occurrence);\n var alts = isArray(altsOrOpts)\n ? altsOrOpts\n : altsOrOpts.DEF;\n var laFunc = this.getLaFuncFromCache(laKey);\n var altIdxToTake = laFunc.call(this, alts);\n if (altIdxToTake !== undefined) {\n var chosenAlternative = alts[altIdxToTake];\n return chosenAlternative.ALT.call(this);\n }\n this.raiseNoAltException(occurrence, altsOrOpts.ERR_MSG);\n };\n RecognizerEngine.prototype.ruleFinallyStateUpdate = function () {\n this.RULE_STACK.pop();\n this.RULE_OCCURRENCE_STACK.pop();\n // NOOP when cst is disabled\n this.cstFinallyStateUpdate();\n if (this.RULE_STACK.length === 0 && this.isAtEndOfInput() === false) {\n var firstRedundantTok = this.LA(1);\n var errMsg = this.errorMessageProvider.buildNotAllInputParsedMessage({\n firstRedundant: firstRedundantTok,\n ruleName: this.getCurrRuleFullName()\n });\n this.SAVE_ERROR(new NotAllInputParsedException(errMsg, firstRedundantTok));\n }\n };\n RecognizerEngine.prototype.subruleInternal = function (ruleToCall, idx, options) {\n var ruleResult;\n try {\n var args = options !== undefined ? options.ARGS : undefined;\n ruleResult = ruleToCall.call(this, idx, args);\n this.cstPostNonTerminal(ruleResult, options !== undefined && options.LABEL !== undefined\n ? options.LABEL\n : ruleToCall.ruleName);\n return ruleResult;\n }\n catch (e) {\n this.subruleInternalError(e, options, ruleToCall.ruleName);\n }\n };\n RecognizerEngine.prototype.subruleInternalError = function (e, options, ruleName) {\n if (isRecognitionException(e) && e.partialCstResult !== undefined) {\n this.cstPostNonTerminal(e.partialCstResult, options !== undefined && options.LABEL !== undefined\n ? options.LABEL\n : ruleName);\n delete e.partialCstResult;\n }\n throw e;\n };\n RecognizerEngine.prototype.consumeInternal = function (tokType, idx, options) {\n var consumedToken;\n try {\n var nextToken = this.LA(1);\n if (this.tokenMatcher(nextToken, tokType) === true) {\n this.consumeToken();\n consumedToken = nextToken;\n }\n else {\n this.consumeInternalError(tokType, nextToken, options);\n }\n }\n catch (eFromConsumption) {\n consumedToken = this.consumeInternalRecovery(tokType, idx, eFromConsumption);\n }\n this.cstPostTerminal(options !== undefined && options.LABEL !== undefined\n ? options.LABEL\n : tokType.name, consumedToken);\n return consumedToken;\n };\n RecognizerEngine.prototype.consumeInternalError = function (tokType, nextToken, options) {\n var msg;\n var previousToken = this.LA(0);\n if (options !== undefined && options.ERR_MSG) {\n msg = options.ERR_MSG;\n }\n else {\n msg = this.errorMessageProvider.buildMismatchTokenMessage({\n expected: tokType,\n actual: nextToken,\n previous: previousToken,\n ruleName: this.getCurrRuleFullName()\n });\n }\n throw this.SAVE_ERROR(new MismatchedTokenException(msg, nextToken, previousToken));\n };\n RecognizerEngine.prototype.consumeInternalRecovery = function (tokType, idx, eFromConsumption) {\n // no recovery allowed during backtracking, otherwise backtracking may recover invalid syntax and accept it\n // but the original syntax could have been parsed successfully without any backtracking + recovery\n if (this.recoveryEnabled &&\n // TODO: more robust checking of the exception type. Perhaps Typescript extending expressions?\n eFromConsumption.name === \"MismatchedTokenException\" &&\n !this.isBackTracking()) {\n var follows = this.getFollowsForInRuleRecovery(tokType, idx);\n try {\n return this.tryInRuleRecovery(tokType, follows);\n }\n catch (eFromInRuleRecovery) {\n if (eFromInRuleRecovery.name === IN_RULE_RECOVERY_EXCEPTION) {\n // failed in RuleRecovery.\n // throw the original error in order to trigger reSync error recovery\n throw eFromConsumption;\n }\n else {\n throw eFromInRuleRecovery;\n }\n }\n }\n else {\n throw eFromConsumption;\n }\n };\n RecognizerEngine.prototype.saveRecogState = function () {\n // errors is a getter which will clone the errors array\n var savedErrors = this.errors;\n var savedRuleStack = cloneArr(this.RULE_STACK);\n return {\n errors: savedErrors,\n lexerState: this.exportLexerState(),\n RULE_STACK: savedRuleStack,\n CST_STACK: this.CST_STACK\n };\n };\n RecognizerEngine.prototype.reloadRecogState = function (newState) {\n this.errors = newState.errors;\n this.importLexerState(newState.lexerState);\n this.RULE_STACK = newState.RULE_STACK;\n };\n RecognizerEngine.prototype.ruleInvocationStateUpdate = function (shortName, fullName, idxInCallingRule) {\n this.RULE_OCCURRENCE_STACK.push(idxInCallingRule);\n this.RULE_STACK.push(shortName);\n // NOOP when cst is disabled\n this.cstInvocationStateUpdate(fullName, shortName);\n };\n RecognizerEngine.prototype.isBackTracking = function () {\n return this.isBackTrackingStack.length !== 0;\n };\n RecognizerEngine.prototype.getCurrRuleFullName = function () {\n var shortName = this.getLastExplicitRuleShortName();\n return this.shortRuleNameToFull[shortName];\n };\n RecognizerEngine.prototype.shortRuleNameToFullName = function (shortName) {\n return this.shortRuleNameToFull[shortName];\n };\n RecognizerEngine.prototype.isAtEndOfInput = function () {\n return this.tokenMatcher(this.LA(1), EOF);\n };\n RecognizerEngine.prototype.reset = function () {\n this.resetLexerState();\n this.isBackTrackingStack = [];\n this.errors = [];\n this.RULE_STACK = [];\n // TODO: extract a specific reset for TreeBuilder trait\n this.CST_STACK = [];\n this.RULE_OCCURRENCE_STACK = [];\n };\n return RecognizerEngine;\n}());\nexport { RecognizerEngine };\n//# sourceMappingURL=recognizer_engine.js.map","import { EarlyExitException, isRecognitionException, NoViableAltException } from \"../../exceptions_public\";\nimport { cloneArr, has } from \"../../../utils/utils\";\nimport { getLookaheadPathsForOptionalProd, getLookaheadPathsForOr } from \"../../grammar/lookahead\";\nimport { DEFAULT_PARSER_CONFIG } from \"../parser\";\n/**\n * Trait responsible for runtime parsing errors.\n */\nvar ErrorHandler = /** @class */ (function () {\n function ErrorHandler() {\n }\n ErrorHandler.prototype.initErrorHandler = function (config) {\n this._errors = [];\n this.errorMessageProvider = has(config, \"errorMessageProvider\")\n ? config.errorMessageProvider\n : DEFAULT_PARSER_CONFIG.errorMessageProvider;\n };\n ErrorHandler.prototype.SAVE_ERROR = function (error) {\n if (isRecognitionException(error)) {\n error.context = {\n ruleStack: this.getHumanReadableRuleStack(),\n ruleOccurrenceStack: cloneArr(this.RULE_OCCURRENCE_STACK)\n };\n this._errors.push(error);\n return error;\n }\n else {\n throw Error(\"Trying to save an Error which is not a RecognitionException\");\n }\n };\n Object.defineProperty(ErrorHandler.prototype, \"errors\", {\n get: function () {\n return cloneArr(this._errors);\n },\n set: function (newErrors) {\n this._errors = newErrors;\n },\n enumerable: true,\n configurable: true\n });\n // TODO: consider caching the error message computed information\n ErrorHandler.prototype.raiseEarlyExitException = function (occurrence, prodType, userDefinedErrMsg) {\n var ruleName = this.getCurrRuleFullName();\n var ruleGrammar = this.getGAstProductions()[ruleName];\n var lookAheadPathsPerAlternative = getLookaheadPathsForOptionalProd(occurrence, ruleGrammar, prodType, this.maxLookahead);\n var insideProdPaths = lookAheadPathsPerAlternative[0];\n var actualTokens = [];\n for (var i = 1; i <= this.maxLookahead; i++) {\n actualTokens.push(this.LA(i));\n }\n var msg = this.errorMessageProvider.buildEarlyExitMessage({\n expectedIterationPaths: insideProdPaths,\n actual: actualTokens,\n previous: this.LA(0),\n customUserDescription: userDefinedErrMsg,\n ruleName: ruleName\n });\n throw this.SAVE_ERROR(new EarlyExitException(msg, this.LA(1), this.LA(0)));\n };\n // TODO: consider caching the error message computed information\n ErrorHandler.prototype.raiseNoAltException = function (occurrence, errMsgTypes) {\n var ruleName = this.getCurrRuleFullName();\n var ruleGrammar = this.getGAstProductions()[ruleName];\n // TODO: getLookaheadPathsForOr can be slow for large enough maxLookahead and certain grammars, consider caching ?\n var lookAheadPathsPerAlternative = getLookaheadPathsForOr(occurrence, ruleGrammar, this.maxLookahead);\n var actualTokens = [];\n for (var i = 1; i <= this.maxLookahead; i++) {\n actualTokens.push(this.LA(i));\n }\n var previousToken = this.LA(0);\n var errMsg = this.errorMessageProvider.buildNoViableAltMessage({\n expectedPathsPerAlt: lookAheadPathsPerAlternative,\n actual: actualTokens,\n previous: previousToken,\n customUserDescription: errMsgTypes,\n ruleName: this.getCurrRuleFullName()\n });\n throw this.SAVE_ERROR(new NoViableAltException(errMsg, this.LA(1), previousToken));\n };\n return ErrorHandler;\n}());\nexport { ErrorHandler };\n//# sourceMappingURL=error_handler.js.map","import { NextAfterTokenWalker, nextPossibleTokensAfter } from \"../../grammar/interpreter\";\nimport { first, isUndefined } from \"../../../utils/utils\";\nvar ContentAssist = /** @class */ (function () {\n function ContentAssist() {\n }\n ContentAssist.prototype.initContentAssist = function () { };\n ContentAssist.prototype.computeContentAssist = function (startRuleName, precedingInput) {\n var startRuleGast = this.gastProductionsCache[startRuleName];\n if (isUndefined(startRuleGast)) {\n throw Error(\"Rule ->\" + startRuleName + \"<- does not exist in this grammar.\");\n }\n return nextPossibleTokensAfter([startRuleGast], precedingInput, this.tokenMatcher, this.maxLookahead);\n };\n // TODO: should this be a member method or a utility? it does not have any state or usage of 'this'...\n // TODO: should this be more explicitly part of the public API?\n ContentAssist.prototype.getNextPossibleTokenTypes = function (grammarPath) {\n var topRuleName = first(grammarPath.ruleStack);\n var gastProductions = this.getGAstProductions();\n var topProduction = gastProductions[topRuleName];\n var nextPossibleTokenTypes = new NextAfterTokenWalker(topProduction, grammarPath).startWalking();\n return nextPossibleTokenTypes;\n };\n return ContentAssist;\n}());\nexport { ContentAssist };\n//# sourceMappingURL=context_assist.js.map","import { forEach, has, isArray, isFunction, peek, some } from \"../../../utils/utils\";\nimport { Alternation, Alternative, NonTerminal, Option, Repetition, RepetitionMandatory, RepetitionMandatoryWithSeparator, RepetitionWithSeparator, Rule, Terminal } from \"../../grammar/gast/gast_public\";\nimport { Lexer } from \"../../../scan/lexer_public\";\nimport { augmentTokenTypes, hasShortKeyProperty } from \"../../../scan/tokens\";\nimport { createToken, createTokenInstance } from \"../../../scan/tokens_public\";\nimport { END_OF_FILE } from \"../parser\";\nimport { BITS_FOR_OCCURRENCE_IDX } from \"../../grammar/keys\";\nvar RECORDING_NULL_OBJECT = {\n description: \"This Object indicates the Parser is during Recording Phase\"\n};\nObject.freeze(RECORDING_NULL_OBJECT);\nvar HANDLE_SEPARATOR = true;\nvar MAX_METHOD_IDX = Math.pow(2, BITS_FOR_OCCURRENCE_IDX) - 1;\nvar RFT = createToken({ name: \"RECORDING_PHASE_TOKEN\", pattern: Lexer.NA });\naugmentTokenTypes([RFT]);\nvar RECORDING_PHASE_TOKEN = createTokenInstance(RFT, \"This IToken indicates the Parser is in Recording Phase\\n\\t\" +\n \"\" +\n \"See: https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording for details\", \n// Using \"-1\" instead of NaN (as in EOF) because an actual number is less likely to\n// cause errors if the output of LA or CONSUME would be (incorrectly) used during the recording phase.\n-1, -1, -1, -1, -1, -1);\nObject.freeze(RECORDING_PHASE_TOKEN);\nvar RECORDING_PHASE_CSTNODE = {\n name: \"This CSTNode indicates the Parser is in Recording Phase\\n\\t\" +\n \"See: https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording for details\",\n children: {}\n};\n/**\n * This trait handles the creation of the GAST structure for Chevrotain Grammars\n */\nvar GastRecorder = /** @class */ (function () {\n function GastRecorder() {\n }\n GastRecorder.prototype.initGastRecorder = function (config) {\n this.recordingProdStack = [];\n this.RECORDING_PHASE = false;\n };\n GastRecorder.prototype.enableRecording = function () {\n var _this = this;\n this.RECORDING_PHASE = true;\n this.TRACE_INIT(\"Enable Recording\", function () {\n var _loop_1 = function (i) {\n var idx = i > 0 ? i : \"\";\n _this[\"CONSUME\" + idx] = function (arg1, arg2) {\n return this.consumeInternalRecord(arg1, i, arg2);\n };\n _this[\"SUBRULE\" + idx] = function (arg1, arg2) {\n return this.subruleInternalRecord(arg1, i, arg2);\n };\n _this[\"OPTION\" + idx] = function (arg1) {\n return this.optionInternalRecord(arg1, i);\n };\n _this[\"OR\" + idx] = function (arg1) {\n return this.orInternalRecord(arg1, i);\n };\n _this[\"MANY\" + idx] = function (arg1) {\n this.manyInternalRecord(i, arg1);\n };\n _this[\"MANY_SEP\" + idx] = function (arg1) {\n this.manySepFirstInternalRecord(i, arg1);\n };\n _this[\"AT_LEAST_ONE\" + idx] = function (arg1) {\n this.atLeastOneInternalRecord(i, arg1);\n };\n _this[\"AT_LEAST_ONE_SEP\" + idx] = function (arg1) {\n this.atLeastOneSepFirstInternalRecord(i, arg1);\n };\n };\n /**\n * Warning Dark Voodoo Magic upcoming!\n * We are \"replacing\" the public parsing DSL methods API\n * With **new** alternative implementations on the Parser **instance**\n *\n * So far this is the only way I've found to avoid performance regressions during parsing time.\n * - Approx 30% performance regression was measured on Chrome 75 Canary when attempting to replace the \"internal\"\n * implementations directly instead.\n */\n for (var i = 0; i < 10; i++) {\n _loop_1(i);\n }\n // DSL methods with the idx(suffix) as an argument\n _this[\"consume\"] = function (idx, arg1, arg2) {\n return this.consumeInternalRecord(arg1, idx, arg2);\n };\n _this[\"subrule\"] = function (idx, arg1, arg2) {\n return this.subruleInternalRecord(arg1, idx, arg2);\n };\n _this[\"option\"] = function (idx, arg1) {\n return this.optionInternalRecord(arg1, idx);\n };\n _this[\"or\"] = function (idx, arg1) {\n return this.orInternalRecord(arg1, idx);\n };\n _this[\"many\"] = function (idx, arg1) {\n this.manyInternalRecord(idx, arg1);\n };\n _this[\"atLeastOne\"] = function (idx, arg1) {\n this.atLeastOneInternalRecord(idx, arg1);\n };\n _this.ACTION = _this.ACTION_RECORD;\n _this.BACKTRACK = _this.BACKTRACK_RECORD;\n _this.LA = _this.LA_RECORD;\n });\n };\n GastRecorder.prototype.disableRecording = function () {\n var _this = this;\n this.RECORDING_PHASE = false;\n // By deleting these **instance** properties, any future invocation\n // will be deferred to the original methods on the **prototype** object\n // This seems to get rid of any incorrect optimizations that V8 may\n // do during the recording phase.\n this.TRACE_INIT(\"Deleting Recording methods\", function () {\n for (var i = 0; i < 10; i++) {\n var idx = i > 0 ? i : \"\";\n delete _this[\"CONSUME\" + idx];\n delete _this[\"SUBRULE\" + idx];\n delete _this[\"OPTION\" + idx];\n delete _this[\"OR\" + idx];\n delete _this[\"MANY\" + idx];\n delete _this[\"MANY_SEP\" + idx];\n delete _this[\"AT_LEAST_ONE\" + idx];\n delete _this[\"AT_LEAST_ONE_SEP\" + idx];\n }\n delete _this[\"consume\"];\n delete _this[\"subrule\"];\n delete _this[\"option\"];\n delete _this[\"or\"];\n delete _this[\"many\"];\n delete _this[\"atLeastOne\"];\n delete _this.ACTION;\n delete _this.BACKTRACK;\n delete _this.LA;\n });\n };\n // TODO: is there any way to use this method to check no\n // Parser methods are called inside an ACTION?\n // Maybe try/catch/finally on ACTIONS while disabling the recorders state changes?\n GastRecorder.prototype.ACTION_RECORD = function (impl) {\n // NO-OP during recording\n return;\n };\n // Executing backtracking logic will break our recording logic assumptions\n GastRecorder.prototype.BACKTRACK_RECORD = function (grammarRule, args) {\n return function () { return true; };\n };\n // LA is part of the official API and may be used for custom lookahead logic\n // by end users who may forget to wrap it in ACTION or inside a GATE\n GastRecorder.prototype.LA_RECORD = function (howMuch) {\n // We cannot use the RECORD_PHASE_TOKEN here because someone may depend\n // On LA return EOF at the end of the input so an infinite loop may occur.\n return END_OF_FILE;\n };\n GastRecorder.prototype.topLevelRuleRecord = function (name, def) {\n try {\n var newTopLevelRule = new Rule({ definition: [], name: name });\n newTopLevelRule.name = name;\n this.recordingProdStack.push(newTopLevelRule);\n def.call(this);\n this.recordingProdStack.pop();\n return newTopLevelRule;\n }\n catch (originalError) {\n if (originalError.KNOWN_RECORDER_ERROR !== true) {\n try {\n originalError.message =\n originalError.message +\n '\\n\\t This error was thrown during the \"grammar recording phase\" For more info see:\\n\\t' +\n \"https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording\";\n }\n catch (mutabilityError) {\n // We may not be able to modify the original error object\n throw originalError;\n }\n }\n throw originalError;\n }\n };\n // Implementation of parsing DSL\n GastRecorder.prototype.optionInternalRecord = function (actionORMethodDef, occurrence) {\n return recordProd.call(this, Option, actionORMethodDef, occurrence);\n };\n GastRecorder.prototype.atLeastOneInternalRecord = function (occurrence, actionORMethodDef) {\n recordProd.call(this, RepetitionMandatory, actionORMethodDef, occurrence);\n };\n GastRecorder.prototype.atLeastOneSepFirstInternalRecord = function (occurrence, options) {\n recordProd.call(this, RepetitionMandatoryWithSeparator, options, occurrence, HANDLE_SEPARATOR);\n };\n GastRecorder.prototype.manyInternalRecord = function (occurrence, actionORMethodDef) {\n recordProd.call(this, Repetition, actionORMethodDef, occurrence);\n };\n GastRecorder.prototype.manySepFirstInternalRecord = function (occurrence, options) {\n recordProd.call(this, RepetitionWithSeparator, options, occurrence, HANDLE_SEPARATOR);\n };\n GastRecorder.prototype.orInternalRecord = function (altsOrOpts, occurrence) {\n return recordOrProd.call(this, altsOrOpts, occurrence);\n };\n GastRecorder.prototype.subruleInternalRecord = function (ruleToCall, occurrence, options) {\n assertMethodIdxIsValid(occurrence);\n if (!ruleToCall || has(ruleToCall, \"ruleName\") === false) {\n var error = new Error(\" argument is invalid\" +\n (\" expecting a Parser method reference but got: <\" + JSON.stringify(ruleToCall) + \">\") +\n (\"\\n inside top level rule: <\" + this.recordingProdStack[0].name + \">\"));\n error.KNOWN_RECORDER_ERROR = true;\n throw error;\n }\n var prevProd = peek(this.recordingProdStack);\n var ruleName = ruleToCall[\"ruleName\"];\n var newNoneTerminal = new NonTerminal({\n idx: occurrence,\n nonTerminalName: ruleName,\n // The resolving of the `referencedRule` property will be done once all the Rule's GASTs have been created\n referencedRule: undefined\n });\n prevProd.definition.push(newNoneTerminal);\n return this.outputCst ? RECORDING_PHASE_CSTNODE : RECORDING_NULL_OBJECT;\n };\n GastRecorder.prototype.consumeInternalRecord = function (tokType, occurrence, options) {\n assertMethodIdxIsValid(occurrence);\n if (!hasShortKeyProperty(tokType)) {\n var error = new Error(\" argument is invalid\" +\n (\" expecting a TokenType reference but got: <\" + JSON.stringify(tokType) + \">\") +\n (\"\\n inside top level rule: <\" + this.recordingProdStack[0].name + \">\"));\n error.KNOWN_RECORDER_ERROR = true;\n throw error;\n }\n var prevProd = peek(this.recordingProdStack);\n var newNoneTerminal = new Terminal({\n idx: occurrence,\n terminalType: tokType\n });\n prevProd.definition.push(newNoneTerminal);\n return RECORDING_PHASE_TOKEN;\n };\n return GastRecorder;\n}());\nexport { GastRecorder };\nfunction recordProd(prodConstructor, mainProdArg, occurrence, handleSep) {\n if (handleSep === void 0) { handleSep = false; }\n assertMethodIdxIsValid(occurrence);\n var prevProd = peek(this.recordingProdStack);\n var grammarAction = isFunction(mainProdArg) ? mainProdArg : mainProdArg.DEF;\n var newProd = new prodConstructor({ definition: [], idx: occurrence });\n if (handleSep) {\n newProd.separator = mainProdArg.SEP;\n }\n if (has(mainProdArg, \"MAX_LOOKAHEAD\")) {\n newProd.maxLookahead = mainProdArg.MAX_LOOKAHEAD;\n }\n this.recordingProdStack.push(newProd);\n grammarAction.call(this);\n prevProd.definition.push(newProd);\n this.recordingProdStack.pop();\n return RECORDING_NULL_OBJECT;\n}\nfunction recordOrProd(mainProdArg, occurrence) {\n var _this = this;\n assertMethodIdxIsValid(occurrence);\n var prevProd = peek(this.recordingProdStack);\n // Only an array of alternatives\n var hasOptions = isArray(mainProdArg) === false;\n var alts = hasOptions === false ? mainProdArg : mainProdArg.DEF;\n var newOrProd = new Alternation({\n definition: [],\n idx: occurrence,\n ignoreAmbiguities: hasOptions && mainProdArg.IGNORE_AMBIGUITIES === true\n });\n if (has(mainProdArg, \"MAX_LOOKAHEAD\")) {\n newOrProd.maxLookahead = mainProdArg.MAX_LOOKAHEAD;\n }\n var hasPredicates = some(alts, function (currAlt) { return isFunction(currAlt.GATE); });\n newOrProd.hasPredicates = hasPredicates;\n prevProd.definition.push(newOrProd);\n forEach(alts, function (currAlt) {\n var currAltFlat = new Alternative({ definition: [] });\n newOrProd.definition.push(currAltFlat);\n if (has(currAlt, \"IGNORE_AMBIGUITIES\")) {\n currAltFlat.ignoreAmbiguities = currAlt.IGNORE_AMBIGUITIES;\n }\n // **implicit** ignoreAmbiguities due to usage of gate\n else if (has(currAlt, \"GATE\")) {\n currAltFlat.ignoreAmbiguities = true;\n }\n _this.recordingProdStack.push(currAltFlat);\n currAlt.ALT.call(_this);\n _this.recordingProdStack.pop();\n });\n return RECORDING_NULL_OBJECT;\n}\nfunction getIdxSuffix(idx) {\n return idx === 0 ? \"\" : \"\" + idx;\n}\nfunction assertMethodIdxIsValid(idx) {\n if (idx < 0 || idx > MAX_METHOD_IDX) {\n var error = new Error(\n // The stack trace will contain all the needed details\n \"Invalid DSL Method idx value: <\" + idx + \">\\n\\t\" +\n (\"Idx value must be a none negative value smaller than \" + (MAX_METHOD_IDX + 1)));\n error.KNOWN_RECORDER_ERROR = true;\n throw error;\n }\n}\n//# sourceMappingURL=gast_recorder.js.map","import { has, timer } from \"../../../utils/utils\";\nimport { DEFAULT_PARSER_CONFIG } from \"../parser\";\n/**\n * Trait responsible for runtime parsing errors.\n */\nvar PerformanceTracer = /** @class */ (function () {\n function PerformanceTracer() {\n }\n PerformanceTracer.prototype.initPerformanceTracer = function (config) {\n if (has(config, \"traceInitPerf\")) {\n var userTraceInitPerf = config.traceInitPerf;\n var traceIsNumber = typeof userTraceInitPerf === \"number\";\n this.traceInitMaxIdent = traceIsNumber\n ? userTraceInitPerf\n : Infinity;\n this.traceInitPerf = traceIsNumber\n ? userTraceInitPerf > 0\n : userTraceInitPerf;\n }\n else {\n this.traceInitMaxIdent = 0;\n this.traceInitPerf = DEFAULT_PARSER_CONFIG.traceInitPerf;\n }\n this.traceInitIndent = -1;\n };\n PerformanceTracer.prototype.TRACE_INIT = function (phaseDesc, phaseImpl) {\n // No need to optimize this using NOOP pattern because\n // It is not called in a hot spot...\n if (this.traceInitPerf === true) {\n this.traceInitIndent++;\n var indent = new Array(this.traceInitIndent + 1).join(\"\\t\");\n if (this.traceInitIndent < this.traceInitMaxIdent) {\n console.log(indent + \"--> <\" + phaseDesc + \">\");\n }\n var _a = timer(phaseImpl), time = _a.time, value = _a.value;\n /* istanbul ignore next - Difficult to reproduce specific performance behavior (>10ms) in tests */\n var traceMethod = time > 10 ? console.warn : console.log;\n if (this.traceInitIndent < this.traceInitMaxIdent) {\n traceMethod(indent + \"<-- <\" + phaseDesc + \"> time: \" + time + \"ms\");\n }\n this.traceInitIndent--;\n return value;\n }\n else {\n return phaseImpl();\n }\n };\n return PerformanceTracer;\n}());\nexport { PerformanceTracer };\n//# sourceMappingURL=perf_tracer.js.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { applyMixins, cloneObj, forEach, has, isEmpty, map, toFastProperties, values } from \"../../utils/utils\";\nimport { computeAllProdsFollows } from \"../grammar/follow\";\nimport { createTokenInstance, EOF } from \"../../scan/tokens_public\";\nimport { defaultGrammarValidatorErrorProvider, defaultParserErrorProvider } from \"../errors_public\";\nimport { resolveGrammar, validateGrammar } from \"../grammar/gast/gast_resolver_public\";\nimport { Recoverable } from \"./traits/recoverable\";\nimport { LooksAhead } from \"./traits/looksahead\";\nimport { TreeBuilder } from \"./traits/tree_builder\";\nimport { LexerAdapter } from \"./traits/lexer_adapter\";\nimport { RecognizerApi } from \"./traits/recognizer_api\";\nimport { RecognizerEngine } from \"./traits/recognizer_engine\";\nimport { ErrorHandler } from \"./traits/error_handler\";\nimport { ContentAssist } from \"./traits/context_assist\";\nimport { GastRecorder } from \"./traits/gast_recorder\";\nimport { PerformanceTracer } from \"./traits/perf_tracer\";\nexport var END_OF_FILE = createTokenInstance(EOF, \"\", NaN, NaN, NaN, NaN, NaN, NaN);\nObject.freeze(END_OF_FILE);\nexport var DEFAULT_PARSER_CONFIG = Object.freeze({\n recoveryEnabled: false,\n maxLookahead: 3,\n dynamicTokensEnabled: false,\n outputCst: true,\n errorMessageProvider: defaultParserErrorProvider,\n nodeLocationTracking: \"none\",\n traceInitPerf: false,\n skipValidations: false\n});\nexport var DEFAULT_RULE_CONFIG = Object.freeze({\n recoveryValueFunc: function () { return undefined; },\n resyncEnabled: true\n});\nexport var ParserDefinitionErrorType;\n(function (ParserDefinitionErrorType) {\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"INVALID_RULE_NAME\"] = 0] = \"INVALID_RULE_NAME\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"DUPLICATE_RULE_NAME\"] = 1] = \"DUPLICATE_RULE_NAME\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"INVALID_RULE_OVERRIDE\"] = 2] = \"INVALID_RULE_OVERRIDE\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"DUPLICATE_PRODUCTIONS\"] = 3] = \"DUPLICATE_PRODUCTIONS\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"UNRESOLVED_SUBRULE_REF\"] = 4] = \"UNRESOLVED_SUBRULE_REF\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"LEFT_RECURSION\"] = 5] = \"LEFT_RECURSION\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"NONE_LAST_EMPTY_ALT\"] = 6] = \"NONE_LAST_EMPTY_ALT\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"AMBIGUOUS_ALTS\"] = 7] = \"AMBIGUOUS_ALTS\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"CONFLICT_TOKENS_RULES_NAMESPACE\"] = 8] = \"CONFLICT_TOKENS_RULES_NAMESPACE\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"INVALID_TOKEN_NAME\"] = 9] = \"INVALID_TOKEN_NAME\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"NO_NON_EMPTY_LOOKAHEAD\"] = 10] = \"NO_NON_EMPTY_LOOKAHEAD\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"AMBIGUOUS_PREFIX_ALTS\"] = 11] = \"AMBIGUOUS_PREFIX_ALTS\";\n ParserDefinitionErrorType[ParserDefinitionErrorType[\"TOO_MANY_ALTS\"] = 12] = \"TOO_MANY_ALTS\";\n})(ParserDefinitionErrorType || (ParserDefinitionErrorType = {}));\nexport function EMPTY_ALT(value) {\n if (value === void 0) { value = undefined; }\n return function () {\n return value;\n };\n}\nvar Parser = /** @class */ (function () {\n function Parser(tokenVocabulary, config) {\n this.definitionErrors = [];\n this.selfAnalysisDone = false;\n var that = this;\n that.initErrorHandler(config);\n that.initLexerAdapter();\n that.initLooksAhead(config);\n that.initRecognizerEngine(tokenVocabulary, config);\n that.initRecoverable(config);\n that.initTreeBuilder(config);\n that.initContentAssist();\n that.initGastRecorder(config);\n that.initPerformanceTracer(config);\n if (has(config, \"ignoredIssues\")) {\n throw new Error(\"The IParserConfig property has been deprecated.\\n\\t\" +\n \"Please use the flag on the relevant DSL method instead.\\n\\t\" +\n \"See: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\\n\\t\" +\n \"For further details.\");\n }\n this.skipValidations = has(config, \"skipValidations\")\n ? config.skipValidations\n : DEFAULT_PARSER_CONFIG.skipValidations;\n }\n /**\n * @deprecated use the **instance** method with the same name instead\n */\n Parser.performSelfAnalysis = function (parserInstance) {\n throw Error(\"The **static** `performSelfAnalysis` method has been deprecated.\" +\n \"\\t\\nUse the **instance** method with the same name instead.\");\n };\n Parser.prototype.performSelfAnalysis = function () {\n var _this = this;\n this.TRACE_INIT(\"performSelfAnalysis\", function () {\n var defErrorsMsgs;\n _this.selfAnalysisDone = true;\n var className = _this.className;\n _this.TRACE_INIT(\"toFastProps\", function () {\n // Without this voodoo magic the parser would be x3-x4 slower\n // It seems it is better to invoke `toFastProperties` **before**\n // Any manipulations of the `this` object done during the recording phase.\n toFastProperties(_this);\n });\n _this.TRACE_INIT(\"Grammar Recording\", function () {\n try {\n _this.enableRecording();\n // Building the GAST\n forEach(_this.definedRulesNames, function (currRuleName) {\n var wrappedRule = _this[currRuleName];\n var originalGrammarAction = wrappedRule[\"originalGrammarAction\"];\n var recordedRuleGast = undefined;\n _this.TRACE_INIT(currRuleName + \" Rule\", function () {\n recordedRuleGast = _this.topLevelRuleRecord(currRuleName, originalGrammarAction);\n });\n _this.gastProductionsCache[currRuleName] = recordedRuleGast;\n });\n }\n finally {\n _this.disableRecording();\n }\n });\n var resolverErrors = [];\n _this.TRACE_INIT(\"Grammar Resolving\", function () {\n resolverErrors = resolveGrammar({\n rules: values(_this.gastProductionsCache)\n });\n _this.definitionErrors.push.apply(_this.definitionErrors, resolverErrors); // mutability for the win?\n });\n _this.TRACE_INIT(\"Grammar Validations\", function () {\n // only perform additional grammar validations IFF no resolving errors have occurred.\n // as unresolved grammar may lead to unhandled runtime exceptions in the follow up validations.\n if (isEmpty(resolverErrors) && _this.skipValidations === false) {\n var validationErrors = validateGrammar({\n rules: values(_this.gastProductionsCache),\n maxLookahead: _this.maxLookahead,\n tokenTypes: values(_this.tokensMap),\n errMsgProvider: defaultGrammarValidatorErrorProvider,\n grammarName: className\n });\n _this.definitionErrors.push.apply(_this.definitionErrors, validationErrors); // mutability for the win?\n }\n });\n // this analysis may fail if the grammar is not perfectly valid\n if (isEmpty(_this.definitionErrors)) {\n // The results of these computations are not needed unless error recovery is enabled.\n if (_this.recoveryEnabled) {\n _this.TRACE_INIT(\"computeAllProdsFollows\", function () {\n var allFollows = computeAllProdsFollows(values(_this.gastProductionsCache));\n _this.resyncFollows = allFollows;\n });\n }\n _this.TRACE_INIT(\"ComputeLookaheadFunctions\", function () {\n _this.preComputeLookaheadFunctions(values(_this.gastProductionsCache));\n });\n }\n if (!Parser.DEFER_DEFINITION_ERRORS_HANDLING &&\n !isEmpty(_this.definitionErrors)) {\n defErrorsMsgs = map(_this.definitionErrors, function (defError) { return defError.message; });\n throw new Error(\"Parser Definition Errors detected:\\n \" + defErrorsMsgs.join(\"\\n-------------------------------\\n\"));\n }\n });\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.\n // (normally during the parser's constructor).\n // This is a design time flag, it will not affect the runtime error handling of the parser, just design time errors,\n // for example: duplicate rule names, referencing an unresolved subrule, ect...\n // This flag should not be enabled during normal usage, it is used in special situations, for example when\n // needing to display the parser definition errors in some GUI(online playground).\n Parser.DEFER_DEFINITION_ERRORS_HANDLING = false;\n return Parser;\n}());\nexport { Parser };\napplyMixins(Parser, [\n Recoverable,\n LooksAhead,\n TreeBuilder,\n LexerAdapter,\n RecognizerEngine,\n RecognizerApi,\n ErrorHandler,\n ContentAssist,\n GastRecorder,\n PerformanceTracer\n]);\nvar CstParser = /** @class */ (function (_super) {\n __extends(CstParser, _super);\n function CstParser(tokenVocabulary, config) {\n if (config === void 0) { config = DEFAULT_PARSER_CONFIG; }\n var _this = this;\n var configClone = cloneObj(config);\n configClone.outputCst = true;\n _this = _super.call(this, tokenVocabulary, configClone) || this;\n return _this;\n }\n return CstParser;\n}(Parser));\nexport { CstParser };\nvar EmbeddedActionsParser = /** @class */ (function (_super) {\n __extends(EmbeddedActionsParser, _super);\n function EmbeddedActionsParser(tokenVocabulary, config) {\n if (config === void 0) { config = DEFAULT_PARSER_CONFIG; }\n var _this = this;\n var configClone = cloneObj(config);\n configClone.outputCst = false;\n _this = _super.call(this, tokenVocabulary, configClone) || this;\n return _this;\n }\n return EmbeddedActionsParser;\n}(Parser));\nexport { EmbeddedActionsParser };\n//# sourceMappingURL=parser.js.map","export const NOOP = Symbol(\"NOOP\"); // basically continue\nexport const MATCH_ANY = Symbol(\"MATCH_ANY\");\nexport const MATCH_WORD = Symbol(\"MATCH_WORD\");\nexport const MATCH_TAG = Symbol(\"MATCH_TAG\");\nexport const MATCH_METHOD = Symbol(\"MATCH_METHOD\");\nexport const MATCH_END = Symbol(\"MATCH_END\");\nexport const JMP = Symbol(\"JMP\");\nexport const SPLIT = Symbol(\"SPLIT\");\nexport const GLOBAL_SAVE = Symbol(\"GLOBAL_SAVE\"); // Set global save value, if true saves results.\nexport const MATCH = Symbol(\"MATCH\");\nexport const OGROUP = Symbol(\"OGROUP\"); // open group\nexport const CGROUP = Symbol(\"CGROUP\"); // close group\nexport const INCV = Symbol(\"INCV\"); // increment a value, set to 0 by default\nexport const JMP_LT = Symbol(\"JMP_LT\"); // jmp if a variable is less than value else continue\nexport const SPLIT_LT = Symbol(\"SPLIT_LT\"); // split if a variable is less than value else continue\nexport const LOOKAHEAD = Symbol(\"LOOKAHEAD\");\nexport const NEGATIVE_LOOKAHEAD = Symbol(\"NEGATIVE_LOOKAHEAD\");\n","import { EmbeddedActionsParser, Lexer, createToken } from \"chevrotain\";\n\nimport {\n NOOP,\n MATCH_ANY,\n MATCH_TAG,\n MATCH_WORD,\n MATCH_METHOD,\n MATCH_END,\n JMP,\n SPLIT,\n GLOBAL_SAVE,\n MATCH,\n OGROUP,\n CGROUP,\n INCV,\n JMP_LT,\n SPLIT_LT,\n LOOKAHEAD,\n NEGATIVE_LOOKAHEAD,\n} from \"./constants\";\n\nconst StartOf = createToken({ name: \"StartOf\", pattern: /\\^/ });\nconst EndOf = createToken({ name: \"EndOf\", pattern: /\\$/ });\nconst Tag = createToken({ name: \"Tag\", pattern: /#([_-\\w]|\\\\.)+/ });\nconst EscapedWord = createToken({\n name: \"EscapedWord\",\n pattern: /\\\\[#@]([_-\\w]|\\\\.)+/,\n});\nconst Word = createToken({ name: \"Word\", pattern: /([_-\\w]|\\\\.)+/ });\nconst Method = createToken({ name: \"Method\", pattern: /@[_-\\w]+/ });\nconst Question = createToken({\n name: \"Question\",\n pattern: /\\?/,\n longer_alt: Word,\n});\nconst Exclamation = createToken({\n name: \"Exclamation\",\n pattern: /!/,\n longer_alt: Word,\n});\nconst Equals = createToken({ name: \"Equals\", pattern: /=/, longer_alt: Word });\nconst Pound = createToken({ name: \"Pound\", pattern: /#/, longer_alt: Tag });\nconst Dot = createToken({ name: \"Dot\", pattern: /\\./, longer_alt: Word });\nconst RegexP = createToken({ name: \"RegexP\", pattern: /\\/.*?\\// });\nconst Pipe = createToken({ name: \"Pipe\", pattern: /\\|/ });\nconst Comma = createToken({ name: \"Comma\", pattern: /,/, longer_alt: Word });\nconst Colon = createToken({ name: \"Colon\", pattern: /:/, longer_alt: Word });\nconst Plus = createToken({ name: \"Plus\", pattern: /\\+/ });\nconst Star = createToken({ name: \"Star\", pattern: /\\*/ });\nconst Zero = createToken({ name: \"Zero\", pattern: /0/, longer_alt: Word });\nconst PositiveInt = createToken({\n name: \"PositiveInt\",\n pattern: /[1-9]\\d*/,\n longer_alt: Word,\n});\nconst LParenthesis = createToken({ name: \"LParenthesis\", pattern: /\\(/ });\nconst RParenthesis = createToken({ name: \"RParenthesis\", pattern: /\\)/ });\nconst LCurly = createToken({ name: \"LCurly\", pattern: /\\{/ });\nconst RCurly = createToken({ name: \"RCurly\", pattern: /\\}/ });\nconst NamedGroupBegin = createToken({ name: \"NamedGroupBegin\", pattern: /P/,\n longer_alt: Word,\n});\nconst WhiteSpace = createToken({\n name: \"WhiteSpace\",\n pattern: /\\s+/,\n group: Lexer.SKIPPED,\n});\n\nexport const allTokens = [\n NamedGroupBegin,\n NamedGroupEnd,\n WhiteSpace,\n StartOf,\n EndOf,\n Zero,\n PositiveInt,\n Dot,\n EscapedWord,\n Word,\n Method,\n Tag,\n Exclamation,\n Equals,\n Pound,\n Colon,\n Question,\n Plus,\n Star,\n Comma,\n Pipe,\n LParenthesis,\n RParenthesis,\n LCurly,\n RCurly,\n];\n\n// Notes or something like it, may not be accurate.\n// (a|b)\n// 0. split 1, 3\n// 1. char a\n// 2. jmp 4\n// 3. char b\n// 4. match\n//\n// (a|b|c)\n// 0. split 1, 3, 5\n// 1. char a\n// 2. jmp 7\n// 3. char b\n// 4. jmp 7\n// 5. char c\n// 6. match\n//\n// ((a|b)|c)\n// 0. split 1, 6\n// 1. split 2, 4\n// 2. char a\n// 3. jmp 7\n// 4. char b\n// 5. jmp 7\n// 6. char c\n// 7. match\n//\n// a{2}\n// 0. noop\n// 1. char a\n// 2. incv i 1, def=0\n// 3. jmp_lt i 2 [0]\n//\n// a{2, 3}\n// 0. noop\n// 1. char a\n// 2. incv i 1, def=0\n// 3. jmp_lt 0 i [2]\n// 4. split_lt i 3 [0, 6]\n//\n// a{,3}\n// 0. noop\n// 1. char a\n// 2. incv i 1, def=0\n// 3. split_lt i 3 [0, 5]\n//\n// a{3,}\n// 0. noop\n// 1. char a\n// 2. incv i 1, def=0\n// 3. jmp_lt i 3\n// 4. split [0, 6]\n//\n// a(!b)\n// 0. noop\n// 1. char a\n// 2. nlookahead prog // negative lookahead is a sub program\n// 1. match b\n// 2. match\n// 2.1. if found stop, else continue at current sp\n//\n\nexport class NLPMatchParser extends EmbeddedActionsParser {\n constructor() {\n super(allTokens);\n\n /*\n * '.'\n * '^remind #Noun$'\n * '\\#Noun' -- escaped word containing #\n * '(remind|#Noun)'\n * '(remind+|#Noun)'\n * '(remind|#Noun)+'\n * '#Noun{2}'\n * '#Noun?'\n * '#Noun*'\n * '(?:remind #Noun)' -- non capturing group\n * '(?P#Noun)'\n * '(?P#Noun)+'\n *\n * matchStatement ([startOf] valueStatement [endOf])\n * valueStatement (value [...value])\n * rangeModifier (LCurly, ((PositiveInt|Zero) [, PositiveInt]) RCurly)\n * oneOrMore (Plus)\n * zeroOrMore (Star)\n * zeroOrOne (Question)\n * valueModifier (oneOrMore, rangeModifier, zeroOrMore, zeroOrOne)\n * value (dot, word, escapedWord, tag, Zero, PositiveInt, group)[valueModifier]\n * namedGroupBegin: token pattern /\\?P/\n * namedGroup (namedGroupBegin, Word, namedGroupEnd)\n * nonCapturingGroup token pattern /\\?:/ -- TODO: figure out how to escape these\n * negativeGroup token patter /\\?!/\n * groupModifier [namedGroup|nonCapturingGroup]\n * group (LParent, [groupModifier], valueStatement|...), RParen)\n *\n */\n\n const $ = this;\n $.RULE(\"matchStatement\", () => {\n const matches = {\n startOf: false,\n prog: [],\n endOf: false,\n };\n\n $.OPTION(() => {\n $.CONSUME(StartOf);\n matches.startOf = true;\n });\n\n // handle ^ startOf\n if (!matches.startOf) {\n // .*? at the start when not ^ / startOf, don't save the matched\n // values.\n matches.prog.push({ code: GLOBAL_SAVE, value: false });\n matches.prog.push({ code: SPLIT, locs: [4, 2] });\n matches.prog.push({ code: MATCH_ANY });\n matches.prog.push({ code: JMP, loc: 1 });\n matches.prog.push({ code: GLOBAL_SAVE, value: true });\n }\n\n matches.groups = [];\n $.SUBRULE($.valueStatement, { ARGS: [matches.prog, matches.groups] });\n\n $.OPTION1(() => {\n $.CONSUME(EndOf);\n matches.endOf = true;\n });\n\n // handle $ endOf\n $.ACTION(() => {\n if (matches.endOf) {\n matches.prog.push({ code: MATCH_END });\n }\n matches.prog.push({ code: MATCH });\n });\n\n return matches;\n });\n\n $.RULE(\"valueStatement\", (prog = [], groups = [], vars = []) => {\n const inst = [];\n $.AT_LEAST_ONE({\n DEF: () => {\n $.SUBRULE($.value, { ARGS: [prog, groups, vars] });\n },\n });\n return inst;\n });\n\n $.RULE(\"value\", (prog = [], groups = [], vars = []) => {\n const split = { code: NOOP }; // save split for modifiers\n prog.push(split);\n const start = prog.length; // save start for split jmp later\n\n $.OR([\n {\n ALT: () => {\n $.CONSUME(Dot);\n prog.push({ code: MATCH_ANY });\n },\n },\n {\n ALT: () => {\n prog.push({ code: MATCH_WORD, value: $.CONSUME(Word).image });\n },\n },\n {\n ALT: () => {\n prog.push({\n code: MATCH_WORD,\n value: $.CONSUME(EscapedWord).image?.substr(1),\n });\n },\n },\n {\n ALT: () => {\n prog.push({\n code: MATCH_TAG,\n value: $.CONSUME(Tag).image?.substr(1),\n });\n },\n },\n {\n ALT: () => {\n prog.push({ code: MATCH_WORD, value: $.CONSUME(Zero).image });\n },\n },\n {\n ALT: () => {\n prog.push({\n code: MATCH_WORD,\n value: $.CONSUME(PositiveInt).image,\n });\n },\n },\n {\n ALT: () => {\n prog.push({\n code: MATCH_METHOD,\n value: $.CONSUME(Method).image?.substr(1),\n });\n },\n },\n {\n ALT: () => {\n $.SUBRULE($.group, { ARGS: [prog, groups, vars] });\n },\n },\n ]);\n\n $.OPTION(() => {\n // TODO: could probably allow relative jmps to get rid of noop\n const { type, greedy, min, max } = $.SUBRULE($.valueModifier);\n switch (type) {\n case \"ZERO_OR_ONE\":\n split.code = SPLIT;\n split.locs = [start, prog.length];\n break;\n case \"ZERO_OR_MORE\":\n prog.push({ code: JMP, loc: start - 1 });\n split.code = SPLIT;\n split.locs = [start, prog.length];\n break;\n case \"ONE_OR_MORE\":\n prog.push({ code: SPLIT, locs: [start, prog.length + 1] });\n if (!greedy) {\n prog[prog.length - 1].locs.reverse();\n }\n break;\n case \"RANGE\":\n const varId = vars.length;\n vars.push(varId);\n prog.push({ code: INCV, varId }); // increment first\n\n const minInst = {\n code: JMP_LT,\n varId,\n value: min ?? 0,\n loc: start,\n };\n let maxInst = null;\n if (min === max) {\n // a{x}\n if (min === 0) {\n // a{0} skip matching, causes token to be ignored\n split.code = JMP;\n split.loc = prog.length; // next instruction\n } else {\n // a{x}\n prog.push(minInst);\n }\n } else if ((min ?? 0) === 0 && max !== null) {\n // a{,y} a{0,y}\n split.code = SPLIT;\n split.locs = [start, prog.length + 1];\n\n maxInst = {\n code: SPLIT_LT,\n varId,\n value: max,\n locs: [start, prog.length + 1],\n };\n prog.push(maxInst);\n } else if (min !== null && max === null) {\n // a{x,}\n prog.push(minInst);\n maxInst = { code: SPLIT, locs: [start, prog.length + 1] };\n prog.push(maxInst);\n } else {\n // if (min !== null && max !== null) {\n // a{x,y}\n prog.push(minInst);\n maxInst = {\n code: SPLIT_LT,\n varId,\n value: max,\n locs: [start, prog.length + 1],\n };\n prog.push(maxInst);\n }\n\n if (!greedy) {\n maxInst?.locs?.reverse(); // reverse thread priority for greedy / non-greedy\n }\n //{ code: SPLIT, locs: [ ] }\n //prog.push({ code: SETV_ONCE, id: rid, value: 0 });\n //prog.push({ code: INCREMENT, id: rid, value: 1 });\n //prog.push({ code: JMP_IF_GTE, id: rid, value: 0 });\n break;\n }\n if (!greedy) {\n split?.locs?.reverse();\n }\n });\n });\n\n $.RULE(\"valueModifier\", () => {\n let result = { type: null, greedy: true };\n $.OR([\n {\n ALT: () => {\n $.CONSUME(Question);\n result.type = \"ZERO_OR_ONE\";\n },\n },\n {\n ALT: () => {\n $.CONSUME(Star);\n result.type = \"ZERO_OR_MORE\";\n },\n },\n {\n ALT: () => {\n $.CONSUME(Plus);\n result.type = \"ONE_OR_MORE\";\n },\n },\n {\n ALT: () => {\n const { min, max } = $.SUBRULE($.rangeModifier);\n $.ACTION(() => {\n result.type = \"RANGE\";\n result.min = min;\n result.max = max;\n });\n },\n },\n ]);\n $.OPTION(() => {\n $.CONSUME1(Question);\n $.ACTION(() => {\n result.greedy = false;\n });\n });\n return result;\n });\n\n $.RULE(\"rangeModifier\", () => {\n const range = { min: null, max: null };\n $.CONSUME(LCurly);\n\n // {x}\n $.OPTION(() => {\n $.OR([\n {\n ALT: () => {\n range.min = $.CONSUME(Zero).image;\n },\n },\n {\n ALT: () => {\n range.min = $.CONSUME(PositiveInt).image;\n },\n },\n ]);\n });\n\n // {x}\n range.max = range.min;\n\n $.OPTION1(() => {\n $.CONSUME(Comma);\n // {x,}\n range.max = null;\n // {,x} {x,}, {x,y}\n $.OPTION2(() => {\n range.max = $.CONSUME1(PositiveInt).image;\n });\n });\n\n $.ACTION(() => {\n if (range.min) {\n range.min = parseInt(range.min);\n }\n if (range.max) {\n range.max = parseInt(range.max);\n }\n const { min, max } = range;\n if (min && max && min > max) {\n throw new Error(\n `Range min(${min}) must be greater than max(${max}).`\n );\n }\n if (min === null && max === null) {\n throw new Error(`Range min or max must be defined.`);\n }\n });\n\n $.CONSUME(RCurly);\n return range;\n });\n\n $.RULE(\"group\", (prog = [], groups = [], vars = []) => {\n let modifiers = {\n capture: true,\n name: null,\n lookahead: false,\n negative: false,\n };\n\n $.CONSUME(LParenthesis);\n\n $.OPTION(() => {\n modifiers = $.SUBRULE($.groupModifier);\n });\n\n let oProg = null;\n if (modifiers.lookahead) {\n // part 1, see finish at end\n modifiers.capture = false;\n oProg = prog;\n prog = [];\n }\n\n const gId = groups.length;\n if (modifiers.capture) {\n groups.push(modifiers);\n prog.push({ code: OGROUP, id: gId, name: modifiers.name });\n }\n\n const split = { code: SPLIT, locs: [] };\n prog.push(split);\n let jmps = [];\n\n $.AT_LEAST_ONE_SEP({\n SEP: Pipe,\n DEF: () => {\n split.locs.push(prog.length);\n $.SUBRULE($.valueStatement, { ARGS: [prog, groups, vars] });\n\n const jmp = { code: JMP, loc: null };\n jmps.push(jmp);\n prog.push(jmp);\n },\n });\n\n // make split noop when just one in group\n if (split.locs.length === 1) {\n split.code = NOOP;\n delete split.locs;\n }\n\n // remove last jmp so it continues\n prog.pop();\n\n // set jmps to end\n for (const jmp of jmps) {\n jmp.loc = prog.length;\n }\n\n // close the group if necessary as the last step\n if (modifiers.capture) {\n prog.push({ code: CGROUP, id: gId, name: modifiers.name });\n }\n\n if (modifiers.lookahead) {\n prog.push({ code: MATCH });\n oProg.push({\n code: modifiers.negative ? NEGATIVE_LOOKAHEAD : LOOKAHEAD,\n prog,\n });\n }\n\n $.CONSUME(RParenthesis);\n });\n\n $.RULE(\"namedGroup\", () => {\n $.CONSUME(Question);\n $.CONSUME(NamedGroupBegin);\n const name = $.CONSUME(Word).image;\n $.CONSUME(NamedGroupEnd);\n return name;\n });\n\n $.RULE(\"nonCapturingGroup\", () => {\n $.CONSUME(Question);\n $.CONSUME(Colon);\n });\n\n $.RULE(\"negativeLookaheadGroup\", () => {\n $.CONSUME(Question);\n $.CONSUME(Exclamation);\n });\n\n $.RULE(\"positiveLookaheadGroup\", () => {\n $.CONSUME(Question);\n $.CONSUME(Equals);\n });\n\n $.RULE(\"commentGroup\", () => {\n $.CONSUME(Question);\n $.CONSUME(Pound);\n });\n\n $.RULE(\"groupModifier\", () => {\n let result = {\n capture: true,\n name: null,\n lookahead: false,\n negative: false,\n comment: false,\n };\n $.OR([\n {\n ALT: () => {\n $.SUBRULE($.nonCapturingGroup);\n result.capture = false;\n },\n },\n {\n ALT: () => {\n result.name = $.SUBRULE($.namedGroup);\n },\n },\n {\n ALT: () => {\n $.SUBRULE($.negativeLookaheadGroup);\n result.capture = false;\n result.lookahead = true;\n result.negative = true;\n },\n },\n {\n ALT: () => {\n $.SUBRULE($.positiveLookaheadGroup);\n result.capture = false;\n result.lookahead = true;\n result.negative = false;\n },\n },\n /*\n { ALT: () => {\n $.SUBRULE($.commentGroup);\n result.capture = false;\n result.comment = true;\n }}\n */\n ]);\n return result;\n });\n\n this.performSelfAnalysis();\n }\n}\n","import {\n NOOP,\n MATCH_ANY,\n MATCH_TAG,\n MATCH_WORD,\n MATCH_METHOD,\n MATCH_END,\n JMP,\n SPLIT,\n GLOBAL_SAVE,\n MATCH,\n OGROUP,\n CGROUP,\n INCV,\n JMP_LT,\n SPLIT_LT,\n LOOKAHEAD,\n NEGATIVE_LOOKAHEAD,\n} from \"./constants\";\n\nexport const termContainsTag = (term, name) =>\n Object.entries(term?.tags ?? {})\n .filter(([k, v]) => v)\n .map((entry) => entry[0].toLowerCase())\n .includes(name.toLowerCase());\n\n/**\n * Helper function, create a thread\n * Copies saved and groups.saved so that each thread contains its own\n * independent saved values.\n *\n * Note: Using the { saved, groups } allows passing a thread which will cause\n * its saved to be cloned.\n *\n * @param {int} pc - position of instance code to execute\n * @param {*[]} saved - matched objects that were saved\n * @param {object} groups - capture groups key of group id\n * @returns {object} thread\n */\nconst thread = (\n pc,\n { save = true, saved = [], groups = {}, vars = {} } = {}\n) => {\n const ngroups = Object.values(groups).reduce((ng, g) => {\n ng[g.id] = {\n ...g,\n saved: [...g.saved],\n };\n return ng;\n }, {});\n\n return {\n pc,\n save,\n saved: [...saved],\n // clone groups.saved\n groups: ngroups,\n vars: { ...vars },\n };\n};\n\nconst addthread = (prog, list, th) => {\n const inst = prog[th.pc];\n //console.log(\"addthread:\", th.pc);\n //console.log(\" inst:\", inst);\n switch (inst.code) {\n case GLOBAL_SAVE:\n th.save = inst.value;\n addthread(prog, list, thread(th.pc + 1, th));\n break;\n case NOOP:\n addthread(prog, list, thread(th.pc + 1, th));\n break;\n case JMP:\n addthread(prog, list, thread(inst.loc, th));\n break;\n case SPLIT:\n for (const loc of inst.locs) {\n addthread(prog, list, thread(loc, th));\n }\n break;\n case OGROUP:\n // again (see below comment in pikevm match), can modify thread\n // because it ends here\n th.groups[inst.id] = {\n id: inst.id,\n name: inst.name,\n saved: [],\n open: true,\n };\n addthread(prog, list, thread(th.pc + 1, th));\n break;\n case CGROUP:\n th.groups[inst.id].open = false;\n addthread(prog, list, thread(th.pc + 1, th));\n break;\n case INCV:\n th.vars[inst.varId] = (th.vars?.[inst.varId] ?? 0) + 1;\n addthread(prog, list, thread(th.pc + 1, th));\n break;\n case JMP_LT:\n if (th.vars[inst.varId] < inst.value) {\n // jump!\n addthread(prog, list, thread(inst.loc, th));\n } else {\n // continue\n addthread(prog, list, thread(th.pc + 1, th));\n }\n break;\n case SPLIT_LT:\n if (th.vars[inst.varId] < inst.value) {\n // split!\n for (const loc of inst.locs) {\n addthread(prog, list, thread(loc, th));\n }\n } else {\n // continue\n addthread(prog, list, thread(th.pc + 1, th));\n }\n break;\n default:\n list.push(th);\n break;\n }\n};\n\n/**\n * Save a match to a thread.\n * Handles saving to open groups too\n * @param {object} th - the thread\n * @param {*] sp - the matched value to add\n * @return {object} the thread th\n */\nconst saveMatch = (th, sp) => {\n if (!th.save) {\n return th;\n }\n\n const buckets = [\n th.saved,\n // get the `saved` from the open buckets\n ...Object.values(th.groups)\n .filter((g) => g.open)\n .map((g) => g.saved),\n ];\n for (const saved of buckets) {\n saved.push(sp);\n }\n return th;\n};\n\n/**\n * Simulate pike's vm, see https://swtch.com/~rsc/regexp/regexp2.html\n * @param {object[]} inst - instructions to execute\n * @param {object[]} input - input word w/ terms\n * @returns true or false for match and saved matches\n */\nexport const pikevm = (prog, input, flags = []) => {\n let clist = [];\n let nlist = [];\n let found = false;\n let groups = {};\n let saved = [];\n\n // helps with match end and also matches that end at exactly the end so that\n // the match function gets a chance to run.\n const END = Symbol(\"END\");\n input = [...input, END];\n\n addthread(prog, clist, thread(0)); // and so we begin...\n for (let i = 0; i < input.length; i++) {\n if (clist.length === 0) {\n break;\n }\n\n const sp = input[i];\n\n for (let j = 0; j < clist.length; j++) {\n // can probably convert to clist.shift as optimization\n const th = clist[j];\n const inst = prog[th.pc];\n //console.log(\"exec:\", inst);\n //console.log(` stack(${i}):`, clist);\n let gotoNextWord = false;\n switch (inst.code) {\n case MATCH_ANY:\n // Note: can call save match like this without worrying about other\n // threads because this thread ends here and another will be created\n // in its place\n if (sp !== END) {\n addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp)));\n }\n break;\n case MATCH_WORD:\n if (sp?.text?.toLowerCase() === inst.value.toLowerCase()) {\n // continue on next word\n addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp)));\n }\n break;\n case MATCH_TAG:\n if (termContainsTag(sp, inst.value)) {\n addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp)));\n }\n break;\n case MATCH_METHOD:\n // call method using null coalescing on term, if it returns true continue\n if (sp?.[inst.value]?.()) {\n addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp)));\n }\n break;\n case MATCH_END:\n if (sp === END) {\n // continue\n addthread(prog, clist, thread(th.pc + 1, th));\n }\n break;\n case LOOKAHEAD:\n const mla = pikevm(inst.prog, input.slice(i));\n if (mla.found) {\n addthread(prog, clist, thread(th.pc + 1, th));\n }\n break;\n case NEGATIVE_LOOKAHEAD:\n const mnla = pikevm(inst.prog, input.slice(i));\n if (!mnla.found) {\n // continue at current position\n // NOTE: this would be in addthread but we require access to input\n addthread(prog, clist, thread(th.pc + 1, th));\n }\n break;\n case MATCH:\n saved = th.saved;\n groups = th.groups;\n found = true;\n // Go to the next word which causes all pending threads in the\n // current list (stack) to be cleared so we don't go down those\n // paths. This allows for greedy and non-greedy matches to work.\n gotoNextWord = true;\n break;\n default:\n throw new Error(`Unsuppored Op code: ${inst.code}`);\n }\n if (gotoNextWord) {\n break; // continue next iteration\n }\n }\n clist = nlist;\n nlist = [];\n }\n if (found) {\n return { found, saved, groups };\n }\n return { found };\n};\n","import { Lexer } from \"chevrotain\";\nimport { NLPMatchParser, allTokens } from \"./parser\";\nimport { pikevm } from \"./pikevm\";\n\nexport const NLPMatchLexer = new Lexer(allTokens);\nexport const parserInstance = new NLPMatchParser();\n\nexport class NLPRegexParseError {\n constructor(errors) {\n this.errors = errors;\n }\n\n get message() {\n return this.errors[0]?.message;\n }\n\n toString() {\n return `NLP RegexP Parsing error: ${this.message}`;\n }\n}\n\n/**\n * Custom NLPRegexP class for regexp compile / cache.\n */\nexport class NLPRegexP {\n /**\n * @param {string} regex - regular expression like string for matching nlp\n * terms.\n */\n constructor(regex) {\n if (regex?.prog) {\n // take another NLPRegexP\n this.regex = regex.regex;\n this.prog = [...regex.prog];\n return;\n }\n\n const { tokens } = NLPMatchLexer.tokenize(regex);\n parserInstance.input = tokens;\n let parsed = null;\n\n try {\n parsed = parserInstance.matchStatement();\n } catch (e) {\n // catch thrown error\n throw new NLPRegexParseError([e]);\n }\n\n if (parserInstance.errors.length > 0) {\n throw new NLPRegexParseError(parserInstance.errors);\n }\n\n this.regex = regex;\n this.prog = parsed.prog;\n }\n\n exec(docOrPhrase) {\n switch (docOrPhrase?.isA?.toLowerCase()) {\n case \"doc\":\n return this.execDoc(docOrPhrase);\n case \"phrase\":\n return this.execPhrase(docOrPhrase);\n default:\n throw new Error(\"Invalid type, must be Document or Phrase\");\n }\n }\n\n execDoc(doc) {\n return doc.buildFrom(\n doc.list\n .map((phrase) => {\n return this.execPhrase(phrase);\n })\n .filter((p) => p !== null)\n );\n }\n\n execPhrase(phrase) {\n const { found, saved = [], groups = {} } = pikevm(\n this.prog,\n phrase.terms()\n );\n\n const namedGroups = Object.values(groups).reduce(\n (arr, g) => ({\n ...arr,\n [parseInt(g.id)]: {\n group: g?.name ?? `${g.id}`,\n start: g.saved[0]?.id ?? 0,\n length: g.saved.length,\n },\n }),\n {}\n );\n\n return found && saved?.[0]?.id\n ? phrase.buildFrom(saved[0].id, saved.length, namedGroups)\n : null;\n }\n}\n","import { NLPRegexP } from \"./regex\";\n\nexport { NLPMatchParser } from \"./parser\";\nexport { NLPRegexP, NLPRegexParseError } from \"./regex\";\n\n// nlp compromise plugin\nexport const Match2Plugin = (Doc, world, nlp, Phrase) => {\n const compileRegex = (regex) => new NLPRegexP(regex);\n nlp.compileRegex = compileRegex;\n Doc.prototype.compileRegex = compileRegex;\n\n const match2 = function (regex) {\n // function, non arrow, need bind for this which is doc/phrase\n regex = new NLPRegexP(regex); // coerce the value\n return regex.exec(this);\n };\n Doc.prototype.match2 = match2;\n Phrase.prototype.match2 = match2;\n};\nexport default Match2Plugin;\n"],"names":["root","factory","module","exports","regexpToAst","self","this","RegExpParser","prototype","saveState","idx","input","groupIdx","restoreState","newState","pattern","consumeChar","value","disjunction","flags","type","loc","begin","end","length","global","ignoreCase","multiLine","unicode","sticky","isRegExpFlag","popChar","addFlag","Error","substring","alts","push","alternative","peekChar","terms","isTerm","term","isAssertion","assertion","atom","ASSERT_EXISTS","ASSERT_NEVER_REACH_HERE","quantifier","isBacktracking","range","atLeast","atMost","Infinity","integerIncludingZero","isDigit","undefined","greedy","dotAll","atomEscape","characterClass","group","isPatternCharacter","patternCharacter","isQuantifier","complement","cc","decimalEscapeAtom","characterClassEscape","controlEscapeAtom","controlLetterEscapeAtom","nulCharacterAtom","hexEscapeSequenceAtom","regExpUnicodeEscapeSequenceAtom","identityEscapeAtom","positiveInteger","set","digitsCharCodes","whitespaceCodes","wordCharCodes","escapeCode","letter","test","letterCode","toUpperCase","charCodeAt","parseHexDigits","escapedChar","classPatternCharacterAtom","nextChar","isClassAtom","from","classAtom","isFromSingleChar","isRangeDash","to","isToSingleChar","insertToSet","classEscape","capturing","groupAst","number","decimalPatternNoZero","decimalPattern","parseInt","howMuch","isAtom","prevState","e","howMany","hexString","i","hexChar","hexDigitPattern","charCode","char","item","forEach","subItem","flagObj","flagKey","obj","concat","BaseRegExpVisitor","visitChildren","node","key","child","hasOwnProperty","visit","Array","isArray","subChild","visitPattern","visitFlags","visitDisjunction","visitAlternative","visitStartAnchor","visitEndAnchor","visitWordBoundary","visitNonWordBoundary","visitLookahead","visitNegativeLookahead","visitCharacter","visitSet","visitGroup","visitGroupBackReference","visitQuantifier","VERSION","__extends","first","utils.map","_first","AlternativeGAST","utils.flatten","utils.groupBy","utils.pick","utils.values","utils.first","utils.contains","utils.isEmpty","utils.difference","utils.cloneArr","utils.drop","utils.reduce","utils.dropRight","utils.compact","resolveGrammar","orgResolveGrammar","validateGrammar","orgValidateGrammar","NOOP","Symbol","MATCH_ANY","MATCH_WORD","MATCH_TAG","MATCH_METHOD","MATCH_END","JMP","SPLIT","GLOBAL_SAVE","MATCH","OGROUP","CGROUP","INCV","JMP_LT","SPLIT_LT","LOOKAHEAD","NEGATIVE_LOOKAHEAD","StartOf","createToken","name","EndOf","Tag","EscapedWord","Word","Method","Question","longer_alt","Exclamation","Equals","Pound","Dot","RegexP","Pipe","Comma","Colon","Plus","Star","Zero","PositiveInt","LParenthesis","RParenthesis","LCurly","RCurly","NamedGroupBegin","NamedGroupEnd","WhiteSpace","Lexer","SKIPPED","allTokens","NLPMatchParser","$","RULE","matches","startOf","prog","endOf","OPTION","CONSUME","code","locs","groups","SUBRULE","valueStatement","ARGS","OPTION1","ACTION","vars","inst","AT_LEAST_ONE","DEF","split","start","OR","ALT","image","substr","valueModifier","min","max","reverse","varId","minInst","maxInst","result","rangeModifier","CONSUME1","OPTION2","modifiers","capture","lookahead","negative","groupModifier","oProg","gId","id","jmps","AT_LEAST_ONE_SEP","SEP","jmp","pop","comment","nonCapturingGroup","namedGroup","negativeLookaheadGroup","positiveLookaheadGroup","performSelfAnalysis","EmbeddedActionsParser","termContainsTag","Object","entries","tags","filter","k","v","map","entry","toLowerCase","includes","thread","pc","save","saved","ngroups","values","reduce","ng","g","addthread","list","th","open","saveMatch","sp","buckets","pikevm","clist","nlist","found","END","j","gotoNextWord","text","mla","slice","mnla","NLPMatchLexer","parserInstance","NLPRegexParseError","errors","message","NLPRegexP","regex","tokenize","tokens","parsed","matchStatement","docOrPhrase","isA","execDoc","execPhrase","doc","buildFrom","phrase","p","namedGroups","arr","Match2Plugin","Doc","world","nlp","Phrase","compileRegex","match2","exec"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAhB,CAAL,GACHoE,MAAM,CAACD,SAAP,CAAiBxC,KAAK,CAAC,CAAD,CAAL,CAAS3B,EAA1B,EAA8B2B,KAAK,CAAC5Q,MAApC,EAA4CuT,WAA5C,CADG,GAEH,IAFJ;EAGD;EA1EH;;EAAA;EAAA;;MClBaE,YAAY,GAAG,SAAfA,YAAe,CAACC,GAAD,EAAMC,KAAN,EAAaC,GAAb,EAAkBC,MAAlB,EAA6B;EACvD,MAAMC,YAAY,GAAG,SAAfA,YAAe,CAACpB,KAAD;EAAA,WAAW,IAAID,SAAJ,CAAcC,KAAd,CAAX;EAAA,GAArB;;EACAkB,EAAAA,GAAG,CAACE,YAAJ,GAAmBA,YAAnB;EACAJ,EAAAA,GAAG,CAAC1U,SAAJ,CAAc8U,YAAd,GAA6BA,YAA7B;;EAEA,MAAMC,MAAM,GAAG,SAATA,MAAS,CAAUrB,KAAV,EAAiB;EAC9B;EACAA,IAAAA,KAAK,GAAG,IAAID,SAAJ,CAAcC,KAAd,CAAR,CAF8B;;EAG9B,WAAOA,KAAK,CAACsB,IAAN,CAAW,IAAX,CAAP;EACD,GAJD;;EAKAN,EAAAA,GAAG,CAAC1U,SAAJ,CAAc+U,MAAd,GAAuBA,MAAvB;EACAF,EAAAA,MAAM,CAAC7U,SAAP,CAAiB+U,MAAjB,GAA0BA,MAA1B;EACD;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/plugins/match2/dist/compromise-match2.min.js b/plugins/match2/dist/compromise-match2.min.js new file mode 100644 index 000000000..ddef41186 --- /dev/null +++ b/plugins/match2/dist/compromise-match2.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).compromiseMatch2={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function E(t){return t&&0===t.length}function T(t){return null==t?[]:Object.keys(t)}function g(t){for(var e=[],n=Object.keys(t),r=0;r=this.input.length)throw Error("Unexpected end of input");this.idx++},t.prototype.loc=function(t){return{begin:t,end:this.idx}};var e,n=/[0-9a-fA-F]/,r=/[0-9]/,o=/[1-9]/;function i(t){return t.charCodeAt(0)}function a(t,e){void 0!==t.length?t.forEach((function(t){e.push(t)})):e.push(t)}function s(t,e){if(!0===t[e])throw"duplicate flag "+e;t[e]=!0}function c(t){if(void 0===t)throw Error("Internal Error - Should never get here!")}var u=[];for(e=i("0");e<=i("9");e++)u.push(e);var l=[i("_")].concat(u);for(e=i("a");e<=i("z");e++)l.push(e);for(e=i("A");e<=i("Z");e++)l.push(e);var p=[i(" "),i("\f"),i("\n"),i("\r"),i("\t"),i("\v"),i("\t"),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i("\u2028"),i("\u2029"),i(" "),i(" "),i(" "),i("\ufeff")];function h(){}return h.prototype.visitChildren=function(t){for(var e in t){var n=t[e];t.hasOwnProperty(e)&&(void 0!==n.type?this.visit(n):Array.isArray(n)&&n.forEach((function(t){this.visit(t)}),this))}},h.prototype.visit=function(t){switch(t.type){case"Pattern":this.visitPattern(t);break;case"Flags":this.visitFlags(t);break;case"Disjunction":this.visitDisjunction(t);break;case"Alternative":this.visitAlternative(t);break;case"StartAnchor":this.visitStartAnchor(t);break;case"EndAnchor":this.visitEndAnchor(t);break;case"WordBoundary":this.visitWordBoundary(t);break;case"NonWordBoundary":this.visitNonWordBoundary(t);break;case"Lookahead":this.visitLookahead(t);break;case"NegativeLookahead":this.visitNegativeLookahead(t);break;case"Character":this.visitCharacter(t);break;case"Set":this.visitSet(t);break;case"Group":this.visitGroup(t);break;case"GroupBackReference":this.visitGroupBackReference(t);break;case"Quantifier":this.visitQuantifier(t)}this.visitChildren(t)},h.prototype.visitPattern=function(t){},h.prototype.visitFlags=function(t){},h.prototype.visitDisjunction=function(t){},h.prototype.visitAlternative=function(t){},h.prototype.visitStartAnchor=function(t){},h.prototype.visitEndAnchor=function(t){},h.prototype.visitWordBoundary=function(t){},h.prototype.visitNonWordBoundary=function(t){},h.prototype.visitLookahead=function(t){},h.prototype.visitNegativeLookahead=function(t){},h.prototype.visitCharacter=function(t){},h.prototype.visitSet=function(t){},h.prototype.visitGroup=function(t){},h.prototype.visitGroupBackReference=function(t){},h.prototype.visitQuantifier=function(t){},{RegExpParser:t,BaseRegExpVisitor:h,VERSION:"0.5.0"}},t.exports?t.exports=n():e.regexpToAst=n()})),ct={},ut=new st.RegExpParser;function lt(t){var e=t.toString();if(ct.hasOwnProperty(e))return ct[e];var n=ut.pattern(e);return ct[e]=n,n}var pt,ht=(pt=function(t,e){return(pt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}pt(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),ft='Unable to use "first char" lexer optimizations:\n';function dt(t,e){void 0===e&&(e=!1);try{var n=lt(t);return function t(e,n,r){switch(e.type){case"Disjunction":for(var o=0;o=Ut)for(var i=e.from>=Ut?e.from:Ut,a=e.to,s=Ft(i),c=Ft(a),u=s;u<=c;u++)n[u]=u}}}));break;case"Group":t(s.value,n,r);break;default:throw Error("Non Exhaustive Match")}var c=void 0!==s.quantifier&&0===s.quantifier.atLeast;if("Group"===s.type&&!1===mt(s)||"Group"!==s.type&&!1===c)break}break;default:throw Error("non exhaustive match!")}return g(n)}(n.value,{},n.flags.ignoreCase)}catch(n){if("Complement Sets are not supported for first char optimization"===n.message)e&&et(ft+"\tUnable to optimize: < "+t.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 r="";e&&(r="\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."),tt(ft+"\n\tFailed parsing: < "+t.toString()+" >\n\tUsing the regexp-to-ast library version: "+st.VERSION+"\n\tPlease open an issue at: https://github.com/bd82/regexp-to-ast/issues"+r)}}return[]}function vt(t,e,n){var r=Ft(t);e[r]=r,!0===n&&function(t,e){var n=String.fromCharCode(t),r=n.toUpperCase();if(r!==n){var o=Ft(r.charCodeAt(0));e[o]=o}else{var i=n.toLowerCase();if(i!==n){o=Ft(i.charCodeAt(0));e[o]=o}}}(t,e)}function yt(t,e){return D(t.value,(function(t){if("number"==typeof t)return w(e,t);var n=t;return void 0!==D(e,(function(t){return n.from<=t&&t<=n.to}))}))}function mt(t){return!(!t.quantifier||0!==t.quantifier.atLeast)||!!t.value&&(j(t.value)?V(t.value,mt):mt(t.value))}var Et=function(t){function e(e){var n=t.call(this)||this;return n.targetCharCodes=e,n.found=!1,n}return ht(e,t),e.prototype.visitChildren=function(e){if(!0!==this.found){switch(e.type){case"Lookahead":return void this.visitLookahead(e);case"NegativeLookahead":return void this.visitNegativeLookahead(e)}t.prototype.visitChildren.call(this,e)}},e.prototype.visitCharacter=function(t){w(this.targetCharCodes,t.value)&&(this.found=!0)},e.prototype.visitSet=function(t){t.complement?void 0===yt(t,this.targetCharCodes)&&(this.found=!0):void 0!==yt(t,this.targetCharCodes)&&(this.found=!0)},e}(st.BaseRegExpVisitor);function Tt(t,e){if(e instanceof RegExp){var n=lt(e),r=new Et(t);return r.visit(n),r.found}return void 0!==D(e,(function(e){return w(t,e.charCodeAt(0))}))}var gt=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Rt="PATTERN",At="boolean"==typeof new RegExp("(?:)").sticky;function Ot(t,e){var n,r=(e=Z(e,{useSticky:At,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:function(t,e){return e()}})).tracer;r("initCharCodeToOptimizedIndexMap",(function(){!function(){if(E(Dt)){Dt=new Array(65536);for(var t=0;t<65536;t++)Dt[t]=t>255?255+~~(t/255):t}}()})),r("Reject Lexer.NA",(function(){n=P(t,(function(t){return t[Rt]===qt.NA}))}));var o,i,a,s,c,u,l,p,h,f,d,v=!1;r("Transform Patterns",(function(){v=!1,o=R(n,(function(t){var n=t[Rt];if(W(n)){var r=n.source;return 1!==r.length||"^"===r||"$"===r||"."===r||n.ignoreCase?2!==r.length||"\\"!==r[0]||w(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],r[1])?e.useSticky?Lt(n):_t(n):r[1]:r}if(L(n))return v=!0,{exec:n};if(M(n,"exec"))return v=!0,n;if("string"==typeof n){if(1===n.length)return n;var o=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),i=new RegExp(o);return e.useSticky?Lt(i):_t(i)}throw Error("non exhaustive match")}))})),r("misc mapping",(function(){i=R(n,(function(t){return t.tokenTypeIdx})),a=R(n,(function(t){var e=t.GROUP;if(e!==qt.SKIPPED){if(S(e))return e;if(_(e))return!1;throw Error("non exhaustive match")}})),s=R(n,(function(t){var e=t.LONGER_ALT;if(e)return function(t,e){for(var n=0;n 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 a=dt(n.PATTERN,e.ensureOptimizations);E(a)&&(y=!1),N(a,(function(e){wt(t,e,d[r])}))}else e.ensureOptimizations&&tt(ft+"\tTokenType: <"+n.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"),y=!1;return t}),[])})),r("ArrayPacking",(function(){m=function(t){for(var e=[],n=0;n"+t.name+"<- missing static 'PATTERN' property",type:zt.MISSING_PATTERN,tokenTypes:[t]}})),r=Y(t,e);return{errors:n,valid:r}}(t);n=n.concat(r.errors);var o=function(t){var e=x(t,(function(t){var e=t[Rt];return!(W(e)||L(e)||M(e,"exec")||S(e))})),n=R(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:zt.INVALID_PATTERN,tokenTypes:[t]}})),r=Y(t,e);return{errors:n,valid:r}}(r.valid),i=o.valid;return n=(n=(n=(n=(n=n.concat(o.errors)).concat(function(t){var e=[],n=x(t,(function(t){return W(t[Rt])}));return e=(e=(e=(e=(e=e.concat(function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.found=!1,e}return gt(e,t),e.prototype.visitEndAnchor=function(t){this.found=!0},e}(st.BaseRegExpVisitor);return R(x(t,(function(t){var n=t[Rt];try{var r=lt(n),o=new e;return o.visit(r),o.found}catch(t){return Nt.test(n.source)}})),(function(t){return{message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+t.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:zt.EOI_ANCHOR_FOUND,tokenTypes:[t]}}))}(n))).concat(function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.found=!1,e}return gt(e,t),e.prototype.visitStartAnchor=function(t){this.found=!0},e}(st.BaseRegExpVisitor);return R(x(t,(function(t){var n=t[Rt];try{var r=lt(n),o=new e;return o.visit(r),o.found}catch(t){return St.test(n.source)}})),(function(t){return{message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+t.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:zt.SOI_ANCHOR_FOUND,tokenTypes:[t]}}))}(n))).concat(function(t){return R(x(t,(function(t){var e=t[Rt];return e instanceof RegExp&&(e.multiline||e.global)})),(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:zt.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[t]}}))}(n))).concat(function(t){var e=[],n=R(t,(function(n){return B(t,(function(t,r){return n.PATTERN.source!==r.PATTERN.source||w(e,r)||r.PATTERN===qt.NA||(e.push(r),t.push(r)),t}),[])}));return R(x(n=G(n),(function(t){return t.length>1})),(function(t){var e=R(t,(function(t){return t.name}));return{message:"The same RegExp pattern ->"+O(t).PATTERN+"<-has been used in all of the following Token Types: "+e.join(", ")+" <-",type:zt.DUPLICATE_PATTERNS_FOUND,tokenTypes:t}}))}(n))).concat(function(t){return R(x(t,(function(t){return t[Rt].test("")})),(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PATTERN' must not match an empty string",type:zt.EMPTY_MATCH_PATTERN,tokenTypes:[t]}}))}(n))}(i))).concat(function(t){return R(x(t,(function(t){if(!M(t,"GROUP"))return!1;var e=t.GROUP;return e!==qt.SKIPPED&&e!==qt.NA&&!S(e)})),(function(t){return{message:"Token Type: ->"+t.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:zt.INVALID_GROUP_TYPE_FOUND,tokenTypes:[t]}}))}(i))).concat(function(t,e){return R(x(t,(function(t){return void 0!==t.PUSH_MODE&&!w(e,t.PUSH_MODE)})),(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+t.PUSH_MODE+"<-which does not exist",type:zt.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[t]}}))}(i,e))).concat(function(t){var e=[],n=B(t,(function(t,e,n){var r,o=e.PATTERN;return o===qt.NA||(S(o)?t.push({str:o,idx:n,tokenType:e}):W(o)&&(r=o,void 0===D([".","\\","[","]","|","^","$","(",")","?","*","+","{"],(function(t){return-1!==r.source.indexOf(t)})))&&t.push({str:o.source,idx:n,tokenType:e})),t}),[]);return N(t,(function(t,r){N(n,(function(n){var o=n.str,i=n.idx,a=n.tokenType;if(r"+t.name+"<-in the lexer's definition.\nSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#UNREACHABLE";e.push({message:s,type:zt.UNREACHABLE_PATTERN,tokenTypes:[t,a]})}}))})),e}(i))}var Nt=/[^\\][\$]/;var St=/[^\\[][\^]|^\^/;function _t(t){var e=t.ignoreCase?"i":"";return new RegExp("^(?:"+t.source+")",e)}function Lt(t){var e=t.ignoreCase?"iy":"y";return new RegExp(""+t.source,e)}function kt(t,e,n){var r=[],o=!1,i=P(G(A(function(t,e){for(var n=[],r=T(t),o=0;o Token Type\n\t Root cause: "+e.errMsg+".\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(e.issue===zt.CUSTOM_LINE_BREAK)return"Warning: A Custom Token Pattern should specify the option.\n\tThe problem is in the <"+t.name+"> Token Type\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}(t,e),type:e.issue,tokenType:t};r.push(n)}else M(t,"LINE_BREAKS")?!0===t.LINE_BREAKS&&(o=!0):Tt(a,t.PATTERN)&&(o=!0)})),e&&!o&&r.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:zt.NO_LINE_BREAKS_FLAGS}),r}function Ct(t){var e=t.PATTERN;if(W(e))return!1;if(L(e))return!0;if(M(e,"exec"))return!0;if(S(e))return!1;throw Error("non exhaustive match")}function xt(t){return!(!S(t)||1!==t.length)&&t.charCodeAt(0)}var Pt={test:function(t){for(var e=t.length,n=this.lastIndex;n0?t.charCodeAt(0):t}))}function wt(t,e,n){void 0===t[e]?t[e]=[n]:t[e].push(n)}var Ut=256;function Ft(t){return t0}))}function Ht(t){return M(t,"tokenTypeIdx")}function Vt(t){return M(t,"CATEGORIES")}function Yt(t){return M(t,"tokenTypeIdx")}var zt;!function(t){t[t.MISSING_PATTERN=0]="MISSING_PATTERN",t[t.INVALID_PATTERN=1]="INVALID_PATTERN",t[t.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",t[t.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",t[t.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",t[t.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",t[t.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",t[t.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",t[t.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",t[t.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",t[t.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",t[t.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",t[t.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",t[t.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",t[t.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",t[t.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",t[t.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK"}(zt||(zt={}));var Xt={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:{buildUnableToPopLexerModeMessage:function(t){return"Unable to pop Lexer Mode after encountering Token ->"+t.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(t,e,n,r,o){return"unexpected character: ->"+t.charAt(e)+"<- at offset: "+e+", skipped "+n+" characters."}},traceInitPerf:!1,skipValidations:!1};Object.freeze(Xt);var qt=function(){function t(t,e){var n=this;if(void 0===e&&(e=Xt),this.lexerDefinition=t,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.config=void 0,this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},"boolean"==typeof e)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=$(Xt,e);var r=this.config.traceInitPerf;!0===r?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof r&&(this.traceInitMaxIdent=r,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",(function(){var r,o=!0;n.TRACE_INIT("Lexer Config handling",(function(){if(n.config.lineTerminatorsPattern===Xt.lineTerminatorsPattern)n.config.lineTerminatorsPattern=Pt;else if(n.config.lineTerminatorCharacters===Xt.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(e.safeMode&&e.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');n.trackStartLines=/full|onlyStart/i.test(n.config.positionTracking),n.trackEndLines=/full/i.test(n.config.positionTracking),j(t)?((r={modes:{}}).modes.defaultMode=U(t),r.defaultMode="defaultMode"):(o=!1,r=F(t))})),!1===n.config.skipValidations&&(n.TRACE_INIT("performRuntimeChecks",(function(){n.lexerDefinitionErrors=n.lexerDefinitionErrors.concat(function(t,e,n){var r=[];return M(t,"defaultMode")||r.push({message:"A MultiMode Lexer cannot be initialized without a property in its definition\n",type:zt.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),M(t,"modes")||r.push({message:"A MultiMode Lexer cannot be initialized without a property in its definition\n",type:zt.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),M(t,"modes")&&M(t,"defaultMode")&&!M(t.modes,t.defaultMode)&&r.push({message:"A MultiMode Lexer cannot be initialized with a defaultMode: <"+t.defaultMode+">which does not exist\n",type:zt.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),M(t,"modes")&&N(t.modes,(function(t,e){N(t,(function(t,n){_(t)&&r.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:<"+e+"> at index: <"+n+">\n",type:zt.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})}))})),r}(r,n.trackStartLines,n.config.lineTerminatorCharacters))})),n.TRACE_INIT("performWarningRuntimeChecks",(function(){n.lexerDefinitionWarning=n.lexerDefinitionWarning.concat(kt(r,n.trackStartLines,n.config.lineTerminatorCharacters))}))),r.modes=r.modes?r.modes:{},N(r.modes,(function(t,e){r.modes[e]=P(t,(function(t){return _(t)}))}));var i=T(r.modes);if(N(r.modes,(function(t,r){n.TRACE_INIT("Mode: <"+r+"> processing",(function(){var o;(n.modes.push(r),!1===n.config.skipValidations&&n.TRACE_INIT("validatePatterns",(function(){n.lexerDefinitionErrors=n.lexerDefinitionErrors.concat(It(t,i))})),E(n.lexerDefinitionErrors))&&(Wt(t),n.TRACE_INIT("analyzeTokenTypes",(function(){o=Ot(t,{lineTerminatorCharacters:n.config.lineTerminatorCharacters,positionTracking:e.positionTracking,ensureOptimizations:e.ensureOptimizations,safeMode:e.safeMode,tracer:n.TRACE_INIT.bind(n)})})),n.patternIdxToConfig[r]=o.patternIdxToConfig,n.charCodeToPatternIdxToConfig[r]=o.charCodeToPatternIdxToConfig,n.emptyGroups=$(n.emptyGroups,o.emptyGroups),n.hasCustom=o.hasCustom||n.hasCustom,n.canModeBeOptimized[r]=o.canBeOptimized)}))})),n.defaultMode=r.defaultMode,!E(n.lexerDefinitionErrors)&&!n.config.deferDefinitionErrorsHandling){var a=R(n.lexerDefinitionErrors,(function(t){return t.message})).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+a)}N(n.lexerDefinitionWarning,(function(t){et(t.message)})),n.TRACE_INIT("Choosing sub-methods implementations",(function(){if(At?(n.chopInput=J,n.match=n.matchWithTest):(n.updateLastIndex=Q,n.match=n.matchWithExec),o&&(n.handleModes=Q),!1===n.trackStartLines&&(n.computeNewColumn=J),!1===n.trackEndLines&&(n.updateTokenEndLineColumnLocation=Q),/full/i.test(n.config.positionTracking))n.createTokenInstance=n.createFullToken;else if(/onlyStart/i.test(n.config.positionTracking))n.createTokenInstance=n.createStartOnlyToken;else{if(!/onlyOffset/i.test(n.config.positionTracking))throw Error('Invalid config option: "'+n.config.positionTracking+'"');n.createTokenInstance=n.createOffsetOnlyToken}n.hasCustom?(n.addToken=n.addTokenUsingPush,n.handlePayload=n.handlePayloadWithCustom):(n.addToken=n.addTokenUsingMemberAccess,n.handlePayload=n.handlePayloadNoCustom)})),n.TRACE_INIT("Failed Optimization Warnings",(function(){var t=B(n.canModeBeOptimized,(function(t,e,n){return!1===e&&t.push(n),t}),[]);if(e.ensureOptimizations&&!E(t))throw Error("Lexer Modes: < "+t.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.')})),n.TRACE_INIT("clearRegExpParserCache",(function(){ct={}})),n.TRACE_INIT("toFastProperties",(function(){rt(n)}))}))}return t.prototype.tokenize=function(t,e){if(void 0===e&&(e=this.defaultMode),!E(this.lexerDefinitionErrors)){var n=R(this.lexerDefinitionErrors,(function(t){return t.message})).join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+n)}return this.tokenizeInternal(t,e)},t.prototype.tokenizeInternal=function(t,e){var n,r,o,i,a,s,c,u,l,p,h,f,d,v,y,m,E=this,g=t,R=g.length,A=0,O=0,S=this.hasCustom?0:Math.floor(t.length/10),_=new Array(S),L=[],k=this.trackStartLines?1:void 0,C=this.trackStartLines?1:void 0,x=(y=this.emptyGroups,m={},N(T(y),(function(t){if(!j(y[t]))throw Error("non exhaustive match");m[t]=[]})),m),P=this.trackStartLines,b=this.config.lineTerminatorsPattern,M=0,w=[],U=[],F=[],D=[];Object.freeze(D);var B=void 0;function G(){return w}function K(t){var e=Ft(t),n=U[e];return void 0===n?D:n}var W,H=function(t){if(1===F.length&&void 0===t.tokenType.PUSH_MODE){var e=E.config.errorMessageProvider.buildUnableToPopLexerModeMessage(t);L.push({offset:t.startOffset,line:void 0!==t.startLine?t.startLine:void 0,column:void 0!==t.startColumn?t.startColumn:void 0,length:t.image.length,message:e})}else{F.pop();var n=I(F);w=E.patternIdxToConfig[n],U=E.charCodeToPatternIdxToConfig[n],M=w.length;var r=E.canModeBeOptimized[n]&&!1===E.config.safeMode;B=U&&r?K:G}};function V(t){F.push(t),U=this.charCodeToPatternIdxToConfig[t],w=this.patternIdxToConfig[t],M=w.length,M=w.length;var e=this.canModeBeOptimized[t]&&!1===this.config.safeMode;B=U&&e?K:G}for(V.call(this,e);Aa.length&&(a=o,s=c,W=Z)}break}}if(null!==a){if(u=a.length,void 0!==(l=W.group)&&(p=W.tokenTypeIdx,h=this.createTokenInstance(a,A,p,W.tokenType,k,C,u),this.handlePayload(h,s),!1===l?O=this.addToken(_,O,h):x[l].push(h)),t=this.chopInput(t,u),A+=u,C=this.computeNewColumn(C,u),!0===P&&!0===W.canLineTerminator){var Q=0,J=void 0,tt=void 0;b.lastIndex=0;do{!0===(J=b.test(a))&&(tt=b.lastIndex-1,Q++)}while(!0===J);0!==Q&&(k+=Q,C=u-tt,this.updateTokenEndLineColumnLocation(h,l,tt,Q,k,C,u))}this.handleModes(W,H,V,h)}else{for(var et=A,nt=k,rt=C,ot=!1;!ot&&A");var r=it(e),o=r.time,i=r.value,a=o>10?console.warn:console.log;return this.traceInitIndent time: "+o+"ms"),this.traceInitIndent--,i}return e()},t.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",t.NA=/NOT_APPLICABLE/,t}();function Zt(t){return $t(t)?t.LABEL:t.name}function $t(t){return S(t.LABEL)&&""!==t.LABEL}function Qt(t){return function(t){var e=t.pattern,n={};n.name=t.name,_(e)||(n.PATTERN=e);if(M(t,"parent"))throw"The parent property is no longer supported.\nSee: https://github.com/SAP/chevrotain/issues/564#issuecomment-349062346 for details.";M(t,"categories")&&(n.CATEGORIES=t.categories);Wt([n]),M(t,"label")&&(n.LABEL=t.label);M(t,"group")&&(n.GROUP=t.group);M(t,"pop_mode")&&(n.POP_MODE=t.pop_mode);M(t,"push_mode")&&(n.PUSH_MODE=t.push_mode);M(t,"longer_alt")&&(n.LONGER_ALT=t.longer_alt);M(t,"line_breaks")&&(n.LINE_BREAKS=t.line_breaks);M(t,"start_chars_hint")&&(n.START_CHARS_HINT=t.start_chars_hint);return n}(t)}var Jt=Qt({name:"EOF",pattern:qt.NA});function te(t,e,n,r,o,i,a,s){return{image:e,startOffset:n,endOffset:r,startLine:o,endLine:i,startColumn:a,endColumn:s,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}Wt([Jt]);var ee=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ne=function(){function t(t){this.definition=t}return t.prototype.accept=function(t){t.visit(this),N(this.definition,(function(e){e.accept(t)}))},t}(),re=function(t){function e(e){var n=t.call(this,[])||this;return n.idx=1,X(n,b(e,(function(t){return void 0!==t}))),n}return ee(e,t),Object.defineProperty(e.prototype,"definition",{get:function(){return void 0!==this.referencedRule?this.referencedRule.definition:[]},set:function(t){},enumerable:!0,configurable:!0}),e.prototype.accept=function(t){t.visit(this)},e}(ne),oe=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.orgText="",X(n,b(e,(function(t){return void 0!==t}))),n}return ee(e,t),e}(ne),ie=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.ignoreAmbiguities=!1,X(n,b(e,(function(t){return void 0!==t}))),n}return ee(e,t),e}(ne),ae=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,X(n,b(e,(function(t){return void 0!==t}))),n}return ee(e,t),e}(ne),se=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,X(n,b(e,(function(t){return void 0!==t}))),n}return ee(e,t),e}(ne),ce=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,X(n,b(e,(function(t){return void 0!==t}))),n}return ee(e,t),e}(ne),ue=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,X(n,b(e,(function(t){return void 0!==t}))),n}return ee(e,t),e}(ne),le=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,X(n,b(e,(function(t){return void 0!==t}))),n}return ee(e,t),e}(ne),pe=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,n.ignoreAmbiguities=!1,n.hasPredicates=!1,X(n,b(e,(function(t){return void 0!==t}))),n}return ee(e,t),e}(ne),he=function(){function t(t){this.idx=1,X(this,b(t,(function(t){return void 0!==t})))}return t.prototype.accept=function(t){t.visit(this)},t}();function fe(t){function e(t){return R(t,fe)}if(t instanceof re)return{type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};if(t instanceof ie)return{type:"Alternative",definition:e(t.definition)};if(t instanceof ae)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof se)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof ce)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:fe(new he({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof le)return{type:"RepetitionWithSeparator",idx:t.idx,separator:fe(new he({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof ue)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof pe)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof he){var n={type:"Terminal",name:t.terminalType.name,label:Zt(t.terminalType),idx:t.idx},r=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(n.pattern=W(r)?r.source:r),n}if(t instanceof oe)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}var de=function(){function t(){}return t.prototype.walk=function(t,e){var n=this;void 0===e&&(e=[]),N(t.definition,(function(r,o){var i=k(t.definition,o+1);if(r instanceof re)n.walkProdRef(r,i,e);else if(r instanceof he)n.walkTerminal(r,i,e);else if(r instanceof ie)n.walkFlat(r,i,e);else if(r instanceof ae)n.walkOption(r,i,e);else if(r instanceof se)n.walkAtLeastOne(r,i,e);else if(r instanceof ce)n.walkAtLeastOneSep(r,i,e);else if(r instanceof le)n.walkManySep(r,i,e);else if(r instanceof ue)n.walkMany(r,i,e);else{if(!(r instanceof pe))throw Error("non exhaustive match");n.walkOr(r,i,e)}}))},t.prototype.walkTerminal=function(t,e,n){},t.prototype.walkProdRef=function(t,e,n){},t.prototype.walkFlat=function(t,e,n){var r=e.concat(n);this.walk(t,r)},t.prototype.walkOption=function(t,e,n){var r=e.concat(n);this.walk(t,r)},t.prototype.walkAtLeastOne=function(t,e,n){var r=[new ae({definition:t.definition})].concat(e,n);this.walk(t,r)},t.prototype.walkAtLeastOneSep=function(t,e,n){var r=ve(t,e,n);this.walk(t,r)},t.prototype.walkMany=function(t,e,n){var r=[new ae({definition:t.definition})].concat(e,n);this.walk(t,r)},t.prototype.walkManySep=function(t,e,n){var r=ve(t,e,n);this.walk(t,r)},t.prototype.walkOr=function(t,e,n){var r=this,o=e.concat(n);N(t.definition,(function(t){var e=new ie({definition:[t]});r.walk(e,o)}))},t}();function ve(t,e,n){return[new ae({definition:[new he({terminalType:t.separator})].concat(t.definition)})].concat(e,n)}var ye=function(){function t(){}return t.prototype.visit=function(t){var e=t;switch(e.constructor){case re:return this.visitNonTerminal(e);case ie:return this.visitAlternative(e);case ae:return this.visitOption(e);case se:return this.visitRepetitionMandatory(e);case ce:return this.visitRepetitionMandatoryWithSeparator(e);case le:return this.visitRepetitionWithSeparator(e);case ue:return this.visitRepetition(e);case pe:return this.visitAlternation(e);case he:return this.visitTerminal(e);case oe:return this.visitRule(e);default:throw Error("non exhaustive match")}},t.prototype.visitNonTerminal=function(t){},t.prototype.visitAlternative=function(t){},t.prototype.visitOption=function(t){},t.prototype.visitRepetition=function(t){},t.prototype.visitRepetitionMandatory=function(t){},t.prototype.visitRepetitionMandatoryWithSeparator=function(t){},t.prototype.visitRepetitionWithSeparator=function(t){},t.prototype.visitAlternation=function(t){},t.prototype.visitTerminal=function(t){},t.prototype.visitRule=function(t){},t}(),me=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();function Ee(t,e){return void 0===e&&(e=[]),!!(t instanceof ae||t instanceof ue||t instanceof le)||(t instanceof pe?z(t.definition,(function(t){return Ee(t,e)})):!(t instanceof re&&w(e,t))&&(t instanceof ne&&(t instanceof re&&e.push(t),V(t.definition,(function(t){return Ee(t,e)})))))}function Te(t){if(t instanceof re)return"SUBRULE";if(t instanceof ae)return"OPTION";if(t instanceof pe)return"OR";if(t instanceof se)return"AT_LEAST_ONE";if(t instanceof ce)return"AT_LEAST_ONE_SEP";if(t instanceof le)return"MANY_SEP";if(t instanceof ue)return"MANY";if(t instanceof he)return"CONSUME";throw Error("non exhaustive match")}var ge=new(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.separator="-",e.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},e}return me(e,t),e.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},e.prototype.visitTerminal=function(t){var e=t.terminalType.name+this.separator+"Terminal";M(this.dslMethods,e)||(this.dslMethods[e]=[]),this.dslMethods[e].push(t)},e.prototype.visitNonTerminal=function(t){var e=t.nonTerminalName+this.separator+"Terminal";M(this.dslMethods,e)||(this.dslMethods[e]=[]),this.dslMethods[e].push(t)},e.prototype.visitOption=function(t){this.dslMethods.option.push(t)},e.prototype.visitRepetitionWithSeparator=function(t){this.dslMethods.repetitionWithSeparator.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.dslMethods.repetitionMandatory.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)},e.prototype.visitRepetition=function(t){this.dslMethods.repetition.push(t)},e.prototype.visitAlternation=function(t){this.dslMethods.alternation.push(t)},e}(ye));function Re(t){if(t instanceof re)return Re(t.referencedRule);if(t instanceof he)return[t.terminalType];if(function(t){return t instanceof ie||t instanceof ae||t instanceof ue||t instanceof se||t instanceof ce||t instanceof le||t instanceof he||t instanceof oe}(t))return function(t){var e,n=[],r=t.definition,o=0,i=r.length>o,a=!0;for(;i&&a;)e=r[o],a=Ee(e),n=n.concat(Re(e)),o+=1,i=r.length>o;return K(n)}(t);if(function(t){return t instanceof pe}(t))return function(t){return K(A(R(t.definition,(function(t){return Re(t)}))))}(t);throw Error("non exhaustive match")}var Ae=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Oe=function(t){function e(e){var n=t.call(this)||this;return n.topProd=e,n.follows={},n}return Ae(e,t),e.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},e.prototype.walkTerminal=function(t,e,n){},e.prototype.walkProdRef=function(t,e,n){var r,o,i=(r=t.referencedRule,o=t.idx,r.name+o+"_~IN~_"+this.topProd.name),a=e.concat(n),s=Re(new ie({definition:a}));this.follows[i]=s},e}(de);var Ie={buildMismatchTokenMessage:function(t){var e=t.expected,n=t.actual;t.previous,t.ruleName;return"Expecting "+($t(e)?"--\x3e "+Zt(e)+" <--":"token of type --\x3e "+e.name+" <--")+" but found --\x3e '"+n.image+"' <--"},buildNotAllInputParsedMessage:function(t){var e=t.firstRedundant;t.ruleName;return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage:function(t){var e=t.expectedPathsPerAlt,n=t.actual,r=(t.previous,t.customUserDescription),o=(t.ruleName,"\nbut found: '"+O(n).image+"'");if(r)return"Expecting: "+r+o;var i=R(B(e,(function(t,e){return t.concat(e)}),[]),(function(t){return"["+R(t,(function(t){return Zt(t)})).join(", ")+"]"}));return"Expecting: "+("one of these possible Token sequences:\n"+R(i,(function(t,e){return" "+(e+1)+". "+t})).join("\n"))+o},buildEarlyExitMessage:function(t){var e=t.expectedIterationPaths,n=t.actual,r=t.customUserDescription,o=(t.ruleName,"\nbut found: '"+O(n).image+"'");return r?"Expecting: "+r+o:"Expecting: "+("expecting at least one iteration which starts with one of these possible Token sequences::\n <"+R(e,(function(t){return"["+R(t,(function(t){return Zt(t)})).join(",")+"]"})).join(" ,")+">")+o}};Object.freeze(Ie);var Ne={buildRuleNotFoundError:function(t,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+"<-\ninside top level rule: ->"+t.name+"<-"}},Se={buildDuplicateFoundError:function(t,e){var n,r=t.name,o=O(e),i=o.idx,a=Te(o),s=(n=o)instanceof he?n.terminalType.name:n instanceof re?n.nonTerminalName:"",c="->"+a+(i>0?i:"")+"<- "+(s?"with argument: ->"+s+"<-":"")+"\n appears more than once ("+e.length+" times) in the top level rule: ->"+r+"<-. \n For further details see: https://sap.github.io/chevrotain/docs/FAQ.html#NUMERICAL_SUFFIXES \n ";return c=(c=c.replace(/[ \t]+/g," ")).replace(/\s\s+/g,"\n")},buildNamespaceConflictError:function(t){return"Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+t.name+">.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter."},buildAlternationPrefixAmbiguityError:function(t){var e=R(t.prefixPath,(function(t){return Zt(t)})).join(", "),n=0===t.alternation.idx?"":t.alternation.idx;return"Ambiguous alternatives: <"+t.ambiguityIndices.join(" ,")+"> due to common lookahead prefix\nin inside <"+t.topLevelRule.name+"> Rule,\n<"+e+"> may appears as a prefix path in all these alternatives.\nSee: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details."},buildAlternationAmbiguityError:function(t){var e=R(t.prefixPath,(function(t){return Zt(t)})).join(", "),n=0===t.alternation.idx?"":t.alternation.idx,r="Ambiguous Alternatives Detected: <"+t.ambiguityIndices.join(" ,")+"> in inside <"+t.topLevelRule.name+"> Rule,\n<"+e+"> may appears as a prefix path in all these alternatives.\n";return r+="See: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details."},buildEmptyRepetitionError:function(t){var e=Te(t.repetition);return 0!==t.repetition.idx&&(e+=t.repetition.idx),"The repetition <"+e+"> within Rule <"+t.topLevelRule.name+"> can never consume any tokens.\nThis could lead to an infinite loop."},buildTokenNameError:function(t){return"Invalid Grammar Token name: ->"+t.tokenType.name+"<- it must match the pattern: ->"+t.expectedPattern.toString()+"<-"},buildEmptyAlternationError:function(t){return"Ambiguous empty alternative: <"+(t.emptyChoiceIdx+1)+"> in inside <"+t.topLevelRule.name+"> Rule.\nOnly the last alternative may be an empty alternative."},buildTooManyAlternativesError:function(t){return"An Alternation cannot have more than 256 alternatives:\n inside <"+t.topLevelRule.name+"> Rule.\n has "+(t.alternation.definition.length+1)+" alternatives."},buildLeftRecursionError:function(t){var e=t.topLevelRule.name;return"Left Recursion found in grammar.\nrule: <"+e+"> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n "+(e+" --\x3e "+R(t.leftRecursionPath,(function(t){return t.name})).concat([e]).join(" --\x3e "))+"\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring."},buildInvalidRuleNameError:function(t){return"Invalid grammar rule name: ->"+t.topLevelRule.name+"<- it must match the pattern: ->"+t.expectedPattern.toString()+"<-"},buildDuplicateRuleNameError:function(t){return"Duplicate definition, rule: ->"+(t.topLevelRule instanceof oe?t.topLevelRule.name:t.topLevelRule)+"<- is already defined in the grammar: ->"+t.grammarName+"<-"}},_e=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();var Le=function(t){function e(e,n){var r=t.call(this)||this;return r.nameToTopRule=e,r.errMsgProvider=n,r.errors=[],r}return _e(e,t),e.prototype.resolveRefs=function(){var t=this;N(g(this.nameToTopRule),(function(e){t.currTopLevel=e,e.accept(t)}))},e.prototype.visitNonTerminal=function(t){var e=this.nameToTopRule[t.nonTerminalName];if(e)t.referencedRule=e;else{var n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:n,type:zn.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}},e}(ye),ke=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ce=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.path=n,r.nextTerminalName="",r.nextTerminalOccurrence=0,r.nextTerminalName=r.path.lastTok.name,r.nextTerminalOccurrence=r.path.lastTokOccurrence,r}return ke(e,t),e.prototype.walkTerminal=function(t,e,n){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){var r=e.concat(n),o=new ie({definition:r});this.possibleTokTypes=Re(o),this.found=!0}},e}(function(t){function e(e,n){var r=t.call(this)||this;return r.topProd=e,r.path=n,r.possibleTokTypes=[],r.nextProductionName="",r.nextProductionOccurrence=0,r.found=!1,r.isAtEndOfPath=!1,r}return ke(e,t),e.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=U(this.path.ruleStack).reverse(),this.occurrenceStack=U(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},e.prototype.walk=function(e,n){void 0===n&&(n=[]),this.found||t.prototype.walk.call(this,e,n)},e.prototype.walkProdRef=function(t,e,n){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){var r=e.concat(n);this.updateExpectedNext(),this.walk(t.referencedRule,r)}},e.prototype.updateExpectedNext=function(){E(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},e}(de)),xe=function(t){function e(e,n){var r=t.call(this)||this;return r.topRule=e,r.occurrence=n,r.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},r}return ke(e,t),e.prototype.startWalking=function(){return this.walk(this.topRule),this.result},e}(de),Pe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ke(e,t),e.prototype.walkMany=function(e,n,r){if(e.idx===this.occurrence){var o=O(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof he&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkMany.call(this,e,n,r)},e}(xe),be=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ke(e,t),e.prototype.walkManySep=function(e,n,r){if(e.idx===this.occurrence){var o=O(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof he&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkManySep.call(this,e,n,r)},e}(xe),Me=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ke(e,t),e.prototype.walkAtLeastOne=function(e,n,r){if(e.idx===this.occurrence){var o=O(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof he&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkAtLeastOne.call(this,e,n,r)},e}(xe),we=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ke(e,t),e.prototype.walkAtLeastOneSep=function(e,n,r){if(e.idx===this.occurrence){var o=O(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof he&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkAtLeastOneSep.call(this,e,n,r)},e}(xe);function Ue(t,e,n){void 0===n&&(n=[]),n=U(n);var r=[],o=0;function i(i){var a=Ue(i.concat(k(t,o+1)),e,n);return r.concat(a)}for(;n.length=0;_--){var L={idx:h,def:v.definition[_].definition.concat(k(p)),ruleStack:f,occurrenceStack:d};u.push(L),u.push("EXIT_ALTERNATIVE")}else if(v instanceof ie)u.push({idx:h,def:v.definition.concat(k(p)),ruleStack:f,occurrenceStack:d});else{if(!(v instanceof oe))throw Error("non exhaustive match");u.push(De(v,h,f,d))}}}else i&&I(u).idx<=s&&u.pop()}return c}function De(t,e,n,r){var o=U(n);o.push(t.name);var i=U(r);return i.push(1),{idx:e,def:t.definition,ruleStack:o,occurrenceStack:i}}var Be,Ge=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t[t.OPTION=0]="OPTION",t[t.REPETITION=1]="REPETITION",t[t.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",t[t.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",t[t.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",t[t.ALTERNATION=5]="ALTERNATION"}(Be||(Be={}));var Ke=function(t){function e(e,n,r){var o=t.call(this)||this;return o.topProd=e,o.targetOccurrence=n,o.targetProdType=r,o}return Ge(e,t),e.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},e.prototype.checkIsTarget=function(t,e,n,r){return t.idx===this.targetOccurrence&&this.targetProdType===e&&(this.restDef=n.concat(r),!0)},e.prototype.walkOption=function(e,n,r){this.checkIsTarget(e,Be.OPTION,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkAtLeastOne=function(e,n,r){this.checkIsTarget(e,Be.REPETITION_MANDATORY,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkAtLeastOneSep=function(e,n,r){this.checkIsTarget(e,Be.REPETITION_MANDATORY_WITH_SEPARATOR,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkMany=function(e,n,r){this.checkIsTarget(e,Be.REPETITION,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkManySep=function(e,n,r){this.checkIsTarget(e,Be.REPETITION_WITH_SEPARATOR,n,r)||t.prototype.walkOption.call(this,e,n,r)},e}(de),je=function(t){function e(e,n,r){var o=t.call(this)||this;return o.targetOccurrence=e,o.targetProdType=n,o.targetRef=r,o.result=[],o}return Ge(e,t),e.prototype.checkIsTarget=function(t,e){t.idx!==this.targetOccurrence||this.targetProdType!==e||void 0!==this.targetRef&&t!==this.targetRef||(this.result=t.definition)},e.prototype.visitOption=function(t){this.checkIsTarget(t,Be.OPTION)},e.prototype.visitRepetition=function(t){this.checkIsTarget(t,Be.REPETITION)},e.prototype.visitRepetitionMandatory=function(t){this.checkIsTarget(t,Be.REPETITION_MANDATORY)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.checkIsTarget(t,Be.REPETITION_MANDATORY_WITH_SEPARATOR)},e.prototype.visitRepetitionWithSeparator=function(t){this.checkIsTarget(t,Be.REPETITION_WITH_SEPARATOR)},e.prototype.visitAlternation=function(t){this.checkIsTarget(t,Be.ALTERNATION)},e}(ye);function We(t){for(var e=new Array(t),n=0;n1}))),(function(n){var r=O(n),o=e.buildDuplicateFoundError(t,n),i=Te(r),a={message:o,type:zn.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:i,occurrence:r.idx},s=tn(r);return s&&(a.parameter=s),a}))}(t,r)})),a=R(t,(function(t){return function t(e,n,r,o){void 0===o&&(o=[]);var i=[],a=function t(e){var n=[];if(E(e))return n;var r=O(e);if(r instanceof re)n.push(r.referencedRule);else if(r instanceof ie||r instanceof ae||r instanceof se||r instanceof ce||r instanceof le||r instanceof ue)n=n.concat(t(r.definition));else if(r instanceof pe)n=A(R(r.definition,(function(e){return t(e.definition)})));else if(!(r instanceof he))throw Error("non exhaustive match");var o=Ee(r),i=e.length>1;if(o&&i){var a=k(e);return n.concat(t(a))}return n}(n.definition);if(E(a))return[];var s=e.name;w(a,e)&&i.push({message:r.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:o}),type:zn.LEFT_RECURSION,ruleName:s});var c=R(Y(a,o.concat([e])),(function(n){var i=U(o);return i.push(n),t(e,n,r,i)}));return i.concat(A(c))}(t,t,r)})),s=[],c=[],u=[];V(a,E)&&(s=R(t,(function(t){return function(t,e){var n=new rn;return t.accept(n),B(n.alternations,(function(n,r){var o=R(C(r.definition),(function(n,o){return E(Fe([n],[],null,1))?{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:r,emptyChoiceIdx:o}),type:zn.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:r.idx,alternative:o+1}:null}));return n.concat(G(o))}),[])}(t,r)})),c=R(t,(function(t){return function(t,e,n){var r=new rn;t.accept(r);var o=r.alternations;return B(o=P(o,(function(t){return!0===t.ignoreAmbiguities})),(function(r,o){var i=o.idx,a=o.maxLookahead||e,s=ze(i,t,a,o),c=function(t,e,n,r){var o=[];return R(B(t,(function(n,r,i){return!0===e.definition[i].ignoreAmbiguities||N(r,(function(r){var a=[i];N(t,(function(t,n){i!==n&&qe(t,r)&&!0!==e.definition[n].ignoreAmbiguities&&a.push(n)})),a.length>1&&!qe(o,r)&&(o.push(r),n.push({alts:a,path:r}))})),n}),[]),(function(t){var o=R(t.alts,(function(t){return t+1}));return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:o,prefixPath:t.path}),type:zn.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:e.idx,alternatives:[t.alts]}}))}(s,o,t,n),u=function(t,e,n,r){var o=[],i=B(t,(function(t,e,n){var r=R(e,(function(t){return{idx:n,path:t}}));return t.concat(r)}),[]);return N(i,(function(t){if(!0!==e.definition[t.idx].ignoreAmbiguities){var a=t.idx,s=t.path,c=R(function(t,e){for(var n=[],r=0;r255&&n.push({message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:r}),type:zn.TOO_MANY_ALTS,ruleName:t.name,occurrence:r.idx}),n}),[])}(t,r)})),f=R(t,(function(t){return function(t,e){var n=[],r=t.name;r.match(nn)||n.push({message:e.buildInvalidRuleNameError({topLevelRule:t,expectedPattern:nn}),type:zn.INVALID_RULE_NAME,ruleName:r});return n}(t,r)})),d=R(t,(function(e){return function(t,e,n,r){var o=[];if(B(e,(function(e,n){return n.name===t.name?e+1:e}),0)>1){var i=r.buildDuplicateRuleNameError({topLevelRule:t,grammarName:n});o.push({message:i,type:zn.DUPLICATE_RULE_NAME,ruleName:t.name})}return o}(e,t,o,r)}));return A(i.concat(p,u,a,s,c,l,h,f,d))}function Je(t){return Te(t)+"_#_"+t.idx+"_#_"+tn(t)}function tn(t){return t instanceof he?t.terminalType.name:t instanceof re?t.nonTerminalName:""}var en=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allProductions=[],e}return $e(e,t),e.prototype.visitNonTerminal=function(t){this.allProductions.push(t)},e.prototype.visitOption=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetition=function(t){this.allProductions.push(t)},e.prototype.visitAlternation=function(t){this.allProductions.push(t)},e.prototype.visitTerminal=function(t){this.allProductions.push(t)},e}(ye),nn=/^[a-zA-Z_]\w*$/;var rn=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.alternations=[],e}return $e(e,t),e.prototype.visitAlternation=function(t){this.alternations.push(t)},e}(ye);var on=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allProductions=[],e}return $e(e,t),e.prototype.visitRepetitionWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetition=function(t){this.allProductions.push(t)},e}(ye);function an(t){t=Z(t,{errMsgProvider:Ne});var e,n,r,o={};return N(t.rules,(function(t){o[t.name]=t})),e=o,n=t.errMsgProvider,(r=new Le(e,n)).resolveRefs(),r.errors}var sn=["MismatchedTokenException","NoViableAltException","EarlyExitException","NotAllInputParsedException"];function cn(t){return w(sn,t.name)}function un(t,e,n){this.name="MismatchedTokenException",this.message=t,this.token=e,this.previousToken=n,this.resyncedTokens=[]}function ln(t,e,n){this.name="NoViableAltException",this.message=t,this.token=e,this.previousToken=n,this.resyncedTokens=[]}function pn(t,e){this.name="NotAllInputParsedException",this.message=t,this.token=e,this.resyncedTokens=[]}function hn(t,e,n){this.name="EarlyExitException",this.message=t,this.token=e,this.previousToken=n,this.resyncedTokens=[]}Object.freeze(sn),un.prototype=Error.prototype,ln.prototype=Error.prototype,pn.prototype=Error.prototype,hn.prototype=Error.prototype;var fn={};function dn(t){this.name="InRuleRecoveryException",this.message=t}dn.prototype=Error.prototype;var vn=function(){function t(){}return t.prototype.initRecoverable=function(t){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=M(t,"recoveryEnabled")?t.recoveryEnabled:Xn.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=yn)},t.prototype.getTokenToInsert=function(t){var e=te(t,"",NaN,NaN,NaN,NaN,NaN,NaN);return e.isInsertedInRecovery=!0,e},t.prototype.canTokenTypeBeInsertedInRecovery=function(t){return!0},t.prototype.tryInRepetitionRecovery=function(t,e,n,r){for(var o=this,i=this.findReSyncTokenType(),a=this.exportLexerState(),s=[],c=!1,u=this.LA(1),l=this.LA(1),p=function(){var t=o.LA(0),e=new un(o.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:u,previous:t,ruleName:o.getCurrRuleFullName()}),u,o.LA(0));e.resyncedTokens=C(s),o.SAVE_ERROR(e)};!c;){if(this.tokenMatcher(l,r))return void p();if(n.call(this))return p(),void t.apply(this,e);this.tokenMatcher(l,i)?c=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,s))}this.importLexerState(a)},t.prototype.shouldInRepetitionRecoveryBeTried=function(t,e,n){return!1!==n&&(void 0!==t&&void 0!==e&&(!this.tokenMatcher(this.LA(1),t)&&(!this.isBackTracking()&&!this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,e)))))},t.prototype.getFollowsForInRuleRecovery=function(t,e){var n=this.getCurrentGrammarPath(t,e);return this.getNextPossibleTokenTypes(n)},t.prototype.tryInRuleRecovery=function(t,e){if(this.canRecoverWithSingleTokenInsertion(t,e))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){var n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new dn("sad sad panda")},t.prototype.canPerformInRuleRecovery=function(t,e){return this.canRecoverWithSingleTokenInsertion(t,e)||this.canRecoverWithSingleTokenDeletion(t)},t.prototype.canRecoverWithSingleTokenInsertion=function(t,e){var n=this;if(!this.canTokenTypeBeInsertedInRecovery(t))return!1;if(E(e))return!1;var r=this.LA(1);return void 0!==D(e,(function(t){return n.tokenMatcher(r,t)}))},t.prototype.canRecoverWithSingleTokenDeletion=function(t){return this.tokenMatcher(this.LA(2),t)},t.prototype.isInCurrentRuleReSyncSet=function(t){var e=this.getCurrFollowKey();return w(this.getFollowSetFromFollowKey(e),t)},t.prototype.findReSyncTokenType=function(){for(var t=this.flattenFollowSet(),e=this.LA(1),n=2;;){var r=e.tokenType;if(w(t,r))return r;e=this.LA(n),n++}},t.prototype.getCurrFollowKey=function(){if(1===this.RULE_STACK.length)return fn;var t=this.getLastExplicitRuleShortName(),e=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:e,inRule:this.shortRuleNameToFullName(n)}},t.prototype.buildFullFollowKeyStack=function(){var t=this,e=this.RULE_STACK,n=this.RULE_OCCURRENCE_STACK;return R(e,(function(r,o){return 0===o?fn:{ruleName:t.shortRuleNameToFullName(r),idxInCallingRule:n[o],inRule:t.shortRuleNameToFullName(e[o-1])}}))},t.prototype.flattenFollowSet=function(){var t=this;return A(R(this.buildFullFollowKeyStack(),(function(e){return t.getFollowSetFromFollowKey(e)})))},t.prototype.getFollowSetFromFollowKey=function(t){if(t===fn)return[Jt];var e=t.ruleName+t.idxInCallingRule+"_~IN~_"+t.inRule;return this.resyncFollows[e]},t.prototype.addToResyncTokens=function(t,e){return this.tokenMatcher(t,Jt)||e.push(t),e},t.prototype.reSyncTo=function(t){for(var e=[],n=this.LA(1);!1===this.tokenMatcher(n,t);)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,e);return C(e)},t.prototype.attemptInRepetitionRecovery=function(t,e,n,r,o,i,a){},t.prototype.getCurrentGrammarPath=function(t,e){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:U(this.RULE_OCCURRENCE_STACK),lastTok:t,lastTokOccurrence:e}},t.prototype.getHumanReadableRuleStack=function(){var t=this;return R(this.RULE_STACK,(function(e){return t.shortRuleNameToFullName(e)}))},t}();function yn(t,e,n,r,o,i,a){var s=this.getKeyForAutomaticLookahead(r,o),c=this.firstAfterRepMap[s];if(void 0===c){var u=this.getCurrRuleFullName();c=new i(this.getGAstProductions()[u],o).startWalking(),this.firstAfterRepMap[s]=c}var l=c.token,p=c.occurrence,h=c.isEndOfRule;1===this.RULE_STACK.length&&h&&void 0===l&&(l=Jt,p=1),this.shouldInRepetitionRecoveryBeTried(l,p,a)&&this.tryInRepetitionRecovery(t,e,n,l)}function mn(t,e,n){return n|e|t}var En=function(){function t(){}return t.prototype.initLooksAhead=function(t){this.dynamicTokensEnabled=M(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:Xn.dynamicTokensEnabled,this.maxLookahead=M(t,"maxLookahead")?t.maxLookahead:Xn.maxLookahead,this.lookAheadFuncsCache=nt()?new Map:[],nt()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},t.prototype.preComputeLookaheadFunctions=function(t){var e=this;N(t,(function(t){e.TRACE_INIT(t.name+" Rule Lookahead",(function(){var n=function(t){ge.reset(),t.accept(ge);var e=ge.dslMethods;return ge.reset(),e}(t),r=n.alternation,o=n.repetition,i=n.option,a=n.repetitionMandatory,s=n.repetitionMandatoryWithSeparator,c=n.repetitionWithSeparator;N(r,(function(n){var r=0===n.idx?"":n.idx;e.TRACE_INIT(""+Te(n)+r,(function(){var r,o,i,a,s,c,u,l=(r=n.idx,o=t,i=n.maxLookahead||e.maxLookahead,a=n.hasPredicates,s=e.dynamicTokensEnabled,c=e.lookAheadBuilderForAlternatives,u=ze(r,o,i),c(u,a,Ze(u)?Gt:Bt,s)),p=mn(e.fullRuleNameToShort[t.name],256,n.idx);e.setLaFuncCache(p,l)}))})),N(o,(function(n){e.computeLookaheadFunc(t,n.idx,768,Be.REPETITION,n.maxLookahead,Te(n))})),N(i,(function(n){e.computeLookaheadFunc(t,n.idx,512,Be.OPTION,n.maxLookahead,Te(n))})),N(a,(function(n){e.computeLookaheadFunc(t,n.idx,1024,Be.REPETITION_MANDATORY,n.maxLookahead,Te(n))})),N(s,(function(n){e.computeLookaheadFunc(t,n.idx,1536,Be.REPETITION_MANDATORY_WITH_SEPARATOR,n.maxLookahead,Te(n))})),N(c,(function(n){e.computeLookaheadFunc(t,n.idx,1280,Be.REPETITION_WITH_SEPARATOR,n.maxLookahead,Te(n))}))}))}))},t.prototype.computeLookaheadFunc=function(t,e,n,r,o,i){var a=this;this.TRACE_INIT(""+i+(0===e?"":e),(function(){var i=function(t,e,n,r,o,i){var a=Xe(t,e,o,n),s=Ze(a)?Gt:Bt;return i(a[0],s,r)}(e,t,o||a.maxLookahead,a.dynamicTokensEnabled,r,a.lookAheadBuilderForOptional),s=mn(a.fullRuleNameToShort[t.name],n,e);a.setLaFuncCache(s,i)}))},t.prototype.lookAheadBuilderForOptional=function(t,e,n){return function(t,e,n){var r=V(t,(function(t){return 1===t.length})),o=t.length;if(r&&!n){var i=A(t);if(1===i.length&&E(i[0].categoryMatches)){var a=i[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===a}}var s=B(i,(function(t,e,n){return t[e.tokenTypeIdx]=!0,N(e.categoryMatches,(function(e){t[e]=!0})),t}),[]);return function(){var t=this.LA(1);return!0===s[t.tokenTypeIdx]}}return function(){t:for(var n=0;n on "+On(t.constructor)+" CST Visitor.",type:Rn.MISSING_METHOD,methodName:e}})))}(t,e),r=function(t,e){var n=[];for(var r in t)nn.test(r)&&L(t[r])&&!w(_n,r)&&!w(e,r)&&n.push({msg:"Redundant visitor method: <"+r+"> on "+On(t.constructor)+" CST Visitor\nThere is no Grammar Rule corresponding to this method's name.\nFor utility methods on visitor classes use methods names that do not match /"+nn.source+"/.",type:Rn.REDUNDANT_METHOD,methodName:r});return n}(t,e);return n.concat(r)}(this,e);if(!E(t)){var n=R(t,(function(t){return t.msg}));throw Error("Errors Detected in CST Visitor <"+On(this.constructor)+">:\n\t"+n.join("\n\n").replace(/\n/g,"\n\t"))}}}).constructor=n,n._RULE_NAMES=e,n}!function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"}(Rn||(Rn={}));var _n=["constructor","visit","validateVisitor"];var Ln=function(){function t(){}return t.prototype.initTreeBuilder=function(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=M(t,"nodeLocationTracking")?t.nodeLocationTracking:Xn.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=gn,this.setNodeLocationFromNode=gn,this.cstPostRule=Q,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=Q,this.setNodeLocationFromNode=Q,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Tn,this.setNodeLocationFromNode=Tn,this.cstPostRule=Q,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=Q,this.setNodeLocationFromNode=Q,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else{if(!/none/i.test(this.nodeLocationTracking))throw Error('Invalid config option: "'+t.nodeLocationTracking+'"');this.setNodeLocationFromToken=Q,this.setNodeLocationFromNode=Q,this.cstPostRule=Q,this.setInitialNodeLocation=Q}else this.cstInvocationStateUpdate=Q,this.cstFinallyStateUpdate=Q,this.cstPostTerminal=Q,this.cstPostNonTerminal=Q,this.cstPostRule=Q},t.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(t){t.location={startOffset:NaN,endOffset:NaN}},t.prototype.setInitialNodeLocationOnlyOffsetRegular=function(t){t.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},t.prototype.setInitialNodeLocationFullRecovery=function(t){t.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},t.prototype.setInitialNodeLocationFullRegular=function(t){var e=this.LA(1);t.location={startOffset:e.startOffset,startLine:e.startLine,startColumn:e.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},t.prototype.cstInvocationStateUpdate=function(t,e){var n={name:t,children:{}};this.setInitialNodeLocation(n),this.CST_STACK.push(n)},t.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},t.prototype.cstPostRuleFull=function(t){var e=this.LA(0),n=t.location;n.startOffset<=e.startOffset==!0?(n.endOffset=e.endOffset,n.endLine=e.endLine,n.endColumn=e.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)},t.prototype.cstPostRuleOnlyOffset=function(t){var e=this.LA(0),n=t.location;n.startOffset<=e.startOffset==!0?n.endOffset=e.endOffset:n.startOffset=NaN},t.prototype.cstPostTerminal=function(t,e){var n,r,o,i=this.CST_STACK[this.CST_STACK.length-1];r=e,o=t,void 0===(n=i).children[o]?n.children[o]=[r]:n.children[o].push(r),this.setNodeLocationFromToken(i.location,e)},t.prototype.cstPostNonTerminal=function(t,e){var n=this.CST_STACK[this.CST_STACK.length-1];!function(t,e,n){void 0===t.children[e]?t.children[e]=[n]:t.children[e].push(n)}(n,e,t),this.setNodeLocationFromNode(n.location,t.location)},t.prototype.getBaseCstVisitorConstructor=function(){if(_(this.baseCstVisitorConstructor)){var t=Sn(this.className,T(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor},t.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(_(this.baseCstVisitorWithDefaultsConstructor)){var t=function(t,e,n){var r=function(){};In(r,t+"BaseSemanticsWithDefaults");var o=Object.create(n.prototype);return N(e,(function(t){o[t]=Nn})),(r.prototype=o).constructor=r,r}(this.className,T(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor},t.prototype.getLastExplicitRuleShortName=function(){var t=this.RULE_STACK;return t[t.length-1]},t.prototype.getPreviousExplicitRuleShortName=function(){var t=this.RULE_STACK;return t[t.length-2]},t.prototype.getLastExplicitRuleOccurrenceIndex=function(){var t=this.RULE_OCCURRENCE_STACK;return t[t.length-1]},t}(),kn=function(){function t(){}return t.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(t.prototype,"input",{get:function(){return this.tokVector},set:function(t){if(!0!==this.selfAnalysisDone)throw Error("Missing invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=t,this.tokVectorLength=t.length},enumerable:!0,configurable:!0}),t.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):Yn},t.prototype.LA=function(t){var e=this.currIdx+t;return e<0||this.tokVectorLength<=e?Yn:this.tokVector[e]},t.prototype.consumeToken=function(){this.currIdx++},t.prototype.exportLexerState=function(){return this.currIdx},t.prototype.importLexerState=function(t){this.currIdx=t},t.prototype.resetLexerState=function(){this.currIdx=-1},t.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},t.prototype.getLexerPosition=function(){return this.exportLexerState()},t}(),Cn=function(){function t(){}return t.prototype.ACTION=function(t){return t.call(this)},t.prototype.consume=function(t,e,n){return this.consumeInternal(e,t,n)},t.prototype.subrule=function(t,e,n){return this.subruleInternal(e,t,n)},t.prototype.option=function(t,e){return this.optionInternal(e,t)},t.prototype.or=function(t,e){return this.orInternal(e,t)},t.prototype.many=function(t,e){return this.manyInternal(t,e)},t.prototype.atLeastOne=function(t,e){return this.atLeastOneInternal(t,e)},t.prototype.CONSUME=function(t,e){return this.consumeInternal(t,0,e)},t.prototype.CONSUME1=function(t,e){return this.consumeInternal(t,1,e)},t.prototype.CONSUME2=function(t,e){return this.consumeInternal(t,2,e)},t.prototype.CONSUME3=function(t,e){return this.consumeInternal(t,3,e)},t.prototype.CONSUME4=function(t,e){return this.consumeInternal(t,4,e)},t.prototype.CONSUME5=function(t,e){return this.consumeInternal(t,5,e)},t.prototype.CONSUME6=function(t,e){return this.consumeInternal(t,6,e)},t.prototype.CONSUME7=function(t,e){return this.consumeInternal(t,7,e)},t.prototype.CONSUME8=function(t,e){return this.consumeInternal(t,8,e)},t.prototype.CONSUME9=function(t,e){return this.consumeInternal(t,9,e)},t.prototype.SUBRULE=function(t,e){return this.subruleInternal(t,0,e)},t.prototype.SUBRULE1=function(t,e){return this.subruleInternal(t,1,e)},t.prototype.SUBRULE2=function(t,e){return this.subruleInternal(t,2,e)},t.prototype.SUBRULE3=function(t,e){return this.subruleInternal(t,3,e)},t.prototype.SUBRULE4=function(t,e){return this.subruleInternal(t,4,e)},t.prototype.SUBRULE5=function(t,e){return this.subruleInternal(t,5,e)},t.prototype.SUBRULE6=function(t,e){return this.subruleInternal(t,6,e)},t.prototype.SUBRULE7=function(t,e){return this.subruleInternal(t,7,e)},t.prototype.SUBRULE8=function(t,e){return this.subruleInternal(t,8,e)},t.prototype.SUBRULE9=function(t,e){return this.subruleInternal(t,9,e)},t.prototype.OPTION=function(t){return this.optionInternal(t,0)},t.prototype.OPTION1=function(t){return this.optionInternal(t,1)},t.prototype.OPTION2=function(t){return this.optionInternal(t,2)},t.prototype.OPTION3=function(t){return this.optionInternal(t,3)},t.prototype.OPTION4=function(t){return this.optionInternal(t,4)},t.prototype.OPTION5=function(t){return this.optionInternal(t,5)},t.prototype.OPTION6=function(t){return this.optionInternal(t,6)},t.prototype.OPTION7=function(t){return this.optionInternal(t,7)},t.prototype.OPTION8=function(t){return this.optionInternal(t,8)},t.prototype.OPTION9=function(t){return this.optionInternal(t,9)},t.prototype.OR=function(t){return this.orInternal(t,0)},t.prototype.OR1=function(t){return this.orInternal(t,1)},t.prototype.OR2=function(t){return this.orInternal(t,2)},t.prototype.OR3=function(t){return this.orInternal(t,3)},t.prototype.OR4=function(t){return this.orInternal(t,4)},t.prototype.OR5=function(t){return this.orInternal(t,5)},t.prototype.OR6=function(t){return this.orInternal(t,6)},t.prototype.OR7=function(t){return this.orInternal(t,7)},t.prototype.OR8=function(t){return this.orInternal(t,8)},t.prototype.OR9=function(t){return this.orInternal(t,9)},t.prototype.MANY=function(t){this.manyInternal(0,t)},t.prototype.MANY1=function(t){this.manyInternal(1,t)},t.prototype.MANY2=function(t){this.manyInternal(2,t)},t.prototype.MANY3=function(t){this.manyInternal(3,t)},t.prototype.MANY4=function(t){this.manyInternal(4,t)},t.prototype.MANY5=function(t){this.manyInternal(5,t)},t.prototype.MANY6=function(t){this.manyInternal(6,t)},t.prototype.MANY7=function(t){this.manyInternal(7,t)},t.prototype.MANY8=function(t){this.manyInternal(8,t)},t.prototype.MANY9=function(t){this.manyInternal(9,t)},t.prototype.MANY_SEP=function(t){this.manySepFirstInternal(0,t)},t.prototype.MANY_SEP1=function(t){this.manySepFirstInternal(1,t)},t.prototype.MANY_SEP2=function(t){this.manySepFirstInternal(2,t)},t.prototype.MANY_SEP3=function(t){this.manySepFirstInternal(3,t)},t.prototype.MANY_SEP4=function(t){this.manySepFirstInternal(4,t)},t.prototype.MANY_SEP5=function(t){this.manySepFirstInternal(5,t)},t.prototype.MANY_SEP6=function(t){this.manySepFirstInternal(6,t)},t.prototype.MANY_SEP7=function(t){this.manySepFirstInternal(7,t)},t.prototype.MANY_SEP8=function(t){this.manySepFirstInternal(8,t)},t.prototype.MANY_SEP9=function(t){this.manySepFirstInternal(9,t)},t.prototype.AT_LEAST_ONE=function(t){this.atLeastOneInternal(0,t)},t.prototype.AT_LEAST_ONE1=function(t){return this.atLeastOneInternal(1,t)},t.prototype.AT_LEAST_ONE2=function(t){this.atLeastOneInternal(2,t)},t.prototype.AT_LEAST_ONE3=function(t){this.atLeastOneInternal(3,t)},t.prototype.AT_LEAST_ONE4=function(t){this.atLeastOneInternal(4,t)},t.prototype.AT_LEAST_ONE5=function(t){this.atLeastOneInternal(5,t)},t.prototype.AT_LEAST_ONE6=function(t){this.atLeastOneInternal(6,t)},t.prototype.AT_LEAST_ONE7=function(t){this.atLeastOneInternal(7,t)},t.prototype.AT_LEAST_ONE8=function(t){this.atLeastOneInternal(8,t)},t.prototype.AT_LEAST_ONE9=function(t){this.atLeastOneInternal(9,t)},t.prototype.AT_LEAST_ONE_SEP=function(t){this.atLeastOneSepFirstInternal(0,t)},t.prototype.AT_LEAST_ONE_SEP1=function(t){this.atLeastOneSepFirstInternal(1,t)},t.prototype.AT_LEAST_ONE_SEP2=function(t){this.atLeastOneSepFirstInternal(2,t)},t.prototype.AT_LEAST_ONE_SEP3=function(t){this.atLeastOneSepFirstInternal(3,t)},t.prototype.AT_LEAST_ONE_SEP4=function(t){this.atLeastOneSepFirstInternal(4,t)},t.prototype.AT_LEAST_ONE_SEP5=function(t){this.atLeastOneSepFirstInternal(5,t)},t.prototype.AT_LEAST_ONE_SEP6=function(t){this.atLeastOneSepFirstInternal(6,t)},t.prototype.AT_LEAST_ONE_SEP7=function(t){this.atLeastOneSepFirstInternal(7,t)},t.prototype.AT_LEAST_ONE_SEP8=function(t){this.atLeastOneSepFirstInternal(8,t)},t.prototype.AT_LEAST_ONE_SEP9=function(t){this.atLeastOneSepFirstInternal(9,t)},t.prototype.RULE=function(t,e,n){if(void 0===n&&(n=qn),w(this.definedRulesNames,t)){var r={message:Se.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:zn.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(r)}this.definedRulesNames.push(t);var o=this.defineRule(t,e,n);return this[t]=o,o},t.prototype.OVERRIDE_RULE=function(t,e,n){void 0===n&&(n=qn);var r,o,i,a,s,c=[];c=c.concat((r=t,o=this.definedRulesNames,i=this.className,s=[],w(o,r)||(a="Invalid rule override, rule: ->"+r+"<- cannot be overridden in the grammar: ->"+i+"<-as it is not defined in any of the super grammars ",s.push({message:a,type:zn.INVALID_RULE_OVERRIDE,ruleName:r})),s)),this.definitionErrors.push.apply(this.definitionErrors,c);var u=this.defineRule(t,e,n);return this[t]=u,u},t.prototype.BACKTRACK=function(t,e){return function(){this.isBackTrackingStack.push(1);var n=this.saveRecogState();try{return t.apply(this,e),!0}catch(t){if(cn(t))return!1;throw t}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}},t.prototype.getGAstProductions=function(){return this.gastProductionsCache},t.prototype.getSerializedGastProductions=function(){return R(g(this.gastProductionsCache),fe)},t}(),xn=function(){function t(){}return t.prototype.initRecognizerEngine=function(t,e){if(this.className=On(this.constructor),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=Gt,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},M(e,"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(j(t)){if(E(t))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("number"==typeof t[0].startOffset)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(j(t))this.tokensMap=B(t,(function(t,e){return t[e.name]=e,t}),{});else if(M(t,"modes")&&V(A(g(t.modes)),Yt)){var n=K(A(g(t.modes)));this.tokensMap=B(n,(function(t,e){return t[e.name]=e,t}),{})}else{if(!H(t))throw new Error(" argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=F(t)}this.tokensMap.EOF=Jt;var r=V(g(t),(function(t){return E(t.categoryMatches)}));this.tokenMatcher=r?Gt:Bt,Wt(g(this.tokensMap))},t.prototype.defineRule=function(t,e,n){if(this.selfAnalysisDone)throw Error("Grammar rule <"+t+"> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.");var r,o=M(n,"resyncEnabled")?n.resyncEnabled:qn.resyncEnabled,i=M(n,"recoveryValueFunc")?n.recoveryValueFunc:qn.recoveryValueFunc,a=this.ruleShortNameIdx<<12;function s(t){try{if(!0===this.outputCst){e.apply(this,t);var n=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(n),n}return e.apply(this,t)}catch(t){return this.invokeRuleCatch(t,o,i)}finally{this.ruleFinallyStateUpdate()}}this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=t,this.fullRuleNameToShort[t]=a;return(r=function(e,n){return void 0===e&&(e=0),this.ruleInvocationStateUpdate(a,t,e),s.call(this,n)}).ruleName=t,r.originalGrammarAction=e,r},t.prototype.invokeRuleCatch=function(t,e,n){var r=1===this.RULE_STACK.length,o=e&&!this.isBackTracking()&&this.recoveryEnabled;if(cn(t)){var i=t;if(o){var a,s=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(s))return i.resyncedTokens=this.reSyncTo(s),this.outputCst?((a=this.CST_STACK[this.CST_STACK.length-1]).recoveredNode=!0,a):n();throw this.outputCst&&((a=this.CST_STACK[this.CST_STACK.length-1]).recoveredNode=!0,i.partialCstResult=a),i}if(r)return this.moveToTerminatedState(),n();throw i}throw t},t.prototype.optionInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(512,e);return this.optionInternalLogic(t,e,n)},t.prototype.optionInternalLogic=function(t,e,n){var r,o,i=this,a=this.getLaFuncFromCache(n);if(void 0!==t.DEF){if(r=t.DEF,void 0!==(o=t.GATE)){var s=a;a=function(){return o.call(i)&&s.call(i)}}}else r=t;if(!0===a.call(this))return r.call(this)},t.prototype.atLeastOneInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(1024,t);return this.atLeastOneInternalLogic(t,e,n)},t.prototype.atLeastOneInternalLogic=function(t,e,n){var r,o,i=this,a=this.getLaFuncFromCache(n);if(void 0!==e.DEF){if(r=e.DEF,void 0!==(o=e.GATE)){var s=a;a=function(){return o.call(i)&&s.call(i)}}}else r=e;if(!0!==a.call(this))throw this.raiseEarlyExitException(t,Be.REPETITION_MANDATORY,e.ERR_MSG);for(var c=this.doSingleRepetition(r);!0===a.call(this)&&!0===c;)c=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,e],a,1024,t,Me)},t.prototype.atLeastOneSepFirstInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(1536,t);this.atLeastOneSepFirstInternalLogic(t,e,n)},t.prototype.atLeastOneSepFirstInternalLogic=function(t,e,n){var r=this,o=e.DEF,i=e.SEP;if(!0!==this.getLaFuncFromCache(n).call(this))throw this.raiseEarlyExitException(t,Be.REPETITION_MANDATORY_WITH_SEPARATOR,e.ERR_MSG);o.call(this);for(var a=function(){return r.tokenMatcher(r.LA(1),i)};!0===this.tokenMatcher(this.LA(1),i);)this.CONSUME(i),o.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,i,a,o,we],a,1536,t,we)},t.prototype.manyInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(768,t);return this.manyInternalLogic(t,e,n)},t.prototype.manyInternalLogic=function(t,e,n){var r,o,i=this,a=this.getLaFuncFromCache(n);if(void 0!==e.DEF){if(r=e.DEF,void 0!==(o=e.GATE)){var s=a;a=function(){return o.call(i)&&s.call(i)}}}else r=e;for(var c=!0;!0===a.call(this)&&!0===c;)c=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[t,e],a,768,t,Pe,c)},t.prototype.manySepFirstInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(1280,t);this.manySepFirstInternalLogic(t,e,n)},t.prototype.manySepFirstInternalLogic=function(t,e,n){var r=this,o=e.DEF,i=e.SEP;if(!0===this.getLaFuncFromCache(n).call(this)){o.call(this);for(var a=function(){return r.tokenMatcher(r.LA(1),i)};!0===this.tokenMatcher(this.LA(1),i);)this.CONSUME(i),o.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,i,a,o,be],a,1280,t,be)}},t.prototype.repetitionSepSecondInternal=function(t,e,n,r,o){for(;n();)this.CONSUME(e),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,e,n,r,o],n,1536,t,o)},t.prototype.doSingleRepetition=function(t){var e=this.getLexerPosition();return t.call(this),this.getLexerPosition()>e},t.prototype.orInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(256,e),r=j(t)?t:t.DEF,o=this.getLaFuncFromCache(n).call(this,r);if(void 0!==o)return r[o].ALT.call(this);this.raiseNoAltException(e,t.ERR_MSG)},t.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),0===this.RULE_STACK.length&&!1===this.isAtEndOfInput()){var t=this.LA(1),e=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new pn(e,t))}},t.prototype.subruleInternal=function(t,e,n){var r;try{var o=void 0!==n?n.ARGS:void 0;return r=t.call(this,e,o),this.cstPostNonTerminal(r,void 0!==n&&void 0!==n.LABEL?n.LABEL:t.ruleName),r}catch(e){this.subruleInternalError(e,n,t.ruleName)}},t.prototype.subruleInternalError=function(t,e,n){throw cn(t)&&void 0!==t.partialCstResult&&(this.cstPostNonTerminal(t.partialCstResult,void 0!==e&&void 0!==e.LABEL?e.LABEL:n),delete t.partialCstResult),t},t.prototype.consumeInternal=function(t,e,n){var r;try{var o=this.LA(1);!0===this.tokenMatcher(o,t)?(this.consumeToken(),r=o):this.consumeInternalError(t,o,n)}catch(n){r=this.consumeInternalRecovery(t,e,n)}return this.cstPostTerminal(void 0!==n&&void 0!==n.LABEL?n.LABEL:t.name,r),r},t.prototype.consumeInternalError=function(t,e,n){var r,o=this.LA(0);throw r=void 0!==n&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:e,previous:o,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new un(r,e,o))},t.prototype.consumeInternalRecovery=function(t,e,n){if(!this.recoveryEnabled||"MismatchedTokenException"!==n.name||this.isBackTracking())throw n;var r=this.getFollowsForInRuleRecovery(t,e);try{return this.tryInRuleRecovery(t,r)}catch(t){throw"InRuleRecoveryException"===t.name?n:t}},t.prototype.saveRecogState=function(){var t=this.errors,e=U(this.RULE_STACK);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:e,CST_STACK:this.CST_STACK}},t.prototype.reloadRecogState=function(t){this.errors=t.errors,this.importLexerState(t.lexerState),this.RULE_STACK=t.RULE_STACK},t.prototype.ruleInvocationStateUpdate=function(t,e,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(t),this.cstInvocationStateUpdate(e,t)},t.prototype.isBackTracking=function(){return 0!==this.isBackTrackingStack.length},t.prototype.getCurrRuleFullName=function(){var t=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[t]},t.prototype.shortRuleNameToFullName=function(t){return this.shortRuleNameToFull[t]},t.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),Jt)},t.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},t}(),Pn=function(){function t(){}return t.prototype.initErrorHandler=function(t){this._errors=[],this.errorMessageProvider=M(t,"errorMessageProvider")?t.errorMessageProvider:Xn.errorMessageProvider},t.prototype.SAVE_ERROR=function(t){if(cn(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:U(this.RULE_OCCURRENCE_STACK)},this._errors.push(t),t;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(t.prototype,"errors",{get:function(){return U(this._errors)},set:function(t){this._errors=t},enumerable:!0,configurable:!0}),t.prototype.raiseEarlyExitException=function(t,e,n){for(var r=this.getCurrRuleFullName(),o=Xe(t,this.getGAstProductions()[r],e,this.maxLookahead)[0],i=[],a=1;a<=this.maxLookahead;a++)i.push(this.LA(a));var s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:o,actual:i,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new hn(s,this.LA(1),this.LA(0)))},t.prototype.raiseNoAltException=function(t,e){for(var n=this.getCurrRuleFullName(),r=ze(t,this.getGAstProductions()[n],this.maxLookahead),o=[],i=1;i<=this.maxLookahead;i++)o.push(this.LA(i));var a=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:r,actual:o,previous:a,customUserDescription:e,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new ln(s,this.LA(1),a))},t}(),bn=function(){function t(){}return t.prototype.initContentAssist=function(){},t.prototype.computeContentAssist=function(t,e){var n=this.gastProductionsCache[t];if(_(n))throw Error("Rule ->"+t+"<- does not exist in this grammar.");return Fe([n],e,this.tokenMatcher,this.maxLookahead)},t.prototype.getNextPossibleTokenTypes=function(t){var e=O(t.ruleStack),n=this.getGAstProductions()[e];return new Ce(n,t).startWalking()},t}(),Mn={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Mn);var wn=Math.pow(2,8)-1,Un=Qt({name:"RECORDING_PHASE_TOKEN",pattern:qt.NA});Wt([Un]);var Fn=te(Un,"This IToken indicates the Parser is in Recording Phase\n\tSee: https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(Fn);var Dn={name:"This CSTNode indicates the Parser is in Recording Phase\n\tSee: https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording for details",children:{}},Bn=function(){function t(){}return t.prototype.initGastRecorder=function(t){this.recordingProdStack=[],this.RECORDING_PHASE=!1},t.prototype.enableRecording=function(){var t=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",(function(){for(var e=function(e){var n=e>0?e:"";t["CONSUME"+n]=function(t,n){return this.consumeInternalRecord(t,e,n)},t["SUBRULE"+n]=function(t,n){return this.subruleInternalRecord(t,e,n)},t["OPTION"+n]=function(t){return this.optionInternalRecord(t,e)},t["OR"+n]=function(t){return this.orInternalRecord(t,e)},t["MANY"+n]=function(t){this.manyInternalRecord(e,t)},t["MANY_SEP"+n]=function(t){this.manySepFirstInternalRecord(e,t)},t["AT_LEAST_ONE"+n]=function(t){this.atLeastOneInternalRecord(e,t)},t["AT_LEAST_ONE_SEP"+n]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}},n=0;n<10;n++)e(n);t.consume=function(t,e,n){return this.consumeInternalRecord(e,t,n)},t.subrule=function(t,e,n){return this.subruleInternalRecord(e,t,n)},t.option=function(t,e){return this.optionInternalRecord(e,t)},t.or=function(t,e){return this.orInternalRecord(e,t)},t.many=function(t,e){this.manyInternalRecord(t,e)},t.atLeastOne=function(t,e){this.atLeastOneInternalRecord(t,e)},t.ACTION=t.ACTION_RECORD,t.BACKTRACK=t.BACKTRACK_RECORD,t.LA=t.LA_RECORD}))},t.prototype.disableRecording=function(){var t=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",(function(){for(var e=0;e<10;e++){var n=e>0?e:"";delete t["CONSUME"+n],delete t["SUBRULE"+n],delete t["OPTION"+n],delete t["OR"+n],delete t["MANY"+n],delete t["MANY_SEP"+n],delete t["AT_LEAST_ONE"+n],delete t["AT_LEAST_ONE_SEP"+n]}delete t.consume,delete t.subrule,delete t.option,delete t.or,delete t.many,delete t.atLeastOne,delete t.ACTION,delete t.BACKTRACK,delete t.LA}))},t.prototype.ACTION_RECORD=function(t){},t.prototype.BACKTRACK_RECORD=function(t,e){return function(){return!0}},t.prototype.LA_RECORD=function(t){return Yn},t.prototype.topLevelRuleRecord=function(t,e){try{var n=new oe({definition:[],name:t});return n.name=t,this.recordingProdStack.push(n),e.call(this),this.recordingProdStack.pop(),n}catch(t){if(!0!==t.KNOWN_RECORDER_ERROR)try{t.message=t.message+'\n\t This error was thrown during the "grammar recording phase" For more info see:\n\thttps://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording'}catch(e){throw t}throw t}},t.prototype.optionInternalRecord=function(t,e){return Gn.call(this,ae,t,e)},t.prototype.atLeastOneInternalRecord=function(t,e){Gn.call(this,se,e,t)},t.prototype.atLeastOneSepFirstInternalRecord=function(t,e){Gn.call(this,ce,e,t,!0)},t.prototype.manyInternalRecord=function(t,e){Gn.call(this,ue,e,t)},t.prototype.manySepFirstInternalRecord=function(t,e){Gn.call(this,le,e,t,!0)},t.prototype.orInternalRecord=function(t,e){return Kn.call(this,t,e)},t.prototype.subruleInternalRecord=function(t,e,n){if(Wn(e),!t||!1===M(t,"ruleName")){var r=new Error(" argument is invalid expecting a Parser method reference but got: <"+JSON.stringify(t)+">\n inside top level rule: <"+this.recordingProdStack[0].name+">");throw r.KNOWN_RECORDER_ERROR=!0,r}var o=ot(this.recordingProdStack),i=t.ruleName,a=new re({idx:e,nonTerminalName:i,referencedRule:void 0});return o.definition.push(a),this.outputCst?Dn:Mn},t.prototype.consumeInternalRecord=function(t,e,n){if(Wn(e),!Ht(t)){var r=new Error(" argument is invalid expecting a TokenType reference but got: <"+JSON.stringify(t)+">\n inside top level rule: <"+this.recordingProdStack[0].name+">");throw r.KNOWN_RECORDER_ERROR=!0,r}var o=ot(this.recordingProdStack),i=new he({idx:e,terminalType:t});return o.definition.push(i),Fn},t}();function Gn(t,e,n,r){void 0===r&&(r=!1),Wn(n);var o=ot(this.recordingProdStack),i=L(e)?e:e.DEF,a=new t({definition:[],idx:n});return r&&(a.separator=e.SEP),M(e,"MAX_LOOKAHEAD")&&(a.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(a),i.call(this),o.definition.push(a),this.recordingProdStack.pop(),Mn}function Kn(t,e){var n=this;Wn(e);var r=ot(this.recordingProdStack),o=!1===j(t),i=!1===o?t:t.DEF,a=new pe({definition:[],idx:e,ignoreAmbiguities:o&&!0===t.IGNORE_AMBIGUITIES});M(t,"MAX_LOOKAHEAD")&&(a.maxLookahead=t.MAX_LOOKAHEAD);var s=z(i,(function(t){return L(t.GATE)}));return a.hasPredicates=s,r.definition.push(a),N(i,(function(t){var e=new ie({definition:[]});a.definition.push(e),M(t,"IGNORE_AMBIGUITIES")?e.ignoreAmbiguities=t.IGNORE_AMBIGUITIES:M(t,"GATE")&&(e.ignoreAmbiguities=!0),n.recordingProdStack.push(e),t.ALT.call(n),n.recordingProdStack.pop()})),Mn}function jn(t){return 0===t?"":""+t}function Wn(t){if(t<0||t>wn){var e=new Error("Invalid DSL Method idx value: <"+t+">\n\tIdx value must be a none negative value smaller than "+(wn+1));throw e.KNOWN_RECORDER_ERROR=!0,e}}var Hn=function(){function t(){}return t.prototype.initPerformanceTracer=function(t){if(M(t,"traceInitPerf")){var e=t.traceInitPerf,n="number"==typeof e;this.traceInitMaxIdent=n?e:1/0,this.traceInitPerf=n?e>0:e}else this.traceInitMaxIdent=0,this.traceInitPerf=Xn.traceInitPerf;this.traceInitIndent=-1},t.prototype.TRACE_INIT=function(t,e){if(!0===this.traceInitPerf){this.traceInitIndent++;var n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent");var r=it(e),o=r.time,i=r.value,a=o>10?console.warn:console.log;return this.traceInitIndent time: "+o+"ms"),this.traceInitIndent--,i}return e()},t}(),Vn=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Yn=te(Jt,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Yn);var zn,Xn=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Ie,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),qn=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0});!function(t){t[t.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",t[t.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",t[t.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",t[t.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",t[t.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",t[t.LEFT_RECURSION=5]="LEFT_RECURSION",t[t.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",t[t.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",t[t.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",t[t.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",t[t.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",t[t.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",t[t.TOO_MANY_ALTS=12]="TOO_MANY_ALTS"}(zn||(zn={}));var Zn,$n=function(){function t(t,e){this.definitionErrors=[],this.selfAnalysisDone=!1;if(this.initErrorHandler(e),this.initLexerAdapter(),this.initLooksAhead(e),this.initRecognizerEngine(t,e),this.initRecoverable(e),this.initTreeBuilder(e),this.initContentAssist(),this.initGastRecorder(e),this.initPerformanceTracer(e),M(e,"ignoredIssues"))throw new Error("The IParserConfig property has been deprecated.\n\tPlease use the flag on the relevant DSL method instead.\n\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\tFor further details.");this.skipValidations=M(e,"skipValidations")?e.skipValidations:Xn.skipValidations}return t.performSelfAnalysis=function(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")},t.prototype.performSelfAnalysis=function(){var e=this;this.TRACE_INIT("performSelfAnalysis",(function(){var n;e.selfAnalysisDone=!0;var r=e.className;e.TRACE_INIT("toFastProps",(function(){rt(e)})),e.TRACE_INIT("Grammar Recording",(function(){try{e.enableRecording(),N(e.definedRulesNames,(function(t){var n=e[t].originalGrammarAction,r=void 0;e.TRACE_INIT(t+" Rule",(function(){r=e.topLevelRuleRecord(t,n)})),e.gastProductionsCache[t]=r}))}finally{e.disableRecording()}}));var o=[];if(e.TRACE_INIT("Grammar Resolving",(function(){o=an({rules:g(e.gastProductionsCache)}),e.definitionErrors.push.apply(e.definitionErrors,o)})),e.TRACE_INIT("Grammar Validations",(function(){if(E(o)&&!1===e.skipValidations){var t=Qe((n=Z(n={rules:g(e.gastProductionsCache),maxLookahead:e.maxLookahead,tokenTypes:g(e.tokensMap),errMsgProvider:Se,grammarName:r},{errMsgProvider:Se})).rules,n.maxLookahead,n.tokenTypes,n.errMsgProvider,n.grammarName);e.definitionErrors.push.apply(e.definitionErrors,t)}var n})),E(e.definitionErrors)&&(e.recoveryEnabled&&e.TRACE_INIT("computeAllProdsFollows",(function(){var t,n,r=(t=g(e.gastProductionsCache),n={},N(t,(function(t){var e=new Oe(t).startWalking();X(n,e)})),n);e.resyncFollows=r})),e.TRACE_INIT("ComputeLookaheadFunctions",(function(){e.preComputeLookaheadFunctions(g(e.gastProductionsCache))}))),!t.DEFER_DEFINITION_ERRORS_HANDLING&&!E(e.definitionErrors))throw n=R(e.definitionErrors,(function(t){return t.message})),new Error("Parser Definition Errors detected:\n "+n.join("\n-------------------------------\n"))}))},t.DEFER_DEFINITION_ERRORS_HANDLING=!1,t}();Zn=$n,[vn,En,Ln,kn,xn,Cn,Pn,bn,Bn,Hn].forEach((function(t){var e=t.prototype;Object.getOwnPropertyNames(e).forEach((function(n){if("constructor"!==n){var r=Object.getOwnPropertyDescriptor(e,n);r&&(r.get||r.set)?Object.defineProperty(Zn.prototype,n,r):Zn.prototype[n]=t.prototype[n]}}))}));!function(t){function e(e,n){void 0===n&&(n=Xn);var r=F(n);return r.outputCst=!0,t.call(this,e,r)||this}Vn(e,t)}($n);var Qn=function(t){function e(e,n){void 0===n&&(n=Xn);var r=F(n);return r.outputCst=!1,t.call(this,e,r)||this}return Vn(e,t),e}($n),Jn=Symbol("NOOP"),tr=Symbol("MATCH_ANY"),er=Symbol("MATCH_WORD"),nr=Symbol("MATCH_TAG"),rr=Symbol("MATCH_METHOD"),or=Symbol("MATCH_END"),ir=Symbol("JMP"),ar=Symbol("SPLIT"),sr=Symbol("GLOBAL_SAVE"),cr=Symbol("MATCH"),ur=Symbol("OGROUP"),lr=Symbol("CGROUP"),pr=Symbol("INCV"),hr=Symbol("JMP_LT"),fr=Symbol("SPLIT_LT"),dr=Symbol("LOOKAHEAD"),vr=Symbol("NEGATIVE_LOOKAHEAD"),yr=Qt({name:"StartOf",pattern:/\^/}),mr=Qt({name:"EndOf",pattern:/\$/}),Er=Qt({name:"Tag",pattern:/#([_-\w]|\\.)+/}),Tr=Qt({name:"EscapedWord",pattern:/\\[#@]([_-\w]|\\.)+/}),gr=Qt({name:"Word",pattern:/([_-\w]|\\.)+/}),Rr=Qt({name:"Method",pattern:/@[_-\w]+/}),Ar=Qt({name:"Question",pattern:/\?/,longer_alt:gr}),Or=Qt({name:"Exclamation",pattern:/!/,longer_alt:gr}),Ir=Qt({name:"Equals",pattern:/=/,longer_alt:gr}),Nr=Qt({name:"Pound",pattern:/#/,longer_alt:Er}),Sr=Qt({name:"Dot",pattern:/\./,longer_alt:gr}),_r=(Qt({name:"RegexP",pattern:/\/.*?\//}),Qt({name:"Pipe",pattern:/\|/})),Lr=Qt({name:"Comma",pattern:/,/,longer_alt:gr}),kr=Qt({name:"Colon",pattern:/:/,longer_alt:gr}),Cr=Qt({name:"Plus",pattern:/\+/}),xr=Qt({name:"Star",pattern:/\*/}),Pr=Qt({name:"Zero",pattern:/0/,longer_alt:gr}),br=Qt({name:"PositiveInt",pattern:/[1-9]\d*/,longer_alt:gr}),Mr=Qt({name:"LParenthesis",pattern:/\(/}),wr=Qt({name:"RParenthesis",pattern:/\)/}),Ur=Qt({name:"LCurly",pattern:/\{/}),Fr=Qt({name:"RCurly",pattern:/\}/}),Dr=Qt({name:"NamedGroupBegin",pattern:/P/,longer_alt:gr}),Gr=Qt({name:"WhiteSpace",pattern:/\s+/,group:qt.SKIPPED}),Kr=[Dr,Br,Gr,yr,mr,Pr,br,Sr,Tr,gr,Rr,Er,Or,Ir,Nr,kr,Ar,Cr,xr,Lr,_r,Mr,wr,Ur,Fr],jr=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)}(r,t);var e=h(r);function r(){var t;n(this,r);var o=l(t=e.call(this,Kr));return o.RULE("matchStatement",(function(){var t={startOf:!1,prog:[],endOf:!1};return o.OPTION((function(){o.CONSUME(yr),t.startOf=!0})),t.startOf||(t.prog.push({code:sr,value:!1}),t.prog.push({code:ar,locs:[4,2]}),t.prog.push({code:tr}),t.prog.push({code:ir,loc:1}),t.prog.push({code:sr,value:!0})),t.groups=[],o.SUBRULE(o.valueStatement,{ARGS:[t.prog,t.groups]}),o.OPTION1((function(){o.CONSUME(mr),t.endOf=!0})),o.ACTION((function(){t.endOf&&t.prog.push({code:or}),t.prog.push({code:cr})})),t})),o.RULE("valueStatement",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=[];return o.AT_LEAST_ONE({DEF:function(){o.SUBRULE(o.value,{ARGS:[t,e,n]})}}),r})),o.RULE("value",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r={code:Jn};t.push(r);var i=t.length;o.OR([{ALT:function(){o.CONSUME(Sr),t.push({code:tr})}},{ALT:function(){t.push({code:er,value:o.CONSUME(gr).image})}},{ALT:function(){var e;t.push({code:er,value:null===(e=o.CONSUME(Tr).image)||void 0===e?void 0:e.substr(1)})}},{ALT:function(){var e;t.push({code:nr,value:null===(e=o.CONSUME(Er).image)||void 0===e?void 0:e.substr(1)})}},{ALT:function(){t.push({code:er,value:o.CONSUME(Pr).image})}},{ALT:function(){t.push({code:er,value:o.CONSUME(br).image})}},{ALT:function(){var e;t.push({code:rr,value:null===(e=o.CONSUME(Rr).image)||void 0===e?void 0:e.substr(1)})}},{ALT:function(){o.SUBRULE(o.group,{ARGS:[t,e,n]})}}]),o.OPTION((function(){var e,a=o.SUBRULE(o.valueModifier),s=a.type,c=a.greedy,u=a.min,l=a.max;switch(s){case"ZERO_OR_ONE":r.code=ar,r.locs=[i,t.length];break;case"ZERO_OR_MORE":t.push({code:ir,loc:i-1}),r.code=ar,r.locs=[i,t.length];break;case"ONE_OR_MORE":t.push({code:ar,locs:[i,t.length+1]}),c||t[t.length-1].locs.reverse();break;case"RANGE":var p=n.length;n.push(p),t.push({code:pr,varId:p});var h,f,d={code:hr,varId:p,value:null!=u?u:0,loc:i},v=null;if(u===l?0===u?(r.code=ir,r.loc=t.length):t.push(d):0===(null!=u?u:0)&&null!==l?(r.code=ar,r.locs=[i,t.length+1],v={code:fr,varId:p,value:l,locs:[i,t.length+1]},t.push(v)):null!==u&&null===l?(t.push(d),v={code:ar,locs:[i,t.length+1]},t.push(v)):(t.push(d),v={code:fr,varId:p,value:l,locs:[i,t.length+1]},t.push(v)),!c)null===(h=v)||void 0===h||null===(f=h.locs)||void 0===f||f.reverse()}c||(null==r||null===(e=r.locs)||void 0===e||e.reverse())}))})),o.RULE("valueModifier",(function(){var t={type:null,greedy:!0};return o.OR([{ALT:function(){o.CONSUME(Ar),t.type="ZERO_OR_ONE"}},{ALT:function(){o.CONSUME(xr),t.type="ZERO_OR_MORE"}},{ALT:function(){o.CONSUME(Cr),t.type="ONE_OR_MORE"}},{ALT:function(){var e=o.SUBRULE(o.rangeModifier),n=e.min,r=e.max;o.ACTION((function(){t.type="RANGE",t.min=n,t.max=r}))}}]),o.OPTION((function(){o.CONSUME1(Ar),o.ACTION((function(){t.greedy=!1}))})),t})),o.RULE("rangeModifier",(function(){var t={min:null,max:null};return o.CONSUME(Ur),o.OPTION((function(){o.OR([{ALT:function(){t.min=o.CONSUME(Pr).image}},{ALT:function(){t.min=o.CONSUME(br).image}}])})),t.max=t.min,o.OPTION1((function(){o.CONSUME(Lr),t.max=null,o.OPTION2((function(){t.max=o.CONSUME1(br).image}))})),o.ACTION((function(){t.min&&(t.min=parseInt(t.min)),t.max&&(t.max=parseInt(t.max));var e=t.min,n=t.max;if(e&&n&&e>n)throw new Error("Range min(".concat(e,") must be greater than max(").concat(n,")."));if(null===e&&null===n)throw new Error("Range min or max must be defined.")})),o.CONSUME(Fr),t})),o.RULE("group",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r={capture:!0,name:null,lookahead:!1,negative:!1};o.CONSUME(Mr),o.OPTION((function(){r=o.SUBRULE(o.groupModifier)}));var i=null;r.lookahead&&(r.capture=!1,i=t,t=[]);var a=e.length;r.capture&&(e.push(r),t.push({code:ur,id:a,name:r.name}));var s={code:ar,locs:[]};t.push(s);var c=[];o.AT_LEAST_ONE_SEP({SEP:_r,DEF:function(){s.locs.push(t.length),o.SUBRULE(o.valueStatement,{ARGS:[t,e,n]});var r={code:ir,loc:null};c.push(r),t.push(r)}}),1===s.locs.length&&(s.code=Jn,delete s.locs),t.pop();for(var u=0,l=c;u1&&void 0!==arguments[1]?arguments[1]:{},n=e.save,r=void 0===n||n,o=e.saved,i=void 0===o?[]:o,a=e.groups,c=void 0===a?{}:a,u=e.vars,l=void 0===u?{}:u,p=Object.values(c).reduce((function(t,e){return t[e.id]=s(s({},e),{},{saved:d(e.saved)}),t}),{});return{pc:t,save:r,saved:d(i),groups:p,vars:s({},l)}},Hr=function t(e,n,r){var o,i,a=e[r.pc];switch(a.code){case sr:r.save=a.value,t(e,n,Wr(r.pc+1,r));break;case Jn:t(e,n,Wr(r.pc+1,r));break;case ir:t(e,n,Wr(a.loc,r));break;case ar:var s,c=m(a.locs);try{for(c.s();!(s=c.n()).done;){var u=s.value;t(e,n,Wr(u,r))}}catch(t){c.e(t)}finally{c.f()}break;case ur:r.groups[a.id]={id:a.id,name:a.name,saved:[],open:!0},t(e,n,Wr(r.pc+1,r));break;case lr:r.groups[a.id].open=!1,t(e,n,Wr(r.pc+1,r));break;case pr:r.vars[a.varId]=(null!==(o=null===(i=r.vars)||void 0===i?void 0:i[a.varId])&&void 0!==o?o:0)+1,t(e,n,Wr(r.pc+1,r));break;case hr:r.vars[a.varId]0)throw new Xr(zr.errors);this.regex=e,this.prog=o.prog}return o(t,[{key:"exec",value:function(t){var e;switch(null==t||null===(e=t.isA)||void 0===e?void 0:e.toLowerCase()){case"doc":return this.execDoc(t);case"phrase":return this.execPhrase(t);default:throw new Error("Invalid type, must be Document or Phrase")}}},{key:"execDoc",value:function(t){var e=this;return t.buildFrom(t.list.map((function(t){return e.execPhrase(t)})).filter((function(t){return null!==t})))}},{key:"execPhrase",value:function(t){var e,n=function t(e,n){var r,o,i,a,s,c=[],u=[],l=!1,p={},h=[],v=Symbol("END");n=[].concat(d(n),[v]),Hr(e,c,Wr(0));for(var y=0;y arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +/* + 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... + */ +function isEmpty(arr) { + return arr && arr.length === 0; +} +function keys(obj) { + if (obj === undefined || obj === null) { + return []; + } + + return Object.keys(obj); +} +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; +} +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; +} +function map(arr, callback) { + var result = []; + + for (var idx = 0; idx < arr.length; idx++) { + result.push(callback.call(null, arr[idx], idx)); + } + + return result; +} +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; +} +function first(arr) { + return isEmpty(arr) ? undefined : arr[0]; +} +function last(arr) { + var len = arr && arr.length; + return len ? arr[len - 1] : undefined; +} +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"); + } +} +function isString(item) { + return typeof item === "string"; +} +function isUndefined(item) { + return item === undefined; +} +function isFunction(item) { + return item instanceof Function; +} +function drop(arr, howMuch) { + if (howMuch === void 0) { + howMuch = 1; + } + + return arr.slice(howMuch, arr.length); +} +function dropRight(arr, howMuch) { + if (howMuch === void 0) { + howMuch = 1; + } + + return arr.slice(0, arr.length - howMuch); +} +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; +} +function reject(arr, predicate) { + return filter(arr, function (item) { + return !predicate(item); + }); +} +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; +} +function has(obj, prop) { + if (isObject(obj)) { + return obj.hasOwnProperty(prop); + } + + return false; +} +function contains(arr, item) { + return find(arr, function (currItem) { + return currItem === item; + }) !== undefined ? true : false; +} +/** + * shallow clone + */ + +function cloneArr(arr) { + var newArr = []; + + for (var i = 0; i < arr.length; i++) { + newArr.push(arr[i]); + } + + return newArr; +} +/** + * 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; +} +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; +} +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; +} +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; +} +function compact(arr) { + return reject(arr, function (item) { + return item === null || item === undefined; + }); +} +function uniq(arr, identity) { + if (identity === void 0) { + identity = function identity(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); + } + }, []); +} +function isArray(obj) { + return Array.isArray(obj); +} +function isRegExp(obj) { + return obj instanceof RegExp; +} +function isObject(obj) { + return obj instanceof Object; +} +function every(arr, predicate) { + for (var i = 0; i < arr.length; i++) { + if (!predicate(arr[i], i)) { + return false; + } + } + + return true; +} +function difference(arr, values) { + return reject(arr, function (item) { + return contains(values, item); + }); +} +function some(arr, predicate) { + for (var i = 0; i < arr.length; i++) { + if (predicate(arr[i])) { + return true; + } + } + + return false; +} +function indexOf(arr, value) { + for (var i = 0; i < arr.length; i++) { + if (arr[i] === value) { + return i; + } + } + + return -1; +} +/** + * 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; +} +/** + * 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]; + 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; +} +function defaults() { + var sources = []; + + for (var _i = 0; _i < arguments.length; _i++) { + sources[_i] = arguments[_i]; + } + + return assignNoOverwrite.apply(null, [{}].concat(sources)); +} +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; +} +/** + * 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; +} +function NOOP() {} +function IDENTITY(item) { + return item; +} +/** + * 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; +} +function PRINT_ERROR(msg) { + /* istanbul ignore else - can't override global.console in node.js */ + if (console && console.error) { + console.error("Error: " + msg); + } +} +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); + } +} +function isES2015MapSupported() { + return typeof Map === "function"; +} +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]; + } + }); + }); +} // 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) +} +function peek(arr) { + return arr[arr.length - 1]; +} +/* 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 + }; +} + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function createCommonjsModule(fn, basedir, module) { + return module = { + path: basedir, + exports: {}, + require: function (path, base) { + return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); + } + }, fn(module, module.exports), module.exports; +} + +function commonjsRequire () { + throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); +} + +var regexpToAst = createCommonjsModule(function (module) { + + (function (root, factory) { + // istanbul ignore next + if ( module.exports) { + module.exports = factory(); + } else { + // istanbul ignore next + root.regexpToAst = factory(); + } + })(typeof self !== "undefined" ? // istanbul ignore next + self : commonjsGlobal, 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", + loc: { + begin: this.idx, + end: input.length + }, + 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, + loc: this.loc(0) + }; + }; + + RegExpParser.prototype.disjunction = function () { + var alts = []; + var begin = this.idx; + alts.push(this.alternative()); + + while (this.peekChar() === "|") { + this.consumeChar("|"); + alts.push(this.alternative()); + } + + return { + type: "Disjunction", + value: alts, + loc: this.loc(begin) + }; + }; + + RegExpParser.prototype.alternative = function () { + var terms = []; + var begin = this.idx; + + while (this.isTerm()) { + terms.push(this.term()); + } + + return { + type: "Alternative", + value: terms, + loc: this.loc(begin) + }; + }; + + RegExpParser.prototype.term = function () { + if (this.isAssertion()) { + return this.assertion(); + } else { + return this.atom(); + } + }; + + RegExpParser.prototype.assertion = function () { + var begin = this.idx; + + switch (this.popChar()) { + case "^": + return { + type: "StartAnchor", + loc: this.loc(begin) + }; + + case "$": + return { + type: "EndAnchor", + loc: this.loc(begin) + }; + // '\b' or '\B' + + case "\\": + switch (this.popChar()) { + case "b": + return { + type: "WordBoundary", + loc: this.loc(begin) + }; + + case "B": + return { + type: "NonWordBoundary", + loc: this.loc(begin) + }; + } // 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, + loc: this.loc(begin) + }; + } // istanbul ignore next + + + ASSERT_NEVER_REACH_HERE(); + }; + + RegExpParser.prototype.quantifier = function (isBacktracking) { + var range; + var begin = this.idx; + + 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"; + range.loc = this.loc(begin); + return range; + }; + + RegExpParser.prototype.atom = function () { + var atom; + var begin = this.idx; + + 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); + atom.loc = this.loc(begin); + + 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("\b") + }; + + 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++; + }; + + RegExpParser.prototype.loc = function (begin) { + return { + begin: begin, + end: this.idx + }; + }; // consts and utilities + + + var hexDigitPattern = /[0-9a-fA-F]/; + var decimalPattern = /[0-9]/; + var decimalPatternNoZero = /[1-9]/; + + function cc(_char2) { + return _char2.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("\xA0"), 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.5.0" + }; + }); +}); + +var regExpAstCache = {}; +var regExpParser = new regexpToAst.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; + } +} +function clearRegExpParserCache() { + regExpAstCache = {}; +} + +var __extends = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; +}(); +var complementErrorMessage = "Complement Sets are not supported for first char optimization"; +var failedOptimizationPrefixMsg = 'Unable to use "first char" lexer optimizations:\n'; +function getOptimizedStartCodesIndices(regExp, ensureOptimizations) { + if (ensureOptimizations === void 0) { + ensureOptimizations = false; + } + + try { + var ast = 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) { + PRINT_WARNING("" + 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."; + } + + PRINT_ERROR(failedOptimizationPrefixMsg + "\n" + ("\tFailed parsing: < " + regExp.toString() + " >\n") + ("\tUsing the regexp-to-ast library version: " + regexpToAst.VERSION + "\n") + "\tPlease open an issue at: https://github.com/bd82/regexp-to-ast/issues" + msgSuffix); + } + } + + return []; +} +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); + } + + 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 < minOptimizationVal; rangeCode++) { + addOptimizedIdxToResult(rangeCode, result, ignoreCase); + } // Less common charCode where we optimize for faster init time, by using larger "buckets" + + + if (range.to >= minOptimizationVal) { + var minUnOptVal = range.from >= minOptimizationVal ? range.from : minOptimizationVal; + var maxUnOptVal = range.to; + var minOptIdx = charCodeToOptimizedIndex(minUnOptVal); + var maxOptIdx = 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 values(result); +} + +function addOptimizedIdxToResult(code, result, ignoreCase) { + var optimizedCharIdx = 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 = charCodeToOptimizedIndex(upperChar.charCodeAt(0)); + result[optimizedCharIdx] = optimizedCharIdx; + } else { + var lowerChar = _char.toLowerCase(); + + if (lowerChar !== _char) { + var optimizedCharIdx = charCodeToOptimizedIndex(lowerChar.charCodeAt(0)); + result[optimizedCharIdx] = optimizedCharIdx; + } + } +} + +function findCode(setNode, targetCharCodes) { + return find(setNode.value, function (codeOrRange) { + if (typeof codeOrRange === "number") { + return contains(targetCharCodes, codeOrRange); + } else { + // range + var range_1 = codeOrRange; + return 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 isArray(ast.value) ? 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 (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; +}(regexpToAst.BaseRegExpVisitor); + +function canMatchCharCode(charCodes, pattern) { + if (pattern instanceof RegExp) { + var ast = getRegExpAst(pattern); + var charCodeFinder = new CharCodeFinder(charCodes); + charCodeFinder.visit(ast); + return charCodeFinder.found; + } else { + return find(pattern, function (_char2) { + return contains(charCodes, _char2.charCodeAt(0)); + }) !== undefined; + } +} + +var __extends$1 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; +}(); +var PATTERN = "PATTERN"; +var DEFAULT_MODE = "defaultMode"; +var MODES = "modes"; +var SUPPORT_STICKY = typeof new RegExp("(?:)").sticky === "boolean"; +function analyzeTokenTypes(tokenTypes, options) { + options = defaults(options, { + useSticky: SUPPORT_STICKY, + debug: false, + safeMode: false, + positionTracking: "full", + lineTerminatorCharacters: ["\r", "\n"], + tracer: function tracer(msg, action) { + return action(); + } + }); + var tracer = options.tracer; + tracer("initCharCodeToOptimizedIndexMap", function () { + initCharCodeToOptimizedIndexMap(); + }); + var onlyRelevantTypes; + tracer("Reject Lexer.NA", function () { + onlyRelevantTypes = reject(tokenTypes, function (currType) { + return currType[PATTERN] === Lexer.NA; + }); + }); + var hasCustom = false; + var allTransformedPatterns; + tracer("Transform Patterns", function () { + hasCustom = false; + allTransformedPatterns = map(onlyRelevantTypes, function (currType) { + var currPattern = currType[PATTERN]; + /* istanbul ignore else */ + + if (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 !== "." && !currPattern.ignoreCase) { + return regExpSource; + } else if (regExpSource.length === 2 && regExpSource[0] === "\\" && // not a meta character + !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 (isFunction(currPattern)) { + hasCustom = true; // CustomPatternMatcherFunc - custom patterns do not require any transformations, only wrapping in a RegExp Like object + + return { + exec: currPattern + }; + } else if (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 = map(onlyRelevantTypes, function (currType) { + return currType.tokenTypeIdx; + }); + patternIdxToGroup = map(onlyRelevantTypes, function (clazz) { + var groupName = clazz.GROUP; + /* istanbul ignore next */ + + if (groupName === Lexer.SKIPPED) { + return undefined; + } else if (isString(groupName)) { + return groupName; + } else if (isUndefined(groupName)) { + return false; + } else { + throw Error("non exhaustive match"); + } + }); + patternIdxToLongerAltIdx = map(onlyRelevantTypes, function (clazz) { + var longerAltType = clazz.LONGER_ALT; + + if (longerAltType) { + var longerAltIdx = indexOf(onlyRelevantTypes, longerAltType); + return longerAltIdx; + } + }); + patternIdxToPushMode = map(onlyRelevantTypes, function (clazz) { + return clazz.PUSH_MODE; + }); + patternIdxToPopMode = map(onlyRelevantTypes, function (clazz) { + return has(clazz, "POP_MODE"); + }); + }); + var patternIdxToCanLineTerminator; + tracer("Line Terminator Handling", function () { + var lineTerminatorCharCodes = getCharCodes(options.lineTerminatorCharacters); + patternIdxToCanLineTerminator = map(onlyRelevantTypes, function (tokType) { + return false; + }); + + if (options.positionTracking !== "onlyOffset") { + patternIdxToCanLineTerminator = map(onlyRelevantTypes, function (tokType) { + if (has(tokType, "LINE_BREAKS")) { + return tokType.LINE_BREAKS; + } else { + if (checkLineBreaksIssues(tokType, lineTerminatorCharCodes) === false) { + return canMatchCharCode(lineTerminatorCharCodes, tokType.PATTERN); + } + } + }); + } + }); + var patternIdxToIsCustom; + var patternIdxToShort; + var emptyGroups; + var patternIdxToConfig; + tracer("Misc Mapping #2", function () { + patternIdxToIsCustom = map(onlyRelevantTypes, isCustomPattern); + patternIdxToShort = map(allTransformedPatterns, isShortPattern); + emptyGroups = reduce(onlyRelevantTypes, function (acc, clazz) { + var groupName = clazz.GROUP; + + if (isString(groupName) && !(groupName === Lexer.SKIPPED)) { + acc[groupName] = []; + } + + return acc; + }, {}); + patternIdxToConfig = 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 = 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 (isArray(currTokType.START_CHARS_HINT)) { + var lastOptimizedIdx_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 + + /* istanbul ignore else */ + // - Difficult to check this scenario effects as it is only a performance + // optimization that does not change correctness + + if (lastOptimizedIdx_1 !== currOptimizedIdx) { + lastOptimizedIdx_1 = currOptimizedIdx; + addToMapOfArrays(result, currOptimizedIdx, patternIdxToConfig[idx]); + } + }); + } else if (isRegExp(currTokType.PATTERN)) { + if (currTokType.PATTERN.unicode) { + canBeOptimized = false; + + if (options.ensureOptimizations) { + PRINT_ERROR("" + 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 = 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 (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; + } + + forEach(optimizedCodes, function (code) { + addToMapOfArrays(result, code, patternIdxToConfig[idx]); + }); + } + } else { + if (options.ensureOptimizations) { + PRINT_ERROR("" + 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 = packArray(charCodeToPatternIdxToConfig); + }); + return { + emptyGroups: emptyGroups, + patternIdxToConfig: patternIdxToConfig, + charCodeToPatternIdxToConfig: charCodeToPatternIdxToConfig, + hasCustom: hasCustom, + canBeOptimized: canBeOptimized + }; +} +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; +} + +function validateRegExpPattern(tokenTypes) { + var errors = []; + var withRegExpPatterns = filter(tokenTypes, function (currTokType) { + return 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 = filter(tokenTypes, function (currType) { + return !has(currType, PATTERN); + }); + var errors = map(tokenTypesWithMissingPattern, function (currType) { + return { + message: "Token Type: ->" + currType.name + "<- missing static 'PATTERN' property", + type: LexerDefinitionErrorType.MISSING_PATTERN, + tokenTypes: [currType] + }; + }); + var valid = difference(tokenTypes, tokenTypesWithMissingPattern); + return { + errors: errors, + valid: valid + }; +} +function findInvalidPatterns(tokenTypes) { + var tokenTypesWithInvalidPattern = filter(tokenTypes, function (currType) { + var pattern = currType[PATTERN]; + return !isRegExp(pattern) && !isFunction(pattern) && !has(pattern, "exec") && !isString(pattern); + }); + var errors = 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: LexerDefinitionErrorType.INVALID_PATTERN, + tokenTypes: [currType] + }; + }); + var valid = difference(tokenTypes, tokenTypesWithInvalidPattern); + return { + errors: errors, + valid: valid + }; +} +var end_of_input = /[^\\][\$]/; +function findEndOfInputAnchor(tokenTypes) { + var EndAnchorFinder = + /** @class */ + function (_super) { + __extends$1(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; + }(regexpToAst.BaseRegExpVisitor); + + var invalidRegex = filter(tokenTypes, function (currType) { + var pattern = currType[PATTERN]; + + try { + var regexpAst = 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 = 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: LexerDefinitionErrorType.EOI_ANCHOR_FOUND, + tokenTypes: [currType] + }; + }); + return errors; +} +function findEmptyMatchRegExps(tokenTypes) { + var matchesEmptyString = filter(tokenTypes, function (currType) { + var pattern = currType[PATTERN]; + return pattern.test(""); + }); + var errors = map(matchesEmptyString, function (currType) { + return { + message: "Token Type: ->" + currType.name + "<- static 'PATTERN' must not match an empty string", + type: LexerDefinitionErrorType.EMPTY_MATCH_PATTERN, + tokenTypes: [currType] + }; + }); + return errors; +} +var start_of_input = /[^\\[][\^]|^\^/; +function findStartOfInputAnchor(tokenTypes) { + var StartAnchorFinder = + /** @class */ + function (_super) { + __extends$1(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; + }(regexpToAst.BaseRegExpVisitor); + + var invalidRegex = filter(tokenTypes, function (currType) { + var pattern = currType[PATTERN]; + + try { + var regexpAst = 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 = 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: LexerDefinitionErrorType.SOI_ANCHOR_FOUND, + tokenTypes: [currType] + }; + }); + return errors; +} +function findUnsupportedFlags(tokenTypes) { + var invalidFlags = filter(tokenTypes, function (currType) { + var pattern = currType[PATTERN]; + return pattern instanceof RegExp && (pattern.multiline || pattern.global); + }); + var errors = map(invalidFlags, function (currType) { + return { + message: "Token Type: ->" + currType.name + "<- static 'PATTERN' may NOT contain global('g') or multiline('m')", + type: LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND, + tokenTypes: [currType] + }; + }); + return errors; +} // This can only test for identical duplicate RegExps, not semantically equivalent ones. + +function findDuplicatePatterns(tokenTypes) { + var found = []; + var identicalPatterns = map(tokenTypes, function (outerType) { + return reduce(tokenTypes, function (result, innerType) { + if (outerType.PATTERN.source === innerType.PATTERN.source && !contains(found, innerType) && innerType.PATTERN !== 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 = compact(identicalPatterns); + var duplicatePatterns = filter(identicalPatterns, function (currIdenticalSet) { + return currIdenticalSet.length > 1; + }); + var errors = map(duplicatePatterns, function (setOfIdentical) { + var tokenTypeNames = map(setOfIdentical, function (currType) { + return currType.name; + }); + var dupPatternSrc = first(setOfIdentical).PATTERN; + return { + message: "The same RegExp pattern ->" + dupPatternSrc + "<-" + ("has been used in all of the following Token Types: " + tokenTypeNames.join(", ") + " <-"), + type: LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND, + tokenTypes: setOfIdentical + }; + }); + return errors; +} +function findInvalidGroupType(tokenTypes) { + var invalidTypes = filter(tokenTypes, function (clazz) { + if (!has(clazz, "GROUP")) { + return false; + } + + var group = clazz.GROUP; + return group !== Lexer.SKIPPED && group !== Lexer.NA && !isString(group); + }); + var errors = map(invalidTypes, function (currType) { + return { + message: "Token Type: ->" + currType.name + "<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String", + type: LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND, + tokenTypes: [currType] + }; + }); + return errors; +} +function findModesThatDoNotExist(tokenTypes, validModes) { + var invalidModes = filter(tokenTypes, function (clazz) { + return clazz.PUSH_MODE !== undefined && !contains(validModes, clazz.PUSH_MODE); + }); + var errors = 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: LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST, + tokenTypes: [tokType] + }; + }); + return errors; +} +function findUnreachablePatterns(tokenTypes) { + var errors = []; + var canBeTested = reduce(tokenTypes, function (result, tokType, idx) { + var pattern = tokType.PATTERN; + + if (pattern === Lexer.NA) { + return result; + } // a more comprehensive validation for all forms of regExps would require + // deeper regExp analysis capabilities + + + if (isString(pattern)) { + result.push({ + str: pattern, + idx: idx, + tokenType: tokType + }); + } else if (isRegExp(pattern) && noMetaChar(pattern)) { + result.push({ + str: pattern.source, + idx: idx, + tokenType: tokType + }); + } + + return result; + }, []); + forEach(tokenTypes, function (tokType, testIdx) { + 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: LexerDefinitionErrorType.UNREACHABLE_PATTERN, + tokenTypes: [tokType, tokenType] + }); + } + }); + }); + return errors; +} + +function testTokenType(str, pattern) { + /* istanbul ignore else */ + if (isRegExp(pattern)) { + var regExpArray = pattern.exec(str); + return regExpArray !== null && regExpArray.index === 0; + } else if (isFunction(pattern)) { + // maintain the API of custom patterns + return pattern(str, 0, [], {}); + } else if (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 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); +} +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); +} +function performRuntimeChecks(lexerDefinition, trackLines, lineTerminatorCharacters) { + var errors = []; // some run time checks to help the end users. + + if (!has(lexerDefinition, DEFAULT_MODE)) { + errors.push({ + message: "A MultiMode Lexer cannot be initialized without a <" + DEFAULT_MODE + "> property in its definition\n", + type: LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE + }); + } + + if (!has(lexerDefinition, MODES)) { + errors.push({ + message: "A MultiMode Lexer cannot be initialized without a <" + MODES + "> property in its definition\n", + type: LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY + }); + } + + if (has(lexerDefinition, MODES) && has(lexerDefinition, DEFAULT_MODE) && !has(lexerDefinition.modes, lexerDefinition.defaultMode)) { + errors.push({ + message: "A MultiMode Lexer cannot be initialized with a " + DEFAULT_MODE + ": <" + lexerDefinition.defaultMode + ">" + "which does not exist\n", + type: LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST + }); + } + + if (has(lexerDefinition, MODES)) { + forEach(lexerDefinition.modes, function (currModeValue, currModeName) { + forEach(currModeValue, function (currTokType, currIdx) { + if (isUndefined(currTokType)) { + errors.push({ + message: "A Lexer cannot be initialized using an undefined Token Type. Mode:" + ("<" + currModeName + "> at index: <" + currIdx + ">\n"), + type: LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED + }); + } + }); + }); + } + + return errors; +} +function performWarningRuntimeChecks(lexerDefinition, trackLines, lineTerminatorCharacters) { + var warnings = []; + var hasAnyLineBreak = false; + var allTokenTypes = compact(flatten(mapValues(lexerDefinition.modes, function (tokTypes) { + return tokTypes; + }))); + var concreteTokenTypes = reject(allTokenTypes, function (currType) { + return currType[PATTERN] === Lexer.NA; + }); + var terminatorCharCodes = getCharCodes(lineTerminatorCharacters); + + if (trackLines) { + 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 (has(tokType, "LINE_BREAKS")) { + if (tokType.LINE_BREAKS === true) { + hasAnyLineBreak = true; + } + } else { + if (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: LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS + }); + } + + return warnings; +} +function cloneEmptyGroups(emptyGroups) { + var clonedResult = {}; + var groupKeys = keys(emptyGroups); + forEach(groupKeys, function (currKey) { + var currGroupValue = emptyGroups[currKey]; + /* istanbul ignore else */ + + if (isArray(currGroupValue)) { + clonedResult[currKey] = []; + } else { + throw Error("non exhaustive match"); + } + }); + return clonedResult; +} // TODO: refactor to avoid duplication + +function isCustomPattern(tokenType) { + var pattern = tokenType.PATTERN; + /* istanbul ignore else */ + + if (isRegExp(pattern)) { + return false; + } else if (isFunction(pattern)) { + // CustomPatternMatcherFunc - custom patterns do not require any transformations, only wrapping in a RegExp Like object + return true; + } else if (has(pattern, "exec")) { + // ICustomPattern + return true; + } else if (isString(pattern)) { + return false; + } else { + throw Error("non exhaustive match"); + } +} +function isShortPattern(pattern) { + if (isString(pattern) && pattern.length === 1) { + return pattern.charCodeAt(0); + } else { + return false; + } +} +/** + * Faster than using a RegExp for default newline detection during lexing. + */ + +var LineTerminatorOptimizedTester = { + // implements /\n|\r\n?/g.test + test: function test(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 (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 (isRegExp(tokType.PATTERN)) { + try { + canMatchCharCode(lineTerminatorCharCodes, tokType.PATTERN); + } catch (e) { + /* istanbul ignore next - to test this we would have to mock to throw an error */ + return { + issue: LexerDefinitionErrorType.IDENTIFY_TERMINATOR, + errMsg: e.message + }; + } + + return false; + } else if (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: LexerDefinitionErrorType.CUSTOM_LINE_BREAK + }; + } else { + throw Error("non exhaustive match"); + } + } +} + +function buildLineBreakIssueMessage(tokType, details) { + /* istanbul ignore else */ + if (details.issue === 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 === 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"); + } +} + +function getCharCodes(charsOrCodes) { + var charCodes = map(charsOrCodes, function (numOrString) { + if (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); + } +} + +var 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 < minOptimizationVal ? charCode : charCodeToOptimizedIdxMap[charCode]; +} +/** + * 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 (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 */ + } + } +} + +function tokenStructuredMatcher(tokInstance, tokConstructor) { + var instanceType = tokInstance.tokenTypeIdx; + + if (instanceType === tokConstructor.tokenTypeIdx) { + return true; + } else { + return tokConstructor.isParent === true && tokConstructor.categoryMatchesMap[instanceType] === true; + } +} // 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; +} +var tokenShortNameIdx = 1; +var 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); + forEach(tokenTypesAndParents, function (tokType) { + tokType.isParent = tokType.categoryMatches.length > 0; + }); +} +function expandCategories(tokenTypes) { + var result = cloneArr(tokenTypes); + var categories = tokenTypes; + var searching = true; + + while (searching) { + categories = compact(flatten(map(categories, function (currTokType) { + return currTokType.CATEGORIES; + }))); + var newCategories = difference(categories, result); + result = result.concat(newCategories); + + if (isEmpty(newCategories)) { + searching = false; + } else { + categories = newCategories; + } + } + + return result; +} +function assignTokenDefaultProps(tokenTypes) { + forEach(tokenTypes, function (currTokType) { + if (!hasShortKeyProperty(currTokType)) { + tokenIdxToClass[tokenShortNameIdx] = currTokType; + currTokType.tokenTypeIdx = tokenShortNameIdx++; + } // CATEGORIES? : TokenType | TokenType[] + + + if (hasCategoriesProperty(currTokType) && !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 = {}; + } + }); +} +function assignCategoriesTokensProp(tokenTypes) { + forEach(tokenTypes, function (currTokType) { + // avoid duplications + currTokType.categoryMatches = []; + forEach(currTokType.categoryMatchesMap, function (val, key) { + currTokType.categoryMatches.push(tokenIdxToClass[key].tokenTypeIdx); + }); + }); +} +function assignCategoriesMapProp(tokenTypes) { + forEach(tokenTypes, function (currTokType) { + singleAssignCategoriesToksMap([], currTokType); + }); +} +function singleAssignCategoriesToksMap(path, nextNode) { + forEach(path, function (pathNode) { + nextNode.categoryMatchesMap[pathNode.tokenTypeIdx] = true; + }); + forEach(nextNode.CATEGORIES, function (nextCategory) { + var newPath = path.concat(nextNode); // avoids infinite loops due to cyclic categories. + + if (!contains(newPath, nextCategory)) { + singleAssignCategoriesToksMap(newPath, nextCategory); + } + }); +} +function hasShortKeyProperty(tokType) { + return has(tokType, "tokenTypeIdx"); +} +function hasCategoriesProperty(tokType) { + return has(tokType, "CATEGORIES"); +} +function hasExtendingTokensTypesProperty(tokType) { + return has(tokType, "categoryMatches"); +} +function hasExtendingTokensTypesMapProperty(tokType) { + return has(tokType, "categoryMatchesMap"); +} +function isTokenType(tokType) { + return has(tokType, "tokenTypeIdx"); +} + +var defaultLexerErrorProvider = { + buildUnableToPopLexerModeMessage: function buildUnableToPopLexerModeMessage(token) { + return "Unable to pop Lexer Mode after encountering Token ->" + token.image + "<- The Mode Stack is empty"; + }, + buildUnexpectedCharactersMessage: function buildUnexpectedCharactersMessage(fullText, startOffset, length, line, column) { + return "unexpected character: ->" + fullText.charAt(startOffset) + "<- at offset: " + startOffset + "," + (" skipped " + length + " characters."); + } +}; + +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 || (LexerDefinitionErrorType = {})); + +var DEFAULT_LEXER_CONFIG = { + deferDefinitionErrorsHandling: false, + positionTracking: "full", + lineTerminatorsPattern: /\n|\r\n?/g, + lineTerminatorCharacters: ["\n", "\r"], + ensureOptimizations: false, + safeMode: false, + errorMessageProvider: 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 = 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 = 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 (isArray(lexerDefinition)) { + actualDefinition = { + modes: {} + }; + actualDefinition.modes[DEFAULT_MODE] = cloneArr(lexerDefinition); + actualDefinition[DEFAULT_MODE] = DEFAULT_MODE; + } else { + // no conversion needed, input should already be a IMultiModeLexerDefinition + hasOnlySingleMode = false; + actualDefinition = cloneObj(lexerDefinition); + } + }); + + if (_this.config.skipValidations === false) { + _this.TRACE_INIT("performRuntimeChecks", function () { + _this.lexerDefinitionErrors = _this.lexerDefinitionErrors.concat(performRuntimeChecks(actualDefinition, _this.trackStartLines, _this.config.lineTerminatorCharacters)); + }); + + _this.TRACE_INIT("performWarningRuntimeChecks", function () { + _this.lexerDefinitionWarning = _this.lexerDefinitionWarning.concat(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. + + forEach(actualDefinition.modes, function (currModeValue, currModeName) { + actualDefinition.modes[currModeName] = reject(currModeValue, function (currTokType) { + return isUndefined(currTokType); + }); + }); + var allModeNames = keys(actualDefinition.modes); + 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(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 (isEmpty(_this.lexerDefinitionErrors)) { + augmentTokenTypes(currModDef); + var currAnalyzeResult_1; + + _this.TRACE_INIT("analyzeTokenTypes", function () { + currAnalyzeResult_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 = merge(_this.emptyGroups, currAnalyzeResult_1.emptyGroups); + _this.hasCustom = currAnalyzeResult_1.hasCustom || _this.hasCustom; + _this.canModeBeOptimized[currModName] = currAnalyzeResult_1.canBeOptimized; + } + }); + }); + _this.defaultMode = actualDefinition.defaultMode; + + if (!isEmpty(_this.lexerDefinitionErrors) && !_this.config.deferDefinitionErrorsHandling) { + var allErrMessages = 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 + + + forEach(_this.lexerDefinitionWarning, function (warningDescriptor) { + 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 (SUPPORT_STICKY) { + _this.chopInput = IDENTITY; + _this.match = _this.matchWithTest; + } else { + _this.updateLastIndex = NOOP; + _this.match = _this.matchWithExec; + } + + if (hasOnlySingleMode) { + _this.handleModes = NOOP; + } + + if (_this.trackStartLines === false) { + _this.computeNewColumn = IDENTITY; + } + + if (_this.trackEndLines === false) { + _this.updateTokenEndLineColumnLocation = 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 = reduce(_this.canModeBeOptimized, function (cannotBeOptimized, canBeOptimized, modeName) { + if (canBeOptimized === false) { + cannotBeOptimized.push(modeName); + } + + return cannotBeOptimized; + }, []); + + if (config.ensureOptimizations && !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 () { + clearRegExpParserCache(); + }); + + _this.TRACE_INIT("toFastProperties", function () { + toFastProperties(_this); + }); + }); + } + + Lexer.prototype.tokenize = function (text, initialMode) { + if (initialMode === void 0) { + initialMode = this.defaultMode; + } + + if (!isEmpty(this.lexerDefinitionErrors)) { + var allErrMessages = 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 = 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 = charCodeToOptimizedIndex(charCode); + var possiblePatterns = currCharCodeToPatternIdxToConfig[optimizedCharIdx]; + + if (possiblePatterns === undefined) { + return emptyArray; + } else { + return possiblePatterns; + } + } + + var pop_mode = function pop_mode(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 = 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 = 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; +}(); + +function tokenLabel(tokType) { + if (hasTokenLabel(tokType)) { + return tokType.LABEL; + } else { + return tokType.name; + } +} +function hasTokenLabel(obj) { + return isString(obj.LABEL) && obj.LABEL !== ""; +} +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); +} + +function createTokenInternal(config) { + var pattern = config.pattern; + var tokenType = {}; + tokenType.name = config.name; + + if (!isUndefined(pattern)) { + tokenType.PATTERN = pattern; + } + + if (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 (has(config, CATEGORIES)) { + // casting to ANY as this will be fixed inside `augmentTokenTypes`` + tokenType.CATEGORIES = config[CATEGORIES]; + } + + augmentTokenTypes([tokenType]); + + if (has(config, LABEL)) { + tokenType.LABEL = config[LABEL]; + } + + if (has(config, GROUP)) { + tokenType.GROUP = config[GROUP]; + } + + if (has(config, POP_MODE)) { + tokenType.POP_MODE = config[POP_MODE]; + } + + if (has(config, PUSH_MODE)) { + tokenType.PUSH_MODE = config[PUSH_MODE]; + } + + if (has(config, LONGER_ALT)) { + tokenType.LONGER_ALT = config[LONGER_ALT]; + } + + if (has(config, LINE_BREAKS)) { + tokenType.LINE_BREAKS = config[LINE_BREAKS]; + } + + if (has(config, START_CHARS_HINT)) { + tokenType.START_CHARS_HINT = config[START_CHARS_HINT]; + } + + return tokenType; +} + +var EOF = createToken({ + name: "EOF", + pattern: Lexer.NA +}); +augmentTokenTypes([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 + }; +} + +var __extends$2 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; +}(); + +var AbstractProduction = +/** @class */ +function () { + function AbstractProduction(definition) { + this.definition = definition; + } + + AbstractProduction.prototype.accept = function (visitor) { + visitor.visit(this); + forEach(this.definition, function (prod) { + prod.accept(visitor); + }); + }; + + return AbstractProduction; +}(); + +var NonTerminal = +/** @class */ +function (_super) { + __extends$2(NonTerminal, _super); + + function NonTerminal(options) { + var _this = _super.call(this, []) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + Object.defineProperty(NonTerminal.prototype, "definition", { + get: function get() { + if (this.referencedRule !== undefined) { + return this.referencedRule.definition; + } + + return []; + }, + set: function set(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); + +var Rule = +/** @class */ +function (_super) { + __extends$2(Rule, _super); + + function Rule(options) { + var _this = _super.call(this, options.definition) || this; + + _this.orgText = ""; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return Rule; +}(AbstractProduction); + +var Alternative = +/** @class */ +function (_super) { + __extends$2(Alternative, _super); + + function Alternative(options) { + var _this = _super.call(this, options.definition) || this; + + _this.ignoreAmbiguities = false; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return Alternative; +}(AbstractProduction); + +var Option = +/** @class */ +function (_super) { + __extends$2(Option, _super); + + function Option(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return Option; +}(AbstractProduction); + +var RepetitionMandatory = +/** @class */ +function (_super) { + __extends$2(RepetitionMandatory, _super); + + function RepetitionMandatory(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return RepetitionMandatory; +}(AbstractProduction); + +var RepetitionMandatoryWithSeparator = +/** @class */ +function (_super) { + __extends$2(RepetitionMandatoryWithSeparator, _super); + + function RepetitionMandatoryWithSeparator(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return RepetitionMandatoryWithSeparator; +}(AbstractProduction); + +var Repetition = +/** @class */ +function (_super) { + __extends$2(Repetition, _super); + + function Repetition(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return Repetition; +}(AbstractProduction); + +var RepetitionWithSeparator = +/** @class */ +function (_super) { + __extends$2(RepetitionWithSeparator, _super); + + function RepetitionWithSeparator(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return RepetitionWithSeparator; +}(AbstractProduction); + +var Alternation = +/** @class */ +function (_super) { + __extends$2(Alternation, _super); + + function Alternation(options) { + var _this = _super.call(this, options.definition) || this; + + _this.idx = 1; + _this.ignoreAmbiguities = false; + _this.hasPredicates = false; + assign(_this, pick(options, function (v) { + return v !== undefined; + })); + return _this; + } + + return Alternation; +}(AbstractProduction); + +var Terminal = +/** @class */ +function () { + function Terminal(options) { + this.idx = 1; + assign(this, pick(options, function (v) { + return v !== undefined; + })); + } + + Terminal.prototype.accept = function (visitor) { + visitor.visit(this); + }; + + return Terminal; +}(); +function serializeGrammar(topRules) { + return map(topRules, serializeProduction); +} +function serializeProduction(node) { + function convertDefinition(definition) { + return map(definition, serializeProduction); + } + /* istanbul ignore else */ + + + if (node instanceof NonTerminal) { + return { + type: "NonTerminal", + name: node.nonTerminalName, + idx: node.idx + }; + } else if (node instanceof Alternative) { + return { + type: "Alternative", + 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", + idx: node.idx, + definition: convertDefinition(node.definition) + }; + } else if (node instanceof RepetitionMandatoryWithSeparator) { + return { + type: "RepetitionMandatoryWithSeparator", + idx: node.idx, + separator: serializeProduction(new Terminal({ + terminalType: node.separator + })), + definition: convertDefinition(node.definition) + }; + } else if (node instanceof RepetitionWithSeparator) { + return { + type: "RepetitionWithSeparator", + idx: node.idx, + separator: serializeProduction(new Terminal({ + terminalType: node.separator + })), + definition: convertDefinition(node.definition) + }; + } else if (node instanceof Repetition) { + return { + type: "Repetition", + idx: node.idx, + definition: convertDefinition(node.definition) + }; + } else if (node instanceof Alternation) { + return { + type: "Alternation", + idx: node.idx, + definition: convertDefinition(node.definition) + }; + } else if (node instanceof Terminal) { + var serializedTerminal = { + type: "Terminal", + name: node.terminalType.name, + label: tokenLabel(node.terminalType), + idx: node.idx + }; + var pattern = node.terminalType.PATTERN; + + if (node.terminalType.PATTERN) { + serializedTerminal.pattern = 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"); + } +} + +/** + * 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 = []; + } + + forEach(prod.definition, function (subProd, index) { + var currRest = drop(prod.definition, index + 1); + /* istanbul ignore else */ + + if (subProd instanceof NonTerminal) { + _this.walkProdRef(subProd, currRest, prevRest); + } else if (subProd instanceof Terminal) { + _this.walkTerminal(subProd, currRest, prevRest); + } else if (subProd instanceof Alternative) { + _this.walkFlat(subProd, currRest, prevRest); + } else if (subProd instanceof Option) { + _this.walkOption(subProd, currRest, prevRest); + } else if (subProd instanceof RepetitionMandatory) { + _this.walkAtLeastOne(subProd, currRest, prevRest); + } else if (subProd instanceof RepetitionMandatoryWithSeparator) { + _this.walkAtLeastOneSep(subProd, currRest, prevRest); + } else if (subProd instanceof RepetitionWithSeparator) { + _this.walkManySep(subProd, currRest, prevRest); + } else if (subProd instanceof Repetition) { + _this.walkMany(subProd, currRest, prevRest); + } else if (subProd instanceof 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 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 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 + + 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 Alternative({ + definition: [alt] + }); + + _this.walk(prodWrapper, fullOrRest); + }); + }; + + return RestWalker; +}(); + +function restForRepetitionWithSeparator(repSepProd, currRest, prevRest) { + var repSepRest = [new Option({ + definition: [new Terminal({ + terminalType: repSepProd.separator + })].concat(repSepProd.definition) + })]; + var fullRepSepRest = repSepRest.concat(currRest, prevRest); + return fullRepSepRest; +} + +var GAstVisitor = +/** @class */ +function () { + function GAstVisitor() {} + + GAstVisitor.prototype.visit = function (node) { + var nodeAny = node; + + switch (nodeAny.constructor) { + case NonTerminal: + return this.visitNonTerminal(nodeAny); + + case Alternative: + return this.visitAlternative(nodeAny); + + case Option: + return this.visitOption(nodeAny); + + case RepetitionMandatory: + return this.visitRepetitionMandatory(nodeAny); + + case RepetitionMandatoryWithSeparator: + return this.visitRepetitionMandatoryWithSeparator(nodeAny); + + case RepetitionWithSeparator: + return this.visitRepetitionWithSeparator(nodeAny); + + case Repetition: + return this.visitRepetition(nodeAny); + + case Alternation: + return this.visitAlternation(nodeAny); + + case Terminal: + return this.visitTerminal(nodeAny); + + case Rule: + return this.visitRule(nodeAny); + + /* istanbul ignore next */ + + default: + throw Error("non exhaustive match"); + } + }; + + GAstVisitor.prototype.visitNonTerminal = function (node) {}; + + GAstVisitor.prototype.visitAlternative = 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; +}(); + +var __extends$3 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; +}(); +function isSequenceProd(prod) { + return prod instanceof Alternative || prod instanceof Option || prod instanceof Repetition || prod instanceof RepetitionMandatory || prod instanceof RepetitionMandatoryWithSeparator || prod instanceof RepetitionWithSeparator || prod instanceof Terminal || prod instanceof Rule; +} +function isOptionalProd(prod, alreadyVisited) { + if (alreadyVisited === void 0) { + alreadyVisited = []; + } + + var isDirectlyOptional = prod instanceof Option || prod instanceof Repetition || prod instanceof 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 Alternation) { + // for OR its enough for just one of the alternatives to be optional + return some(prod.definition, function (subProd) { + return isOptionalProd(subProd, alreadyVisited); + }); + } else if (prod instanceof NonTerminal && contains(alreadyVisited, prod)) { + // avoiding stack overflow due to infinite recursion + return false; + } else if (prod instanceof AbstractProduction) { + if (prod instanceof NonTerminal) { + alreadyVisited.push(prod); + } + + return every(prod.definition, function (subProd) { + return isOptionalProd(subProd, alreadyVisited); + }); + } else { + return false; + } +} +function isBranchingProd(prod) { + return prod instanceof Alternation; +} +function getProductionDslName(prod) { + /* istanbul ignore else */ + if (prod instanceof NonTerminal) { + return "SUBRULE"; + } else if (prod instanceof Option) { + return "OPTION"; + } else if (prod instanceof Alternation) { + return "OR"; + } else if (prod instanceof RepetitionMandatory) { + return "AT_LEAST_ONE"; + } else if (prod instanceof RepetitionMandatoryWithSeparator) { + return "AT_LEAST_ONE_SEP"; + } else if (prod instanceof RepetitionWithSeparator) { + return "MANY_SEP"; + } else if (prod instanceof Repetition) { + return "MANY"; + } else if (prod instanceof Terminal) { + return "CONSUME"; + } else { + throw Error("non exhaustive match"); + } +} + +var DslMethodsCollectorVisitor = +/** @class */ +function (_super) { + __extends$3(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 (!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 (!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; +}(GAstVisitor); +var collectorVisitor = new DslMethodsCollectorVisitor(); +function collectMethods(rule) { + collectorVisitor.reset(); + rule.accept(collectorVisitor); + var dslMethods = collectorVisitor.dslMethods; // avoid uncleaned references + + collectorVisitor.reset(); + return dslMethods; +} + +function first$1(prod) { + /* istanbul ignore else */ + if (prod instanceof 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$1(prod.referencedRule); + } else if (prod instanceof Terminal) { + return firstForTerminal(prod); + } else if (isSequenceProd(prod)) { + return firstForSequence(prod); + } else if (isBranchingProd(prod)) { + return firstForBranching(prod); + } else { + throw Error("non exhaustive match"); + } +} +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 = isOptionalProd(currSubProd); + firstSet = firstSet.concat(first$1(currSubProd)); + nextSubProdIdx = nextSubProdIdx + 1; + hasInnerProdsRemaining = seq.length > nextSubProdIdx; + } + + return uniq(firstSet); +} +function firstForBranching(prod) { + var allAlternativesFirsts = map(prod.definition, function (innerProd) { + return first$1(innerProd); + }); + return uniq(flatten(allAlternativesFirsts)); +} +function firstForTerminal(terminal) { + return [terminal.terminalType]; +} + +// TODO: can this be removed? where is it used? +var IN = "_~IN~_"; + +var __extends$4 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; +}(); +// (skipping reference production). + +var ResyncFollowsWalker = +/** @class */ +function (_super) { + __extends$4(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 Alternative({ + definition: fullRest + }); + var t_in_topProd_follows = first$1(restProd); + this.follows[followName] = t_in_topProd_follows; + }; + + return ResyncFollowsWalker; +}(RestWalker); +function computeAllProdsFollows(topProductions) { + var reSyncFollows = {}; + forEach(topProductions, function (topProd) { + var currRefsFollow = new ResyncFollowsWalker(topProd).startWalking(); + assign(reSyncFollows, currRefsFollow); + }); + return reSyncFollows; +} +function buildBetweenProdsFollowPrefix(inner, occurenceInParent) { + return inner.name + occurenceInParent + IN; +} + +var defaultParserErrorProvider = { + buildMismatchTokenMessage: function buildMismatchTokenMessage(_a) { + var expected = _a.expected, + actual = _a.actual, + previous = _a.previous, + ruleName = _a.ruleName; + var hasLabel = hasTokenLabel(expected); + var expectedMsg = hasLabel ? "--> " + tokenLabel(expected) + " <--" : "token of type --> " + expected.name + " <--"; + var msg = "Expecting " + expectedMsg + " but found --> '" + actual.image + "' <--"; + return msg; + }, + buildNotAllInputParsedMessage: function buildNotAllInputParsedMessage(_a) { + var firstRedundant = _a.firstRedundant, + ruleName = _a.ruleName; + return "Redundant input, expecting EOF but found: " + firstRedundant.image; + }, + buildNoViableAltMessage: function buildNoViableAltMessage(_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 = first(actual).image; + var errSuffix = "\nbut found: '" + actualText + "'"; + + if (customUserDescription) { + return errPrefix + customUserDescription + errSuffix; + } else { + var allLookAheadPaths = reduce(expectedPathsPerAlt, function (result, currAltPaths) { + return result.concat(currAltPaths); + }, []); + var nextValidTokenSequences = map(allLookAheadPaths, function (currPath) { + return "[" + map(currPath, function (currTokenType) { + return tokenLabel(currTokenType); + }).join(", ") + "]"; + }); + var nextValidSequenceItems = 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 buildEarlyExitMessage(_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 = first(actual).image; + var errSuffix = "\nbut found: '" + actualText + "'"; + + if (customUserDescription) { + return errPrefix + customUserDescription + errSuffix; + } else { + var nextValidTokenSequences = map(expectedIterationPaths, function (currPath) { + return "[" + map(currPath, function (currTokenType) { + return 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(defaultParserErrorProvider); +var defaultGrammarResolverErrorProvider = { + buildRuleNotFoundError: function buildRuleNotFoundError(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; + } +}; +var defaultGrammarValidatorErrorProvider = { + buildDuplicateFoundError: function buildDuplicateFoundError(topLevelRule, duplicateProds) { + function getExtraProductionArgument(prod) { + if (prod instanceof Terminal) { + return prod.terminalType.name; + } else if (prod instanceof NonTerminal) { + return prod.nonTerminalName; + } else { + return ""; + } + } + + var topLevelName = topLevelRule.name; + var duplicateProd = first(duplicateProds); + var index = duplicateProd.idx; + var dslName = 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; + }, + buildNamespaceConflictError: function buildNamespaceConflictError(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 buildAlternationPrefixAmbiguityError(options) { + var pathMsg = map(options.prefixPath, function (currTok) { + return 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 buildAlternationAmbiguityError(options) { + var pathMsg = map(options.prefixPath, function (currtok) { + return 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 buildEmptyRepetitionError(options) { + var dslName = 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 buildTokenNameError(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 buildEmptyAlternationError(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 buildTooManyAlternativesError(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 buildLeftRecursionError(options) { + var ruleName = options.topLevelRule.name; + var pathNames = 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 buildInvalidRuleNameError(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 buildDuplicateRuleNameError(options) { + var ruleName; + + if (options.topLevelRule instanceof 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; + } +}; + +var __extends$5 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; +}(); +function resolveGrammar(topLevels, errMsgProvider) { + var refResolver = new GastRefResolverVisitor(topLevels, errMsgProvider); + refResolver.resolveRefs(); + return refResolver.errors; +} + +var GastRefResolverVisitor = +/** @class */ +function (_super) { + __extends$5(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; + + forEach(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: ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF, + ruleName: this.currTopLevel.name, + unresolvedRefName: node.nonTerminalName + }); + } else { + node.referencedRule = ref; + } + }; + + return GastRefResolverVisitor; +}(GAstVisitor); + +var __extends$6 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; +}(); + +var AbstractNextPossibleTokensWalker = +/** @class */ +function (_super) { + __extends$6(AbstractNextPossibleTokensWalker, _super); + + function AbstractNextPossibleTokensWalker(topProd, path) { + var _this = _super.call(this) || 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 = cloneArr(this.path.ruleStack).reverse(); // intelij bug requires assertion + + this.occurrenceStack = 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 (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; +}(RestWalker); + +var NextAfterTokenWalker = +/** @class */ +function (_super) { + __extends$6(NextAfterTokenWalker, _super); + + function NextAfterTokenWalker(topProd, path) { + var _this = _super.call(this, topProd, path) || 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 Alternative({ + definition: fullRest + }); + this.possibleTokTypes = first$1(restProd); + this.found = true; + } + }; + + return NextAfterTokenWalker; +}(AbstractNextPossibleTokensWalker); +/** + * 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$6(AbstractNextTerminalAfterProductionWalker, _super); + + function AbstractNextTerminalAfterProductionWalker(topRule, occurrence) { + var _this = _super.call(this) || 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; +}(RestWalker); + +var NextTerminalAfterManyWalker = +/** @class */ +function (_super) { + __extends$6(NextTerminalAfterManyWalker, _super); + + function NextTerminalAfterManyWalker() { + return _super !== null && _super.apply(this, arguments) || this; + } + + NextTerminalAfterManyWalker.prototype.walkMany = function (manyProd, currRest, prevRest) { + if (manyProd.idx === this.occurrence) { + var firstAfterMany = first(currRest.concat(prevRest)); + + this.result.isEndOfRule = firstAfterMany === undefined; + + if (firstAfterMany instanceof Terminal) { + this.result.token = firstAfterMany.terminalType; + this.result.occurrence = firstAfterMany.idx; + } + } else { + _super.prototype.walkMany.call(this, manyProd, currRest, prevRest); + } + }; + + return NextTerminalAfterManyWalker; +}(AbstractNextTerminalAfterProductionWalker); + +var NextTerminalAfterManySepWalker = +/** @class */ +function (_super) { + __extends$6(NextTerminalAfterManySepWalker, _super); + + function NextTerminalAfterManySepWalker() { + return _super !== null && _super.apply(this, arguments) || this; + } + + NextTerminalAfterManySepWalker.prototype.walkManySep = function (manySepProd, currRest, prevRest) { + if (manySepProd.idx === this.occurrence) { + var firstAfterManySep = first(currRest.concat(prevRest)); + + this.result.isEndOfRule = firstAfterManySep === undefined; + + if (firstAfterManySep instanceof Terminal) { + this.result.token = firstAfterManySep.terminalType; + this.result.occurrence = firstAfterManySep.idx; + } + } else { + _super.prototype.walkManySep.call(this, manySepProd, currRest, prevRest); + } + }; + + return NextTerminalAfterManySepWalker; +}(AbstractNextTerminalAfterProductionWalker); + +var NextTerminalAfterAtLeastOneWalker = +/** @class */ +function (_super) { + __extends$6(NextTerminalAfterAtLeastOneWalker, _super); + + function NextTerminalAfterAtLeastOneWalker() { + return _super !== null && _super.apply(this, arguments) || this; + } + + NextTerminalAfterAtLeastOneWalker.prototype.walkAtLeastOne = function (atLeastOneProd, currRest, prevRest) { + if (atLeastOneProd.idx === this.occurrence) { + var firstAfterAtLeastOne = first(currRest.concat(prevRest)); + + this.result.isEndOfRule = firstAfterAtLeastOne === undefined; + + if (firstAfterAtLeastOne instanceof Terminal) { + this.result.token = firstAfterAtLeastOne.terminalType; + this.result.occurrence = firstAfterAtLeastOne.idx; + } + } else { + _super.prototype.walkAtLeastOne.call(this, atLeastOneProd, currRest, prevRest); + } + }; + + return NextTerminalAfterAtLeastOneWalker; +}(AbstractNextTerminalAfterProductionWalker); + +var NextTerminalAfterAtLeastOneSepWalker = +/** @class */ +function (_super) { + __extends$6(NextTerminalAfterAtLeastOneSepWalker, _super); + + function NextTerminalAfterAtLeastOneSepWalker() { + return _super !== null && _super.apply(this, arguments) || this; + } + + NextTerminalAfterAtLeastOneSepWalker.prototype.walkAtLeastOneSep = function (atleastOneSepProd, currRest, prevRest) { + if (atleastOneSepProd.idx === this.occurrence) { + var firstAfterfirstAfterAtLeastOneSep = first(currRest.concat(prevRest)); + + this.result.isEndOfRule = firstAfterfirstAfterAtLeastOneSep === undefined; + + if (firstAfterfirstAfterAtLeastOneSep instanceof Terminal) { + this.result.token = firstAfterfirstAfterAtLeastOneSep.terminalType; + this.result.occurrence = firstAfterfirstAfterAtLeastOneSep.idx; + } + } else { + _super.prototype.walkAtLeastOneSep.call(this, atleastOneSepProd, currRest, prevRest); + } + }; + + return NextTerminalAfterAtLeastOneSepWalker; +}(AbstractNextTerminalAfterProductionWalker); +function possiblePathsFrom(targetDef, maxLength, currPath) { + if (currPath === void 0) { + currPath = []; + } // avoid side effects + + + currPath = cloneArr(currPath); + var result = []; + var i = 0; // TODO: avoid inner funcs + + function remainingPathWith(nextDef) { + return nextDef.concat(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 Alternative) { + return getAlternativesForProd(prod.definition); + } else if (prod instanceof NonTerminal) { + return getAlternativesForProd(prod.definition); + } else if (prod instanceof Option) { + result = getAlternativesForProd(prod.definition); + } else if (prod instanceof RepetitionMandatory) { + var newDef = prod.definition.concat([new Repetition({ + definition: prod.definition + })]); + return getAlternativesForProd(newDef); + } else if (prod instanceof RepetitionMandatoryWithSeparator) { + var newDef = [new Alternative({ + definition: prod.definition + }), new Repetition({ + definition: [new Terminal({ + terminalType: prod.separator + })].concat(prod.definition) + })]; + return getAlternativesForProd(newDef); + } else if (prod instanceof RepetitionWithSeparator) { + var newDef = prod.definition.concat([new Repetition({ + definition: [new Terminal({ + terminalType: prod.separator + })].concat(prod.definition) + })]); + result = getAlternativesForProd(newDef); + } else if (prod instanceof Repetition) { + var newDef = prod.definition.concat([new Repetition({ + definition: prod.definition + })]); + result = getAlternativesForProd(newDef); + } else if (prod instanceof Alternation) { + forEach(prod.definition, function (currAlt) { + result = getAlternativesForProd(currAlt.definition); + }); + return result; + } else if (prod instanceof Terminal) { + currPath.push(prod.terminalType); + } else { + throw Error("non exhaustive match"); + } + + i++; + } + + result.push({ + partialPath: currPath, + suffixDef: drop(targetDef, i) + }); + return result; +} +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 (!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 && 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 (isEmpty(currDef)) { + continue; + } + + var prod = currDef[0]; + /* istanbul ignore else */ + + if (prod === EXIT_NON_TERMINAL) { + var nextPath = { + idx: currIdx, + def: drop(currDef), + ruleStack: dropRight(currRuleStack), + occurrenceStack: dropRight(currOccurrenceStack) + }; + possiblePaths.push(nextPath); + } else if (prod instanceof 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: 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 NonTerminal) { + var newRuleStack = cloneArr(currRuleStack); + newRuleStack.push(prod.nonTerminalName); + var newOccurrenceStack = cloneArr(currOccurrenceStack); + newOccurrenceStack.push(prod.idx); + var nextPath = { + idx: currIdx, + def: prod.definition.concat(EXIT_NON_TERMINAL_ARR, drop(currDef)), + ruleStack: newRuleStack, + occurrenceStack: newOccurrenceStack + }; + possiblePaths.push(nextPath); + } else if (prod instanceof Option) { + // the order of alternatives is meaningful, FILO (Last path will be traversed first). + var nextPathWithout = { + idx: currIdx, + def: 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(drop(currDef)), + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(nextPathWith); + } else if (prod instanceof RepetitionMandatory) { + // TODO:(THE NEW operators here take a while...) (convert once?) + var secondIteration = new Repetition({ + definition: prod.definition, + idx: prod.idx + }); + var nextDef = prod.definition.concat([secondIteration], drop(currDef)); + var nextPath = { + idx: currIdx, + def: nextDef, + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(nextPath); + } else if (prod instanceof RepetitionMandatoryWithSeparator) { + // TODO:(THE NEW operators here take a while...) (convert once?) + var separatorGast = new Terminal({ + terminalType: prod.separator + }); + var secondIteration = new Repetition({ + definition: [separatorGast].concat(prod.definition), + idx: prod.idx + }); + var nextDef = prod.definition.concat([secondIteration], drop(currDef)); + var nextPath = { + idx: currIdx, + def: nextDef, + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(nextPath); + } else if (prod instanceof RepetitionWithSeparator) { + // the order of alternatives is meaningful, FILO (Last path will be traversed first). + var nextPathWithout = { + idx: currIdx, + def: 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 Terminal({ + terminalType: prod.separator + }); + var nthRepetition = new Repetition({ + definition: [separatorGast].concat(prod.definition), + idx: prod.idx + }); + var nextDef = prod.definition.concat([nthRepetition], drop(currDef)); + var nextPathWith = { + idx: currIdx, + def: nextDef, + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(nextPathWith); + } else if (prod instanceof Repetition) { + // the order of alternatives is meaningful, FILO (Last path will be traversed first). + var nextPathWithout = { + idx: currIdx, + def: 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 Repetition({ + definition: prod.definition, + idx: prod.idx + }); + var nextDef = prod.definition.concat([nthRepetition], drop(currDef)); + var nextPathWith = { + idx: currIdx, + def: nextDef, + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(nextPathWith); + } else if (prod instanceof 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(drop(currDef)), + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }; + possiblePaths.push(currAltPath); + possiblePaths.push(EXIT_ALTERNATIVE); + } + } else if (prod instanceof Alternative) { + possiblePaths.push({ + idx: currIdx, + def: prod.definition.concat(drop(currDef)), + ruleStack: currRuleStack, + occurrenceStack: currOccurrenceStack + }); + } else if (prod instanceof 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; +} + +function expandTopLevelRule(topRule, currIdx, currRuleStack, currOccurrenceStack) { + var newRuleStack = cloneArr(currRuleStack); + newRuleStack.push(topRule.name); + var newCurrOccurrenceStack = 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 + }; +} + +var __extends$7 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; +}(); +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 || (PROD_TYPE = {})); + +function getProdType(prod) { + /* istanbul ignore else */ + if (prod instanceof Option) { + return PROD_TYPE.OPTION; + } else if (prod instanceof Repetition) { + return PROD_TYPE.REPETITION; + } else if (prod instanceof RepetitionMandatory) { + return PROD_TYPE.REPETITION_MANDATORY; + } else if (prod instanceof RepetitionMandatoryWithSeparator) { + return PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR; + } else if (prod instanceof RepetitionWithSeparator) { + return PROD_TYPE.REPETITION_WITH_SEPARATOR; + } else if (prod instanceof Alternation) { + return PROD_TYPE.ALTERNATION; + } else { + throw Error("non exhaustive match"); + } +} +function buildLookaheadFuncForOr(occurrence, ruleGrammar, maxLookahead, hasPredicates, dynamicTokensEnabled, laFuncBuilder) { + var lookAheadPaths = getLookaheadPathsForOr(occurrence, ruleGrammar, maxLookahead); + var tokenMatcher = areTokenCategoriesNotUsed(lookAheadPaths) ? tokenStructuredMatcherNoCategories : tokenStructuredMatcher; + return laFuncBuilder(lookAheadPaths, hasPredicates, tokenMatcher, dynamicTokensEnabled); +} +/** + * 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) ? tokenStructuredMatcherNoCategories : tokenStructuredMatcher; + return lookaheadBuilder(lookAheadPaths[0], tokenMatcher, dynamicTokensEnabled); +} +function buildAlternativesLookAheadFunc(alts, hasPredicates, tokenMatcher, dynamicTokensEnabled) { + var numOfAlts = alts.length; + var areAllOneTokenLookahead = every(alts, function (currAlt) { + return 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 = 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 = map(alts, function (currAlt) { + return flatten(currAlt); + }); + var choiceToAlt_1 = reduce(singleTokenAlts, function (result, currAlt, idx) { + forEach(currAlt, function (currTokType) { + if (!has(result, currTokType.tokenTypeIdx)) { + result[currTokType.tokenTypeIdx] = idx; + } + + forEach(currTokType.categoryMatches, function (currExtendingType) { + if (!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; + }; + } +} +function buildSingleAlternativeLookaheadFunction(alt, tokenMatcher, dynamicTokensEnabled) { + var areAllOneTokenLookahead = 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 = flatten(alt); + + if (singleTokensTypes.length === 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 = reduce(singleTokensTypes, function (result, currTokType, idx) { + result[currTokType.tokenTypeIdx] = true; + 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; + }; + } +} + +var RestDefinitionFinderWalker = +/** @class */ +function (_super) { + __extends$7(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; +}(RestWalker); +/** + * Returns the definition of a target production in a top level level rule. + */ + + +var InsideDefinitionFinderVisitor = +/** @class */ +function (_super) { + __extends$7(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; +}(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 = map(altsDefs, function (currAlt) { + return possiblePathsFrom([currAlt], 1); + }); + var finalResult = initializeArrayOfArrays(partialAlts.length); + var altsHashes = map(partialAlts, function (currAltPaths) { + var dict = {}; + forEach(currAltPaths, function (item) { + var keys = pathToHashKeys(item.partialPath); + 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 _loop_1(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 || 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 = possiblePathsFrom(suffixDef, pathLength + 1, currPathPrefix); + newData[altIdx] = newData[altIdx].concat(newPartialPathsAndSuffixes); // Update keys for new known paths + + forEach(newPartialPathsAndSuffixes, function (item) { + var prefixKeys = pathToHashKeys(item.partialPath); + forEach(prefixKeys, function (key) { + altsHashes[altIdx][key] = true; + }); + }); + } + } + }; // alternatives loop + + + for (var altIdx = 0; altIdx < currDataset.length; altIdx++) { + _loop_1(altIdx); + } + } + + return finalResult; +} +function getLookaheadPathsForOr(occurrence, ruleGrammar, k, orProd) { + var visitor = new InsideDefinitionFinderVisitor(occurrence, PROD_TYPE.ALTERNATION, orProd); + ruleGrammar.accept(visitor); + return lookAheadSequenceFromAlternatives(visitor.result, k); +} +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 Alternative({ + definition: insideDef + }); + var afterFlat = new Alternative({ + definition: afterDef + }); + return lookAheadSequenceFromAlternatives([insideFlat, afterFlat], k); +} +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; +} +function isStrictPrefixOfPath(prefix, other) { + return prefix.length < other.length && every(prefix, function (tokType, idx) { + var otherTokType = other[idx]; + return tokType === otherTokType || otherTokType.categoryMatchesMap[tokType.tokenTypeIdx]; + }); +} +function areTokenCategoriesNotUsed(lookAheadPaths) { + return every(lookAheadPaths, function (singleAltPaths) { + return every(singleAltPaths, function (singlePath) { + return every(singlePath, function (token) { + return isEmpty(token.categoryMatches); + }); + }); + }); +} + +var __extends$8 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; +}(); +function validateGrammar(topLevels, globalMaxLookahead, tokenTypes, errMsgProvider, grammarName) { + var duplicateErrors = map(topLevels, function (currTopLevel) { + return validateDuplicateProductions(currTopLevel, errMsgProvider); + }); + var leftRecursionErrors = 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 (every(leftRecursionErrors, isEmpty)) { + emptyAltErrors = map(topLevels, function (currTopRule) { + return validateEmptyOrAlternative(currTopRule, errMsgProvider); + }); + ambiguousAltsErrors = map(topLevels, function (currTopRule) { + return validateAmbiguousAlternationAlternatives(currTopRule, globalMaxLookahead, errMsgProvider); + }); + emptyRepetitionErrors = validateSomeNonEmptyLookaheadPath(topLevels, globalMaxLookahead, errMsgProvider); + } + + var termsNamespaceConflictErrors = checkTerminalAndNoneTerminalsNameSpace(topLevels, tokenTypes, errMsgProvider); + var tokenNameErrors = map(tokenTypes, function (currTokType) { + return validateTokenName(currTokType, errMsgProvider); + }); + var tooManyAltsErrors = map(topLevels, function (curRule) { + return validateTooManyAlts(curRule, errMsgProvider); + }); + var ruleNameErrors = map(topLevels, function (curRule) { + return validateRuleName(curRule, errMsgProvider); + }); + var duplicateRulesError = map(topLevels, function (curRule) { + return validateRuleDoesNotAlreadyExist(curRule, topLevels, grammarName, errMsgProvider); + }); + return flatten(duplicateErrors.concat(tokenNameErrors, emptyRepetitionErrors, leftRecursionErrors, emptyAltErrors, ambiguousAltsErrors, termsNamespaceConflictErrors, tooManyAltsErrors, ruleNameErrors, duplicateRulesError)); +} + +function validateDuplicateProductions(topLevelRule, errMsgProvider) { + var collectorVisitor = new OccurrenceValidationCollector(); + topLevelRule.accept(collectorVisitor); + var allRuleProductions = collectorVisitor.allProductions; + var productionGroups = groupBy(allRuleProductions, identifyProductionForDuplicates); + var duplicates = pick(productionGroups, function (currGroup) { + return currGroup.length > 1; + }); + var errors = map(values(duplicates), function (currDuplicates) { + var firstProd = first(currDuplicates); + var msg = errMsgProvider.buildDuplicateFoundError(topLevelRule, currDuplicates); + var dslName = getProductionDslName(firstProd); + var defError = { + message: msg, + type: 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 getProductionDslName(prod) + "_#_" + prod.idx + "_#_" + getExtraProductionArgument(prod); +} + +function getExtraProductionArgument(prod) { + if (prod instanceof Terminal) { + return prod.terminalType.name; + } else if (prod instanceof NonTerminal) { + return prod.nonTerminalName; + } else { + return ""; + } +} + +var OccurrenceValidationCollector = +/** @class */ +function (_super) { + __extends$8(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; +}(GAstVisitor); +var validTermsPattern = /^[a-zA-Z_]\w*$/; // TODO: remove this limitation now that we use recorders + +function validateRuleName(rule, errMsgProvider) { + var errors = []; + var ruleName = rule.name; + + if (!ruleName.match(validTermsPattern)) { + errors.push({ + message: errMsgProvider.buildInvalidRuleNameError({ + topLevelRule: rule, + expectedPattern: validTermsPattern + }), + type: ParserDefinitionErrorType.INVALID_RULE_NAME, + ruleName: ruleName + }); + } + + return errors; +} // TODO: remove this limitation now that we use recorders + +function validateTokenName(tokenType, errMsgProvider) { + var errors = []; + var tokTypeName = tokenType.name; + + if (!tokTypeName.match(validTermsPattern)) { + errors.push({ + message: errMsgProvider.buildTokenNameError({ + tokenType: tokenType, + expectedPattern: validTermsPattern + }), + type: ParserDefinitionErrorType.INVALID_TOKEN_NAME + }); + } + + return errors; +} +function validateRuleDoesNotAlreadyExist(rule, allRules, className, errMsgProvider) { + var errors = []; + var occurrences = 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: ParserDefinitionErrorType.DUPLICATE_RULE_NAME, + ruleName: rule.name + }); + } + + return errors; +} // 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 (!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: ParserDefinitionErrorType.INVALID_RULE_OVERRIDE, + ruleName: ruleName + }); + } + + return errors; +} +function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path) { + if (path === void 0) { + path = []; + } + + var errors = []; + var nextNonTerminals = getFirstNoneTerminal(currRule.definition); + + if (isEmpty(nextNonTerminals)) { + return []; + } else { + var ruleName = topRule.name; + var foundLeftRecursion = contains(nextNonTerminals, topRule); + + if (foundLeftRecursion) { + errors.push({ + message: errMsgProvider.buildLeftRecursionError({ + topLevelRule: topRule, + leftRecursionPath: path + }), + type: 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 = difference(nextNonTerminals, path.concat([topRule])); + var errorsFromNextSteps = map(validNextSteps, function (currRefRule) { + var newPath = cloneArr(path); + newPath.push(currRefRule); + return validateNoLeftRecursion(topRule, currRefRule, errMsgProvider, newPath); + }); + return errors.concat(flatten(errorsFromNextSteps)); + } +} +function getFirstNoneTerminal(definition) { + var result = []; + + if (isEmpty(definition)) { + return result; + } + + var firstProd = first(definition); + /* istanbul ignore else */ + + if (firstProd instanceof NonTerminal) { + result.push(firstProd.referencedRule); + } else if (firstProd instanceof Alternative || firstProd instanceof Option || firstProd instanceof RepetitionMandatory || firstProd instanceof RepetitionMandatoryWithSeparator || firstProd instanceof RepetitionWithSeparator || firstProd instanceof Repetition) { + result = result.concat(getFirstNoneTerminal(firstProd.definition)); + } else if (firstProd instanceof Alternation) { + // each sub definition in alternation is a FLAT + result = flatten(map(firstProd.definition, function (currSubDef) { + return getFirstNoneTerminal(currSubDef.definition); + })); + } else if (firstProd instanceof Terminal) ; else { + throw Error("non exhaustive match"); + } + + var isFirstOptional = isOptionalProd(firstProd); + var hasMore = definition.length > 1; + + if (isFirstOptional && hasMore) { + var rest = drop(definition); + return result.concat(getFirstNoneTerminal(rest)); + } else { + return result; + } +} + +var OrCollector = +/** @class */ +function (_super) { + __extends$8(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; +}(GAstVisitor); + +function validateEmptyOrAlternative(topLevelRule, errMsgProvider) { + var orCollector = new OrCollector(); + topLevelRule.accept(orCollector); + var ors = orCollector.alternations; + var errors = reduce(ors, function (errors, currOr) { + var exceptLast = dropRight(currOr.definition); + var currErrors = map(exceptLast, function (currAlternative, currAltIdx) { + var possibleFirstInAlt = nextPossibleTokensAfter([currAlternative], [], null, 1); + + if (isEmpty(possibleFirstInAlt)) { + return { + message: errMsgProvider.buildEmptyAlternationError({ + topLevelRule: topLevelRule, + alternation: currOr, + emptyChoiceIdx: currAltIdx + }), + type: ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT, + ruleName: topLevelRule.name, + occurrence: currOr.idx, + alternative: currAltIdx + 1 + }; + } else { + return null; + } + }); + return errors.concat(compact(currErrors)); + }, []); + return errors; +} +function validateAmbiguousAlternationAlternatives(topLevelRule, globalMaxLookahead, errMsgProvider) { + var orCollector = new OrCollector(); + topLevelRule.accept(orCollector); + var ors = orCollector.alternations; // New Handling of ignoring ambiguities + // - https://github.com/SAP/chevrotain/issues/869 + + ors = reject(ors, function (currOr) { + return currOr.ignoreAmbiguities === true; + }); + var errors = reduce(ors, function (result, currOr) { + var currOccurrence = currOr.idx; + var actualMaxLookahead = currOr.maxLookahead || globalMaxLookahead; + var alternatives = 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; +} + +var RepetionCollector = +/** @class */ +function (_super) { + __extends$8(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; +}(GAstVisitor); +function validateTooManyAlts(topLevelRule, errMsgProvider) { + var orCollector = new OrCollector(); + topLevelRule.accept(orCollector); + var ors = orCollector.alternations; + var errors = reduce(ors, function (errors, currOr) { + if (currOr.definition.length > 255) { + errors.push({ + message: errMsgProvider.buildTooManyAlternativesError({ + topLevelRule: topLevelRule, + alternation: currOr + }), + type: ParserDefinitionErrorType.TOO_MANY_ALTS, + ruleName: topLevelRule.name, + occurrence: currOr.idx + }); + } + + return errors; + }, []); + return errors; +} +function validateSomeNonEmptyLookaheadPath(topLevelRules, maxLookahead, errMsgProvider) { + var errors = []; + forEach(topLevelRules, function (currTopRule) { + var collectorVisitor = new RepetionCollector(); + currTopRule.accept(collectorVisitor); + var allRuleProductions = collectorVisitor.allProductions; + forEach(allRuleProductions, function (currProd) { + var prodType = getProdType(currProd); + var actualMaxLookahead = currProd.maxLookahead || maxLookahead; + var currOccurrence = currProd.idx; + var paths = getLookaheadPathsForOptionalProd(currOccurrence, currTopRule, prodType, actualMaxLookahead); + var pathsInsideProduction = paths[0]; + + if (isEmpty(flatten(pathsInsideProduction))) { + var errMsg = errMsgProvider.buildEmptyRepetitionError({ + topLevelRule: currTopRule, + repetition: currProd + }); + errors.push({ + message: errMsg, + type: ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD, + ruleName: currTopRule.name + }); + } + }); + }); + return errors; +} + +function checkAlternativesAmbiguities(alternatives, alternation, rule, errMsgProvider) { + var foundAmbiguousPaths = []; + var identicalAmbiguities = reduce(alternatives, function (result, currAlt, currAltIdx) { + // ignore (skip) ambiguities with this alternative + if (alternation.definition[currAltIdx].ignoreAmbiguities === true) { + return result; + } + + forEach(currAlt, function (currPath) { + var altsCurrPathAppearsIn = [currAltIdx]; + forEach(alternatives, function (currOtherAlt, currOtherAltIdx) { + if (currAltIdx !== currOtherAltIdx && containsPath(currOtherAlt, currPath) && // ignore (skip) ambiguities with this "other" alternative + alternation.definition[currOtherAltIdx].ignoreAmbiguities !== true) { + altsCurrPathAppearsIn.push(currOtherAltIdx); + } + }); + + if (altsCurrPathAppearsIn.length > 1 && !containsPath(foundAmbiguousPaths, currPath)) { + foundAmbiguousPaths.push(currPath); + result.push({ + alts: altsCurrPathAppearsIn, + path: currPath + }); + } + }); + return result; + }, []); + var currErrors = map(identicalAmbiguities, function (currAmbDescriptor) { + var ambgIndices = 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: 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 = reduce(alternatives, function (result, currAlt, idx) { + var currPathsAndIdx = map(currAlt, function (currPath) { + return { + idx: idx, + path: currPath + }; + }); + return result.concat(currPathsAndIdx); + }, []); + 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 = 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. + isStrictPrefixOfPath(searchPathAndIdx.path, targetPath) + ); + }); + var currPathPrefixErrors = 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: ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS, + ruleName: rule.name, + occurrence: occurrence, + alternatives: ambgIndices + }; + }); + errors = errors.concat(currPathPrefixErrors); + }); + return errors; +} + +function checkTerminalAndNoneTerminalsNameSpace(topLevels, tokenTypes, errMsgProvider) { + var errors = []; + var tokenNames = map(tokenTypes, function (currToken) { + return currToken.name; + }); + forEach(topLevels, function (currRule) { + var currRuleName = currRule.name; + + if (contains(tokenNames, currRuleName)) { + var errMsg = errMsgProvider.buildNamespaceConflictError(currRule); + errors.push({ + message: errMsg, + type: ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE, + ruleName: currRuleName + }); + } + }); + return errors; +} + +function resolveGrammar$1(options) { + options = defaults(options, { + errMsgProvider: defaultGrammarResolverErrorProvider + }); + var topRulesTable = {}; + forEach(options.rules, function (rule) { + topRulesTable[rule.name] = rule; + }); + return resolveGrammar(topRulesTable, options.errMsgProvider); +} +function validateGrammar$1(options) { + options = defaults(options, { + errMsgProvider: defaultGrammarValidatorErrorProvider + }); + return validateGrammar(options.rules, options.maxLookahead, options.tokenTypes, options.errMsgProvider, options.grammarName); +} + +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 contains(RECOGNITION_EXCEPTION_NAMES, error.name); +} +function MismatchedTokenException(message, token, previousToken) { + this.name = MISMATCHED_TOKEN_EXCEPTION; + this.message = message; + this.token = token; + this.previousToken = previousToken; + this.resyncedTokens = []; +} // 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 = []; +} +NoViableAltException.prototype = Error.prototype; +function NotAllInputParsedException(message, token) { + this.name = NOT_ALL_INPUT_PARSED_EXCEPTION; + this.message = message; + this.token = token; + this.resyncedTokens = []; +} +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 = []; +} +EarlyExitException.prototype = Error.prototype; + +var EOF_FOLLOW_KEY = {}; +var IN_RULE_RECOVERY_EXCEPTION = "InRuleRecoveryException"; +function InRuleRecoveryException(message) { + this.name = IN_RULE_RECOVERY_EXCEPTION; + this.message = message; +} +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 = has(config, "recoveryEnabled") ? config.recoveryEnabled : 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 = 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 generateErrorMessage() { + 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 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 = 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 (isEmpty(follows)) { + return false; + } + + var mismatchedTok = this.LA(1); + var isMisMatchedTokInFollows = 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 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 (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 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; + return map(explicitRuleStack, function (ruleName, idx) { + if (idx === 0) { + return 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 = map(this.buildFullFollowKeyStack(), function (currKey) { + return _this.getFollowSetFromFollowKey(currKey); + }); + return flatten(followStack); + }; + + Recoverable.prototype.getFollowSetFromFollowKey = function (followKey) { + if (followKey === EOF_FOLLOW_KEY) { + return [EOF]; + } + + var followName = followKey.ruleName + followKey.idxInCallingRule + 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, 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 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 = cloneArr(this.RULE_OCCURRENCE_STACK); + var grammarPath = { + ruleStack: pathRuleStack, + occurrenceStack: pathOccurrenceStack, + lastTok: tokType, + lastTokOccurrence: tokIdxInRule + }; + return grammarPath; + }; + + Recoverable.prototype.getHumanReadableRuleStack = function () { + var _this = this; + + return map(this.RULE_STACK, function (currShortName) { + return _this.shortRuleNameToFullName(currShortName); + }); + }; + + return 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 = 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); + } +} + +// 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 +var BITS_FOR_METHOD_TYPE = 4; +var BITS_FOR_OCCURRENCE_IDX = 8; +// 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 */ + +var OR_IDX = 1 << BITS_FOR_OCCURRENCE_IDX; +var OPTION_IDX = 2 << BITS_FOR_OCCURRENCE_IDX; +var MANY_IDX = 3 << BITS_FOR_OCCURRENCE_IDX; +var AT_LEAST_ONE_IDX = 4 << BITS_FOR_OCCURRENCE_IDX; +var MANY_SEP_IDX = 5 << BITS_FOR_OCCURRENCE_IDX; +var AT_LEAST_ONE_SEP_IDX = 6 << 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 */ +} + +/** + * Trait responsible for the lookahead related utilities and optimizations. + */ + +var LooksAhead = +/** @class */ +function () { + function LooksAhead() {} + + LooksAhead.prototype.initLooksAhead = function (config) { + this.dynamicTokensEnabled = has(config, "dynamicTokensEnabled") ? config.dynamicTokensEnabled : DEFAULT_PARSER_CONFIG.dynamicTokensEnabled; + this.maxLookahead = has(config, "maxLookahead") ? config.maxLookahead : DEFAULT_PARSER_CONFIG.maxLookahead; + /* istanbul ignore next - Using plain array as dictionary will be tested on older node.js versions and IE11 */ + + this.lookAheadFuncsCache = 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 (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; + + forEach(rules, function (currRule) { + _this.TRACE_INIT(currRule.name + " Rule Lookahead", function () { + var _a = collectMethods(currRule), + alternation = _a.alternation, + repetition = _a.repetition, + option = _a.option, + repetitionMandatory = _a.repetitionMandatory, + repetitionMandatoryWithSeparator = _a.repetitionMandatoryWithSeparator, + repetitionWithSeparator = _a.repetitionWithSeparator; + + forEach(alternation, function (currProd) { + var prodIdx = currProd.idx === 0 ? "" : currProd.idx; + + _this.TRACE_INIT("" + getProductionDslName(currProd) + prodIdx, function () { + var laFunc = buildLookaheadFuncForOr(currProd.idx, currRule, currProd.maxLookahead || _this.maxLookahead, currProd.hasPredicates, _this.dynamicTokensEnabled, _this.lookAheadBuilderForAlternatives); + var key = getKeyForAutomaticLookahead(_this.fullRuleNameToShort[currRule.name], OR_IDX, currProd.idx); + + _this.setLaFuncCache(key, laFunc); + }); + }); + forEach(repetition, function (currProd) { + _this.computeLookaheadFunc(currRule, currProd.idx, MANY_IDX, PROD_TYPE.REPETITION, currProd.maxLookahead, getProductionDslName(currProd)); + }); + forEach(option, function (currProd) { + _this.computeLookaheadFunc(currRule, currProd.idx, OPTION_IDX, PROD_TYPE.OPTION, currProd.maxLookahead, getProductionDslName(currProd)); + }); + forEach(repetitionMandatory, function (currProd) { + _this.computeLookaheadFunc(currRule, currProd.idx, AT_LEAST_ONE_IDX, PROD_TYPE.REPETITION_MANDATORY, currProd.maxLookahead, getProductionDslName(currProd)); + }); + forEach(repetitionMandatoryWithSeparator, function (currProd) { + _this.computeLookaheadFunc(currRule, currProd.idx, AT_LEAST_ONE_SEP_IDX, PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR, currProd.maxLookahead, getProductionDslName(currProd)); + }); + forEach(repetitionWithSeparator, function (currProd) { + _this.computeLookaheadFunc(currRule, currProd.idx, MANY_SEP_IDX, PROD_TYPE.REPETITION_WITH_SEPARATOR, currProd.maxLookahead, 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 = buildLookaheadFuncForOptionalProd(prodOccurrence, rule, prodMaxLookahead || _this.maxLookahead, _this.dynamicTokensEnabled, prodType, _this.lookAheadBuilderForOptional); + var key = getKeyForAutomaticLookahead(_this.fullRuleNameToShort[rule.name], prodKey, prodOccurrence); + + _this.setLaFuncCache(key, laFunc); + }); + }; + + LooksAhead.prototype.lookAheadBuilderForOptional = function (alt, tokenMatcher, dynamicTokensEnabled) { + return buildSingleAlternativeLookaheadFunction(alt, tokenMatcher, dynamicTokensEnabled); + }; + + LooksAhead.prototype.lookAheadBuilderForAlternatives = function (alts, hasPredicates, tokenMatcher, dynamicTokensEnabled) { + return 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 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; +}(); + +/** + * 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; + } +} +/** + * 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; + } +} +function addTerminalToCst(node, token, tokenTypeName) { + if (node.children[tokenTypeName] === undefined) { + node.children[tokenTypeName] = [token]; + } else { + node.children[tokenTypeName].push(token); + } +} +function addNoneTerminalToCst(node, ruleName, ruleResult) { + if (node.children[ruleName] === undefined) { + node.children[ruleName] = [ruleResult]; + } else { + node.children[ruleName].push(ruleResult); + } +} + +function classNameFromInstance(instance) { + return functionName(instance.constructor); +} +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; +} +/** + * @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 (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; +} + +function defaultVisit(ctx, param) { + var childrenNames = 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) { + this[currChild.name](currChild.children, param); + } + } + } // defaultVisit does not support generic out param + + + return undefined; +} +function createBaseSemanticVisitorConstructor(grammarName, ruleNames) { + var derivedConstructor = function derivedConstructor() {}; // 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 + + + defineNameProp(derivedConstructor, grammarName + "BaseSemantics"); + var semanticProto = { + visit: function visit(cstNode, param) { + // enables writing more concise visitor methods when CstNode has only a single child + if (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 (isUndefined(cstNode)) { + return undefined; + } + + return this[cstNode.name](cstNode.children, param); + }, + validateVisitor: function validateVisitor() { + var semanticDefinitionErrors = _validateVisitor(this, ruleNames); + + if (!isEmpty(semanticDefinitionErrors)) { + var errorMessages = map(semanticDefinitionErrors, function (currDefError) { + return currDefError.msg; + }); + throw Error("Errors Detected in CST Visitor <" + 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; +} +function createBaseVisitorConstructorWithDefaults(grammarName, ruleNames, baseConstructor) { + var derivedConstructor = function derivedConstructor() {}; // 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 + + + defineNameProp(derivedConstructor, grammarName + "BaseSemanticsWithDefaults"); + var withDefaultsProto = Object.create(baseConstructor.prototype); + forEach(ruleNames, function (ruleName) { + withDefaultsProto[ruleName] = defaultVisit; + }); + derivedConstructor.prototype = withDefaultsProto; + derivedConstructor.prototype.constructor = derivedConstructor; + return derivedConstructor; +} +var CstVisitorDefinitionError; + +(function (CstVisitorDefinitionError) { + CstVisitorDefinitionError[CstVisitorDefinitionError["REDUNDANT_METHOD"] = 0] = "REDUNDANT_METHOD"; + CstVisitorDefinitionError[CstVisitorDefinitionError["MISSING_METHOD"] = 1] = "MISSING_METHOD"; +})(CstVisitorDefinitionError || (CstVisitorDefinitionError = {})); + +function _validateVisitor(visitorInstance, ruleNames) { + var missingErrors = validateMissingCstMethods(visitorInstance, ruleNames); + var redundantErrors = validateRedundantMethods(visitorInstance, ruleNames); + return missingErrors.concat(redundantErrors); +} +function validateMissingCstMethods(visitorInstance, ruleNames) { + var errors = map(ruleNames, function (currRuleName) { + if (!isFunction(visitorInstance[currRuleName])) { + return { + msg: "Missing visitor method: <" + currRuleName + "> on " + functionName(visitorInstance.constructor) + " CST Visitor.", + type: CstVisitorDefinitionError.MISSING_METHOD, + methodName: currRuleName + }; + } + }); + return compact(errors); +} +var VALID_PROP_NAMES = ["constructor", "visit", "validateVisitor"]; +function validateRedundantMethods(visitorInstance, ruleNames) { + var errors = []; + + for (var prop in visitorInstance) { + if (validTermsPattern.test(prop) && isFunction(visitorInstance[prop]) && !contains(VALID_PROP_NAMES, prop) && !contains(ruleNames, prop)) { + errors.push({ + msg: "Redundant visitor method: <" + prop + "> on " + 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 /" + validTermsPattern.source + "/."), + type: CstVisitorDefinitionError.REDUNDANT_METHOD, + methodName: prop + }); + } + } + + return errors; +} + +/** + * This trait is responsible for the CST building logic. + */ + +var TreeBuilder = +/** @class */ +function () { + function TreeBuilder() {} + + TreeBuilder.prototype.initTreeBuilder = function (config) { + this.CST_STACK = []; // outputCst is no longer exposed/defined in the pubic API + + this.outputCst = config.outputCst; + this.nodeLocationTracking = has(config, "nodeLocationTracking") ? config.nodeLocationTracking : DEFAULT_PARSER_CONFIG.nodeLocationTracking; + + if (!this.outputCst) { + this.cstInvocationStateUpdate = NOOP; + this.cstFinallyStateUpdate = NOOP; + this.cstPostTerminal = NOOP; + this.cstPostNonTerminal = NOOP; + this.cstPostRule = NOOP; + } else { + if (/full/i.test(this.nodeLocationTracking)) { + if (this.recoveryEnabled) { + this.setNodeLocationFromToken = setNodeLocationFull; + this.setNodeLocationFromNode = setNodeLocationFull; + this.cstPostRule = NOOP; + this.setInitialNodeLocation = this.setInitialNodeLocationFullRecovery; + } else { + this.setNodeLocationFromToken = NOOP; + this.setNodeLocationFromNode = NOOP; + this.cstPostRule = this.cstPostRuleFull; + this.setInitialNodeLocation = this.setInitialNodeLocationFullRegular; + } + } else if (/onlyOffset/i.test(this.nodeLocationTracking)) { + if (this.recoveryEnabled) { + this.setNodeLocationFromToken = setNodeLocationOnlyOffset; + this.setNodeLocationFromNode = setNodeLocationOnlyOffset; + this.cstPostRule = NOOP; + this.setInitialNodeLocation = this.setInitialNodeLocationOnlyOffsetRecovery; + } else { + this.setNodeLocationFromToken = NOOP; + this.setNodeLocationFromNode = NOOP; + this.cstPostRule = this.cstPostRuleOnlyOffset; + this.setInitialNodeLocation = this.setInitialNodeLocationOnlyOffsetRegular; + } + } else if (/none/i.test(this.nodeLocationTracking)) { + this.setNodeLocationFromToken = NOOP; + this.setNodeLocationFromNode = NOOP; + this.cstPostRule = NOOP; + this.setInitialNodeLocation = 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 + }; + }; + + TreeBuilder.prototype.cstInvocationStateUpdate = function (fullRuleName, shortName) { + var cstNode = { + name: fullRuleName, + children: {} + }; + this.setInitialNodeLocation(cstNode); + this.CST_STACK.push(cstNode); + }; + + TreeBuilder.prototype.cstFinallyStateUpdate = function () { + this.CST_STACK.pop(); + }; + + 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. + + 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. + + 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]; + 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) { + var preCstNode = this.CST_STACK[this.CST_STACK.length - 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 (isUndefined(this.baseCstVisitorConstructor)) { + var newBaseCstVisitorConstructor = createBaseSemanticVisitorConstructor(this.className, keys(this.gastProductionsCache)); + this.baseCstVisitorConstructor = newBaseCstVisitorConstructor; + return newBaseCstVisitorConstructor; + } + + return this.baseCstVisitorConstructor; + }; + + TreeBuilder.prototype.getBaseCstVisitorConstructorWithDefaults = function () { + if (isUndefined(this.baseCstVisitorWithDefaultsConstructor)) { + var newConstructor = createBaseVisitorConstructorWithDefaults(this.className, keys(this.gastProductionsCache), this.getBaseCstVisitorConstructor()); + this.baseCstVisitorWithDefaultsConstructor = newConstructor; + return newConstructor; + } + + return this.baseCstVisitorWithDefaultsConstructor; + }; + + TreeBuilder.prototype.getLastExplicitRuleShortName = function () { + var ruleStack = this.RULE_STACK; + return ruleStack[ruleStack.length - 1]; + }; + + TreeBuilder.prototype.getPreviousExplicitRuleShortName = function () { + var ruleStack = this.RULE_STACK; + return ruleStack[ruleStack.length - 2]; + }; + + TreeBuilder.prototype.getLastExplicitRuleOccurrenceIndex = function () { + var occurrenceStack = this.RULE_OCCURRENCE_STACK; + return occurrenceStack[occurrenceStack.length - 1]; + }; + + return TreeBuilder; +}(); + +/** + * 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 get() { + return this.tokVector; + }, + set: function set(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 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 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; +}(); + +/** + * 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 = DEFAULT_RULE_CONFIG; + } + + if (contains(this.definedRulesNames, name)) { + var errMsg = defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({ + topLevelRule: name, + grammarName: this.className + }); + var error = { + message: errMsg, + type: 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 = DEFAULT_RULE_CONFIG; + } + + var ruleErrors = []; + ruleErrors = ruleErrors.concat(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 (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 serializeGrammar(values(this.gastProductionsCache)); + }; + + return RecognizerApi; +}(); + +/** + * 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 = 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 = tokenStructuredMatcherNoCategories; + this.definedRulesNames = []; + this.tokensMap = {}; + this.isBackTrackingStack = []; + this.RULE_STACK = []; + this.RULE_OCCURRENCE_STACK = []; + this.gastProductionsCache = {}; + + if (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 (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 (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 (isArray(tokenVocabulary)) { + this.tokensMap = reduce(tokenVocabulary, function (acc, tokType) { + acc[tokType.name] = tokType; + return acc; + }, {}); + } else if (has(tokenVocabulary, "modes") && every(flatten(values(tokenVocabulary.modes)), isTokenType)) { + var allTokenTypes = flatten(values(tokenVocabulary.modes)); + var uniqueTokens = uniq(allTokenTypes); + this.tokensMap = reduce(uniqueTokens, function (acc, tokType) { + acc[tokType.name] = tokType; + return acc; + }, {}); + } else if (isObject(tokenVocabulary)) { + this.tokensMap = 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"] = EOF; // TODO: This check may not be accurate for multi mode lexers + + var noTokenCategoriesUsed = every(values(tokenVocabulary), function (tokenConstructor) { + return isEmpty(tokenConstructor.categoryMatches); + }); + this.tokenMatcher = noTokenCategoriesUsed ? tokenStructuredMatcherNoCategories : 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 + + augmentTokenTypes(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 = has(config, "resyncEnabled") ? config.resyncEnabled : DEFAULT_RULE_CONFIG.resyncEnabled; + var recoveryValueFunc = has(config, "recoveryValueFunc") ? config.recoveryValueFunc : 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 << BITS_FOR_METHOD_TYPE + 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 wrappedGrammarRule(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 (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(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 lookAheadFunc() { + 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(AT_LEAST_ONE_IDX, prodOccurrence); + return this.atLeastOneInternalLogic(prodOccurrence, actionORMethodDef, laKey); + }; + + 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 lookAheadFunc() { + 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, 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, AT_LEAST_ONE_IDX, prodOccurrence, NextTerminalAfterAtLeastOneWalker); + }; + + RecognizerEngine.prototype.atLeastOneSepFirstInternal = function (prodOccurrence, options) { + var laKey = this.getKeyForAutomaticLookahead(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 separatorLookAheadFunc() { + 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, NextTerminalAfterAtLeastOneSepWalker], separatorLookAheadFunc, AT_LEAST_ONE_SEP_IDX, prodOccurrence, NextTerminalAfterAtLeastOneSepWalker); + } else { + throw this.raiseEarlyExitException(prodOccurrence, PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR, options.ERR_MSG); + } + }; + + RecognizerEngine.prototype.manyInternal = function (prodOccurrence, actionORMethodDef) { + var laKey = this.getKeyForAutomaticLookahead(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 lookaheadFunction() { + 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, MANY_IDX, prodOccurrence, 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(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 separatorLookAheadFunc() { + 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, NextTerminalAfterManySepWalker], separatorLookAheadFunc, MANY_SEP_IDX, prodOccurrence, 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, 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.orInternal = function (altsOrOpts, occurrence) { + var laKey = this.getKeyForAutomaticLookahead(OR_IDX, occurrence); + var alts = isArray(altsOrOpts) ? altsOrOpts : altsOrOpts.DEF; + 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.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 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 (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 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 === 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 = cloneArr(this.RULE_STACK); + return { + errors: savedErrors, + lexerState: this.exportLexerState(), + RULE_STACK: savedRuleStack, + CST_STACK: this.CST_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), EOF); + }; + + RecognizerEngine.prototype.reset = function () { + this.resetLexerState(); + this.isBackTrackingStack = []; + this.errors = []; + this.RULE_STACK = []; // TODO: extract a specific reset for TreeBuilder trait + + this.CST_STACK = []; + this.RULE_OCCURRENCE_STACK = []; + }; + + return RecognizerEngine; +}(); + +/** + * Trait responsible for runtime parsing errors. + */ + +var ErrorHandler = +/** @class */ +function () { + function ErrorHandler() {} + + ErrorHandler.prototype.initErrorHandler = function (config) { + this._errors = []; + this.errorMessageProvider = has(config, "errorMessageProvider") ? config.errorMessageProvider : DEFAULT_PARSER_CONFIG.errorMessageProvider; + }; + + ErrorHandler.prototype.SAVE_ERROR = function (error) { + if (isRecognitionException(error)) { + error.context = { + ruleStack: this.getHumanReadableRuleStack(), + ruleOccurrenceStack: 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", { + get: function get() { + return cloneArr(this._errors); + }, + set: function set(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 = 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 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 = 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 NoViableAltException(errMsg, this.LA(1), previousToken)); + }; + + return ErrorHandler; +}(); + +var ContentAssist = +/** @class */ +function () { + function ContentAssist() {} + + ContentAssist.prototype.initContentAssist = function () {}; + + ContentAssist.prototype.computeContentAssist = function (startRuleName, precedingInput) { + var startRuleGast = this.gastProductionsCache[startRuleName]; + + if (isUndefined(startRuleGast)) { + throw Error("Rule ->" + startRuleName + "<- does not exist in this grammar."); + } + + return 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 = first(grammarPath.ruleStack); + var gastProductions = this.getGAstProductions(); + var topProduction = gastProductions[topRuleName]; + var nextPossibleTokenTypes = new NextAfterTokenWalker(topProduction, grammarPath).startWalking(); + return nextPossibleTokenTypes; + }; + + return ContentAssist; +}(); + +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, BITS_FOR_OCCURRENCE_IDX) - 1; +var RFT = createToken({ + name: "RECORDING_PHASE_TOKEN", + pattern: Lexer.NA +}); +augmentTokenTypes([RFT]); +var RECORDING_PHASE_TOKEN = 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 _loop_1(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 END_OF_FILE; + }; + + GastRecorder.prototype.topLevelRuleRecord = function (name, def) { + try { + var newTopLevelRule = new 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, Option, actionORMethodDef, occurrence); + }; + + GastRecorder.prototype.atLeastOneInternalRecord = function (occurrence, actionORMethodDef) { + recordProd.call(this, RepetitionMandatory, actionORMethodDef, occurrence); + }; + + GastRecorder.prototype.atLeastOneSepFirstInternalRecord = function (occurrence, options) { + recordProd.call(this, RepetitionMandatoryWithSeparator, options, occurrence, HANDLE_SEPARATOR); + }; + + GastRecorder.prototype.manyInternalRecord = function (occurrence, actionORMethodDef) { + recordProd.call(this, Repetition, actionORMethodDef, occurrence); + }; + + GastRecorder.prototype.manySepFirstInternalRecord = function (occurrence, options) { + recordProd.call(this, 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 || 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 = peek(this.recordingProdStack); + var ruleName = ruleToCall["ruleName"]; + var newNoneTerminal = new 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 (!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 = peek(this.recordingProdStack); + var newNoneTerminal = new Terminal({ + idx: occurrence, + terminalType: tokType + }); + prevProd.definition.push(newNoneTerminal); + return RECORDING_PHASE_TOKEN; + }; + + return GastRecorder; +}(); + +function recordProd(prodConstructor, mainProdArg, occurrence, handleSep) { + if (handleSep === void 0) { + handleSep = false; + } + + assertMethodIdxIsValid(occurrence); + var prevProd = peek(this.recordingProdStack); + var grammarAction = isFunction(mainProdArg) ? mainProdArg : mainProdArg.DEF; + var newProd = new prodConstructor({ + definition: [], + idx: occurrence + }); + + if (handleSep) { + newProd.separator = mainProdArg.SEP; + } + + if (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 = peek(this.recordingProdStack); // Only an array of alternatives + + var hasOptions = isArray(mainProdArg) === false; + var alts = hasOptions === false ? mainProdArg : mainProdArg.DEF; + var newOrProd = new Alternation({ + definition: [], + idx: occurrence, + ignoreAmbiguities: hasOptions && mainProdArg.IGNORE_AMBIGUITIES === true + }); + + if (has(mainProdArg, "MAX_LOOKAHEAD")) { + newOrProd.maxLookahead = mainProdArg.MAX_LOOKAHEAD; + } + + var hasPredicates = some(alts, function (currAlt) { + return isFunction(currAlt.GATE); + }); + newOrProd.hasPredicates = hasPredicates; + prevProd.definition.push(newOrProd); + forEach(alts, function (currAlt) { + var currAltFlat = new Alternative({ + definition: [] + }); + newOrProd.definition.push(currAltFlat); + + if (has(currAlt, "IGNORE_AMBIGUITIES")) { + currAltFlat.ignoreAmbiguities = currAlt.IGNORE_AMBIGUITIES; + } // **implicit** ignoreAmbiguities due to usage of gate + else if (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; + } +} + +/** + * Trait responsible for runtime parsing errors. + */ + +var PerformanceTracer = +/** @class */ +function () { + function PerformanceTracer() {} + + PerformanceTracer.prototype.initPerformanceTracer = function (config) { + if (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 = 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 = 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; +}(); + +var __extends$9 = undefined && undefined.__extends || function () { + var _extendStatics = function extendStatics(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 __()); + }; +}(); +var END_OF_FILE = createTokenInstance(EOF, "", NaN, NaN, NaN, NaN, NaN, NaN); +Object.freeze(END_OF_FILE); +var DEFAULT_PARSER_CONFIG = Object.freeze({ + recoveryEnabled: false, + maxLookahead: 3, + dynamicTokensEnabled: false, + outputCst: true, + errorMessageProvider: defaultParserErrorProvider, + nodeLocationTracking: "none", + traceInitPerf: false, + skipValidations: false +}); +var DEFAULT_RULE_CONFIG = Object.freeze({ + recoveryValueFunc: function recoveryValueFunc() { + 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["NO_NON_EMPTY_LOOKAHEAD"] = 10] = "NO_NON_EMPTY_LOOKAHEAD"; + ParserDefinitionErrorType[ParserDefinitionErrorType["AMBIGUOUS_PREFIX_ALTS"] = 11] = "AMBIGUOUS_PREFIX_ALTS"; + ParserDefinitionErrorType[ParserDefinitionErrorType["TOO_MANY_ALTS"] = 12] = "TOO_MANY_ALTS"; +})(ParserDefinitionErrorType || (ParserDefinitionErrorType = {})); + +var Parser = +/** @class */ +function () { + function Parser(tokenVocabulary, config) { + 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); + + if (has(config, "ignoredIssues")) { + throw new Error("The IParserConfig property has been deprecated.\n\t" + "Please use the flag on the relevant DSL method instead.\n\t" + "See: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\t" + "For further details."); + } + + this.skipValidations = has(config, "skipValidations") ? config.skipValidations : DEFAULT_PARSER_CONFIG.skipValidations; + } + /** + * @deprecated use the **instance** method with the same name instead + */ + + + Parser.performSelfAnalysis = function (parserInstance) { + throw Error("The **static** `performSelfAnalysis` method has been deprecated." + "\t\nUse the **instance** method with the same name instead."); + }; + + 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. + toFastProperties(_this); + }); + + _this.TRACE_INIT("Grammar Recording", function () { + try { + _this.enableRecording(); // Building the GAST + + + 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 = resolveGrammar$1({ + rules: 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 (isEmpty(resolverErrors) && _this.skipValidations === false) { + var validationErrors = validateGrammar$1({ + rules: values(_this.gastProductionsCache), + maxLookahead: _this.maxLookahead, + tokenTypes: values(_this.tokensMap), + errMsgProvider: 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 (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 = computeAllProdsFollows(values(_this.gastProductionsCache)); + _this.resyncFollows = allFollows; + }); + } + + _this.TRACE_INIT("ComputeLookaheadFunctions", function () { + _this.preComputeLookaheadFunctions(values(_this.gastProductionsCache)); + }); + } + + if (!Parser.DEFER_DEFINITION_ERRORS_HANDLING && !isEmpty(_this.definitionErrors)) { + defErrorsMsgs = 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; +}(); +applyMixins(Parser, [Recoverable, LooksAhead, TreeBuilder, LexerAdapter, RecognizerEngine, RecognizerApi, ErrorHandler, ContentAssist, GastRecorder, PerformanceTracer]); + +var CstParser = +/** @class */ +function (_super) { + __extends$9(CstParser, _super); + + function CstParser(tokenVocabulary, config) { + if (config === void 0) { + config = DEFAULT_PARSER_CONFIG; + } + + var _this = this; + + var configClone = cloneObj(config); + configClone.outputCst = true; + _this = _super.call(this, tokenVocabulary, configClone) || this; + return _this; + } + + return CstParser; +}(Parser); + +var EmbeddedActionsParser = +/** @class */ +function (_super) { + __extends$9(EmbeddedActionsParser, _super); + + function EmbeddedActionsParser(tokenVocabulary, config) { + if (config === void 0) { + config = DEFAULT_PARSER_CONFIG; + } + + var _this = this; + + var configClone = cloneObj(config); + configClone.outputCst = false; + _this = _super.call(this, tokenVocabulary, configClone) || this; + return _this; + } + + return EmbeddedActionsParser; +}(Parser); + +var NOOP$1 = Symbol("NOOP"); // basically continue + +var MATCH_ANY = Symbol("MATCH_ANY"); +var MATCH_WORD = Symbol("MATCH_WORD"); +var MATCH_TAG = Symbol("MATCH_TAG"); +var MATCH_METHOD = Symbol("MATCH_METHOD"); +var MATCH_END = Symbol("MATCH_END"); +var JMP = Symbol("JMP"); +var SPLIT = Symbol("SPLIT"); +var GLOBAL_SAVE = Symbol("GLOBAL_SAVE"); // Set global save value, if true saves results. + +var MATCH = Symbol("MATCH"); +var OGROUP = Symbol("OGROUP"); // open group + +var CGROUP = Symbol("CGROUP"); // close group + +var INCV = Symbol("INCV"); // increment a value, set to 0 by default + +var JMP_LT = Symbol("JMP_LT"); // jmp if a variable is less than value else continue + +var SPLIT_LT = Symbol("SPLIT_LT"); // split if a variable is less than value else continue + +var LOOKAHEAD = Symbol("LOOKAHEAD"); +var NEGATIVE_LOOKAHEAD = Symbol("NEGATIVE_LOOKAHEAD"); + +var StartOf = createToken({ + name: "StartOf", + pattern: /\^/ +}); +var EndOf = createToken({ + name: "EndOf", + pattern: /\$/ +}); +var Tag = createToken({ + name: "Tag", + pattern: /#([_-\w]|\\.)+/ +}); +var EscapedWord = createToken({ + name: "EscapedWord", + pattern: /\\[#@]([_-\w]|\\.)+/ +}); +var Word = createToken({ + name: "Word", + pattern: /([_-\w]|\\.)+/ +}); +var Method = createToken({ + name: "Method", + pattern: /@[_-\w]+/ +}); +var Question = createToken({ + name: "Question", + pattern: /\?/, + longer_alt: Word +}); +var Exclamation = createToken({ + name: "Exclamation", + pattern: /!/, + longer_alt: Word +}); +var Equals = createToken({ + name: "Equals", + pattern: /=/, + longer_alt: Word +}); +var Pound = createToken({ + name: "Pound", + pattern: /#/, + longer_alt: Tag +}); +var Dot = createToken({ + name: "Dot", + pattern: /\./, + longer_alt: Word +}); +var RegexP = createToken({ + name: "RegexP", + pattern: /\/.*?\// +}); +var Pipe = createToken({ + name: "Pipe", + pattern: /\|/ +}); +var Comma = createToken({ + name: "Comma", + pattern: /,/, + longer_alt: Word +}); +var Colon = createToken({ + name: "Colon", + pattern: /:/, + longer_alt: Word +}); +var Plus = createToken({ + name: "Plus", + pattern: /\+/ +}); +var Star = createToken({ + name: "Star", + pattern: /\*/ +}); +var Zero = createToken({ + name: "Zero", + pattern: /0/, + longer_alt: Word +}); +var PositiveInt = createToken({ + name: "PositiveInt", + pattern: /[1-9]\d*/, + longer_alt: Word +}); +var LParenthesis = createToken({ + name: "LParenthesis", + pattern: /\(/ +}); +var RParenthesis = createToken({ + name: "RParenthesis", + pattern: /\)/ +}); +var LCurly = createToken({ + name: "LCurly", + pattern: /\{/ +}); +var RCurly = createToken({ + name: "RCurly", + pattern: /\}/ +}); +var NamedGroupBegin = createToken({ + name: "NamedGroupBegin", + pattern: /P/, + longer_alt: Word +}); +var WhiteSpace = createToken({ + name: "WhiteSpace", + pattern: /\s+/, + group: Lexer.SKIPPED +}); +var allTokens = [NamedGroupBegin, NamedGroupEnd, WhiteSpace, StartOf, EndOf, Zero, PositiveInt, Dot, EscapedWord, Word, Method, Tag, Exclamation, Equals, Pound, Colon, Question, Plus, Star, Comma, Pipe, LParenthesis, RParenthesis, LCurly, RCurly]; // Notes or something like it, may not be accurate. +// (a|b) +// 0. split 1, 3 +// 1. char a +// 2. jmp 4 +// 3. char b +// 4. match +// +// (a|b|c) +// 0. split 1, 3, 5 +// 1. char a +// 2. jmp 7 +// 3. char b +// 4. jmp 7 +// 5. char c +// 6. match +// +// ((a|b)|c) +// 0. split 1, 6 +// 1. split 2, 4 +// 2. char a +// 3. jmp 7 +// 4. char b +// 5. jmp 7 +// 6. char c +// 7. match +// +// a{2} +// 0. noop +// 1. char a +// 2. incv i 1, def=0 +// 3. jmp_lt i 2 [0] +// +// a{2, 3} +// 0. noop +// 1. char a +// 2. incv i 1, def=0 +// 3. jmp_lt 0 i [2] +// 4. split_lt i 3 [0, 6] +// +// a{,3} +// 0. noop +// 1. char a +// 2. incv i 1, def=0 +// 3. split_lt i 3 [0, 5] +// +// a{3,} +// 0. noop +// 1. char a +// 2. incv i 1, def=0 +// 3. jmp_lt i 3 +// 4. split [0, 6] +// +// a(!b) +// 0. noop +// 1. char a +// 2. nlookahead prog // negative lookahead is a sub program +// 1. match b +// 2. match +// 2.1. if found stop, else continue at current sp +// + +var NLPMatchParser = /*#__PURE__*/function (_EmbeddedActionsParse) { + _inherits(NLPMatchParser, _EmbeddedActionsParse); + + var _super = _createSuper(NLPMatchParser); + + function NLPMatchParser() { + var _this; + + _classCallCheck(this, NLPMatchParser); + + _this = _super.call(this, allTokens); + /* + * '.' + * '^remind #Noun$' + * '\#Noun' -- escaped word containing # + * '(remind|#Noun)' + * '(remind+|#Noun)' + * '(remind|#Noun)+' + * '#Noun{2}' + * '#Noun?' + * '#Noun*' + * '(?:remind #Noun)' -- non capturing group + * '(?P#Noun)' + * '(?P#Noun)+' + * + * matchStatement ([startOf] valueStatement [endOf]) + * valueStatement (value [...value]) + * rangeModifier (LCurly, ((PositiveInt|Zero) [, PositiveInt]) RCurly) + * oneOrMore (Plus) + * zeroOrMore (Star) + * zeroOrOne (Question) + * valueModifier (oneOrMore, rangeModifier, zeroOrMore, zeroOrOne) + * value (dot, word, escapedWord, tag, Zero, PositiveInt, group)[valueModifier] + * namedGroupBegin: token pattern /\?P/ + * namedGroup (namedGroupBegin, Word, namedGroupEnd) + * nonCapturingGroup token pattern /\?:/ -- TODO: figure out how to escape these + * negativeGroup token patter /\?!/ + * groupModifier [namedGroup|nonCapturingGroup] + * group (LParent, [groupModifier], valueStatement|...), RParen) + * + */ + + var $ = _assertThisInitialized(_this); + + $.RULE("matchStatement", function () { + var matches = { + startOf: false, + prog: [], + endOf: false + }; + $.OPTION(function () { + $.CONSUME(StartOf); + matches.startOf = true; + }); // handle ^ startOf + + if (!matches.startOf) { + // .*? at the start when not ^ / startOf, don't save the matched + // values. + matches.prog.push({ + code: GLOBAL_SAVE, + value: false + }); + matches.prog.push({ + code: SPLIT, + locs: [4, 2] + }); + matches.prog.push({ + code: MATCH_ANY + }); + matches.prog.push({ + code: JMP, + loc: 1 + }); + matches.prog.push({ + code: GLOBAL_SAVE, + value: true + }); + } + + matches.groups = []; + $.SUBRULE($.valueStatement, { + ARGS: [matches.prog, matches.groups] + }); + $.OPTION1(function () { + $.CONSUME(EndOf); + matches.endOf = true; + }); // handle $ endOf + + $.ACTION(function () { + if (matches.endOf) { + matches.prog.push({ + code: MATCH_END + }); + } + + matches.prog.push({ + code: MATCH + }); + }); + return matches; + }); + $.RULE("valueStatement", function () { + var prog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var groups = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + var vars = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; + var inst = []; + $.AT_LEAST_ONE({ + DEF: function DEF() { + $.SUBRULE($.value, { + ARGS: [prog, groups, vars] + }); + } + }); + return inst; + }); + $.RULE("value", function () { + var prog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var groups = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + var vars = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; + var split = { + code: NOOP$1 + }; // save split for modifiers + + prog.push(split); + var start = prog.length; // save start for split jmp later + + $.OR([{ + ALT: function ALT() { + $.CONSUME(Dot); + prog.push({ + code: MATCH_ANY + }); + } + }, { + ALT: function ALT() { + prog.push({ + code: MATCH_WORD, + value: $.CONSUME(Word).image + }); + } + }, { + ALT: function ALT() { + var _$$CONSUME$image; + + prog.push({ + code: MATCH_WORD, + value: (_$$CONSUME$image = $.CONSUME(EscapedWord).image) === null || _$$CONSUME$image === void 0 ? void 0 : _$$CONSUME$image.substr(1) + }); + } + }, { + ALT: function ALT() { + var _$$CONSUME$image2; + + prog.push({ + code: MATCH_TAG, + value: (_$$CONSUME$image2 = $.CONSUME(Tag).image) === null || _$$CONSUME$image2 === void 0 ? void 0 : _$$CONSUME$image2.substr(1) + }); + } + }, { + ALT: function ALT() { + prog.push({ + code: MATCH_WORD, + value: $.CONSUME(Zero).image + }); + } + }, { + ALT: function ALT() { + prog.push({ + code: MATCH_WORD, + value: $.CONSUME(PositiveInt).image + }); + } + }, { + ALT: function ALT() { + var _$$CONSUME$image3; + + prog.push({ + code: MATCH_METHOD, + value: (_$$CONSUME$image3 = $.CONSUME(Method).image) === null || _$$CONSUME$image3 === void 0 ? void 0 : _$$CONSUME$image3.substr(1) + }); + } + }, { + ALT: function ALT() { + $.SUBRULE($.group, { + ARGS: [prog, groups, vars] + }); + } + }]); + $.OPTION(function () { + // TODO: could probably allow relative jmps to get rid of noop + var _$$SUBRULE = $.SUBRULE($.valueModifier), + type = _$$SUBRULE.type, + greedy = _$$SUBRULE.greedy, + min = _$$SUBRULE.min, + max = _$$SUBRULE.max; + + switch (type) { + case "ZERO_OR_ONE": + split.code = SPLIT; + split.locs = [start, prog.length]; + break; + + case "ZERO_OR_MORE": + prog.push({ + code: JMP, + loc: start - 1 + }); + split.code = SPLIT; + split.locs = [start, prog.length]; + break; + + case "ONE_OR_MORE": + prog.push({ + code: SPLIT, + locs: [start, prog.length + 1] + }); + + if (!greedy) { + prog[prog.length - 1].locs.reverse(); + } + + break; + + case "RANGE": + var varId = vars.length; + vars.push(varId); + prog.push({ + code: INCV, + varId: varId + }); // increment first + + var minInst = { + code: JMP_LT, + varId: varId, + value: min !== null && min !== void 0 ? min : 0, + loc: start + }; + var maxInst = null; + + if (min === max) { + // a{x} + if (min === 0) { + // a{0} skip matching, causes token to be ignored + split.code = JMP; + split.loc = prog.length; // next instruction + } else { + // a{x} + prog.push(minInst); + } + } else if ((min !== null && min !== void 0 ? min : 0) === 0 && max !== null) { + // a{,y} a{0,y} + split.code = SPLIT; + split.locs = [start, prog.length + 1]; + maxInst = { + code: SPLIT_LT, + varId: varId, + value: max, + locs: [start, prog.length + 1] + }; + prog.push(maxInst); + } else if (min !== null && max === null) { + // a{x,} + prog.push(minInst); + maxInst = { + code: SPLIT, + locs: [start, prog.length + 1] + }; + prog.push(maxInst); + } else { + // if (min !== null && max !== null) { + // a{x,y} + prog.push(minInst); + maxInst = { + code: SPLIT_LT, + varId: varId, + value: max, + locs: [start, prog.length + 1] + }; + prog.push(maxInst); + } + + if (!greedy) { + var _maxInst, _maxInst$locs; + + (_maxInst = maxInst) === null || _maxInst === void 0 ? void 0 : (_maxInst$locs = _maxInst.locs) === null || _maxInst$locs === void 0 ? void 0 : _maxInst$locs.reverse(); // reverse thread priority for greedy / non-greedy + } //{ code: SPLIT, locs: [ ] } + //prog.push({ code: SETV_ONCE, id: rid, value: 0 }); + //prog.push({ code: INCREMENT, id: rid, value: 1 }); + //prog.push({ code: JMP_IF_GTE, id: rid, value: 0 }); + + + break; + } + + if (!greedy) { + var _split$locs; + + split === null || split === void 0 ? void 0 : (_split$locs = split.locs) === null || _split$locs === void 0 ? void 0 : _split$locs.reverse(); + } + }); + }); + $.RULE("valueModifier", function () { + var result = { + type: null, + greedy: true + }; + $.OR([{ + ALT: function ALT() { + $.CONSUME(Question); + result.type = "ZERO_OR_ONE"; + } + }, { + ALT: function ALT() { + $.CONSUME(Star); + result.type = "ZERO_OR_MORE"; + } + }, { + ALT: function ALT() { + $.CONSUME(Plus); + result.type = "ONE_OR_MORE"; + } + }, { + ALT: function ALT() { + var _$$SUBRULE2 = $.SUBRULE($.rangeModifier), + min = _$$SUBRULE2.min, + max = _$$SUBRULE2.max; + + $.ACTION(function () { + result.type = "RANGE"; + result.min = min; + result.max = max; + }); + } + }]); + $.OPTION(function () { + $.CONSUME1(Question); + $.ACTION(function () { + result.greedy = false; + }); + }); + return result; + }); + $.RULE("rangeModifier", function () { + var range = { + min: null, + max: null + }; + $.CONSUME(LCurly); // {x} + + $.OPTION(function () { + $.OR([{ + ALT: function ALT() { + range.min = $.CONSUME(Zero).image; + } + }, { + ALT: function ALT() { + range.min = $.CONSUME(PositiveInt).image; + } + }]); + }); // {x} + + range.max = range.min; + $.OPTION1(function () { + $.CONSUME(Comma); // {x,} + + range.max = null; // {,x} {x,}, {x,y} + + $.OPTION2(function () { + range.max = $.CONSUME1(PositiveInt).image; + }); + }); + $.ACTION(function () { + if (range.min) { + range.min = parseInt(range.min); + } + + if (range.max) { + range.max = parseInt(range.max); + } + + var min = range.min, + max = range.max; + + if (min && max && min > max) { + throw new Error("Range min(".concat(min, ") must be greater than max(").concat(max, ").")); + } + + if (min === null && max === null) { + throw new Error("Range min or max must be defined."); + } + }); + $.CONSUME(RCurly); + return range; + }); + $.RULE("group", function () { + var prog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var groups = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + var vars = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; + var modifiers = { + capture: true, + name: null, + lookahead: false, + negative: false + }; + $.CONSUME(LParenthesis); + $.OPTION(function () { + modifiers = $.SUBRULE($.groupModifier); + }); + var oProg = null; + + if (modifiers.lookahead) { + // part 1, see finish at end + modifiers.capture = false; + oProg = prog; + prog = []; + } + + var gId = groups.length; + + if (modifiers.capture) { + groups.push(modifiers); + prog.push({ + code: OGROUP, + id: gId, + name: modifiers.name + }); + } + + var split = { + code: SPLIT, + locs: [] + }; + prog.push(split); + var jmps = []; + $.AT_LEAST_ONE_SEP({ + SEP: Pipe, + DEF: function DEF() { + split.locs.push(prog.length); + $.SUBRULE($.valueStatement, { + ARGS: [prog, groups, vars] + }); + var jmp = { + code: JMP, + loc: null + }; + jmps.push(jmp); + prog.push(jmp); + } + }); // make split noop when just one in group + + if (split.locs.length === 1) { + split.code = NOOP$1; + delete split.locs; + } // remove last jmp so it continues + + + prog.pop(); // set jmps to end + + for (var _i = 0, _jmps = jmps; _i < _jmps.length; _i++) { + var jmp = _jmps[_i]; + jmp.loc = prog.length; + } // close the group if necessary as the last step + + + if (modifiers.capture) { + prog.push({ + code: CGROUP, + id: gId, + name: modifiers.name + }); + } + + if (modifiers.lookahead) { + prog.push({ + code: MATCH + }); + oProg.push({ + code: modifiers.negative ? NEGATIVE_LOOKAHEAD : LOOKAHEAD, + prog: prog + }); + } + + $.CONSUME(RParenthesis); + }); + $.RULE("namedGroup", function () { + $.CONSUME(Question); + $.CONSUME(NamedGroupBegin); + var name = $.CONSUME(Word).image; + $.CONSUME(NamedGroupEnd); + return name; + }); + $.RULE("nonCapturingGroup", function () { + $.CONSUME(Question); + $.CONSUME(Colon); + }); + $.RULE("negativeLookaheadGroup", function () { + $.CONSUME(Question); + $.CONSUME(Exclamation); + }); + $.RULE("positiveLookaheadGroup", function () { + $.CONSUME(Question); + $.CONSUME(Equals); + }); + $.RULE("commentGroup", function () { + $.CONSUME(Question); + $.CONSUME(Pound); + }); + $.RULE("groupModifier", function () { + var result = { + capture: true, + name: null, + lookahead: false, + negative: false, + comment: false + }; + $.OR([{ + ALT: function ALT() { + $.SUBRULE($.nonCapturingGroup); + result.capture = false; + } + }, { + ALT: function ALT() { + result.name = $.SUBRULE($.namedGroup); + } + }, { + ALT: function ALT() { + $.SUBRULE($.negativeLookaheadGroup); + result.capture = false; + result.lookahead = true; + result.negative = true; + } + }, { + ALT: function ALT() { + $.SUBRULE($.positiveLookaheadGroup); + result.capture = false; + result.lookahead = true; + result.negative = false; + } + } + /* + { ALT: () => { + $.SUBRULE($.commentGroup); + result.capture = false; + result.comment = true; + }} + */ + ]); + return result; + }); + + _this.performSelfAnalysis(); + + return _this; + } + + return NLPMatchParser; +}(EmbeddedActionsParser); + +var termContainsTag = function termContainsTag(term, name) { + var _term$tags; + + return Object.entries((_term$tags = term === null || term === void 0 ? void 0 : term.tags) !== null && _term$tags !== void 0 ? _term$tags : {}).filter(function (_ref) { + var _ref2 = _slicedToArray(_ref, 2), + k = _ref2[0], + v = _ref2[1]; + + return v; + }).map(function (entry) { + return entry[0].toLowerCase(); + }).includes(name.toLowerCase()); +}; +/** + * Helper function, create a thread + * Copies saved and groups.saved so that each thread contains its own + * independent saved values. + * + * Note: Using the { saved, groups } allows passing a thread which will cause + * its saved to be cloned. + * + * @param {int} pc - position of instance code to execute + * @param {*[]} saved - matched objects that were saved + * @param {object} groups - capture groups key of group id + * @returns {object} thread + */ + +var thread = function thread(pc) { + var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref3$save = _ref3.save, + save = _ref3$save === void 0 ? true : _ref3$save, + _ref3$saved = _ref3.saved, + saved = _ref3$saved === void 0 ? [] : _ref3$saved, + _ref3$groups = _ref3.groups, + groups = _ref3$groups === void 0 ? {} : _ref3$groups, + _ref3$vars = _ref3.vars, + vars = _ref3$vars === void 0 ? {} : _ref3$vars; + + var ngroups = Object.values(groups).reduce(function (ng, g) { + ng[g.id] = _objectSpread2(_objectSpread2({}, g), {}, { + saved: _toConsumableArray(g.saved) + }); + return ng; + }, {}); + return { + pc: pc, + save: save, + saved: _toConsumableArray(saved), + // clone groups.saved + groups: ngroups, + vars: _objectSpread2({}, vars) + }; +}; + +var addthread = function addthread(prog, list, th) { + var _th$vars$inst$varId, _th$vars; + + var inst = prog[th.pc]; //console.log("addthread:", th.pc); + //console.log(" inst:", inst); + + switch (inst.code) { + case GLOBAL_SAVE: + th.save = inst.value; + addthread(prog, list, thread(th.pc + 1, th)); + break; + + case NOOP$1: + addthread(prog, list, thread(th.pc + 1, th)); + break; + + case JMP: + addthread(prog, list, thread(inst.loc, th)); + break; + + case SPLIT: + var _iterator = _createForOfIteratorHelper(inst.locs), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var loc = _step.value; + addthread(prog, list, thread(loc, th)); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + break; + + case OGROUP: + // again (see below comment in pikevm match), can modify thread + // because it ends here + th.groups[inst.id] = { + id: inst.id, + name: inst.name, + saved: [], + open: true + }; + addthread(prog, list, thread(th.pc + 1, th)); + break; + + case CGROUP: + th.groups[inst.id].open = false; + addthread(prog, list, thread(th.pc + 1, th)); + break; + + case INCV: + th.vars[inst.varId] = ((_th$vars$inst$varId = (_th$vars = th.vars) === null || _th$vars === void 0 ? void 0 : _th$vars[inst.varId]) !== null && _th$vars$inst$varId !== void 0 ? _th$vars$inst$varId : 0) + 1; + addthread(prog, list, thread(th.pc + 1, th)); + break; + + case JMP_LT: + if (th.vars[inst.varId] < inst.value) { + // jump! + addthread(prog, list, thread(inst.loc, th)); + } else { + // continue + addthread(prog, list, thread(th.pc + 1, th)); + } + + break; + + case SPLIT_LT: + if (th.vars[inst.varId] < inst.value) { + // split! + var _iterator2 = _createForOfIteratorHelper(inst.locs), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _loc = _step2.value; + addthread(prog, list, thread(_loc, th)); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + } else { + // continue + addthread(prog, list, thread(th.pc + 1, th)); + } + + break; + + default: + list.push(th); + break; + } +}; +/** + * Save a match to a thread. + * Handles saving to open groups too + * @param {object} th - the thread + * @param {*] sp - the matched value to add + * @return {object} the thread th + */ + + +var saveMatch = function saveMatch(th, sp) { + if (!th.save) { + return th; + } + + var buckets = [th.saved].concat(_toConsumableArray(Object.values(th.groups).filter(function (g) { + return g.open; + }).map(function (g) { + return g.saved; + }))); + + var _iterator3 = _createForOfIteratorHelper(buckets), + _step3; + + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var saved = _step3.value; + saved.push(sp); + } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); + } + + return th; +}; +/** + * Simulate pike's vm, see https://swtch.com/~rsc/regexp/regexp2.html + * @param {object[]} inst - instructions to execute + * @param {object[]} input - input word w/ terms + * @returns true or false for match and saved matches + */ + + +var pikevm = function pikevm(prog, input) { + var _sp$text, _sp$inst$value; + var clist = []; + var nlist = []; + var found = false; + var groups = {}; + var saved = []; // helps with match end and also matches that end at exactly the end so that + // the match function gets a chance to run. + + var END = Symbol("END"); + input = [].concat(_toConsumableArray(input), [END]); + addthread(prog, clist, thread(0)); // and so we begin... + + for (var i = 0; i < input.length; i++) { + if (clist.length === 0) { + break; + } + + var sp = input[i]; + + for (var j = 0; j < clist.length; j++) { + // can probably convert to clist.shift as optimization + var th = clist[j]; + var inst = prog[th.pc]; //console.log("exec:", inst); + //console.log(` stack(${i}):`, clist); + + var gotoNextWord = false; + + switch (inst.code) { + case MATCH_ANY: + // Note: can call save match like this without worrying about other + // threads because this thread ends here and another will be created + // in its place + if (sp !== END) { + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + + break; + + case MATCH_WORD: + if ((sp === null || sp === void 0 ? void 0 : (_sp$text = sp.text) === null || _sp$text === void 0 ? void 0 : _sp$text.toLowerCase()) === inst.value.toLowerCase()) { + // continue on next word + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + + break; + + case MATCH_TAG: + if (termContainsTag(sp, inst.value)) { + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + + break; + + case MATCH_METHOD: + // call method using null coalescing on term, if it returns true continue + if (sp === null || sp === void 0 ? void 0 : (_sp$inst$value = sp[inst.value]) === null || _sp$inst$value === void 0 ? void 0 : _sp$inst$value.call(sp)) { + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + + break; + + case MATCH_END: + if (sp === END) { + // continue + addthread(prog, clist, thread(th.pc + 1, th)); + } + + break; + + case LOOKAHEAD: + var mla = pikevm(inst.prog, input.slice(i)); + + if (mla.found) { + addthread(prog, clist, thread(th.pc + 1, th)); + } + + break; + + case NEGATIVE_LOOKAHEAD: + var mnla = pikevm(inst.prog, input.slice(i)); + + if (!mnla.found) { + // continue at current position + // NOTE: this would be in addthread but we require access to input + addthread(prog, clist, thread(th.pc + 1, th)); + } + + break; + + case MATCH: + saved = th.saved; + groups = th.groups; + found = true; // Go to the next word which causes all pending threads in the + // current list (stack) to be cleared so we don't go down those + // paths. This allows for greedy and non-greedy matches to work. + + gotoNextWord = true; + break; + + default: + throw new Error("Unsuppored Op code: ".concat(inst.code)); + } + + if (gotoNextWord) { + break; // continue next iteration + } + } + + clist = nlist; + nlist = []; + } + + if (found) { + return { + found: found, + saved: saved, + groups: groups + }; + } + + return { + found: found + }; +}; + +var NLPMatchLexer = new Lexer(allTokens); +var parserInstance = new NLPMatchParser(); +var NLPRegexParseError = /*#__PURE__*/function () { + function NLPRegexParseError(errors) { + _classCallCheck(this, NLPRegexParseError); + + this.errors = errors; + } + + _createClass(NLPRegexParseError, [{ + key: "toString", + value: function toString() { + return "NLP RegexP Parsing error: ".concat(this.message); + } + }, { + key: "message", + get: function get() { + var _this$errors$; + + return (_this$errors$ = this.errors[0]) === null || _this$errors$ === void 0 ? void 0 : _this$errors$.message; + } + }]); + + return NLPRegexParseError; +}(); +/** + * Custom NLPRegexP class for regexp compile / cache. + */ + +var NLPRegexP = /*#__PURE__*/function () { + /** + * @param {string} regex - regular expression like string for matching nlp + * terms. + */ + function NLPRegexP(regex) { + _classCallCheck(this, NLPRegexP); + + if (regex === null || regex === void 0 ? void 0 : regex.prog) { + // take another NLPRegexP + this.regex = regex.regex; + this.prog = _toConsumableArray(regex.prog); + return; + } + + var _NLPMatchLexer$tokeni = NLPMatchLexer.tokenize(regex), + tokens = _NLPMatchLexer$tokeni.tokens; + + parserInstance.input = tokens; + var parsed = null; + + try { + parsed = parserInstance.matchStatement(); + } catch (e) { + // catch thrown error + throw new NLPRegexParseError([e]); + } + + if (parserInstance.errors.length > 0) { + throw new NLPRegexParseError(parserInstance.errors); + } + + this.regex = regex; + this.prog = parsed.prog; + } + + _createClass(NLPRegexP, [{ + key: "exec", + value: function exec(docOrPhrase) { + var _docOrPhrase$isA; + + switch (docOrPhrase === null || docOrPhrase === void 0 ? void 0 : (_docOrPhrase$isA = docOrPhrase.isA) === null || _docOrPhrase$isA === void 0 ? void 0 : _docOrPhrase$isA.toLowerCase()) { + case "doc": + return this.execDoc(docOrPhrase); + + case "phrase": + return this.execPhrase(docOrPhrase); + + default: + throw new Error("Invalid type, must be Document or Phrase"); + } + } + }, { + key: "execDoc", + value: function execDoc(doc) { + var _this = this; + + return doc.buildFrom(doc.list.map(function (phrase) { + return _this.execPhrase(phrase); + }).filter(function (p) { + return p !== null; + })); + } + }, { + key: "execPhrase", + value: function execPhrase(phrase) { + var _saved$; + + var _pikevm = pikevm(this.prog, phrase.terms()), + found = _pikevm.found, + _pikevm$saved = _pikevm.saved, + saved = _pikevm$saved === void 0 ? [] : _pikevm$saved, + _pikevm$groups = _pikevm.groups, + groups = _pikevm$groups === void 0 ? {} : _pikevm$groups; + + var namedGroups = Object.values(groups).reduce(function (arr, g) { + var _g$name, _g$saved$0$id, _g$saved$; + + return _objectSpread2(_objectSpread2({}, arr), {}, _defineProperty({}, parseInt(g.id), { + group: (_g$name = g === null || g === void 0 ? void 0 : g.name) !== null && _g$name !== void 0 ? _g$name : "".concat(g.id), + start: (_g$saved$0$id = (_g$saved$ = g.saved[0]) === null || _g$saved$ === void 0 ? void 0 : _g$saved$.id) !== null && _g$saved$0$id !== void 0 ? _g$saved$0$id : 0, + length: g.saved.length + })); + }, {}); + return found && (saved === null || saved === void 0 ? void 0 : (_saved$ = saved[0]) === null || _saved$ === void 0 ? void 0 : _saved$.id) ? phrase.buildFrom(saved[0].id, saved.length, namedGroups) : null; + } + }]); + + return NLPRegexP; +}(); + +var Match2Plugin = function Match2Plugin(Doc, world, nlp, Phrase) { + var compileRegex = function compileRegex(regex) { + return new NLPRegexP(regex); + }; + + nlp.compileRegex = compileRegex; + Doc.prototype.compileRegex = compileRegex; + + var match2 = function match2(regex) { + // function, non arrow, need bind for this which is doc/phrase + regex = new NLPRegexP(regex); // coerce the value + + return regex.exec(this); + }; + + Doc.prototype.match2 = match2; + Phrase.prototype.match2 = match2; +}; + +export default Match2Plugin; +export { Match2Plugin, NLPMatchParser, NLPRegexP, NLPRegexParseError }; diff --git a/plugins/match2/gen_diagram.js b/plugins/match2/gen_diagram.js new file mode 100644 index 000000000..4245ebc03 --- /dev/null +++ b/plugins/match2/gen_diagram.js @@ -0,0 +1,15 @@ +const path = require("path"); +const fs = require("fs"); +const chevrotain = require("chevrotain"); +const { NLPMatchParser } = require("./dist/compromise-match2"); + +// extract the serialized grammar. +const parserInstance = new NLPMatchParser(); +const serializedGrammar = parserInstance.getSerializedGastProductions(); + +// create the HTML Text +const htmlText = chevrotain.createSyntaxDiagramsCode(serializedGrammar); + +// Write the HTML file to disk +const outPath = path.resolve(__dirname, "./"); +fs.writeFileSync(outPath + "/generated_diagrams.html", htmlText); diff --git a/plugins/match2/generated_diagrams.html b/plugins/match2/generated_diagrams.html new file mode 100644 index 000000000..bad60eb2c --- /dev/null +++ b/plugins/match2/generated_diagrams.html @@ -0,0 +1,580 @@ + + + + + + + + + + + + + + +
+ + + + diff --git a/plugins/match2/package-lock.json b/plugins/match2/package-lock.json new file mode 100644 index 000000000..45dfd7d6e --- /dev/null +++ b/plugins/match2/package-lock.json @@ -0,0 +1,6975 @@ +{ + "name": "compromise-match2", + "version": "1.2.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", + "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.4" + } + }, + "@babel/compat-data": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.10.4.tgz", + "integrity": "sha512-t+rjExOrSVvjQQXNp5zAIYDp00KjdvGl/TpDX5REPr0S9IAIPQMTilcfG6q8c0QFmj9lSTVySV2VTsyggvtNIw==", + "dev": true, + "requires": { + "browserslist": "^4.12.0", + "invariant": "^2.2.4", + "semver": "^5.5.0" + } + }, + "@babel/core": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.10.4.tgz", + "integrity": "sha512-3A0tS0HWpy4XujGc7QtOIHTeNwUgWaZc/WuS5YQrfhU67jnVmsD6OGPc1AKHH0LJHQICGncy3+YUjIhVlfDdcA==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.4", + "@babel/generator": "^7.10.4", + "@babel/helper-module-transforms": "^7.10.4", + "@babel/helpers": "^7.10.4", + "@babel/parser": "^7.10.4", + "@babel/template": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.1", + "json5": "^2.1.2", + "lodash": "^4.17.13", + "resolve": "^1.3.2", + "semver": "^5.4.1", + "source-map": "^0.5.0" + } + }, + "@babel/generator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.4.tgz", + "integrity": "sha512-toLIHUIAgcQygFZRAQcsLQV3CBuX6yOIru1kJk/qqqvcRmZrYe6WavZTSG+bB8MxhnL9YPf+pKQfuiP161q7ng==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" + } + }, + "@babel/helper-annotate-as-pure": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.10.4.tgz", + "integrity": "sha512-XQlqKQP4vXFB7BN8fEEerrmYvHp3fK/rBkRFz9jaJbzK0B1DSfej9Kc7ZzE8Z/OnId1jpJdNAZ3BFQjWG68rcA==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-builder-binary-assignment-operator-visitor": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.10.4.tgz", + "integrity": "sha512-L0zGlFrGWZK4PbT8AszSfLTM5sDU1+Az/En9VrdT8/LmEiJt4zXt+Jve9DCAnQcbqDhCI+29y/L93mrDzddCcg==", + "dev": true, + "requires": { + "@babel/helper-explode-assignable-expression": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-compilation-targets": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.10.4.tgz", + "integrity": "sha512-a3rYhlsGV0UHNDvrtOXBg8/OpfV0OKTkxKPzIplS1zpx7CygDcWWxckxZeDd3gzPzC4kUT0A4nVFDK0wGMh4MQ==", + "dev": true, + "requires": { + "@babel/compat-data": "^7.10.4", + "browserslist": "^4.12.0", + "invariant": "^2.2.4", + "levenary": "^1.1.1", + "semver": "^5.5.0" + } + }, + "@babel/helper-create-class-features-plugin": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.10.4.tgz", + "integrity": "sha512-9raUiOsXPxzzLjCXeosApJItoMnX3uyT4QdM2UldffuGApNrF8e938MwNpDCK9CPoyxrEoCgT+hObJc3mZa6lQ==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.10.4", + "@babel/helper-member-expression-to-functions": "^7.10.4", + "@babel/helper-optimise-call-expression": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/helper-replace-supers": "^7.10.4", + "@babel/helper-split-export-declaration": "^7.10.4" + } + }, + "@babel/helper-create-regexp-features-plugin": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.10.4.tgz", + "integrity": "sha512-2/hu58IEPKeoLF45DBwx3XFqsbCXmkdAay4spVr2x0jYgRxrSNp+ePwvSsy9g6YSaNDcKIQVPXk1Ov8S2edk2g==", + "dev": true, + "requires": { + "@babel/helper-annotate-as-pure": "^7.10.4", + "@babel/helper-regex": "^7.10.4", + "regexpu-core": "^4.7.0" + } + }, + "@babel/helper-define-map": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-define-map/-/helper-define-map-7.10.4.tgz", + "integrity": "sha512-nIij0oKErfCnLUCWaCaHW0Bmtl2RO9cN7+u2QT8yqTywgALKlyUVOvHDElh+b5DwVC6YB1FOYFOTWcN/+41EDA==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.10.4", + "@babel/types": "^7.10.4", + "lodash": "^4.17.13" + } + }, + "@babel/helper-explode-assignable-expression": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.10.4.tgz", + "integrity": "sha512-4K71RyRQNPRrR85sr5QY4X3VwG4wtVoXZB9+L3r1Gp38DhELyHCtovqydRi7c1Ovb17eRGiQ/FD5s8JdU0Uy5A==", + "dev": true, + "requires": { + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-function-name": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz", + "integrity": "sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.10.4", + "@babel/template": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.4.tgz", + "integrity": "sha512-EkN3YDB+SRDgiIUnNgcmiD361ti+AVbL3f3Henf6dqqUyr5dMsorno0lJWJuLhDhkI5sYEpgj6y9kB8AOU1I2A==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-hoist-variables": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.10.4.tgz", + "integrity": "sha512-wljroF5PgCk2juF69kanHVs6vrLwIPNp6DLD+Lrl3hoQ3PpPPikaDRNFA+0t81NOoMt2DL6WW/mdU8k4k6ZzuA==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-member-expression-to-functions": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.4.tgz", + "integrity": "sha512-m5j85pK/KZhuSdM/8cHUABQTAslV47OjfIB9Cc7P+PvlAoBzdb79BGNfw8RhT5Mq3p+xGd0ZfAKixbrUZx0C7A==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-module-imports": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz", + "integrity": "sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-module-transforms": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.10.4.tgz", + "integrity": "sha512-Er2FQX0oa3nV7eM1o0tNCTx7izmQtwAQsIiaLRWtavAAEcskb0XJ5OjJbVrYXWOTr8om921Scabn4/tzlx7j1Q==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.10.4", + "@babel/helper-replace-supers": "^7.10.4", + "@babel/helper-simple-access": "^7.10.4", + "@babel/helper-split-export-declaration": "^7.10.4", + "@babel/template": "^7.10.4", + "@babel/types": "^7.10.4", + "lodash": "^4.17.13" + } + }, + "@babel/helper-optimise-call-expression": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.4.tgz", + "integrity": "sha512-n3UGKY4VXwXThEiKrgRAoVPBMqeoPgHVqiHZOanAJCG9nQUL2pLRQirUzl0ioKclHGpGqRgIOkgcIJaIWLpygg==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-plugin-utils": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz", + "integrity": "sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg==", + "dev": true + }, + "@babel/helper-regex": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-regex/-/helper-regex-7.10.4.tgz", + "integrity": "sha512-inWpnHGgtg5NOF0eyHlC0/74/VkdRITY9dtTpB2PrxKKn+AkVMRiZz/Adrx+Ssg+MLDesi2zohBW6MVq6b4pOQ==", + "dev": true, + "requires": { + "lodash": "^4.17.13" + } + }, + "@babel/helper-remap-async-to-generator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.10.4.tgz", + "integrity": "sha512-86Lsr6NNw3qTNl+TBcF1oRZMaVzJtbWTyTko+CQL/tvNvcGYEFKbLXDPxtW0HKk3McNOk4KzY55itGWCAGK5tg==", + "dev": true, + "requires": { + "@babel/helper-annotate-as-pure": "^7.10.4", + "@babel/helper-wrap-function": "^7.10.4", + "@babel/template": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-replace-supers": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.10.4.tgz", + "integrity": "sha512-sPxZfFXocEymYTdVK1UNmFPBN+Hv5mJkLPsYWwGBxZAxaWfFu+xqp7b6qWD0yjNuNL2VKc6L5M18tOXUP7NU0A==", + "dev": true, + "requires": { + "@babel/helper-member-expression-to-functions": "^7.10.4", + "@babel/helper-optimise-call-expression": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-simple-access": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.10.4.tgz", + "integrity": "sha512-0fMy72ej/VEvF8ULmX6yb5MtHG4uH4Dbd6I/aHDb/JVg0bbivwt9Wg+h3uMvX+QSFtwr5MeItvazbrc4jtRAXw==", + "dev": true, + "requires": { + "@babel/template": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.4.tgz", + "integrity": "sha512-pySBTeoUff56fL5CBU2hWm9TesA4r/rOkI9DyJLvvgz09MB9YtfIYe3iBriVaYNaPe+Alua0vBIOVOLs2buWhg==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz", + "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==", + "dev": true + }, + "@babel/helper-wrap-function": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.10.4.tgz", + "integrity": "sha512-6py45WvEF0MhiLrdxtRjKjufwLL1/ob2qDJgg5JgNdojBAZSAKnAjkyOCNug6n+OBl4VW76XjvgSFTdaMcW0Ug==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.10.4", + "@babel/template": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helpers": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.4.tgz", + "integrity": "sha512-L2gX/XeUONeEbI78dXSrJzGdz4GQ+ZTA/aazfUsFaWjSe95kiCuOZ5HsXvkiw3iwF+mFHSRUfJU8t6YavocdXA==", + "dev": true, + "requires": { + "@babel/template": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/highlight": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz", + "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.4", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.4.tgz", + "integrity": "sha512-8jHII4hf+YVDsskTF6WuMB3X4Eh+PsUkC2ljq22so5rHvH+T8BzyL94VOdyFLNR8tBSVXOTbNHOKpR4TfRxVtA==", + "dev": true + }, + "@babel/plugin-proposal-async-generator-functions": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.10.4.tgz", + "integrity": "sha512-MJbxGSmejEFVOANAezdO39SObkURO5o/8b6fSH6D1pi9RZQt+ldppKPXfqgUWpSQ9asM6xaSaSJIaeWMDRP0Zg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/helper-remap-async-to-generator": "^7.10.4", + "@babel/plugin-syntax-async-generators": "^7.8.0" + } + }, + "@babel/plugin-proposal-class-properties": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.10.4.tgz", + "integrity": "sha512-vhwkEROxzcHGNu2mzUC0OFFNXdZ4M23ib8aRRcJSsW8BZK9pQMD7QB7csl97NBbgGZO7ZyHUyKDnxzOaP4IrCg==", + "dev": true, + "requires": { + "@babel/helper-create-class-features-plugin": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-proposal-dynamic-import": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.10.4.tgz", + "integrity": "sha512-up6oID1LeidOOASNXgv/CFbgBqTuKJ0cJjz6An5tWD+NVBNlp3VNSBxv2ZdU7SYl3NxJC7agAQDApZusV6uFwQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/plugin-syntax-dynamic-import": "^7.8.0" + } + }, + "@babel/plugin-proposal-json-strings": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.10.4.tgz", + "integrity": "sha512-fCL7QF0Jo83uy1K0P2YXrfX11tj3lkpN7l4dMv9Y9VkowkhkQDwFHFd8IiwyK5MZjE8UpbgokkgtcReH88Abaw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/plugin-syntax-json-strings": "^7.8.0" + } + }, + "@babel/plugin-proposal-nullish-coalescing-operator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.10.4.tgz", + "integrity": "sha512-wq5n1M3ZUlHl9sqT2ok1T2/MTt6AXE0e1Lz4WzWBr95LsAZ5qDXe4KnFuauYyEyLiohvXFMdbsOTMyLZs91Zlw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.0" + } + }, + "@babel/plugin-proposal-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.10.4.tgz", + "integrity": "sha512-73/G7QoRoeNkLZFxsoCCvlg4ezE4eM+57PnOqgaPOozd5myfj7p0muD1mRVJvbUWbOzD+q3No2bWbaKy+DJ8DA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/plugin-syntax-numeric-separator": "^7.10.4" + } + }, + "@babel/plugin-proposal-object-rest-spread": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.10.4.tgz", + "integrity": "sha512-6vh4SqRuLLarjgeOf4EaROJAHjvu9Gl+/346PbDH9yWbJyfnJ/ah3jmYKYtswEyCoWZiidvVHjHshd4WgjB9BA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/plugin-syntax-object-rest-spread": "^7.8.0", + "@babel/plugin-transform-parameters": "^7.10.4" + } + }, + "@babel/plugin-proposal-optional-catch-binding": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.10.4.tgz", + "integrity": "sha512-LflT6nPh+GK2MnFiKDyLiqSqVHkQnVf7hdoAvyTnnKj9xB3docGRsdPuxp6qqqW19ifK3xgc9U5/FwrSaCNX5g==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.0" + } + }, + "@babel/plugin-proposal-optional-chaining": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.10.4.tgz", + "integrity": "sha512-ZIhQIEeavTgouyMSdZRap4VPPHqJJ3NEs2cuHs5p0erH+iz6khB0qfgU8g7UuJkG88+fBMy23ZiU+nuHvekJeQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/plugin-syntax-optional-chaining": "^7.8.0" + } + }, + "@babel/plugin-proposal-private-methods": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.10.4.tgz", + "integrity": "sha512-wh5GJleuI8k3emgTg5KkJK6kHNsGEr0uBTDBuQUBJwckk9xs1ez79ioheEVVxMLyPscB0LfkbVHslQqIzWV6Bw==", + "dev": true, + "requires": { + "@babel/helper-create-class-features-plugin": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-proposal-unicode-property-regex": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.10.4.tgz", + "integrity": "sha512-H+3fOgPnEXFL9zGYtKQe4IDOPKYlZdF1kqFDQRRb8PK4B8af1vAGK04tF5iQAAsui+mHNBQSAtd2/ndEDe9wuA==", + "dev": true, + "requires": { + "@babel/helper-create-regexp-features-plugin": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-class-properties": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.10.4.tgz", + "integrity": "sha512-GCSBF7iUle6rNugfURwNmCGG3Z/2+opxAMLs1nND4bhEG5PuxTIggDBoeYYSujAlLtsupzOHYJQgPS3pivwXIA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-syntax-dynamic-import": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz", + "integrity": "sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-top-level-await": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.10.4.tgz", + "integrity": "sha512-ni1brg4lXEmWyafKr0ccFWkJG0CeMt4WV1oyeBW6EFObF4oOHclbkj5cARxAPQyAQ2UTuplJyK4nfkXIMMFvsQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-arrow-functions": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.10.4.tgz", + "integrity": "sha512-9J/oD1jV0ZCBcgnoFWFq1vJd4msoKb/TCpGNFyyLt0zABdcvgK3aYikZ8HjzB14c26bc7E3Q1yugpwGy2aTPNA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-async-to-generator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.10.4.tgz", + "integrity": "sha512-F6nREOan7J5UXTLsDsZG3DXmZSVofr2tGNwfdrVwkDWHfQckbQXnXSPfD7iO+c/2HGqycwyLST3DnZ16n+cBJQ==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/helper-remap-async-to-generator": "^7.10.4" + } + }, + "@babel/plugin-transform-block-scoped-functions": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.10.4.tgz", + "integrity": "sha512-WzXDarQXYYfjaV1szJvN3AD7rZgZzC1JtjJZ8dMHUyiK8mxPRahynp14zzNjU3VkPqPsO38CzxiWO1c9ARZ8JA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-block-scoping": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.10.4.tgz", + "integrity": "sha512-J3b5CluMg3hPUii2onJDRiaVbPtKFPLEaV5dOPY5OeAbDi1iU/UbbFFTgwb7WnanaDy7bjU35kc26W3eM5Qa0A==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4", + "lodash": "^4.17.13" + } + }, + "@babel/plugin-transform-classes": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.10.4.tgz", + "integrity": "sha512-2oZ9qLjt161dn1ZE0Ms66xBncQH4In8Sqw1YWgBUZuGVJJS5c0OFZXL6dP2MRHrkU/eKhWg8CzFJhRQl50rQxA==", + "dev": true, + "requires": { + "@babel/helper-annotate-as-pure": "^7.10.4", + "@babel/helper-define-map": "^7.10.4", + "@babel/helper-function-name": "^7.10.4", + "@babel/helper-optimise-call-expression": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/helper-replace-supers": "^7.10.4", + "@babel/helper-split-export-declaration": "^7.10.4", + "globals": "^11.1.0" + } + }, + "@babel/plugin-transform-computed-properties": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.10.4.tgz", + "integrity": "sha512-JFwVDXcP/hM/TbyzGq3l/XWGut7p46Z3QvqFMXTfk6/09m7xZHJUN9xHfsv7vqqD4YnfI5ueYdSJtXqqBLyjBw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-destructuring": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.10.4.tgz", + "integrity": "sha512-+WmfvyfsyF603iPa6825mq6Qrb7uLjTOsa3XOFzlYcYDHSS4QmpOWOL0NNBY5qMbvrcf3tq0Cw+v4lxswOBpgA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-dotall-regex": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.10.4.tgz", + "integrity": "sha512-ZEAVvUTCMlMFAbASYSVQoxIbHm2OkG2MseW6bV2JjIygOjdVv8tuxrCTzj1+Rynh7ODb8GivUy7dzEXzEhuPaA==", + "dev": true, + "requires": { + "@babel/helper-create-regexp-features-plugin": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-duplicate-keys": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.10.4.tgz", + "integrity": "sha512-GL0/fJnmgMclHiBTTWXNlYjYsA7rDrtsazHG6mglaGSTh0KsrW04qml+Bbz9FL0LcJIRwBWL5ZqlNHKTkU3xAA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-exponentiation-operator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.10.4.tgz", + "integrity": "sha512-S5HgLVgkBcRdyQAHbKj+7KyuWx8C6t5oETmUuwz1pt3WTWJhsUV0WIIXuVvfXMxl/QQyHKlSCNNtaIamG8fysw==", + "dev": true, + "requires": { + "@babel/helper-builder-binary-assignment-operator-visitor": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-for-of": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.10.4.tgz", + "integrity": "sha512-ItdQfAzu9AlEqmusA/65TqJ79eRcgGmpPPFvBnGILXZH975G0LNjP1yjHvGgfuCxqrPPueXOPe+FsvxmxKiHHQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-function-name": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.10.4.tgz", + "integrity": "sha512-OcDCq2y5+E0dVD5MagT5X+yTRbcvFjDI2ZVAottGH6tzqjx/LKpgkUepu3hp/u4tZBzxxpNGwLsAvGBvQ2mJzg==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-literals": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.10.4.tgz", + "integrity": "sha512-Xd/dFSTEVuUWnyZiMu76/InZxLTYilOSr1UlHV+p115Z/Le2Fi1KXkJUYz0b42DfndostYlPub3m8ZTQlMaiqQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-member-expression-literals": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.10.4.tgz", + "integrity": "sha512-0bFOvPyAoTBhtcJLr9VcwZqKmSjFml1iVxvPL0ReomGU53CX53HsM4h2SzckNdkQcHox1bpAqzxBI1Y09LlBSw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-modules-amd": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.10.4.tgz", + "integrity": "sha512-3Fw+H3WLUrTlzi3zMiZWp3AR4xadAEMv6XRCYnd5jAlLM61Rn+CRJaZMaNvIpcJpQ3vs1kyifYvEVPFfoSkKOA==", + "dev": true, + "requires": { + "@babel/helper-module-transforms": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4", + "babel-plugin-dynamic-import-node": "^2.3.3" + } + }, + "@babel/plugin-transform-modules-commonjs": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.10.4.tgz", + "integrity": "sha512-Xj7Uq5o80HDLlW64rVfDBhao6OX89HKUmb+9vWYaLXBZOma4gA6tw4Ni1O5qVDoZWUV0fxMYA0aYzOawz0l+1w==", + "dev": true, + "requires": { + "@babel/helper-module-transforms": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/helper-simple-access": "^7.10.4", + "babel-plugin-dynamic-import-node": "^2.3.3" + } + }, + "@babel/plugin-transform-modules-systemjs": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.10.4.tgz", + "integrity": "sha512-Tb28LlfxrTiOTGtZFsvkjpyjCl9IoaRI52AEU/VIwOwvDQWtbNJsAqTXzh+5R7i74e/OZHH2c2w2fsOqAfnQYQ==", + "dev": true, + "requires": { + "@babel/helper-hoist-variables": "^7.10.4", + "@babel/helper-module-transforms": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4", + "babel-plugin-dynamic-import-node": "^2.3.3" + } + }, + "@babel/plugin-transform-modules-umd": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.10.4.tgz", + "integrity": "sha512-mohW5q3uAEt8T45YT7Qc5ws6mWgJAaL/8BfWD9Dodo1A3RKWli8wTS+WiQ/knF+tXlPirW/1/MqzzGfCExKECA==", + "dev": true, + "requires": { + "@babel/helper-module-transforms": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-named-capturing-groups-regex": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.10.4.tgz", + "integrity": "sha512-V6LuOnD31kTkxQPhKiVYzYC/Jgdq53irJC/xBSmqcNcqFGV+PER4l6rU5SH2Vl7bH9mLDHcc0+l9HUOe4RNGKA==", + "dev": true, + "requires": { + "@babel/helper-create-regexp-features-plugin": "^7.10.4" + } + }, + "@babel/plugin-transform-new-target": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.10.4.tgz", + "integrity": "sha512-YXwWUDAH/J6dlfwqlWsztI2Puz1NtUAubXhOPLQ5gjR/qmQ5U96DY4FQO8At33JN4XPBhrjB8I4eMmLROjjLjw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-object-super": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.10.4.tgz", + "integrity": "sha512-5iTw0JkdRdJvr7sY0vHqTpnruUpTea32JHmq/atIWqsnNussbRzjEDyWep8UNztt1B5IusBYg8Irb0bLbiEBCQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/helper-replace-supers": "^7.10.4" + } + }, + "@babel/plugin-transform-parameters": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.10.4.tgz", + "integrity": "sha512-RurVtZ/D5nYfEg0iVERXYKEgDFeesHrHfx8RT05Sq57ucj2eOYAP6eu5fynL4Adju4I/mP/I6SO0DqNWAXjfLQ==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-property-literals": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.10.4.tgz", + "integrity": "sha512-ofsAcKiUxQ8TY4sScgsGeR2vJIsfrzqvFb9GvJ5UdXDzl+MyYCaBj/FGzXuv7qE0aJcjWMILny1epqelnFlz8g==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-regenerator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.10.4.tgz", + "integrity": "sha512-3thAHwtor39A7C04XucbMg17RcZ3Qppfxr22wYzZNcVIkPHfpM9J0SO8zuCV6SZa265kxBJSrfKTvDCYqBFXGw==", + "dev": true, + "requires": { + "regenerator-transform": "^0.14.2" + } + }, + "@babel/plugin-transform-reserved-words": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.10.4.tgz", + "integrity": "sha512-hGsw1O6Rew1fkFbDImZIEqA8GoidwTAilwCyWqLBM9f+e/u/sQMQu7uX6dyokfOayRuuVfKOW4O7HvaBWM+JlQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-shorthand-properties": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.10.4.tgz", + "integrity": "sha512-AC2K/t7o07KeTIxMoHneyX90v3zkm5cjHJEokrPEAGEy3UCp8sLKfnfOIGdZ194fyN4wfX/zZUWT9trJZ0qc+Q==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-spread": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.10.4.tgz", + "integrity": "sha512-1e/51G/Ni+7uH5gktbWv+eCED9pP8ZpRhZB3jOaI3mmzfvJTWHkuyYTv0Z5PYtyM+Tr2Ccr9kUdQxn60fI5WuQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-sticky-regex": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.10.4.tgz", + "integrity": "sha512-Ddy3QZfIbEV0VYcVtFDCjeE4xwVTJWTmUtorAJkn6u/92Z/nWJNV+mILyqHKrUxXYKA2EoCilgoPePymKL4DvQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/helper-regex": "^7.10.4" + } + }, + "@babel/plugin-transform-template-literals": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.10.4.tgz", + "integrity": "sha512-4NErciJkAYe+xI5cqfS8pV/0ntlY5N5Ske/4ImxAVX7mk9Rxt2bwDTGv1Msc2BRJvWQcmYEC+yoMLdX22aE4VQ==", + "dev": true, + "requires": { + "@babel/helper-annotate-as-pure": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-typeof-symbol": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.10.4.tgz", + "integrity": "sha512-QqNgYwuuW0y0H+kUE/GWSR45t/ccRhe14Fs/4ZRouNNQsyd4o3PG4OtHiIrepbM2WKUBDAXKCAK/Lk4VhzTaGA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-unicode-escapes": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.10.4.tgz", + "integrity": "sha512-y5XJ9waMti2J+e7ij20e+aH+fho7Wb7W8rNuu72aKRwCHFqQdhkdU2lo3uZ9tQuboEJcUFayXdARhcxLQ3+6Fg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-transform-unicode-regex": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.10.4.tgz", + "integrity": "sha512-wNfsc4s8N2qnIwpO/WP2ZiSyjfpTamT2C9V9FDH/Ljub9zw6P3SjkXcFmc0RQUt96k2fmIvtla2MMjgTwIAC+A==", + "dev": true, + "requires": { + "@babel/helper-create-regexp-features-plugin": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/preset-env": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.10.4.tgz", + "integrity": "sha512-tcmuQ6vupfMZPrLrc38d0sF2OjLT3/bZ0dry5HchNCQbrokoQi4reXqclvkkAT5b+gWc23meVWpve5P/7+w/zw==", + "dev": true, + "requires": { + "@babel/compat-data": "^7.10.4", + "@babel/helper-compilation-targets": "^7.10.4", + "@babel/helper-module-imports": "^7.10.4", + "@babel/helper-plugin-utils": "^7.10.4", + "@babel/plugin-proposal-async-generator-functions": "^7.10.4", + "@babel/plugin-proposal-class-properties": "^7.10.4", + "@babel/plugin-proposal-dynamic-import": "^7.10.4", + "@babel/plugin-proposal-json-strings": "^7.10.4", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4", + "@babel/plugin-proposal-numeric-separator": "^7.10.4", + "@babel/plugin-proposal-object-rest-spread": "^7.10.4", + "@babel/plugin-proposal-optional-catch-binding": "^7.10.4", + "@babel/plugin-proposal-optional-chaining": "^7.10.4", + "@babel/plugin-proposal-private-methods": "^7.10.4", + "@babel/plugin-proposal-unicode-property-regex": "^7.10.4", + "@babel/plugin-syntax-async-generators": "^7.8.0", + "@babel/plugin-syntax-class-properties": "^7.10.4", + "@babel/plugin-syntax-dynamic-import": "^7.8.0", + "@babel/plugin-syntax-json-strings": "^7.8.0", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.0", + "@babel/plugin-syntax-numeric-separator": "^7.10.4", + "@babel/plugin-syntax-object-rest-spread": "^7.8.0", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.0", + "@babel/plugin-syntax-optional-chaining": "^7.8.0", + "@babel/plugin-syntax-top-level-await": "^7.10.4", + "@babel/plugin-transform-arrow-functions": "^7.10.4", + "@babel/plugin-transform-async-to-generator": "^7.10.4", + "@babel/plugin-transform-block-scoped-functions": "^7.10.4", + "@babel/plugin-transform-block-scoping": "^7.10.4", + "@babel/plugin-transform-classes": "^7.10.4", + "@babel/plugin-transform-computed-properties": "^7.10.4", + "@babel/plugin-transform-destructuring": "^7.10.4", + "@babel/plugin-transform-dotall-regex": "^7.10.4", + "@babel/plugin-transform-duplicate-keys": "^7.10.4", + "@babel/plugin-transform-exponentiation-operator": "^7.10.4", + "@babel/plugin-transform-for-of": "^7.10.4", + "@babel/plugin-transform-function-name": "^7.10.4", + "@babel/plugin-transform-literals": "^7.10.4", + "@babel/plugin-transform-member-expression-literals": "^7.10.4", + "@babel/plugin-transform-modules-amd": "^7.10.4", + "@babel/plugin-transform-modules-commonjs": "^7.10.4", + "@babel/plugin-transform-modules-systemjs": "^7.10.4", + "@babel/plugin-transform-modules-umd": "^7.10.4", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.10.4", + "@babel/plugin-transform-new-target": "^7.10.4", + "@babel/plugin-transform-object-super": "^7.10.4", + "@babel/plugin-transform-parameters": "^7.10.4", + "@babel/plugin-transform-property-literals": "^7.10.4", + "@babel/plugin-transform-regenerator": "^7.10.4", + "@babel/plugin-transform-reserved-words": "^7.10.4", + "@babel/plugin-transform-shorthand-properties": "^7.10.4", + "@babel/plugin-transform-spread": "^7.10.4", + "@babel/plugin-transform-sticky-regex": "^7.10.4", + "@babel/plugin-transform-template-literals": "^7.10.4", + "@babel/plugin-transform-typeof-symbol": "^7.10.4", + "@babel/plugin-transform-unicode-escapes": "^7.10.4", + "@babel/plugin-transform-unicode-regex": "^7.10.4", + "@babel/preset-modules": "^0.1.3", + "@babel/types": "^7.10.4", + "browserslist": "^4.12.0", + "core-js-compat": "^3.6.2", + "invariant": "^2.2.2", + "levenary": "^1.1.1", + "semver": "^5.5.0" + } + }, + "@babel/preset-modules": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.3.tgz", + "integrity": "sha512-Ra3JXOHBq2xd56xSF7lMKXdjBn3T772Y1Wet3yWnkDly9zHvJki029tAFzvAAK5cf4YV3yoxuP61crYRol6SVg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", + "@babel/plugin-transform-dotall-regex": "^7.4.4", + "@babel/types": "^7.4.4", + "esutils": "^2.0.2" + } + }, + "@babel/runtime": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.10.4.tgz", + "integrity": "sha512-UpTN5yUJr9b4EX2CnGNWIvER7Ab83ibv0pcvvHc4UOdrBI5jb8bj+32cCwPX6xu0mt2daFNjYhoi+X7beH0RSw==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, + "@babel/runtime-corejs3": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.10.4.tgz", + "integrity": "sha512-BFlgP2SoLO9HJX9WBwN67gHWMBhDX/eDz64Jajd6mR/UAUzqrNMm99d4qHnVaKscAElZoFiPv+JpR/Siud5lXw==", + "dev": true, + "requires": { + "core-js-pure": "^3.0.0", + "regenerator-runtime": "^0.13.4" + } + }, + "@babel/template": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.4.tgz", + "integrity": "sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.4", + "@babel/parser": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/traverse": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.4.tgz", + "integrity": "sha512-aSy7p5THgSYm4YyxNGz6jZpXf+Ok40QF3aA2LyIONkDHpAcJzDUqlCKXv6peqYUs2gmic849C/t2HKw2a2K20Q==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.4", + "@babel/generator": "^7.10.4", + "@babel/helper-function-name": "^7.10.4", + "@babel/helper-split-export-declaration": "^7.10.4", + "@babel/parser": "^7.10.4", + "@babel/types": "^7.10.4", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.4.tgz", + "integrity": "sha512-UTCFOxC3FsFHb7lkRMVvgLzaRVamXuAs2Tz4wajva4WxtVY82eZeaUBtC2Zt95FU9TiznuC0Zk35tsim8jeVpg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.4", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "@cnakazawa/watch": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@cnakazawa/watch/-/watch-1.0.4.tgz", + "integrity": "sha512-v9kIhKwjeZThiWrLmj0y17CWoyddASLj9O2yvbZkbvw/N3rWOYy9zkV66ursAoVr0mV15bL8g0c4QZUE6cdDoQ==", + "dev": true, + "requires": { + "exec-sh": "^0.3.2", + "minimist": "^1.2.0" + } + }, + "@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + } + }, + "@istanbuljs/schema": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.2.tgz", + "integrity": "sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==", + "dev": true + }, + "@jest/console": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-26.1.0.tgz", + "integrity": "sha512-+0lpTHMd/8pJp+Nd4lyip+/Iyf2dZJvcCqrlkeZQoQid+JlThA4M9vxHtheyrQ99jJTMQam+es4BcvZ5W5cC3A==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0", + "chalk": "^4.0.0", + "jest-message-util": "^26.1.0", + "jest-util": "^26.1.0", + "slash": "^3.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "@jest/core": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-26.1.0.tgz", + "integrity": "sha512-zyizYmDJOOVke4OO/De//aiv8b07OwZzL2cfsvWF3q9YssfpcKfcnZAwDY8f+A76xXSMMYe8i/f/LPocLlByfw==", + "dev": true, + "requires": { + "@jest/console": "^26.1.0", + "@jest/reporters": "^26.1.0", + "@jest/test-result": "^26.1.0", + "@jest/transform": "^26.1.0", + "@jest/types": "^26.1.0", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.4", + "jest-changed-files": "^26.1.0", + "jest-config": "^26.1.0", + "jest-haste-map": "^26.1.0", + "jest-message-util": "^26.1.0", + "jest-regex-util": "^26.0.0", + "jest-resolve": "^26.1.0", + "jest-resolve-dependencies": "^26.1.0", + "jest-runner": "^26.1.0", + "jest-runtime": "^26.1.0", + "jest-snapshot": "^26.1.0", + "jest-util": "^26.1.0", + "jest-validate": "^26.1.0", + "jest-watcher": "^26.1.0", + "micromatch": "^4.0.2", + "p-each-series": "^2.1.0", + "rimraf": "^3.0.0", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "@jest/environment": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-26.1.0.tgz", + "integrity": "sha512-86+DNcGongbX7ai/KE/S3/NcUVZfrwvFzOOWX/W+OOTvTds7j07LtC+MgGydH5c8Ri3uIrvdmVgd1xFD5zt/xA==", + "dev": true, + "requires": { + "@jest/fake-timers": "^26.1.0", + "@jest/types": "^26.1.0", + "jest-mock": "^26.1.0" + } + }, + "@jest/fake-timers": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-26.1.0.tgz", + "integrity": "sha512-Y5F3kBVWxhau3TJ825iuWy++BAuQzK/xEa+wD9vDH3RytW9f2DbMVodfUQC54rZDX3POqdxCgcKdgcOL0rYUpA==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0", + "@sinonjs/fake-timers": "^6.0.1", + "jest-message-util": "^26.1.0", + "jest-mock": "^26.1.0", + "jest-util": "^26.1.0" + } + }, + "@jest/globals": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-26.1.0.tgz", + "integrity": "sha512-MKiHPNaT+ZoG85oMaYUmGHEqu98y3WO2yeIDJrs2sJqHhYOy3Z6F7F/luzFomRQ8SQ1wEkmahFAz2291Iv8EAw==", + "dev": true, + "requires": { + "@jest/environment": "^26.1.0", + "@jest/types": "^26.1.0", + "expect": "^26.1.0" + } + }, + "@jest/reporters": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-26.1.0.tgz", + "integrity": "sha512-SVAysur9FOIojJbF4wLP0TybmqwDkdnFxHSPzHMMIYyBtldCW9gG+Q5xWjpMFyErDiwlRuPyMSJSU64A67Pazg==", + "dev": true, + "requires": { + "@bcoe/v8-coverage": "^0.2.3", + "@jest/console": "^26.1.0", + "@jest/test-result": "^26.1.0", + "@jest/transform": "^26.1.0", + "@jest/types": "^26.1.0", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.2", + "graceful-fs": "^4.2.4", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-instrument": "^4.0.3", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.0.2", + "jest-haste-map": "^26.1.0", + "jest-resolve": "^26.1.0", + "jest-util": "^26.1.0", + "jest-worker": "^26.1.0", + "node-notifier": "^7.0.0", + "slash": "^3.0.0", + "source-map": "^0.6.0", + "string-length": "^4.0.1", + "terminal-link": "^2.0.0", + "v8-to-istanbul": "^4.1.3" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "@jest/source-map": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-26.1.0.tgz", + "integrity": "sha512-XYRPYx4eEVX15cMT9mstnO7hkHP3krNtKfxUYd8L7gbtia8JvZZ6bMzSwa6IQJENbudTwKMw5R1BePRD+bkEmA==", + "dev": true, + "requires": { + "callsites": "^3.0.0", + "graceful-fs": "^4.2.4", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "@jest/test-result": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-26.1.0.tgz", + "integrity": "sha512-Xz44mhXph93EYMA8aYDz+75mFbarTV/d/x0yMdI3tfSRs/vh4CqSxgzVmCps1fPkHDCtn0tU8IH9iCKgGeGpfw==", + "dev": true, + "requires": { + "@jest/console": "^26.1.0", + "@jest/types": "^26.1.0", + "@types/istanbul-lib-coverage": "^2.0.0", + "collect-v8-coverage": "^1.0.0" + } + }, + "@jest/test-sequencer": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-26.1.0.tgz", + "integrity": "sha512-Z/hcK+rTq56E6sBwMoQhSRDVjqrGtj1y14e2bIgcowARaIE1SgOanwx6gvY4Q9gTKMoZQXbXvptji+q5GYxa6Q==", + "dev": true, + "requires": { + "@jest/test-result": "^26.1.0", + "graceful-fs": "^4.2.4", + "jest-haste-map": "^26.1.0", + "jest-runner": "^26.1.0", + "jest-runtime": "^26.1.0" + } + }, + "@jest/transform": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-26.1.0.tgz", + "integrity": "sha512-ICPm6sUXmZJieq45ix28k0s+d/z2E8CHDsq+WwtWI6kW8m7I8kPqarSEcUN86entHQ570ZBRci5OWaKL0wlAWw==", + "dev": true, + "requires": { + "@babel/core": "^7.1.0", + "@jest/types": "^26.1.0", + "babel-plugin-istanbul": "^6.0.0", + "chalk": "^4.0.0", + "convert-source-map": "^1.4.0", + "fast-json-stable-stringify": "^2.0.0", + "graceful-fs": "^4.2.4", + "jest-haste-map": "^26.1.0", + "jest-regex-util": "^26.0.0", + "jest-util": "^26.1.0", + "micromatch": "^4.0.2", + "pirates": "^4.0.1", + "slash": "^3.0.0", + "source-map": "^0.6.1", + "write-file-atomic": "^3.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "@jest/types": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.1.0.tgz", + "integrity": "sha512-GXigDDsp6ZlNMhXQDeuy/iYCDsRIHJabWtDzvnn36+aqFfG14JmFV0e/iXxY4SP9vbXSiPNOWdehU5MeqrYHBQ==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^1.1.1", + "@types/yargs": "^15.0.0", + "chalk": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "@rollup/plugin-commonjs": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-13.0.0.tgz", + "integrity": "sha512-Anxc3qgkAi7peAyesTqGYidG5GRim9jtg8xhmykNaZkImtvjA7Wsqep08D2mYsqw1IF7rA3lYfciLgzUSgRoqw==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.0.8", + "commondir": "^1.0.1", + "estree-walker": "^1.0.1", + "glob": "^7.1.2", + "is-reference": "^1.1.2", + "magic-string": "^0.25.2", + "resolve": "^1.11.0" + } + }, + "@rollup/plugin-node-resolve": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-8.1.0.tgz", + "integrity": "sha512-ovq7ZM3JJYUUmEjjO+H8tnUdmQmdQudJB7xruX8LFZ1W2q8jXdPUS6SsIYip8ByOApu4RR7729Am9WhCeCMiHA==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.0.8", + "@types/resolve": "0.0.8", + "builtin-modules": "^3.1.0", + "deep-freeze": "^0.0.1", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.14.2" + } + }, + "@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "requires": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + } + }, + "@sinonjs/commons": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.0.tgz", + "integrity": "sha512-wEj54PfsZ5jGSwMX68G8ZXFawcSglQSXqCftWX3ec8MDUzQdHgcKvw97awHbY0efQEL5iKUOAmmVtoYgmrSG4Q==", + "dev": true, + "requires": { + "type-detect": "4.0.8" + } + }, + "@sinonjs/fake-timers": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-6.0.1.tgz", + "integrity": "sha512-MZPUxrmFubI36XS1DI3qmI0YdN1gks62JtFZvxR67ljjSNCeK6U08Zx4msEWOXuofgqUt6zPHSi1H9fbjR/NRA==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0" + } + }, + "@types/babel__core": { + "version": "7.1.9", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.9.tgz", + "integrity": "sha512-sY2RsIJ5rpER1u3/aQ8OFSI7qGIy8o1NEEbgb2UaJcvOtXOMpd39ko723NBpjQFg9SIX7TXtjejZVGeIMLhoOw==", + "dev": true, + "requires": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "@types/babel__generator": { + "version": "7.6.1", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.1.tgz", + "integrity": "sha512-bBKm+2VPJcMRVwNhxKu8W+5/zT7pwNEqeokFOmbvVSqGzFneNxYcEBro9Ac7/N9tlsaPYnZLK8J1LWKkMsLAew==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@types/babel__template": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.0.2.tgz", + "integrity": "sha512-/K6zCpeW7Imzgab2bLkLEbz0+1JlFSrUMdw7KoIIu+IUdu51GWaBZpd3y1VXGVXzynvGa4DaIaxNZHiON3GXUg==", + "dev": true, + "requires": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@types/babel__traverse": { + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.12.tgz", + "integrity": "sha512-t4CoEokHTfcyfb4hUaF9oOHu9RmmNWnm1CP0YmMqOOfClKascOmvlEM736vlqeScuGvBDsHkf8R2INd4DWreQA==", + "dev": true, + "requires": { + "@babel/types": "^7.3.0" + } + }, + "@types/color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", + "dev": true + }, + "@types/estree": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", + "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", + "dev": true + }, + "@types/graceful-fs": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.3.tgz", + "integrity": "sha512-AiHRaEB50LQg0pZmm659vNBb9f4SJ0qrAnteuzhSeAUcJKxoYgEnprg/83kppCnc2zvtCKbdZry1a5pVY3lOTQ==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/istanbul-lib-coverage": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", + "integrity": "sha512-sz7iLqvVUg1gIedBOvlkxPlc8/uVzyS5OwGz1cKjXzkl3FpL3al0crU8YGU1WoHkxn0Wxbw5tyi6hvzJKNzFsw==", + "dev": true + }, + "@types/istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "*" + } + }, + "@types/istanbul-reports": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-1.1.2.tgz", + "integrity": "sha512-P/W9yOX/3oPZSpaYOCQzGqgCQRXn0FFO/V8bWrCQs+wLmvVVxk6CRBXALEvNs9OHIatlnlFokfhuDo2ug01ciw==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "*", + "@types/istanbul-lib-report": "*" + } + }, + "@types/node": { + "version": "14.0.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.14.tgz", + "integrity": "sha512-syUgf67ZQpaJj01/tRTknkMNoBBLWJOBODF0Zm4NrXmiSuxjymFrxnTu1QVYRubhVkRcZLYZG8STTwJRdVm/WQ==", + "dev": true + }, + "@types/normalize-package-data": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz", + "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", + "dev": true + }, + "@types/prettier": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.0.1.tgz", + "integrity": "sha512-boy4xPNEtiw6N3abRhBi/e7hNvy3Tt8E9ZRAQrwAGzoCGZS/1wjo9KY7JHhnfnEsG5wSjDbymCozUM9a3ea7OQ==", + "dev": true + }, + "@types/resolve": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", + "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/stack-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz", + "integrity": "sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==", + "dev": true + }, + "@types/yargs": { + "version": "15.0.5", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", + "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "dev": true, + "requires": { + "@types/yargs-parser": "*" + } + }, + "@types/yargs-parser": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-15.0.0.tgz", + "integrity": "sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==", + "dev": true + }, + "abab": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.3.tgz", + "integrity": "sha512-tsFzPpcttalNjFBCFMqsKYQcWxxen1pgJR56by//QwvJc4/OUS3kPOOttx2tSIfjsylB0pYu7f5D3K1RCxUnUg==", + "dev": true + }, + "acorn": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", + "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", + "dev": true + }, + "acorn-globals": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz", + "integrity": "sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg==", + "dev": true, + "requires": { + "acorn": "^7.1.1", + "acorn-walk": "^7.1.1" + } + }, + "acorn-walk": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", + "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", + "dev": true + }, + "ajv": { + "version": "6.12.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz", + "integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-escapes": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", + "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==", + "dev": true, + "requires": { + "type-fest": "^0.11.0" + }, + "dependencies": { + "type-fest": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", + "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==", + "dev": true + } + } + }, + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "anymatch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "dev": true, + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "atob": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", + "dev": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true + }, + "aws4": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.0.tgz", + "integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==", + "dev": true + }, + "babel-jest": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-26.1.0.tgz", + "integrity": "sha512-Nkqgtfe7j6PxLO6TnCQQlkMm8wdTdnIF8xrdpooHCuD5hXRzVEPbPneTJKknH5Dsv3L8ip9unHDAp48YQ54Dkg==", + "dev": true, + "requires": { + "@jest/transform": "^26.1.0", + "@jest/types": "^26.1.0", + "@types/babel__core": "^7.1.7", + "babel-plugin-istanbul": "^6.0.0", + "babel-preset-jest": "^26.1.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.4", + "slash": "^3.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "babel-plugin-dynamic-import-node": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz", + "integrity": "sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==", + "dev": true, + "requires": { + "object.assign": "^4.1.0" + } + }, + "babel-plugin-istanbul": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.0.0.tgz", + "integrity": "sha512-AF55rZXpe7trmEylbaE1Gv54wn6rwU03aptvRoVIGP8YykoSxqdVLV1TfwflBCE/QtHmqtP8SWlTENqbK8GCSQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^4.0.0", + "test-exclude": "^6.0.0" + } + }, + "babel-plugin-jest-hoist": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-26.1.0.tgz", + "integrity": "sha512-qhqLVkkSlqmC83bdMhM8WW4Z9tB+JkjqAqlbbohS9sJLT5Ha2vfzuKqg5yenXrAjOPG2YC0WiXdH3a9PvB+YYw==", + "dev": true, + "requires": { + "@babel/template": "^7.3.3", + "@babel/types": "^7.3.3", + "@types/babel__core": "^7.0.0", + "@types/babel__traverse": "^7.0.6" + } + }, + "babel-preset-current-node-syntax": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-0.1.3.tgz", + "integrity": "sha512-uyexu1sVwcdFnyq9o8UQYsXwXflIh8LvrF5+cKrYam93ned1CStffB3+BEcsxGSgagoA3GEyjDqO4a/58hyPYQ==", + "dev": true, + "requires": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.8.3", + "@babel/plugin-syntax-import-meta": "^7.8.3", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.8.3", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3" + } + }, + "babel-preset-jest": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-26.1.0.tgz", + "integrity": "sha512-na9qCqFksknlEj5iSdw1ehMVR06LCCTkZLGKeEtxDDdhg8xpUF09m29Kvh1pRbZ07h7AQ5ttLYUwpXL4tO6w7w==", + "dev": true, + "requires": { + "babel-plugin-jest-hoist": "^26.1.0", + "babel-preset-current-node-syntax": "^0.1.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, + "requires": { + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "dev": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "benchmark": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz", + "integrity": "sha1-CfPeMckWQl1JjMLuVloOvzwqVik=", + "dev": true, + "requires": { + "lodash": "^4.17.4", + "platform": "^1.3.3" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "browser-process-hrtime": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz", + "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==", + "dev": true + }, + "browserslist": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.12.2.tgz", + "integrity": "sha512-MfZaeYqR8StRZdstAK9hCKDd2StvePCYp5rHzQCPicUjfFliDgmuaBNPHYUTpAywBN8+Wc/d7NYVFkO0aqaBUw==", + "dev": true, + "requires": { + "caniuse-lite": "^1.0.30001088", + "electron-to-chromium": "^1.3.483", + "escalade": "^3.0.1", + "node-releases": "^1.1.58" + } + }, + "bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "requires": { + "node-int64": "^0.4.0" + } + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "builtin-modules": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", + "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", + "dev": true + }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" + } + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "caniuse-lite": { + "version": "1.0.30001093", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001093.tgz", + "integrity": "sha512-0+ODNoOjtWD5eS9aaIpf4K0gQqZfILNY4WSNuYzeT1sXni+lMrrVjc0odEobJt6wrODofDZUX8XYi/5y7+xl8g==", + "dev": true + }, + "capture-exit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/capture-exit/-/capture-exit-2.0.0.tgz", + "integrity": "sha512-PiT/hQmTonHhl/HFGN+Lx3JJUznrVYJ3+AQsnthneZbvW7x+f08Tk7yLJTLEOUvBTbduLeeBkxEaYXUOUrRq6g==", + "dev": true, + "requires": { + "rsvp": "^4.8.4" + } + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "char-regex": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", + "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "dev": true + }, + "chevrotain": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-7.0.1.tgz", + "integrity": "sha512-B/44jrdw5GAzy483LEeVSgXSX0qOYM8lUd3l5+yf6Vl6OQjEUCm2BUiYbHRCIK6xCEvCLAFe1kj8uyV6+zdaVw==", + "requires": { + "regexp-to-ast": "0.5.0" + } + }, + "ci-info": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", + "dev": true + }, + "class-utils": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true + }, + "collect-v8-coverage": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz", + "integrity": "sha512-iBPtljfCNcTKNAto0KEtDfZ3qzjJvqE3aTGZsbhjSBlorqpXJlaWWtPO35D+ZImoC3KWejX64o+yPGxhWSTzfg==", + "dev": true + }, + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, + "component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", + "dev": true + }, + "compromise": { + "version": "13.3.1", + "resolved": "https://registry.npmjs.org/compromise/-/compromise-13.3.1.tgz", + "integrity": "sha512-GcnPmjJ0HKonf2q2VRCBNFTDG/MQOAa1URH+t7FLN9KeJY68orBh7OeAznXo7g5Mgz2bpgqRTp9jQoYreYRo/Q==", + "dev": true, + "requires": { + "efrt-unpack": "2.2.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "convert-source-map": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", + "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } + }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, + "core-js-compat": { + "version": "3.6.5", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.6.5.tgz", + "integrity": "sha512-7ItTKOhOZbznhXAQ2g/slGg1PJV5zDO/WdkTwi7UEOJmkvsE32PWvx6mKtDjiMpjnR2CNf6BAD6sSxIlv7ptng==", + "dev": true, + "requires": { + "browserslist": "^4.8.5", + "semver": "7.0.0" + }, + "dependencies": { + "semver": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", + "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", + "dev": true + } + } + }, + "core-js-pure": { + "version": "3.6.5", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.6.5.tgz", + "integrity": "sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "dependencies": { + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "cssom": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", + "integrity": "sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==", + "dev": true + }, + "cssstyle": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz", + "integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==", + "dev": true, + "requires": { + "cssom": "~0.3.6" + }, + "dependencies": { + "cssom": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", + "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", + "dev": true + } + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "data-urls": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz", + "integrity": "sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==", + "dev": true, + "requires": { + "abab": "^2.0.3", + "whatwg-mimetype": "^2.3.0", + "whatwg-url": "^8.0.0" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "decamelize": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-3.2.0.tgz", + "integrity": "sha512-4TgkVUsmmu7oCSyGBm5FvfMoACuoh9EOidm7V5/J2X2djAwwt57qb3F2KMP2ITqODTCSwb+YRV+0Zqrv18k/hw==", + "dev": true, + "requires": { + "xregexp": "^4.2.4" + } + }, + "decimal.js": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.0.tgz", + "integrity": "sha512-vDPw+rDgn3bZe1+F/pyEwb1oMG2XTlRVgAa6B4KccTEpYgF8w6eQllVbQcfIJnZyvzFtFpxnpGtx8dd7DJp/Rw==", + "dev": true + }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "dev": true + }, + "deep-freeze": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/deep-freeze/-/deep-freeze-0.0.1.tgz", + "integrity": "sha1-OgsABd4YZygZ39OM0x+RF5yJPoQ=", + "dev": true + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true + }, + "diff-sequences": { + "version": "26.0.0", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-26.0.0.tgz", + "integrity": "sha512-JC/eHYEC3aSS0vZGjuoc4vHA0yAQTzhQQldXMeMF+JlxLGJlCO38Gma82NV9gk1jGFz8mDzUMeaKXvjRRdJ2dg==", + "dev": true + }, + "domexception": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/domexception/-/domexception-2.0.1.tgz", + "integrity": "sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg==", + "dev": true, + "requires": { + "webidl-conversions": "^5.0.0" + }, + "dependencies": { + "webidl-conversions": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz", + "integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==", + "dev": true + } + } + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "dev": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "efrt-unpack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/efrt-unpack/-/efrt-unpack-2.2.0.tgz", + "integrity": "sha512-9xUSSj7qcUxz+0r4X3+bwUNttEfGfK5AH+LVa1aTpqdAfrN5VhROYCfcF+up4hp5OL7IUKcZJJrzAGipQRDoiQ==", + "dev": true + }, + "electron-to-chromium": { + "version": "1.3.484", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.484.tgz", + "integrity": "sha512-esh5mmjAGl6HhAaYgHlDZme+jCIc+XIrLrBTwxviE+pM64UBmdLUIHLlrPzJGbit7hQI1TR/oGDQWCvQZ5yrFA==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "escalade": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.0.1.tgz", + "integrity": "sha512-DR6NO3h9niOT+MZs7bjxlj2a1k+POu5RN8CLTPX2+i78bRi9eLe7+0zXgUHMnGXWybYcL61E9hGhPKqedy8tQA==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "escodegen": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", + "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", + "dev": true, + "requires": { + "esprima": "^4.0.1", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "optional": true + } + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, + "exec-sh": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/exec-sh/-/exec-sh-0.3.4.tgz", + "integrity": "sha512-sEFIkc61v75sWeOe72qyrqg2Qg0OuLESziUDk/O/z2qgS15y2gWVFrI6f2Qn/qw/0/NCfCEsmNA4zOjkwEZT1A==", + "dev": true + }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "expect": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-26.1.0.tgz", + "integrity": "sha512-QbH4LZXDsno9AACrN9eM0zfnby9G+OsdNgZUohjg/P0mLy1O+/bzTAJGT6VSIjVCe8yKM6SzEl/ckEOFBT7Vnw==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0", + "ansi-styles": "^4.0.0", + "jest-get-type": "^26.0.0", + "jest-matcher-utils": "^26.1.0", + "jest-message-util": "^26.1.0", + "jest-regex-util": "^26.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "fb-watchman": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.1.tgz", + "integrity": "sha512-DkPJKQeY6kKwmuMretBhr7G6Vodr7bFwDYTXIkfG1gjvNpaxBTQV3PbXg6bR1c1UP4jPOX0jHUbbHANL9vRjVg==", + "dev": true, + "requires": { + "bser": "2.1.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "map-cache": "^0.2.2" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "dev": true, + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "gensync": { + "version": "1.0.0-beta.1", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz", + "integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, + "graceful-fs": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", + "dev": true + }, + "growly": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", + "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=", + "dev": true, + "optional": true + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "dev": true, + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "hosted-git-info": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, + "html-encoding-sniffer": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", + "integrity": "sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ==", + "dev": true, + "requires": { + "whatwg-encoding": "^1.0.5" + } + }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "human-signals": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", + "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==", + "dev": true + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "import-local": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.0.2.tgz", + "integrity": "sha512-vjL3+w0oulAVZ0hBHnxa/Nm5TAurf9YLQJDhqRZyqb+VKGOB6LU8t9H1Nr5CIo16vh9XfJTOoHwU0B71S557gA==", + "dev": true, + "requires": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "invariant": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "dev": true, + "requires": { + "loose-envify": "^1.0.0" + } + }, + "ip-regex": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz", + "integrity": "sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=", + "dev": true + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "is-ci": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", + "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", + "dev": true, + "requires": { + "ci-info": "^2.0.0" + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "is-docker": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.0.0.tgz", + "integrity": "sha512-pJEdRugimx4fBMra5z2/5iRdZ63OhYV0vr0Dwm5+xtW4D1FvRkB8hamMIhnWfyJeDdyr/aa7BDyNbtG38VxgoQ==", + "dev": true, + "optional": true + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "is-generator-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true + }, + "is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "dev": true + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "is-potential-custom-element-name": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz", + "integrity": "sha1-DFLlS8yjkbssSUsh6GJtczbG45c=", + "dev": true + }, + "is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "requires": { + "@types/estree": "*" + } + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "optional": true, + "requires": { + "is-docker": "^2.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true + }, + "istanbul-lib-coverage": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", + "integrity": "sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg==", + "dev": true + }, + "istanbul-lib-instrument": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz", + "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==", + "dev": true, + "requires": { + "@babel/core": "^7.7.5", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.0.0", + "semver": "^6.3.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "istanbul-lib-source-maps": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.0.tgz", + "integrity": "sha512-c16LpFRkR8vQXyHZ5nLpY35JZtzj1PQY1iZmesUbf1FZHbIupcWfjgOXBY9YHkLEQ6puz1u4Dgj6qmU/DisrZg==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "istanbul-reports": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.0.2.tgz", + "integrity": "sha512-9tZvz7AiR3PEDNGiV9vIouQ/EAcqMXFmkcA1CDFTwOB98OZVDL0PH9glHotf5Ugp6GCOTypfzGWI/OqjWNCRUw==", + "dev": true, + "requires": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + } + }, + "jest": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest/-/jest-26.1.0.tgz", + "integrity": "sha512-LIti8jppw5BcQvmNJe4w2g1N/3V68HUfAv9zDVm7v+VAtQulGhH0LnmmiVkbNE4M4I43Bj2fXPiBGKt26k9tHw==", + "dev": true, + "requires": { + "@jest/core": "^26.1.0", + "import-local": "^3.0.2", + "jest-cli": "^26.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "jest-cli": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-26.1.0.tgz", + "integrity": "sha512-Imumvjgi3rU7stq6SJ1JUEMaV5aAgJYXIs0jPqdUnF47N/Tk83EXfmtvNKQ+SnFVI6t6mDOvfM3aA9Sg6kQPSw==", + "dev": true, + "requires": { + "@jest/core": "^26.1.0", + "@jest/test-result": "^26.1.0", + "@jest/types": "^26.1.0", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.4", + "import-local": "^3.0.2", + "is-ci": "^2.0.0", + "jest-config": "^26.1.0", + "jest-util": "^26.1.0", + "jest-validate": "^26.1.0", + "prompts": "^2.0.1", + "yargs": "^15.3.1" + } + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-changed-files": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-26.1.0.tgz", + "integrity": "sha512-HS5MIJp3B8t0NRKGMCZkcDUZo36mVRvrDETl81aqljT1S9tqiHRSpyoOvWg9ZilzZG9TDisDNaN1IXm54fLRZw==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0", + "execa": "^4.0.0", + "throat": "^5.0.0" + }, + "dependencies": { + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "execa": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/execa/-/execa-4.0.2.tgz", + "integrity": "sha512-QI2zLa6CjGWdiQsmSkZoGtDx2N+cQIGb3yNolGTdjSQzydzLgYYf8LRuagp7S7fPimjcrzUDSUFd/MgzELMi4Q==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.0", + "get-stream": "^5.0.0", + "human-signals": "^1.1.1", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.0", + "onetime": "^5.1.0", + "signal-exit": "^3.0.2", + "strip-final-newline": "^2.0.0" + } + }, + "get-stream": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz", + "integrity": "sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "is-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", + "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", + "dev": true + }, + "npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "requires": { + "path-key": "^3.0.0" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + } + } + }, + "jest-config": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-26.1.0.tgz", + "integrity": "sha512-ONTGeoMbAwGCdq4WuKkMcdMoyfs5CLzHEkzFOlVvcDXufZSaIWh/OXMLa2fwKXiOaFcqEw8qFr4VOKJQfn4CVw==", + "dev": true, + "requires": { + "@babel/core": "^7.1.0", + "@jest/test-sequencer": "^26.1.0", + "@jest/types": "^26.1.0", + "babel-jest": "^26.1.0", + "chalk": "^4.0.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.1", + "graceful-fs": "^4.2.4", + "jest-environment-jsdom": "^26.1.0", + "jest-environment-node": "^26.1.0", + "jest-get-type": "^26.0.0", + "jest-jasmine2": "^26.1.0", + "jest-regex-util": "^26.0.0", + "jest-resolve": "^26.1.0", + "jest-util": "^26.1.0", + "jest-validate": "^26.1.0", + "micromatch": "^4.0.2", + "pretty-format": "^26.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-diff": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-26.1.0.tgz", + "integrity": "sha512-GZpIcom339y0OXznsEKjtkfKxNdg7bVbEofK8Q6MnevTIiR1jNhDWKhRX6X0SDXJlwn3dy59nZ1z55fLkAqPWg==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "diff-sequences": "^26.0.0", + "jest-get-type": "^26.0.0", + "pretty-format": "^26.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-docblock": { + "version": "26.0.0", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-26.0.0.tgz", + "integrity": "sha512-RDZ4Iz3QbtRWycd8bUEPxQsTlYazfYn/h5R65Fc6gOfwozFhoImx+affzky/FFBuqISPTqjXomoIGJVKBWoo0w==", + "dev": true, + "requires": { + "detect-newline": "^3.0.0" + } + }, + "jest-each": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-26.1.0.tgz", + "integrity": "sha512-lYiSo4Igr81q6QRsVQq9LIkJW0hZcKxkIkHzNeTMPENYYDw/W/Raq28iJ0sLlNFYz2qxxeLnc5K2gQoFYlu2bA==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0", + "chalk": "^4.0.0", + "jest-get-type": "^26.0.0", + "jest-util": "^26.1.0", + "pretty-format": "^26.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-environment-jsdom": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-26.1.0.tgz", + "integrity": "sha512-dWfiJ+spunVAwzXbdVqPH1LbuJW/kDL+FyqgA5YzquisHqTi0g9hquKif9xKm7c1bKBj6wbmJuDkeMCnxZEpUw==", + "dev": true, + "requires": { + "@jest/environment": "^26.1.0", + "@jest/fake-timers": "^26.1.0", + "@jest/types": "^26.1.0", + "jest-mock": "^26.1.0", + "jest-util": "^26.1.0", + "jsdom": "^16.2.2" + } + }, + "jest-environment-node": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-26.1.0.tgz", + "integrity": "sha512-DNm5x1aQH0iRAe9UYAkZenuzuJ69VKzDCAYISFHQ5i9e+2Tbeu2ONGY7YStubCLH8a1wdKBgqScYw85+ySxqxg==", + "dev": true, + "requires": { + "@jest/environment": "^26.1.0", + "@jest/fake-timers": "^26.1.0", + "@jest/types": "^26.1.0", + "jest-mock": "^26.1.0", + "jest-util": "^26.1.0" + } + }, + "jest-get-type": { + "version": "26.0.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-26.0.0.tgz", + "integrity": "sha512-zRc1OAPnnws1EVfykXOj19zo2EMw5Hi6HLbFCSjpuJiXtOWAYIjNsHVSbpQ8bDX7L5BGYGI8m+HmKdjHYFF0kg==", + "dev": true + }, + "jest-haste-map": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-26.1.0.tgz", + "integrity": "sha512-WeBS54xCIz9twzkEdm6+vJBXgRBQfdbbXD0dk8lJh7gLihopABlJmIQFdWSDDtuDe4PRiObsjZSUjbJ1uhWEpA==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0", + "@types/graceful-fs": "^4.1.2", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "fsevents": "^2.1.2", + "graceful-fs": "^4.2.4", + "jest-serializer": "^26.1.0", + "jest-util": "^26.1.0", + "jest-worker": "^26.1.0", + "micromatch": "^4.0.2", + "sane": "^4.0.3", + "walker": "^1.0.7", + "which": "^2.0.2" + } + }, + "jest-jasmine2": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-26.1.0.tgz", + "integrity": "sha512-1IPtoDKOAG+MeBrKvvuxxGPJb35MTTRSDglNdWWCndCB3TIVzbLThRBkwH9P081vXLgiJHZY8Bz3yzFS803xqQ==", + "dev": true, + "requires": { + "@babel/traverse": "^7.1.0", + "@jest/environment": "^26.1.0", + "@jest/source-map": "^26.1.0", + "@jest/test-result": "^26.1.0", + "@jest/types": "^26.1.0", + "chalk": "^4.0.0", + "co": "^4.6.0", + "expect": "^26.1.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^26.1.0", + "jest-matcher-utils": "^26.1.0", + "jest-message-util": "^26.1.0", + "jest-runtime": "^26.1.0", + "jest-snapshot": "^26.1.0", + "jest-util": "^26.1.0", + "pretty-format": "^26.1.0", + "throat": "^5.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-leak-detector": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-26.1.0.tgz", + "integrity": "sha512-dsMnKF+4BVOZwvQDlgn3MG+Ns4JuLv8jNvXH56bgqrrboyCbI1rQg6EI5rs+8IYagVcfVP2yZFKfWNZy0rK0Hw==", + "dev": true, + "requires": { + "jest-get-type": "^26.0.0", + "pretty-format": "^26.1.0" + } + }, + "jest-matcher-utils": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-26.1.0.tgz", + "integrity": "sha512-PW9JtItbYvES/xLn5mYxjMd+Rk+/kIt88EfH3N7w9KeOrHWaHrdYPnVHndGbsFGRJ2d5gKtwggCvkqbFDoouQA==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "jest-diff": "^26.1.0", + "jest-get-type": "^26.0.0", + "pretty-format": "^26.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-message-util": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-26.1.0.tgz", + "integrity": "sha512-dY0+UlldiAJwNDJ08SF0HdF32g9PkbF2NRK/+2iMPU40O6q+iSn1lgog/u0UH8ksWoPv0+gNq8cjhYO2MFtT0g==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@jest/types": "^26.1.0", + "@types/stack-utils": "^1.0.1", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.4", + "micromatch": "^4.0.2", + "slash": "^3.0.0", + "stack-utils": "^2.0.2" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-mock": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-26.1.0.tgz", + "integrity": "sha512-1Rm8EIJ3ZFA8yCIie92UbxZWj9SuVmUGcyhLHyAhY6WI3NIct38nVcfOPWhJteqSn8V8e3xOMha9Ojfazfpovw==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0" + } + }, + "jest-pnp-resolver": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.2.tgz", + "integrity": "sha512-olV41bKSMm8BdnuMsewT4jqlZ8+3TCARAXjZGT9jcoSnrfUnRCqnMoF9XEeoWjbzObpqF9dRhHQj0Xb9QdF6/w==", + "dev": true + }, + "jest-regex-util": { + "version": "26.0.0", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", + "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", + "dev": true + }, + "jest-resolve": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-26.1.0.tgz", + "integrity": "sha512-KsY1JV9FeVgEmwIISbZZN83RNGJ1CC+XUCikf/ZWJBX/tO4a4NvA21YixokhdR9UnmPKKAC4LafVixJBrwlmfg==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.4", + "jest-pnp-resolver": "^1.2.1", + "jest-util": "^26.1.0", + "read-pkg-up": "^7.0.1", + "resolve": "^1.17.0", + "slash": "^3.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-resolve-dependencies": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-26.1.0.tgz", + "integrity": "sha512-fQVEPHHQ1JjHRDxzlLU/buuQ9om+hqW6Vo928aa4b4yvq4ZHBtRSDsLdKQLuCqn5CkTVpYZ7ARh2fbA8WkRE6g==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0", + "jest-regex-util": "^26.0.0", + "jest-snapshot": "^26.1.0" + } + }, + "jest-runner": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-26.1.0.tgz", + "integrity": "sha512-elvP7y0fVDREnfqit0zAxiXkDRSw6dgCkzPCf1XvIMnSDZ8yogmSKJf192dpOgnUVykmQXwYYJnCx641uLTgcw==", + "dev": true, + "requires": { + "@jest/console": "^26.1.0", + "@jest/environment": "^26.1.0", + "@jest/test-result": "^26.1.0", + "@jest/types": "^26.1.0", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.4", + "jest-config": "^26.1.0", + "jest-docblock": "^26.0.0", + "jest-haste-map": "^26.1.0", + "jest-jasmine2": "^26.1.0", + "jest-leak-detector": "^26.1.0", + "jest-message-util": "^26.1.0", + "jest-resolve": "^26.1.0", + "jest-runtime": "^26.1.0", + "jest-util": "^26.1.0", + "jest-worker": "^26.1.0", + "source-map-support": "^0.5.6", + "throat": "^5.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-runtime": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-26.1.0.tgz", + "integrity": "sha512-1qiYN+EZLmG1QV2wdEBRf+Ci8i3VSfIYLF02U18PiUDrMbhfpN/EAMMkJtT02jgJUoaEOpHAIXG6zS3QRMzRmA==", + "dev": true, + "requires": { + "@jest/console": "^26.1.0", + "@jest/environment": "^26.1.0", + "@jest/fake-timers": "^26.1.0", + "@jest/globals": "^26.1.0", + "@jest/source-map": "^26.1.0", + "@jest/test-result": "^26.1.0", + "@jest/transform": "^26.1.0", + "@jest/types": "^26.1.0", + "@types/yargs": "^15.0.0", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.4", + "jest-config": "^26.1.0", + "jest-haste-map": "^26.1.0", + "jest-message-util": "^26.1.0", + "jest-mock": "^26.1.0", + "jest-regex-util": "^26.0.0", + "jest-resolve": "^26.1.0", + "jest-snapshot": "^26.1.0", + "jest-util": "^26.1.0", + "jest-validate": "^26.1.0", + "slash": "^3.0.0", + "strip-bom": "^4.0.0", + "yargs": "^15.3.1" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-serializer": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-serializer/-/jest-serializer-26.1.0.tgz", + "integrity": "sha512-eqZOQG/0+MHmr25b2Z86g7+Kzd5dG9dhCiUoyUNJPgiqi38DqbDEOlHcNijyfZoj74soGBohKBZuJFS18YTJ5w==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.4" + } + }, + "jest-snapshot": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-26.1.0.tgz", + "integrity": "sha512-YhSbU7eMTVQO/iRbNs8j0mKRxGp4plo7sJ3GzOQ0IYjvsBiwg0T1o0zGQAYepza7lYHuPTrG5J2yDd0CE2YxSw==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0", + "@jest/types": "^26.1.0", + "@types/prettier": "^2.0.0", + "chalk": "^4.0.0", + "expect": "^26.1.0", + "graceful-fs": "^4.2.4", + "jest-diff": "^26.1.0", + "jest-get-type": "^26.0.0", + "jest-haste-map": "^26.1.0", + "jest-matcher-utils": "^26.1.0", + "jest-message-util": "^26.1.0", + "jest-resolve": "^26.1.0", + "natural-compare": "^1.4.0", + "pretty-format": "^26.1.0", + "semver": "^7.3.2" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-util": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.1.0.tgz", + "integrity": "sha512-rNMOwFQevljfNGvbzNQAxdmXQ+NawW/J72dmddsK0E8vgxXCMtwQ/EH0BiWEIxh0hhMcTsxwAxINt7Lh46Uzbg==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.4", + "is-ci": "^2.0.0", + "micromatch": "^4.0.2" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-validate": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-26.1.0.tgz", + "integrity": "sha512-WPApOOnXsiwhZtmkDsxnpye+XLb/tUISP+H6cHjfUIXvlG+eKwP+isnivsxlHCPaO9Q5wvbhloIBkdF3qUn+Nw==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0", + "camelcase": "^6.0.0", + "chalk": "^4.0.0", + "jest-get-type": "^26.0.0", + "leven": "^3.1.0", + "pretty-format": "^26.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "camelcase": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.0.0.tgz", + "integrity": "sha512-8KMDF1Vz2gzOq54ONPJS65IvTUaB1cHJ2DMM7MbPmLZljDH1qpzzLsWdiN9pHh6qvkRVDTi/07+eNGch/oLU4w==", + "dev": true + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-watcher": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-26.1.0.tgz", + "integrity": "sha512-ffEOhJl2EvAIki613oPsSG11usqnGUzIiK7MMX6hE4422aXOcVEG3ySCTDFLn1+LZNXGPE8tuJxhp8OBJ1pgzQ==", + "dev": true, + "requires": { + "@jest/test-result": "^26.1.0", + "@jest/types": "^26.1.0", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "jest-util": "^26.1.0", + "string-length": "^4.0.1" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "jest-worker": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.1.0.tgz", + "integrity": "sha512-Z9P5pZ6UC+kakMbNJn+tA2RdVdNX5WH1x+5UCBZ9MxIK24pjYtFt96fK+UwBTrjLYm232g1xz0L3eTh51OW+yQ==", + "dev": true, + "requires": { + "merge-stream": "^2.0.0", + "supports-color": "^7.0.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", + "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true + }, + "jsdom": { + "version": "16.2.2", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.2.2.tgz", + "integrity": "sha512-pDFQbcYtKBHxRaP55zGXCJWgFHkDAYbKcsXEK/3Icu9nKYZkutUXfLBwbD+09XDutkYSHcgfQLZ0qvpAAm9mvg==", + "dev": true, + "requires": { + "abab": "^2.0.3", + "acorn": "^7.1.1", + "acorn-globals": "^6.0.0", + "cssom": "^0.4.4", + "cssstyle": "^2.2.0", + "data-urls": "^2.0.0", + "decimal.js": "^10.2.0", + "domexception": "^2.0.1", + "escodegen": "^1.14.1", + "html-encoding-sniffer": "^2.0.1", + "is-potential-custom-element-name": "^1.0.0", + "nwsapi": "^2.2.0", + "parse5": "5.1.1", + "request": "^2.88.2", + "request-promise-native": "^1.0.8", + "saxes": "^5.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^3.0.1", + "w3c-hr-time": "^1.0.2", + "w3c-xmlserializer": "^2.0.0", + "webidl-conversions": "^6.0.0", + "whatwg-encoding": "^1.0.5", + "whatwg-mimetype": "^2.3.0", + "whatwg-url": "^8.0.0", + "ws": "^7.2.3", + "xml-name-validator": "^3.0.0" + } + }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true + }, + "json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "dev": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, + "json5": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", + "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "dev": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true + }, + "kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true + }, + "leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true + }, + "levenary": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/levenary/-/levenary-1.1.1.tgz", + "integrity": "sha512-mkAdOIt79FD6irqjYSs4rdbnlT5vRonMEvBVPVb3XmevfS8kgRXwfes0dhPdEtzTWD/1eNE/Bm/G1iRt6DcnQQ==", + "dev": true, + "requires": { + "leven": "^3.1.0" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "lines-and-columns": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", + "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", + "dev": true + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "lodash": { + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", + "dev": true + }, + "lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", + "dev": true + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "magic-string": { + "version": "0.25.7", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", + "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", + "dev": true, + "requires": { + "sourcemap-codec": "^1.4.4" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "makeerror": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.11.tgz", + "integrity": "sha1-4BpckQnyr3lmDk6LlYd5AYT1qWw=", + "dev": true, + "requires": { + "tmpl": "1.0.x" + } + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "^1.0.0" + } + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "micromatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", + "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "dev": true, + "requires": { + "braces": "^3.0.1", + "picomatch": "^2.0.5" + } + }, + "mime-db": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", + "dev": true + }, + "mime-types": { + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "dev": true, + "requires": { + "mime-db": "1.44.0" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "mixin-deep": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", + "dev": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + } + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=", + "dev": true + }, + "node-modules-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz", + "integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=", + "dev": true + }, + "node-notifier": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-7.0.1.tgz", + "integrity": "sha512-VkzhierE7DBmQEElhTGJIoiZa1oqRijOtgOlsXg32KrJRXsPy0NXFBqWGW/wTswnJlDCs5viRYaqWguqzsKcmg==", + "dev": true, + "optional": true, + "requires": { + "growly": "^1.3.0", + "is-wsl": "^2.1.1", + "semver": "^7.2.1", + "shellwords": "^0.1.1", + "uuid": "^7.0.3", + "which": "^2.0.2" + }, + "dependencies": { + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true, + "optional": true + } + } + }, + "node-releases": { + "version": "1.1.58", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.58.tgz", + "integrity": "sha512-NxBudgVKiRh/2aPWMgPR7bPTX0VPmGx5QBwCtdHitnqFE5/O8DeBXuIMH1nwNnw/aMo6AjOrpsHzfY3UbUJ7yg==", + "dev": true + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, + "nwsapi": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.0.tgz", + "integrity": "sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ==", + "dev": true + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true + }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "^3.0.0" + } + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + } + }, + "p-each-series": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-each-series/-/p-each-series-2.1.0.tgz", + "integrity": "sha512-ZuRs1miPT4HrjFa+9fRfOFXxGJfORgelKV9f9nNOWw2gl6gVsRaVDOQP0+MI0G0wGKns1Yacsu0GjOFbTK0JFQ==", + "dev": true + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "parse-json": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.0.0.tgz", + "integrity": "sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1", + "lines-and-columns": "^1.1.6" + } + }, + "parse5": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz", + "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==", + "dev": true + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true + }, + "picomatch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "dev": true + }, + "pirates": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.1.tgz", + "integrity": "sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA==", + "dev": true, + "requires": { + "node-modules-regexp": "^1.0.0" + } + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, + "platform": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.5.tgz", + "integrity": "sha512-TuvHS8AOIZNAlE77WUDiR4rySV/VMptyMfcfeoMgs4P8apaZM3JrnbzBiixKUv+XR6i+BXrQh8WAnjaSPFO65Q==", + "dev": true + }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "prettier": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", + "integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==", + "dev": true + }, + "pretty-format": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.1.0.tgz", + "integrity": "sha512-GmeO1PEYdM+non4BKCj+XsPJjFOJIPnsLewqhDVoqY1xo0yNmDas7tC2XwpMrRAHR3MaE2hPo37deX5OisJ2Wg==", + "dev": true, + "requires": { + "@jest/types": "^26.1.0", + "ansi-regex": "^5.0.0", + "ansi-styles": "^4.0.0", + "react-is": "^16.12.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + } + } + }, + "prompts": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.3.2.tgz", + "integrity": "sha512-Q06uKs2CkNYVID0VqwfAl9mipo99zkBv/n2JtWY89Yxa3ZabWSrs0e2KTudKVa3peLUvYXMefDqIleLPVUBZMA==", + "dev": true, + "requires": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.4" + } + }, + "psl": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", + "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", + "dev": true + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "dev": true + }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true + }, + "read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dev": true, + "requires": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "dependencies": { + "type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true + } + } + }, + "read-pkg-up": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", + "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", + "dev": true, + "requires": { + "find-up": "^4.1.0", + "read-pkg": "^5.2.0", + "type-fest": "^0.8.1" + } + }, + "regenerate": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.1.tgz", + "integrity": "sha512-j2+C8+NtXQgEKWk49MMP5P/u2GhnahTtVkRIHr5R5lVRlbKvmQ+oS+A5aLKWp2ma5VkT8sh6v+v4hbH0YHR66A==", + "dev": true + }, + "regenerate-unicode-properties": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz", + "integrity": "sha512-F9DjY1vKLo/tPePDycuH3dn9H1OTPIkVD9Kz4LODu+F2C75mgjAJ7x/gwy6ZcSNRAAkhNlJSOHRe8k3p+K9WhA==", + "dev": true, + "requires": { + "regenerate": "^1.4.0" + } + }, + "regenerator-runtime": { + "version": "0.13.5", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz", + "integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==", + "dev": true + }, + "regenerator-transform": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.14.5.tgz", + "integrity": "sha512-eOf6vka5IO151Jfsw2NO9WpGX58W6wWmefK3I1zEGr0lOD0u8rwPaNqQL1aRxUaxLeKO3ArNh3VYg1KbaD+FFw==", + "dev": true, + "requires": { + "@babel/runtime": "^7.8.4" + } + }, + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" + } + }, + "regexp-to-ast": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/regexp-to-ast/-/regexp-to-ast-0.5.0.tgz", + "integrity": "sha512-tlbJqcMHnPKI9zSrystikWKwHkBqu2a/Sgw01h3zFjvYrMxEDYHzzoMZnUrbIfpTFEsoRnnviOXNCzFiSc54Qw==" + }, + "regexpu-core": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.7.0.tgz", + "integrity": "sha512-TQ4KXRnIn6tz6tjnrXEkD/sshygKH/j5KzK86X8MkeHyZ8qst/LZ89j3X4/8HEIfHANTFIP/AbXakeRhWIl5YQ==", + "dev": true, + "requires": { + "regenerate": "^1.4.0", + "regenerate-unicode-properties": "^8.2.0", + "regjsgen": "^0.5.1", + "regjsparser": "^0.6.4", + "unicode-match-property-ecmascript": "^1.0.4", + "unicode-match-property-value-ecmascript": "^1.2.0" + } + }, + "regjsgen": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.5.2.tgz", + "integrity": "sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A==", + "dev": true + }, + "regjsparser": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.6.4.tgz", + "integrity": "sha512-64O87/dPDgfk8/RQqC4gkZoGyyWFIEUTTh80CU6CWuK5vkCGyekIx+oKcEIYtP/RAxSQltCZHCNu/mdd7fqlJw==", + "dev": true, + "requires": { + "jsesc": "~0.5.0" + }, + "dependencies": { + "jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", + "dev": true + } + } + }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "repeat-element": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.5.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dev": true, + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + } + } + }, + "request-promise-core": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.3.tgz", + "integrity": "sha512-QIs2+ArIGQVp5ZYbWD5ZLCY29D5CfWizP8eWnm8FoGD1TX61veauETVQbrV60662V0oFBkrDOuaBI8XgtuyYAQ==", + "dev": true, + "requires": { + "lodash": "^4.17.15" + } + }, + "request-promise-native": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.8.tgz", + "integrity": "sha512-dapwLGqkHtwL5AEbfenuzjTYg35Jd6KPytsC2/TLkVMz8rm+tNt72MGUWT1RP/aYawMpN6HqbNGBQaRcBtjQMQ==", + "dev": true, + "requires": { + "request-promise-core": "1.1.3", + "stealthy-require": "^1.1.1", + "tough-cookie": "^2.3.3" + }, + "dependencies": { + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dev": true, + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + } + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dev": true, + "requires": { + "resolve-from": "^5.0.0" + } + }, + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "rollup": { + "version": "2.18.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.18.2.tgz", + "integrity": "sha512-+mzyZhL9ZyLB3eHBISxRNTep9Z2qCuwXzAYkUbFyz7yNKaKH03MFKeiGOS1nv2uvPgDb4ASKv+FiS5mC4h5IFQ==", + "dev": true, + "requires": { + "fsevents": "~2.1.2" + } + }, + "rollup-plugin-babel": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-babel/-/rollup-plugin-babel-4.4.0.tgz", + "integrity": "sha512-Lek/TYp1+7g7I+uMfJnnSJ7YWoD58ajo6Oarhlex7lvUce+RCKRuGRSgztDO3/MF/PuGKmUL5iTHKf208UNszw==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.0.0", + "rollup-pluginutils": "^2.8.1" + } + }, + "rollup-plugin-terser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-6.1.0.tgz", + "integrity": "sha512-4fB3M9nuoWxrwm39habpd4hvrbrde2W2GG4zEGPQg1YITNkM3Tqur5jSuXlWNzbv/2aMLJ+dZJaySc3GCD8oDw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.8.3", + "jest-worker": "^26.0.0", + "serialize-javascript": "^3.0.0", + "terser": "^4.7.0" + } + }, + "rollup-pluginutils": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", + "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", + "dev": true, + "requires": { + "estree-walker": "^0.6.1" + }, + "dependencies": { + "estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + } + } + }, + "rsvp": { + "version": "4.8.5", + "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", + "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", + "dev": true + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "~0.1.10" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "sane": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/sane/-/sane-4.1.0.tgz", + "integrity": "sha512-hhbzAgTIX8O7SHfp2c8/kREfEn4qO/9q8C9beyY6+tvZ87EpoZ3i1RIEvp27YBswnNbY9mWd6paKVmKbAgLfZA==", + "dev": true, + "requires": { + "@cnakazawa/watch": "^1.0.3", + "anymatch": "^2.0.0", + "capture-exit": "^2.0.0", + "exec-sh": "^0.3.2", + "execa": "^1.0.0", + "fb-watchman": "^2.0.0", + "micromatch": "^3.1.4", + "minimist": "^1.1.1", + "walker": "~1.0.5" + }, + "dependencies": { + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "dev": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + } + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + } + } + }, + "saxes": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz", + "integrity": "sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw==", + "dev": true, + "requires": { + "xmlchars": "^2.2.0" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "serialize-javascript": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.1.0.tgz", + "integrity": "sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "set-value": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "shellwords": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", + "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", + "dev": true + }, + "sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, + "requires": { + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "dev": true, + "requires": { + "kind-of": "^3.2.0" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "source-map-resolve": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", + "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", + "dev": true, + "requires": { + "atob": "^2.1.2", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "sourcemap-codec": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", + "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", + "dev": true + }, + "spdx-correct": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", + "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", + "dev": true + }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "dev": true, + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "stack-utils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.2.tgz", + "integrity": "sha512-0H7QK2ECz3fyZMzQ8rH0j2ykpfbnd20BFtfg/SqVC2+sCTtcw0aDTGB7dk+de4U4uUeuz6nOtJcrkFFLG1B0Rg==", + "dev": true, + "requires": { + "escape-string-regexp": "^2.0.0" + }, + "dependencies": { + "escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true + } + } + }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "^0.2.5", + "object-copy": "^0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "stealthy-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", + "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", + "dev": true + }, + "string-length": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.1.tgz", + "integrity": "sha512-PKyXUd0LK0ePjSOnWn34V2uD6acUWev9uy0Ft05k0E8xRW+SKcA0F7eMr7h5xlzfn+4O3N+55rduYyet3Jk+jw==", + "dev": true, + "requires": { + "char-regex": "^1.0.2", + "strip-ansi": "^6.0.0" + } + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true + }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "supports-hyperlinks": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-2.1.0.tgz", + "integrity": "sha512-zoE5/e+dnEijk6ASB6/qrK+oYdm2do1hjoLWrqUC/8WEIW1gbxFcKuBof7sW8ArN6e+AYvsE8HBGiVRWL/F5CA==", + "dev": true, + "requires": { + "has-flag": "^4.0.0", + "supports-color": "^7.0.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true + }, + "terminal-link": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", + "integrity": "sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ==", + "dev": true, + "requires": { + "ansi-escapes": "^4.2.1", + "supports-hyperlinks": "^2.0.0" + } + }, + "terser": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.8.0.tgz", + "integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==", + "dev": true, + "requires": { + "commander": "^2.20.0", + "source-map": "~0.6.1", + "source-map-support": "~0.5.12" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + } + }, + "throat": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz", + "integrity": "sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==", + "dev": true + }, + "tmpl": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz", + "integrity": "sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE=", + "dev": true + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "tough-cookie": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-3.0.1.tgz", + "integrity": "sha512-yQyJ0u4pZsv9D4clxO69OEjLWYw+jbgspjTue4lTQZLfV0c5l1VmK2y1JK8E9ahdpltPOaAThPcp5nKPUgSnsg==", + "dev": true, + "requires": { + "ip-regex": "^2.1.0", + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + }, + "tr46": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.0.2.tgz", + "integrity": "sha512-3n1qG+/5kg+jrbTzwAykB5yRYtQCTqOGKq5U5PE3b0a1/mzo6snDhjGS0zJVJunO0NrT3Dg1MLy5TjWP/UJppg==", + "dev": true, + "requires": { + "punycode": "^2.1.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dev": true, + "requires": { + "is-typedarray": "^1.0.0" + } + }, + "unicode-canonical-property-names-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", + "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==", + "dev": true + }, + "unicode-match-property-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", + "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", + "dev": true, + "requires": { + "unicode-canonical-property-names-ecmascript": "^1.0.4", + "unicode-property-aliases-ecmascript": "^1.0.4" + } + }, + "unicode-match-property-value-ecmascript": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.2.0.tgz", + "integrity": "sha512-wjuQHGQVofmSJv1uVISKLE5zO2rNGzM/KCYZch/QQvez7C1hUhBIuZ701fYXExuufJFMPhv2SyL8CyoIfMLbIQ==", + "dev": true + }, + "unicode-property-aliases-ecmascript": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.1.0.tgz", + "integrity": "sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg==", + "dev": true + }, + "union-value": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^2.0.1" + } + }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "^0.3.1", + "isobject": "^3.0.0" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + } + } + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, + "use": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "dev": true + }, + "uuid": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-7.0.3.tgz", + "integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==", + "dev": true, + "optional": true + }, + "v8-to-istanbul": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-4.1.4.tgz", + "integrity": "sha512-Rw6vJHj1mbdK8edjR7+zuJrpDtKIgNdAvTSAcpYfgMIw+u2dPDntD3dgN4XQFLU2/fvFQdzj+EeSGfd/jnY5fQ==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^1.6.0", + "source-map": "^0.7.3" + }, + "dependencies": { + "source-map": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", + "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "dev": true + } + } + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "w3c-hr-time": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", + "integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==", + "dev": true, + "requires": { + "browser-process-hrtime": "^1.0.0" + } + }, + "w3c-xmlserializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-2.0.0.tgz", + "integrity": "sha512-4tzD0mF8iSiMiNs30BiLO3EpfGLZUT2MSX/G+o7ZywDzliWQ3OPtTZ0PTC3B3ca1UAf4cJMHB+2Bf56EriJuRA==", + "dev": true, + "requires": { + "xml-name-validator": "^3.0.0" + } + }, + "walker": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.7.tgz", + "integrity": "sha1-L3+bj9ENZ3JisYqITijRlhjgKPs=", + "dev": true, + "requires": { + "makeerror": "1.0.x" + } + }, + "webidl-conversions": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", + "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==", + "dev": true + }, + "whatwg-encoding": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", + "integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==", + "dev": true, + "requires": { + "iconv-lite": "0.4.24" + } + }, + "whatwg-mimetype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", + "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==", + "dev": true + }, + "whatwg-url": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.1.0.tgz", + "integrity": "sha512-vEIkwNi9Hqt4TV9RdnaBPNt+E2Sgmo3gePebCRgZ1R7g6d23+53zCTnuB0amKI4AXq6VM8jj2DUAa0S1vjJxkw==", + "dev": true, + "requires": { + "lodash.sortby": "^4.7.0", + "tr46": "^2.0.2", + "webidl-conversions": "^5.0.0" + }, + "dependencies": { + "webidl-conversions": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz", + "integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==", + "dev": true + } + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write-file-atomic": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "is-typedarray": "^1.0.0", + "signal-exit": "^3.0.2", + "typedarray-to-buffer": "^3.1.5" + } + }, + "ws": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", + "integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==", + "dev": true + }, + "xml-name-validator": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", + "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", + "dev": true + }, + "xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true + }, + "xregexp": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.3.0.tgz", + "integrity": "sha512-7jXDIFXh5yJ/orPn4SXjuVrWWoi4Cr8jfV1eHv9CixKSbU+jY4mxfrBwAuDvupPNKpMUY+FeIqsVw/JLT9+B8g==", + "dev": true, + "requires": { + "@babel/runtime-corejs3": "^7.8.3" + } + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yargs": { + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.0.tgz", + "integrity": "sha512-D3fRFnZwLWp8jVAAhPZBsmeIHY8tTsb8ItV9KaAaopmC6wde2u6Yw29JBIZHXw14kgkRnYmDgmQU4FVMDlIsWw==", + "dev": true, + "requires": { + "cliui": "^6.0.0", + "decamelize": "^3.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "dependencies": { + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + } + } + } + } +} diff --git a/plugins/match2/package.json b/plugins/match2/package.json new file mode 100644 index 000000000..380c9af5e --- /dev/null +++ b/plugins/match2/package.json @@ -0,0 +1,80 @@ +{ + "name": "compromise-match2", + "version": "1.2.0", + "description": "Better regex like matching for nlp-compromise", + "main": "dist/compromise-match2.js", + "unpkg": "dist/compromise-match2.min.js", + "module": "dist/compromise-match2.mjs", + "scripts": { + "test": "jest", + "test:coverage": "jest --coverage", + "test:watch": "jest --watch", + "test:watch:cover": "jest --watchAll --coverage", + "build": "rollup -c", + "pretty": "prettier --write .", + "bench": "node bench.js" + }, + "prettier": { + "trailingComma": "es5", + "tabWidth": 2, + "semi": true + }, + "jest": { + "collectCoverageFrom": [ + "src/**/*.js", + "!src/**/*.test.js" + ], + "coverageThreshold": { + "global": { + "branches": 100, + "functions": 100, + "lines": 100, + "statements": 100 + } + } + }, + "repository": { + "type": "git", + "url": "git+https://github.com/catalogm/compromise-match2.git" + }, + "keywords": [ + "compromise", + "nlp-compromise", + "regex", + "match", + "nlp", + "natural-language-parsing", + "natural", + "language", + "pikevm" + ], + "author": "Kelvin Hammond ", + "license": "GPL-3.0-or-later", + "bugs": { + "url": "https://github.com/catalogm/compromise-match2/issues" + }, + "homepage": "https://github.com/catalogm/compromise-match2#readme", + "files": [ + "dist/" + ], + "eslintIgnore": [ + "dist/*.js" + ], + "dependencies": { + "chevrotain": "^7.0.1" + }, + "devDependencies": { + "@babel/core": "^7.10.4", + "@babel/preset-env": "^7.10.4", + "@rollup/plugin-commonjs": "^13.0.0", + "@rollup/plugin-node-resolve": "^8.1.0", + "babel-jest": "^26.1.0", + "benchmark": "^2.1.4", + "compromise": "^13.3.1", + "jest": "^26.1.0", + "prettier": "^2.0.5", + "rollup": "^2.18.2", + "rollup-plugin-babel": "^4.4.0", + "rollup-plugin-terser": "^6.1.0" + } +} diff --git a/plugins/match2/rollup.config.js b/plugins/match2/rollup.config.js new file mode 100644 index 000000000..75dcdb794 --- /dev/null +++ b/plugins/match2/rollup.config.js @@ -0,0 +1,71 @@ +import commonjs from "@rollup/plugin-commonjs"; +import resolve from "@rollup/plugin-node-resolve"; +import { terser } from "rollup-plugin-terser"; +import babel from "rollup-plugin-babel"; + +import { version } from "./package.json"; + +const name = "compromise-match2"; +const banner = `/* ${name} ${version} GPLv3 */`; + +export default [ + { + input: "src/index.js", + output: [ + { + file: `dist/${name}.js`, + format: "umd", + sourcemap: true, + name: "compromiseMatch2", + banner, + }, + ], + plugins: [ + resolve(), + commonjs(), + babel({ + babelrc: false, + presets: ["@babel/preset-env"], + }), + ], + }, + { + input: "src/index.js", + output: [ + { + file: `dist/${name}.mjs`, + format: "esm", + name: "compromiseMatch2", + banner, + }, + ], + plugins: [ + resolve(), + commonjs(), + babel({ + babelrc: false, + presets: ["@babel/preset-env"], + }), + ], + }, + { + input: "src/index.js", + output: [ + { + file: `dist/${name}.min.js`, + format: "umd", + name: "compromiseMatch2", + banner, + }, + ], + plugins: [ + resolve(), + commonjs(), + babel({ + babelrc: false, + presets: ["@babel/preset-env"], + }), + terser(), + ], + }, +]; diff --git a/plugins/match2/src/constants.js b/plugins/match2/src/constants.js new file mode 100644 index 000000000..98dddc7cb --- /dev/null +++ b/plugins/match2/src/constants.js @@ -0,0 +1,17 @@ +export const NOOP = Symbol("NOOP"); // basically continue +export const MATCH_ANY = Symbol("MATCH_ANY"); +export const MATCH_WORD = Symbol("MATCH_WORD"); +export const MATCH_TAG = Symbol("MATCH_TAG"); +export const MATCH_METHOD = Symbol("MATCH_METHOD"); +export const MATCH_END = Symbol("MATCH_END"); +export const JMP = Symbol("JMP"); +export const SPLIT = Symbol("SPLIT"); +export const GLOBAL_SAVE = Symbol("GLOBAL_SAVE"); // Set global save value, if true saves results. +export const MATCH = Symbol("MATCH"); +export const OGROUP = Symbol("OGROUP"); // open group +export const CGROUP = Symbol("CGROUP"); // close group +export const INCV = Symbol("INCV"); // increment a value, set to 0 by default +export const JMP_LT = Symbol("JMP_LT"); // jmp if a variable is less than value else continue +export const SPLIT_LT = Symbol("SPLIT_LT"); // split if a variable is less than value else continue +export const LOOKAHEAD = Symbol("LOOKAHEAD"); +export const NEGATIVE_LOOKAHEAD = Symbol("NEGATIVE_LOOKAHEAD"); diff --git a/plugins/match2/src/index.js b/plugins/match2/src/index.js new file mode 100644 index 000000000..d4e26b27b --- /dev/null +++ b/plugins/match2/src/index.js @@ -0,0 +1,20 @@ +import { NLPRegexP } from "./regex"; + +export { NLPMatchParser } from "./parser"; +export { NLPRegexP, NLPRegexParseError } from "./regex"; + +// nlp compromise plugin +export const Match2Plugin = (Doc, world, nlp, Phrase) => { + const compileRegex = (regex) => new NLPRegexP(regex); + nlp.compileRegex = compileRegex; + Doc.prototype.compileRegex = compileRegex; + + const match2 = function (regex) { + // function, non arrow, need bind for this which is doc/phrase + regex = new NLPRegexP(regex); // coerce the value + return regex.exec(this); + }; + Doc.prototype.match2 = match2; + Phrase.prototype.match2 = match2; +}; +export default Match2Plugin; diff --git a/plugins/match2/src/index.test.js b/plugins/match2/src/index.test.js new file mode 100644 index 000000000..6ea0d91d9 --- /dev/null +++ b/plugins/match2/src/index.test.js @@ -0,0 +1,356 @@ +import NLP from "compromise"; +import compromise_match2 from "./index"; +import { NLPRegexParseError } from "./index"; + +describe("match2 plugin", () => { + const nlp = NLP.clone().extend(compromise_match2); + let doc = null; + + beforeEach(() => { + doc = nlp("hello hello world"); + }); + + describe("edge case", () => { + it("invalid compiled regex code throws exception", () => { + const regex = nlp.compileRegex("hello"); + regex.prog[0].code = null; + expect(() => doc.match2(regex)).toThrow(/Unsuppored Op code: null/); + }); + }); + + describe("plugin defines", () => { + it("extend adds match2 functions to nlp, doc, and phrase", () => { + expect(nlp.compileRegex).toBeDefined(); + expect(doc.compileRegex).toBeDefined(); + expect(doc.match2).toBeDefined(); + expect(doc.match2).toBeDefined(); + + const phrase = doc.list[0]; + expect(phrase.match2).toBeDefined(); + }); + }); + + describe("regex matches phrase", () => { + it("matches phrase", () => { + const phrase = doc.list[0]; + expect(phrase.match2("world").text()).toEqual("world"); + }); + }); + + describe("handles previous bugs", () => { + it("match term should handle match_end or when term.tags is nullish", () => { + // this particular query triggers it, match2 ends up with MATCH_END as a + // tag, probably the nested groups that allows it to get there where it + // keeps trying to match, this is fine / expected + doc = nlp("remind me to reply to @spencermountain today"); + expect( + doc + .match2( + "((remind|remember) (me|you|.) to? do? (?P.+) (?P#Date+))" + ) + .text() + ).toEqual(doc.text()); + }); + }); + + describe("regex matches doc", () => { + it("successful match sets found", () => { + expect(doc.match2("world").found).toBe(true); + }); + + it("returns empty doc when no matches", () => { + const match = doc.match2("no match"); + expect(match.found).toBe(false); + expect(match.text()).toBe(""); + }); + + describe("values", () => { + it("word", () => { + expect(doc.match2("world").text()).toEqual("world"); + }); + + it("tag", () => { + expect(doc.match2("#Noun").text()).toEqual("world"); + }); + + it("any", () => { + expect(doc.match2(".").text()).toEqual("hello"); + }); + + it("mathod", () => { + expect(nlp("a, b, c").match2("@hasComma+").text()).toEqual("a, b"); + }); + + describe("escaped words", () => { + it("tag", () => { + expect(nlp("#Noun").match2("\\#Noun").text()).toEqual("#Noun"); + }); + + it("methods", () => { + expect(nlp("@hasComma").match2("\\@hasComma").text()).toEqual( + "@hasComma" + ); + }); + }); + }); + + describe("match locations", () => { + it("matches anywhere when not start of", () => { + expect( + nlp("hi there hello world this is a match").match2("world").text() + ).toEqual("world"); + }); + + it("matches startOf", () => { + expect(doc.match2("^hello").text()).toEqual("hello"); + expect(doc.match2("^world").text()).toEqual(""); + }); + + it("matches endOf", () => { + expect(doc.match2("world$").text()).toEqual("world"); + expect(doc.match2("hello$").text()).toEqual(""); + }); + }); + + describe("value modifiers", () => { + it("one or more", () => { + expect(nlp("hello world").match2(".+").text()).toEqual("hello world"); + expect(nlp("hello hello world").match2("hello+").text()).toEqual( + "hello hello" + ); + }); + + it("zero or more", () => { + expect(nlp("hello hello world").match2("hello*").text()).toEqual( + "hello hello" + ); + expect(nlp("hello hello world").match2("none*").text()).toEqual(""); + }); + + it("zero or one", () => { + expect(nlp("hello hello world").match2("hello?").text()).toEqual( + "hello" + ); + expect(nlp("world").match2("hello?").text()).toEqual(""); + }); + + describe("ranges", () => { + describe("greedy", () => { + it("match exact", () => { + expect(doc.match2("hello{1}").text()).toEqual("hello"); + expect(doc.match2("hello{1,1}").text()).toEqual("hello"); + expect(doc.match2("hello{2}").text()).toEqual("hello hello"); + expect(doc.match2("hello{2,2}").text()).toEqual("hello hello"); + expect(doc.match2("hello{3}").text()).toEqual(""); + }); + + it("match minimum", () => { + expect(doc.match2("hello{1,}").text()).toEqual("hello hello"); + expect(doc.match2("hello{2,}").text()).toEqual("hello hello"); + expect(doc.match2("hello{1,}").text()).toEqual("hello hello"); + expect(doc.match2("hello{2,} world").text()).toEqual( + "hello hello world" + ); + }); + + it("match maximum", () => { + expect(doc.match2("hello{,1} world").text()).toEqual("hello world"); + expect(doc.match2("hello{,2}").text()).toEqual("hello hello"); + expect(doc.match2("hello{,1}").text()).toEqual("hello"); + }); + + it("match minimum and maximum", () => { + expect(doc.match2("hello{1,2}").text()).toEqual("hello hello"); + expect(doc.match2("hello{0,2}").text()).toEqual("hello hello"); + expect(doc.match2("hello{0,1}").text()).toEqual("hello"); + expect(doc.match2("hello{0,1} world").text()).toEqual( + "hello world" + ); + expect(doc.match2("hello{0,2} world").text()).toEqual( + "hello hello world" + ); + }); + + it("skip zero range", () => { + expect(doc.match2("hello{0}").text()).toEqual(""); + expect(doc.match2("hello hello{0}").text()).toEqual("hello"); + expect(doc.match2("hello{0} world").text()).toEqual("world"); + }); + + it("throws error on invalid range", () => { + expect(() => doc.match2("hello{,}")).toThrow( + /Range min or max must be defined/ + ); + expect(() => doc.match2("hello{2,1}")).toThrow(NLPRegexParseError); + expect(() => doc.match2("hello{,-1}")).toThrow(NLPRegexParseError); + }); + }); + + describe("non greedy", () => { + it("match exact", () => { + expect(doc.match2("hello{1}?").text()).toEqual("hello"); + expect(doc.match2("hello{1,1}?").text()).toEqual("hello"); + expect(doc.match2("hello{2}?").text()).toEqual("hello hello"); + expect(doc.match2("hello{2,2}?").text()).toEqual("hello hello"); + expect(doc.match2("hello{3}?").text()).toEqual(""); + }); + + it("match minimum", () => { + expect(doc.match2("hello{1,}?").text()).toEqual("hello"); + expect(doc.match2("hello{2,}?").text()).toEqual("hello hello"); + expect(doc.match2("hello{1,}?").text()).toEqual("hello"); + expect(doc.match2("hello{2,}? world").text()).toEqual( + "hello hello world" + ); + }); + + it("match maximum", () => { + expect(doc.match2("hello{,1}? world").text()).toEqual( + "hello world" + ); + expect(doc.match2("hello{,2}?").text()).toEqual(""); + expect(doc.match2("hello{,1}?").text()).toEqual(""); + }); + + it("match minimum and maximum", () => { + expect(doc.match2("hello{1,2}?").text()).toEqual("hello"); + expect(doc.match2("hello{0,2}?").text()).toEqual(""); + expect(doc.match2("hello{0,1}?").text()).toEqual(""); + expect(doc.match2("hello{0,1}? world").text()).toEqual( + "hello world" + ); + expect(doc.match2("hello{0,2}? world").text()).toEqual( + "hello hello world" + ); + }); + + it("skip zero range", () => { + expect(doc.match2("hello{0}?").text()).toEqual(""); + expect(doc.match2("hello hello{0}?").text()).toEqual("hello"); + expect(doc.match2("hello{0}? world").text()).toEqual("world"); + }); + + it("throws error on invalid range", () => { + expect(() => doc.match2("hello{,}?")).toThrow( + /Range min or max must be defined/ + ); + expect(() => doc.match2("hello{2,1}?")).toThrow(NLPRegexParseError); + expect(() => doc.match2("hello{,-1}?")).toThrow(NLPRegexParseError); + }); + }); + }); + + describe("non greedy", () => { + it("one or more", () => { + expect(nlp("hello hello world").match2("hello+?").text()).toEqual( + "hello" + ); + expect( + nlp("hello hello world").match2("hello+? world").text() + ).toEqual("hello hello world"); + }); + + it("zero or more", () => { + expect(nlp("hello hello world").match2("hello*?").text()).toEqual(""); + expect( + nlp("hello hello world").match2("hello*? world").text() + ).toEqual("hello hello world"); + }); + + it("zero or one", () => { + expect(nlp("hello hello world").match2("hello??").text()).toEqual(""); + expect( + nlp("hello hello world").match2("hello?? world").text() + ).toEqual("hello world"); + }); + }); + }); + + describe("groups", () => { + describe("default group", () => { + it("matches", () => { + const match = nlp("hello world today").match2("hello (world)?"); + expect(match.text()).toEqual("hello world"); + expect(match.group(0).text()).toEqual("world"); + expect(Object.keys(match.groups())).toEqual(["0"]); + }); + + it("matches nested groups", () => { + const match = doc.match2("(hello (hello+ world+)+)+"); + expect(Object.keys(match.groups())).toHaveLength(2); + expect(match.groups(0).text()).toEqual("hello hello world"); + expect(match.groups(1).text()).toEqual("hello world"); + }); + + it("matches optional groups", () => { + const match = nlp("hello").match2("hello (world)?"); + expect(match.text()).toEqual("hello"); + expect(match.group(0).text()).toBe(""); + expect(match.groups()).toEqual({}); + }); + + it("matches groups with no matches", () => { + const match = nlp("hello").match2("hello (world?)"); + expect(match.text()).toEqual("hello"); + expect(match.group(0).text()).toBe(""); + expect(Object.keys(match.groups())).toEqual(["0"]); + }); + + it("captures the group matches", () => { + const match = doc.match2("(hello+) world"); + expect(match.text()).toEqual("hello hello world"); + expect(match.groups(0).text()).toEqual("hello hello"); + expect(Object.keys(match.groups())).toEqual(["0"]); + }); + + it("matches any pipe seperated value statements, OR operator", () => { + const match = doc.match2("(world|hello)"); + expect(match.text()).toEqual("hello"); + expect(match.group(0).text()).toEqual("hello"); + expect(Object.keys(match.groups())).toEqual(["0"]); + }); + + it("only saves the last matched value for group", () => { + const match = doc.match2("(world|hello)+"); + expect(match.text()).toEqual("hello hello world"); + expect(match.group(0).text()).toEqual("world"); + expect(Object.keys(match.groups())).toEqual(["0"]); + }); + }); + + describe("named capture groups", () => { + it("matches and saves named group", () => { + const text = nlp("hello world") + .match2("(?Phello)") + .groups("what") + .text(); + expect(text).toEqual("hello"); + }); + }); + + describe("non-capturing group", () => { + it("matches but does not save non-capturing group", () => { + const match = doc.match2("hello (?:world)"); + expect(match.text()).toEqual("hello world"); + expect(match.groups()).toEqual({}); + }); + }); + + describe("lookahead group", () => { + it("asserts matches ahead and does not consume token", () => { + const match = doc.match2("hello (?=world) ."); + expect(match.text()).toEqual("hello world"); + expect(match.groups()).toEqual({}); + }); + }); + + describe("negative lookahead group", () => { + it("asserts does not match ahead and does not consume token", () => { + const match = doc.match2("hello (?!hello) ."); + expect(match.text()).toEqual("hello world"); + expect(match.groups()).toEqual({}); + }); + }); + }); + }); +}); diff --git a/plugins/match2/src/parser.js b/plugins/match2/src/parser.js new file mode 100644 index 000000000..f1715b3e6 --- /dev/null +++ b/plugins/match2/src/parser.js @@ -0,0 +1,646 @@ +import { EmbeddedActionsParser, Lexer, createToken } from "chevrotain"; + +import { + NOOP, + MATCH_ANY, + MATCH_TAG, + MATCH_WORD, + MATCH_METHOD, + MATCH_END, + JMP, + SPLIT, + GLOBAL_SAVE, + MATCH, + OGROUP, + CGROUP, + INCV, + JMP_LT, + SPLIT_LT, + LOOKAHEAD, + NEGATIVE_LOOKAHEAD, +} from "./constants"; + +const StartOf = createToken({ name: "StartOf", pattern: /\^/ }); +const EndOf = createToken({ name: "EndOf", pattern: /\$/ }); +const Tag = createToken({ name: "Tag", pattern: /#([_-\w]|\\.)+/ }); +const EscapedWord = createToken({ + name: "EscapedWord", + pattern: /\\[#@]([_-\w]|\\.)+/, +}); +const Word = createToken({ name: "Word", pattern: /([_-\w]|\\.)+/ }); +const Method = createToken({ name: "Method", pattern: /@[_-\w]+/ }); +const Question = createToken({ + name: "Question", + pattern: /\?/, + longer_alt: Word, +}); +const Exclamation = createToken({ + name: "Exclamation", + pattern: /!/, + longer_alt: Word, +}); +const Equals = createToken({ name: "Equals", pattern: /=/, longer_alt: Word }); +const Pound = createToken({ name: "Pound", pattern: /#/, longer_alt: Tag }); +const Dot = createToken({ name: "Dot", pattern: /\./, longer_alt: Word }); +const RegexP = createToken({ name: "RegexP", pattern: /\/.*?\// }); +const Pipe = createToken({ name: "Pipe", pattern: /\|/ }); +const Comma = createToken({ name: "Comma", pattern: /,/, longer_alt: Word }); +const Colon = createToken({ name: "Colon", pattern: /:/, longer_alt: Word }); +const Plus = createToken({ name: "Plus", pattern: /\+/ }); +const Star = createToken({ name: "Star", pattern: /\*/ }); +const Zero = createToken({ name: "Zero", pattern: /0/, longer_alt: Word }); +const PositiveInt = createToken({ + name: "PositiveInt", + pattern: /[1-9]\d*/, + longer_alt: Word, +}); +const LParenthesis = createToken({ name: "LParenthesis", pattern: /\(/ }); +const RParenthesis = createToken({ name: "RParenthesis", pattern: /\)/ }); +const LCurly = createToken({ name: "LCurly", pattern: /\{/ }); +const RCurly = createToken({ name: "RCurly", pattern: /\}/ }); +const NamedGroupBegin = createToken({ name: "NamedGroupBegin", pattern: /P/, + longer_alt: Word, +}); +const WhiteSpace = createToken({ + name: "WhiteSpace", + pattern: /\s+/, + group: Lexer.SKIPPED, +}); + +export const allTokens = [ + NamedGroupBegin, + NamedGroupEnd, + WhiteSpace, + StartOf, + EndOf, + Zero, + PositiveInt, + Dot, + EscapedWord, + Word, + Method, + Tag, + Exclamation, + Equals, + Pound, + Colon, + Question, + Plus, + Star, + Comma, + Pipe, + LParenthesis, + RParenthesis, + LCurly, + RCurly, +]; + +// Notes or something like it, may not be accurate. +// (a|b) +// 0. split 1, 3 +// 1. char a +// 2. jmp 4 +// 3. char b +// 4. match +// +// (a|b|c) +// 0. split 1, 3, 5 +// 1. char a +// 2. jmp 7 +// 3. char b +// 4. jmp 7 +// 5. char c +// 6. match +// +// ((a|b)|c) +// 0. split 1, 6 +// 1. split 2, 4 +// 2. char a +// 3. jmp 7 +// 4. char b +// 5. jmp 7 +// 6. char c +// 7. match +// +// a{2} +// 0. noop +// 1. char a +// 2. incv i 1, def=0 +// 3. jmp_lt i 2 [0] +// +// a{2, 3} +// 0. noop +// 1. char a +// 2. incv i 1, def=0 +// 3. jmp_lt 0 i [2] +// 4. split_lt i 3 [0, 6] +// +// a{,3} +// 0. noop +// 1. char a +// 2. incv i 1, def=0 +// 3. split_lt i 3 [0, 5] +// +// a{3,} +// 0. noop +// 1. char a +// 2. incv i 1, def=0 +// 3. jmp_lt i 3 +// 4. split [0, 6] +// +// a(!b) +// 0. noop +// 1. char a +// 2. nlookahead prog // negative lookahead is a sub program +// 1. match b +// 2. match +// 2.1. if found stop, else continue at current sp +// + +export class NLPMatchParser extends EmbeddedActionsParser { + constructor() { + super(allTokens); + + /* + * '.' + * '^remind #Noun$' + * '\#Noun' -- escaped word containing # + * '(remind|#Noun)' + * '(remind+|#Noun)' + * '(remind|#Noun)+' + * '#Noun{2}' + * '#Noun?' + * '#Noun*' + * '(?:remind #Noun)' -- non capturing group + * '(?P#Noun)' + * '(?P#Noun)+' + * + * matchStatement ([startOf] valueStatement [endOf]) + * valueStatement (value [...value]) + * rangeModifier (LCurly, ((PositiveInt|Zero) [, PositiveInt]) RCurly) + * oneOrMore (Plus) + * zeroOrMore (Star) + * zeroOrOne (Question) + * valueModifier (oneOrMore, rangeModifier, zeroOrMore, zeroOrOne) + * value (dot, word, escapedWord, tag, Zero, PositiveInt, group)[valueModifier] + * namedGroupBegin: token pattern /\?P/ + * namedGroup (namedGroupBegin, Word, namedGroupEnd) + * nonCapturingGroup token pattern /\?:/ -- TODO: figure out how to escape these + * negativeGroup token patter /\?!/ + * groupModifier [namedGroup|nonCapturingGroup] + * group (LParent, [groupModifier], valueStatement|...), RParen) + * + */ + + const $ = this; + $.RULE("matchStatement", () => { + const matches = { + startOf: false, + prog: [], + endOf: false, + }; + + $.OPTION(() => { + $.CONSUME(StartOf); + matches.startOf = true; + }); + + // handle ^ startOf + if (!matches.startOf) { + // .*? at the start when not ^ / startOf, don't save the matched + // values. + matches.prog.push({ code: GLOBAL_SAVE, value: false }); + matches.prog.push({ code: SPLIT, locs: [4, 2] }); + matches.prog.push({ code: MATCH_ANY }); + matches.prog.push({ code: JMP, loc: 1 }); + matches.prog.push({ code: GLOBAL_SAVE, value: true }); + } + + matches.groups = []; + $.SUBRULE($.valueStatement, { ARGS: [matches.prog, matches.groups] }); + + $.OPTION1(() => { + $.CONSUME(EndOf); + matches.endOf = true; + }); + + // handle $ endOf + $.ACTION(() => { + if (matches.endOf) { + matches.prog.push({ code: MATCH_END }); + } + matches.prog.push({ code: MATCH }); + }); + + return matches; + }); + + $.RULE("valueStatement", (prog = [], groups = [], vars = []) => { + const inst = []; + $.AT_LEAST_ONE({ + DEF: () => { + $.SUBRULE($.value, { ARGS: [prog, groups, vars] }); + }, + }); + return inst; + }); + + $.RULE("value", (prog = [], groups = [], vars = []) => { + const split = { code: NOOP }; // save split for modifiers + prog.push(split); + const start = prog.length; // save start for split jmp later + + $.OR([ + { + ALT: () => { + $.CONSUME(Dot); + prog.push({ code: MATCH_ANY }); + }, + }, + { + ALT: () => { + prog.push({ code: MATCH_WORD, value: $.CONSUME(Word).image }); + }, + }, + { + ALT: () => { + prog.push({ + code: MATCH_WORD, + value: $.CONSUME(EscapedWord).image?.substr(1), + }); + }, + }, + { + ALT: () => { + prog.push({ + code: MATCH_TAG, + value: $.CONSUME(Tag).image?.substr(1), + }); + }, + }, + { + ALT: () => { + prog.push({ code: MATCH_WORD, value: $.CONSUME(Zero).image }); + }, + }, + { + ALT: () => { + prog.push({ + code: MATCH_WORD, + value: $.CONSUME(PositiveInt).image, + }); + }, + }, + { + ALT: () => { + prog.push({ + code: MATCH_METHOD, + value: $.CONSUME(Method).image?.substr(1), + }); + }, + }, + { + ALT: () => { + $.SUBRULE($.group, { ARGS: [prog, groups, vars] }); + }, + }, + ]); + + $.OPTION(() => { + // TODO: could probably allow relative jmps to get rid of noop + const { type, greedy, min, max } = $.SUBRULE($.valueModifier); + switch (type) { + case "ZERO_OR_ONE": + split.code = SPLIT; + split.locs = [start, prog.length]; + break; + case "ZERO_OR_MORE": + prog.push({ code: JMP, loc: start - 1 }); + split.code = SPLIT; + split.locs = [start, prog.length]; + break; + case "ONE_OR_MORE": + prog.push({ code: SPLIT, locs: [start, prog.length + 1] }); + if (!greedy) { + prog[prog.length - 1].locs.reverse(); + } + break; + case "RANGE": + const varId = vars.length; + vars.push(varId); + prog.push({ code: INCV, varId }); // increment first + + const minInst = { + code: JMP_LT, + varId, + value: min ?? 0, + loc: start, + }; + let maxInst = null; + if (min === max) { + // a{x} + if (min === 0) { + // a{0} skip matching, causes token to be ignored + split.code = JMP; + split.loc = prog.length; // next instruction + } else { + // a{x} + prog.push(minInst); + } + } else if ((min ?? 0) === 0 && max !== null) { + // a{,y} a{0,y} + split.code = SPLIT; + split.locs = [start, prog.length + 1]; + + maxInst = { + code: SPLIT_LT, + varId, + value: max, + locs: [start, prog.length + 1], + }; + prog.push(maxInst); + } else if (min !== null && max === null) { + // a{x,} + prog.push(minInst); + maxInst = { code: SPLIT, locs: [start, prog.length + 1] }; + prog.push(maxInst); + } else { + // if (min !== null && max !== null) { + // a{x,y} + prog.push(minInst); + maxInst = { + code: SPLIT_LT, + varId, + value: max, + locs: [start, prog.length + 1], + }; + prog.push(maxInst); + } + + if (!greedy) { + maxInst?.locs?.reverse(); // reverse thread priority for greedy / non-greedy + } + //{ code: SPLIT, locs: [ ] } + //prog.push({ code: SETV_ONCE, id: rid, value: 0 }); + //prog.push({ code: INCREMENT, id: rid, value: 1 }); + //prog.push({ code: JMP_IF_GTE, id: rid, value: 0 }); + break; + } + if (!greedy) { + split?.locs?.reverse(); + } + }); + }); + + $.RULE("valueModifier", () => { + let result = { type: null, greedy: true }; + $.OR([ + { + ALT: () => { + $.CONSUME(Question); + result.type = "ZERO_OR_ONE"; + }, + }, + { + ALT: () => { + $.CONSUME(Star); + result.type = "ZERO_OR_MORE"; + }, + }, + { + ALT: () => { + $.CONSUME(Plus); + result.type = "ONE_OR_MORE"; + }, + }, + { + ALT: () => { + const { min, max } = $.SUBRULE($.rangeModifier); + $.ACTION(() => { + result.type = "RANGE"; + result.min = min; + result.max = max; + }); + }, + }, + ]); + $.OPTION(() => { + $.CONSUME1(Question); + $.ACTION(() => { + result.greedy = false; + }); + }); + return result; + }); + + $.RULE("rangeModifier", () => { + const range = { min: null, max: null }; + $.CONSUME(LCurly); + + // {x} + $.OPTION(() => { + $.OR([ + { + ALT: () => { + range.min = $.CONSUME(Zero).image; + }, + }, + { + ALT: () => { + range.min = $.CONSUME(PositiveInt).image; + }, + }, + ]); + }); + + // {x} + range.max = range.min; + + $.OPTION1(() => { + $.CONSUME(Comma); + // {x,} + range.max = null; + // {,x} {x,}, {x,y} + $.OPTION2(() => { + range.max = $.CONSUME1(PositiveInt).image; + }); + }); + + $.ACTION(() => { + if (range.min) { + range.min = parseInt(range.min); + } + if (range.max) { + range.max = parseInt(range.max); + } + const { min, max } = range; + if (min && max && min > max) { + throw new Error( + `Range min(${min}) must be greater than max(${max}).` + ); + } + if (min === null && max === null) { + throw new Error(`Range min or max must be defined.`); + } + }); + + $.CONSUME(RCurly); + return range; + }); + + $.RULE("group", (prog = [], groups = [], vars = []) => { + let modifiers = { + capture: true, + name: null, + lookahead: false, + negative: false, + }; + + $.CONSUME(LParenthesis); + + $.OPTION(() => { + modifiers = $.SUBRULE($.groupModifier); + }); + + let oProg = null; + if (modifiers.lookahead) { + // part 1, see finish at end + modifiers.capture = false; + oProg = prog; + prog = []; + } + + const gId = groups.length; + if (modifiers.capture) { + groups.push(modifiers); + prog.push({ code: OGROUP, id: gId, name: modifiers.name }); + } + + const split = { code: SPLIT, locs: [] }; + prog.push(split); + let jmps = []; + + $.AT_LEAST_ONE_SEP({ + SEP: Pipe, + DEF: () => { + split.locs.push(prog.length); + $.SUBRULE($.valueStatement, { ARGS: [prog, groups, vars] }); + + const jmp = { code: JMP, loc: null }; + jmps.push(jmp); + prog.push(jmp); + }, + }); + + // make split noop when just one in group + if (split.locs.length === 1) { + split.code = NOOP; + delete split.locs; + } + + // remove last jmp so it continues + prog.pop(); + + // set jmps to end + for (const jmp of jmps) { + jmp.loc = prog.length; + } + + // close the group if necessary as the last step + if (modifiers.capture) { + prog.push({ code: CGROUP, id: gId, name: modifiers.name }); + } + + if (modifiers.lookahead) { + prog.push({ code: MATCH }); + oProg.push({ + code: modifiers.negative ? NEGATIVE_LOOKAHEAD : LOOKAHEAD, + prog, + }); + } + + $.CONSUME(RParenthesis); + }); + + $.RULE("namedGroup", () => { + $.CONSUME(Question); + $.CONSUME(NamedGroupBegin); + const name = $.CONSUME(Word).image; + $.CONSUME(NamedGroupEnd); + return name; + }); + + $.RULE("nonCapturingGroup", () => { + $.CONSUME(Question); + $.CONSUME(Colon); + }); + + $.RULE("negativeLookaheadGroup", () => { + $.CONSUME(Question); + $.CONSUME(Exclamation); + }); + + $.RULE("positiveLookaheadGroup", () => { + $.CONSUME(Question); + $.CONSUME(Equals); + }); + + $.RULE("commentGroup", () => { + $.CONSUME(Question); + $.CONSUME(Pound); + }); + + $.RULE("groupModifier", () => { + let result = { + capture: true, + name: null, + lookahead: false, + negative: false, + comment: false, + }; + $.OR([ + { + ALT: () => { + $.SUBRULE($.nonCapturingGroup); + result.capture = false; + }, + }, + { + ALT: () => { + result.name = $.SUBRULE($.namedGroup); + }, + }, + { + ALT: () => { + $.SUBRULE($.negativeLookaheadGroup); + result.capture = false; + result.lookahead = true; + result.negative = true; + }, + }, + { + ALT: () => { + $.SUBRULE($.positiveLookaheadGroup); + result.capture = false; + result.lookahead = true; + result.negative = false; + }, + }, + /* + { ALT: () => { + $.SUBRULE($.commentGroup); + result.capture = false; + result.comment = true; + }} + */ + ]); + return result; + }); + + this.performSelfAnalysis(); + } +} diff --git a/plugins/match2/src/pikevm.js b/plugins/match2/src/pikevm.js new file mode 100644 index 000000000..758cfb908 --- /dev/null +++ b/plugins/match2/src/pikevm.js @@ -0,0 +1,254 @@ +import { + NOOP, + MATCH_ANY, + MATCH_TAG, + MATCH_WORD, + MATCH_METHOD, + MATCH_END, + JMP, + SPLIT, + GLOBAL_SAVE, + MATCH, + OGROUP, + CGROUP, + INCV, + JMP_LT, + SPLIT_LT, + LOOKAHEAD, + NEGATIVE_LOOKAHEAD, +} from "./constants"; + +export const termContainsTag = (term, name) => + Object.entries(term?.tags ?? {}) + .filter(([k, v]) => v) + .map((entry) => entry[0].toLowerCase()) + .includes(name.toLowerCase()); + +/** + * Helper function, create a thread + * Copies saved and groups.saved so that each thread contains its own + * independent saved values. + * + * Note: Using the { saved, groups } allows passing a thread which will cause + * its saved to be cloned. + * + * @param {int} pc - position of instance code to execute + * @param {*[]} saved - matched objects that were saved + * @param {object} groups - capture groups key of group id + * @returns {object} thread + */ +const thread = ( + pc, + { save = true, saved = [], groups = {}, vars = {} } = {} +) => { + const ngroups = Object.values(groups).reduce((ng, g) => { + ng[g.id] = { + ...g, + saved: [...g.saved], + }; + return ng; + }, {}); + + return { + pc, + save, + saved: [...saved], + // clone groups.saved + groups: ngroups, + vars: { ...vars }, + }; +}; + +const addthread = (prog, list, th) => { + const inst = prog[th.pc]; + //console.log("addthread:", th.pc); + //console.log(" inst:", inst); + switch (inst.code) { + case GLOBAL_SAVE: + th.save = inst.value; + addthread(prog, list, thread(th.pc + 1, th)); + break; + case NOOP: + addthread(prog, list, thread(th.pc + 1, th)); + break; + case JMP: + addthread(prog, list, thread(inst.loc, th)); + break; + case SPLIT: + for (const loc of inst.locs) { + addthread(prog, list, thread(loc, th)); + } + break; + case OGROUP: + // again (see below comment in pikevm match), can modify thread + // because it ends here + th.groups[inst.id] = { + id: inst.id, + name: inst.name, + saved: [], + open: true, + }; + addthread(prog, list, thread(th.pc + 1, th)); + break; + case CGROUP: + th.groups[inst.id].open = false; + addthread(prog, list, thread(th.pc + 1, th)); + break; + case INCV: + th.vars[inst.varId] = (th.vars?.[inst.varId] ?? 0) + 1; + addthread(prog, list, thread(th.pc + 1, th)); + break; + case JMP_LT: + if (th.vars[inst.varId] < inst.value) { + // jump! + addthread(prog, list, thread(inst.loc, th)); + } else { + // continue + addthread(prog, list, thread(th.pc + 1, th)); + } + break; + case SPLIT_LT: + if (th.vars[inst.varId] < inst.value) { + // split! + for (const loc of inst.locs) { + addthread(prog, list, thread(loc, th)); + } + } else { + // continue + addthread(prog, list, thread(th.pc + 1, th)); + } + break; + default: + list.push(th); + break; + } +}; + +/** + * Save a match to a thread. + * Handles saving to open groups too + * @param {object} th - the thread + * @param {*] sp - the matched value to add + * @return {object} the thread th + */ +const saveMatch = (th, sp) => { + if (!th.save) { + return th; + } + + const buckets = [ + th.saved, + // get the `saved` from the open buckets + ...Object.values(th.groups) + .filter((g) => g.open) + .map((g) => g.saved), + ]; + for (const saved of buckets) { + saved.push(sp); + } + return th; +}; + +/** + * Simulate pike's vm, see https://swtch.com/~rsc/regexp/regexp2.html + * @param {object[]} inst - instructions to execute + * @param {object[]} input - input word w/ terms + * @returns true or false for match and saved matches + */ +export const pikevm = (prog, input, flags = []) => { + let clist = []; + let nlist = []; + let found = false; + let groups = {}; + let saved = []; + + // helps with match end and also matches that end at exactly the end so that + // the match function gets a chance to run. + const END = Symbol("END"); + input = [...input, END]; + + addthread(prog, clist, thread(0)); // and so we begin... + for (let i = 0; i < input.length; i++) { + if (clist.length === 0) { + break; + } + + const sp = input[i]; + + for (let j = 0; j < clist.length; j++) { + // can probably convert to clist.shift as optimization + const th = clist[j]; + const inst = prog[th.pc]; + //console.log("exec:", inst); + //console.log(` stack(${i}):`, clist); + let gotoNextWord = false; + switch (inst.code) { + case MATCH_ANY: + // Note: can call save match like this without worrying about other + // threads because this thread ends here and another will be created + // in its place + if (sp !== END) { + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + break; + case MATCH_WORD: + if (sp?.text?.toLowerCase() === inst.value.toLowerCase()) { + // continue on next word + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + break; + case MATCH_TAG: + if (termContainsTag(sp, inst.value)) { + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + break; + case MATCH_METHOD: + // call method using null coalescing on term, if it returns true continue + if (sp?.[inst.value]?.()) { + addthread(prog, nlist, thread(th.pc + 1, saveMatch(th, sp))); + } + break; + case MATCH_END: + if (sp === END) { + // continue + addthread(prog, clist, thread(th.pc + 1, th)); + } + break; + case LOOKAHEAD: + const mla = pikevm(inst.prog, input.slice(i)); + if (mla.found) { + addthread(prog, clist, thread(th.pc + 1, th)); + } + break; + case NEGATIVE_LOOKAHEAD: + const mnla = pikevm(inst.prog, input.slice(i)); + if (!mnla.found) { + // continue at current position + // NOTE: this would be in addthread but we require access to input + addthread(prog, clist, thread(th.pc + 1, th)); + } + break; + case MATCH: + saved = th.saved; + groups = th.groups; + found = true; + // Go to the next word which causes all pending threads in the + // current list (stack) to be cleared so we don't go down those + // paths. This allows for greedy and non-greedy matches to work. + gotoNextWord = true; + break; + default: + throw new Error(`Unsuppored Op code: ${inst.code}`); + } + if (gotoNextWord) { + break; // continue next iteration + } + } + clist = nlist; + nlist = []; + } + if (found) { + return { found, saved, groups }; + } + return { found }; +}; diff --git a/plugins/match2/src/regex.js b/plugins/match2/src/regex.js new file mode 100644 index 000000000..4137440ea --- /dev/null +++ b/plugins/match2/src/regex.js @@ -0,0 +1,100 @@ +import { Lexer } from "chevrotain"; +import { NLPMatchParser, allTokens } from "./parser"; +import { pikevm } from "./pikevm"; + +export const NLPMatchLexer = new Lexer(allTokens); +export const parserInstance = new NLPMatchParser(); + +export class NLPRegexParseError { + constructor(errors) { + this.errors = errors; + } + + get message() { + return this.errors[0]?.message; + } + + toString() { + return `NLP RegexP Parsing error: ${this.message}`; + } +} + +/** + * Custom NLPRegexP class for regexp compile / cache. + */ +export class NLPRegexP { + /** + * @param {string} regex - regular expression like string for matching nlp + * terms. + */ + constructor(regex) { + if (regex?.prog) { + // take another NLPRegexP + this.regex = regex.regex; + this.prog = [...regex.prog]; + return; + } + + const { tokens } = NLPMatchLexer.tokenize(regex); + parserInstance.input = tokens; + let parsed = null; + + try { + parsed = parserInstance.matchStatement(); + } catch (e) { + // catch thrown error + throw new NLPRegexParseError([e]); + } + + if (parserInstance.errors.length > 0) { + throw new NLPRegexParseError(parserInstance.errors); + } + + this.regex = regex; + this.prog = parsed.prog; + } + + exec(docOrPhrase) { + switch (docOrPhrase?.isA?.toLowerCase()) { + case "doc": + return this.execDoc(docOrPhrase); + case "phrase": + return this.execPhrase(docOrPhrase); + default: + throw new Error("Invalid type, must be Document or Phrase"); + } + } + + execDoc(doc) { + return doc.buildFrom( + doc.list + .map((phrase) => { + return this.execPhrase(phrase); + }) + .filter((p) => p !== null) + ); + } + + execPhrase(phrase) { + const { found, saved = [], groups = {} } = pikevm( + this.prog, + phrase.terms() + ); + + const namedGroups = Object.values(groups).reduce( + (arr, g) => ({ + ...arr, + [parseInt(g.id)]: { + group: g?.name ?? `${g.id}`, + start: g.saved[0]?.id ?? 0, + length: g.saved.length, + }, + }), + {} + ); + + return found && saved?.[0]?.id + ? phrase.buildFrom(saved[0].id, saved.length, namedGroups) + : null; + } +} diff --git a/plugins/match2/src/regex.test.js b/plugins/match2/src/regex.test.js new file mode 100644 index 000000000..27b986f82 --- /dev/null +++ b/plugins/match2/src/regex.test.js @@ -0,0 +1,46 @@ +import { NLPRegexP, NLPRegexParseError } from "./regex"; + +describe("NLPRegexP class", () => { + describe("regex creation", () => { + it("creates regex successfully", () => { + const str = + "((remind|remember) (me|you|.) to? do? (?P.+) (?P#Date+))"; + const regex = new NLPRegexP(str); + expect(regex).toBeDefined(); + expect(regex.regex).toEqual(str); + expect(regex.prog).toBeDefined(); + expect(regex.prog.length).toBeGreaterThan(0); + }); + + it("thows an error on invalid regex", () => { + const str = + "((remind|remember) (me|you|.) to? do? (?P.+) (?P#Date+"; + expect(() => new NLPRegexP(str)).toThrow(NLPRegexParseError); + try { + new NLPRegexP(str); + } catch (e) { + expect(e.message).toBeDefined(); + expect(e.toString()).toMatch(/^NLP RegexP Parsing error: .*/); + } + }); + + it("copies a regex if one already exists", () => { + const str = + "((remind|remember) (me|you|.) to? do? (?P.+) (?P#Date+))"; + const regexOrig = new NLPRegexP(str); + const regex = new NLPRegexP(regexOrig); + expect(regex).toBeDefined(); + expect(regex.regex).toEqual(str); + expect(regex.regex).toEqual(regexOrig.regex); + expect(regex.prog).toBeDefined(); + expect(regex.prog).toEqual(regexOrig.prog); + }); + + it("throws an error on invalid document type", () => { + const regex = new NLPRegexP("hello world"); + expect(() => regex.exec("hello world")).toThrow( + "Invalid type, must be Document or Phrase" + ); + }); + }); +});