Git Product home page Git Product logo

Comments (2)

Theoistic avatar Theoistic commented on July 18, 2024 1

Here is an example from the Simple-CIL-compiler project,
The identifier has to catch single words except the ones listed, which means you have to include the exception token's in to the identifier

IDENTIFIER-> @"[a-zA-Z_][a-zA-Z0-9_]*(?<!(^)(end|else|do|while|for|true|false|return|to|incby|global|or|and|not|write|readnum|readstr|call))(?!\w)";

Hope that helps.

from tinypg.

ultrasuperpingu avatar ultrasuperpingu commented on July 18, 2024

First of all, sorry for my english which is far from perfect. I hope this post is still understandable.

I had the same issue. But because I wasn't attempting to match a particular grammar, I just modified it as a workaround (here, I would just replace LIST and END tokens by something like [ and ]). But I looked in the code why this wasn't working. It is because of the "Partial Context Sensitive/Ambiguous Grammars" feature (take a look at the documentation here). The parser asks to the scanner to look ahead for expected tokens but, if the rule has a OneOrMultiple cardinality (+), the expected token list does not contains the following rules first terminal tokens. That means that, in this example, while parsing the IDENTIFIER+ rule, the lookahead only looks for IDENTIFIER tokens, matches the END token as an identifier and consumes it.

The solution here would be to provide too the next rule(s?) first terminals list as expected token. I will give it a try and, if working, propose it as a pull request.

Edit: Pull request submited

from tinypg.

Related Issues (12)

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.