Parse¶
parse reads a series with a block of rules, a dialect of its own for matching text and blocks. See
parse.
parse¶
Checks the input against a block of rules; true if they match all of it.
parse input rules
input(series!)rules(block!)/case
The rules are a block. In it, a value matches itself in the input, and a word matches what it names: a
string, a character, a bitset made with charset, another block of rules. In a block, a datatype such as
integer! matches any value of it. Rules written one after another match one after another; | separates
alternatives, tried in order. These words do the rest:
Rule |
Matches |
|---|---|
|
the rule, or nothing |
|
the rule once or more, as many times as it can |
|
the rule as many times as it can, none included |
|
like |
|
the rule exactly 3 times, from 2 to 4 times |
|
any one value |
|
everything up to the rule; up to and including it |
|
the end of the input |
|
the value itself, even when it is a word or an integer |
|
nothing, when the rule does not match here |
|
nothing, when the rule does match here |
|
a block (or string) in the input, matched inside by the rule |
|
nothing, always |
|
never |
|
nothing, when the code gives a true value |
|
nothing: leave the rule block as a match (and end a repetition it is in) |
|
leave the rule block as a failure |
|
stop |
These keep or change what was matched:
Rule |
Does |
|---|---|
|
runs the code, where it is in the rules |
|
sets the word to the input at this position; moves the input to where the word says |
|
sets the word to the first value the rule matched |
|
sets the word to a copy of all the rule matched |
|
|
|
the same block, set to the word; |
|
removes what the rule matched from the input |
|
puts the value into the input here ( |
|
changes what the rule matched for the value |
Without /case, text matches whatever its case: "Chain" matches "chain".
charset¶
Makes a bitset of characters, for parse.
charset spec
spec(char!integer!any-string!binary!block!)
complement¶
The opposite: a bitset of everything else, a logic negated, an integer with its bits flipped.
complement value
value(bitset!logic!integer!)