Changeset 13287 in project


Ignore:
Timestamp:
02/13/09 07:46:27 (11 years ago)
Author:
Ivan Raikov
Message:

Added documentation about new procedure try and tok.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/lexgen

    r13262 r13287  
    2828==== Basic procedures
    2929
    30 <procedure>(pred TOKEN PROC) => MATCHER</procedure>
     30<procedure>(tok TOKEN PROC) => MATCHER</procedure>
    3131
    32 Procedure {{pred}} builds a pattern matcher function that, for each
    33 stream given, applies a predicate to the given token {{TOKEN}} and an
    34 input character. If the predicate returns true, the character is
    35 prepended to the list of the consumed characters in the corresponding
    36 stream.
     32Procedure {{tok}} builds a pattern matcher function that, for each
     33stream given, applies a procedure to the given token {{TOKEN}} and an
     34input character. If the procedure returns a true value, that value is
     35prepended to the list of consumed elements, and the input character is
     36removed from the list of input elements.
    3737
    3838<procedure>(seq MATCHER-LIST) => MATCHER</procedure>
     
    5656for convenience.
    5757
     58<procedure>(try PROC) => PROC</procedure>
     59
     60Converts a binary predicate procedure to a binary procedure that
     61returns its right argument when the predicate is true, and false
     62otherwise.
     63
     64<procedure>(char CHAR) => MATCHER</procedure>
     65
     66Matches a single character.
     67
    5868<procedure>(pos MATCHER) => MATCHER</procedure>
    5969
     
    6373
    6474Optional pattern. Analogous to {{?}}.
    65 
    66 <procedure>(char CHAR) => MATCHER</procedure>
    67 
    68 Matches a single character.
    6975
    7076<procedure>(set CHAR-SET) => MATCHER</procedure>
     
    98104=== Examples
    99105
    100   (define a-pat (pred #\a char=?))
    101   (define b-pat (pred #\b char=?))
     106  (define a-pat (tok #\a (try char=?)))
     107  (define b-pat (tok #\b (try char=?)))
    102108  (define a-then-b-pat (seq (list a-pat b-pat)))
    103109  (define a-or-b-pat (seq (list a-pat b-pat)))
     
    131137=== Version History
    132138
     139* 1.2 Added procedures try and tok (supersedes pred)
    133140* 1.0 Initial release
    134141
Note: See TracChangeset for help on using the changeset viewer.