9 Commits

Author SHA1 Message Date
amery b76b9044bf parser: Unescaped [WIP]
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 18:51:46 +00:00
amery 7968b06d7e build-sys: use local darvaza.org/core [DO-NOT-MERGE]
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 18:19:54 +00:00
amery 8b0bb69809 build-sys: use local asciigoat.org/core [DO-NOT-MERGE]
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 18:19:54 +00:00
amery c9f75bf74a vscode: add Subname to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 18:19:54 +00:00
amery 4336ced6a8 vscode: add unescapes to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 18:19:54 +00:00
amery 67a8fb1387 vscode: add asciigoat to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 18:19:54 +00:00
amery fa8eec7aa1 Merge branch 'pr-amery-parser-quoted' into next-amery 2023-09-04 18:19:45 +00:00
amery beb7c29fed parser: introduce SplitCommaArray to splits comma separated strings
removing whitespace and respecting quoted literals.

Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 18:17:03 +00:00
amery b16aa02140 parser: Unquoted(), AcceptQuotedString()
TODO: reduce quoted strings with escaped characters

Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 18:14:39 +00:00
2 changed files with 3 additions and 5 deletions
-3
View File
@@ -49,9 +49,6 @@ func newErrIncomplete(p *TextParser, hint string) *lexer.Error {
return NewError(pos, s, hint, fs.ErrInvalid)
}
// NewErrInvalidEscapeSequence returns a [lexer.Error] indicating
// the specified sequence, at the end of the accepted buffer,
// is invalid
func NewErrInvalidEscapeSequence(p *TextParser, seq string) *lexer.Error {
pos, s := p.Position(), p.String()
+3 -2
View File
@@ -76,7 +76,7 @@ func lexQuotedStringEscaped(p *TextParser) (string, *lexer.Error) {
var result strings.Builder
// append what was accepted before the escape character
_, _ = result.WriteString(p.String()[1:])
result.WriteString(p.String()[1:])
for {
r, _, err := p.ReadRune()
@@ -101,13 +101,14 @@ func lexQuotedStringEscaped(p *TextParser) (string, *lexer.Error) {
default:
// TODO: check valid escape character and
// append to result
p.UnreadRune()
s := string([]rune{r, r2})
err := NewErrInvalidEscapeSequence(p, s)
return "", err
}
default:
// normal, append to result
_, _ = result.WriteRune(r)
result.WriteRune(r)
}
}
}