Comments (6)
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.
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.
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.
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.
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.
thank you for the explanation
from parglare.
Related Issues (20)
- A terminal that doesn't match specific strings HOT 2
- QUESTION: confusing 0.12.0 versions ... HOT 1
- ENHANCEMENT: new parameter for call_actions for not reversing HOT 1
- Parser object singleton or caching. Actions as object members HOT 3
- Error for named matches in an imported grammar with default action HOT 2
- Possible memory leak HOT 4
- Question on AST generation and actions with side effects HOT 1
- 0.13.0 is released
- Support for parenthesized groups HOT 1
- 0.14.0 is released
- 0.15.0 is released
- possible regression in regexp handling HOT 2
- Request to optimize recognizers matching HOT 4
- 0.16.0 is released
- `a_opt: a?;` is not equivalent to `a_opt: a | EMPTY;` and causes an error `First set empty for grammar symbol "a_opt". An infinite recursion on the grammar symbol.` when `a` is a sequence. HOT 4
- advice requested on implementing a language "feature" HOT 1
- Lexical disambiguation not working as expected HOT 1
- Iterating through Forest fails in NodeNonTerm solutions property HOT 3
- Overriding terminal indirectly through multiple module imports fails when using separator repetition HOT 3
- Separate imports of the same file result in multiple "instances" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parglare.