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

Implement the Terraform Lexer #917

Merged
merged 3 commits into from
Jun 19, 2018
Merged

Conversation

lowjoel
Copy link
Contributor

@lowjoel lowjoel commented May 24, 2018

Fixes #722.

This implements two parts of the lexer, the HCL lexer implements most of the HCL language, and the Terraform lexer adds keywords and string interpolations.

Copy link
Collaborator

@dblessing dblessing left a comment

Choose a reason for hiding this comment

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

Couple of minor comments/questions. Thanks @lowjoel

@heredocstr = Regexp.escape(m[5])
push :heredoc
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason for putting these above the def self.* methods and also above the root state? While it's a minor style thing, it's customary to have root be the first state and methods to appear at the top before states. Maybe there's a specific thought you had in mind, though?

Copy link
Contributor Author

@lowjoel lowjoel Jun 13, 2018

Choose a reason for hiding this comment

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

Not quite, I just took the ordering found in the JavaScript lexer: https://github.com/jneen/rouge/blob/master/lib/rouge/lexers/javascript.rb. It kind of made sense since this set of keywords may be overridden in derived lexers (Terraform redefines these)

What do you recommend?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm OK with this.

token Name::Builtin
else
token Name::Other
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are declarations/keywords/etc. tokenized here and in the root state of the hcl lexer? Can you give me an example of each case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

expression is used inside interpolations.

resource "something" {
}

resource "other" {
  key = "${resource.something.key}" # This is handled by the expression state.
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK.

@dblessing dblessing added the author-action The PR has been reviewed but action by the author is needed label Jun 13, 2018
@dblessing dblessing merged commit 75855c3 into rouge-ruby:master Jun 19, 2018
@lowjoel
Copy link
Contributor Author

lowjoel commented Jun 20, 2018

Awesome, thanks @dblessing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author-action The PR has been reviewed but action by the author is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants