Skip to content

Commit

Permalink
Merge pull request #873 from rsteube/lexer-escape-eof
Browse files Browse the repository at this point in the history
lexer: remove escape character when EOF follows (lenient)
  • Loading branch information
rsteube committed Aug 1, 2023
2 parents 49fe8cc + 62a6308 commit 0b50a69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ type Tokenset struct {

func Split(s string, pipelines bool) (*Tokenset, error) {
tokenset, err := split(s, pipelines)
if err != nil && err.Error() == "EOF found after escape character" {
return Split(s[:len(s)-1], pipelines) // TODO mark this in tokenset
}
if err != nil && err.Error() == "EOF found when expecting closing quote" {
tokenset, err = split(s+`_"`, pipelines)
if err == nil {
Expand Down
5 changes: 5 additions & 0 deletions internal/lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,9 @@ func TestSplit(t *testing.T) {
Prefix: `example `,
State: OPEN_SINGLE,
})

_test(`example \`, Tokenset{
Tokens: []string{"example", ""},
Prefix: `example `,
})
}

0 comments on commit 0b50a69

Please sign in to comment.