goccmack / gocc

Parser / Scanner Generator
Other
622 stars 48 forks source link

internal: remove commented-out debugging block from production generated code #53

Closed kortschak closed 7 years ago

kortschak commented 7 years ago

See https://github.com/goccmack/gocc/pull/52#discussion_r129208442

sangisos commented 7 years ago

Is anybody working on this or should I take it? a simple grep -r "// fmt.Print" gave me the following 71 lines:

example/nolexer/parser/parser.go:       // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String())
example/sr/lexer/lexer.go:  // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos)
example/sr/lexer/lexer.go:      // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state)
example/sr/lexer/lexer.go:      // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState)
example/sr/lexer/lexer.go:      // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end)
example/sr/lexer/lexer.go:              // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok)
example/sr/lexer/lexer.go:              // fmt.Printf("\t Ignore(%s)\n", string(act))
example/sr/lexer/lexer.go:  // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit)
example/sr/parser/parser.go:        // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String())
example/errorrecovery/parser/parser.go:     // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String())
example/calc/lexer/lexer.go:    // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos)
example/calc/lexer/lexer.go:        // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state)
example/calc/lexer/lexer.go:        // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState)
example/calc/lexer/lexer.go:        // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end)
example/calc/lexer/lexer.go:                // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok)
example/calc/lexer/lexer.go:                // fmt.Printf("\t Ignore(%s)\n", string(act))
example/calc/lexer/lexer.go:    // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit)
example/calc/parser/parser.go:      // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String())
example/astx/lexer/lexer.go:    // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos)
example/astx/lexer/lexer.go:        // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state)
example/astx/lexer/lexer.go:        // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState)
example/astx/lexer/lexer.go:        // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end)
example/astx/lexer/lexer.go:                // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok)
example/astx/lexer/lexer.go:                // fmt.Printf("\t Ignore(%s)\n", string(act))
example/astx/lexer/lexer.go:    // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit)
example/astx/parser/parser.go:      // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String())
example/bools/lexer/lexer.go:   // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos)
example/bools/lexer/lexer.go:       // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state)
example/bools/lexer/lexer.go:       // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState)
example/bools/lexer/lexer.go:       // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end)
example/bools/lexer/lexer.go:               // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok)
example/bools/lexer/lexer.go:               // fmt.Printf("\t Ignore(%s)\n", string(act))
example/bools/lexer/lexer.go:   // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit)
example/bools/parser/parser.go:     // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String())
example/rr/lexer/lexer.go:  // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos)
example/rr/lexer/lexer.go:      // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state)
example/rr/lexer/lexer.go:      // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState)
example/rr/lexer/lexer.go:      // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end)
example/rr/lexer/lexer.go:              // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok)
example/rr/lexer/lexer.go:              // fmt.Printf("\t Ignore(%s)\n", string(act))
example/rr/lexer/lexer.go:  // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit)
example/rr/parser/parser.go:        // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String())
example/mail/lexer/lexer.go:    // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos)
example/mail/lexer/lexer.go:        // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state)
example/mail/lexer/lexer.go:        // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState)
example/mail/lexer/lexer.go:        // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end)
example/mail/lexer/lexer.go:                // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok)
example/mail/lexer/lexer.go:                // fmt.Printf("\t Ignore(%s)\n", string(act))
example/mail/lexer/lexer.go:    // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit)
internal/frontend/parser/parser.go:     // fmt.Printf("S%d %s %s\n", this.stack.Top(), this.nextToken, action)
internal/frontend/parser/parser_ut.go:      // fmt.Printf("S%d %s %s\n", this.stack.Top(), this.nextToken, action)
internal/lexer/items/item_test.go:          // fmt.Printf("%s", item.pos)
internal/lexer/items/itemset.go:    // fmt.Printf("S%d%s\n", this.setNo, this)
internal/lexer/items/itemset.go:    // fmt.Printf("dependentsClosure S%d, %s\n", this.setNo, items)
internal/lexer/items/itemset.go:                    // fmt.Printf("\t%s\n", thisItem)
internal/lexer/gen/golang/lexer.go: // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos)
internal/lexer/gen/golang/lexer.go:     // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state)
internal/lexer/gen/golang/lexer.go:     // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState)
internal/lexer/gen/golang/lexer.go:     // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end)
internal/lexer/gen/golang/lexer.go:             // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok)
internal/lexer/gen/golang/lexer.go:             // fmt.Printf("\t Ignore(%s)\n", string(act))
internal/lexer/gen/golang/lexer.go: // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit)
internal/parser/gen/golang/parser.go:       // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String())
internal/test/t1/lexer/lexer.go:    // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos)
internal/test/t1/lexer/lexer.go:        // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state)
internal/test/t1/lexer/lexer.go:        // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState)
internal/test/t1/lexer/lexer.go:        // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end)
internal/test/t1/lexer/lexer.go:                // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok)
internal/test/t1/lexer/lexer.go:                // fmt.Printf("\t Ignore(%s)\n", string(act))
internal/test/t1/lexer/lexer.go:    // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit)
internal/test/t1/parser/parser.go:      // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String())

telling us that each lexer generated gives us 7 commented out prints in lexer.go, and each parser generated gives 1 commented out print in parser.go. Should we only deal with these and leave the rest of the commented out prints in the backend code alone for now? Or should there be a complete overhaul of debug-prints even in backend?

awalterschulze commented 7 years ago

Two steps might be simpler, but contributor's choice. I am not working on this, but will review it.

On Thu, 27 Jul 2017, 17:53 sangisos, notifications@github.com wrote:

Is anybody working on this or should I take it? a simple grep -r "// fmt.Print" gave me the following 71 lines:

example/nolexer/parser/parser.go: // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String()) example/sr/lexer/lexer.go: // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos) example/sr/lexer/lexer.go: // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state) example/sr/lexer/lexer.go: // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState) example/sr/lexer/lexer.go: // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end) example/sr/lexer/lexer.go: // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok) example/sr/lexer/lexer.go: // fmt.Printf("\t Ignore(%s)\n", string(act)) example/sr/lexer/lexer.go: // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit) example/sr/parser/parser.go: // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String()) example/errorrecovery/parser/parser.go: // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String()) example/calc/lexer/lexer.go: // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos) example/calc/lexer/lexer.go: // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state) example/calc/lexer/lexer.go: // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState) example/calc/lexer/lexer.go: // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end) example/calc/lexer/lexer.go: // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok) example/calc/lexer/lexer.go: // fmt.Printf("\t Ignore(%s)\n", string(act)) example/calc/lexer/lexer.go: // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit) example/calc/parser/parser.go: // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String()) example/astx/lexer/lexer.go: // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos) example/astx/lexer/lexer.go: // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state) example/astx/lexer/lexer.go: // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState) example/astx/lexer/lexer.go: // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end) example/astx/lexer/lexer.go: // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok) example/astx/lexer/lexer.go: // fmt.Printf("\t Ignore(%s)\n", string(act)) example/astx/lexer/lexer.go: // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit) example/astx/parser/parser.go: // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String()) example/bools/lexer/lexer.go: // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos) example/bools/lexer/lexer.go: // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state) example/bools/lexer/lexer.go: // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState) example/bools/lexer/lexer.go: // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end) example/bools/lexer/lexer.go: // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok) example/bools/lexer/lexer.go: // fmt.Printf("\t Ignore(%s)\n", string(act)) example/bools/lexer/lexer.go: // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit) example/bools/parser/parser.go: // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String()) example/rr/lexer/lexer.go: // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos) example/rr/lexer/lexer.go: // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state) example/rr/lexer/lexer.go: // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState) example/rr/lexer/lexer.go: // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end) example/rr/lexer/lexer.go: // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok) example/rr/lexer/lexer.go: // fmt.Printf("\t Ignore(%s)\n", string(act)) example/rr/lexer/lexer.go: // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit) example/rr/parser/parser.go: // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String()) example/mail/lexer/lexer.go: // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos) example/mail/lexer/lexer.go: // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state) example/mail/lexer/lexer.go: // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState) example/mail/lexer/lexer.go: // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end) example/mail/lexer/lexer.go: // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok) example/mail/lexer/lexer.go: // fmt.Printf("\t Ignore(%s)\n", string(act)) example/mail/lexer/lexer.go: // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit) internal/frontend/parser/parser.go: // fmt.Printf("S%d %s %s\n", this.stack.Top(), this.nextToken, action) internal/frontend/parser/parser_ut.go: // fmt.Printf("S%d %s %s\n", this.stack.Top(), this.nextToken, action) internal/lexer/items/item_test.go: // fmt.Printf("%s", item.pos) internal/lexer/items/itemset.go: // fmt.Printf("S%d%s\n", this.setNo, this) internal/lexer/items/itemset.go: // fmt.Printf("dependentsClosure S%d, %s\n", this.setNo, items) internal/lexer/items/itemset.go: // fmt.Printf("\t%s\n", thisItem) internal/lexer/gen/golang/lexer.go: // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos) internal/lexer/gen/golang/lexer.go: // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state) internal/lexer/gen/golang/lexer.go: // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState) internal/lexer/gen/golang/lexer.go: // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end) internal/lexer/gen/golang/lexer.go: // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok) internal/lexer/gen/golang/lexer.go: // fmt.Printf("\t Ignore(%s)\n", string(act)) internal/lexer/gen/golang/lexer.go: // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit) internal/parser/gen/golang/parser.go: // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String()) internal/test/t1/lexer/lexer.go: // fmt.Printf("Lexer.Scan() pos=%d\n", this.pos) internal/test/t1/lexer/lexer.go: // fmt.Printf("\tpos=%d, line=%d, col=%d, state=%d\n", this.pos, this.line, this.column, state) internal/test/t1/lexer/lexer.go: // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState) internal/test/t1/lexer/lexer.go: // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", this.pos, size, start, end) internal/test/t1/lexer/lexer.go: // fmt.Printf("\t Accept(%s), %s(%d)\n", string(act), token.TokMap.Id(tok), tok) internal/test/t1/lexer/lexer.go: // fmt.Printf("\t Ignore(%s)\n", string(act)) internal/test/t1/lexer/lexer.go: // fmt.Printf("Token at %s: %s \"%s\"\n", tok.String(), token.TokMap.Id(tok.Type), tok.Lit) internal/test/t1/parser/parser.go: // fmt.Printf("S%d %s %s\n", this.stack.top(), token.TokMap.TokenString(this.nextToken), action.String())

telling us that each lexer generated gives us 7 commented out prints in lexer.go, and each parser generated gives 1 commented out print in parser.go. Should we only deal with these and leave the rest of the commented out prints in the backend code alone for now? Or should there be a complete overhaul of debug-prints even in backend?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/goccmack/gocc/issues/53#issuecomment-318404573, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvsLRyOYdcQ9zManr1T1FZopPKIpLFEks5sSLJigaJpZM4OkrPW .

mewmew commented 7 years ago

@sangisos Go for it!

sangisos commented 7 years ago

I'm guessing the whole argument for keeping debug prints commented out in production is because of the part of the lexer being done differently depending on debug mode:

{{- if .Debug}}
        // Production start
        // if rune1 != -1 {
        //  state = TransTab[state](rune1)
        // } else {
        //  state = -1
        // }
        // Production end

        // Debug start
        nextState := -1
        if rune1 != -1 {
            nextState = TransTab[state](rune1)
        }
        fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState)
        fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", l.pos, size, start, end)
        if nextState != -1 {
            fmt.Printf("\t\taction:%s\n", ActTab[nextState].String())
        }
        state = nextState
        // Debug end
    {{- else}}
        // Production start
        if rune1 != -1 {
            state = TransTab[state](rune1)
        } else {
            state = -1
        }
        // Production end

        // Debug start
        // nextState := -1
        // if rune1 != -1 {
        //  nextState = TransTab[state](rune1)
        // }
        // fmt.Printf("\tS%d, : tok=%s, rune == %s(%x), next state == %d\n", state, token.TokMap.Id(tok.Type), util.RuneToString(rune1), rune1, nextState)
        // fmt.Printf("\t\tpos=%d, size=%d, start=%d, end=%d\n", l.pos, size, start, end)
        // if nextState != -1 {
        //  fmt.Printf("\t\taction:%s\n", ActTab[nextState].String())
        // }
        // state = nextState
        // Debug end
    {{- end}}

Removing all commented out parts, not mentioning the difference, feels prone to create hisenbugs. Any tips?

sangisos commented 7 years ago

I believe in the power of the go compiler to optimize this, and would go with the debug version at all times (minus the print outs) if it does not hit performance. @mewmew could you bench it after i push to sangisos/gocc branch remcom?

mewmew commented 7 years ago

Removing all commented out parts, not mentioning the difference, feels prone to create hisenbugs. Any tips?

Indeed, the difference between the debug and production code should be next to none; basically only include debug messages when debugging is enabled, but the lexing (and parsing) code should be identical. Otherwise, the debugger will be debugging something other than the production code.

I believe in the power of the go compiler to optimize this, and would go with the debug version at all times (minus the print outs) if it does not hit performance. @mewmew could you bench it after i push to sangisos/gocc branch remcom?

Ping me when you wish to try the benchmark. llir/llvm is large enough to be useful for such a benchmark :)

awalterschulze commented 7 years ago

Sounds good to me :)