enable tracing

This commit is contained in:
Arpad Ryszka 2017-07-29 22:10:47 +02:00
parent cd9ecab3d1
commit 0b699ece28
4 changed files with 24 additions and 24 deletions

View File

@ -48,9 +48,9 @@ func (p *charParser) commitType() CommitType {
} }
func (p *charParser) setIncludedBy(includedBy parser, parsers *idSet) { func (p *charParser) setIncludedBy(includedBy parser, parsers *idSet) {
if parsers.has(p.id) { // if parsers.has(p.id) {
panic(cannotIncludeParsers(p.name)) // panic(cannotIncludeParsers(p.name))
} // }
p.includedBy = append(p.includedBy, includedBy) p.includedBy = append(p.includedBy, includedBy)
} }

View File

@ -78,9 +78,9 @@ func (p *choiceParser) nodeName() string { return p.name }
func (p *choiceParser) nodeID() int { return p.id } func (p *choiceParser) nodeID() int { return p.id }
func (p *choiceParser) setIncludedBy(includedBy parser, parsers *idSet) { func (p *choiceParser) setIncludedBy(includedBy parser, parsers *idSet) {
if parsers.has(p.id) { // if parsers.has(p.id) {
return // return
} // }
p.includedBy = append(p.includedBy, includedBy) p.includedBy = append(p.includedBy, includedBy)
} }
@ -100,22 +100,22 @@ func (p *choiceParser) storeIncluded(c *context, n *Node) {
} }
func (p *choiceParser) parse(t Trace, c *context) { func (p *choiceParser) parse(t Trace, c *context) {
// t = t.Extend(p.name) t = t.Extend(p.name)
// t.Out1("parsing choice", c.offset) t.Out1("parsing choice", c.offset)
if p.commit&Documentation != 0 { if p.commit&Documentation != 0 {
// t.Out1("fail, doc") t.Out1("fail, doc")
c.fail(c.offset) c.fail(c.offset)
return return
} }
if _, ok := c.fromStore(p.id); ok { if m, ok := c.fromStore(p.id); ok {
// t.Out1("found in store, match:", m) t.Out1("found in store, match:", m)
return return
} }
if c.excluded(c.offset, p.id) { if c.excluded(c.offset, p.id) {
// t.Out1("excluded") t.Out1("excluded")
c.fail(c.offset) c.fail(c.offset)
return return
} }
@ -156,13 +156,13 @@ func (p *choiceParser) parse(t Trace, c *context) {
} }
if match { if match {
// t.Out1("choice, success") t.Out1("choice, success")
c.success(node) c.success(node)
c.include(initialOffset, p.id) c.include(initialOffset, p.id)
return return
} }
// t.Out1("fail") t.Out1("fail")
c.store.set(node.From, p.id, nil) c.store.set(node.From, p.id, nil)
c.fail(node.From) c.fail(node.From)
c.include(initialOffset, p.id) c.include(initialOffset, p.id)

View File

@ -9,7 +9,7 @@ import (
) )
func TestMML(t *testing.T) { func TestMML(t *testing.T) {
test(t, "mml.parser", "mml", []testItem{{ testTrace(t, "mml.parser", "mml", 1, []testItem{{
msg: "empty", msg: "empty",
node: &Node{Name: "mml"}, node: &Node{Name: "mml"},
}, { }, {

View File

@ -99,9 +99,9 @@ func (p *sequenceParser) nodeName() string { return p.name }
func (p *sequenceParser) nodeID() int { return p.id } func (p *sequenceParser) nodeID() int { return p.id }
func (p *sequenceParser) setIncludedBy(includedBy parser, parsers *idSet) { func (p *sequenceParser) setIncludedBy(includedBy parser, parsers *idSet) {
if parsers.has(p.id) { // if parsers.has(p.id) {
return // return
} // }
p.includedBy = append(p.includedBy, includedBy) p.includedBy = append(p.includedBy, includedBy)
} }
@ -121,17 +121,17 @@ func (p *sequenceParser) storeIncluded(c *context, n *Node) {
} }
func (p *sequenceParser) parse(t Trace, c *context) { func (p *sequenceParser) parse(t Trace, c *context) {
// t = t.Extend(p.name) t = t.Extend(p.name)
// t.Out1("parsing sequence", c.offset) t.Out1("parsing sequence", c.offset)
if p.commit&Documentation != 0 { if p.commit&Documentation != 0 {
// t.Out1("fail, doc") t.Out1("fail, doc")
c.fail(c.offset) c.fail(c.offset)
return return
} }
if c.excluded(c.offset, p.id) { if c.excluded(c.offset, p.id) {
// t.Out1("excluded") t.Out1("excluded")
c.fail(c.offset) c.fail(c.offset)
return return
} }
@ -157,7 +157,7 @@ func (p *sequenceParser) parse(t Trace, c *context) {
if !m { if !m {
if currentCount < ranges[0][0] { if currentCount < ranges[0][0] {
// t.Out1("fail, item failed") t.Out1("fail, item failed")
// c.store.set(node.From, p.id, nil) // c.store.set(node.From, p.id, nil)
c.fail(node.From) c.fail(node.From)
c.include(initialOffset, p.id) c.include(initialOffset, p.id)
@ -186,7 +186,7 @@ func (p *sequenceParser) parse(t Trace, c *context) {
} }
} }
// t.Out1("success, items parsed") t.Out1("success, items parsed")
// c.store.set(node.From, p.id, node) // c.store.set(node.From, p.id, node)
for _, includedBy := range p.includedBy { for _, includedBy := range p.includedBy {