Skip to content

Commit ecec0c0

Browse files
authored
Merge pull request #64 from yoheimuta/fix-option-parse-error/63
Fix option parse error/63
2 parents 4f9e29a + 46c4f7d commit ecec0c0

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

parser/option.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ func (p *Parser) parseOptionName() (string, error) {
156156
optionName = p.lex.Text
157157
case scanner.TLEFTPAREN:
158158
optionName = p.lex.Text
159+
160+
// protoc accepts "(." fullIndent ")". See #63
161+
if p.permissive {
162+
p.lex.Next()
163+
if p.lex.Token == scanner.TDOT {
164+
optionName += "."
165+
} else {
166+
p.lex.UnNext()
167+
}
168+
}
169+
159170
fullIdent, _, err := p.lex.ReadFullIdent()
160171
if err != nil {
161172
return "", err

parser/option_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,22 @@ body:"*"}]}`,
242242
},
243243
},
244244
},
245+
{
246+
name: `parsing "(." fullIdent ")". Fix #63`,
247+
input: `option (.foo.bar.name) = "name";`,
248+
permissive: true,
249+
wantOption: &parser.Option{
250+
OptionName: "(.foo.bar.name)",
251+
Constant: `"name"`,
252+
Meta: meta.Meta{
253+
Pos: meta.Position{
254+
Offset: 0,
255+
Line: 1,
256+
Column: 1,
257+
},
258+
},
259+
},
260+
},
245261
}
246262

247263
for _, test := range tests {

0 commit comments

Comments
 (0)