From 9f110fff7867bccb7125384dee6088af6579567c Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Fri, 23 Jun 2023 23:59:20 -0400 Subject: [PATCH] code compiles --- lexer.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lexer.go b/lexer.go index af9ae28..5db9aa0 100644 --- a/lexer.go +++ b/lexer.go @@ -21,7 +21,7 @@ func lex(name, input string) *lexer { l := &lexer{ name: name, input: input, - state: lexText + state: lexText, items: make(chan item, 2), } go l.run() @@ -39,8 +39,6 @@ func (l *lexer) nextItem() item { } } -func (l *lexer) state( - func (l *lexer) ignore() { l.start = l.pos } @@ -52,6 +50,7 @@ func (l *lexer) backup() { type lexer struct { name, input string start, pos, width int + state stateFn items chan item } @@ -88,8 +87,13 @@ func (l *lexer) errorf(format string, args ...interface{}) stateFn { return nil } -func lexFragment (l *lexer) stateFn -func lexAlias (l *lexer) stateFn +func lexFragment(l *lexer) stateFn { + return l.errorf("lexFragment not implemented") +} + +func lexAlias(l *lexer) stateFn { + return l.errorf("lexAlias not implemented") +} func lexInsideLink(l *lexer) stateFn { for { @@ -103,10 +107,9 @@ func lexInsideLink(l *lexer) stateFn { case r == eof: case r == '\n': return l.errorf("unclosed link") - case r == "#": - next = l.peek() + case r == '#': return lexFragment - case r == "|": + case r == '|': return lexAlias } }