debugging

dev
Nick Dumas 1 year ago
parent c109f142b6
commit 4735f0b36d

@ -1,6 +1,7 @@
package wikilink package wikilink
import ( import (
"log"
"strings" "strings"
) )
@ -25,6 +26,7 @@ func isBlockRef(s string) bool {
} }
func lexIdent(l *Lexer) stateFn { func lexIdent(l *Lexer) stateFn {
log.Println("lexIdent")
for { for {
r := l.next() r := l.next()
s := l.input[l.pos:] s := l.input[l.pos:]
@ -47,11 +49,11 @@ func lexIdent(l *Lexer) stateFn {
} }
} }
panic("we shouldn't be here") return l.errorf("malformed link")
return nil // this shouldn't ever be reached
} }
func lexHeading(l *Lexer) stateFn { func lexHeading(l *Lexer) stateFn {
log.Println("lexHeading")
l.pos += len(Heading) l.pos += len(Heading)
l.emit(ItemHeading) l.emit(ItemHeading)
@ -59,6 +61,7 @@ func lexHeading(l *Lexer) stateFn {
} }
func lexBlockRef(l *Lexer) stateFn { func lexBlockRef(l *Lexer) stateFn {
log.Println("lexBlockRef")
l.pos += len(BlockRef) l.pos += len(BlockRef)
l.emit(ItemBlockRef) l.emit(ItemBlockRef)
@ -66,6 +69,7 @@ func lexBlockRef(l *Lexer) stateFn {
} }
func lexAlias(l *Lexer) stateFn { func lexAlias(l *Lexer) stateFn {
log.Println("lexAlias")
l.pos += len(Alias) l.pos += len(Alias)
l.emit(ItemAlias) l.emit(ItemAlias)
@ -73,6 +77,7 @@ func lexAlias(l *Lexer) stateFn {
} }
func lexText(l *Lexer) stateFn { func lexText(l *Lexer) stateFn {
log.Println("lexText")
for { for {
if isOpenLink(l.input[l.pos:]) { if isOpenLink(l.input[l.pos:]) {
return lexOpenLink return lexOpenLink
@ -87,6 +92,7 @@ func lexText(l *Lexer) stateFn {
} }
func lexOpenLink(l *Lexer) stateFn { func lexOpenLink(l *Lexer) stateFn {
log.Println("lexOpenLink")
l.pos += len(OpenLink) l.pos += len(OpenLink)
l.emit(ItemOpenLink) l.emit(ItemOpenLink)
@ -94,6 +100,7 @@ func lexOpenLink(l *Lexer) stateFn {
} }
func lexCloseLink(l *Lexer) stateFn { func lexCloseLink(l *Lexer) stateFn {
log.Println("lexCloseLink")
l.pos += len(CloseLink) l.pos += len(CloseLink)
l.emit(ItemCloseLink) l.emit(ItemCloseLink)

Loading…
Cancel
Save