File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import {
21
21
Parser ,
22
22
sequence ,
23
23
UnexpectedError ,
24
+ withPosition ,
24
25
withSource ,
25
26
} from "../src/parser/parser_lib.ts" ;
26
27
import { Definition , Noun , PartialVerb } from "./type.ts" ;
@@ -61,10 +62,15 @@ const semicolon = lex(matchString(";", "semicolon"));
61
62
const slash = lex ( matchString ( "/" , "slash" ) ) ;
62
63
63
64
const keyword = memoize ( < T extends string > ( keyword : T ) =>
64
- lex ( match ( / [ a - z \- ] + / , keyword ) )
65
- . filter ( ( that ) =>
66
- keyword === that ||
67
- throwError ( new UnexpectedError ( `"${ that } "` , `"${ keyword } "` ) )
65
+ lex ( withPosition ( match ( / [ a - z \- ] + / , keyword ) ) )
66
+ . map ( ( positioned ) =>
67
+ positioned . value === keyword ? positioned . value : throwError (
68
+ new UnexpectedError (
69
+ `"${ positioned . value } "` ,
70
+ `"${ keyword } "` ,
71
+ positioned ,
72
+ ) ,
73
+ )
68
74
) as Parser < T >
69
75
) ;
70
76
const unescapedWord = allAtLeastOnceWithCheck (
You can’t perform that action at this time.
0 commit comments