File tree 3 files changed +7
-6
lines changed
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";
8
8
import {
9
9
all ,
10
10
allAtLeastOnce ,
11
- character ,
12
11
choiceOnlyOne ,
13
12
end ,
14
13
match ,
@@ -32,6 +31,7 @@ const comment = match(/#[^\n]*\n?/, "comment");
32
31
const spaces = sourceOnly ( all ( choiceOnlyOne ( match ( / \s / , "space" ) , comment ) ) ) ;
33
32
const backtick = matchString ( "`" , "backtick" ) ;
34
33
const colon = matchString ( ":" , "colon" ) ;
34
+ const character = match ( / ./ u, "character" ) ;
35
35
36
36
const tokiPonaWord = lex ( match ( / [ a - z ] [ a - z A - Z ] * / , "word" ) ) ;
37
37
const openParenthesis = lex ( matchString ( "(" , "open parenthesis" ) ) ;
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ import {
49
49
count ,
50
50
empty ,
51
51
end ,
52
- everything ,
52
+ allRest ,
53
53
lazy ,
54
54
lookAhead ,
55
55
many ,
@@ -715,7 +715,7 @@ const sentence = choice<Sentence>(
715
715
. filter ( filter ( SENTENCE_RULE ) ) ;
716
716
export const parser = spaces
717
717
. with (
718
- lookAhead ( everything . filter ( ( source ) =>
718
+ lookAhead ( allRest . filter ( ( source ) =>
719
719
source . trimEnd ( ) . length <= 500 ||
720
720
throwError ( new UnrecognizedError ( "long text" ) )
721
721
) ) ,
Original file line number Diff line number Diff line change @@ -178,7 +178,9 @@ export function allAtLeastOnce<T>(parser: Parser<T>): Parser<ReadonlyArray<T>> {
178
178
return sequence ( parser , all ( parser ) )
179
179
. map ( ( [ first , rest ] ) => [ first , ...rest ] ) ;
180
180
}
181
- export function count ( parser : Parser < { length : number } > ) : Parser < number > {
181
+ export function count (
182
+ parser : Parser < Readonly < { length : number } > > ,
183
+ ) : Parser < number > {
182
184
return parser . map ( ( { length } ) => length ) ;
183
185
}
184
186
function describeSource ( source : string ) : string {
@@ -240,13 +242,12 @@ export function matchString(
240
242
}
241
243
} ) ;
242
244
}
243
- export const everything = new Parser ( ( position ) =>
245
+ export const allRest = new Parser ( ( position ) =>
244
246
new ArrayResult ( [ {
245
247
value : currentSource . slice ( position ) ,
246
248
length : currentSource . length - position ,
247
249
} ] )
248
250
) ;
249
- export const character = match ( / ./ us, "character" ) ;
250
251
export const end = new Parser ( ( position ) =>
251
252
position === currentSource . length
252
253
? new ArrayResult ( [ { value : null , length : 0 } ] )
You can’t perform that action at this time.
0 commit comments