File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed
Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import { ArrayResultError } from "../src/array_result.ts";
88import {
99 all ,
1010 allAtLeastOnce ,
11- character ,
1211 choiceOnlyOne ,
1312 end ,
1413 match ,
@@ -32,6 +31,7 @@ const comment = match(/#[^\n]*\n?/, "comment");
3231const spaces = sourceOnly ( all ( choiceOnlyOne ( match ( / \s / , "space" ) , comment ) ) ) ;
3332const backtick = matchString ( "`" , "backtick" ) ;
3433const colon = matchString ( ":" , "colon" ) ;
34+ const character = match ( / ./ u, "character" ) ;
3535
3636const tokiPonaWord = lex ( match ( / [ a - z ] [ a - z A - Z ] * / , "word" ) ) ;
3737const openParenthesis = lex ( matchString ( "(" , "open parenthesis" ) ) ;
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ import {
4949 count ,
5050 empty ,
5151 end ,
52- everything ,
52+ allRest ,
5353 lazy ,
5454 lookAhead ,
5555 many ,
@@ -715,7 +715,7 @@ const sentence = choice<Sentence>(
715715 . filter ( filter ( SENTENCE_RULE ) ) ;
716716export const parser = spaces
717717 . with (
718- lookAhead ( everything . filter ( ( source ) =>
718+ lookAhead ( allRest . filter ( ( source ) =>
719719 source . trimEnd ( ) . length <= 500 ||
720720 throwError ( new UnrecognizedError ( "long text" ) )
721721 ) ) ,
Original file line number Diff line number Diff line change @@ -178,7 +178,9 @@ export function allAtLeastOnce<T>(parser: Parser<T>): Parser<ReadonlyArray<T>> {
178178 return sequence ( parser , all ( parser ) )
179179 . map ( ( [ first , rest ] ) => [ first , ...rest ] ) ;
180180}
181- export function count ( parser : Parser < { length : number } > ) : Parser < number > {
181+ export function count (
182+ parser : Parser < Readonly < { length : number } > > ,
183+ ) : Parser < number > {
182184 return parser . map ( ( { length } ) => length ) ;
183185}
184186function describeSource ( source : string ) : string {
@@ -240,13 +242,12 @@ export function matchString(
240242 }
241243 } ) ;
242244}
243- export const everything = new Parser ( ( position ) =>
245+ export const allRest = new Parser ( ( position ) =>
244246 new ArrayResult ( [ {
245247 value : currentSource . slice ( position ) ,
246248 length : currentSource . length - position ,
247249 } ] )
248250) ;
249- export const character = match ( / ./ us, "character" ) ;
250251export const end = new Parser ( ( position ) =>
251252 position === currentSource . length
252253 ? new ArrayResult ( [ { value : null , length : 0 } ] )
You can’t perform that action at this time.
0 commit comments