File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -249,19 +249,18 @@ A = "aaa ${B} ccc "
249
249
func TestFull (t * testing.T ) {
250
250
log .SetLevel (log .DebugLevel )
251
251
is := `
252
+ # my comment
252
253
253
-
254
- A=aaa
255
- B="bbb"
254
+ A=aaa # my inline comment on A
255
+ B="bbb" # my inline comment on B
256
256
C =ccc
257
257
D= ddd
258
- E='eee'
258
+ E='eee' # my inline comment on E
259
259
F=
260
260
G
261
261
262
262
H="my_value"
263
263
264
-
265
264
I = bar baz
266
265
267
266
export EXPORTED_VAR = exported_value
Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ func (l *EnvLangFileListener) ExitEntry(c *fileparser.EntryContext) {
37
37
// TODO: Implement the logic to handle the export keyword in the grammar file
38
38
id , _ = strings .CutPrefix (id , "export " )
39
39
id = strings .TrimSpace (id )
40
+ if strings .HasPrefix (id , "#" ) {
41
+ return
42
+ }
40
43
41
44
hasAssign := true
42
45
if c .ASSIGN () == nil || c .ASSIGN ().GetText () == "" {
@@ -47,6 +50,7 @@ func (l *EnvLangFileListener) ExitEntry(c *fileparser.EntryContext) {
47
50
valuePtr = & v
48
51
}
49
52
53
+ toTrim := true
50
54
if c .Value () != nil {
51
55
v := strings .TrimSpace (c .Value ().GetText ())
52
56
switch c .Value ().GetStr ().GetTokenType () {
@@ -55,8 +59,15 @@ func (l *EnvLangFileListener) ExitEntry(c *fileparser.EntryContext) {
55
59
valuePtr = & v
56
60
case fileparser .EnvLangFileParserDQSTRING :
57
61
v = v [1 : len (v )- 1 ] // Removing quotes
62
+ toTrim = false
58
63
fallthrough
59
64
case fileparser .EnvLangFileParserTEXT :
65
+ if strings .Index (v , "#" ) != 0 {
66
+ v = strings .SplitN (v , "#" , pair )[0 ]
67
+ if toTrim {
68
+ v = strings .TrimSpace (v )
69
+ }
70
+ }
60
71
v = GetValue (l .d , v )
61
72
valuePtr = & v
62
73
default :
You can’t perform that action at this time.
0 commit comments