-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathblock.go
More file actions
37 lines (30 loc) · 698 Bytes
/
Copy pathblock.go
File metadata and controls
37 lines (30 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package solparser
import (
"github.com/uji/solparser/ast"
"github.com/uji/solparser/token"
)
func (p *Parser) ParseBlock() (*ast.Block, error) {
lblace, err := p.lexer.Scan()
if err != nil {
return nil, err
}
if lblace.Type != token.LBrace {
return nil, token.NewPosError(lblace.Position, "not found LBrace.")
}
stmt, err := p.ParseStatement()
if err != nil {
return nil, err
}
rblace, err := p.lexer.Scan()
if err != nil {
return nil, err
}
if rblace.Type != token.RBrace {
return nil, token.NewPosError(rblace.Position, "not found RBrace.")
}
return &ast.Block{
LBracePos: lblace.Position,
RBracePos: rblace.Position,
Nodes: []ast.Node{stmt},
}, nil
}