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 {
2121 Parser ,
2222 sequence ,
2323 UnexpectedError ,
24+ withPosition ,
2425 withSource ,
2526} from "../src/parser/parser_lib.ts" ;
2627import { Definition , Noun , PartialVerb } from "./type.ts" ;
@@ -61,10 +62,15 @@ const semicolon = lex(matchString(";", "semicolon"));
6162const slash = lex ( matchString ( "/" , "slash" ) ) ;
6263
6364const 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+ )
6874 ) as Parser < T >
6975) ;
7076const unescapedWord = allAtLeastOnceWithCheck (
You can’t perform that action at this time.
0 commit comments