-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathidentifierPath.go
More file actions
41 lines (34 loc) · 798 Bytes
/
identifierPath.go
File metadata and controls
41 lines (34 loc) · 798 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
38
39
40
41
package solparser
import (
"github.com/uji/solparser/ast"
"github.com/uji/solparser/token"
)
func (p *Parser) ParseIdentifierPath() (ast.IdentifierPath, error) {
id, err := p.ParseIdentifier()
if err != nil {
return ast.IdentifierPath{}, err
}
var elements []*ast.IdentifierPathElement
for {
prd, err := p.lexer.Peek()
if err != nil || prd.Type != token.Period {
break
}
p.lexer.Scan()
elements = append(elements, &ast.IdentifierPathElement{
Identifier: ast.Identifier(id),
Period: &prd.Position,
})
i, err := p.ParseIdentifier()
if err != nil {
return ast.IdentifierPath{}, err
}
id = i
}
elements = append(elements, &ast.IdentifierPathElement{
Identifier: ast.Identifier(id),
})
return ast.IdentifierPath{
Elements: elements,
}, nil
}