-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 support for HCL #1594
Add support for HCL #1594
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.
Thank you for creating this language definition!
There are, however, a few things we have to fix before we can merge this. Apart from the comments, I left you, these things have to be addressed:
- Please don't use capturing groups when you don't need to. This is confusing because I expect the captured text to be used in some way. So please use non-capturing groups.
- There are a few cases where you have lists of tokens with only one pattern (
'abc': [ { /* stuff */ } ]
). Just assign the pattern to the token ('abc': { /* stuff */ }
).
Same goes for pattern objects of the form:{ pattern: /regex/ }
. You can always just inline/regex/
. - Multiline strings are not supported.
- Please add a
punctuation
token for the brackets of objects and arrays.
After that is done, I will continue to review your PR.
Also, I'm not very familiar with HCL so please tell me if I made a mistake somewhere.
Sorry for late, I will fix them until next weekend. |
@outsideris any luck? need a hand? |
I started to work on it. |
I'm updating code as your great feedback. Thank you!! |
@outsideris no need to apologise for open source work mate ;) |
f9013cb
to
6ff5cf9
Compare
I modified them as your feedback. |
@outsideris I'm sorry, I missed your last commit! I will review the changes ASAP. |
@outsideris Will this also parse hcl2 ? If not, would it be an idea to name this |
@maartenvanderhoef It is not parse hcl2 and hcl2 is still experimental. |
6ff5cf9
to
e1fd27d
Compare
I rebased onto latest master. |
hi @outsideris, you're right, let's stick Hashicorp's own naming. |
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.
Sorry for the delay!
I have a few problems beside my comments:
- Indentation.
- The use of capturing groups when the captured content is not used.
You use capturing groups a lot and they are necessary for lookbehinds and backreferences but all groups which are not used in that way should be non-capturing.
This is to make the patterns easier to understand because if there is a capturing group, you'll expect the captured text to be used. - Unnecessary surrounding array/objects.
In a few places, there is an array wrapped around a single object (e.g.'type': [ { /* pattern and so on */ } ]
in which case you can replace the array with its content.
In other places, there are objects which only contain thepattern
property. Those can be replaced with the pattern itself.
Again to make it easier to read and understand. - Instead of
[\w-]+|"[\w-]+"
you should use[\w-]+|"(?:[^\n\r\\"]|\\.)*"
to captur things like"abc\"def": 8
.
We will talk about interpolation, greedy strings and the keyword
patterns once this is done.
Again, I'm really sorry for the delay.
e1fd27d
to
40c4578
Compare
I fixed as your feedback. Sorry for bordering you because I'm not regexp expert. |
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.
A few more things and then we can talk about interpolation.
Also, please replace all arrays which only contain one item with said item. A good example of this is interpolation
.
(And don't worry. That doesn't borther me at all. Nobody is a regex master from the get go.)
I believe I didn't understand what you mean exactly. I can't find more arrays which only contain one item. |
Maybe another example: 'type': [ // start of array
{ // one item
pattern: /(resource|data|\s+)(?:[\w-]+|"[\w-]+")/i,
lookbehind: true,
alias: 'variable'
}
] // end of array But this can be replaced with a simpler expression: 'type': {
pattern: /(resource|data|\s+)(?:[\w-]+|"[\w-]+")/i,
lookbehind: true,
alias: 'variable'
} Other examples like this can be found on line 7, 19, 32, 36, and 48. |
5406c69
to
890be15
Compare
fixed. |
@outsideris
|
Signed-off-by: Outsider <outsideris@gmail.com>
Signed-off-by: Outsider <outsideris@gmail.com>
Signed-off-by: Outsider <outsideris@gmail.com>
Signed-off-by: Outsider <outsideris@gmail.com>
Signed-off-by: Outsider <outsideris@gmail.com>
Signed-off-by: Outsider <outsideris@gmail.com>
890be15
to
c05d498
Compare
@RunDevelopment |
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.
Good work!
I left you a few comments and after that is done, I think we are ready to merge this.
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 changed them as your feedback.
Signed-off-by: Outsider <outsideris@gmail.com>
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.
Looks good!
Two small things:
- Please make
comment
the first pattern andheredoc
greedy. This will solve the problem of false comments inside heredoc strings. - Please replace all occurrences of
"?[\w-]+"?
and[\w-]+|"[\w-]+"
with(?:[\w-]+|"(?:\\[\s\S]|[^\\"])*")
. All of these occurrences are inkeyword
.
Signed-off-by: Outsider <outsideris@gmail.com>
Fixed! :) |
Signed-off-by: Outsider <outsideris@gmail.com>
Done. |
Signed-off-by: Outsider <outsideris@gmail.com>
@RunDevelopment Fixed. Sorry for I missed it. |
@RunDevelopment You are awesome. I couldn't make this PR without you. Thank you. |
Good job! 👍 |
Supporting HCL(HashiCorp Configuration Language).
Close #1252