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

added basic Haxe support #815

Merged
merged 18 commits into from
Aug 9, 2019
Merged

added basic Haxe support #815

merged 18 commits into from
Aug 9, 2019

Conversation

josuigoa
Copy link
Contributor

@josuigoa josuigoa commented Nov 6, 2017

No description provided.

@jdonaldson jdonaldson mentioned this pull request Jan 8, 2018
@olleolleolle
Copy link
Contributor

Also: <3 Haxe support. Thanks for building this!

@kLabz
Copy link

kLabz commented Mar 21, 2018

Any news on this?

lib/rouge/lexers/haxe.rb Outdated Show resolved Hide resolved
@uvtc uvtc mentioned this pull request Aug 30, 2018
@zabojad
Copy link

zabojad commented Jan 19, 2019

Hi there! What need to be done here to make it merged?

@cmandlbaur
Copy link

@olleolleolle any guidance here on what needs to be done would be greatly appreciated.

@RichardBray
Copy link

@pyrmont @olleolleolle @jneen Hey guys 👋 any updates on what needs to be done to get this merged? The guys at dev.to use this to syntax highlight their articles and this would be great for all the Haxe posts out there.

@pyrmont
Copy link
Contributor

pyrmont commented Jul 24, 2019

@RichardBray Sorry it's taken so long to get to this. I'm afraid that I've been working my way through the PRs in reverse chronological order which admittedly isn't great for the older PRs. I do prioritise ones where there's activity, though, so am happy to move this to the front of my queue! Will take a look on where things are and get back to you :)

@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Jul 24, 2019
Copy link
Contributor

@pyrmont pyrmont left a comment

Choose a reason for hiding this comment

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

Thanks for this submission and apologies for how long it has taken to review it.

In addition to the specific comments below, the lexer also needs to have a spec. At a basic level, the spec just needs to test a handful of things. The Perl one is a very similar example:

# -*- coding: utf-8 -*- #
# frozen_string_literal: true
describe Rouge::Lexers::Perl do
let(:subject) { Rouge::Lexers::Perl.new }
describe 'guessing' do
include Support::Guessing
it 'guesses by filename' do
# *.pl needs source hints because it's also used by Prolog
assert_guess :filename => 'foo.pl', :source => 'my $foo = 1'
assert_guess :filename => 'foo.pm'
assert_guess :filename => 'test.t'
end
it 'guesses by mimetype' do
assert_guess :mimetype => 'text/x-perl'
assert_guess :mimetype => 'application/x-perl'
end
it 'guesses by source' do
assert_guess :source => '#!/usr/local/bin/perl'
end
end
end

lib/rouge/lexers/haxe.rb Show resolved Hide resolved
lib/rouge/lexers/haxe.rb Show resolved Hide resolved
lib/rouge/lexers/haxe.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/haxe.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/haxe.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/haxe.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/haxe.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/haxe.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/haxe.rb Outdated Show resolved Hide resolved
spec/visual/samples/haxe Show resolved Hide resolved
@pyrmont
Copy link
Contributor

pyrmont commented Jul 24, 2019

Oh, two more things:

  1. To get this to work with Travis, you'll need to bring in the new settings for Travis, the Gemfile, the Rake task. Rebasing against master should bring all that stuff in. Once you've done that, you'll be able to run rake at the command line and see the results of the test suite and RuboCop.

  2. One of the things that RuboCop will complain about is regular expression literals that can be ambiguous as to whether they are calls to the / method. The general way we've fixed this since your original submission is to move from this rule /.../ to this rule %r/.../. You can of course use other delimiters with %r but that's the change that requires the least amount of work.

Let me know if any of the above or any of the comments are unclear!

@pyrmont pyrmont added author-action The PR has been reviewed but action by the author is needed and removed needs-review The PR needs to be reviewed labels Jul 24, 2019
@RichardBray
Copy link

Thanks @pyrmont for taking a look at this. I really want to get Haxe support included but my Ruby is rusty :( I will ping @josuigoa to take a look, if I get nothing in a week I'll try and take it myself 🤞

@pyrmont
Copy link
Contributor

pyrmont commented Jul 26, 2019

@RichardBray No worries! Let me know if you get stuck!

@josuigoa
Copy link
Contributor Author

josuigoa commented Aug 1, 2019

Hi! I'm going on vacation these days and I couldn't add a better sample. I think all other changes are done. @RichardBray , could you add a proper sample?

@RichardBray
Copy link

@josuigoa Yeah sure, I will see what I can do. Thanks for your work on this so far.

@RichardBray
Copy link

@josuigoa Sorry I wasn't able to edit the samples file from your file so I made a new PR with the changes #1293. Hopefully, you're okay with that. If not we can hold off merge until you're back from vacation.

@josuigoa
Copy link
Contributor Author

josuigoa commented Aug 5, 2019 via email

@RichardBray
Copy link

@josuigoa Ah cool thanks for giving me permission. I'll see if I can push my changes to this PR

@pyrmont
Copy link
Contributor

pyrmont commented Aug 6, 2019

@josuigoa @RichardBray I'm sorry for the force push—there's been some important changes made to Rouge's Gemfile and Rake tasks that I wanted to pick up so I've rebased against the current master.

I've corrected some remaining indentation mistakes and added a self.detect? method so that the automatic tests will pass (you can run these yourself by pulling down the rebased repo, making sure your gems are up to date and running rake).

The last thing to check are the errors in the visual sample. If you run rackup, you'll have a web server running locally that you can open and see the way Rouge is lexing the visual sample. You'll see there's problems with the @ character and with regular expressions. I haven't looked closely at the rules to see where the problems are. If it's not obvious, you can wait a little bit and I'll have a look at fixing it.

@RichardBray
Copy link

RichardBray commented Aug 8, 2019

@pyrmont Hmmm, I guess there must be a rule where if an @ symbol is not in a method or in quotation marks it errors out. They're not essential in the Haxe sample file so I've taken them out in this PR. josuigoa#3

But if someone does want syntax highlighting for a Haxe Macro then there might be an issue 🤔

@kLabz
Copy link

kLabz commented Aug 8, 2019

I guess there must be a rule where if an @ symbol is not in a method or in quotation marks it errors out.

What do you mean? Haxe metas can be used in various places.

@RichardBray
Copy link

@kLabz sorry I meant an error in the rouge lexer not an error with Haxe. I feel like rouge will need to be updated in the future to accommodate the @ symbol being used anywhere.

@kLabz
Copy link

kLabz commented Aug 8, 2019

I'm testing things locally and yeah this version is very limited but I guess that's already better than current state (no highlighting at all)

@pyrmont
Copy link
Contributor

pyrmont commented Aug 8, 2019

@kLabz Can you provide some examples (you can just paste them here) that aren't being parsed properly? I'm more inclined to want to fix this while we're reviewing this lexer now than put it off to later.

@kLabz
Copy link

kLabz commented Aug 8, 2019

There's not much missing actually 👍

  • String interpolation is not handled at all but that's only a nice-to-have, it doesn't break anything
  • Metadata (incorrectly named "haxe macros" here) give errors. Note that with haxe 4 you can have namespaced metadata as in @:some.meta.
  • Conditional compilation give errors too. In haxe 4 they can be namespaced too #if abc.def and there's a new semver parsing #if (somelib_ver >= version("1.2.4")).
  • Abstracts are partially supported (Some example with from, to and metadata + Operator overloading); seems like only from/to and metadata support are missing.

@pyrmont pyrmont added needs-review The PR needs to be reviewed and removed author-action The PR has been reviewed but action by the author is needed labels Aug 8, 2019
@pyrmont
Copy link
Contributor

pyrmont commented Aug 8, 2019

@kLabz I think I've added all the features you mentioned but let me know if I broke something or if I missed something.

@pyrmont pyrmont added author-action The PR has been reviewed but action by the author is needed and removed needs-review The PR needs to be reviewed labels Aug 8, 2019
@kLabz
Copy link

kLabz commented Aug 9, 2019

Indeed it works pretty well, thanks!

@RichardBray
Copy link

Thanks for sorting things out and approving this PR @pyrmont. I owe you a coffee when I'm next in Tokyo ☕️

@pyrmont pyrmont merged commit 669dc1e into rouge-ruby:master Aug 9, 2019
@pyrmont
Copy link
Contributor

pyrmont commented Aug 9, 2019

Thanks everyone :) We're on a two-week cadence for releases of Rouge as we go through the backlog of pull requests. The next release (v3.9.0) is scheduled for Tuesday 20 August and this lexer will be included with that version.

@pyrmont pyrmont removed the author-action The PR has been reviewed but action by the author is needed label Aug 9, 2019
@kLabz kLabz mentioned this pull request Aug 9, 2019
1 task
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.

8 participants