Comments (5)
Hey,
Looks like your grammar is left-recursive in some situations when parsing item
. The first part of item
is factor
. If factor
then fails for all options before item
it will try to match an item
. In matching an item
it will look for a factor
and the loop will continue.
mpc
can't detect left-recursion so you will have to change your grammar manually. I can't tell just from looking at it how to make it right-recursive but there is probably some simple transformation to be made.
Thanks,
Dan
from mpc.
OK, I solved this issue.
https://github.com/mattn/orelang/blob/master/ore.c#L40
Thanks.
from mpc.
Great! No problem.
from mpc.
Ah, however it still have problem for future. For example I may want to implement anonymous function call like below.
var counter = func() {
var c = 0;
return func() {
c++;
return c;
};
}();
So, yacc stracture should be below.
call : <factor> '(' <factor>? (',' <factor>)* ')' ;
This make recursible.
from mpc.
I don't know the solution to this without thinking about it much more, but I think perhaps you can fix it by instead of making a call
a type of factor
, instead adding the parenthesis calling syntax as an optional part of those factors which support function calls.
Perhaps in the future I can add some code to detect or refactor Left Recursion but for now I think you will have to work out these issues yourself :)
from mpc.
Related Issues (20)
- Undefined symbols for architecture x86_64 HOT 2
- Implementation of `mpcf_all_free` not seen in mpc.c HOT 1
- In theory: Can MPC parse C? HOT 2
- scan coverity findings HOT 1
- Add support for arm64 architecture. HOT 4
- CMakeLists.txt suggestion HOT 6
- Release: GNU Guix
- Segmentation fault and timeout occur at mpca_lang_st() HOT 1
- Does the order of definitions matter in languages? HOT 2
- Mix parsers and AST HOT 3
- Greedy matching causes token matching issue HOT 2
- What about MPC now? HOT 1
- "-static" does not work on newer MacOS due to crt0
- make install does not work on newer MacOS (install command/folders)
- dependency errors issue HOT 9
- shared state and multi-threaded use HOT 2
- parser for """long string""" ? HOT 2
- Make include guards unique
- Completion of error handling
- memory leak in mpca_lang function
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 mpc.