From 4735f0b36d4ee4706e7c0e33154e2b42aeb1fa91 Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Sat, 1 Jul 2023 17:37:23 -0400 Subject: [PATCH] debugging --- states.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/states.go b/states.go index 4ed8c98..dc04950 100644 --- a/states.go +++ b/states.go @@ -1,6 +1,7 @@ package wikilink import ( + "log" "strings" ) @@ -25,6 +26,7 @@ func isBlockRef(s string) bool { } func lexIdent(l *Lexer) stateFn { + log.Println("lexIdent") for { r := l.next() s := l.input[l.pos:] @@ -47,11 +49,11 @@ func lexIdent(l *Lexer) stateFn { } } - panic("we shouldn't be here") - return nil // this shouldn't ever be reached + return l.errorf("malformed link") } func lexHeading(l *Lexer) stateFn { + log.Println("lexHeading") l.pos += len(Heading) l.emit(ItemHeading) @@ -59,6 +61,7 @@ func lexHeading(l *Lexer) stateFn { } func lexBlockRef(l *Lexer) stateFn { + log.Println("lexBlockRef") l.pos += len(BlockRef) l.emit(ItemBlockRef) @@ -66,6 +69,7 @@ func lexBlockRef(l *Lexer) stateFn { } func lexAlias(l *Lexer) stateFn { + log.Println("lexAlias") l.pos += len(Alias) l.emit(ItemAlias) @@ -73,6 +77,7 @@ func lexAlias(l *Lexer) stateFn { } func lexText(l *Lexer) stateFn { + log.Println("lexText") for { if isOpenLink(l.input[l.pos:]) { return lexOpenLink @@ -87,6 +92,7 @@ func lexText(l *Lexer) stateFn { } func lexOpenLink(l *Lexer) stateFn { + log.Println("lexOpenLink") l.pos += len(OpenLink) l.emit(ItemOpenLink) @@ -94,6 +100,7 @@ func lexOpenLink(l *Lexer) stateFn { } func lexCloseLink(l *Lexer) stateFn { + log.Println("lexCloseLink") l.pos += len(CloseLink) l.emit(ItemCloseLink)