enable tracing, disable storing included
This commit is contained in:
parent
85cd8f1729
commit
3aa2d9a6b0
5
char.go
5
char.go
@ -69,11 +69,16 @@ func (p *charParser) match(t rune) bool {
|
||||
}
|
||||
|
||||
func (p *charParser) parse(t Trace, c *context) {
|
||||
t = t.Extend(p.name)
|
||||
t.Out1("parsing", c.offset)
|
||||
|
||||
if tok, ok := c.token(); !ok || !p.match(tok) {
|
||||
t.Out1("fail")
|
||||
c.fail(c.offset)
|
||||
return
|
||||
}
|
||||
|
||||
t.Out1("success")
|
||||
c.success(c.offset + 1)
|
||||
for _, includedBy := range p.includedBy {
|
||||
c.store.setMatch(c.offset, includedBy, c.offset+1)
|
||||
|
15
choice.go
15
choice.go
@ -144,16 +144,22 @@ func (p *choiceParser) nodeName() string { return p.name }
|
||||
func (p *choiceParser) nodeID() int { return p.id }
|
||||
|
||||
func (p *choiceParser) parse(t Trace, c *context) {
|
||||
t = t.Extend(p.name)
|
||||
t.Out1("parsing", c.offset)
|
||||
|
||||
// TODO: don't add documentation
|
||||
if p.commit&Documentation != 0 {
|
||||
c.fail(c.offset)
|
||||
return
|
||||
}
|
||||
|
||||
if _, ok := c.fromStore(p.id); ok {
|
||||
if m, ok := c.fromStore(p.id); ok {
|
||||
t.Out1("found in cache", m)
|
||||
return
|
||||
}
|
||||
|
||||
if c.excluded(c.offset, p.id) {
|
||||
t.Out1("fail, excluded")
|
||||
c.fail(c.offset)
|
||||
return
|
||||
}
|
||||
@ -186,7 +192,10 @@ func (p *choiceParser) parse(t Trace, c *context) {
|
||||
|
||||
c.store.setMatch(from, p.id, to)
|
||||
for _, includedBy := range p.includedBy {
|
||||
c.store.setMatch(from, includedBy, to)
|
||||
if !c.excluded(from, includedBy) {
|
||||
t.Out1("storing included", includedBy)
|
||||
// c.store.setMatch(from, includedBy, to)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,9 +207,11 @@ func (p *choiceParser) parse(t Trace, c *context) {
|
||||
if match {
|
||||
c.success(to)
|
||||
c.include(from, p.id)
|
||||
t.Out1("success")
|
||||
return
|
||||
}
|
||||
|
||||
t.Out1("fail")
|
||||
c.store.setNoMatch(from, p.id)
|
||||
c.fail(from)
|
||||
c.include(from, p.id)
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMML(t *testing.T) {
|
||||
testTrace(t, "mml.parser", "mml", 1, []testItem{{
|
||||
testTrace(t, "mml.parser", "mml", 0, []testItem{{
|
||||
msg: "empty",
|
||||
node: &Node{Name: "mml"},
|
||||
}, {
|
||||
|
11
sequence.go
11
sequence.go
@ -171,12 +171,16 @@ func (p *sequenceParser) nodeName() string { return p.name }
|
||||
func (p *sequenceParser) nodeID() int { return p.id }
|
||||
|
||||
func (p *sequenceParser) parse(t Trace, c *context) {
|
||||
t = t.Extend(p.name)
|
||||
t.Out1("parsing", c.offset)
|
||||
|
||||
if p.commit&Documentation != 0 {
|
||||
c.fail(c.offset)
|
||||
return
|
||||
}
|
||||
|
||||
if c.excluded(c.offset, p.id) {
|
||||
t.Out1("fail, excluded")
|
||||
c.fail(c.offset)
|
||||
return
|
||||
}
|
||||
@ -200,6 +204,7 @@ func (p *sequenceParser) parse(t Trace, c *context) {
|
||||
// c.store.setNoMatch(from, p.id)
|
||||
c.fail(from)
|
||||
c.include(from, p.id)
|
||||
t.Out1("fail, not enough items")
|
||||
return
|
||||
}
|
||||
|
||||
@ -222,9 +227,13 @@ func (p *sequenceParser) parse(t Trace, c *context) {
|
||||
}
|
||||
|
||||
for _, includedBy := range p.includedBy {
|
||||
c.store.setMatch(from, includedBy, to)
|
||||
if !c.excluded(from, includedBy) {
|
||||
t.Out1("storing included", includedBy)
|
||||
// c.store.setMatch(from, includedBy, to)
|
||||
}
|
||||
}
|
||||
|
||||
t.Out1("success")
|
||||
c.store.setMatch(from, p.id, to)
|
||||
c.success(to)
|
||||
c.include(from, p.id)
|
||||
|
Loading…
Reference in New Issue
Block a user