Allow recipes to end with EOF.
This commit is contained in:
parent
6ef6f52936
commit
0cc6493a56
1 changed files with 9 additions and 1 deletions
10
lex.go
10
lex.go
|
|
@ -188,6 +188,14 @@ func (l *lexer) acceptUntil(invalid string) {
|
|||
}
|
||||
}
|
||||
|
||||
// Accept until something from the given string is encountered, or the end of th
|
||||
// file
|
||||
func (l *lexer) acceptUntilOrEof(invalid string) {
|
||||
for l.pos < len(l.input) && strings.IndexRune(invalid, l.peek()) < 0 {
|
||||
l.next()
|
||||
}
|
||||
}
|
||||
|
||||
// Skip characters from the valid string until the next is not.
|
||||
func (l *lexer) skipRun(valid string) int {
|
||||
prevpos := l.pos
|
||||
|
|
@ -343,7 +351,7 @@ func lexSingleQuotedWord(l *lexer) lexerStateFun {
|
|||
|
||||
func lexRecipe(l *lexer) lexerStateFun {
|
||||
for {
|
||||
l.acceptUntil("\n")
|
||||
l.acceptUntilOrEof("\n")
|
||||
l.acceptRun(" \t\n\r")
|
||||
if !l.indented || l.col == 0 {
|
||||
break
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue