Code Monkey home page Code Monkey logo

Comments (9)

rain-1 avatar rain-1 commented on August 25, 2024 1

I understand the problem.. it is hard to analyse a rule when a rule is defined in terms of things in another file.

Thinking about cost: "amount of code to implement feature" vs "value of feature".

  • The code to implement this feature would be very complex and affect many parts of the system.
  • The value of the feature is low, because it just gives a warning on some bad grammars which is good. But often the programmer will understand the problem when running it infinite loops. So it makes life easier but only a small amount.

So I think we should do without this feature. But It was good to raise it and consider it!

from racket-peg.

rain-1 avatar rain-1 commented on August 25, 2024

Yeah, Good idea to detect left recursion and nullable star.

transforming into a non-left recursive grammar sounds very complex and I think we should not do this! It will be enough to give an error.

from racket-peg.

petrolifero avatar petrolifero commented on August 25, 2024

https://github.com/PhilippeSigaud/Pegged/wiki/Left-Recursion

To detect left-recursive rules, direct or indirect, we need to calculate the NULL set and the left relation.

NULL = {A | A is a non-terminal and (peg A "") suceeds}

left(A,B) <=> there exist some rule A < B C or A <- B C or A <-- B C where B is a non-terminal and C is whatever. Another alternative is that A <- B C, B is elem of NULL, and the production A <- C allow to derive some left relation.

Each ordered choice contribute to this sets in this way : A <- B / C / D , if NULL(B) and NULL(C) and NULL(D), then NULL(A)

left(A,B) can be infered by A <- C / D if left(A,B) can be infered by A <- C or A <- D

from racket-peg.

petrolifero avatar petrolifero commented on August 25, 2024

I am testing the algorithm above and see a problem : we can't see if some peg imported is nullable.

(Require a);
B <- A B / 'b';

I can't see if the A above is nullable and without that I can't tell if B can be left recursive or not.

from racket-peg.

petrolifero avatar petrolifero commented on August 25, 2024

WIth require, what we import is peg-rule:A but with the function alone, can't see if there's some input that match and dont consume anything.

from racket-peg.

petrolifero avatar petrolifero commented on August 25, 2024

I dont want to get something that was decided before, but with import we can intercept the require, and before that, open the file, transform in peg, and do something about

#lang peg
//A.rkt

A <- 'a'? ;
#lang peg
//B.rkt

import A.rkt;
B <- A B / 'b' ;

We can, instead of transform in a require immediately, open the file, transform in rules, using (peg peg ...) and execute the algorithm above with all the peg, even if that is modularized.

from racket-peg.

petrolifero avatar petrolifero commented on August 25, 2024

Can you see a different solution?

from racket-peg.

petrolifero avatar petrolifero commented on August 25, 2024

This means that I can close that?

from racket-peg.

rain-1 avatar rain-1 commented on August 25, 2024

yeah

from racket-peg.

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.