-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
Description
anyCharOf and charCodeWhere aren't adequate when parsing strings containing unicode characters:
import { anyCharOf, charCodeWhere, string } from "parjs";
import { qthen } from "parjs/combinators";
const s = "🥔";
const p1 = anyCharOf(s);
const p2 = charCodeWhere((x) => x === s.codePointAt(0) || { reason: "Bar" });
console.log([
p1.parse(s),
p2.parse(s),
]);give the following result
[
ParjsFailure {
trace: {
userState: ParserUserState {},
position: 1,
reason: 'parsers did not consume all input',
input: '🥔',
location: [Getter],
stackTrace: [],
kind: 'Soft'
}
},
ParjsFailure {
trace: {
userState: ParserUserState {},
position: 0,
reason: 'Bar',
input: '🥔',
location: [Getter],
stackTrace: [Array],
kind: 'Soft'
}
}
]
Not unexpected, but I would like to be able to do something like this.
Reactions are currently unavailable