@@ -13,22 +13,23 @@ import (
1313)
1414
1515type ParserResult struct {
16- Variables []string `yaml:"variables"`
17- NegatedVarCount int `yaml:"negated_var_count"`
18- CollectionLengthCount int `yaml:"collection_length_count"`
19- Collections []string `yaml:"collections"`
20- CollectionArgs []string `yaml:"collection_args"`
21- OperatorList []string `yaml:"operator_list"`
22- OperatorValueList []string `yaml:"operator_value_list"`
23- NegatedOperatorCount int `yaml:"negated_operator_count"`
24- DirectiveList []string `yaml:"directive_list"`
25- DirectiveValues []string `yaml:"directive_values"`
26- RangeEvents []string `yaml:"range_events"`
27- RangeStartEvents []int `yaml:"range_start_events"`
28- RangeEndEvents []int `yaml:"range_end_events"`
29- SetvarCollections []string `yaml:"setvar_collections"`
30- SetvarNames []string `yaml:"setvar_names"`
31- SetvarOperations []string `yaml:"setvar_operations"`
16+ Comments []string `yaml:"comments"`
17+ Variables []string `yaml:"variables"`
18+ NegatedVarCount int `yaml:"negated_var_count"`
19+ CollectionLengthCount int `yaml:"collection_length_count"`
20+ Collections []string `yaml:"collections"`
21+ CollectionArgs []string `yaml:"collection_args"`
22+ OperatorList []string `yaml:"operator_list"`
23+ OperatorValueList []string `yaml:"operator_value_list"`
24+ NegatedOperatorCount int `yaml:"negated_operator_count"`
25+ DirectiveList []string `yaml:"directive_list"`
26+ DirectiveValues []string `yaml:"directive_values"`
27+ RangeEvents []string `yaml:"range_events"`
28+ RangeStartEvents []int `yaml:"range_start_events"`
29+ RangeEndEvents []int `yaml:"range_end_events"`
30+ SetvarCollections []string `yaml:"setvar_collections"`
31+ SetvarNames []string `yaml:"setvar_names"`
32+ SetvarOperations []string `yaml:"setvar_operations"`
3233}
3334
3435type TreeShapeListener struct {
@@ -183,3 +184,12 @@ func (l *TreeShapeListener) EnterCtl_action(ctx *parser.Ctl_actionContext) {
183184func (l * TreeShapeListener ) EnterCtl_id (ctx * parser.Ctl_idContext ) {
184185 l .results .DirectiveValues = append (l .results .DirectiveValues , ctx .GetText ())
185186}
187+
188+ func (l * TreeShapeListener ) EnterComment (ctx * parser.CommentContext ) {
189+ // ctx.COMMENT() can be nil if there is only a HASH without comment text
190+ if ctx .COMMENT () != nil {
191+ l .results .Comments = append (l .results .Comments , ctx .COMMENT ().GetText ())
192+ } else {
193+ l .results .Comments = append (l .results .Comments , "" )
194+ }
195+ }
0 commit comments