Skip to content

Commit

Permalink
lexer: quote workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jul 29, 2023
1 parent f39db97 commit 99682eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions internal/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ type Tokenset struct {
func Split(s string, pipelines bool) (*Tokenset, error) {
tokenset, err := split(s, pipelines)
if err != nil && err.Error() == "EOF found when expecting closing quote" {
tokenset, err = split(s+`"`, pipelines)
tokenset, err = split(s+`_"`, pipelines)
if err == nil {
tokenset.State = OPEN_DOUBLE
last := tokenset.Tokens[len(tokenset.Tokens)-1]
tokenset.Tokens[len(tokenset.Tokens)-1] = last[:len(last)-1]
}
}
if err != nil && err.Error() == "EOF found when expecting closing quote" {
tokenset, err = split(s+`'`, pipelines)
tokenset, err = split(s+`_'`, pipelines)
if err == nil {
tokenset.State = OPEN_SINGLE
last := tokenset.Tokens[len(tokenset.Tokens)-1]
tokenset.Tokens[len(tokenset.Tokens)-1] = last[:len(last)-1]
}
}
return tokenset, err
Expand Down
1 change: 0 additions & 1 deletion internal/lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ func TestSplit(t *testing.T) {
State: OPEN_DOUBLE,
})

t.Skip("skipping test that don't work yet") // TODO these need to work
_test(`example "`, Tokenset{
Tokens: []string{"example", ""},
Prefix: `example `,
Expand Down

0 comments on commit 99682eb

Please sign in to comment.