-
Notifications
You must be signed in to change notification settings - Fork 629
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
Terraform (HCL) (*.tf): new parser #3683
Closed
Closed
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
616c2d1
add terraform support (preliminary)
antonysouthworth-halter c78ccef
add terraform c parser
antonysouthworth-halter c4d902e
add copyright notice and doc
antonysouthworth-halter ca9d8fe
fix build
antonysouthworth-halter 489c04c
fix newlines
antonysouthworth-halter 7d58baf
pr fixes
antonysouthworth-halter 30035c2
Merge remote-tracking branch 'antony/master' into add-terraform-support
6bea5b5
Add terraform to source.mak
31aa0ff
Simplify terraform regexes
8763e9c
Add terraform unit tests for each resource type
8e2b2e1
Don't sort simple-terraform.d test output
239d8be
Remove unnecessary names from regex patterns
63267c7
Rename terraform to Terraform
772eb3b
Fix visual studio project files
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Generated by ./misc/optlib2c from optlib/terraform.ctags, Don't edit this manually. | ||
*/ | ||
#include "general.h" | ||
#include "parse.h" | ||
#include "routines.h" | ||
#include "field.h" | ||
#include "xtag.h" | ||
|
||
|
||
static void initializeTerraformParser (const langType language CTAGS_ATTR_UNUSED) | ||
{ | ||
} | ||
|
||
extern parserDefinition* TerraformParser (void) | ||
{ | ||
static const char *const extensions [] = { | ||
"tf", | ||
"tfvars", | ||
NULL | ||
}; | ||
|
||
static const char *const aliases [] = { | ||
NULL | ||
}; | ||
|
||
static const char *const patterns [] = { | ||
NULL | ||
}; | ||
|
||
static kindDefinition TerraformKindTable [] = { | ||
{ | ||
true, 'r', "Resource", "Terraform Resource", | ||
}, | ||
{ | ||
true, 'd', "Data", "Terraform Data", | ||
}, | ||
{ | ||
true, 'v', "Variable", "Terraform Variable", | ||
}, | ||
{ | ||
true, 'p', "Provider", "Terraform Provider", | ||
}, | ||
{ | ||
true, 'm', "Module", "Terraform Module", | ||
}, | ||
{ | ||
true, 'o', "Output", "Terraform Output", | ||
}, | ||
}; | ||
static tagRegexTable TerraformTagRegexTable [] = { | ||
{"^resource[[:space:]]\"([^\"]+)\"[[:space:]]\"([^\"]+)\"", "\\2", | ||
"r,Resource", NULL, NULL, false}, | ||
{"^data[[:space:]]\"([^\"]+)\"[[:space:]]\"([^\"]+)\"", "\\2", | ||
"d,Data", NULL, NULL, false}, | ||
{"^variable[[:space:]]\"([^\"]+)\"", "\\1", | ||
"v,Variable", NULL, NULL, false}, | ||
{"^provider[[:space:]]\"([^\"]+)\"", "\\1", | ||
"p,Provider", NULL, NULL, false}, | ||
{"^module[[:space:]]\"([^\"]+)\"", "\\1", | ||
"m,Module", NULL, NULL, false}, | ||
{"^output[[:space:]]\"([^\"]+)\"", "\\1", | ||
"o,Output", NULL, NULL, false}, | ||
{"^([a-z0-9_]+)[[:space:]]*=", "\\1", | ||
"f,TFVar", NULL, NULL, false}, | ||
}; | ||
|
||
|
||
parserDefinition* const def = parserNew ("terraform"); | ||
|
||
def->versionCurrent= 0; | ||
def->versionAge = 0; | ||
def->enabled = true; | ||
def->extensions = extensions; | ||
def->patterns = patterns; | ||
def->aliases = aliases; | ||
def->method = METHOD_NOT_CRAFTED|METHOD_REGEX; | ||
def->kindTable = TerraformKindTable; | ||
def->kindCount = ARRAY_SIZE(TerraformKindTable); | ||
def->tagRegexTable = TerraformTagRegexTable; | ||
def->tagRegexCount = ARRAY_SIZE(TerraformTagRegexTable); | ||
def->initialize = initializeTerraformParser; | ||
|
||
return def; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# terraform.ctags: regex parse for Terraform (HCL). | ||
# | ||
# Author: Antony Southworth <https://github.com/antonysouthworth-halter> | ||
# | ||
# This source code is released for free distribution under the terms of the | ||
# GNU General Public License version 2 or (at your option) any later version. | ||
# | ||
# Derived from `vim-terraform-completion`: | ||
# - https://github.com/juliosueiras/vim-terraform-completion/blob/master/ctags/terraform.ctags | ||
# | ||
# Changed the name from `terraform` to `tf` so vim will recognise it properly based | ||
# on file extension (*.tf). | ||
# | ||
# A notable abscence is `local`, because `locals` are defined inside a block and | ||
# it's way harder to write a good regex for that. | ||
# - https://www.terraform.io/docs/language/values/locals.html | ||
|
||
--langdef=terraform | ||
--map-terraform=+.tf | ||
--map-terraform=+.tfvars | ||
--kinddef-terraform=r,Resource,Terraform Resource | ||
--kinddef-terraform=d,Data,Terraform Data | ||
--kinddef-terraform=v,Variable,Terraform Variable | ||
--kinddef-terraform=p,Provider,Terraform Provider | ||
--kinddef-terraform=m,Module,Terraform Module | ||
--kinddef-terraform=o,Output,Terraform Output | ||
--regex-terraform=/^resource[[:space:]]"([^"]+)"[[:space:]]"([^"]+)"/\2/r,Resource/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You use both kind letter and kind long name in "r,Resource".
|
||
--regex-terraform=/^data[[:space:]]"([^"]+)"[[:space:]]"([^"]+)"/\2/d,Data/ | ||
--regex-terraform=/^variable[[:space:]]"([^"]+)"/\1/v,Variable/ | ||
--regex-terraform=/^provider[[:space:]]"([^"]+)"/\1/p,Provider/ | ||
--regex-terraform=/^module[[:space:]]"([^"]+)"/\1/m,Module/ | ||
--regex-terraform=/^output[[:space:]]"([^"]+)"/\1/o,Output/ | ||
--regex-terraform=/^([a-z0-9_]+)[[:space:]]*=/\1/f,TFVar/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Terraform or TerraForm is better.
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.
You are right. It should be Terraform.