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 basic Hack support #712

Merged
merged 2 commits into from
Sep 28, 2017
Merged

Add basic Hack support #712

merged 2 commits into from
Sep 28, 2017

Conversation

fredemmott
Copy link
Contributor

See hacklang.org

Changes to PHP and C++ (and corresponding tests) to make sure that
ambiguities are covered.

Will add XHP support in a separate pull request.

refs #392

@fredemmott
Copy link
Contributor Author

Is there a problem with this, or just not got to it yet?

aliases 'hack', 'hh'
filenames '*.php', '*.hh'

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.

Filetype guesser is changed in #763

Can you take a look at it?

See hacklang.org

Changes to PHP and C++ (and corresponding tests) to make sure that
ambiguities are covered.

Will add XHP support in a separate pull request.

refs rouge-ruby#392
@fredemmott
Copy link
Contributor Author

fredemmott commented Sep 22, 2017

@gfx: done, thanks, and squashed it down to one as the history was more confusing than useful

disambiguate '*.hh' do
next Cpp if matches?(/^\s*#include/)
next Hack if matches?(/^<\?hh/)
next Hack if matches?(/\):\s*Awaitable</)
Copy link
Member

Choose a reason for hiding this comment

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

: Awaitable is a valid syntax C++, so it shouldn't be here.

@fredemmott
Copy link
Contributor Author

fredemmott commented Sep 24, 2017

There's also a leading close parents in the pattern; is ): Awaitable< valid in C++?

@fredemmott
Copy link
Contributor Author

Also, is your objective to never pick Hack if it could be C++, or to pick the most likely? Even if ): Awaitable< is valid in C++, it seems specific enough to make Hack more likely

@gfx
Copy link
Member

gfx commented Sep 26, 2017

I think it never pick Hack over C++ if it might be C++ when ambiguous. If you declare a source is Hack, you can easily use <?hh.

@gfx
Copy link
Member

gfx commented Sep 28, 2017

Thanks. LGTM.

@gfx gfx merged commit 08fc22c into rouge-ruby:master Sep 28, 2017
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