Giter Club home page Giter Club logo

Comments (5)

SKalt avatar SKalt commented on June 18, 2024 2

What would you think of

  1. reducing a grammar to a directed graph structure
  2. where nodes are rule names and edges go from a rule to its dependents. For example: <A> ::= <B> | <C> <D> would result in a graph
(A) --> (B)
   \
    `-> (C) --> (D)
  1. then check for cycles that can't be reached from terminals

?

I think that'd be doable using petgraph.

from bnf.

shnewto avatar shnewto commented on June 18, 2024 2

Ah petgraph looks cool! I like your proposed solution too, I'd have to poke at it a bit if I were implementing, but fwiw I'd totally support a solution like this in a PR.

from bnf.

notDhruv avatar notDhruv commented on June 18, 2024 1

Has this question been resolved already? If not I think I have proposal for it (I was skeptical that the proposed solution would work).

This problem can be reduced to solving the emptiness problem for CFLs. I have added a solution strategy below:

  1. We mark every non-terminal that produces a sequences of terminals
  2. We then recursively mark every non-terminal that can produce a sequence of marked elements
  3. We check whether the initial non-terminal is marked

I don't think this needs any special libraries but just a poly-space recursion on the existing grammar would work well.

What do you guys think?

from bnf.

shnewto avatar shnewto commented on June 18, 2024

@notDhruv this hasn't been solved yet 😄 I think your approach sounds great, seems like it'd definitely give us a mechanism for avoiding the infinite loop issues, and I can imagine that if we have some known-to-be-finite paths to terminals to traverse, we could work in the min - max generated sentence length too.

from bnf.

shnewto avatar shnewto commented on June 18, 2024

addressed by #127 thanks for everyone's suggestions!

from bnf.

Related Issues (20)

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.