10 Commits

Author SHA1 Message Date
amery 3bf20948c0 parser: Unescaped [WIP]
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-05 13:22:39 +00:00
amery 0dd29272e9 build-sys: use local darvaza.org/core [DO-NOT-MERGE]
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-05 13:22:09 +00:00
amery 7fab1a799a build-sys: use local asciigoat.org/core [DO-NOT-MERGE]
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-05 13:22:09 +00:00
amery 16dfde1503 vscode: add Subname to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-05 13:22:09 +00:00
amery 41d7c6e04d vscode: add unescapes to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-05 13:22:09 +00:00
amery 48adaeb8a8 vscode: add asciigoat to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-05 13:22:09 +00:00
amery 99ca8d0b3b Merge branch 'pr-amery-basic' into next-amery 2023-09-05 13:22:01 +00:00
amery 986b6d1c6d Merge pull request 'parser: Unquoted(), AcceptQuotedString() and SplitCommaArray' (#9)
Reviewed-on: #9
2023-09-05 15:20:38 +02:00
amery d41cd781d9 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:58:06 +00:00
amery 651fcb6215 parser: Unquoted(), AcceptQuotedString()
TODO: reduce quoted strings with escaped characters

Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 18:58:06 +00:00
2 changed files with 5 additions and 3 deletions
+3
View File
@@ -49,6 +49,9 @@ 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()
+2 -3
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,14 +101,13 @@ 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)
}
}
}