Git Product home page Git Product logo

Comments (6)

igordejanovic avatar igordejanovic commented on July 19, 2024

If LAYOUT is not provided ws setting is used.
If LAYOUT is provided it must match between each two adjacent tokens plus the beginning and end of the input. I've added a note in the docs.

Controlling word boundaries is in parglare handled with a special rule KEYWORD as the word boundary is not determined only by whitespaces. I think this mechanism should work in your case also.

from parglare.

alberth avatar alberth commented on July 19, 2024

I found the WS and LAYOUT explanation in the documentation already (which is quite good, I might add). The confusion part there is that the WS setting is also non-empty, and it doesn't fail to match before the first token (just like my example doesn't fail if you take out the LAYOUT rule). I guess there is a default LAYOUT rule that allows empty matches.

I agree that KEYWORD is an alternative, and I have used that currently, and made LAYOUT allow empty matches. Thank you for confirming that is the desired solution here.

from parglare.

igordejanovic avatar igordejanovic commented on July 19, 2024

Chars in ws setting are always optional and they are used if LAYOUT is not defined. This is relevant part of the implementation.

from parglare.

alberth avatar alberth commented on July 19, 2024

Ah right, the code provides the optional matching rather than the pattern.

Looking at the code, I noticed the position is always incremented by 1. Does that mean my WS definition of WS : /[ \t]+/ ; is wrong, or at least non-efficient? That is, I match a sequence of whitespace at the line, rather than just 1 character. The code then repeats that process after moving forward 1 position, etc, until the end of the whitepsace is matched.

from parglare.

igordejanovic avatar igordejanovic commented on July 19, 2024

No, your definition is perfectly fine. WS from your grammar is used in entirely different way. It has nothing to do with ws Parser param. You can call your rules in LAYOUT part of grammar anyway you like, only the entry rule must be called LAYOUT. Matching using grammar rules is done here using regex and string matches from terminal definitions. If the match succeeds the position is incremented by the length of the match, so your WS will greadilly consume all whitespaces ahead in one go.

from parglare.

alberth avatar alberth commented on July 19, 2024

thank you for the explanation

from parglare.

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.