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 lexer for Ada 2012. #1255

Merged
merged 2 commits into from Jul 11, 2019
Merged

Add a lexer for Ada 2012. #1255

merged 2 commits into from Jul 11, 2019

Conversation

stoklund
Copy link
Contributor

This implements Ada as described in the Consolidated Ada 2012 Language
Reference Manual
.

Follow the pygments example in terms of mime-type and file extensions
detected, but allow for full Unicode identifiers. Ada has specific rules
about the use of underscores in identifiers and number literals, and we
flag any errors.

Resolves #824.

I'm aware of the other Ada PR, #1021. I think this attempt is more complete with some significant differences:

  • Ada 2012 allows Unicode identifiers, not just a-z.
  • The predefined names in package Standard are not keywords, so I'm marking them, as Name.Builtin.
  • Double-quoted strings use different escape codes than C.
  • Character literals are single-quoted: 'x'.
  • There's a variety of number literal syntaxes.

I'd be happy to take notes from @btmalone.

This implements Ada as described in the [Consolidated Ada 2012 Language
Reference Manual](http://ada-auth.org/standards/ada12_w_tc1.html).

Follow the pygments example in terms of mime-type and file extensions
detected, but allow for full Unicode identifiers. Ada has specific rules
about the use of underscores in identifiers and number literals, and we
flag any errors.

Resolves #824.
@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Jul 10, 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.

This is looking good! I had a couple of comments:

lib/rouge/lexers/ada.rb Show resolved Hide resolved
lib/rouge/lexers/ada.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/ada.rb Outdated Show resolved Hide resolved
@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 10, 2019
The rule entering state :libunit_name was incorrectly classifying
whitespace as Keyword::Namespace in `limited with`. Add a spec to make
sure this is marked as Text.

In the :libunit_name state, detect keywords that shouldn't be there and
use those to recover quickly from the incorrectly entered state.

This recovery is more robust that the previous ping-pong with
:libunit_sep, so merge that state into libunit_name for simplicity.

Add specs to make sure we're recovering well.
@stoklund
Copy link
Contributor Author

Thanks for reviewing, @pyrmont!

I've added a new commit which addresses your review comments and also gets rid of the :libunit_sep state. By instead detecting keywords inside :libunit_name, we handle the most likely mistakes even better than before.

@pyrmont pyrmont merged commit 7295682 into rouge-ruby:master Jul 11, 2019
@pyrmont
Copy link
Contributor

pyrmont commented Jul 11, 2019

@stoklund Thanks for taking the time to submit such a good PR! It's great to have support for Ada in Rouge :)

@pyrmont pyrmont removed author-action The PR has been reviewed but action by the author is needed labels Jul 11, 2019
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.

Ada language support
2 participants