Repair span of identifier after `$`
This commit is contained in:
parent
da97db8548
commit
2dca2c2d77
|
@ -2,9 +2,10 @@
|
|||
/// SPDX-FileCopyrightText: Copyright © 2016-2024 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||
|
||||
import {
|
||||
Token, Items, TokenBase, TokenType,
|
||||
Token, Items, TokenBase, TokenType, Pos,
|
||||
Pattern,
|
||||
foldItems, match, anonymousTemplate as template, commaJoin,
|
||||
advancePos,
|
||||
|
||||
scope, bind, seq, seqTuple, alt, upTo, atom, atomString, group,
|
||||
repeat, option, withoutSpace, map, mapm, rest, discard,
|
||||
|
@ -410,9 +411,18 @@ export class SyndicateParser {
|
|||
|
||||
pCaptureBinder = (b: Pattern<Binder>): Pattern<Binder> =>
|
||||
mapm(b, i => {
|
||||
return i.id.text.startsWith('$')
|
||||
? succeed({ id: { ... i.id, text: i.id.text.slice(1) }, type: i.type })
|
||||
: fail;
|
||||
if (i.id.text.startsWith('$')) {
|
||||
const adjustedStart: Pos = { ... i.id.start };
|
||||
advancePos(adjustedStart, ' ');
|
||||
const adjustedId: Token = {
|
||||
... i.id,
|
||||
start: adjustedStart,
|
||||
text: i.id.text.slice(1),
|
||||
};
|
||||
return succeed({ id: adjustedId, type: i.type });
|
||||
} else {
|
||||
return fail;
|
||||
}
|
||||
});
|
||||
readonly pCaptureDefaultBinder = this.pCaptureBinder(this.defaultBinder);
|
||||
|
||||
|
|
Loading…
Reference in New Issue