|
|
|
@ -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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|