nearley | 📜🔜🌲 Simple , fast , powerful parser toolkit for JavaScript | Parser library

 by   kach JavaScript Version: 2.20.1 License: MIT

kandi X-RAY | nearley Summary

kandi X-RAY | nearley Summary

nearley is a JavaScript library typically used in Utilities, Parser, Nodejs applications. nearley has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.

If you are citing nearley in academic work, please use the following BibTeX entry.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              nearley has a medium active ecosystem.
              It has 3375 star(s) with 228 fork(s). There are 46 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 158 open issues and 288 have been closed. On average issues are closed in 142 days. There are 27 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of nearley is 2.20.1

            kandi-Quality Quality

              nearley has 0 bugs and 0 code smells.

            kandi-Security Security

              nearley has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              nearley code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              nearley is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              nearley releases are available to install and integrate.
              Deployable package is available in Maven.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed nearley and discovered the below as its top functions. This is intended to give you an instant insight into nearley implemented functionality, and help decide if they suit your requirements.
            • Compile structure
            • Train the rail - diagram
            • Generate a random rule
            • Build a single token
            • graph
            • Generate random symbols
            • render token .
            • Initialize a new Parser with the given rules .
            • Remove indent function
            • Build the rule name for the given rule name .
            Get all kandi verified functions for this library.

            nearley Key Features

            No Key Features are available at this moment for nearley.

            nearley Examples and Code Snippets

            No Code Snippets are available at this moment for nearley.

            Community Discussions

            QUESTION

            Generating a parser for expressions
            Asked 2021-Aug-27 at 03:14

            I am trying to generate a javascript parser for the ebnf grammar described in this Microsoft article. The ebnf specified in the article does not work when I use it as its written, so I have tried to simplify it to make it work with the REx parser generator.

            The goal is in Javascript to be able to parse and evaluate expressions like these to True or False:

            • AttributeA > 2 - The value of AttributeA is greater than 2
            • HasCategory(Assembly) - The node has Category Assembly
            • Assembly - The node has Category Assembly
            • HasValue(AttributeA) - The attribute AttributeA has a value. Its not undefined.
            • AttributeA < AttributeB - The value of attribute AttributeA is less than the value of attribute Attribute B
            • IsReference - The value of the attribute IsReference is True
            • AttributeA + 2 > 5 and AttributeB - 5 != 7
            • AttributeA * 1.25 >= 500

            I am using the REx parser generator online here: https://bottlecaps.de/rex/. If you have suggestions for other parser generators that produce JavaScript I would appreciate some links to where I can find them.

            The issue I'm struggling with is the definition of the MethodCall. I have tried a lot of different definitions but all fail. When I remove the MethodCall and MethodArgs definition the REx parser generator produces a parser.

            So I would appreciate any help to crack this problem a lot.

            Below is the grammar as far as I have been able to get.

            ...

            ANSWER

            Answered 2021-Aug-20 at 12:08

            There are a few problems with your grammar, but it's mostly fine.

            • 'and' and 'or' conflict with Identifier. So, subtract those string literals from Identifier in its rule.
            • Number was missing parentheses. It should be Number ::= Digit ( ('.' Digit) | (Digit)* )
            • You are missing the EOF rule. Almost every parser generator I know requires a bottom/EOF rule to force consumption of the entire input. I added the rule "Input".
            • Make sure to click the "configure" box, then "backtracking". Your grammar is ambiguous, which is fine, but requires you to tell the parser generator to handle that.

            Parser generators have a slightly different syntax for "EBNF", which is what REx takes. REx adds a string to denote the boundary between parser and lexer rules. Microsoft says the grammar is "BNF" but it's not because it uses the Kleene operator ::= [^. ]*, an EBNF construct. It also fudges the definition of and with prose.

            I haven't tested the generated parser, but it seems like a straightforward recursive descent implementation. The parser generators that I am familiar with, and that are popular, are listed in the conversion page. (I'm writing converters for all of them and many more.)

            Try this:

            Source https://stackoverflow.com/questions/68857120

            QUESTION

            Nearley parser grammar for parsing opening and closing tags
            Asked 2021-Apr-22 at 06:03

            Say I had a simple language to parse in nearley that's just made of strings. "this is a string"

            ...

            ANSWER

            Answered 2021-Apr-22 at 06:03

            I'd use a regex-based lexer, certainly. But you could try to write an unambiguous grammar, based on the observation that you can never have two adjacent chars in a charCode:

            Source https://stackoverflow.com/questions/67189678

            QUESTION

            [Nearley]: how to parse matching opening and closing tag
            Asked 2021-Mar-09 at 03:49

            I'm trying to parse a very simple language with nearley: you can put a string between matching opening and closing tags, and you can chain some tags. It looks like a kind of XML, but with[ instead of < , with tag always 2 chars long, and without nesting.

            ...

            ANSWER

            Answered 2021-Mar-09 at 03:49

            Your language is almost too simple to need a parser generator. And at the same time, it is not context free, which makes it difficult to use a parser generator. So it is quite possible that the Nearly parser is not the best tool for you, although it is probably possible to make it work with a bit of hackery.

            First things first. You have not actually provided an unambiguous definition of your language, which is why your parser reports an ambiguity. To see the ambiguity, consider the input

            Source https://stackoverflow.com/questions/66538876

            QUESTION

            Reduce array of arrays and remove null from Javascript data
            Asked 2020-Nov-30 at 20:17

            I am having difficulty "compressing" the results of my grammar by stripping out null values and embedded arrays using Javascript. I am using the Nearley grammar checker which can run JS functions after a sentence is matched. Unfortunately you get the results of the full parse as a series of arrays. The following is an example of the output

            ...

            ANSWER

            Answered 2020-Nov-30 at 18:52
            var arr = [
              [
               [
                 [
                    [
                       [
                          [ [ 'climb'], [ [ null, 'to' ] ] ],
                          [ [ null, [ 'alt' ] ] ],
                          [ 332, [ null, [ 'km' ] ] ]
                       ]
                    ],
                    [ null ]
                   ]
                ]
              ]
            ]
            
            var iterator = arr.values();
            
            for (let onlyitems of iterator) {
                console.log(onlyitems);
              }  
            

            Source https://stackoverflow.com/questions/65078970

            QUESTION

            Grammar - How to match optional and required whitespaces before and after words?
            Asked 2020-Nov-25 at 21:44

            I am using nearley and moo to come up with a rather complex grammar. It seems to be working fine EXCEPT for my whitespace requirements. I need to require whitespace when needed and allow it when not while keeping the grammar unambiguous.

            For example:

            ...

            ANSWER

            Answered 2020-Nov-24 at 19:23

            I'm not familiar with Nearly nor Moo but the regex could be

            Source https://stackoverflow.com/questions/64993104

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install nearley

            You can download it from GitHub, Maven.

            Support

            Please visit our website https://nearley.js.org to get started! You will find a tutorial, detailed reference documents, and links to several real-world examples to get inspired.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
            Maven
            Gradle
            CLONE
          • HTTPS

            https://github.com/kach/nearley.git

          • CLI

            gh repo clone kach/nearley

          • sshUrl

            git@github.com:kach/nearley.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link