Skip to content

Add Scanner.#16

Open
dabrahams wants to merge 7 commits intoroop:masterfrom
dabrahams:scanner
Open

Add Scanner.#16
dabrahams wants to merge 7 commits intoroop:masterfrom
dabrahams:scanner

Conversation

@dabrahams
Copy link
Copy Markdown
Contributor

This is intended to be a replacement lexer; I hope it's of some use. I'm not attached to how or whether it is integrated. Of course I didn't make any of the examples use it, nor did I include tests, which should get done someday. I suggest that if backward compatibility is important to you that you simply reimplement CitronLexer in terms of Scanner.

Thanks for this project; it has basically been a joy to work with :-)

@roop
Copy link
Copy Markdown
Owner

roop commented Jun 21, 2021

Thanks a lot. I'll take a closer look this weekend and figure out how to integrate it (maybe make it a separate module alongside the current lexer).

Thanks for this project; it has basically been a joy to work with :-)

Thanks. This made my day. :) 😊

@dabrahams
Copy link
Copy Markdown
Contributor Author

dabrahams commented Jul 19, 2021

A few features I forgot to describe:

  1. This code labels each token with its location in the source.
  2. This lexer obeys the "max munch" rule, which says that the longest text matching any pattern is the next token. That's how lexers traditionally work, so you don't have to worry about the order in which patterns are specified.
  3. It uses one single regex for all tokens that are described literally rather than as patterns (e.g. keywords)

It's not the most efficient possible implementation, but it should be more efficient than what's currently in the project.

@dabrahams
Copy link
Copy Markdown
Contributor Author

dabrahams commented Mar 15, 2022

@dabrahams
Copy link
Copy Markdown
Contributor Author

This PR should be considered a draft until I report back.

@dabrahams
Copy link
Copy Markdown
Contributor Author

OK, reporting back; it works, FWIW.

@dabrahams
Copy link
Copy Markdown
Contributor Author

@roop Bump. I use this all the time.

@roop
Copy link
Copy Markdown
Owner

roop commented Jul 19, 2022

Thanks, @dabrahams. I hope to get around to integrating this in the next few days.

@dabrahams
Copy link
Copy Markdown
Contributor Author

I'm still on my own fork because this hasn't been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants