commit
8e5f513192
1 changed files with 3 additions and 3 deletions
|
|
@ -76,7 +76,7 @@ to a variable (that was passed to the ``scanf`` macro) while ``$[]`` merely
|
||||||
optional tokens.
|
optional tokens.
|
||||||
|
|
||||||
|
|
||||||
In this example, we define a helper proc ``skipSep`` that skips some separators
|
In this example, we define a helper proc ``someSep`` that skips some separators
|
||||||
which we then use in our scanf pattern to help us in the matching process:
|
which we then use in our scanf pattern to help us in the matching process:
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
|
|
@ -86,14 +86,14 @@ which we then use in our scanf pattern to help us in the matching process:
|
||||||
result = 0
|
result = 0
|
||||||
while input[start+result] in seps: inc result
|
while input[start+result] in seps: inc result
|
||||||
|
|
||||||
if scanf(input, "$w${someSep}$w", key, value):
|
if scanf(input, "$w$[someSep]$w", key, value):
|
||||||
...
|
...
|
||||||
|
|
||||||
It also possible to pass arguments to a user definable matcher:
|
It also possible to pass arguments to a user definable matcher:
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
|
|
||||||
proc ndigits(input: string; start: int; intVal: var int; n: int): int =
|
proc ndigits(input: string; intVal: var int; start: int; n: int): int =
|
||||||
# matches exactly ``n`` digits. Matchers need to return 0 if nothing
|
# matches exactly ``n`` digits. Matchers need to return 0 if nothing
|
||||||
# matched or otherwise the number of processed chars.
|
# matched or otherwise the number of processed chars.
|
||||||
var x = 0
|
var x = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue