public bool ReadIdentifier(ITokenResult result = null) { // perf: using Character.IsIdentifierStart instead of x => Character.IsIdentifierStart(x) induces some allocations return(ReadFirstThenOthers(static x => Character.IsIdentifierStart(x), static x => Character.IsIdentifierPart(x), result));
public bool ReadFirstThenOthers(Func <char, bool> first, Func <char, bool> other, ITokenResult result = null) { if (!first(Cursor.Current)) { result?.Fail(); return(false); } var start = Cursor.Position; // At this point we have an identifier, read while it's an identifier part. Cursor.Advance(); ReadWhile(other, null); result?.Succeed(Buffer, start, Cursor.Position); return(true); }