Replies: 3 comments
-
Performance-wise it shouldn't matter. Nesting is more readable.
Postfix
That ought to work. There are many lexers that use this construct: https://github.com/search?q=repo%3Aorbitalquark%2Fscintillua%20lexer.any%20-%20lexer.space&type=code
Nicely done! That's the hardest part.
I would take a look at other lexers, note the style and structure, and try to mimic them. If and when you're ready to contribute, you can mark your PR as ready for review, and we'll go through the review process. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick response @orbitalquark ! I'm still cogitating over number 2.... But I finally figured out number 3, I needed to exclude colon for my use case! 🙃 local not_whitespace = lexer.any - lexer.space - P(':') |
Beta Was this translation helpful? Give feedback.
-
#136 ready for review. I know it's incomplete from a meta-data perspective, so I need some feedback. |
Beta Was this translation helpful? Give feedback.
-
First time playing with LPeg / scintillua so I may not know how to ask the right questions.
I'm working on a todo.txt lexer, I have something that works https://github.com/clach04/scintillua/blob/todotxt/lexers/todotxt.lua but it's the first working version and there are a few things I'm not sure about.
What's the best practice for chaining patterns with "starts with"? Nest or concatenate?
For example:
versus:
Any performance impact?
#patt Matches patt but consumes no input.
I want to match dates in ISO like format, my initial pattern was too greedy and matches anything that has is date-like (see "order number" example at end):I thought a prefix of☹️ .
#lexer.space
(or evenlexer.space
) would help filter, it does NOTHowever, post-fix works great 😃
I'm currently using a workaround to match basic us-ascii (with some exceptions due to use case) but it feels dirty:
Any suggestions? I know I need to rename this 😜 if I keep this approach.
Here is my test todo.txt file:
Screenshot from bat
My current progress:
TL;DR I have something that works, what do I need to polish this and potentially contribute it to scintillua?
Beta Was this translation helpful? Give feedback.
All reactions