This commit is contained in:
Arpad Ryszka 2017-07-30 03:08:45 +02:00
parent 1b21b8fde2
commit 59d0a333ed
2 changed files with 12 additions and 32 deletions

39
char.go
View File

@ -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
} }

View File

@ -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