normalize, skeleton
This commit is contained in:
parent
950eb2f2f6
commit
74549f3576
1
char.go
1
char.go
@ -27,6 +27,7 @@ func (p *charParser) nodeName() string { return p.name }
|
||||
func (p *charParser) nodeID() int { return p.id }
|
||||
func (p *charParser) setID(id int) { p.id = id }
|
||||
func (p *charParser) commitType() CommitType { return Alias }
|
||||
func (p *charParser) normalize(*registry, *idSet) error { return nil }
|
||||
|
||||
func (p *charParser) init(r *registry) error { return nil }
|
||||
|
||||
|
18
choice.go
18
choice.go
@ -38,6 +38,24 @@ func (d *choiceDefinition) nodeID() int { return d.id }
|
||||
func (d *choiceDefinition) setID(id int) { d.id = id }
|
||||
func (d *choiceDefinition) commitType() CommitType { return d.commit }
|
||||
|
||||
func (d *choiceDefinition) normalize(r *registry, path *idSet) error {
|
||||
if path.has(d.id) {
|
||||
return nil
|
||||
}
|
||||
|
||||
path.set(d.id)
|
||||
for i := range d.elements {
|
||||
element, ok := r.definition(d.elements[i])
|
||||
if !ok {
|
||||
return parserNotFound(d.elements[i])
|
||||
}
|
||||
|
||||
element.normalize(r, path)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *choiceDefinition) init(r *registry) error {
|
||||
if d.cbuilder == nil {
|
||||
d.cbuilder = &choiceBuilder{
|
||||
|
1
parse.go
1
parse.go
@ -7,6 +7,7 @@ type definition interface {
|
||||
nodeID() int
|
||||
commitType() CommitType
|
||||
setID(int)
|
||||
normalize(*registry, *idSet) error
|
||||
init(*registry) error
|
||||
setIncludedBy(*registry, int, *idSet) error
|
||||
parser(*registry, *idSet) (parser, error)
|
||||
|
18
sequence.go
18
sequence.go
@ -44,6 +44,24 @@ func (d *sequenceDefinition) nodeID() int { return d.id }
|
||||
func (d *sequenceDefinition) setID(id int) { d.id = id }
|
||||
func (d *sequenceDefinition) commitType() CommitType { return d.commit }
|
||||
|
||||
func (d *sequenceDefinition) normalize(r *registry, path *idSet) error {
|
||||
if path.has(d.id) {
|
||||
return nil
|
||||
}
|
||||
|
||||
path.set(d.id)
|
||||
for i := range d.items {
|
||||
element, ok := r.definition(d.items[i].Name)
|
||||
if !ok {
|
||||
return parserNotFound(d.items[i].Name)
|
||||
}
|
||||
|
||||
element.normalize(r, path)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *sequenceDefinition) includeItems() bool {
|
||||
return len(d.items) == 1 && d.items[0].Min == 1 && d.items[0].Max == 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user