mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 16:47:28 +01:00
Assign values, not just messages, to status codes
This commit is contained in:
1 parent
86010a17e2
commit
634789722d
10 files changed
+103
-59
No files matched your search
+17
-1
@@ -229,6 +229,22 @@ func (p *parser) parseTopLevelDecl() (*a.Node, error) {
|
||||
case t.IDError, t.IDSuspension:
|
||||
keyword := p.src[0].ID
|
||||
p.src = p.src[1:]
|
||||
|
||||
if x := p.peek1(); x != t.IDOpenParen {
|
||||
got := p.tm.ByID(x)
|
||||
return nil, fmt.Errorf(`parse: expected "(", got %q at %s:%d`, got, p.filename, p.line())
|
||||
}
|
||||
p.src = p.src[1:]
|
||||
value, err := p.parseExpr()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if x := p.peek1(); x != t.IDCloseParen {
|
||||
got := p.tm.ByID(x)
|
||||
return nil, fmt.Errorf(`parse: expected ")", got %q at %s:%d`, got, p.filename, p.line())
|
||||
}
|
||||
p.src = p.src[1:]
|
||||
|
||||
message := p.peek1()
|
||||
if !message.IsStrLiteral(p.tm) {
|
||||
got := p.tm.ByID(message)
|
||||
@@ -240,7 +256,7 @@ func (p *parser) parseTopLevelDecl() (*a.Node, error) {
|
||||
return nil, fmt.Errorf(`parse: expected (implicit) ";", got %q at %s:%d`, got, p.filename, p.line())
|
||||
}
|
||||
p.src = p.src[1:]
|
||||
return a.NewStatus(flags, p.filename, line, keyword, message).Node(), nil
|
||||
return a.NewStatus(flags, p.filename, line, keyword, value, message).Node(), nil
|
||||
|
||||
case t.IDStruct:
|
||||
p.src = p.src[1:]
|
||||
|
||||
Reference in new issue
Block a user