Skip to content

Commit 5779aef

Browse files
committed
No longer strip comments and ";" from description
1 parent 0353fcd commit 5779aef

File tree

6 files changed

+7
-16
lines changed

6 files changed

+7
-16
lines changed

go/pkg/parser/parser.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,10 @@ func (p *parser) description() *ast.Description {
358358
preCmt := p.readPreCmt("")
359359
if p.check("description") {
360360
p.expectLeave("=")
361-
p.pos, p.tok = p.scanner.ToEOLorComment()
361+
p.pos, p.tok = p.scanner.ToEOL()
362362
a := new(ast.Description)
363-
a.Text = p.tok
363+
a.Text = strings.TrimSpace(p.tok)
364364
a.SetPreComment(preCmt)
365-
a.SetPostComment(p.readPostCmtAfter(""))
366365
p.next()
367366
return a
368367
}

go/pkg/pass1/setup-objects.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,7 @@ func (c *spoc) setupService(v *ast.Service) {
23892389
sv := c.symTable.service[sName]
23902390
sv.name = name
23912391
if d := v.Description; d != nil {
2392-
sv.description = strings.TrimSuffix(strings.TrimSpace(d.Text), ";")
2392+
sv.description = d.Text
23932393
}
23942394
for _, a := range v.Attributes {
23952395
switch a.Name {

go/pkg/scanner/scanner.go

-8
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,3 @@ func (s *Scanner) ToEOL() (int, string) {
254254
}
255255
return pos, string(s.src[pos:s.offset])
256256
}
257-
258-
func (s *Scanner) ToEOLorComment() (int, string) {
259-
pos := s.offset
260-
for s.ch != '\n' && s.ch != '#' && s.ch >= 0 {
261-
s.next()
262-
}
263-
return pos, string(s.src[pos:s.offset])
264-
}

go/testdata/cut-netspoc/cut-netspoc.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -3083,7 +3083,7 @@ service:s = {
30833083
}
30843084
=OUTPUT=
30853085
network:n1 = {
3086-
description = network:n1
3086+
description = network:n1; # looks like code
30873087
ip = 10.1.1.0/24;
30883088
}
30893089
network:n2 = { ip = 10.1.2.0/24; }

go/testdata/export-netspoc/export.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -2124,7 +2124,7 @@ service:s1 = {
21242124
{
21252125
"s1": {
21262126
"details": {
2127-
"description": "test; test, test",
2127+
"description": "test; test, test;# With comment",
21282128
"owner": [
21292129
":unknown"
21302130
]

go/testdata/format-netspoc/format-netspoc.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ host:h2, # after second
231231
group:g1 =
232232
# g1 trailing2
233233
# g1 post def
234-
description = This is a fine group # desc
234+
description = This is a fine group; # desc
235235

236236
# desc post
237237
# desc post 2
@@ -253,7 +253,7 @@ group:g1 =
253253
;
254254
=OUTPUT=
255255
group:g1 =
256-
description = the text # comment
256+
description = the text; ;; # comment
257257

258258
;
259259
=END=

0 commit comments

Comments
 (0)