From af56dc0cb5b3a0bbc017beef2b5dfe74e58b9a25 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sat, 25 Oct 2025 14:56:15 -0700 Subject: Add support for C-style comments --- asspb.go | 2 +- asspb_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/asspb.go b/asspb.go index 488c731..62f81a7 100644 --- a/asspb.go +++ b/asspb.go @@ -36,7 +36,7 @@ type parser struct { i int } -var spaceRE = regexp.MustCompile(`^([[:space:]\p{Zs}]|#[^\n]*)*`) +var spaceRE = regexp.MustCompile(`^([[:space:]\p{Zs}]|(#|//)[^\n]*|/\*([^*]|\*[^/])*\**\*/)*`) func (p *parser) skipSpace() { p.i += len(spaceRE.Find(p.data[p.i:])) diff --git a/asspb_test.go b/asspb_test.go index 36e8e5f..6803733 100644 --- a/asspb_test.go +++ b/asspb_test.go @@ -162,6 +162,14 @@ field: 2`, desc: "ListOfMessage", msg: `field: [{}]`, want: map[string]any{"field": []any{map[string]any{}}}, + }, { + desc: "CStyleComment", + msg: `field: /** inline comment **/ {}`, + want: map[string]any{"field": map[string]any{}}, + }, { + desc: "CStyleLineComment", + msg: `field: {} // line comment`, + want: map[string]any{"field": map[string]any{}}, }} { t.Run(tc.desc, func(t *testing.T) { t.Parallel() -- cgit v1.3.1