Skip to content

Commit

Permalink
✨ : add comment support in HCL parser
Browse files Browse the repository at this point in the history
  • Loading branch information
juwit committed Nov 12, 2019
1 parent 7bea678 commit 4df23fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/antlr4/io/codeka/gaia/hcl/antlr/hcl.g4
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ NUMBER
: '0' | [1-9] [0-9]*
;

WS
: [ \t\r\n]+ -> skip
; // skip spaces, tabs, newlines
// comments and whitespaces
COMMENT: '/*' .*? '*/' -> skip;
LINE_COMMENT: '//' ~[\r\n]* -> skip;
HAS_COMMENT: '#' ~ [\r\n]* -> skip;
WS: [ \t\r\n]+ -> skip; // skip spaces, tabs, newlines
5 changes: 5 additions & 0 deletions src/test/resources/hcl/variables.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
// a full variable
variable "string_var" {
type = "string"
description = "a test string var"
default = "foo"
}

# another one
variable "number_var" {
description = "a test number var"
type = number
default = 42
}

/*
* A multi line comment
*/
variable "bool_var" {
default = false
}

0 comments on commit 4df23fa

Please sign in to comment.