-
Notifications
You must be signed in to change notification settings - Fork 743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lexer development documentation #1111
Add lexer development documentation #1111
Conversation
Rouge does not have a single document explaining how a lexer should be developed. The README contains a simplified example and there are existing lexers that can be looked at for reference but these are inconsistent and do not clearly explain some of the more difficult elements (eg. disambiguating conflicting filename globs). This commit adds a docs directory with a basic guide. The guide is written in Markdown and so is viewable directly on GitHub but it is intended for use with YARD and uses YARD tags for cross referencing. For this reason, the commit also updates the `.yardopts` file. The README is also updated to refer to this guide.
This needs to be updated with further information. I think it would also be helpful to submit a separate PR changing the YARD settings. |
This adds further detail and adjusts the structure slightly.
I haven't finished reading this but I promise to do that during the weekend and add feedback :) This is very useful stuff |
Thanks @miparnisari :) I hope it's useful. I've merged this into master but it's intended to be a draft so please feel free to contribute feedback (either via GitHub or as a PR). |
I don't know how github works anymore so I forgot to hit the "Submit Review" button ><. |
@jneen That's cool! Thanks for the feedback. I'll get it updated as soon as I can (probably later tonight) :) |
Well I read this, very very well written and I actually learned a few things.
|
I'll reply to the other points a bit later tonight but regarding the way the source is consumed, @miparnisari wrote:
Rouge uses rouge/lib/rouge/regex_lexer.rb Line 305 in c1e1388
I'm not sure how |
From the docs for StringScanner#scan, it looks like the pointer advances till the end of match. For example: s = StringScanner.new('test string')
# test string
# ^
s.scan(/\w+/) # => test
# string
# ^
s.scan(/\w+/) # nil
# string
# ^
s.scan(/\s+/) # => " "
# string
# ^
s.scan(/\w+/) # => string
# EOS
# ^ |
Gah, I said |
😃 From the same docs :
|
@miparnisari The other answers to your questions:
|
As per the suggestions from @jneen in rouge-ruby#1111, this updates the lexer development guide.
Rouge does not have a single document explaining how a lexer should be developed. The README contains a simplified example and there are existing lexers that can be looked at for reference but these are inconsistent and do not clearly explain some of the more difficult elements (eg. disambiguating conflicting filename globs).
This commit adds a docs directory with a basic guide. The guide is written in Markdown and so is viewable directly on GitHub but it is intended for use with YARD and uses YARD tags for cross referencing. For this reason, the commit also updates the
.yardopts
file. The README is also updated to refer to this guide.