Git Product home page Git Product logo

Comments (4)

orangeduck avatar orangeduck commented on July 19, 2024

That is really weird. I'll have to investigate more and see what is wrong.

from mpc.

orangeduck avatar orangeduck commented on July 19, 2024

I found the problem. The issue is that you are declaring your grammar as predictive: MPCA_LANG_PREDICTIVE.

Predictive means that no backtracking is required and that the first character any of the cases of an or clause always informs how the whole clause is going to be parsed. This is good for performance reasons but can't always be ensured for every grammar.

When you added repeat and rand it meant your grammar was no longer predictive because because both of them start with r. So the parser first tries to parse repeat and gets the first r and fails - at this point it needs to backtrack if it wants to parse rand but it doesn't bother because it is delcared as predictive and carries on blindly trying to parse the next a.

Probably I should remove the MPCA_LANG_PREDICTIVE clause from the maths example to give people a better starting point - and also consider throwing some sort of error when a predictive grammar is asked to backtrack.

Hope that helps,

  • Dan

from mpc.

VitorCBSB avatar VitorCBSB commented on July 19, 2024

Yes, changing it to MPCA_LANG_DEFAULT makes it work as expected. I assume this is the one I should be using? In any case, thank you very much for your help. :)

from mpc.

orangeduck avatar orangeduck commented on July 19, 2024

Yup, MPCA_LANG_DEFAULT is correct. No problem, and good luck with your project.

from mpc.

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.