-
Notifications
You must be signed in to change notification settings - Fork 739
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 a Raku/Perl 6 lexer #771
base: master
Are you sure you want to change the base?
Conversation
I took at look at the Pygments implementation and might try to crib a few bits from there (especially the bracketing and Unicode operators) 💪 |
Thanks for the contribution. I think Perl6 is not compatible from Perl5 so you shouldn't extend Perl6 lexer from Perl lexer. |
desc "The Perl 6 programming language (perl6.org)" | ||
|
||
tag "perl6" | ||
aliases 'pl6' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aliases
are aliases for tags. I think it is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, though I'm a bit confused here since the docstrings for tag
and aliases
are
Rouge::Lexer.tag([t]) Used to specify or get the canonical name of this lexer class.
Rouge::Lexer.aliases(args...) Used to specify alternate names this lexer class may be found by.
lib/rouge/lexers/perl6.rb
Outdated
filenames '*.pl6', '*.pm6' | ||
mimetypes 'text/x-perl6', 'application/x-perl6' | ||
|
||
def self.analyze_text(text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The language detection has been changed in #763
No "scores" are used anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, so moving forward should I have a detect?
method returning boolean instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep!
|
||
rules = %w(regex rule token) | ||
|
||
includes = %w(use require\ unit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in require/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this from existing Emacs perl6-mode rules, but checking others like pygments' Perl6Lexer seems to be more correct. I'll likely change it as I further flesh out the RegexLexer-based update 👍
Hi @gfx, thanks for the feedback! Indeed, I've mentioned earlier that this is early phase and would really be better if it is based on Lexers::RegexLexer instead of Lexers::Perl; I'm working on that now and hopefully I can push an update by this weekend. Hope you can let me know again what you think of it when it is up. 👍 |
Is there still any progress on this PR? |
@Tyil thanks for noticing. I haven't had tuits lately to work on this, but I'll try this weekend. |
Hi, It's been a while since I last checked, is there anything I can do to help this particular PR to get merged? I'd like to have my README.pod6 to get rendered properly on GitLab :> |
@Tyil thanks for reminding! I have to sort out the review comments here first (and likely rebase against any |
This is an initial work deriving from current Rouge::Lexer::Perl, and using keyword data from https://docs.perl6.org and https://github.com/perl6/perl6-mode. In all likelihood though, this might just derive directly from Rouge::Lexer::RegexLexer instead and implement its own states soon in subsequent commits, considering there's a lot of syntax changes. Ref. rouge-ruby#390
This makes tests pass for the time being, while working to move this to use RegexLexer instead of deriving from Perl5.
f0b7dff
to
a1830d3
Compare
This should be `#!/usr/bin/env` rather than `#!/usr/local/env` (though the source detector should ignore this and check for `perl6`.)
I'd just like to point out that the language has been renamed to Raku, although it might still be good to make perl6 an alias to raku for backward compatibility. |
Hi guys! Any updates here? We really need it - forem/forem#3009 (comment) it's stale for awhile ... |
@melezhik I've been working on a different version of this PR for a while (it's the one we are using in raku.land), which does not use the Perl lexer as the starting point. That's been making slow progress, but seems promising. I'll see if I can try to get that into a more workable condition soon. Not to mean that I would not like to see progress done on this one in the meantime, though :) |
Thanks @jjatria the thing is dev.to uses the mainstream version of rogue ... But yeah, thanks ... |
Just a gentle bump... @jjatria 😄 |
This is an initial work deriving from current Rouge::Lexer::Perl, and
using keyword data from https://docs.perl6.org and
https://github.com/perl6/perl6-mode.
In all likelihood though, this might just derive directly from
Rouge::Lexer::RegexLexer instead and implement its own states soon in
subsequent commits, considering there's a lot of syntax changes.
This would close #390