Giter Site home page Giter Site logo

Can't fix this failure. about pegged HOT 2 CLOSED

enjoysmath avatar enjoysmath commented on July 18, 2024
Can't fix this failure.

from pegged.

Comments (2)

veelo avatar veelo commented on July 18, 2024

Hi, for situations like this I wrote the tracing capability of Pegged, see https://github.com/PhilippeSigaud/Pegged/wiki/Grammar-Debugging.

But let me try to parse your input with your grammar manually:

  • Typed tries to parse a+b:A, invokes List.
    • List tries to parse a+b:A, invokes Template.
      • Template tries to parse a+b:A, invokes TemplatePart.
        • TemplatePart tries to parse a+b:A, invokes Variable.
          • Variable tries to parse a+b:A, invokes identifier.
            • identifier tries to parse a+b:A, matches a. Remaining input: +b:A
        • TemplatePart matches a. Remaining input: +b:A
      • Template tries to parse +b:A, invokes another TemplatePart.
        • TemplatePart tries to parse +b:A, invokes Variable.
          • Variable tries to parse +b:A, invokes identifier.
            • identifier tries to parse +b:A, fails.
        • TemplatePart tries to parse +b:A, invokes Number.
          • Number tries to parse +b:A, fails.
        • TemplatePart tries to parse +b:A, invokes Text.
          • Text tries to parse +b:A. Text cannot match anything but the empty string because it only contains a negative lookahead, repeated 0 or more times. It succeeds on the empty string. Remaining input: +b:A.
      • Template has not advanced the input, gives up on trying another TemplatePart.
    • List succeeds with a. Remaining input: +b:A.
  • Typed expects literal ":" after List, but the remaining input is +b:A, and fails.

I assume you expect "+" to be matched by Text, and it looks like you just forgot the "match anything parser" . in

Text           < (!(Variable / Number / ":" / ",") . )*

Hope this helps,
Bastiaan.

from pegged.

enjoysmath avatar enjoysmath commented on July 18, 2024

Hi, for situations like this I wrote the tracing capability of Pegged, see https://github.com/PhilippeSigaud/Pegged/wiki/Grammar-Debugging.

But let me try to parse your input with your grammar manually:

  • Typed tries to parse a+b:A, invokes List.

    • List tries to parse a+b:A, invokes Template.

      • Template tries to parse a+b:A, invokes TemplatePart.

        • TemplatePart tries to parse a+b:A, invokes Variable.

          • Variable tries to parse a+b:A, invokes identifier.

            • identifier tries to parse a+b:A, matches a. Remaining input: +b:A
        • TemplatePart matches a. Remaining input: +b:A

      • Template tries to parse +b:A, invokes another TemplatePart.

        • TemplatePart tries to parse +b:A, invokes Variable.

          • Variable tries to parse +b:A, invokes identifier.

            • identifier tries to parse +b:A, fails.
        • TemplatePart tries to parse +b:A, invokes Number.

          • Number tries to parse +b:A, fails.
        • TemplatePart tries to parse +b:A, invokes Text.

          • Text tries to parse +b:A. Text cannot match anything but the empty string because it only contains a negative lookahead, repeated 0 or more times. It succeeds on the empty string. Remaining input: +b:A.
      • Template has not advanced the input, gives up on trying another TemplatePart.

    • List succeeds with a. Remaining input: +b:A.

  • Typed expects literal ":" after List, but the remaining input is +b:A, and fails.

I assume you expect "+" to be matched by Text, and it looks like you just forgot the "match anything parser" . in

Text           < (!(Variable / Number / ":" / ",") . )*

Hope this helps,
Bastiaan.

@veelo Yes, that fixed it! :)

from pegged.

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.