|
|
@ -21,7 +21,7 @@ func lex(name, input string) *lexer {
|
|
|
|
l := &lexer{
|
|
|
|
l := &lexer{
|
|
|
|
name: name,
|
|
|
|
name: name,
|
|
|
|
input: input,
|
|
|
|
input: input,
|
|
|
|
state: lexText
|
|
|
|
state: lexText,
|
|
|
|
items: make(chan item, 2),
|
|
|
|
items: make(chan item, 2),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
go l.run()
|
|
|
|
go l.run()
|
|
|
@ -39,8 +39,6 @@ func (l *lexer) nextItem() item {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (l *lexer) state(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (l *lexer) ignore() {
|
|
|
|
func (l *lexer) ignore() {
|
|
|
|
l.start = l.pos
|
|
|
|
l.start = l.pos
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -52,6 +50,7 @@ func (l *lexer) backup() {
|
|
|
|
type lexer struct {
|
|
|
|
type lexer struct {
|
|
|
|
name, input string
|
|
|
|
name, input string
|
|
|
|
start, pos, width int
|
|
|
|
start, pos, width int
|
|
|
|
|
|
|
|
state stateFn
|
|
|
|
items chan item
|
|
|
|
items chan item
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -88,8 +87,13 @@ func (l *lexer) errorf(format string, args ...interface{}) stateFn {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func lexFragment (l *lexer) stateFn
|
|
|
|
func lexFragment(l *lexer) stateFn {
|
|
|
|
func lexAlias (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 {
|
|
|
|
func lexInsideLink(l *lexer) stateFn {
|
|
|
|
for {
|
|
|
|
for {
|
|
|
@ -103,10 +107,9 @@ func lexInsideLink(l *lexer) stateFn {
|
|
|
|
case r == eof:
|
|
|
|
case r == eof:
|
|
|
|
case r == '\n':
|
|
|
|
case r == '\n':
|
|
|
|
return l.errorf("unclosed link")
|
|
|
|
return l.errorf("unclosed link")
|
|
|
|
case r == "#":
|
|
|
|
case r == '#':
|
|
|
|
next = l.peek()
|
|
|
|
|
|
|
|
return lexFragment
|
|
|
|
return lexFragment
|
|
|
|
case r == "|":
|
|
|
|
case r == '|':
|
|
|
|
return lexAlias
|
|
|
|
return lexAlias
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|