Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

zakame
Copy link

@zakame zakame commented Sep 9, 2017

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

@zakame
Copy link
Author

zakame commented Sep 9, 2017

I took at look at the Pygments implementation and might try to crib a few bits from there (especially the bracketing and Unicode operators) 💪

@gfx
Copy link
Member

gfx commented Sep 13, 2017

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'
Copy link
Member

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.

Copy link
Author

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.

filenames '*.pl6', '*.pm6'
mimetypes 'text/x-perl6', 'application/x-perl6'

def self.analyze_text(text)
Copy link
Member

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.

Copy link
Author

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?

Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in require/?

Copy link
Author

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 👍

@zakame
Copy link
Author

zakame commented Sep 14, 2017

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. 👍

@Tyil
Copy link

Tyil commented May 31, 2018

Is there still any progress on this PR?

spec/lexers/perl6_spec.rb Outdated Show resolved Hide resolved
@zakame
Copy link
Author

zakame commented May 31, 2018

@Tyil thanks for noticing. I haven't had tuits lately to work on this, but I'll try this weekend.

@Tyil
Copy link

Tyil commented Aug 29, 2018

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 :>

@zakame
Copy link
Author

zakame commented Aug 29, 2018

@Tyil thanks for reminding! I have to sort out the review comments here first (and likely rebase against any master updates,) which I missed last time as I prioritized on https://github.com/Perl/docker-perl work. Let me check and update tonight, thanks!

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.
This should be `#!/usr/bin/env` rather than `#!/usr/local/env` (though
the source detector should ignore this and check for `perl6`.)
@rypervenche
Copy link

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.

https://raku.org/

@pyrmont pyrmont changed the title Add a Perl6 lexer Add a Raku/Perl 6 lexer Feb 27, 2020
@melezhik
Copy link

Hi guys! Any updates here? We really need it - forem/forem#3009 (comment) it's stale for awhile ...

@jjatria
Copy link
Contributor

jjatria commented Jan 19, 2021

@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 :)

@melezhik
Copy link

Thanks @jjatria the thing is dev.to uses the mainstream version of rogue ... But yeah, thanks ...

@polettix
Copy link

polettix commented Feb 4, 2023

Just a gentle bump... @jjatria 😄

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.

Add support for Perl 6
7 participants