-
Notifications
You must be signed in to change notification settings - Fork 738
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
Awesome, thanks @dblessing! |
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.