cleanup
This commit is contained in:
parent
1b21b8fde2
commit
59d0a333ed
39
char.go
39
char.go
@ -68,22 +68,6 @@ func (p *charParser) match(t rune) bool {
|
|||||||
return p.not
|
return p.not
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *charParser) matchBuild(t rune) bool {
|
|
||||||
for _, ci := range p.chars {
|
|
||||||
if ci == t {
|
|
||||||
return !p.not
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, ri := range p.ranges {
|
|
||||||
if t >= ri[0] && t <= ri[1] {
|
|
||||||
return !p.not
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return p.not
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *charParser) parse(t Trace, c *context) {
|
func (p *charParser) parse(t Trace, c *context) {
|
||||||
// t = t.Extend(p.name)
|
// t = t.Extend(p.name)
|
||||||
// t.Out1("parsing", c.offset)
|
// t.Out1("parsing", c.offset)
|
||||||
@ -102,17 +86,18 @@ func (p *charParser) parse(t Trace, c *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *charParser) build(c *context) ([]*Node, bool) {
|
func (p *charParser) build(c *context) ([]*Node, bool) {
|
||||||
// TODO: how to remove this check
|
panic("called char build")
|
||||||
t, ok := c.token()
|
// // TODO: how to remove this check
|
||||||
if !ok {
|
// t, ok := c.token()
|
||||||
panic("damaged parser context")
|
// if !ok {
|
||||||
}
|
// panic("damaged parser context")
|
||||||
|
// }
|
||||||
|
|
||||||
if !p.matchBuild(t) {
|
// if !p.match(t) {
|
||||||
return nil, false
|
// return nil, false
|
||||||
}
|
// }
|
||||||
|
|
||||||
// always alias
|
// // always alias
|
||||||
c.offset++
|
// c.offset++
|
||||||
return nil, true
|
// return nil, true
|
||||||
}
|
}
|
||||||
|
5
store.go
5
store.go
@ -1,10 +1,5 @@
|
|||||||
package treerack
|
package treerack
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// - store it similarly to the excluded ones? sorted by offset?
|
|
||||||
// - use a helper field for the last accessed position to walk from there? for every offset?
|
|
||||||
// - use a helper field to store the largest value and its index, too? for an offset?
|
|
||||||
|
|
||||||
type store struct {
|
type store struct {
|
||||||
noMatch []*idSet
|
noMatch []*idSet
|
||||||
match [][]int
|
match [][]int
|
||||||
|
Loading…
Reference in New Issue
Block a user