GithubHelp home page GithubHelp logo

Comments (3)

shamansir avatar shamansir commented on June 7, 2024

Additional Info:

In my fork this code also fails:

var actionKnowsEndPositionInsideParser = PEG.buildParser(
    'start = "e" "d" ([bc]* { return 4; }) "a"'
);
parses(actionKnowsEndPositionInsideParser, "edcba", ["e", "d", 4, "a"]);

And I can help it to pass with changing [bc]* to [b-c]*.

However, both this variants ([bc]* and [b-c]*) pass ok in a clean clone of https://github.com/dmajda/pegjs.git

from pegjs.

shamansir avatar shamansir commented on June 7, 2024

I've tried to go deep with these issues (issue #55 is directly related), and, it seems, this is the very deep thing. The parser result block in my case is:

        if (/^[bc]/.test(input.charAt(pos))) {
                result3 = input.charAt(pos);
          pos++;
        } else {
          result3 = null;
          if (reportFailures === 0) {
            matchFailed("[bc]");
          }
        }
          }
        }
        while (result3 !== null) {
          result2.push(result3);
          if (/^[bc]/.test(input.charAt(pos))) {
            result3 = input.charAt(pos);
            pos++;
          } else {
            result3 = null;
            if (reportFailures === 0) {
              matchFailed("[bc]");
            }
          }
        }
        _chunk.pos = pos1;
              _chunk.end = pos;
        _chunk.match = input.substring(pos1,pos);
        i  f (result2 !== null) {
          result2 = (function(_chunk) { return _chunk.end; })(_chunk);
        }

You see the incorrect indent at start and broken i f in the end.

  • May be the unindent/indent mechanics fail in Codie, but why they fail only for this concrete rule among all 480+?
  • May be the problem is in literal (more possible) or zero_or_more (less possible, one_or_more fails in your branch) templates, but the code for them seems right (I've tried grouping if-s and aligning indents in different ways and nothing helped)
  • May be the problem is somewhere else, only you know where)

In conclusion, I suppose that the reason is that complex if-else-nested rule in literal template (it was introduced only in last commits with ignoreCase flag) and indentation fails on parsing of that.

from pegjs.

dmajda avatar dmajda commented on June 7, 2024

This is a duplicate of #55 which was fixed. Thanks for digging into the issue.

from pegjs.

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.