Fixes for parsing regex meta-rules.
This commit is contained in:
parent
0cc6493a56
commit
b9a5986fc7
2 changed files with 23 additions and 8 deletions
|
|
@ -78,7 +78,11 @@ func expand(input string, vars map[string][]string, expandBackticks bool) []stri
|
||||||
// Expand following a '\\'
|
// Expand following a '\\'
|
||||||
func expandEscape(input string) (string, int) {
|
func expandEscape(input string) (string, int) {
|
||||||
c, w := utf8.DecodeRuneInString(input)
|
c, w := utf8.DecodeRuneInString(input)
|
||||||
return string(c), w
|
if c == '\t' || c == ' ' {
|
||||||
|
return string(c), w
|
||||||
|
} else {
|
||||||
|
return "\\" + string(c), w
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expand a double quoted string starting after a '\"'
|
// Expand a double quoted string starting after a '\"'
|
||||||
|
|
|
||||||
25
lex.go
25
lex.go
|
|
@ -283,10 +283,6 @@ func lexTopLevel(l *lexer) lexerStateFun {
|
||||||
return lexBackQuotedWord
|
return lexBackQuotedWord
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.IndexRune(nonBareRunes, c) >= 0 {
|
|
||||||
l.lexerror(fmt.Sprintf("expected a unquoted string, but found '%c'", c))
|
|
||||||
}
|
|
||||||
|
|
||||||
return lexBareWord
|
return lexBareWord
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -366,12 +362,27 @@ func lexRecipe(l *lexer) lexerStateFun {
|
||||||
|
|
||||||
func lexBareWord(l *lexer) lexerStateFun {
|
func lexBareWord(l *lexer) lexerStateFun {
|
||||||
l.acceptUntil(nonBareRunes)
|
l.acceptUntil(nonBareRunes)
|
||||||
if l.peek() == '"' {
|
c := l.peek()
|
||||||
|
if c == '"' {
|
||||||
return lexDoubleQuotedWord
|
return lexDoubleQuotedWord
|
||||||
} else if l.peek() == '\'' {
|
} else if c == '\'' {
|
||||||
return lexSingleQuotedWord
|
return lexSingleQuotedWord
|
||||||
} else if l.peek() == '`' {
|
} else if c == '`' {
|
||||||
return lexBackQuotedWord
|
return lexBackQuotedWord
|
||||||
|
} else if c == '\\' {
|
||||||
|
c1 := l.peekN(1)
|
||||||
|
if c1 == '\n' || c1 == '\r' {
|
||||||
|
if l.start < l.pos {
|
||||||
|
l.emit(tokenWord)
|
||||||
|
}
|
||||||
|
l.skip()
|
||||||
|
l.skip()
|
||||||
|
return lexTopLevel
|
||||||
|
} else {
|
||||||
|
l.next()
|
||||||
|
l.next()
|
||||||
|
return lexBareWord
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if l.start < l.pos {
|
if l.start < l.pos {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue