Git Product home page Git Product logo

Comments (2)

neils-s avatar neils-s commented on August 24, 2024

On the one hand, adding the NOT and AND predicates makes this an actual PEG parser.
On the other hand, adding those predicates would make it much, much harder to use the Grammar Arrays to generate sample MUMPS code for fuzz testing.

Additionally, automatically creating a railroad track syntax diagram using the grammar array is pretty trivial with the current state, but it's not possible to generate proper diagrams if we have AND and NOT predicates. This is because an AND predicate conceptually means that an input string has to follow two separate "railroad tracks" at the same time.

from mumps-parser.

neils-s avatar neils-s commented on August 24, 2024

Augmenting the code to handle the AND and NOT predicates is actually pretty easy. It would just be a change to the ParseSubtree code to check for certain nodes in the map that tell us what we need to check for and exclude. Adding support for the the reasonable subnodes to the grammar array is pretty straight-forward.

For example, if these predicates get added, the grammar map for tokens would need to be augmented to hold data like this:
; @subtree = "token"
; @subtree@("value") = the name of the token. This should match some name occurring in the first coordinate of the @Map
; @subtree@("force") = the behavior of the parser to force when parsing this or deeper subtrees.
; @subtree@("AlsoParsableAs") = a subtree that the input stream must be parsable as. This is the AND predicate
; @subtree@("NotParsableAs") = a subtree that the input stream must not be parsable as. This is the NOT predicate

Adding these predicates wouldn't require that we change the structure of the parse tree output.

from mumps-parser.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.