Comments (9)
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.
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.
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.
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.
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.
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.
Can you see a different solution?
from racket-peg.
This means that I can close that?
from racket-peg.
yeah
from racket-peg.
Related Issues (20)
- We can't use #f as a semantic value HOT 1
- unicode safe HOT 5
- support to "..." HOT 3
- add quantifier repetition HOT 18
- Add verbose option on peg HOT 1
- Next milestone and Relase HOT 2
- Implement a extension of PEG HOT 2
- Can PEG results objects become more predictable?
- Parse Failure HOT 1
- difficult to parse a basic language HOT 7
- document pegvm semantics HOT 7
- change (? e) to (or e (epsilon)) HOT 1
- No way to use bake from PEG language. HOT 1
- implement memorization of results HOT 1
- benchmark this
- Overriding/adding alternatives to rules from imported modules HOT 2
- 'capture' should be 'name' in reference HOT 1
- Release under LGPLv3+
- Bug with context-sensitive grammar HOT 1
- Precise defitition of the peg syntax? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from racket-peg.