@@ -71,12 +71,12 @@ License: MIT
7171 - [Array](#Array)
7272 - [Optional](#Optional)
7373 - [Epsilon](#Epsilon)
74- - [Tokens](#Tokens)
75- - [Ident](#Ident)
76- - [Integer](#Integer)
77- - [BigInt](#BigInt)
74+ - [Token](#Token)
7875 - [Number](#Number)
7976 - [String](#String)
77+ - [Integer](#Integer)
78+ - [BigInt](#BigInt)
79+ - [Ident](#Ident)
8080- [Mapping](#Mapping)
8181- [Modules](#Modules)
8282- [Advanced](#Advanced)
@@ -235,29 +235,38 @@ const R1 = Runtime.Parse(T, 'X Y Z') // const R1 = [['X', 'Y'], '
235235const R2 = Runtime .Parse (T , ' Y Z' ) // const R2 = [[], 'Y Z']
236236```
237237
238- ## Tokens
238+ ## Token
239239
240240ParseBox includes several specialized combinators used to quickly parse common language tokens.
241241
242- ### Ident
242+ ### Number
243243
244- Parses an identifier
244+ Parses a number with fractional parts
245245
246246``` typescript
247- const Expression = Runtime .Number () // const Expression = { type: 'Number' }
247+ const T = Runtime .Number ()
248248
249- const Let = Runtime .Tuple ([ // const Let = {
250- Runtime .Const (' let' ), // type: 'Tuple',
251- Runtime .Ident (), // parsers: [
252- Runtime .Const (' =' ), // { type: 'Const', value: 'let' },
253- Expression // { type: 'Ident' },
254- ]) // { type: 'Const', value: '=' },
255- // { type: 'Number' },
256- // ]
257- // }
249+ // ...
258250
259- const R = Runtime .Parse (Let , ' let n = 10' ) // const R = [[ 'let', 'n', '=', '10'], '' ]
251+ const R1 = Runtime .Parse (T , ' 1' ) // const R1 = ['1', '']
252+
253+ const R2 = Runtime .Parse (T , ' 3.14' ) // const R2 = ['3.14', '']
254+
255+ const R3 = Runtime .Parse (T , ' .1' ) // const R3 = ['.1', '']
256+
257+ const E = Runtime .Parse (T , ' 01' ) // const E = ['0', '1']
258+ ```
259+
260+ ### String
261+
262+ The String combinator parses quoted string literals, accepting an array of permissible quote characters. The result is the interior string.
263+
264+ ``` typescript
265+ const T = Runtime .String ([' "' ])
266+
267+ // ...
260268
269+ const R = Runtime .Parse (T , ' "hello"' ) // const R = ['hello', '']
261270```
262271
263272### Integer
@@ -296,39 +305,27 @@ const R3 = Runtime.Parse(T, '.1n') // const R3 = []
296305const E = Runtime .Parse (T , ' 01n' ) // const E = []
297306```
298307
299- ### Number
300-
301- Parses a number with fractional parts
302-
303- ``` typescript
304- const T = Runtime .Number ()
305-
306- // ...
307-
308- const R1 = Runtime .Parse (T , ' 1' ) // const R1 = ['1', '']
309-
310- const R2 = Runtime .Parse (T , ' 3.14' ) // const R2 = ['3.14', '']
311-
312- const R3 = Runtime .Parse (T , ' .1' ) // const R3 = ['.1', '']
313-
314- const E = Runtime .Parse (T , ' 01' ) // const E = ['0', '1']
315- ```
316308
317- ### String
309+ ### Ident
318310
319- The String combinator parses quoted string literals, accepting an array of permissible quote characters. The result is the interior string.
311+ Parses an identifier
320312
321313``` typescript
322- const T = Runtime .String ([' "' ])
314+ const Let = Runtime .Tuple ([ // const Let = {
315+ Runtime .Const (' let' ), // type: 'Tuple',
316+ Runtime .Ident (), /* here */ // parsers: [
317+ Runtime .Const (' =' ), // { type: 'Const', value: 'let' },
318+ Runtime .Number () // { type: 'Ident' },
319+ ]) // { type: 'Const', value: '=' },
320+ // { type: 'Number' },
321+ // ]
322+ // }
323323
324- // ...
324+ const R = Runtime . Parse ( Let , ' let n = 10 ' ) // const R = [[ 'let', 'n', '=', '10'], '' ]
325325
326- const R = Runtime .Parse (T , ' "hello"' ) // const R = ['hello', '']
327326```
328327
329328
330-
331-
332329## Mapping
333330
334331ParseBox supports semantic actions (i.e., mappings) for both static and runtime parsing, enabling parsed content to be transformed into complex structures like abstract syntax trees (ASTs). Below is an explanation of how mapping works in both environments.
0 commit comments